Index: src/global-handles.cc |
diff --git a/src/global-handles.cc b/src/global-handles.cc |
index 18cdc5a3af5615e559e6d91faed474ef7430c8c5..6492520714727b080724f6de142c3b02c1f43df3 100644 |
--- a/src/global-handles.cc |
+++ b/src/global-handles.cc |
@@ -41,6 +41,7 @@ class GlobalHandles::Node : public Malloced { |
void Initialize(Object* object) { |
// Set the initial value of the handle. |
object_ = object; |
+ class_id_ = v8::HeapProfiler::kPersistentHandleNoClassId; |
state_ = NORMAL; |
parameter_or_next_free_.parameter = NULL; |
callback_ = NULL; |
@@ -137,6 +138,14 @@ class GlobalHandles::Node : public Malloced { |
return state_ == WEAK; |
} |
+ bool CanBeRetainer() { |
+ return state_ != DESTROYED && state_ != NEAR_DEATH; |
+ } |
+ |
+ void SetWrapperClassId(uint16_t class_id) { |
+ class_id_ = class_id; |
+ } |
+ |
// Returns the id for this weak handle. |
void set_parameter(void* parameter) { |
ASSERT(state_ != DESTROYED); |
@@ -190,6 +199,8 @@ class GlobalHandles::Node : public Malloced { |
// Place the handle address first to avoid offset computation. |
Object* object_; // Storage for object pointer. |
+ uint16_t class_id_; |
+ |
// Transition diagram: |
// NORMAL <-> WEAK -> PENDING -> NEAR_DEATH -> { NORMAL, WEAK, DESTROYED } |
enum State { |
@@ -199,7 +210,7 @@ class GlobalHandles::Node : public Malloced { |
NEAR_DEATH, // Callback has informed the handle is near death. |
DESTROYED |
}; |
- State state_; |
+ State state_ : 3; |
private: |
// Handle specific callback. |
@@ -337,6 +348,11 @@ bool GlobalHandles::IsWeak(Object** location) { |
} |
+void GlobalHandles::SetWrapperClassId(Object** location, uint16_t class_id) { |
+ Node::FromLocation(location)->SetWrapperClassId(class_id); |
+} |
+ |
+ |
void GlobalHandles::IterateWeakRoots(ObjectVisitor* v) { |
// Traversal of GC roots in the global handle list that are marked as |
// WEAK or PENDING. |
@@ -435,6 +451,16 @@ void GlobalHandles::IterateAllRoots(ObjectVisitor* v) { |
} |
+void GlobalHandles::IterateAllRootsWithClassIds(ObjectVisitor* v) { |
+ for (Node* current = head_; current != NULL; current = current->next()) { |
+ if (current->class_id_ != v8::HeapProfiler::kPersistentHandleNoClassId && |
+ current->CanBeRetainer()) { |
+ v->VisitEmbedderReference(¤t->object_, current->class_id_); |
+ } |
+ } |
+} |
+ |
+ |
void GlobalHandles::TearDown() { |
// Reset all the lists. |
set_head(NULL); |
@@ -515,8 +541,10 @@ List<ObjectGroup*>* GlobalHandles::ObjectGroups() { |
return &groups; |
} |
-void GlobalHandles::AddGroup(Object*** handles, size_t length) { |
- ObjectGroup* new_entry = new ObjectGroup(length); |
+void GlobalHandles::AddGroup(Object*** handles, |
+ size_t length, |
+ v8::RetainedObjectInfo* info) { |
+ ObjectGroup* new_entry = new ObjectGroup(length, info); |
for (size_t i = 0; i < length; ++i) |
new_entry->objects_.Add(handles[i]); |
ObjectGroups()->Add(new_entry); |