Chromium Code Reviews| Index: src/objects.h |
| diff --git a/src/objects.h b/src/objects.h |
| index 12413123c09c2a922da3f76a7fbe3679a3dd0609..1f6e7cc0878c87a8630b77f4e05bd40f7d89cc18 100644 |
| --- a/src/objects.h |
| +++ b/src/objects.h |
| @@ -4683,24 +4683,52 @@ class Code: public HeapObject { |
| // This class describes the layout of dependent codes array of a map. The |
| -// first element contains the number of codes as a Smi. The subsequent |
| -// elements contain code objects. The suffix of the array can be filled with the |
| -// undefined value if the number of codes is less than the length of the array. |
| +// array is partitioned into several groups of dependent codes. Each group |
| +// contains codes with the same dependency on the map. The array has the |
| +// following layout for n dependency groups: |
| +// |
| +// +----+----+-----+----+---------+----------+-----+---------+-----------+ |
| +// | C1 | C2 | ... | Cn | group 1 | group 2 | ... | group n | undefined | |
| +// +----+----+-----+----+---------+----------+-----+---------+-----------+ |
| +// |
| +// The first n elements are Smis, each of them specifies the number of codes |
| +// in the corresponding group. The subsequent elements contain grouped code |
| +// objects. The suffix of the array can be filled with the undefined value if |
| +// the number of codes is less than the length of the array. |
|
Michael Starzinger
2013/02/14 10:40:52
Can we also add a sentence stating that the order
ulan_google
2013/02/14 11:59:06
Done.
|
| +// |
| +// All code indexes used in the class are counted starting from the first |
| +// code object of the first group. In other words, code index 0 corresponds |
| +// to array index n = kCodesStartIndex. |
| + |
| class DependentCodes: public FixedArray { |
| public: |
| - inline int number_of_codes(); |
| - inline void set_number_of_codes(int value); |
| + enum DependencyGroup { |
| + // Group of codes that weakly embed this map and depend on being |
| + // deoptimized when the map is garbage collected. |
| + kWeaklyEmbeddedGroup, |
| + kGroupCount = kWeaklyEmbeddedGroup + 1 |
| + }; |
| + // Array for holding the index of the first code object of each group. |
| + // The last element stores the total number of code objects. |
| + typedef int GroupStartIndexes[kGroupCount + 1]; |
| + inline int number_of_codes(DependencyGroup group); |
| + inline void set_number_of_codes(DependencyGroup group, int value); |
| inline Code* code_at(int i); |
| inline void set_code_at(int i, Code* value); |
| inline Object** code_slot_at(int i); |
| inline void clear_code_at(int i); |
|
Michael Starzinger
2013/02/14 10:40:52
As discussed offline: Can we (visually) separate t
ulan_google
2013/02/14 11:59:06
Done.
|
| - static Handle<DependentCodes> Append(Handle<DependentCodes> codes, |
| - Handle<Code> value); |
| static inline DependentCodes* cast(Object* object); |
| - bool Contains(Code* code); |
| + inline void ComputeGroupStartIndexes(GroupStartIndexes starts); |
| + bool Contains(DependencyGroup group, Code* code); |
| + static Handle<DependentCodes> Insert(Handle<DependentCodes> codes, |
| + DependencyGroup group, |
| + Handle<Code> value); |
| + |
| private: |
| - static const int kNumberOfCodesIndex = 0; |
| - static const int kCodesIndex = 1; |
| + // Make a room at the end of the given group by moving out the first |
| + // code objects of the subsequent groups. |
| + inline void ExtendGroup(DependencyGroup group); |
| + static const int kCodesStartIndex = kGroupCount; |
| }; |
| @@ -5151,7 +5179,8 @@ class Map: public HeapObject { |
| return instance_type() >= FIRST_JS_OBJECT_TYPE; |
| } |
| - inline void AddDependentCode(Handle<Code> code); |
| + inline void AddDependentCode(DependentCodes::DependencyGroup group, |
| + Handle<Code> code); |
| // Dispatched behavior. |
| DECLARE_PRINTER(Map) |