 Chromium Code Reviews
 Chromium Code Reviews| Index: src/global-handles.h | 
| diff --git a/src/global-handles.h b/src/global-handles.h | 
| index 990014467cea5157612eed91400490ee3d6367d5..32478ff0bda2a299ffd0e97b703e03fcbab34c9f 100644 | 
| --- a/src/global-handles.h | 
| +++ b/src/global-handles.h | 
| @@ -44,34 +44,40 @@ 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 ObjectGroupConnection { | 
| + ObjectGroupConnection(void* id, Object** object) | 
| + : id(id), object(object) {} | 
| + | 
| + bool operator==(const ObjectGroupConnection& other) const { | 
| + return id == other.id; | 
| } | 
| - void Dispose() { | 
| - if (info_ != NULL) info_->Dispose(); | 
| - free(this); | 
| + bool operator<(const ObjectGroupConnection& other) const { | 
| + return id < other.id; | 
| } | 
| - size_t length_; | 
| - v8::RetainedObjectInfo* info_; | 
| - Object** objects_[1]; // Variable sized array. | 
| + void* id; | 
| + Object** object; | 
| +}; | 
| - private: | 
| - void* operator new(size_t size); | 
| - void operator delete(void* p); | 
| - ~ObjectGroup(); | 
| - DISALLOW_IMPLICIT_CONSTRUCTORS(ObjectGroup); | 
| + | 
| +struct GroupRetainedObjectInfo { | 
| + GroupRetainedObjectInfo(void* id, RetainedObjectInfo* info) | 
| + : id(id), info(info) {} | 
| + | 
| + ~GroupRetainedObjectInfo(); | 
| 
Sven Panne
2013/04/10 08:37:49
Kill me! :-)
 
marja
2013/04/10 09:31:07
Done.
 | 
| + | 
| + bool operator==(const GroupRetainedObjectInfo& other) const { | 
| + return id == other.id; | 
| + } | 
| + | 
| + bool operator<(const GroupRetainedObjectInfo& other) const { | 
| + return id < other.id; | 
| + } | 
| + | 
| + void* id; | 
| + RetainedObjectInfo* info; | 
| }; | 
| @@ -213,6 +219,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 +235,13 @@ class GlobalHandles { | 
| Object*** children, | 
| size_t length); | 
| - // Returns the object groups. | 
| - List<ObjectGroup*>* object_groups() { return &object_groups_; } | 
| + List<ObjectGroupConnection>* object_groups() { | 
| + return &object_groups_; | 
| + } | 
| + | 
| + List<GroupRetainedObjectInfo>* retained_object_infos() { | 
| + return &retained_object_infos_; | 
| + } | 
| // Returns the implicit references' groups. | 
| List<ImplicitRefGroup*>* implicit_ref_groups() { | 
| @@ -270,7 +290,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; |