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

Unified Diff: runtime/vm/service.cc

Issue 1453983002: Add RPC and UI for reachable size of an object / all instances of a class. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 1 month 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/vm/raw_object.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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,
« no previous file with comments | « runtime/vm/raw_object.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698