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

Unified Diff: runtime/vm/service.cc

Issue 2231313002: Avoid to list internal Arrays in _GetRetainingPath api (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Fixed comment 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/vm/object_graph.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/service.cc
diff --git a/runtime/vm/service.cc b/runtime/vm/service.cc
index c57890a6b0404b44a1e447cfeb2be8747eee10b6..d5468dab9bb5fab4a382f4138398d56271a995f4 100644
--- a/runtime/vm/service.cc
+++ b/runtime/vm/service.cc
@@ -2006,21 +2006,37 @@ static bool PrintRetainingPath(Thread* thread,
Smi& slot_offset = Smi::Handle();
Class& element_class = Class::Handle();
Array& element_field_map = Array::Handle();
+ LinkedHashMap& map = LinkedHashMap::Handle();
+ Array& map_data = Array::Handle();
Field& field = Field::Handle();
limit = Utils::Minimum(limit, length);
for (intptr_t i = 0; i < limit; ++i) {
JSONObject jselement(&elements);
element = path.At(i * 2);
- jselement.AddProperty("index", i);
jselement.AddProperty("value", element);
- // Interpret the word offset from parent as list index or instance field.
- // TODO(koda): User-friendly interpretation for map entries.
+ // Interpret the word offset from parent as list index, map key
+ // or instance field.
if (i > 0) {
slot_offset ^= path.At((i * 2) - 1);
- if (element.IsArray()) {
+ jselement.AddProperty("offset", slot_offset.Value());
+ if (element.IsArray() || element.IsGrowableObjectArray()) {
intptr_t element_index = slot_offset.Value() -
(Array::element_offset(0) >> kWordSizeLog2);
jselement.AddProperty("parentListIndex", element_index);
+ } else if (element.IsLinkedHashMap()) {
+ map = static_cast<RawLinkedHashMap*>(path.At(i * 2));
+ map_data = map.data();
+ intptr_t element_index = slot_offset.Value() -
+ (Array::element_offset(0) >> kWordSizeLog2);
+ LinkedHashMap::Iterator iterator(map);
+ while (iterator.MoveNext()) {
+ if (iterator.CurrentKey() == map_data.At(element_index) ||
+ iterator.CurrentValue() == map_data.At(element_index)) {
+ element = iterator.CurrentKey();
+ jselement.AddProperty("parentMapKey", element);
+ break;
+ }
+ }
} else if (element.IsInstance()) {
element_class ^= element.clazz();
element_field_map = element_class.OffsetToFieldMap();
« no previous file with comments | « runtime/vm/object_graph.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698