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

Side by Side 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 unified diff | Download patch
OLDNEW
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 1788 matching lines...) Expand 10 before | Expand all | Expand 10 after
1799 } 1799 }
1800 1800
1801 ObjectGraph graph(thread); 1801 ObjectGraph graph(thread);
1802 intptr_t retained_size = graph.SizeRetainedByInstance(obj); 1802 intptr_t retained_size = graph.SizeRetainedByInstance(obj);
1803 const Object& result = Object::Handle(Integer::New(retained_size)); 1803 const Object& result = Object::Handle(Integer::New(retained_size));
1804 result.PrintJSON(js, true); 1804 result.PrintJSON(js, true);
1805 return true; 1805 return true;
1806 } 1806 }
1807 1807
1808 1808
1809 static const MethodParameter* get_reachable_size_params[] = {
1810 ISOLATE_PARAMETER,
1811 NULL,
Cutch 2015/11/18 15:00:20 new IdParameter("targetId", true),
rmacnak 2015/11/18 18:07:29 Done, here and retained_size
1812 };
1813
1814
1815 static bool GetReachableSize(Thread* thread, JSONStream* js) {
1816 const char* target_id = js->LookupParam("targetId");
1817 if (target_id == NULL) {
Cutch 2015/11/18 15:00:20 ASSERT(target_id != NULL);
rmacnak 2015/11/18 18:07:29 Done.
1818 PrintMissingParamError(js, "targetId");
1819 return true;
1820 }
1821 ObjectIdRing::LookupResult lookup_result;
1822 Object& obj = Object::Handle(LookupHeapObject(thread, target_id,
1823 &lookup_result));
1824 if (obj.raw() == Object::sentinel().raw()) {
1825 if (lookup_result == ObjectIdRing::kCollected) {
1826 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
1827 } else if (lookup_result == ObjectIdRing::kExpired) {
1828 PrintSentinel(js, kExpiredSentinel);
1829 } else {
1830 PrintInvalidParamError(js, "targetId");
1831 }
1832 return true;
1833 }
1834 // TODO(rmacnak): There is no way to get the size retained by a class object.
1835 // SizeRetainedByClass should be a separate RPC.
1836 if (obj.IsClass()) {
1837 const Class& cls = Class::Cast(obj);
1838 ObjectGraph graph(thread);
1839 intptr_t retained_size = graph.SizeReachableByClass(cls.id());
1840 const Object& result = Object::Handle(Integer::New(retained_size));
1841 result.PrintJSON(js, true);
1842 return true;
1843 }
1844
1845 ObjectGraph graph(thread);
1846 intptr_t retained_size = graph.SizeReachableByInstance(obj);
1847 const Object& result = Object::Handle(Integer::New(retained_size));
1848 result.PrintJSON(js, true);
1849 return true;
1850 }
1851
1852
1809 static const MethodParameter* evaluate_params[] = { 1853 static const MethodParameter* evaluate_params[] = {
1810 ISOLATE_PARAMETER, 1854 ISOLATE_PARAMETER,
1811 NULL, 1855 NULL,
1812 }; 1856 };
1813 1857
1814 1858
1815 static bool Evaluate(Thread* thread, JSONStream* js) { 1859 static bool Evaluate(Thread* thread, JSONStream* js) {
1816 if (!thread->isolate()->compilation_allowed()) { 1860 if (!thread->isolate()->compilation_allowed()) {
1817 js->PrintError(kFeatureDisabled, 1861 js->PrintError(kFeatureDisabled,
1818 "Cannot evaluate when running a precompiled program."); 1862 "Cannot evaluate when running a precompiled program.");
(...skipping 1629 matching lines...) Expand 10 before | Expand all | Expand 10 after
3448 { "_getIsolateMetric", GetIsolateMetric, 3492 { "_getIsolateMetric", GetIsolateMetric,
3449 get_isolate_metric_params }, 3493 get_isolate_metric_params },
3450 { "_getIsolateMetricList", GetIsolateMetricList, 3494 { "_getIsolateMetricList", GetIsolateMetricList,
3451 get_isolate_metric_list_params }, 3495 get_isolate_metric_list_params },
3452 { "getObject", GetObject, 3496 { "getObject", GetObject,
3453 get_object_params }, 3497 get_object_params },
3454 { "_getObjectByAddress", GetObjectByAddress, 3498 { "_getObjectByAddress", GetObjectByAddress,
3455 get_object_by_address_params }, 3499 get_object_by_address_params },
3456 { "_getPorts", GetPorts, 3500 { "_getPorts", GetPorts,
3457 get_ports_params }, 3501 get_ports_params },
3502 { "_getReachableSize", GetReachableSize,
3503 get_reachable_size_params },
3458 { "_getRetainedSize", GetRetainedSize, 3504 { "_getRetainedSize", GetRetainedSize,
3459 get_retained_size_params }, 3505 get_retained_size_params },
3460 { "_getRetainingPath", GetRetainingPath, 3506 { "_getRetainingPath", GetRetainingPath,
3461 get_retaining_path_params }, 3507 get_retaining_path_params },
3462 { "getStack", GetStack, 3508 { "getStack", GetStack,
3463 get_stack_params }, 3509 get_stack_params },
3464 { "_getTagProfile", GetTagProfile, 3510 { "_getTagProfile", GetTagProfile,
3465 get_tag_profile_params }, 3511 get_tag_profile_params },
3466 { "_getTypeArgumentsList", GetTypeArgumentsList, 3512 { "_getTypeArgumentsList", GetTypeArgumentsList,
3467 get_type_arguments_list_params }, 3513 get_type_arguments_list_params },
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
3511 ServiceMethodDescriptor& method = service_methods_[i]; 3557 ServiceMethodDescriptor& method = service_methods_[i];
3512 if (strcmp(method_name, method.name) == 0) { 3558 if (strcmp(method_name, method.name) == 0) {
3513 return &method; 3559 return &method;
3514 } 3560 }
3515 } 3561 }
3516 return NULL; 3562 return NULL;
3517 } 3563 }
3518 3564
3519 3565
3520 } // namespace dart 3566 } // namespace dart
OLDNEW
« runtime/observatory/tests/service/reachable_size_test.dart ('K') | « runtime/vm/raw_object.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698