Chromium Code Reviews| Index: src/global-handles.cc |
| diff --git a/src/global-handles.cc b/src/global-handles.cc |
| index 0006f8ed2d24c8fe660a0773f8b6073c834e65b8..604a7fad5db77b17c3bf407be5043f5dc9c3559d 100644 |
| --- a/src/global-handles.cc |
| +++ b/src/global-handles.cc |
| @@ -551,6 +551,51 @@ void GlobalHandles::IterateNewSpaceWeakIndependentRoots(ObjectVisitor* v) { |
| } |
| +bool GlobalHandles::IterateObjectGroups(ObjectVisitor* v, |
| + WeakSlotCallbackWithHeap f) { |
| + int last = 0; |
| + bool any_group_was_visited = false; |
| + for (int i = 0; i < object_groups_.length(); i++) { |
| + ObjectGroup* entry = object_groups_.at(i); |
| + ASSERT(entry != NULL); |
| + |
| + Object*** objects = entry->objects_; |
| + bool group_should_be_visited = false; |
| + for (size_t j = 0; j < entry->length_; j++) { |
| + Object* object = *objects[j]; |
| + if (object->IsHeapObject()) { |
| + if (!f(isolate_->heap(), &object)) { |
|
ulan
2012/12/04 09:41:46
Maybe rename "f" to something more descriptive lik
Michael Starzinger
2012/12/04 10:18:14
Done.
|
| + group_should_be_visited = true; |
| + break; |
| + } |
| + } |
| + } |
| + |
| + if (!group_should_be_visited) { |
| + object_groups_[last++] = entry; |
| + continue; |
| + } |
| + |
| + // An object in the group requires visiting, so iterate over all |
| + // objects in the group. |
| + for (size_t j = 0; j < entry->length_; ++j) { |
| + Object* object = *objects[j]; |
| + if (object->IsHeapObject()) { |
| + v->VisitPointer(&object); |
| + any_group_was_visited = true; |
| + } |
| + } |
| + |
| + // Once the entire group has been iterated over, set the object |
| + // group to NULL so it won't be processed again. |
| + entry->Dispose(); |
| + object_groups_.at(i) = NULL; |
| + } |
| + object_groups_.Rewind(last); |
| + return any_group_was_visited; |
| +} |
| + |
| + |
| bool GlobalHandles::PostGarbageCollectionProcessing( |
| GarbageCollector collector) { |
| // Process weak global handle callbacks. This must be done after the |