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 855 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
866 V(FreeSpace) \ | 866 V(FreeSpace) \ |
867 V(JSReceiver) \ | 867 V(JSReceiver) \ |
868 V(JSObject) \ | 868 V(JSObject) \ |
869 V(JSContextExtensionObject) \ | 869 V(JSContextExtensionObject) \ |
870 V(JSModule) \ | 870 V(JSModule) \ |
871 V(Map) \ | 871 V(Map) \ |
872 V(DescriptorArray) \ | 872 V(DescriptorArray) \ |
873 V(TransitionArray) \ | 873 V(TransitionArray) \ |
874 V(DeoptimizationInputData) \ | 874 V(DeoptimizationInputData) \ |
875 V(DeoptimizationOutputData) \ | 875 V(DeoptimizationOutputData) \ |
876 V(DependentCodes) \ | 876 V(DependentCode) \ |
877 V(TypeFeedbackCells) \ | 877 V(TypeFeedbackCells) \ |
878 V(FixedArray) \ | 878 V(FixedArray) \ |
879 V(FixedDoubleArray) \ | 879 V(FixedDoubleArray) \ |
880 V(Context) \ | 880 V(Context) \ |
881 V(NativeContext) \ | 881 V(NativeContext) \ |
882 V(ScopeInfo) \ | 882 V(ScopeInfo) \ |
883 V(JSFunction) \ | 883 V(JSFunction) \ |
884 V(Code) \ | 884 V(Code) \ |
885 V(Oddball) \ | 885 V(Oddball) \ |
886 V(SharedFunctionInfo) \ | 886 V(SharedFunctionInfo) \ |
(...skipping 3801 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4688 | 4688 |
4689 // Code aging -- platform-specific | 4689 // Code aging -- platform-specific |
4690 static void PatchPlatformCodeAge(byte* sequence, Age age, | 4690 static void PatchPlatformCodeAge(byte* sequence, Age age, |
4691 MarkingParity parity); | 4691 MarkingParity parity); |
4692 | 4692 |
4693 DISALLOW_IMPLICIT_CONSTRUCTORS(Code); | 4693 DISALLOW_IMPLICIT_CONSTRUCTORS(Code); |
4694 }; | 4694 }; |
4695 | 4695 |
4696 | 4696 |
4697 // This class describes the layout of dependent codes array of a map. The | 4697 // This class describes the layout of dependent codes array of a map. The |
4698 // first element contains the number of codes as a Smi. The subsequent | 4698 // array is partitioned into several groups of dependent codes. Each group |
4699 // elements contain code objects. The suffix of the array can be filled with the | 4699 // contains codes with the same dependency on the map. The array has the |
4700 // undefined value if the number of codes is less than the length of the array. | 4700 // following layout for n dependency groups: |
4701 class DependentCodes: public FixedArray { | 4701 // |
4702 // +----+----+-----+----+---------+----------+-----+---------+-----------+ | |
4703 // | C1 | C2 | ... | Cn | group 1 | group 2 | ... | group n | undefined | | |
4704 // +----+----+-----+----+---------+----------+-----+---------+-----------+ | |
4705 // | |
4706 // The first n elements are Smis, each of them specifies the number of codes | |
4707 // in the corresponding group. The subsequent elements contain grouped code | |
4708 // objects. The suffix of the array can be filled with the undefined value if | |
4709 // the number of codes is less than the length of the array. The order of the | |
4710 // code objects within a group is not preserved. | |
4711 // | |
4712 // All code indexes used in the class are counted starting from the first | |
4713 // code object of the first group. In other words, code index 0 corresponds | |
4714 // to array index n = kCodesStartIndex. | |
4715 | |
4716 class DependentCode: public FixedArray { | |
4702 public: | 4717 public: |
4703 inline int number_of_codes(); | 4718 enum DependencyGroup { |
4704 inline void set_number_of_codes(int value); | 4719 // Group of code that weakly embed this map and depend on being |
4720 // deoptimized when the map is garbage collected. | |
4721 kWeaklyEmbeddedGroup, | |
4722 // Group of code that omit run-time prototype checks for prototypes | |
4723 // described by this map. The group is deoptimized whenever an object | |
4724 // described by this map changes shape (and transitions to a new map), | |
4725 // possibly invalidating the assumptions embedded in the code. | |
4726 kPrototypeCheckGroup, | |
4727 kGroupCount = kPrototypeCheckGroup + 1 | |
4728 }; | |
4729 | |
4730 // Array for holding the index of the first code object of each group. | |
4731 // The last element stores the total number of code objects. | |
4732 class GroupStartIndexes { | |
4733 public: | |
4734 explicit GroupStartIndexes(DependentCode* entries); | |
4735 void Recompute(DependentCode* entries); | |
4736 int at(int i) { return start_indexes_[i]; } | |
4737 int number_of_entries() { return start_indexes_[kGroupCount]; } | |
4738 private: | |
4739 int start_indexes_[kGroupCount + 1]; | |
4740 }; | |
4741 | |
4742 bool Contains(DependencyGroup group, Code* code); | |
4743 static Handle<DependentCode> Insert(Handle<DependentCode> entries, | |
4744 DependencyGroup group, | |
4745 Handle<Code> value); | |
4746 void DeoptimizeDependentCodeGroup(DependentCode::DependencyGroup group); | |
4747 | |
4748 // The following low-level accessors should only be used by this class | |
4749 // and the mark compact collector. | |
4750 inline int number_of_entries(DependencyGroup group); | |
4751 inline void set_number_of_entries(DependencyGroup group, int value); | |
4705 inline Code* code_at(int i); | 4752 inline Code* code_at(int i); |
4706 inline void set_code_at(int i, Code* value); | 4753 inline void set_code_at(int i, Code* value); |
4707 inline Object** code_slot_at(int i); | 4754 inline Object** code_slot_at(int i); |
4708 inline void clear_code_at(int i); | 4755 inline void clear_code_at(int i); |
4709 static Handle<DependentCodes> Append(Handle<DependentCodes> codes, | 4756 static inline DependentCode* cast(Object* object); |
4710 Handle<Code> value); | 4757 |
4711 static inline DependentCodes* cast(Object* object); | |
4712 bool Contains(Code* code); | |
4713 private: | 4758 private: |
4714 static const int kNumberOfCodesIndex = 0; | 4759 // Make a room at the end of the given group by moving out the first |
4715 static const int kCodesIndex = 1; | 4760 // code objects of the subsequent groups. |
4761 inline void ExtendGroup(DependencyGroup group); | |
4762 static const int kCodesStartIndex = kGroupCount; | |
4716 }; | 4763 }; |
4717 | 4764 |
4718 | 4765 |
4719 // All heap objects have a Map that describes their structure. | 4766 // All heap objects have a Map that describes their structure. |
4720 // A Map contains information about: | 4767 // A Map contains information about: |
4721 // - Size information about the object | 4768 // - Size information about the object |
4722 // - How to iterate over an object (for garbage collection) | 4769 // - How to iterate over an object (for garbage collection) |
4723 class Map: public HeapObject { | 4770 class Map: public HeapObject { |
4724 public: | 4771 public: |
4725 // Instance size. | 4772 // Instance size. |
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4938 | 4985 |
4939 inline JSFunction* unchecked_constructor(); | 4986 inline JSFunction* unchecked_constructor(); |
4940 | 4987 |
4941 // [instance descriptors]: describes the object. | 4988 // [instance descriptors]: describes the object. |
4942 DECL_ACCESSORS(instance_descriptors, DescriptorArray) | 4989 DECL_ACCESSORS(instance_descriptors, DescriptorArray) |
4943 inline void InitializeDescriptors(DescriptorArray* descriptors); | 4990 inline void InitializeDescriptors(DescriptorArray* descriptors); |
4944 | 4991 |
4945 // [stub cache]: contains stubs compiled for this map. | 4992 // [stub cache]: contains stubs compiled for this map. |
4946 DECL_ACCESSORS(code_cache, Object) | 4993 DECL_ACCESSORS(code_cache, Object) |
4947 | 4994 |
4948 // [dependent codes]: list of optimized codes that have this map embedded. | 4995 // [dependent code]: list of optimized codes that have this map embedded. |
4949 DECL_ACCESSORS(dependent_codes, DependentCodes) | 4996 DECL_ACCESSORS(dependent_code, DependentCode) |
4950 | 4997 |
4951 // [back pointer]: points back to the parent map from which a transition | 4998 // [back pointer]: points back to the parent map from which a transition |
4952 // leads to this map. The field overlaps with prototype transitions and the | 4999 // leads to this map. The field overlaps with prototype transitions and the |
4953 // back pointer will be moved into the prototype transitions array if | 5000 // back pointer will be moved into the prototype transitions array if |
4954 // required. | 5001 // required. |
4955 inline Object* GetBackPointer(); | 5002 inline Object* GetBackPointer(); |
4956 inline void SetBackPointer(Object* value, | 5003 inline void SetBackPointer(Object* value, |
4957 WriteBarrierMode mode = UPDATE_WRITE_BARRIER); | 5004 WriteBarrierMode mode = UPDATE_WRITE_BARRIER); |
4958 inline void init_back_pointer(Object* undefined); | 5005 inline void init_back_pointer(Object* undefined); |
4959 | 5006 |
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5156 // heap verification is turned on. | 5203 // heap verification is turned on. |
5157 void ZapPrototypeTransitions(); | 5204 void ZapPrototypeTransitions(); |
5158 void ZapTransitions(); | 5205 void ZapTransitions(); |
5159 | 5206 |
5160 bool CanTransition() { | 5207 bool CanTransition() { |
5161 // Only JSObject and subtypes have map transitions and back pointers. | 5208 // Only JSObject and subtypes have map transitions and back pointers. |
5162 STATIC_ASSERT(LAST_TYPE == LAST_JS_OBJECT_TYPE); | 5209 STATIC_ASSERT(LAST_TYPE == LAST_JS_OBJECT_TYPE); |
5163 return instance_type() >= FIRST_JS_OBJECT_TYPE; | 5210 return instance_type() >= FIRST_JS_OBJECT_TYPE; |
5164 } | 5211 } |
5165 | 5212 |
5166 inline void AddDependentCode(Handle<Code> code); | 5213 |
Michael Starzinger
2013/02/20 10:12:26
Drop one of the two empty newlines.
ulan
2013/02/20 10:30:33
Done.
| |
5214 inline void NotifyObjectLayoutChange(); | |
Michael Starzinger
2013/02/20 10:12:26
Could we rename this to "NotifyLeafMapLayoutChange
ulan
2013/02/20 10:30:33
Done.
| |
5215 | |
5216 inline bool CanOmitPrototypeChecks(); | |
5217 | |
5218 inline void AddDependentCode(DependentCode::DependencyGroup group, | |
5219 Handle<Code> code); | |
5167 | 5220 |
5168 // Dispatched behavior. | 5221 // Dispatched behavior. |
5169 DECLARE_PRINTER(Map) | 5222 DECLARE_PRINTER(Map) |
5170 DECLARE_VERIFIER(Map) | 5223 DECLARE_VERIFIER(Map) |
5171 | 5224 |
5172 #ifdef VERIFY_HEAP | 5225 #ifdef VERIFY_HEAP |
5173 void SharedMapVerify(); | 5226 void SharedMapVerify(); |
5174 #endif | 5227 #endif |
5175 | 5228 |
5176 inline int visitor_id(); | 5229 inline int visitor_id(); |
(...skipping 29 matching lines...) Expand all Loading... | |
5206 static const int kConstructorOffset = kPrototypeOffset + kPointerSize; | 5259 static const int kConstructorOffset = kPrototypeOffset + kPointerSize; |
5207 // Storage for the transition array is overloaded to directly contain a back | 5260 // Storage for the transition array is overloaded to directly contain a back |
5208 // pointer if unused. When the map has transitions, the back pointer is | 5261 // pointer if unused. When the map has transitions, the back pointer is |
5209 // transferred to the transition array and accessed through an extra | 5262 // transferred to the transition array and accessed through an extra |
5210 // indirection. | 5263 // indirection. |
5211 static const int kTransitionsOrBackPointerOffset = | 5264 static const int kTransitionsOrBackPointerOffset = |
5212 kConstructorOffset + kPointerSize; | 5265 kConstructorOffset + kPointerSize; |
5213 static const int kDescriptorsOffset = | 5266 static const int kDescriptorsOffset = |
5214 kTransitionsOrBackPointerOffset + kPointerSize; | 5267 kTransitionsOrBackPointerOffset + kPointerSize; |
5215 static const int kCodeCacheOffset = kDescriptorsOffset + kPointerSize; | 5268 static const int kCodeCacheOffset = kDescriptorsOffset + kPointerSize; |
5216 static const int kDependentCodesOffset = kCodeCacheOffset + kPointerSize; | 5269 static const int kDependentCodeOffset = kCodeCacheOffset + kPointerSize; |
5217 static const int kBitField3Offset = kDependentCodesOffset + kPointerSize; | 5270 static const int kBitField3Offset = kDependentCodeOffset + kPointerSize; |
5218 static const int kSize = kBitField3Offset + kPointerSize; | 5271 static const int kSize = kBitField3Offset + kPointerSize; |
5219 | 5272 |
5220 // Layout of pointer fields. Heap iteration code relies on them | 5273 // Layout of pointer fields. Heap iteration code relies on them |
5221 // being continuously allocated. | 5274 // being continuously allocated. |
5222 static const int kPointerFieldsBeginOffset = Map::kPrototypeOffset; | 5275 static const int kPointerFieldsBeginOffset = Map::kPrototypeOffset; |
5223 static const int kPointerFieldsEndOffset = kBitField3Offset + kPointerSize; | 5276 static const int kPointerFieldsEndOffset = kBitField3Offset + kPointerSize; |
5224 | 5277 |
5225 // Byte offsets within kInstanceSizesOffset. | 5278 // Byte offsets within kInstanceSizesOffset. |
5226 static const int kInstanceSizeOffset = kInstanceSizesOffset + 0; | 5279 static const int kInstanceSizeOffset = kInstanceSizesOffset + 0; |
5227 static const int kInObjectPropertiesByte = 1; | 5280 static const int kInObjectPropertiesByte = 1; |
(...skipping 3722 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
8950 } else { | 9003 } else { |
8951 value &= ~(1 << bit_position); | 9004 value &= ~(1 << bit_position); |
8952 } | 9005 } |
8953 return value; | 9006 return value; |
8954 } | 9007 } |
8955 }; | 9008 }; |
8956 | 9009 |
8957 } } // namespace v8::internal | 9010 } } // namespace v8::internal |
8958 | 9011 |
8959 #endif // V8_OBJECTS_H_ | 9012 #endif // V8_OBJECTS_H_ |
OLD | NEW |