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

Unified Diff: runtime/vm/object_graph.cc

Issue 2231313002: Avoid to list internal Arrays in _GetRetainingPath api (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Stop iterating at static fields and remove GrowableObjectList internal storage from the list Created 4 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/observatory/tests/service/get_retaining_path_rpc_test.dart ('k') | runtime/vm/service.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 bbecac73b11bfdaf1717a3bf6a33c81fb8769b9e..8e235b32bfc1de06f5f57ecc76ee1edf0f9efd03 100644
--- a/runtime/vm/object_graph.cc
+++ b/runtime/vm/object_graph.cc
@@ -319,6 +319,30 @@ class RetainingPathVisitor : public ObjectGraph::Visitor {
}
}
+ bool ShouldStop(RawObject* obj) {
+ // A static field is considered a root from a language point of view.
+ if (obj->IsField()) {
+ const Field& field = Field::Handle(static_cast<RawField*>(obj));
+ return field.is_static();
+ }
+ return false;
+ }
+
+ void StartList() {
+ wasLastArray_ = false;
Cutch 2016/08/12 14:23:39 C++ style guide says variables are lower_case_like
cbernaschina 2016/08/12 17:28:24 Done.
+ }
+
+ bool ShouldOverwrite(RawObject* obj) {
Cutch 2016/08/12 14:23:40 ShouldReplace?
cbernaschina 2016/08/12 17:28:24 Changed approach, and name
+ // A GrowableObjectArray overwrites its internal storage.
+ // Keeping both of them in the list is redundant.
+ if (wasLastArray_ && obj->IsGrowableObjectArray()) {
+ wasLastArray_ = false;
+ return true;
+ }
+ wasLastArray_ = obj->IsArray();
+ return false;
+ }
+
virtual Direction VisitObject(ObjectGraph::StackIterator* it) {
if (it->Get() != obj_) {
if (ShouldSkip(it->Get())) {
@@ -330,7 +354,11 @@ class RetainingPathVisitor : public ObjectGraph::Visitor {
HANDLESCOPE(thread_);
Object& current = Object::Handle();
Smi& offset_from_parent = Smi::Handle();
+ StartList();
do {
+ if (ShouldOverwrite(it->Get())) {
+ --length_;
+ }
intptr_t obj_index = length_ * 2;
intptr_t offset_index = obj_index + 1;
if (!path_.IsNull() && offset_index < path_.Length()) {
@@ -340,7 +368,7 @@ class RetainingPathVisitor : public ObjectGraph::Visitor {
path_.SetAt(offset_index, offset_from_parent);
}
++length_;
- } while (it->MoveToParent());
+ } while (!ShouldStop(it->Get()) && it->MoveToParent());
return kAbort;
}
}
@@ -350,6 +378,7 @@ class RetainingPathVisitor : public ObjectGraph::Visitor {
RawObject* obj_;
const Array& path_;
intptr_t length_;
+ bool wasLastArray_;
};
« no previous file with comments | « runtime/observatory/tests/service/get_retaining_path_rpc_test.dart ('k') | runtime/vm/service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698