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 2591 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2602 inline void PrintDescriptors() { | 2602 inline void PrintDescriptors() { |
| 2603 PrintDescriptors(stdout); | 2603 PrintDescriptors(stdout); |
| 2604 } | 2604 } |
| 2605 void PrintDescriptors(FILE* out); | 2605 void PrintDescriptors(FILE* out); |
| 2606 #endif | 2606 #endif |
| 2607 | 2607 |
| 2608 #ifdef DEBUG | 2608 #ifdef DEBUG |
| 2609 // Is the descriptor array sorted and without duplicates? | 2609 // Is the descriptor array sorted and without duplicates? |
| 2610 bool IsSortedNoDuplicates(); | 2610 bool IsSortedNoDuplicates(); |
| 2611 | 2611 |
| 2612 // Is the descriptor array consistent with the back pointers in targets? | |
| 2613 bool IsConsistentWithBackPointers(Map* current_map); | |
| 2614 | |
| 2612 // Are two DescriptorArrays equal? | 2615 // Are two DescriptorArrays equal? |
| 2613 bool IsEqualTo(DescriptorArray* other); | 2616 bool IsEqualTo(DescriptorArray* other); |
| 2614 #endif | 2617 #endif |
| 2615 | 2618 |
| 2616 // The maximum number of descriptors we want in a descriptor array (should | 2619 // The maximum number of descriptors we want in a descriptor array (should |
| 2617 // fit in a page). | 2620 // fit in a page). |
| 2618 static const int kMaxNumberOfDescriptors = 1024 + 512; | 2621 static const int kMaxNumberOfDescriptors = 1024 + 512; |
| 2619 | 2622 |
| 2620 private: | 2623 private: |
| 2621 // An entry in a DescriptorArray, represented as an (array, index) pair. | 2624 // An entry in a DescriptorArray, represented as an (array, index) pair. |
| (...skipping 2090 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4712 // [instance descriptors]: describes the object. | 4715 // [instance descriptors]: describes the object. |
| 4713 DECL_ACCESSORS(instance_descriptors, DescriptorArray) | 4716 DECL_ACCESSORS(instance_descriptors, DescriptorArray) |
| 4714 | 4717 |
| 4715 // Sets the instance descriptor array for the map to be an empty descriptor | 4718 // Sets the instance descriptor array for the map to be an empty descriptor |
| 4716 // array. | 4719 // array. |
| 4717 inline void clear_instance_descriptors(); | 4720 inline void clear_instance_descriptors(); |
| 4718 | 4721 |
| 4719 // [stub cache]: contains stubs compiled for this map. | 4722 // [stub cache]: contains stubs compiled for this map. |
| 4720 DECL_ACCESSORS(code_cache, Object) | 4723 DECL_ACCESSORS(code_cache, Object) |
| 4721 | 4724 |
| 4725 // [back pointer]: points back to the parent map from which a transition | |
| 4726 // leads to this map. The field overlaps with prototype transitions and the | |
| 4727 // back pointer will be moved into the prototype transitions array if | |
| 4728 // required. | |
| 4729 DECL_ACCESSORS(back_pointer, Object) | |
|
Vyacheslav Egorov (Chromium)
2012/05/08 14:29:19
I would prefer if this was declared as GetBackPoin
Michael Starzinger
2012/05/09 07:30:02
Done.
| |
| 4730 | |
| 4722 // [prototype transitions]: cache of prototype transitions. | 4731 // [prototype transitions]: cache of prototype transitions. |
| 4723 // Prototype transition is a transition that happens | 4732 // Prototype transition is a transition that happens |
| 4724 // when we change object's prototype to a new one. | 4733 // when we change object's prototype to a new one. |
| 4725 // Cache format: | 4734 // Cache format: |
| 4726 // 0: finger - index of the first free cell in the cache | 4735 // 0: finger - index of the first free cell in the cache |
| 4727 // 1 + 2 * i: prototype | 4736 // 1: back pointer that overlaps with prototype transitions field. |
| 4728 // 2 + 2 * i: target map | 4737 // 2 + 2 * i: prototype |
| 4738 // 3 + 2 * i: target map | |
| 4729 DECL_ACCESSORS(prototype_transitions, FixedArray) | 4739 DECL_ACCESSORS(prototype_transitions, FixedArray) |
| 4730 | 4740 |
| 4731 inline FixedArray* unchecked_prototype_transitions(); | 4741 inline void init_prototype_transitions(Object* undefined); |
| 4742 inline HeapObject* unchecked_prototype_transitions(); | |
| 4732 | 4743 |
| 4733 static const int kProtoTransitionHeaderSize = 1; | 4744 static const int kProtoTransitionHeaderSize = 2; |
| 4734 static const int kProtoTransitionNumberOfEntriesOffset = 0; | 4745 static const int kProtoTransitionNumberOfEntriesOffset = 0; |
| 4746 static const int kProtoTransitionBackPointerOffset = 1; | |
| 4735 static const int kProtoTransitionElementsPerEntry = 2; | 4747 static const int kProtoTransitionElementsPerEntry = 2; |
| 4736 static const int kProtoTransitionPrototypeOffset = 0; | 4748 static const int kProtoTransitionPrototypeOffset = 0; |
| 4737 static const int kProtoTransitionMapOffset = 1; | 4749 static const int kProtoTransitionMapOffset = 1; |
| 4738 | 4750 |
| 4739 inline int NumberOfProtoTransitions() { | 4751 inline int NumberOfProtoTransitions() { |
| 4740 FixedArray* cache = prototype_transitions(); | 4752 FixedArray* cache = prototype_transitions(); |
| 4741 if (cache->length() == 0) return 0; | 4753 if (cache->length() == 0) return 0; |
| 4742 return | 4754 return |
| 4743 Smi::cast(cache->get(kProtoTransitionNumberOfEntriesOffset))->value(); | 4755 Smi::cast(cache->get(kProtoTransitionNumberOfEntriesOffset))->value(); |
| 4744 } | 4756 } |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4796 // Returns the found code or undefined if absent. | 4808 // Returns the found code or undefined if absent. |
| 4797 Object* FindInCodeCache(String* name, Code::Flags flags); | 4809 Object* FindInCodeCache(String* name, Code::Flags flags); |
| 4798 | 4810 |
| 4799 // Returns the non-negative index of the code object if it is in the | 4811 // Returns the non-negative index of the code object if it is in the |
| 4800 // cache and -1 otherwise. | 4812 // cache and -1 otherwise. |
| 4801 int IndexInCodeCache(Object* name, Code* code); | 4813 int IndexInCodeCache(Object* name, Code* code); |
| 4802 | 4814 |
| 4803 // Removes a code object from the code cache at the given index. | 4815 // Removes a code object from the code cache at the given index. |
| 4804 void RemoveFromCodeCache(String* name, Code* code, int index); | 4816 void RemoveFromCodeCache(String* name, Code* code, int index); |
| 4805 | 4817 |
| 4806 // For every transition in this map, makes the transition's | 4818 // Set all map transitions from this map to dead maps to null. Also clear |
| 4807 // target's prototype pointer point back to this map. | 4819 // back pointers in transition targets so that we do not process this map |
| 4808 // This is undone in MarkCompactCollector::ClearNonLiveTransitions(). | 4820 // again while following back pointers. |
| 4809 void CreateBackPointers(); | 4821 void ClearNonLiveTransitions(Heap* heap); |
| 4810 | |
| 4811 void CreateOneBackPointer(Object* transition_target); | |
| 4812 | |
| 4813 // Set all map transitions from this map to dead maps to null. | |
| 4814 // Also, restore the original prototype on the targets of these | |
| 4815 // transitions, so that we do not process this map again while | |
| 4816 // following back pointers. | |
| 4817 void ClearNonLiveTransitions(Heap* heap, Object* real_prototype); | |
| 4818 | |
| 4819 // Restore a possible back pointer in the prototype field of object. | |
| 4820 // Return true in that case and false otherwise. Set *keep_entry to | |
| 4821 // true when a live map transition has been found. | |
| 4822 bool RestoreOneBackPointer(Object* object, | |
| 4823 Object* real_prototype, | |
| 4824 bool* keep_entry); | |
| 4825 | 4822 |
| 4826 // Computes a hash value for this map, to be used in HashTables and such. | 4823 // Computes a hash value for this map, to be used in HashTables and such. |
| 4827 int Hash(); | 4824 int Hash(); |
| 4828 | 4825 |
| 4829 // Compares this map to another to see if they describe equivalent objects. | 4826 // Compares this map to another to see if they describe equivalent objects. |
| 4830 // If |mode| is set to CLEAR_INOBJECT_PROPERTIES, |other| is treated as if | 4827 // If |mode| is set to CLEAR_INOBJECT_PROPERTIES, |other| is treated as if |
| 4831 // it had exactly zero inobject properties. | 4828 // it had exactly zero inobject properties. |
| 4832 // The "shared" flags of both this map and |other| are ignored. | 4829 // The "shared" flags of both this map and |other| are ignored. |
| 4833 bool EquivalentToForNormalization(Map* other, PropertyNormalizationMode mode); | 4830 bool EquivalentToForNormalization(Map* other, PropertyNormalizationMode mode); |
| 4834 | 4831 |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4896 // through an extra indirection. | 4893 // through an extra indirection. |
| 4897 // TODO(1399): It should be possible to make room for bit_field3 in the map | 4894 // TODO(1399): It should be possible to make room for bit_field3 in the map |
| 4898 // without overloading the instance descriptors field, but the map is | 4895 // without overloading the instance descriptors field, but the map is |
| 4899 // currently perfectly aligned to 32 bytes and extending it at all would | 4896 // currently perfectly aligned to 32 bytes and extending it at all would |
| 4900 // double its size. After the increment GC work lands, this size restriction | 4897 // double its size. After the increment GC work lands, this size restriction |
| 4901 // could be loosened and bit_field3 moved directly back in the map. | 4898 // could be loosened and bit_field3 moved directly back in the map. |
| 4902 static const int kInstanceDescriptorsOrBitField3Offset = | 4899 static const int kInstanceDescriptorsOrBitField3Offset = |
| 4903 kConstructorOffset + kPointerSize; | 4900 kConstructorOffset + kPointerSize; |
| 4904 static const int kCodeCacheOffset = | 4901 static const int kCodeCacheOffset = |
| 4905 kInstanceDescriptorsOrBitField3Offset + kPointerSize; | 4902 kInstanceDescriptorsOrBitField3Offset + kPointerSize; |
| 4906 static const int kPrototypeTransitionsOffset = | 4903 static const int kPrototypeTransitionsOrBackPointerOffset = |
| 4907 kCodeCacheOffset + kPointerSize; | 4904 kCodeCacheOffset + kPointerSize; |
| 4908 static const int kPadStart = kPrototypeTransitionsOffset + kPointerSize; | 4905 static const int kPadStart = |
| 4906 kPrototypeTransitionsOrBackPointerOffset + kPointerSize; | |
| 4909 static const int kSize = MAP_POINTER_ALIGN(kPadStart); | 4907 static const int kSize = MAP_POINTER_ALIGN(kPadStart); |
| 4910 | 4908 |
| 4911 // Layout of pointer fields. Heap iteration code relies on them | 4909 // Layout of pointer fields. Heap iteration code relies on them |
| 4912 // being continuously allocated. | 4910 // being continuously allocated. |
| 4913 static const int kPointerFieldsBeginOffset = Map::kPrototypeOffset; | 4911 static const int kPointerFieldsBeginOffset = Map::kPrototypeOffset; |
| 4914 static const int kPointerFieldsEndOffset = | 4912 static const int kPointerFieldsEndOffset = |
| 4915 Map::kPrototypeTransitionsOffset + kPointerSize; | 4913 kPrototypeTransitionsOrBackPointerOffset + kPointerSize; |
| 4916 | 4914 |
| 4917 // Byte offsets within kInstanceSizesOffset. | 4915 // Byte offsets within kInstanceSizesOffset. |
| 4918 static const int kInstanceSizeOffset = kInstanceSizesOffset + 0; | 4916 static const int kInstanceSizeOffset = kInstanceSizesOffset + 0; |
| 4919 static const int kInObjectPropertiesByte = 1; | 4917 static const int kInObjectPropertiesByte = 1; |
| 4920 static const int kInObjectPropertiesOffset = | 4918 static const int kInObjectPropertiesOffset = |
| 4921 kInstanceSizesOffset + kInObjectPropertiesByte; | 4919 kInstanceSizesOffset + kInObjectPropertiesByte; |
| 4922 static const int kPreAllocatedPropertyFieldsByte = 2; | 4920 static const int kPreAllocatedPropertyFieldsByte = 2; |
| 4923 static const int kPreAllocatedPropertyFieldsOffset = | 4921 static const int kPreAllocatedPropertyFieldsOffset = |
| 4924 kInstanceSizesOffset + kPreAllocatedPropertyFieldsByte; | 4922 kInstanceSizesOffset + kPreAllocatedPropertyFieldsByte; |
| 4925 static const int kVisitorIdByte = 3; | 4923 static const int kVisitorIdByte = 3; |
| (...skipping 3732 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 8658 } else { | 8656 } else { |
| 8659 value &= ~(1 << bit_position); | 8657 value &= ~(1 << bit_position); |
| 8660 } | 8658 } |
| 8661 return value; | 8659 return value; |
| 8662 } | 8660 } |
| 8663 }; | 8661 }; |
| 8664 | 8662 |
| 8665 } } // namespace v8::internal | 8663 } } // namespace v8::internal |
| 8666 | 8664 |
| 8667 #endif // V8_OBJECTS_H_ | 8665 #endif // V8_OBJECTS_H_ |
| OLD | NEW |