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 844 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 855 V(FreeSpace) \ | 855 V(FreeSpace) \ |
| 856 V(JSReceiver) \ | 856 V(JSReceiver) \ |
| 857 V(JSObject) \ | 857 V(JSObject) \ |
| 858 V(JSContextExtensionObject) \ | 858 V(JSContextExtensionObject) \ |
| 859 V(JSModule) \ | 859 V(JSModule) \ |
| 860 V(Map) \ | 860 V(Map) \ |
| 861 V(DescriptorArray) \ | 861 V(DescriptorArray) \ |
| 862 V(TransitionArray) \ | 862 V(TransitionArray) \ |
| 863 V(DeoptimizationInputData) \ | 863 V(DeoptimizationInputData) \ |
| 864 V(DeoptimizationOutputData) \ | 864 V(DeoptimizationOutputData) \ |
| 865 V(DependentCodes) \ | 865 V(DependentCode) \ |
| 866 V(TypeFeedbackCells) \ | 866 V(TypeFeedbackCells) \ |
| 867 V(FixedArray) \ | 867 V(FixedArray) \ |
| 868 V(FixedDoubleArray) \ | 868 V(FixedDoubleArray) \ |
| 869 V(Context) \ | 869 V(Context) \ |
| 870 V(NativeContext) \ | 870 V(NativeContext) \ |
| 871 V(ScopeInfo) \ | 871 V(ScopeInfo) \ |
| 872 V(JSFunction) \ | 872 V(JSFunction) \ |
| 873 V(Code) \ | 873 V(Code) \ |
| 874 V(Oddball) \ | 874 V(Oddball) \ |
| 875 V(SharedFunctionInfo) \ | 875 V(SharedFunctionInfo) \ |
| (...skipping 3812 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4688 // following layout for n dependency groups: | 4688 // following layout for n dependency groups: |
| 4689 // | 4689 // |
| 4690 // +----+----+-----+----+---------+----------+-----+---------+-----------+ | 4690 // +----+----+-----+----+---------+----------+-----+---------+-----------+ |
| 4691 // | C1 | C2 | ... | Cn | group 1 | group 2 | ... | group n | undefined | | 4691 // | C1 | C2 | ... | Cn | group 1 | group 2 | ... | group n | undefined | |
| 4692 // +----+----+-----+----+---------+----------+-----+---------+-----------+ | 4692 // +----+----+-----+----+---------+----------+-----+---------+-----------+ |
| 4693 // | 4693 // |
| 4694 // The first n elements are Smis, each of them specifies the number of codes | 4694 // The first n elements are Smis, each of them specifies the number of codes |
| 4695 // in the corresponding group. The subsequent elements contain grouped code | 4695 // in the corresponding group. The subsequent elements contain grouped code |
| 4696 // objects. The suffix of the array can be filled with the undefined value if | 4696 // objects. The suffix of the array can be filled with the undefined value if |
| 4697 // the number of codes is less than the length of the array. | 4697 // the number of codes is less than the length of the array. |
| 4698 // | 4698 // |
| 4699 // All code indexes used in the class are counted starting from the first | 4699 // All code indexes used in the class are counted starting from the first |
| 4700 // code object of the first group. In other words, code index 0 corresponds | 4700 // code object of the first group. In other words, code index 0 corresponds |
| 4701 // to array index n = kCodesStartIndex. | 4701 // to array index n = kCodesStartIndex. |
| 4702 | 4702 |
| 4703 class DependentCodes: public FixedArray { | 4703 class DependentCode: public FixedArray { |
| 4704 public: | 4704 public: |
| 4705 enum DependencyGroup { | 4705 enum DependencyGroup { |
| 4706 // Group of codes that weakly embed this map and depend on being | 4706 // Group of codes that weakly embed this map and depend on being |
|
Toon Verwaest
2013/02/13 15:18:25
Group of code
ulan
2013/02/14 09:30:46
Done.
| |
| 4707 // deoptimized when the map is garbage collected. | 4707 // deoptimized when the map is garbage collected. |
| 4708 kWeaklyEmbeddedGroup, | 4708 kWeaklyEmbeddedGroup, |
| 4709 kGroupCount = kWeaklyEmbeddedGroup + 1 | 4709 // Group of code that omit run-time prototype checks for prototypes |
| 4710 // described by this map. The group is deoptimized whenever an object | |
| 4711 // described by this map changes shape (and transitions to a new map), | |
| 4712 // possibly invalidating the assumptions embedded in the code. | |
| 4713 kPrototypeCheckGroup, | |
| 4714 kGroupCount = kPrototypeCheckGroup + 1 | |
| 4710 }; | 4715 }; |
| 4711 // Array for holding the index of the first code object of each group. | 4716 // Array for holding the index of the first code object of each group. |
| 4712 // The last element stores the total number of code objects. | 4717 // The last element stores the total number of code objects. |
| 4713 typedef int GroupStartIndexes[kGroupCount + 1]; | 4718 class GroupStartIndexes { |
| 4719 public: | |
| 4720 explicit GroupStartIndexes(DependentCode* codes); | |
| 4721 void Recompute(DependentCode* codes); | |
| 4722 int at(int i) { return start_indexes_[i]; } | |
| 4723 private: | |
| 4724 int start_indexes_[kGroupCount + 1]; | |
| 4725 }; | |
| 4714 inline int number_of_codes(DependencyGroup group); | 4726 inline int number_of_codes(DependencyGroup group); |
| 4715 inline void set_number_of_codes(DependencyGroup group, int value); | 4727 inline void set_number_of_codes(DependencyGroup group, int value); |
| 4716 inline Code* code_at(int i); | 4728 inline Code* code_at(int i); |
| 4717 inline void set_code_at(int i, Code* value); | 4729 inline void set_code_at(int i, Code* value); |
| 4718 inline Object** code_slot_at(int i); | 4730 inline Object** code_slot_at(int i); |
| 4719 inline void clear_code_at(int i); | 4731 inline void clear_code_at(int i); |
| 4720 static inline DependentCodes* cast(Object* object); | 4732 static inline DependentCode* cast(Object* object); |
| 4721 inline void ComputeGroupStartIndexes(GroupStartIndexes starts); | |
| 4722 bool Contains(DependencyGroup group, Code* code); | 4733 bool Contains(DependencyGroup group, Code* code); |
| 4723 static Handle<DependentCodes> Insert(Handle<DependentCodes> codes, | 4734 static Handle<DependentCode> Insert(Handle<DependentCode> codes, |
| 4724 DependencyGroup group, | 4735 DependencyGroup group, |
| 4725 Handle<Code> value); | 4736 Handle<Code> value); |
| 4726 | 4737 |
| 4727 private: | 4738 private: |
| 4728 // Make a room at the end of the given group by moving out the first | 4739 // Make a room at the end of the given group by moving out the first |
| 4729 // code objects of the subsequent groups. | 4740 // code objects of the subsequent groups. |
| 4730 inline void ExtendGroup(DependencyGroup group); | 4741 inline void ExtendGroup(DependencyGroup group); |
| 4731 static const int kCodesStartIndex = kGroupCount; | 4742 static const int kCodesStartIndex = kGroupCount; |
| 4732 }; | 4743 }; |
| 4733 | 4744 |
| (...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4955 inline JSFunction* unchecked_constructor(); | 4966 inline JSFunction* unchecked_constructor(); |
| 4956 | 4967 |
| 4957 // [instance descriptors]: describes the object. | 4968 // [instance descriptors]: describes the object. |
| 4958 DECL_ACCESSORS(instance_descriptors, DescriptorArray) | 4969 DECL_ACCESSORS(instance_descriptors, DescriptorArray) |
| 4959 inline void InitializeDescriptors(DescriptorArray* descriptors); | 4970 inline void InitializeDescriptors(DescriptorArray* descriptors); |
| 4960 | 4971 |
| 4961 // [stub cache]: contains stubs compiled for this map. | 4972 // [stub cache]: contains stubs compiled for this map. |
| 4962 DECL_ACCESSORS(code_cache, Object) | 4973 DECL_ACCESSORS(code_cache, Object) |
| 4963 | 4974 |
| 4964 // [dependent codes]: list of optimized codes that have this map embedded. | 4975 // [dependent codes]: list of optimized codes that have this map embedded. |
| 4965 DECL_ACCESSORS(dependent_codes, DependentCodes) | 4976 DECL_ACCESSORS(dependent_code, DependentCode) |
| 4966 | 4977 |
| 4967 // [back pointer]: points back to the parent map from which a transition | 4978 // [back pointer]: points back to the parent map from which a transition |
| 4968 // leads to this map. The field overlaps with prototype transitions and the | 4979 // leads to this map. The field overlaps with prototype transitions and the |
| 4969 // back pointer will be moved into the prototype transitions array if | 4980 // back pointer will be moved into the prototype transitions array if |
| 4970 // required. | 4981 // required. |
| 4971 inline Object* GetBackPointer(); | 4982 inline Object* GetBackPointer(); |
| 4972 inline void SetBackPointer(Object* value, | 4983 inline void SetBackPointer(Object* value, |
| 4973 WriteBarrierMode mode = UPDATE_WRITE_BARRIER); | 4984 WriteBarrierMode mode = UPDATE_WRITE_BARRIER); |
| 4974 inline void init_back_pointer(Object* undefined); | 4985 inline void init_back_pointer(Object* undefined); |
| 4975 | 4986 |
| (...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5172 // heap verification is turned on. | 5183 // heap verification is turned on. |
| 5173 void ZapPrototypeTransitions(); | 5184 void ZapPrototypeTransitions(); |
| 5174 void ZapTransitions(); | 5185 void ZapTransitions(); |
| 5175 | 5186 |
| 5176 bool CanTransition() { | 5187 bool CanTransition() { |
| 5177 // Only JSObject and subtypes have map transitions and back pointers. | 5188 // Only JSObject and subtypes have map transitions and back pointers. |
| 5178 STATIC_ASSERT(LAST_TYPE == LAST_JS_OBJECT_TYPE); | 5189 STATIC_ASSERT(LAST_TYPE == LAST_JS_OBJECT_TYPE); |
| 5179 return instance_type() >= FIRST_JS_OBJECT_TYPE; | 5190 return instance_type() >= FIRST_JS_OBJECT_TYPE; |
| 5180 } | 5191 } |
| 5181 | 5192 |
| 5182 inline void AddDependentCode(DependentCodes::DependencyGroup group, | 5193 |
| 5194 inline void NotifyObjectLayoutChange(); | |
| 5195 | |
| 5196 inline bool CanOmitPrototypeChecks(); | |
| 5197 | |
| 5198 inline void AddDependentCode(DependentCode::DependencyGroup group, | |
| 5183 Handle<Code> code); | 5199 Handle<Code> code); |
| 5184 | 5200 |
| 5201 void DeoptimizeDependentCode(DependentCode::DependencyGroup group); | |
| 5202 | |
| 5185 // Dispatched behavior. | 5203 // Dispatched behavior. |
| 5186 DECLARE_PRINTER(Map) | 5204 DECLARE_PRINTER(Map) |
| 5187 DECLARE_VERIFIER(Map) | 5205 DECLARE_VERIFIER(Map) |
| 5188 | 5206 |
| 5189 #ifdef VERIFY_HEAP | 5207 #ifdef VERIFY_HEAP |
| 5190 void SharedMapVerify(); | 5208 void SharedMapVerify(); |
| 5191 #endif | 5209 #endif |
| 5192 | 5210 |
| 5193 inline int visitor_id(); | 5211 inline int visitor_id(); |
| 5194 inline void set_visitor_id(int visitor_id); | 5212 inline void set_visitor_id(int visitor_id); |
| (...skipping 28 matching lines...) Expand all Loading... | |
| 5223 static const int kConstructorOffset = kPrototypeOffset + kPointerSize; | 5241 static const int kConstructorOffset = kPrototypeOffset + kPointerSize; |
| 5224 // Storage for the transition array is overloaded to directly contain a back | 5242 // Storage for the transition array is overloaded to directly contain a back |
| 5225 // pointer if unused. When the map has transitions, the back pointer is | 5243 // pointer if unused. When the map has transitions, the back pointer is |
| 5226 // transferred to the transition array and accessed through an extra | 5244 // transferred to the transition array and accessed through an extra |
| 5227 // indirection. | 5245 // indirection. |
| 5228 static const int kTransitionsOrBackPointerOffset = | 5246 static const int kTransitionsOrBackPointerOffset = |
| 5229 kConstructorOffset + kPointerSize; | 5247 kConstructorOffset + kPointerSize; |
| 5230 static const int kDescriptorsOffset = | 5248 static const int kDescriptorsOffset = |
| 5231 kTransitionsOrBackPointerOffset + kPointerSize; | 5249 kTransitionsOrBackPointerOffset + kPointerSize; |
| 5232 static const int kCodeCacheOffset = kDescriptorsOffset + kPointerSize; | 5250 static const int kCodeCacheOffset = kDescriptorsOffset + kPointerSize; |
| 5233 static const int kDependentCodesOffset = kCodeCacheOffset + kPointerSize; | 5251 static const int kDependentCodeOffset = kCodeCacheOffset + kPointerSize; |
| 5234 static const int kBitField3Offset = kDependentCodesOffset + kPointerSize; | 5252 static const int kBitField3Offset = kDependentCodeOffset + kPointerSize; |
| 5235 static const int kSize = kBitField3Offset + kPointerSize; | 5253 static const int kSize = kBitField3Offset + kPointerSize; |
| 5236 | 5254 |
| 5237 // Layout of pointer fields. Heap iteration code relies on them | 5255 // Layout of pointer fields. Heap iteration code relies on them |
| 5238 // being continuously allocated. | 5256 // being continuously allocated. |
| 5239 static const int kPointerFieldsBeginOffset = Map::kPrototypeOffset; | 5257 static const int kPointerFieldsBeginOffset = Map::kPrototypeOffset; |
| 5240 static const int kPointerFieldsEndOffset = kBitField3Offset + kPointerSize; | 5258 static const int kPointerFieldsEndOffset = kBitField3Offset + kPointerSize; |
| 5241 | 5259 |
| 5242 // Byte offsets within kInstanceSizesOffset. | 5260 // Byte offsets within kInstanceSizesOffset. |
| 5243 static const int kInstanceSizeOffset = kInstanceSizesOffset + 0; | 5261 static const int kInstanceSizeOffset = kInstanceSizesOffset + 0; |
| 5244 static const int kInObjectPropertiesByte = 1; | 5262 static const int kInObjectPropertiesByte = 1; |
| (...skipping 3669 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 8914 } else { | 8932 } else { |
| 8915 value &= ~(1 << bit_position); | 8933 value &= ~(1 << bit_position); |
| 8916 } | 8934 } |
| 8917 return value; | 8935 return value; |
| 8918 } | 8936 } |
| 8919 }; | 8937 }; |
| 8920 | 8938 |
| 8921 } } // namespace v8::internal | 8939 } } // namespace v8::internal |
| 8922 | 8940 |
| 8923 #endif // V8_OBJECTS_H_ | 8941 #endif // V8_OBJECTS_H_ |
| OLD | NEW |