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 4677 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 DependentCodes: 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 |
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 codes that omitted prototype check for a prototype with this map |
4710 // and depend on being deoptimized when map layout changes. | |
Toon Verwaest
2013/02/13 10:40:07
Group of code that omit run-time prototype checks
ulan
2013/02/13 12:27:38
Done.
| |
4711 kPrototypeCheckGroup, | |
4712 kGroupCount = kPrototypeCheckGroup + 1 | |
4710 }; | 4713 }; |
4711 // Array for holding the index of the first code object of each group. | 4714 // Array for holding the index of the first code object of each group. |
4712 // The last element stores the total number of code objects. | 4715 // The last element stores the total number of code objects. |
4713 typedef int GroupStartIndexes[kGroupCount + 1]; | 4716 class GroupStartIndexes { |
4717 public: | |
4718 explicit GroupStartIndexes(DependentCodes* codes); | |
4719 void Recompute(DependentCodes* codes); | |
4720 int at(int i) { return start_indexes_[i]; } | |
4721 private: | |
4722 int start_indexes_[kGroupCount + 1]; | |
4723 }; | |
4714 inline int number_of_codes(DependencyGroup group); | 4724 inline int number_of_codes(DependencyGroup group); |
4715 inline void set_number_of_codes(DependencyGroup group, int value); | 4725 inline void set_number_of_codes(DependencyGroup group, int value); |
4716 inline Code* code_at(int i); | 4726 inline Code* code_at(int i); |
4717 inline void set_code_at(int i, Code* value); | 4727 inline void set_code_at(int i, Code* value); |
4718 inline Object** code_slot_at(int i); | 4728 inline Object** code_slot_at(int i); |
4719 inline void clear_code_at(int i); | 4729 inline void clear_code_at(int i); |
4720 static inline DependentCodes* cast(Object* object); | 4730 static inline DependentCodes* cast(Object* object); |
4721 inline void ComputeGroupStartIndexes(GroupStartIndexes starts); | |
4722 bool Contains(DependencyGroup group, Code* code); | 4731 bool Contains(DependencyGroup group, Code* code); |
4723 static Handle<DependentCodes> Insert(Handle<DependentCodes> codes, | 4732 static Handle<DependentCodes> Insert(Handle<DependentCodes> codes, |
4724 DependencyGroup group, | 4733 DependencyGroup group, |
4725 Handle<Code> value); | 4734 Handle<Code> value); |
4726 | 4735 |
4727 private: | 4736 private: |
4728 // Make a room at the end of the given group by moving out the first | 4737 // Make a room at the end of the given group by moving out the first |
4729 // code objects of the subsequent groups. | 4738 // code objects of the subsequent groups. |
4730 inline void ExtendGroup(DependencyGroup group); | 4739 inline void ExtendGroup(DependencyGroup group); |
4731 static const int kCodesStartIndex = kGroupCount; | 4740 static const int kCodesStartIndex = kGroupCount; |
(...skipping 440 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5172 // heap verification is turned on. | 5181 // heap verification is turned on. |
5173 void ZapPrototypeTransitions(); | 5182 void ZapPrototypeTransitions(); |
5174 void ZapTransitions(); | 5183 void ZapTransitions(); |
5175 | 5184 |
5176 bool CanTransition() { | 5185 bool CanTransition() { |
5177 // Only JSObject and subtypes have map transitions and back pointers. | 5186 // Only JSObject and subtypes have map transitions and back pointers. |
5178 STATIC_ASSERT(LAST_TYPE == LAST_JS_OBJECT_TYPE); | 5187 STATIC_ASSERT(LAST_TYPE == LAST_JS_OBJECT_TYPE); |
5179 return instance_type() >= FIRST_JS_OBJECT_TYPE; | 5188 return instance_type() >= FIRST_JS_OBJECT_TYPE; |
5180 } | 5189 } |
5181 | 5190 |
5191 | |
5192 inline void NotifyObjectLayoutChange(); | |
5193 | |
5194 inline bool CanOmitPrototypeChecks(); | |
5195 | |
5182 inline void AddDependentCode(DependentCodes::DependencyGroup group, | 5196 inline void AddDependentCode(DependentCodes::DependencyGroup group, |
5183 Handle<Code> code); | 5197 Handle<Code> code); |
5184 | 5198 |
5199 void DeoptimizeDependentCodes(DependentCodes::DependencyGroup group); | |
5200 | |
5185 // Dispatched behavior. | 5201 // Dispatched behavior. |
5186 DECLARE_PRINTER(Map) | 5202 DECLARE_PRINTER(Map) |
5187 DECLARE_VERIFIER(Map) | 5203 DECLARE_VERIFIER(Map) |
5188 | 5204 |
5189 #ifdef VERIFY_HEAP | 5205 #ifdef VERIFY_HEAP |
5190 void SharedMapVerify(); | 5206 void SharedMapVerify(); |
5191 #endif | 5207 #endif |
5192 | 5208 |
5193 inline int visitor_id(); | 5209 inline int visitor_id(); |
5194 inline void set_visitor_id(int visitor_id); | 5210 inline void set_visitor_id(int visitor_id); |
(...skipping 3719 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
8914 } else { | 8930 } else { |
8915 value &= ~(1 << bit_position); | 8931 value &= ~(1 << bit_position); |
8916 } | 8932 } |
8917 return value; | 8933 return value; |
8918 } | 8934 } |
8919 }; | 8935 }; |
8920 | 8936 |
8921 } } // namespace v8::internal | 8937 } } // namespace v8::internal |
8922 | 8938 |
8923 #endif // V8_OBJECTS_H_ | 8939 #endif // V8_OBJECTS_H_ |
OLD | NEW |