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

Unified Diff: src/global-handles.h

Issue 14175005: New GC related APIs: Implicit references. (Closed) Base URL: git://github.com/v8/v8.git@master
Patch Set: style Created 7 years, 8 months 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
Index: src/global-handles.h
diff --git a/src/global-handles.h b/src/global-handles.h
index ffec6c20445f4abe9258b5c95024d17e2e9ea7f1..3ce685c3cd64646c693e0c1e2337c122c155e205 100644
--- a/src/global-handles.h
+++ b/src/global-handles.h
@@ -42,10 +42,16 @@ namespace internal {
// At GC the destroyed global handles are removed from the free list
// and deallocated.
+// Data structures for tracking object groups and implicit references.
+
// An object group is treated like a single JS object: if one of object in
// the group is alive, all objects in the same group are considered alive.
// An object group is used to simulate object relationship in a DOM tree.
+// An implicit references group consists of two parts: a parent object and a
+// list of children objects. If the parent is alive, all the children are alive
+// too.
+
struct ObjectGroupConnection {
ObjectGroupConnection(UniqueId id, Object** object)
: id(id), object(object) {}
@@ -80,36 +86,21 @@ struct ObjectGroupRetainerInfo {
};
-// An implicit references group consists of two parts: a parent object and
-// a list of children objects. If the parent is alive, all the children
-// are alive too.
-class ImplicitRefGroup {
- public:
- static ImplicitRefGroup* New(HeapObject** parent,
- Object*** children,
- size_t length) {
- ASSERT(length > 0);
- ImplicitRefGroup* group = reinterpret_cast<ImplicitRefGroup*>(
- malloc(OFFSET_OF(ImplicitRefGroup, children_[length])));
- group->parent_ = parent;
- group->length_ = length;
- CopyWords(group->children_, children, static_cast<int>(length));
- return group;
- }
+struct ObjectGroupRepresentativeObject {
Michael Starzinger 2013/04/16 10:42:16 Let's just call this structure "ObjectGroupReprese
marja 2013/04/16 12:28:37 Done.
+ ObjectGroupRepresentativeObject(UniqueId id,
+ HeapObject** object)
+ : id(id), object(object) {}
- void Dispose() {
- free(this);
+ bool operator==(const ObjectGroupRepresentativeObject& other) const {
+ return id == other.id;
}
- HeapObject** parent_;
- size_t length_;
- Object** children_[1]; // Variable sized array.
+ bool operator<(const ObjectGroupRepresentativeObject& other) const {
+ return id < other.id;
+ }
- private:
- void* operator new(size_t size);
- void operator delete(void* p);
- ~ImplicitRefGroup();
- DISALLOW_IMPLICIT_CONSTRUCTORS(ImplicitRefGroup);
+ UniqueId id;
+ HeapObject** object;
};
@@ -223,7 +214,15 @@ class GlobalHandles {
// All groups are destroyed after a garbage collection.
void SetObjectGroupId(Object** handle, UniqueId id);
- void SetRetainedObjectInfo(UniqueId id, RetainedObjectInfo* info = NULL);
+ // Set RetainedObjectInfo for an object group. Should not be called more than
+ // once for a group. Should not be called for a group which contains no
+ // handles.
+ void SetRetainedObjectInfo(UniqueId id, RetainedObjectInfo* info);
+
+ // Sets a representative object for an object group. Should not be called more
+ // than once for a group. Should not be called for a group which contains no
+ // handles.
+ void SetRepresentativeObject(UniqueId id, HeapObject** representative_object);
// Add an implicit references' group.
// Should be only used in GC callback function before a collection.
@@ -232,6 +231,12 @@ class GlobalHandles {
Object*** children,
size_t length);
+ // Adds an implicit reference from a group (representative object of that
+ // group) to an object. Should be only used in GC callback function before a
+ // collection. All implicit references are destroyed after a mark-compact
+ // collection.
+ void AddImplicitReference(UniqueId id, Object** child);
+
List<ObjectGroupConnection>* object_groups() {
return &object_groups_;
}
@@ -240,11 +245,14 @@ class GlobalHandles {
return &retainer_infos_;
}
- // Returns the implicit references' groups.
- List<ImplicitRefGroup*>* implicit_ref_groups() {
+ List<ObjectGroupConnection>* implicit_ref_groups() {
return &implicit_ref_groups_;
}
+ List<ObjectGroupRepresentativeObject>* representative_objects() {
+ return &representative_objects_;
+ }
+
// Remove bags, this should only happen after GC.
void RemoveObjectGroups();
void RemoveImplicitRefGroups();
@@ -287,9 +295,13 @@ class GlobalHandles {
int post_gc_processing_count_;
+ // Object groups.
List<ObjectGroupConnection> object_groups_;
List<ObjectGroupRetainerInfo> retainer_infos_;
- List<ImplicitRefGroup*> implicit_ref_groups_;
+ List<ObjectGroupRepresentativeObject> representative_objects_;
+
+ // Implicit references.
+ List<ObjectGroupConnection> implicit_ref_groups_;
friend class Isolate;

Powered by Google App Engine
This is Rietveld 408576698