| OLD | NEW |
| 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 1497 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1508 intptr_t limit, | 1508 intptr_t limit, |
| 1509 JSONStream* js) { | 1509 JSONStream* js) { |
| 1510 ObjectGraph graph(isolate); | 1510 ObjectGraph graph(isolate); |
| 1511 Array& path = Array::Handle(Array::New(limit * 2)); | 1511 Array& path = Array::Handle(Array::New(limit * 2)); |
| 1512 intptr_t length = graph.RetainingPath(obj, path); | 1512 intptr_t length = graph.RetainingPath(obj, path); |
| 1513 JSONObject jsobj(js); | 1513 JSONObject jsobj(js); |
| 1514 jsobj.AddProperty("type", "RetainingPath"); | 1514 jsobj.AddProperty("type", "RetainingPath"); |
| 1515 jsobj.AddProperty("length", length); | 1515 jsobj.AddProperty("length", length); |
| 1516 JSONArray elements(&jsobj, "elements"); | 1516 JSONArray elements(&jsobj, "elements"); |
| 1517 Object& element = Object::Handle(); | 1517 Object& element = Object::Handle(); |
| 1518 Object& parent = Object::Handle(); | 1518 Smi& slot_offset = Smi::Handle(); |
| 1519 Smi& offset_from_parent = Smi::Handle(); | 1519 Class& element_class = Class::Handle(); |
| 1520 Class& parent_class = Class::Handle(); | 1520 Array& element_field_map = Array::Handle(); |
| 1521 Array& parent_field_map = Array::Handle(); | |
| 1522 Field& field = Field::Handle(); | 1521 Field& field = Field::Handle(); |
| 1523 limit = Utils::Minimum(limit, length); | 1522 limit = Utils::Minimum(limit, length); |
| 1524 for (intptr_t i = 0; i < limit; ++i) { | 1523 for (intptr_t i = 0; i < limit; ++i) { |
| 1525 JSONObject jselement(&elements); | 1524 JSONObject jselement(&elements); |
| 1526 element = path.At(i * 2); | 1525 element = path.At(i * 2); |
| 1527 jselement.AddProperty("index", i); | 1526 jselement.AddProperty("index", i); |
| 1528 jselement.AddProperty("value", element); | 1527 jselement.AddProperty("value", element); |
| 1529 // Interpret the word offset from parent as list index or instance field. | 1528 // Interpret the word offset from parent as list index or instance field. |
| 1530 // TODO(koda): User-friendly interpretation for map entries. | 1529 // TODO(koda): User-friendly interpretation for map entries. |
| 1531 offset_from_parent ^= path.At((i * 2) + 1); | 1530 if (i > 0) { |
| 1532 int parent_i = i + 1; | 1531 slot_offset ^= path.At((i * 2) - 1); |
| 1533 if (parent_i < limit) { | 1532 if (element.IsArray()) { |
| 1534 parent = path.At(parent_i * 2); | 1533 intptr_t element_index = slot_offset.Value() - |
| 1535 if (parent.IsArray()) { | |
| 1536 intptr_t element_index = offset_from_parent.Value() - | |
| 1537 (Array::element_offset(0) >> kWordSizeLog2); | 1534 (Array::element_offset(0) >> kWordSizeLog2); |
| 1538 jselement.AddProperty("parentListIndex", element_index); | 1535 jselement.AddProperty("parentListIndex", element_index); |
| 1539 } else if (parent.IsInstance()) { | 1536 } else if (element.IsInstance()) { |
| 1540 parent_class ^= parent.clazz(); | 1537 element_class ^= element.clazz(); |
| 1541 parent_field_map = parent_class.OffsetToFieldMap(); | 1538 element_field_map = element_class.OffsetToFieldMap(); |
| 1542 intptr_t offset = offset_from_parent.Value(); | 1539 intptr_t offset = slot_offset.Value(); |
| 1543 if (offset > 0 && offset < parent_field_map.Length()) { | 1540 if (offset > 0 && offset < element_field_map.Length()) { |
| 1544 field ^= parent_field_map.At(offset); | 1541 field ^= element_field_map.At(offset); |
| 1545 jselement.AddProperty("parentField", field); | 1542 jselement.AddProperty("parentField", field); |
| 1546 } | 1543 } |
| 1544 } else { |
| 1545 intptr_t element_index = slot_offset.Value(); |
| 1546 jselement.AddProperty("_parentWordOffset", element_index); |
| 1547 } | 1547 } |
| 1548 } | 1548 } |
| 1549 } | 1549 } |
| 1550 | 1550 |
| 1551 // We nil out the array after generating the response to prevent | 1551 // We nil out the array after generating the response to prevent |
| 1552 // reporting spurious references when looking for inbound references | 1552 // reporting spurious references when looking for inbound references |
| 1553 // after looking for a retaining path. | 1553 // after looking for a retaining path. |
| 1554 for (intptr_t i = 0; i < limit; ++i) { | 1554 for (intptr_t i = 0; i < limit; ++i) { |
| 1555 path.SetAt(i * 2, Object::null_object()); | 1555 path.SetAt(i * 2, Object::null_object()); |
| 1556 } | 1556 } |
| (...skipping 1509 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3066 ServiceMethodDescriptor& method = service_methods_[i]; | 3066 ServiceMethodDescriptor& method = service_methods_[i]; |
| 3067 if (strcmp(method_name, method.name) == 0) { | 3067 if (strcmp(method_name, method.name) == 0) { |
| 3068 return &method; | 3068 return &method; |
| 3069 } | 3069 } |
| 3070 } | 3070 } |
| 3071 return NULL; | 3071 return NULL; |
| 3072 } | 3072 } |
| 3073 | 3073 |
| 3074 | 3074 |
| 3075 } // namespace dart | 3075 } // namespace dart |
| OLD | NEW |