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 "platform/globals.h" | 8 #include "platform/globals.h" |
9 | 9 |
10 #include "vm/compiler.h" | 10 #include "vm/compiler.h" |
(...skipping 1503 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1514 if (obj.raw() == Object::sentinel().raw()) { | 1514 if (obj.raw() == Object::sentinel().raw()) { |
1515 if (lookup_result == ObjectIdRing::kCollected) { | 1515 if (lookup_result == ObjectIdRing::kCollected) { |
1516 PrintSentinel(js, kCollectedSentinel); | 1516 PrintSentinel(js, kCollectedSentinel); |
1517 } else if (lookup_result == ObjectIdRing::kExpired) { | 1517 } else if (lookup_result == ObjectIdRing::kExpired) { |
1518 PrintSentinel(js, kExpiredSentinel); | 1518 PrintSentinel(js, kExpiredSentinel); |
1519 } else { | 1519 } else { |
1520 PrintInvalidParamError(js, "targetId"); | 1520 PrintInvalidParamError(js, "targetId"); |
1521 } | 1521 } |
1522 return true; | 1522 return true; |
1523 } | 1523 } |
| 1524 // TODO(rmacnak): There is no way to get the size retained by a class object. |
| 1525 // SizeRetainedByClass should be a separate RPC. |
1524 if (obj.IsClass()) { | 1526 if (obj.IsClass()) { |
1525 const Class& cls = Class::Cast(obj); | 1527 const Class& cls = Class::Cast(obj); |
1526 ObjectGraph graph(isolate); | 1528 ObjectGraph graph(isolate); |
1527 intptr_t retained_size = graph.SizeRetainedByClass(cls.id()); | 1529 intptr_t retained_size = graph.SizeRetainedByClass(cls.id()); |
1528 const Object& result = Object::Handle(Integer::New(retained_size)); | 1530 const Object& result = Object::Handle(Integer::New(retained_size)); |
1529 result.PrintJSON(js, true); | 1531 result.PrintJSON(js, true); |
1530 return true; | 1532 return true; |
1531 } | 1533 } |
1532 if (obj.IsInstance() || obj.IsNull()) { | 1534 |
1533 // We don't use Instance::Cast here because it doesn't allow null. | 1535 ObjectGraph graph(isolate); |
1534 ObjectGraph graph(isolate); | 1536 intptr_t retained_size = graph.SizeRetainedByInstance(obj); |
1535 intptr_t retained_size = graph.SizeRetainedByInstance(obj); | 1537 const Object& result = Object::Handle(Integer::New(retained_size)); |
1536 const Object& result = Object::Handle(Integer::New(retained_size)); | 1538 result.PrintJSON(js, true); |
1537 result.PrintJSON(js, true); | |
1538 return true; | |
1539 } | |
1540 js->PrintError(kInvalidParams, | |
1541 "%s: invalid 'targetId' parameter: " | |
1542 "id '%s' does not correspond to a " | |
1543 "library, class, or instance", js->method(), target_id); | |
1544 return true; | 1539 return true; |
1545 } | 1540 } |
1546 | 1541 |
1547 | 1542 |
1548 static const MethodParameter* evaluate_params[] = { | 1543 static const MethodParameter* evaluate_params[] = { |
1549 ISOLATE_PARAMETER, | 1544 ISOLATE_PARAMETER, |
1550 NULL, | 1545 NULL, |
1551 }; | 1546 }; |
1552 | 1547 |
1553 | 1548 |
(...skipping 1298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2852 ServiceMethodDescriptor& method = service_methods_[i]; | 2847 ServiceMethodDescriptor& method = service_methods_[i]; |
2853 if (strcmp(method_name, method.name) == 0) { | 2848 if (strcmp(method_name, method.name) == 0) { |
2854 return &method; | 2849 return &method; |
2855 } | 2850 } |
2856 } | 2851 } |
2857 return NULL; | 2852 return NULL; |
2858 } | 2853 } |
2859 | 2854 |
2860 | 2855 |
2861 } // namespace dart | 2856 } // namespace dart |
OLD | NEW |