Chromium Code Reviews

Unified Diff: src/objects.h

Issue 871253005: Use weak cells in dependent code. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Add comment Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Index: src/objects.h
diff --git a/src/objects.h b/src/objects.h
index 51755054cb00a3513faae0b6c5684ce5473f105e..90b9ed5114fffd3b3008659523758c72e821e92b 100644
--- a/src/objects.h
+++ b/src/objects.h
@@ -5556,9 +5556,9 @@ class CompilationInfo;
//
// 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.
+// 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
@@ -5612,15 +5612,21 @@ class DependentCode: public FixedArray {
int start_indexes_[kGroupCount + 1];
};
- bool Contains(DependencyGroup group, Code* code);
- static Handle<DependentCode> Insert(Handle<DependentCode> entries,
- DependencyGroup group,
- Handle<Object> object);
- void UpdateToFinishedCode(DependencyGroup group,
- CompilationInfo* info,
- Code* code);
+ bool Contains(DependencyGroup group, WeakCell* code_cell);
+
+ static Handle<DependentCode> InsertCompilationInfo(
+ Handle<DependentCode> entries, DependencyGroup group,
+ Handle<Foreign> info);
+
+ static Handle<DependentCode> InsertWeakCode(Handle<DependentCode> entries,
+ DependencyGroup group,
+ Handle<WeakCell> code_cell);
+
+ void UpdateToFinishedCode(DependencyGroup group, Foreign* info,
+ WeakCell* code_cell);
+
void RemoveCompilationInfo(DependentCode::DependencyGroup group,
- CompilationInfo* info);
+ Foreign* info);
void DeoptimizeDependentCodeGroup(Isolate* isolate,
DependentCode::DependencyGroup group);
@@ -5632,12 +5638,8 @@ class DependentCode: public FixedArray {
// and the mark compact collector.
inline int number_of_entries(DependencyGroup group);
inline void set_number_of_entries(DependencyGroup group, int value);
- inline bool is_code_at(int i);
- inline Code* code_at(int i);
- inline CompilationInfo* compilation_info_at(int i);
- inline void set_object_at(int i, Object* object);
- inline Object** slot_at(int i);
inline Object* object_at(int i);
+ inline void set_object_at(int i, Object* object);
inline void clear_at(int i);
inline void copy(int from, int to);
DECLARE_CAST(DependentCode)
@@ -5649,9 +5651,20 @@ class DependentCode: public FixedArray {
static void SetMarkedForDeoptimization(Code* code, DependencyGroup group);
private:
+ static Handle<DependentCode> Insert(Handle<DependentCode> entries,
+ DependencyGroup group,
+ Handle<Object> object);
+ 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();
+ static int Grow(int number_of_entries) {
+ if (number_of_entries < 5) return number_of_entries + 1;
+ return number_of_entries * 5 / 4;
+ }
static const int kCodesStartIndex = kGroupCount;
};
@@ -8454,7 +8467,7 @@ class AllocationSite: public Struct {
// During mark compact we need to take special care for the dependent code
// field.
static const int kPointerFieldsBeginOffset = kTransitionInfoOffset;
- static const int kPointerFieldsEndOffset = kDependentCodeOffset;
+ static const int kPointerFieldsEndOffset = kWeakNextOffset;
// For other visitors, use the fixed body descriptor below.
typedef FixedBodyDescriptor<HeapObject::kHeaderSize,
@@ -9705,7 +9718,7 @@ class PropertyCell: public Cell {
static const int kSize = kDependentCodeOffset + kPointerSize;
static const int kPointerFieldsBeginOffset = kValueOffset;
- static const int kPointerFieldsEndOffset = kDependentCodeOffset;
+ static const int kPointerFieldsEndOffset = kSize;
typedef FixedBodyDescriptor<kValueOffset,
kSize,

Powered by Google App Engine