Chromium Code Reviews| 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 2494 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2505 ASSERT(HasEnumCache()); | 2505 ASSERT(HasEnumCache()); |
| 2506 return HeapObject::RawField(reinterpret_cast<HeapObject*>(this), | 2506 return HeapObject::RawField(reinterpret_cast<HeapObject*>(this), |
| 2507 kEnumerationIndexOffset); | 2507 kEnumerationIndexOffset); |
| 2508 } | 2508 } |
| 2509 | 2509 |
| 2510 Object** GetTransitionsSlot() { | 2510 Object** GetTransitionsSlot() { |
| 2511 return HeapObject::RawField(reinterpret_cast<HeapObject*>(this), | 2511 return HeapObject::RawField(reinterpret_cast<HeapObject*>(this), |
| 2512 kTransitionsOffset); | 2512 kTransitionsOffset); |
| 2513 } | 2513 } |
| 2514 | 2514 |
| 2515 // TODO(1399): It should be possible to make room for bit_field3 in the map | 2515 DECL_ACCESSORS(back_pointer_storage, Object) |
| 2516 // without overloading the instance descriptors field in the map | |
| 2517 // (and storing it in the DescriptorArray when the map has one). | |
| 2518 inline int bit_field3_storage(); | |
| 2519 inline void set_bit_field3_storage(int value); | |
| 2520 | 2516 |
| 2521 // Initialize or change the enum cache, | 2517 // Initialize or change the enum cache, |
| 2522 // using the supplied storage for the small "bridge". | 2518 // using the supplied storage for the small "bridge". |
| 2523 void SetEnumCache(FixedArray* bridge_storage, | 2519 void SetEnumCache(FixedArray* bridge_storage, |
| 2524 FixedArray* new_cache, | 2520 FixedArray* new_cache, |
| 2525 Object* new_index_cache); | 2521 Object* new_index_cache); |
| 2526 | 2522 |
| 2527 // Accessors for fetching instance descriptor at descriptor number. | 2523 // Accessors for fetching instance descriptor at descriptor number. |
| 2528 inline String* GetKey(int descriptor_number); | 2524 inline String* GetKey(int descriptor_number); |
| 2529 inline Object** GetKeySlot(int descriptor_number); | 2525 inline Object** GetKeySlot(int descriptor_number); |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2598 // empty descriptor array object if number_of_descriptors is 0. | 2594 // empty descriptor array object if number_of_descriptors is 0. |
| 2599 MUST_USE_RESULT static MaybeObject* Allocate(int number_of_descriptors, | 2595 MUST_USE_RESULT static MaybeObject* Allocate(int number_of_descriptors, |
| 2600 SharedMode shared_mode); | 2596 SharedMode shared_mode); |
| 2601 | 2597 |
| 2602 // Casting. | 2598 // Casting. |
| 2603 static inline DescriptorArray* cast(Object* obj); | 2599 static inline DescriptorArray* cast(Object* obj); |
| 2604 | 2600 |
| 2605 // Constant for denoting key was not found. | 2601 // Constant for denoting key was not found. |
| 2606 static const int kNotFound = -1; | 2602 static const int kNotFound = -1; |
| 2607 | 2603 |
| 2608 static const int kBitField3StorageIndex = 0; | 2604 static const int kBackPointerStorageIndex = 0; |
| 2609 static const int kEnumerationIndexIndex = 1; | 2605 static const int kEnumerationIndexIndex = 1; |
| 2610 static const int kTransitionsIndex = 2; | 2606 static const int kTransitionsIndex = 2; |
| 2611 static const int kFirstIndex = 3; | 2607 static const int kFirstIndex = 3; |
| 2612 | 2608 |
| 2613 // The length of the "bridge" to the enum cache. | 2609 // The length of the "bridge" to the enum cache. |
| 2614 static const int kEnumCacheBridgeLength = 3; | 2610 static const int kEnumCacheBridgeLength = 3; |
| 2615 static const int kEnumCacheBridgeEnumIndex = 0; | 2611 static const int kEnumCacheBridgeEnumIndex = 0; |
| 2616 static const int kEnumCacheBridgeCacheIndex = 1; | 2612 static const int kEnumCacheBridgeCacheIndex = 1; |
| 2617 static const int kEnumCacheBridgeIndicesCacheIndex = 2; | 2613 static const int kEnumCacheBridgeIndicesCacheIndex = 2; |
| 2618 | 2614 |
| 2619 // Layout description. | 2615 // Layout description. |
| 2620 static const int kBitField3StorageOffset = FixedArray::kHeaderSize; | 2616 static const int kBackPointerStorageOffset = FixedArray::kHeaderSize; |
| 2621 static const int kEnumerationIndexOffset = kBitField3StorageOffset + | 2617 static const int kEnumerationIndexOffset = kBackPointerStorageOffset + |
| 2622 kPointerSize; | 2618 kPointerSize; |
| 2623 static const int kTransitionsOffset = kEnumerationIndexOffset + kPointerSize; | 2619 static const int kTransitionsOffset = kEnumerationIndexOffset + kPointerSize; |
| 2624 static const int kFirstOffset = kTransitionsOffset + kPointerSize; | 2620 static const int kFirstOffset = kTransitionsOffset + kPointerSize; |
| 2625 | 2621 |
| 2626 // Layout description for the bridge array. | 2622 // Layout description for the bridge array. |
| 2627 static const int kEnumCacheBridgeEnumOffset = FixedArray::kHeaderSize; | 2623 static const int kEnumCacheBridgeEnumOffset = FixedArray::kHeaderSize; |
| 2628 static const int kEnumCacheBridgeCacheOffset = | 2624 static const int kEnumCacheBridgeCacheOffset = |
| 2629 kEnumCacheBridgeEnumOffset + kPointerSize; | 2625 kEnumCacheBridgeEnumOffset + kPointerSize; |
| 2630 | 2626 |
| 2631 // Layout of descriptor. | 2627 // Layout of descriptor. |
| (...skipping 1979 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4611 | 4607 |
| 4612 // Bit field. | 4608 // Bit field. |
| 4613 inline byte bit_field(); | 4609 inline byte bit_field(); |
| 4614 inline void set_bit_field(byte value); | 4610 inline void set_bit_field(byte value); |
| 4615 | 4611 |
| 4616 // Bit field 2. | 4612 // Bit field 2. |
| 4617 inline byte bit_field2(); | 4613 inline byte bit_field2(); |
| 4618 inline void set_bit_field2(byte value); | 4614 inline void set_bit_field2(byte value); |
| 4619 | 4615 |
| 4620 // Bit field 3. | 4616 // Bit field 3. |
| 4621 // TODO(1399): It should be possible to make room for bit_field3 in the map | 4617 // TODO(1399): It should be possible to make room for bit_field3 in the map |
|
Jakob Kummerow
2012/07/10 12:26:25
outdated comment?
Toon Verwaest
2012/07/10 13:28:28
Done.
| |
| 4622 // without overloading the instance descriptors field (and storing it in the | 4618 // without overloading the instance descriptors field (and storing it in the |
| 4623 // DescriptorArray when the map has one). | 4619 // DescriptorArray when the map has one). |
| 4624 inline int bit_field3(); | 4620 inline int bit_field3(); |
| 4625 inline void set_bit_field3(int value); | 4621 inline void set_bit_field3(int value); |
| 4626 inline void SetOwnBitField3(int value); | |
| 4627 | 4622 |
| 4628 // Tells whether the object in the prototype property will be used | 4623 // Tells whether the object in the prototype property will be used |
| 4629 // for instances created from this function. If the prototype | 4624 // for instances created from this function. If the prototype |
| 4630 // property is set to a value that is not a JSObject, the prototype | 4625 // property is set to a value that is not a JSObject, the prototype |
| 4631 // property will not be used to create instances of the function. | 4626 // property will not be used to create instances of the function. |
| 4632 // See ECMA-262, 13.2.2. | 4627 // See ECMA-262, 13.2.2. |
| 4633 inline void set_non_instance_prototype(bool value); | 4628 inline void set_non_instance_prototype(bool value); |
| 4634 inline bool has_non_instance_prototype(); | 4629 inline bool has_non_instance_prototype(); |
| 4635 | 4630 |
| 4636 // Tells whether function has special prototype property. If not, prototype | 4631 // Tells whether function has special prototype property. If not, prototype |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4747 inline bool HasTransitionArray(); | 4742 inline bool HasTransitionArray(); |
| 4748 inline bool HasElementsTransition(); | 4743 inline bool HasElementsTransition(); |
| 4749 inline Map* elements_transition_map(); | 4744 inline Map* elements_transition_map(); |
| 4750 MUST_USE_RESULT inline MaybeObject* set_elements_transition_map( | 4745 MUST_USE_RESULT inline MaybeObject* set_elements_transition_map( |
| 4751 Map* transitioned_map); | 4746 Map* transitioned_map); |
| 4752 inline TransitionArray* transitions(); | 4747 inline TransitionArray* transitions(); |
| 4753 MUST_USE_RESULT inline MaybeObject* AddTransition(String* key, | 4748 MUST_USE_RESULT inline MaybeObject* AddTransition(String* key, |
| 4754 Object* value); | 4749 Object* value); |
| 4755 MUST_USE_RESULT inline MaybeObject* set_transitions( | 4750 MUST_USE_RESULT inline MaybeObject* set_transitions( |
| 4756 TransitionArray* transitions); | 4751 TransitionArray* transitions); |
| 4757 inline void ClearTransitions(); | 4752 inline void ClearTransitions(Heap* heap, |
| 4753 WriteBarrierMode mode = UPDATE_WRITE_BARRIER); | |
| 4758 | 4754 |
| 4759 // Tells whether the map is attached to SharedFunctionInfo | 4755 // Tells whether the map is attached to SharedFunctionInfo |
| 4760 // (for inobject slack tracking). | 4756 // (for inobject slack tracking). |
| 4761 inline void set_attached_to_shared_function_info(bool value); | 4757 inline void set_attached_to_shared_function_info(bool value); |
| 4762 | 4758 |
| 4763 inline bool attached_to_shared_function_info(); | 4759 inline bool attached_to_shared_function_info(); |
| 4764 | 4760 |
| 4765 // Tells whether the map is shared between objects that may have different | 4761 // Tells whether the map is shared between objects that may have different |
| 4766 // behavior. If true, the map should never be modified, instead a clone | 4762 // behavior. If true, the map should never be modified, instead a clone |
| 4767 // should be created and modified. | 4763 // should be created and modified. |
| 4768 inline void set_is_shared(bool value); | 4764 inline void set_is_shared(bool value); |
| 4769 inline bool is_shared(); | 4765 inline bool is_shared(); |
| 4770 | 4766 |
| 4771 // Tells whether the instance needs security checks when accessing its | 4767 // Tells whether the instance needs security checks when accessing its |
| 4772 // properties. | 4768 // properties. |
| 4773 inline void set_is_access_check_needed(bool access_check_needed); | 4769 inline void set_is_access_check_needed(bool access_check_needed); |
| 4774 inline bool is_access_check_needed(); | 4770 inline bool is_access_check_needed(); |
| 4775 | 4771 |
| 4776 // [prototype]: implicit prototype object. | 4772 // [prototype]: implicit prototype object. |
| 4777 DECL_ACCESSORS(prototype, Object) | 4773 DECL_ACCESSORS(prototype, Object) |
| 4778 | 4774 |
| 4779 // [constructor]: points back to the function responsible for this map. | 4775 // [constructor]: points back to the function responsible for this map. |
| 4780 DECL_ACCESSORS(constructor, Object) | 4776 DECL_ACCESSORS(constructor, Object) |
| 4781 | 4777 |
| 4782 inline JSFunction* unchecked_constructor(); | 4778 inline JSFunction* unchecked_constructor(); |
| 4783 | 4779 |
| 4784 // Should only be called by the code that initializes map to set initial valid | |
| 4785 // value of the instance descriptor member. | |
| 4786 inline void init_instance_descriptors(); | |
| 4787 | |
| 4788 // [instance descriptors]: describes the object. | 4780 // [instance descriptors]: describes the object. |
| 4789 DECL_ACCESSORS(instance_descriptors, DescriptorArray) | 4781 DECL_ACCESSORS(instance_descriptors, DescriptorArray) |
| 4790 | 4782 |
| 4791 // Should only be called to clear a descriptor array that was only used to | 4783 // Should only be called to clear a descriptor array that was only used to |
| 4792 // store transitions and does not contain any live transitions anymore. | 4784 // store transitions and does not contain any live transitions anymore. |
| 4793 inline void ClearDescriptorArray(); | 4785 inline void ClearDescriptorArray(Heap* heap, WriteBarrierMode mode); |
| 4794 | |
| 4795 // Sets the instance descriptor array for the map to be an empty descriptor | |
| 4796 // array. | |
| 4797 inline void clear_instance_descriptors(); | |
| 4798 | 4786 |
| 4799 // [stub cache]: contains stubs compiled for this map. | 4787 // [stub cache]: contains stubs compiled for this map. |
| 4800 DECL_ACCESSORS(code_cache, Object) | 4788 DECL_ACCESSORS(code_cache, Object) |
| 4801 | 4789 |
| 4802 // [back pointer]: points back to the parent map from which a transition | 4790 // [back pointer]: points back to the parent map from which a transition |
| 4803 // leads to this map. The field overlaps with prototype transitions and the | 4791 // leads to this map. The field overlaps with prototype transitions and the |
| 4804 // back pointer will be moved into the prototype transitions array if | 4792 // back pointer will be moved into the prototype transitions array if |
| 4805 // required. | 4793 // required. |
| 4806 inline Object* GetBackPointer(); | 4794 inline Object* GetBackPointer(); |
| 4807 inline void SetBackPointer(Object* value, | 4795 inline void SetBackPointer(Object* value, |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4982 | 4970 |
| 4983 // Layout description. | 4971 // Layout description. |
| 4984 static const int kInstanceSizesOffset = HeapObject::kHeaderSize; | 4972 static const int kInstanceSizesOffset = HeapObject::kHeaderSize; |
| 4985 static const int kInstanceAttributesOffset = kInstanceSizesOffset + kIntSize; | 4973 static const int kInstanceAttributesOffset = kInstanceSizesOffset + kIntSize; |
| 4986 static const int kPrototypeOffset = kInstanceAttributesOffset + kIntSize; | 4974 static const int kPrototypeOffset = kInstanceAttributesOffset + kIntSize; |
| 4987 static const int kConstructorOffset = kPrototypeOffset + kPointerSize; | 4975 static const int kConstructorOffset = kPrototypeOffset + kPointerSize; |
| 4988 // Storage for instance descriptors is overloaded to also contain additional | 4976 // Storage for instance descriptors is overloaded to also contain additional |
| 4989 // map flags when unused (bit_field3). When the map has instance descriptors, | 4977 // map flags when unused (bit_field3). When the map has instance descriptors, |
| 4990 // the flags are transferred to the instance descriptor array and accessed | 4978 // the flags are transferred to the instance descriptor array and accessed |
| 4991 // through an extra indirection. | 4979 // through an extra indirection. |
| 4992 // TODO(1399): It should be possible to make room for bit_field3 in the map | 4980 // TODO(1399): It should be possible to make room for bit_field3 in the map |
|
Jakob Kummerow
2012/07/10 12:26:25
outdated comment?
Toon Verwaest
2012/07/10 13:28:28
Done.
| |
| 4993 // without overloading the instance descriptors field, but the map is | 4981 // without overloading the instance descriptors field, but the map is |
| 4994 // currently perfectly aligned to 32 bytes and extending it at all would | 4982 // currently perfectly aligned to 32 bytes and extending it at all would |
| 4995 // double its size. After the increment GC work lands, this size restriction | 4983 // double its size. After the increment GC work lands, this size restriction |
| 4996 // could be loosened and bit_field3 moved directly back in the map. | 4984 // could be loosened and bit_field3 moved directly back in the map. |
| 4997 static const int kInstanceDescriptorsOrBitField3Offset = | 4985 static const int kInstanceDescriptorsOrBackPointerOffset = |
| 4998 kConstructorOffset + kPointerSize; | 4986 kConstructorOffset + kPointerSize; |
| 4999 static const int kCodeCacheOffset = | 4987 static const int kCodeCacheOffset = |
| 5000 kInstanceDescriptorsOrBitField3Offset + kPointerSize; | 4988 kInstanceDescriptorsOrBackPointerOffset + kPointerSize; |
| 5001 static const int kBackPointerOffset = kCodeCacheOffset + kPointerSize; | 4989 static const int kBitField3Offset = kCodeCacheOffset + kPointerSize; |
| 5002 static const int kPadStart = kBackPointerOffset + kPointerSize; | 4990 static const int kPadStart = kBitField3Offset + kPointerSize; |
| 5003 static const int kSize = MAP_POINTER_ALIGN(kPadStart); | 4991 static const int kSize = MAP_POINTER_ALIGN(kPadStart); |
| 5004 | 4992 |
| 5005 // Layout of pointer fields. Heap iteration code relies on them | 4993 // Layout of pointer fields. Heap iteration code relies on them |
| 5006 // being continuously allocated. | 4994 // being continuously allocated. |
| 5007 static const int kPointerFieldsBeginOffset = Map::kPrototypeOffset; | 4995 static const int kPointerFieldsBeginOffset = Map::kPrototypeOffset; |
| 5008 static const int kPointerFieldsEndOffset = kBackPointerOffset + kPointerSize; | 4996 static const int kPointerFieldsEndOffset = kBitField3Offset + kPointerSize; |
| 5009 | 4997 |
| 5010 // Byte offsets within kInstanceSizesOffset. | 4998 // Byte offsets within kInstanceSizesOffset. |
| 5011 static const int kInstanceSizeOffset = kInstanceSizesOffset + 0; | 4999 static const int kInstanceSizeOffset = kInstanceSizesOffset + 0; |
| 5012 static const int kInObjectPropertiesByte = 1; | 5000 static const int kInObjectPropertiesByte = 1; |
| 5013 static const int kInObjectPropertiesOffset = | 5001 static const int kInObjectPropertiesOffset = |
| 5014 kInstanceSizesOffset + kInObjectPropertiesByte; | 5002 kInstanceSizesOffset + kInObjectPropertiesByte; |
| 5015 static const int kPreAllocatedPropertyFieldsByte = 2; | 5003 static const int kPreAllocatedPropertyFieldsByte = 2; |
| 5016 static const int kPreAllocatedPropertyFieldsOffset = | 5004 static const int kPreAllocatedPropertyFieldsOffset = |
| 5017 kInstanceSizesOffset + kPreAllocatedPropertyFieldsByte; | 5005 kInstanceSizesOffset + kPreAllocatedPropertyFieldsByte; |
| 5018 static const int kVisitorIdByte = 3; | 5006 static const int kVisitorIdByte = 3; |
| (...skipping 3805 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 8824 } else { | 8812 } else { |
| 8825 value &= ~(1 << bit_position); | 8813 value &= ~(1 << bit_position); |
| 8826 } | 8814 } |
| 8827 return value; | 8815 return value; |
| 8828 } | 8816 } |
| 8829 }; | 8817 }; |
| 8830 | 8818 |
| 8831 } } // namespace v8::internal | 8819 } } // namespace v8::internal |
| 8832 | 8820 |
| 8833 #endif // V8_OBJECTS_H_ | 8821 #endif // V8_OBJECTS_H_ |
| OLD | NEW |