Chromium Code Reviews| Index: runtime/vm/service.cc |
| diff --git a/runtime/vm/service.cc b/runtime/vm/service.cc |
| index 70ca2e305fdbbafe1eebd3bb66ff0206469932b1..5cd668054612952130d4c7adaf1260ca79fae9b9 100644 |
| --- a/runtime/vm/service.cc |
| +++ b/runtime/vm/service.cc |
| @@ -1806,6 +1806,50 @@ static bool GetRetainedSize(Thread* thread, JSONStream* js) { |
| } |
| +static const MethodParameter* get_reachable_size_params[] = { |
| + ISOLATE_PARAMETER, |
| + NULL, |
|
Cutch
2015/11/18 15:00:20
new IdParameter("targetId", true),
rmacnak
2015/11/18 18:07:29
Done, here and retained_size
|
| +}; |
| + |
| + |
| +static bool GetReachableSize(Thread* thread, JSONStream* js) { |
| + const char* target_id = js->LookupParam("targetId"); |
| + if (target_id == NULL) { |
|
Cutch
2015/11/18 15:00:20
ASSERT(target_id != NULL);
rmacnak
2015/11/18 18:07:29
Done.
|
| + PrintMissingParamError(js, "targetId"); |
| + return true; |
| + } |
| + ObjectIdRing::LookupResult lookup_result; |
| + Object& obj = Object::Handle(LookupHeapObject(thread, target_id, |
| + &lookup_result)); |
| + if (obj.raw() == Object::sentinel().raw()) { |
| + if (lookup_result == ObjectIdRing::kCollected) { |
| + PrintSentinel(js, kCollectedSentinel); |
|
Cutch
2015/11/18 15:00:20
Should GetReachableSize for a collected object be
rmacnak
2015/11/18 18:07:29
Asking any question about an object that got colle
|
| + } else if (lookup_result == ObjectIdRing::kExpired) { |
| + PrintSentinel(js, kExpiredSentinel); |
| + } else { |
| + PrintInvalidParamError(js, "targetId"); |
| + } |
| + return true; |
| + } |
| + // TODO(rmacnak): There is no way to get the size retained by a class object. |
| + // SizeRetainedByClass should be a separate RPC. |
| + if (obj.IsClass()) { |
| + const Class& cls = Class::Cast(obj); |
| + ObjectGraph graph(thread); |
| + intptr_t retained_size = graph.SizeReachableByClass(cls.id()); |
| + const Object& result = Object::Handle(Integer::New(retained_size)); |
| + result.PrintJSON(js, true); |
| + return true; |
| + } |
| + |
| + ObjectGraph graph(thread); |
| + intptr_t retained_size = graph.SizeReachableByInstance(obj); |
| + const Object& result = Object::Handle(Integer::New(retained_size)); |
| + result.PrintJSON(js, true); |
| + return true; |
| +} |
| + |
| + |
| static const MethodParameter* evaluate_params[] = { |
| ISOLATE_PARAMETER, |
| NULL, |
| @@ -3455,6 +3499,8 @@ static ServiceMethodDescriptor service_methods_[] = { |
| get_object_by_address_params }, |
| { "_getPorts", GetPorts, |
| get_ports_params }, |
| + { "_getReachableSize", GetReachableSize, |
| + get_reachable_size_params }, |
| { "_getRetainedSize", GetRetainedSize, |
| get_retained_size_params }, |
| { "_getRetainingPath", GetRetainingPath, |