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

Unified Diff: src/global-handles.h

Issue 6800003: Make object groups and implicit references a bit more lightweight. (Closed)
Patch Set: Created 9 years, 9 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 a6afb2dcdeec34fa89458710b08aaa83be89ac2e..daf23a9c8c8a28d493d295b17735d9d62d9df10d 100644
--- a/src/global-handles.h
+++ b/src/global-handles.h
@@ -42,37 +42,60 @@ 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 Malloced {
+class ObjectGroup : public CustomlyAllocated {
public:
- ObjectGroup() : objects_(4) {}
- ObjectGroup(size_t capacity, v8::RetainedObjectInfo* info)
- : objects_(static_cast<int>(capacity)),
- info_(info) { }
- ~ObjectGroup();
+ static ObjectGroup* New(Object*** handles,
+ size_t length,
+ v8::RetainedObjectInfo* info) {
+ ObjectGroup* group = reinterpret_cast<ObjectGroup*>(
+ malloc(OFFSET_OF(ObjectGroup, objects_[length])));
+ group->length_ = length;
+ group->info_ = info;
+ CopyWords(group->objects_, handles, length);
+ return group;
+ }
+
+ void Dispose() {
+ free(this);
+ }
- List<Object**> objects_;
+ size_t length_;
v8::RetainedObjectInfo* info_;
+ Object** objects_[1];
antonm 2011/04/06 11:01:48 maybe add a comment that it's a placeholder for va
Vitaly Repeshko 2011/04/06 19:11:01 Done.
private:
- DISALLOW_COPY_AND_ASSIGN(ObjectGroup);
+ DISALLOW_IMPLICIT_CONSTRUCTORS(ObjectGroup);
+ ~ObjectGroup();
};
// 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 Malloced {
+class ImplicitRefGroup : public CustomlyAllocated {
public:
- ImplicitRefGroup() : children_(4) {}
- ImplicitRefGroup(HeapObject* parent, size_t capacity)
- : parent_(parent),
- children_(static_cast<int>(capacity)) { }
+ static ImplicitRefGroup* New(HeapObject** parent,
+ Object*** children,
+ size_t length) {
+ ImplicitRefGroup* group = reinterpret_cast<ImplicitRefGroup*>(
+ malloc(OFFSET_OF(ImplicitRefGroup, children_[length])));
+ group->parent_ = parent;
+ group->length_ = length;
+ CopyWords(group->children_, children, length);
+ return group;
+ }
+
+ void Dispose() {
+ free(this);
+ }
- HeapObject* parent_;
- List<Object**> children_;
+ HeapObject** parent_;
+ size_t length_;
+ Object** children_[1];
antonm 2011/04/06 11:01:48 ditto
Vitaly Repeshko 2011/04/06 19:11:01 Done.
private:
- DISALLOW_COPY_AND_ASSIGN(ImplicitRefGroup);
+ DISALLOW_IMPLICIT_CONSTRUCTORS(ImplicitRefGroup);
+ ~ImplicitRefGroup();
};
@@ -154,7 +177,7 @@ class GlobalHandles {
// 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.
- void AddImplicitReferences(HeapObject* parent,
+ void AddImplicitReferences(HeapObject** parent,
Object*** children,
size_t length);

Powered by Google App Engine
This is Rietveld 408576698