Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(616)

Unified Diff: src/objects.h

Issue 1435313002: Refactor dependent code. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/crankshaft/lithium.cc ('k') | src/objects.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/objects.h
diff --git a/src/objects.h b/src/objects.h
index 93f57333a150498810f73f264c74082e2147ff3b..d7aa7ea4d3e59a315e98046b0f90eb797a01f714 100644
--- a/src/objects.h
+++ b/src/objects.h
@@ -5389,24 +5389,24 @@ class Code: public HeapObject {
};
-// This class describes the layout of dependent codes array of a map. The
-// 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:
+// Dependent code is a singly linked list of fixed arrays. Each array contains
+// code objects in weak cells for one dependent group. 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.
//
-// +----+----+-----+----+---------+----------+-----+---------+-----------+
-// | C1 | C2 | ... | Cn | group 1 | group 2 | ... | group n | undefined |
-// +----+----+-----+----+---------+----------+-----+---------+-----------+
+// +------+-----------------+--------+--------+-----+--------+-----------+-----+
+// | next | count & group 1 | code 1 | code 2 | ... | code n | undefined | ... |
+// +------+-----------------+--------+--------+-----+--------+-----------+-----+
+// |
+// V
+// +------+-----------------+--------+--------+-----+--------+-----------+-----+
+// | next | count & group 2 | code 1 | code 2 | ... | code m | undefined | ... |
+// +------+-----------------+--------+--------+-----+--------+-----------+-----+
+// |
+// V
+// empty_fixed_array()
//
-// 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 in weak cells. 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.
+// The list of fixed arrays is ordered by dependency groups.
class DependentCode: public FixedArray {
public:
@@ -5441,19 +5441,8 @@ class DependentCode: public FixedArray {
static const int kGroupCount = kAllocationSiteTransitionChangedGroup + 1;
- // 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* entries);
- void Recompute(DependentCode* entries);
- int at(int i) { return start_indexes_[i]; }
- int number_of_entries() { return start_indexes_[kGroupCount]; }
- private:
- int start_indexes_[kGroupCount + 1];
- };
-
bool Contains(DependencyGroup group, WeakCell* code_cell);
+ bool IsEmpty(DependencyGroup group);
static Handle<DependentCode> InsertCompilationDependencies(
Handle<DependentCode> entries, DependencyGroup group,
@@ -5477,8 +5466,12 @@ class DependentCode: public FixedArray {
// The following low-level accessors should only be used by this class
// and the mark compact collector.
- inline int number_of_entries(DependencyGroup group);
- inline void set_number_of_entries(DependencyGroup group, int value);
+ inline DependentCode* next_link();
+ inline void set_next_link(DependentCode* next);
+ inline int count();
+ inline void set_count(int value);
+ inline DependencyGroup group();
+ inline void set_group(DependencyGroup group);
inline Object* object_at(int i);
inline void set_object_at(int i, Object* object);
inline void clear_at(int i);
@@ -5492,10 +5485,9 @@ class DependentCode: public FixedArray {
static Handle<DependentCode> Insert(Handle<DependentCode> entries,
DependencyGroup group,
Handle<Object> object);
+ static Handle<DependentCode> New(DependencyGroup group, Handle<Object> object,
+ Handle<DependentCode> next);
static Handle<DependentCode> EnsureSpace(Handle<DependentCode> entries);
- // 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);
// Compact by removing cleared weak cells and return true if there was
// any cleared weak cell.
bool Compact();
@@ -5503,7 +5495,14 @@ class DependentCode: public FixedArray {
if (number_of_entries < 5) return number_of_entries + 1;
return number_of_entries * 5 / 4;
}
- static const int kCodesStartIndex = kGroupCount;
+ inline int flags();
+ inline void set_flags(int flags);
+ class GroupField : public BitField<int, 0, 3> {};
+ class CountField : public BitField<int, 3, 27> {};
+ STATIC_ASSERT(kGroupCount <= GroupField::kMax + 1);
+ static const int kNextLinkIndex = 0;
+ static const int kFlagsIndex = 1;
+ static const int kCodesStartIndex = 2;
};
« no previous file with comments | « src/crankshaft/lithium.cc ('k') | src/objects.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698