Index: runtime/vm/object_graph.cc |
diff --git a/runtime/vm/object_graph.cc b/runtime/vm/object_graph.cc |
index f50046896face8357917abecee537691a61c7f61..b07fe0a90637f15965a6e46660fa3154451c1a8e 100644 |
--- a/runtime/vm/object_graph.cc |
+++ b/runtime/vm/object_graph.cc |
@@ -147,11 +147,6 @@ class Unmarker : public ObjectVisitor { |
} |
static void UnmarkAll(Isolate* isolate) { |
- PageSpace* old_space = isolate->heap()->old_space(); |
- MonitorLocker ml(old_space->tasks_lock()); |
- while (old_space->tasks() > 0) { |
- ml.Wait(); |
- } |
Unmarker unmarker(isolate); |
isolate->heap()->VisitObjects(&unmarker); |
} |
@@ -177,6 +172,11 @@ ObjectGraph::~ObjectGraph() { |
void ObjectGraph::IterateObjects(ObjectGraph::Visitor* visitor) { |
NoSafepointScope no_safepoint_scope_; |
+ PageSpace* old_space = isolate()->heap()->old_space(); |
+ MonitorLocker ml(old_space->tasks_lock()); |
+ while (old_space->tasks() > 0) { |
+ ml.Wait(); |
+ } |
Stack stack(isolate()); |
isolate()->VisitObjectPointers(&stack, false, false); |
stack.TraverseGraph(visitor); |
@@ -187,6 +187,11 @@ void ObjectGraph::IterateObjects(ObjectGraph::Visitor* visitor) { |
void ObjectGraph::IterateObjectsFrom(const Object& root, |
ObjectGraph::Visitor* visitor) { |
NoSafepointScope no_safepoint_scope_; |
+ PageSpace* old_space = isolate()->heap()->old_space(); |
+ MonitorLocker ml(old_space->tasks_lock()); |
+ while (old_space->tasks() > 0) { |
+ ml.Wait(); |
+ } |
Stack stack(isolate()); |
RawObject* root_raw = root.raw(); |
stack.VisitPointer(&root_raw); |