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

Unified Diff: src/global-handles.h

Issue 14294009: Revert the commits adding new GC-related APIs. (Closed) Base URL: git://github.com/v8/v8.git@master
Patch Set: remove test 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
« no previous file with comments | « src/api.cc ('k') | src/global-handles.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/global-handles.h
diff --git a/src/global-handles.h b/src/global-handles.h
index 7697364d13716f6d5ad28c49ebe026a0a593b7c3..90707b0bc24b5067bc1d46155852b784406c9b70 100644
--- a/src/global-handles.h
+++ b/src/global-handles.h
@@ -28,7 +28,6 @@
#ifndef V8_GLOBAL_HANDLES_H_
#define V8_GLOBAL_HANDLES_H_
-#include "../include/v8.h"
#include "../include/v8-profiler.h"
#include "list.h"
@@ -47,64 +46,70 @@ class ObjectVisitor;
// 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) {}
-
- bool operator==(const ObjectGroupConnection& other) const {
- return id == other.id;
+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;
}
- bool operator<(const ObjectGroupConnection& other) const {
- return id < other.id;
+ void Dispose() {
+ if (info_ != NULL) info_->Dispose();
+ free(this);
}
- UniqueId id;
- Object** object;
-};
-
-
-struct ObjectGroupRetainerInfo {
- ObjectGroupRetainerInfo(UniqueId id, RetainedObjectInfo* info)
- : id(id), info(info) {}
+ size_t length_;
+ v8::RetainedObjectInfo* info_;
+ Object** objects_[1]; // Variable sized array.
- bool operator==(const ObjectGroupRetainerInfo& other) const {
- return id == other.id;
- }
-
- bool operator<(const ObjectGroupRetainerInfo& other) const {
- return id < other.id;
- }
-
- UniqueId id;
- RetainedObjectInfo* info;
+ private:
+ void* operator new(size_t size);
+ void operator delete(void* p);
+ ~ObjectGroup();
+ DISALLOW_IMPLICIT_CONSTRUCTORS(ObjectGroup);
};
-struct ObjectGroupRepresentative {
- ObjectGroupRepresentative(UniqueId id, HeapObject** object)
- : id(id), object(object) {}
-
- bool operator==(const ObjectGroupRepresentative& other) const {
- return id == other.id;
+// 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, length);
+ return group;
}
- bool operator<(const ObjectGroupRepresentative& other) const {
- return id < other.id;
+ void Dispose() {
+ free(this);
}
- UniqueId id;
- HeapObject** object;
+ HeapObject** parent_;
+ size_t length_;
+ Object** children_[1]; // Variable sized array.
+
+ private:
+ void* operator new(size_t size);
+ void operator delete(void* p);
+ ~ImplicitRefGroup();
+ DISALLOW_IMPLICIT_CONSTRUCTORS(ImplicitRefGroup);
};
@@ -213,22 +218,6 @@ 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, UniqueId id);
-
- // 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 SetObjectGroupRepresentative(UniqueId id,
- HeapObject** representative_object);
-
// 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.
@@ -236,28 +225,14 @@ 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);
+ // Returns the object groups.
+ List<ObjectGroup*>* object_groups() { return &object_groups_; }
- List<ObjectGroupConnection>* object_groups() {
- return &object_groups_;
- }
-
- List<ObjectGroupRetainerInfo>* retainer_infos() {
- return &retainer_infos_;
- }
-
- List<ObjectGroupConnection>* implicit_ref_groups() {
+ // Returns the implicit references' groups.
+ List<ImplicitRefGroup*>* implicit_ref_groups() {
return &implicit_ref_groups_;
}
- List<ObjectGroupRepresentative>* representative_objects() {
- return &representative_objects_;
- }
-
// Remove bags, this should only happen after GC.
void RemoveObjectGroups();
void RemoveImplicitRefGroups();
@@ -300,13 +275,8 @@ class GlobalHandles {
int post_gc_processing_count_;
- // Object groups.
- List<ObjectGroupConnection> object_groups_;
- List<ObjectGroupRetainerInfo> retainer_infos_;
- List<ObjectGroupRepresentative> representative_objects_;
-
- // Implicit references.
- List<ObjectGroupConnection> implicit_ref_groups_;
+ List<ObjectGroup*> object_groups_;
+ List<ImplicitRefGroup*> implicit_ref_groups_;
friend class Isolate;
« no previous file with comments | « src/api.cc ('k') | src/global-handles.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698