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 4788 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4799 // [stub cache]: contains stubs compiled for this map. | 4799 // [stub cache]: contains stubs compiled for this map. |
4800 DECL_ACCESSORS(code_cache, Object) | 4800 DECL_ACCESSORS(code_cache, Object) |
4801 | 4801 |
4802 // [back pointer]: points back to the parent map from which a transition | 4802 // [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 | 4803 // leads to this map. The field overlaps with prototype transitions and the |
4804 // back pointer will be moved into the prototype transitions array if | 4804 // back pointer will be moved into the prototype transitions array if |
4805 // required. | 4805 // required. |
4806 inline Object* GetBackPointer(); | 4806 inline Object* GetBackPointer(); |
4807 inline void SetBackPointer(Object* value, | 4807 inline void SetBackPointer(Object* value, |
4808 WriteBarrierMode mode = UPDATE_WRITE_BARRIER); | 4808 WriteBarrierMode mode = UPDATE_WRITE_BARRIER); |
| 4809 inline void init_back_pointer(Object* undefined); |
4809 | 4810 |
4810 // [prototype transitions]: cache of prototype transitions. | 4811 // [prototype transitions]: cache of prototype transitions. |
4811 // Prototype transition is a transition that happens | 4812 // Prototype transition is a transition that happens |
4812 // when we change object's prototype to a new one. | 4813 // when we change object's prototype to a new one. |
4813 // Cache format: | 4814 // Cache format: |
4814 // 0: finger - index of the first free cell in the cache | 4815 // 0: finger - index of the first free cell in the cache |
4815 // 1: back pointer that overlaps with prototype transitions field. | 4816 // 1: back pointer that overlaps with prototype transitions field. |
4816 // 2 + 2 * i: prototype | 4817 // 2 + 2 * i: prototype |
4817 // 3 + 2 * i: target map | 4818 // 3 + 2 * i: target map |
4818 DECL_ACCESSORS(prototype_transitions, FixedArray) | 4819 inline FixedArray* GetPrototypeTransitions(); |
| 4820 MUST_USE_RESULT inline MaybeObject* SetPrototypeTransitions( |
| 4821 FixedArray* prototype_transitions); |
| 4822 inline bool HasPrototypeTransitions(); |
4819 | 4823 |
4820 inline void init_prototype_transitions(Object* undefined); | 4824 inline HeapObject* UncheckedPrototypeTransitions(); |
4821 inline HeapObject* unchecked_prototype_transitions(); | 4825 inline TransitionArray* unchecked_transition_array(); |
4822 | 4826 |
4823 static const int kProtoTransitionHeaderSize = 2; | 4827 static const int kProtoTransitionHeaderSize = 1; |
4824 static const int kProtoTransitionNumberOfEntriesOffset = 0; | 4828 static const int kProtoTransitionNumberOfEntriesOffset = 0; |
4825 static const int kProtoTransitionBackPointerOffset = 1; | |
4826 static const int kProtoTransitionElementsPerEntry = 2; | 4829 static const int kProtoTransitionElementsPerEntry = 2; |
4827 static const int kProtoTransitionPrototypeOffset = 0; | 4830 static const int kProtoTransitionPrototypeOffset = 0; |
4828 static const int kProtoTransitionMapOffset = 1; | 4831 static const int kProtoTransitionMapOffset = 1; |
4829 | 4832 |
4830 inline int NumberOfProtoTransitions() { | 4833 inline int NumberOfProtoTransitions() { |
4831 FixedArray* cache = prototype_transitions(); | 4834 FixedArray* cache = GetPrototypeTransitions(); |
4832 if (cache->length() == 0) return 0; | 4835 if (cache->length() == 0) return 0; |
4833 return | 4836 return |
4834 Smi::cast(cache->get(kProtoTransitionNumberOfEntriesOffset))->value(); | 4837 Smi::cast(cache->get(kProtoTransitionNumberOfEntriesOffset))->value(); |
4835 } | 4838 } |
4836 | 4839 |
4837 inline void SetNumberOfProtoTransitions(int value) { | 4840 inline void SetNumberOfProtoTransitions(int value) { |
4838 FixedArray* cache = prototype_transitions(); | 4841 FixedArray* cache = GetPrototypeTransitions(); |
4839 ASSERT(cache->length() != 0); | 4842 ASSERT(cache->length() != 0); |
4840 cache->set_unchecked(kProtoTransitionNumberOfEntriesOffset, | 4843 cache->set_unchecked(kProtoTransitionNumberOfEntriesOffset, |
4841 Smi::FromInt(value)); | 4844 Smi::FromInt(value)); |
4842 } | 4845 } |
4843 | 4846 |
4844 // Lookup in the map's instance descriptors and fill out the result | 4847 // Lookup in the map's instance descriptors and fill out the result |
4845 // with the given holder if the name is found. The holder may be | 4848 // with the given holder if the name is found. The holder may be |
4846 // NULL when this function is used from the compiler. | 4849 // NULL when this function is used from the compiler. |
4847 void LookupDescriptor(JSObject* holder, | 4850 void LookupDescriptor(JSObject* holder, |
4848 String* name, | 4851 String* name, |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4988 // through an extra indirection. | 4991 // through an extra indirection. |
4989 // TODO(1399): It should be possible to make room for bit_field3 in the map | 4992 // TODO(1399): It should be possible to make room for bit_field3 in the map |
4990 // without overloading the instance descriptors field, but the map is | 4993 // without overloading the instance descriptors field, but the map is |
4991 // currently perfectly aligned to 32 bytes and extending it at all would | 4994 // currently perfectly aligned to 32 bytes and extending it at all would |
4992 // double its size. After the increment GC work lands, this size restriction | 4995 // double its size. After the increment GC work lands, this size restriction |
4993 // could be loosened and bit_field3 moved directly back in the map. | 4996 // could be loosened and bit_field3 moved directly back in the map. |
4994 static const int kInstanceDescriptorsOrBitField3Offset = | 4997 static const int kInstanceDescriptorsOrBitField3Offset = |
4995 kConstructorOffset + kPointerSize; | 4998 kConstructorOffset + kPointerSize; |
4996 static const int kCodeCacheOffset = | 4999 static const int kCodeCacheOffset = |
4997 kInstanceDescriptorsOrBitField3Offset + kPointerSize; | 5000 kInstanceDescriptorsOrBitField3Offset + kPointerSize; |
4998 static const int kPrototypeTransitionsOrBackPointerOffset = | 5001 static const int kBackPointerOffset = kCodeCacheOffset + kPointerSize; |
4999 kCodeCacheOffset + kPointerSize; | 5002 static const int kPadStart = kBackPointerOffset + kPointerSize; |
5000 static const int kPadStart = | |
5001 kPrototypeTransitionsOrBackPointerOffset + kPointerSize; | |
5002 static const int kSize = MAP_POINTER_ALIGN(kPadStart); | 5003 static const int kSize = MAP_POINTER_ALIGN(kPadStart); |
5003 | 5004 |
5004 // Layout of pointer fields. Heap iteration code relies on them | 5005 // Layout of pointer fields. Heap iteration code relies on them |
5005 // being continuously allocated. | 5006 // being continuously allocated. |
5006 static const int kPointerFieldsBeginOffset = Map::kPrototypeOffset; | 5007 static const int kPointerFieldsBeginOffset = Map::kPrototypeOffset; |
5007 static const int kPointerFieldsEndOffset = | 5008 static const int kPointerFieldsEndOffset = kBackPointerOffset + kPointerSize; |
5008 kPrototypeTransitionsOrBackPointerOffset + kPointerSize; | |
5009 | 5009 |
5010 // Byte offsets within kInstanceSizesOffset. | 5010 // Byte offsets within kInstanceSizesOffset. |
5011 static const int kInstanceSizeOffset = kInstanceSizesOffset + 0; | 5011 static const int kInstanceSizeOffset = kInstanceSizesOffset + 0; |
5012 static const int kInObjectPropertiesByte = 1; | 5012 static const int kInObjectPropertiesByte = 1; |
5013 static const int kInObjectPropertiesOffset = | 5013 static const int kInObjectPropertiesOffset = |
5014 kInstanceSizesOffset + kInObjectPropertiesByte; | 5014 kInstanceSizesOffset + kInObjectPropertiesByte; |
5015 static const int kPreAllocatedPropertyFieldsByte = 2; | 5015 static const int kPreAllocatedPropertyFieldsByte = 2; |
5016 static const int kPreAllocatedPropertyFieldsOffset = | 5016 static const int kPreAllocatedPropertyFieldsOffset = |
5017 kInstanceSizesOffset + kPreAllocatedPropertyFieldsByte; | 5017 kInstanceSizesOffset + kPreAllocatedPropertyFieldsByte; |
5018 static const int kVisitorIdByte = 3; | 5018 static const int kVisitorIdByte = 3; |
(...skipping 3805 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8824 } else { | 8824 } else { |
8825 value &= ~(1 << bit_position); | 8825 value &= ~(1 << bit_position); |
8826 } | 8826 } |
8827 return value; | 8827 return value; |
8828 } | 8828 } |
8829 }; | 8829 }; |
8830 | 8830 |
8831 } } // namespace v8::internal | 8831 } } // namespace v8::internal |
8832 | 8832 |
8833 #endif // V8_OBJECTS_H_ | 8833 #endif // V8_OBJECTS_H_ |
OLD | NEW |