| Index: src/global-handles.h
|
| diff --git a/src/global-handles.h b/src/global-handles.h
|
| index 990014467cea5157612eed91400490ee3d6367d5..55d41fac501b88ff30a007f729a91a7242a98e95 100644
|
| --- a/src/global-handles.h
|
| +++ b/src/global-handles.h
|
| @@ -44,37 +44,52 @@ namespace internal {
|
| // 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.
|
| -class ObjectGroup {
|
| - public:
|
| - static ObjectGroup* New(Object*** handles,
|
| - size_t length,
|
| - v8::RetainedObjectInfo* info) {
|
| - ASSERT(length > 0);
|
| - ObjectGroup* group = reinterpret_cast<ObjectGroup*>(
|
| - malloc(OFFSET_OF(ObjectGroup, objects_[length])));
|
| - group->length_ = length;
|
| - group->info_ = info;
|
| - CopyWords(group->objects_, handles, static_cast<int>(length));
|
| - return group;
|
| - }
|
| +struct ObjectGroup {
|
| + ObjectGroup()
|
| + : info(NULL) {}
|
|
|
| - void Dispose() {
|
| - if (info_ != NULL) info_->Dispose();
|
| - free(this);
|
| + ~ObjectGroup();
|
| +
|
| + v8::RetainedObjectInfo* info;
|
| + List<Object**> objects;
|
| +};
|
| +
|
| +
|
| +struct ObjectGroupConnection {
|
| + ObjectGroupConnection(void* id, Object** object)
|
| + : id(id), object(object) {}
|
| +
|
| + bool operator==(const ObjectGroupConnection& other) const {
|
| + return id == other.id;
|
| }
|
|
|
| - size_t length_;
|
| - v8::RetainedObjectInfo* info_;
|
| - Object** objects_[1]; // Variable sized array.
|
| + bool operator<(const ObjectGroupConnection& other) const {
|
| + return id < other.id;
|
| + }
|
|
|
| - private:
|
| - void* operator new(size_t size);
|
| - void operator delete(void* p);
|
| - ~ObjectGroup();
|
| - DISALLOW_IMPLICIT_CONSTRUCTORS(ObjectGroup);
|
| + void* id;
|
| + Object** object;
|
| };
|
|
|
|
|
| +struct GroupRetainedObjectInfo {
|
| + GroupRetainedObjectInfo(void* id, RetainedObjectInfo* info)
|
| + : id(id), info(info) {}
|
| +
|
| + ~GroupRetainedObjectInfo();
|
| +
|
| + bool operator==(const GroupRetainedObjectInfo& other) const {
|
| + return id == other.id;
|
| + }
|
| +
|
| + bool operator<(const GroupRetainedObjectInfo& other) const {
|
| + return id < other.id;
|
| + }
|
| +
|
| + void* id;
|
| + RetainedObjectInfo* info;
|
| +};
|
| +
|
| // 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.
|
| @@ -213,6 +228,15 @@ class GlobalHandles {
|
| size_t length,
|
| v8::RetainedObjectInfo* info);
|
|
|
| + // Associates handle with the object group represented by id.
|
| + // Should be only used in GC callback function before a collection.
|
| + // All groups are destroyed after a garbage collection.
|
| + void SetObjectGroupId(Object** handle,
|
| + void* id);
|
| +
|
| + void SetRetainedObjectInfo(void* id,
|
| + RetainedObjectInfo* info = NULL);
|
| +
|
| // Add an implicit references' group.
|
| // Should be only used in GC callback function before a collection.
|
| // All groups are destroyed after a mark-compact collection.
|
| @@ -220,8 +244,10 @@ class GlobalHandles {
|
| Object*** children,
|
| size_t length);
|
|
|
| - // Returns the object groups.
|
| - List<ObjectGroup*>* object_groups() { return &object_groups_; }
|
| + // Returns the object groups. Caller takes ownership of the list, and the
|
| + // ObjectGroup pointers in it, and the RetainedObjectInfo pointers in the
|
| + // object groups.
|
| + List<ObjectGroup*>* object_groups();
|
|
|
| // Returns the implicit references' groups.
|
| List<ImplicitRefGroup*>* implicit_ref_groups() {
|
| @@ -270,7 +296,8 @@ class GlobalHandles {
|
|
|
| int post_gc_processing_count_;
|
|
|
| - List<ObjectGroup*> object_groups_;
|
| + List<ObjectGroupConnection>* object_groups_;
|
| + List<GroupRetainedObjectInfo> retained_object_infos_;
|
| List<ImplicitRefGroup*> implicit_ref_groups_;
|
|
|
| friend class Isolate;
|
|
|