Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(237)

Unified Diff: src/objects-inl.h

Issue 12297012: Runtime version of declarative native accessors. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/objects-inl.h
diff --git a/src/objects-inl.h b/src/objects-inl.h
index 28c11a646092590960f091e8e5718ccd2fcf9499..32aa2a28daf62d51055c70cb7bcc3234bbce9178 100644
--- a/src/objects-inl.h
+++ b/src/objects-inl.h
@@ -4113,7 +4113,8 @@ ACCESSORS_TO_SMI(AccessorInfo, flag, kFlagOffset)
ACCESSORS(AccessorInfo, expected_receiver_type, Object,
kExpectedReceiverTypeOffset)
-ACCESSORS(DeclaredAccessorDescriptor, internal_field, Smi, kInternalFieldOffset)
+ACCESSORS(DeclaredAccessorDescriptor, serialized_descriptor, ByteArray,
+ kSerializedDescriptorOffset)
ACCESSORS(DeclaredAccessorInfo, descriptor, DeclaredAccessorDescriptor,
kDescriptorOffset)
@@ -5501,6 +5502,110 @@ bool AccessorInfo::IsCompatibleReceiver(Object* receiver) {
}
+template<int size>
Sven Panne 2013/02/19 08:41:16 I'm again not sure if we need this massive machine
+struct AccessorDescriptorSerializationHelper {
+};
+template<>
+struct AccessorDescriptorSerializationHelper<1> {
+ typedef uint8_t UType;
+};
+template<>
+struct AccessorDescriptorSerializationHelper<2> {
+ typedef uint16_t UType;
+};
+template<>
+struct AccessorDescriptorSerializationHelper<4> {
+ typedef uint32_t UType;
+};
+template<>
+struct AccessorDescriptorSerializationHelper<8> {
+ typedef uint64_t UType;
+};
+
+
+template<typename Value>
+struct AccessorDescriptorSerialization {
+ static const int kArraySize = sizeof(Value);
+ typedef AccessorDescriptorSerializationHelper<kArraySize> Helper;
+ typedef typename Helper::UType UType;
+ static inline UType ToUType(Value value) {
+ return static_cast<UType>(value);
+ }
+ static inline Value FromUType(UType utype) {
+ return static_cast<Value>(utype);
+ }
+ static inline void Serialize(Value value, uint8_t array[kArraySize]) {
+ UType u_type = ToUType(value);
+ for (int i = 0; i < kArraySize; i++) {
+ array[i] = static_cast<uint8_t>(u_type >> (8 * i));
+ }
+ }
+ static inline Value Deserialize(uint8_t array[kArraySize]) {
+ UType temp = 0;
+ for (int i = 0; i < kArraySize; i++) {
+ temp |= static_cast<UType>(array[i]) << (8 * i);
+ }
+ return FromUType(temp);
+ }
+};
+
+
+template<>
+inline AccessorDescriptorSerialization<void*>::UType
+ AccessorDescriptorSerialization<void*>::ToUType(void* value) {
+ return reinterpret_cast<UType>(value);
+}
+
+
+template<>
+inline void* AccessorDescriptorSerialization<void*>::FromUType(
+ AccessorDescriptorSerialization<void*>::UType utype) {
+ return reinterpret_cast<void*>(utype);
+}
+
+
+AccessorDescriptorDeserializer::AccessorDescriptorDeserializer(
+ uint16_t length, uint8_t* storage) :
+ AccessorDescriptorSerializerBase(length, storage), visited_(true) {
+}
+
+
+void AccessorDescriptorDeserializer::Next(v8::AccessorDescriptor* descriptor) {
+ ASSERT(!Complete());
+ descriptor->derefence_descriptor = NULL;
+ visited_ = false;
+ v8::DescriptorVisitorHelper::VisitDescriptor(descriptor, this);
+}
+
+
+template<typename T>
+bool AccessorDescriptorDeserializer::ShouldVisit(T* descriptor) {
+ ASSERT(descriptor != NULL);
+ return true;
+}
+
+
+bool AccessorDescriptorDeserializer::ShouldVisit(
+ v8::AccessorDescriptor* descriptor) {
+ if (visited_) {
+ ASSERT(descriptor == NULL);
+ return false;
+ }
+ ASSERT(descriptor != NULL);
+ visited_ = true;
+ return true;
+}
+
+
+template<typename T>
+void AccessorDescriptorDeserializer::Visit(T* member) {
+ typedef AccessorDescriptorSerialization<T> Ser;
+ ASSERT(offset_ + Ser::kArraySize <= length_);
+ *member = Ser::Deserialize(&storage_[offset_]);
+ offset_ += Ser::kArraySize;
+}
+
+
template<typename Shape, typename Key>
void Dictionary<Shape, Key>::SetEntry(int entry,
Object* key,

Powered by Google App Engine
This is Rietveld 408576698