| Index: runtime/vm/service.cc
|
| diff --git a/runtime/vm/service.cc b/runtime/vm/service.cc
|
| index 50d1aa401c08cd99a4448253b331247189b2f6ac..f47fd00c58d06f7522fff3f905c13c91f4a243f9 100644
|
| --- a/runtime/vm/service.cc
|
| +++ b/runtime/vm/service.cc
|
| @@ -1764,16 +1764,14 @@ static bool GetRetainingPath(Thread* thread, JSONStream* js) {
|
|
|
| static const MethodParameter* get_retained_size_params[] = {
|
| ISOLATE_PARAMETER,
|
| + new IdParameter("targetId", true),
|
| NULL,
|
| };
|
|
|
|
|
| static bool GetRetainedSize(Thread* thread, JSONStream* js) {
|
| const char* target_id = js->LookupParam("targetId");
|
| - if (target_id == NULL) {
|
| - PrintMissingParamError(js, "targetId");
|
| - return true;
|
| - }
|
| + ASSERT(target_id != NULL);
|
| ObjectIdRing::LookupResult lookup_result;
|
| Object& obj = Object::Handle(LookupHeapObject(thread, target_id,
|
| &lookup_result));
|
| @@ -1806,6 +1804,48 @@ static bool GetRetainedSize(Thread* thread, JSONStream* js) {
|
| }
|
|
|
|
|
| +static const MethodParameter* get_reachable_size_params[] = {
|
| + ISOLATE_PARAMETER,
|
| + new IdParameter("targetId", true),
|
| + NULL,
|
| +};
|
| +
|
| +
|
| +static bool GetReachableSize(Thread* thread, JSONStream* js) {
|
| + const char* target_id = js->LookupParam("targetId");
|
| + ASSERT(target_id != NULL);
|
| + 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);
|
| + } 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 +3495,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,
|
|
|