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

Unified Diff: runtime/vm/object_graph.cc

Issue 2995543004: [vm, gc] Require a safepoint for heap iteration. (Closed)
Patch Set: explicit-thread 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
« no previous file with comments | « runtime/vm/object.cc ('k') | runtime/vm/object_graph_test.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/object_graph.cc
diff --git a/runtime/vm/object_graph.cc b/runtime/vm/object_graph.cc
index 0f630c7ff04d6393513ece058414fd1f461f0ba7..ea8d2a742d34875bdd038ed5d418ca028a21c196 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(thread());
Stack stack(isolate());
InstanceAccumulator accumulator(&stack, class_id);
- isolate()->heap()->VisitObjectsNoImagePages(&accumulator);
+ iteration.IterateObjectsNoImagePages(&accumulator);
stack.TraverseGraph(visitor);
Unmarker::UnmarkAll(isolate());
@@ -301,7 +298,7 @@ class SizeExcludingClassVisitor : public SizeVisitor {
};
intptr_t ObjectGraph::SizeRetainedByInstance(const Object& obj) {
- HeapIterationScope iteration_scope(true);
+ HeapIterationScope iteration_scope(Thread::Current(), true);
SizeVisitor total;
IterateObjects(&total);
intptr_t size_total = total.size();
@@ -312,14 +309,14 @@ intptr_t ObjectGraph::SizeRetainedByInstance(const Object& obj) {
}
intptr_t ObjectGraph::SizeReachableByInstance(const Object& obj) {
- HeapIterationScope iteration_scope(true);
+ HeapIterationScope iteration_scope(Thread::Current(), true);
SizeVisitor total;
IterateObjectsFrom(obj, &total);
return total.size();
}
intptr_t ObjectGraph::SizeRetainedByClass(intptr_t class_id) {
- HeapIterationScope iteration_scope(true);
+ HeapIterationScope iteration_scope(Thread::Current(), true);
SizeVisitor total;
IterateObjects(&total);
intptr_t size_total = total.size();
@@ -330,7 +327,7 @@ intptr_t ObjectGraph::SizeRetainedByClass(intptr_t class_id) {
}
intptr_t ObjectGraph::SizeReachableByClass(intptr_t class_id) {
- HeapIterationScope iteration_scope(true);
+ HeapIterationScope iteration_scope(Thread::Current(), true);
SizeVisitor total;
IterateObjectsFrom(class_id, &total);
return total.size();
@@ -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,8 +420,7 @@ class RetainingPathVisitor : public ObjectGraph::Visitor {
};
intptr_t ObjectGraph::RetainingPath(Object* obj, const Array& path) {
- NoSafepointScope no_safepoint_scope_;
- HeapIterationScope iteration_scope(true);
+ HeapIterationScope iteration_scope(Thread::Current(), true);
// To break the trivial path, the handle 'obj' is temporarily cleared during
// the search, but restored before returning.
RawObject* raw = obj->raw();
@@ -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(Thread::Current());
InboundReferencesVisitor visitor(isolate(), obj->raw(), references, &scratch);
- isolate()->heap()->IterateObjects(&visitor);
+ iteration.IterateObjects(&visitor);
return visitor.length();
}
@@ -609,7 +604,7 @@ intptr_t ObjectGraph::Serialize(WriteStream* stream,
}
// Current encoding assumes objects do not move, so promote everything to old.
isolate()->heap()->new_space()->Evacuate();
- HeapIterationScope iteration_scope(true);
+ HeapIterationScope iteration_scope(Thread::Current(), true);
RawObject* kRootAddress = reinterpret_cast<RawObject*>(kHeapObjectTag);
const intptr_t kRootCid = kIllegalCid;
« no previous file with comments | « runtime/vm/object.cc ('k') | runtime/vm/object_graph_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698