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

Unified Diff: src/global-handles.h

Issue 13786002: [WIP] New GC related APIs. (Closed) Base URL: git://github.com/v8/v8.git@master
Patch Set: code review (svenpanne) 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 990014467cea5157612eed91400490ee3d6367d5..bc388bd6dc5373bb285e2f084a576840423549bc 100644
--- a/src/global-handles.h
+++ b/src/global-handles.h
@@ -28,6 +28,7 @@
#ifndef V8_GLOBAL_HANDLES_H_
#define V8_GLOBAL_HANDLES_H_
+#include "../include/v8.h"
#include "../include/v8-profiler.h"
#include "list.h"
@@ -44,34 +45,38 @@ 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(UniqueId 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.
+ UniqueId id;
+ Object** object;
+};
- private:
- void* operator new(size_t size);
- void operator delete(void* p);
- ~ObjectGroup();
- DISALLOW_IMPLICIT_CONSTRUCTORS(ObjectGroup);
+
+struct GroupRetainedObjectInfo {
Michael Starzinger 2013/04/10 10:54:16 suggestion: We could call this struct either "Obje
marja 2013/04/10 13:14:51 Renamed to ObjectGroupRetainerInfo.
+ GroupRetainedObjectInfo(UniqueId id, RetainedObjectInfo* info)
+ : id(id), info(info) {}
+
+ bool operator==(const GroupRetainedObjectInfo& other) const {
+ return id == other.id;
+ }
+
+ bool operator<(const GroupRetainedObjectInfo& other) const {
+ return id < other.id;
+ }
+
+ UniqueId id;
+ RetainedObjectInfo* info;
};
@@ -213,6 +218,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,
Michael Starzinger 2013/04/10 10:54:16 nit: Fits into one line.
marja 2013/04/10 13:14:51 Done.
+ UniqueId id);
+
+ void SetRetainedObjectInfo(UniqueId id,
Michael Starzinger 2013/04/10 10:54:16 nit: Fits into one line.
marja 2013/04/10 13:14:51 Done.
+ 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 +234,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 +289,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;

Powered by Google App Engine
This is Rietveld 408576698