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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « runtime/vm/object_graph.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "vm/service.h" 5 #include "vm/service.h"
6 6
7 #include "include/dart_api.h" 7 #include "include/dart_api.h"
8 #include "include/dart_native_api.h" 8 #include "include/dart_native_api.h"
9 #include "platform/globals.h" 9 #include "platform/globals.h"
10 10
(...skipping 1988 matching lines...) Expand 10 before | Expand all | Expand 10 after
1999 Array& path = Array::Handle(Array::New(limit * 2)); 1999 Array& path = Array::Handle(Array::New(limit * 2));
2000 intptr_t length = graph.RetainingPath(obj, path); 2000 intptr_t length = graph.RetainingPath(obj, path);
2001 JSONObject jsobj(js); 2001 JSONObject jsobj(js);
2002 jsobj.AddProperty("type", "RetainingPath"); 2002 jsobj.AddProperty("type", "RetainingPath");
2003 jsobj.AddProperty("length", length); 2003 jsobj.AddProperty("length", length);
2004 JSONArray elements(&jsobj, "elements"); 2004 JSONArray elements(&jsobj, "elements");
2005 Object& element = Object::Handle(); 2005 Object& element = Object::Handle();
2006 Smi& slot_offset = Smi::Handle(); 2006 Smi& slot_offset = Smi::Handle();
2007 Class& element_class = Class::Handle(); 2007 Class& element_class = Class::Handle();
2008 Array& element_field_map = Array::Handle(); 2008 Array& element_field_map = Array::Handle();
2009 LinkedHashMap& map = LinkedHashMap::Handle();
2010 Array& map_data = Array::Handle();
2009 Field& field = Field::Handle(); 2011 Field& field = Field::Handle();
2010 limit = Utils::Minimum(limit, length); 2012 limit = Utils::Minimum(limit, length);
2011 for (intptr_t i = 0; i < limit; ++i) { 2013 for (intptr_t i = 0; i < limit; ++i) {
2012 JSONObject jselement(&elements); 2014 JSONObject jselement(&elements);
2013 element = path.At(i * 2); 2015 element = path.At(i * 2);
2014 jselement.AddProperty("index", i);
2015 jselement.AddProperty("value", element); 2016 jselement.AddProperty("value", element);
2016 // Interpret the word offset from parent as list index or instance field. 2017 // Interpret the word offset from parent as list index, map key
2017 // TODO(koda): User-friendly interpretation for map entries. 2018 // or instance field.
2018 if (i > 0) { 2019 if (i > 0) {
2019 slot_offset ^= path.At((i * 2) - 1); 2020 slot_offset ^= path.At((i * 2) - 1);
2020 if (element.IsArray()) { 2021 jselement.AddProperty("offset", slot_offset.Value());
2022 if (element.IsArray() || element.IsGrowableObjectArray()) {
2021 intptr_t element_index = slot_offset.Value() - 2023 intptr_t element_index = slot_offset.Value() -
2022 (Array::element_offset(0) >> kWordSizeLog2); 2024 (Array::element_offset(0) >> kWordSizeLog2);
2023 jselement.AddProperty("parentListIndex", element_index); 2025 jselement.AddProperty("parentListIndex", element_index);
2026 } else if (element.IsLinkedHashMap()) {
2027 map = static_cast<RawLinkedHashMap*>(path.At(i * 2));
2028 map_data = map.data();
2029 intptr_t element_index = slot_offset.Value() -
2030 (Array::element_offset(0) >> kWordSizeLog2);
2031 LinkedHashMap::Iterator iterator(map);
2032 while (iterator.MoveNext()) {
2033 if (iterator.CurrentKey() == map_data.At(element_index) ||
2034 iterator.CurrentValue() == map_data.At(element_index)) {
2035 element = iterator.CurrentKey();
2036 jselement.AddProperty("parentMapKey", element);
2037 break;
2038 }
2039 }
2024 } else if (element.IsInstance()) { 2040 } else if (element.IsInstance()) {
2025 element_class ^= element.clazz(); 2041 element_class ^= element.clazz();
2026 element_field_map = element_class.OffsetToFieldMap(); 2042 element_field_map = element_class.OffsetToFieldMap();
2027 intptr_t offset = slot_offset.Value(); 2043 intptr_t offset = slot_offset.Value();
2028 if (offset > 0 && offset < element_field_map.Length()) { 2044 if (offset > 0 && offset < element_field_map.Length()) {
2029 field ^= element_field_map.At(offset); 2045 field ^= element_field_map.At(offset);
2030 jselement.AddProperty("parentField", field); 2046 jselement.AddProperty("parentField", field);
2031 } 2047 }
2032 } else { 2048 } else {
2033 intptr_t element_index = slot_offset.Value(); 2049 intptr_t element_index = slot_offset.Value();
(...skipping 2090 matching lines...) Expand 10 before | Expand all | Expand 10 after
4124 if (strcmp(method_name, method.name) == 0) { 4140 if (strcmp(method_name, method.name) == 0) {
4125 return &method; 4141 return &method;
4126 } 4142 }
4127 } 4143 }
4128 return NULL; 4144 return NULL;
4129 } 4145 }
4130 4146
4131 #endif // !PRODUCT 4147 #endif // !PRODUCT
4132 4148
4133 } // namespace dart 4149 } // namespace dart
OLDNEW
« 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