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

Unified Diff: runtime/vm/object_graph.cc

Issue 2995543004: [vm, gc] Require a safepoint for heap iteration. (Closed)
Patch Set: . Created 3 years, 4 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: runtime/vm/object_graph.cc
diff --git a/runtime/vm/object_graph.cc b/runtime/vm/object_graph.cc
index 0f630c7ff04d6393513ece058414fd1f461f0ba7..df4d1a262d368c52fe14a0a65e2d960835c86189 100644
--- a/runtime/vm/object_graph.cc
+++ b/runtime/vm/object_graph.cc
@@ -205,7 +205,6 @@ ObjectGraph::ObjectGraph(Thread* thread) : StackResource(thread) {
ObjectGraph::~ObjectGraph() {}
void ObjectGraph::IterateObjects(ObjectGraph::Visitor* visitor) {
- NoSafepointScope no_safepoint_scope_;
Stack stack(isolate());
isolate()->VisitObjectPointers(&stack, false);
stack.TraverseGraph(visitor);
@@ -213,7 +212,6 @@ void ObjectGraph::IterateObjects(ObjectGraph::Visitor* visitor) {
}
void ObjectGraph::IterateUserObjects(ObjectGraph::Visitor* visitor) {
- NoSafepointScope no_safepoint_scope_;
Stack stack(isolate());
IterateUserFields(&stack);
stack.include_vm_objects_ = false;
@@ -223,7 +221,6 @@ void ObjectGraph::IterateUserObjects(ObjectGraph::Visitor* visitor) {
void ObjectGraph::IterateObjectsFrom(const Object& root,
ObjectGraph::Visitor* visitor) {
- NoSafepointScope no_safepoint_scope_;
Stack stack(isolate());
RawObject* root_raw = root.raw();
stack.VisitPointer(&root_raw);
@@ -252,11 +249,11 @@ class InstanceAccumulator : public ObjectVisitor {
void ObjectGraph::IterateObjectsFrom(intptr_t class_id,
ObjectGraph::Visitor* visitor) {
- NoSafepointScope no_safepoint_scope_;
+ HeapIterationScope iteration;
Stack stack(isolate());
InstanceAccumulator accumulator(&stack, class_id);
- isolate()->heap()->VisitObjectsNoImagePages(&accumulator);
+ iteration.IterateObjectsNoImagePages(&accumulator);
stack.TraverseGraph(visitor);
Unmarker::UnmarkAll(isolate());
@@ -341,7 +338,6 @@ class RetainingPathVisitor : public ObjectGraph::Visitor {
// We cannot use a GrowableObjectArray, since we must not trigger GC.
RetainingPathVisitor(RawObject* obj, const Array& path)
: thread_(Thread::Current()), obj_(obj), path_(path), length_(0) {
- ASSERT(Thread::Current()->no_safepoint_scope_depth() != 0);
}
intptr_t length() const { return length_; }
@@ -424,7 +420,6 @@ class RetainingPathVisitor : public ObjectGraph::Visitor {
};
intptr_t ObjectGraph::RetainingPath(Object* obj, const Array& path) {
- NoSafepointScope no_safepoint_scope_;
HeapIterationScope iteration_scope(true);
// To break the trivial path, the handle 'obj' is temporarily cleared during
// the search, but restored before returning.
@@ -504,9 +499,9 @@ class InboundReferencesVisitor : public ObjectVisitor,
intptr_t ObjectGraph::InboundReferences(Object* obj, const Array& references) {
Object& scratch = Object::Handle();
- NoSafepointScope no_safepoint_scope;
+ HeapIterationScope iteration;
InboundReferencesVisitor visitor(isolate(), obj->raw(), references, &scratch);
- isolate()->heap()->IterateObjects(&visitor);
+ iteration.IterateObjects(&visitor);
return visitor.length();
}

Powered by Google App Engine
This is Rietveld 408576698