Index: src/objects.h |
diff --git a/src/objects.h b/src/objects.h |
index 12413123c09c2a922da3f76a7fbe3679a3dd0609..a2787c169b915b399acc1b5f0b2a7f0bc84a082b 100644 |
--- a/src/objects.h |
+++ b/src/objects.h |
@@ -862,7 +862,7 @@ class MaybeObject BASE_EMBEDDED { |
V(TransitionArray) \ |
V(DeoptimizationInputData) \ |
V(DeoptimizationOutputData) \ |
- V(DependentCodes) \ |
+ V(DependentCode) \ |
V(TypeFeedbackCells) \ |
V(FixedArray) \ |
V(FixedDoubleArray) \ |
@@ -4683,24 +4683,68 @@ 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. |
-class DependentCodes: public FixedArray { |
+// 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. The order of the |
+// code objects within a group is not preserved. |
+// |
+// 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 DependentCode: public FixedArray { |
public: |
- inline int number_of_codes(); |
- inline void set_number_of_codes(int value); |
+ enum DependencyGroup { |
+ // Group of code that weakly embed this map and depend on being |
+ // deoptimized when the map is garbage collected. |
+ kWeaklyEmbeddedGroup, |
+ // Group of code that omit run-time prototype checks for prototypes |
+ // described by this map. The group is deoptimized whenever an object |
+ // described by this map changes shape (and transitions to a new map), |
+ // possibly invalidating the assumptions embedded in the code. |
+ kPrototypeCheckGroup, |
+ kGroupCount = kPrototypeCheckGroup + 1 |
+ }; |
Michael Starzinger
2013/02/14 12:44:04
Add an empty newline after this enum.
ulan
2013/02/15 09:24:02
Done.
|
+ // Array for holding the index of the first code object of each group. |
+ // The last element stores the total number of code objects. |
+ class GroupStartIndexes { |
+ public: |
+ explicit GroupStartIndexes(DependentCode* codes); |
+ void Recompute(DependentCode* codes); |
+ int at(int i) { return start_indexes_[i]; } |
+ private: |
+ int start_indexes_[kGroupCount + 1]; |
+ }; |
Michael Starzinger
2013/02/14 12:44:04
Add and empty newline after this class.
ulan
2013/02/15 09:24:02
Done.
|
+ bool Contains(DependencyGroup group, Code* code); |
+ static Handle<DependentCode> Insert(Handle<DependentCode> codes, |
+ DependencyGroup group, |
+ Handle<Code> value); |
+ void DeoptimizeDependentCodeGroup(DependentCode::DependencyGroup group); |
+ |
+ // The following low-level accessors should only be used by this class |
+ // and the mark compactor. |
Michael Starzinger
2013/02/14 12:44:04
s/mark compactor/mark compact collector/
ulan
2013/02/15 09:24:02
Done.
|
+ 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); |
- static Handle<DependentCodes> Append(Handle<DependentCodes> codes, |
- Handle<Code> value); |
- static inline DependentCodes* cast(Object* object); |
- bool Contains(Code* code); |
+ static inline DependentCode* cast(Object* object); |
+ |
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; |
}; |
@@ -4934,7 +4978,7 @@ class Map: public HeapObject { |
DECL_ACCESSORS(code_cache, Object) |
// [dependent codes]: list of optimized codes that have this map embedded. |
Michael Starzinger
2013/02/14 12:44:04
The name in the comment is outdated.
ulan
2013/02/15 09:24:02
Done.
|
- DECL_ACCESSORS(dependent_codes, DependentCodes) |
+ DECL_ACCESSORS(dependent_code, DependentCode) |
// [back pointer]: points back to the parent map from which a transition |
// leads to this map. The field overlaps with prototype transitions and the |
@@ -5151,7 +5195,13 @@ class Map: public HeapObject { |
return instance_type() >= FIRST_JS_OBJECT_TYPE; |
} |
- inline void AddDependentCode(Handle<Code> code); |
+ |
+ inline void NotifyObjectLayoutChange(); |
+ |
+ inline bool CanOmitPrototypeChecks(); |
+ |
+ inline void AddDependentCode(DependentCode::DependencyGroup group, |
+ Handle<Code> code); |
// Dispatched behavior. |
DECLARE_PRINTER(Map) |
@@ -5201,8 +5251,8 @@ class Map: public HeapObject { |
static const int kDescriptorsOffset = |
kTransitionsOrBackPointerOffset + kPointerSize; |
static const int kCodeCacheOffset = kDescriptorsOffset + kPointerSize; |
- static const int kDependentCodesOffset = kCodeCacheOffset + kPointerSize; |
- static const int kBitField3Offset = kDependentCodesOffset + kPointerSize; |
+ static const int kDependentCodeOffset = kCodeCacheOffset + kPointerSize; |
+ static const int kBitField3Offset = kDependentCodeOffset + kPointerSize; |
static const int kSize = kBitField3Offset + kPointerSize; |
// Layout of pointer fields. Heap iteration code relies on them |