OLD | NEW |
---|---|
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 4095 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4106 ACCESSORS(GlobalObject, global_context, Context, kGlobalContextOffset) | 4106 ACCESSORS(GlobalObject, global_context, Context, kGlobalContextOffset) |
4107 ACCESSORS(GlobalObject, global_receiver, JSObject, kGlobalReceiverOffset) | 4107 ACCESSORS(GlobalObject, global_receiver, JSObject, kGlobalReceiverOffset) |
4108 | 4108 |
4109 ACCESSORS(JSGlobalProxy, native_context, Object, kNativeContextOffset) | 4109 ACCESSORS(JSGlobalProxy, native_context, Object, kNativeContextOffset) |
4110 | 4110 |
4111 ACCESSORS(AccessorInfo, name, Object, kNameOffset) | 4111 ACCESSORS(AccessorInfo, name, Object, kNameOffset) |
4112 ACCESSORS_TO_SMI(AccessorInfo, flag, kFlagOffset) | 4112 ACCESSORS_TO_SMI(AccessorInfo, flag, kFlagOffset) |
4113 ACCESSORS(AccessorInfo, expected_receiver_type, Object, | 4113 ACCESSORS(AccessorInfo, expected_receiver_type, Object, |
4114 kExpectedReceiverTypeOffset) | 4114 kExpectedReceiverTypeOffset) |
4115 | 4115 |
4116 ACCESSORS(DeclaredAccessorDescriptor, internal_field, Smi, kInternalFieldOffset) | 4116 ACCESSORS(DeclaredAccessorDescriptor, serialized_descriptor, ByteArray, |
4117 kSerializedDescriptorOffset) | |
4117 | 4118 |
4118 ACCESSORS(DeclaredAccessorInfo, descriptor, DeclaredAccessorDescriptor, | 4119 ACCESSORS(DeclaredAccessorInfo, descriptor, DeclaredAccessorDescriptor, |
4119 kDescriptorOffset) | 4120 kDescriptorOffset) |
4120 | 4121 |
4121 ACCESSORS(ExecutableAccessorInfo, getter, Object, kGetterOffset) | 4122 ACCESSORS(ExecutableAccessorInfo, getter, Object, kGetterOffset) |
4122 ACCESSORS(ExecutableAccessorInfo, setter, Object, kSetterOffset) | 4123 ACCESSORS(ExecutableAccessorInfo, setter, Object, kSetterOffset) |
4123 ACCESSORS(ExecutableAccessorInfo, data, Object, kDataOffset) | 4124 ACCESSORS(ExecutableAccessorInfo, data, Object, kDataOffset) |
4124 | 4125 |
4125 ACCESSORS(AccessorPair, getter, Object, kGetterOffset) | 4126 ACCESSORS(AccessorPair, getter, Object, kGetterOffset) |
4126 ACCESSORS(AccessorPair, setter, Object, kSetterOffset) | 4127 ACCESSORS(AccessorPair, setter, Object, kSetterOffset) |
(...skipping 1367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5494 } | 5495 } |
5495 | 5496 |
5496 | 5497 |
5497 bool AccessorInfo::IsCompatibleReceiver(Object* receiver) { | 5498 bool AccessorInfo::IsCompatibleReceiver(Object* receiver) { |
5498 Object* function_template = expected_receiver_type(); | 5499 Object* function_template = expected_receiver_type(); |
5499 if (!function_template->IsFunctionTemplateInfo()) return true; | 5500 if (!function_template->IsFunctionTemplateInfo()) return true; |
5500 return receiver->IsInstanceOf(FunctionTemplateInfo::cast(function_template)); | 5501 return receiver->IsInstanceOf(FunctionTemplateInfo::cast(function_template)); |
5501 } | 5502 } |
5502 | 5503 |
5503 | 5504 |
5505 template<int size> | |
Sven Panne
2013/02/19 08:41:16
I'm again not sure if we need this massive machine
| |
5506 struct AccessorDescriptorSerializationHelper { | |
5507 }; | |
5508 template<> | |
5509 struct AccessorDescriptorSerializationHelper<1> { | |
5510 typedef uint8_t UType; | |
5511 }; | |
5512 template<> | |
5513 struct AccessorDescriptorSerializationHelper<2> { | |
5514 typedef uint16_t UType; | |
5515 }; | |
5516 template<> | |
5517 struct AccessorDescriptorSerializationHelper<4> { | |
5518 typedef uint32_t UType; | |
5519 }; | |
5520 template<> | |
5521 struct AccessorDescriptorSerializationHelper<8> { | |
5522 typedef uint64_t UType; | |
5523 }; | |
5524 | |
5525 | |
5526 template<typename Value> | |
5527 struct AccessorDescriptorSerialization { | |
5528 static const int kArraySize = sizeof(Value); | |
5529 typedef AccessorDescriptorSerializationHelper<kArraySize> Helper; | |
5530 typedef typename Helper::UType UType; | |
5531 static inline UType ToUType(Value value) { | |
5532 return static_cast<UType>(value); | |
5533 } | |
5534 static inline Value FromUType(UType utype) { | |
5535 return static_cast<Value>(utype); | |
5536 } | |
5537 static inline void Serialize(Value value, uint8_t array[kArraySize]) { | |
5538 UType u_type = ToUType(value); | |
5539 for (int i = 0; i < kArraySize; i++) { | |
5540 array[i] = static_cast<uint8_t>(u_type >> (8 * i)); | |
5541 } | |
5542 } | |
5543 static inline Value Deserialize(uint8_t array[kArraySize]) { | |
5544 UType temp = 0; | |
5545 for (int i = 0; i < kArraySize; i++) { | |
5546 temp |= static_cast<UType>(array[i]) << (8 * i); | |
5547 } | |
5548 return FromUType(temp); | |
5549 } | |
5550 }; | |
5551 | |
5552 | |
5553 template<> | |
5554 inline AccessorDescriptorSerialization<void*>::UType | |
5555 AccessorDescriptorSerialization<void*>::ToUType(void* value) { | |
5556 return reinterpret_cast<UType>(value); | |
5557 } | |
5558 | |
5559 | |
5560 template<> | |
5561 inline void* AccessorDescriptorSerialization<void*>::FromUType( | |
5562 AccessorDescriptorSerialization<void*>::UType utype) { | |
5563 return reinterpret_cast<void*>(utype); | |
5564 } | |
5565 | |
5566 | |
5567 AccessorDescriptorDeserializer::AccessorDescriptorDeserializer( | |
5568 uint16_t length, uint8_t* storage) : | |
5569 AccessorDescriptorSerializerBase(length, storage), visited_(true) { | |
5570 } | |
5571 | |
5572 | |
5573 void AccessorDescriptorDeserializer::Next(v8::AccessorDescriptor* descriptor) { | |
5574 ASSERT(!Complete()); | |
5575 descriptor->derefence_descriptor = NULL; | |
5576 visited_ = false; | |
5577 v8::DescriptorVisitorHelper::VisitDescriptor(descriptor, this); | |
5578 } | |
5579 | |
5580 | |
5581 template<typename T> | |
5582 bool AccessorDescriptorDeserializer::ShouldVisit(T* descriptor) { | |
5583 ASSERT(descriptor != NULL); | |
5584 return true; | |
5585 } | |
5586 | |
5587 | |
5588 bool AccessorDescriptorDeserializer::ShouldVisit( | |
5589 v8::AccessorDescriptor* descriptor) { | |
5590 if (visited_) { | |
5591 ASSERT(descriptor == NULL); | |
5592 return false; | |
5593 } | |
5594 ASSERT(descriptor != NULL); | |
5595 visited_ = true; | |
5596 return true; | |
5597 } | |
5598 | |
5599 | |
5600 template<typename T> | |
5601 void AccessorDescriptorDeserializer::Visit(T* member) { | |
5602 typedef AccessorDescriptorSerialization<T> Ser; | |
5603 ASSERT(offset_ + Ser::kArraySize <= length_); | |
5604 *member = Ser::Deserialize(&storage_[offset_]); | |
5605 offset_ += Ser::kArraySize; | |
5606 } | |
5607 | |
5608 | |
5504 template<typename Shape, typename Key> | 5609 template<typename Shape, typename Key> |
5505 void Dictionary<Shape, Key>::SetEntry(int entry, | 5610 void Dictionary<Shape, Key>::SetEntry(int entry, |
5506 Object* key, | 5611 Object* key, |
5507 Object* value) { | 5612 Object* value) { |
5508 SetEntry(entry, key, value, PropertyDetails(Smi::FromInt(0))); | 5613 SetEntry(entry, key, value, PropertyDetails(Smi::FromInt(0))); |
5509 } | 5614 } |
5510 | 5615 |
5511 | 5616 |
5512 template<typename Shape, typename Key> | 5617 template<typename Shape, typename Key> |
5513 void Dictionary<Shape, Key>::SetEntry(int entry, | 5618 void Dictionary<Shape, Key>::SetEntry(int entry, |
(...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5902 #undef WRITE_UINT32_FIELD | 6007 #undef WRITE_UINT32_FIELD |
5903 #undef READ_SHORT_FIELD | 6008 #undef READ_SHORT_FIELD |
5904 #undef WRITE_SHORT_FIELD | 6009 #undef WRITE_SHORT_FIELD |
5905 #undef READ_BYTE_FIELD | 6010 #undef READ_BYTE_FIELD |
5906 #undef WRITE_BYTE_FIELD | 6011 #undef WRITE_BYTE_FIELD |
5907 | 6012 |
5908 | 6013 |
5909 } } // namespace v8::internal | 6014 } } // namespace v8::internal |
5910 | 6015 |
5911 #endif // V8_OBJECTS_INL_H_ | 6016 #endif // V8_OBJECTS_INL_H_ |
OLD | NEW |