| 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 "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 1746 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1757 PrintInvalidParamError(js, "targetId"); | 1757 PrintInvalidParamError(js, "targetId"); |
| 1758 } | 1758 } |
| 1759 return true; | 1759 return true; |
| 1760 } | 1760 } |
| 1761 return PrintRetainingPath(thread, &obj, limit, js); | 1761 return PrintRetainingPath(thread, &obj, limit, js); |
| 1762 } | 1762 } |
| 1763 | 1763 |
| 1764 | 1764 |
| 1765 static const MethodParameter* get_retained_size_params[] = { | 1765 static const MethodParameter* get_retained_size_params[] = { |
| 1766 ISOLATE_PARAMETER, | 1766 ISOLATE_PARAMETER, |
| 1767 new IdParameter("targetId", true), |
| 1767 NULL, | 1768 NULL, |
| 1768 }; | 1769 }; |
| 1769 | 1770 |
| 1770 | 1771 |
| 1771 static bool GetRetainedSize(Thread* thread, JSONStream* js) { | 1772 static bool GetRetainedSize(Thread* thread, JSONStream* js) { |
| 1772 const char* target_id = js->LookupParam("targetId"); | 1773 const char* target_id = js->LookupParam("targetId"); |
| 1773 if (target_id == NULL) { | 1774 ASSERT(target_id != NULL); |
| 1774 PrintMissingParamError(js, "targetId"); | |
| 1775 return true; | |
| 1776 } | |
| 1777 ObjectIdRing::LookupResult lookup_result; | 1775 ObjectIdRing::LookupResult lookup_result; |
| 1778 Object& obj = Object::Handle(LookupHeapObject(thread, target_id, | 1776 Object& obj = Object::Handle(LookupHeapObject(thread, target_id, |
| 1779 &lookup_result)); | 1777 &lookup_result)); |
| 1780 if (obj.raw() == Object::sentinel().raw()) { | 1778 if (obj.raw() == Object::sentinel().raw()) { |
| 1781 if (lookup_result == ObjectIdRing::kCollected) { | 1779 if (lookup_result == ObjectIdRing::kCollected) { |
| 1782 PrintSentinel(js, kCollectedSentinel); | 1780 PrintSentinel(js, kCollectedSentinel); |
| 1783 } else if (lookup_result == ObjectIdRing::kExpired) { | 1781 } else if (lookup_result == ObjectIdRing::kExpired) { |
| 1784 PrintSentinel(js, kExpiredSentinel); | 1782 PrintSentinel(js, kExpiredSentinel); |
| 1785 } else { | 1783 } else { |
| 1786 PrintInvalidParamError(js, "targetId"); | 1784 PrintInvalidParamError(js, "targetId"); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 1799 } | 1797 } |
| 1800 | 1798 |
| 1801 ObjectGraph graph(thread); | 1799 ObjectGraph graph(thread); |
| 1802 intptr_t retained_size = graph.SizeRetainedByInstance(obj); | 1800 intptr_t retained_size = graph.SizeRetainedByInstance(obj); |
| 1803 const Object& result = Object::Handle(Integer::New(retained_size)); | 1801 const Object& result = Object::Handle(Integer::New(retained_size)); |
| 1804 result.PrintJSON(js, true); | 1802 result.PrintJSON(js, true); |
| 1805 return true; | 1803 return true; |
| 1806 } | 1804 } |
| 1807 | 1805 |
| 1808 | 1806 |
| 1807 static const MethodParameter* get_reachable_size_params[] = { |
| 1808 ISOLATE_PARAMETER, |
| 1809 new IdParameter("targetId", true), |
| 1810 NULL, |
| 1811 }; |
| 1812 |
| 1813 |
| 1814 static bool GetReachableSize(Thread* thread, JSONStream* js) { |
| 1815 const char* target_id = js->LookupParam("targetId"); |
| 1816 ASSERT(target_id != NULL); |
| 1817 ObjectIdRing::LookupResult lookup_result; |
| 1818 Object& obj = Object::Handle(LookupHeapObject(thread, target_id, |
| 1819 &lookup_result)); |
| 1820 if (obj.raw() == Object::sentinel().raw()) { |
| 1821 if (lookup_result == ObjectIdRing::kCollected) { |
| 1822 PrintSentinel(js, kCollectedSentinel); |
| 1823 } else if (lookup_result == ObjectIdRing::kExpired) { |
| 1824 PrintSentinel(js, kExpiredSentinel); |
| 1825 } else { |
| 1826 PrintInvalidParamError(js, "targetId"); |
| 1827 } |
| 1828 return true; |
| 1829 } |
| 1830 // TODO(rmacnak): There is no way to get the size retained by a class object. |
| 1831 // SizeRetainedByClass should be a separate RPC. |
| 1832 if (obj.IsClass()) { |
| 1833 const Class& cls = Class::Cast(obj); |
| 1834 ObjectGraph graph(thread); |
| 1835 intptr_t retained_size = graph.SizeReachableByClass(cls.id()); |
| 1836 const Object& result = Object::Handle(Integer::New(retained_size)); |
| 1837 result.PrintJSON(js, true); |
| 1838 return true; |
| 1839 } |
| 1840 |
| 1841 ObjectGraph graph(thread); |
| 1842 intptr_t retained_size = graph.SizeReachableByInstance(obj); |
| 1843 const Object& result = Object::Handle(Integer::New(retained_size)); |
| 1844 result.PrintJSON(js, true); |
| 1845 return true; |
| 1846 } |
| 1847 |
| 1848 |
| 1809 static const MethodParameter* evaluate_params[] = { | 1849 static const MethodParameter* evaluate_params[] = { |
| 1810 ISOLATE_PARAMETER, | 1850 ISOLATE_PARAMETER, |
| 1811 NULL, | 1851 NULL, |
| 1812 }; | 1852 }; |
| 1813 | 1853 |
| 1814 | 1854 |
| 1815 static bool Evaluate(Thread* thread, JSONStream* js) { | 1855 static bool Evaluate(Thread* thread, JSONStream* js) { |
| 1816 if (!thread->isolate()->compilation_allowed()) { | 1856 if (!thread->isolate()->compilation_allowed()) { |
| 1817 js->PrintError(kFeatureDisabled, | 1857 js->PrintError(kFeatureDisabled, |
| 1818 "Cannot evaluate when running a precompiled program."); | 1858 "Cannot evaluate when running a precompiled program."); |
| (...skipping 1629 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3448 { "_getIsolateMetric", GetIsolateMetric, | 3488 { "_getIsolateMetric", GetIsolateMetric, |
| 3449 get_isolate_metric_params }, | 3489 get_isolate_metric_params }, |
| 3450 { "_getIsolateMetricList", GetIsolateMetricList, | 3490 { "_getIsolateMetricList", GetIsolateMetricList, |
| 3451 get_isolate_metric_list_params }, | 3491 get_isolate_metric_list_params }, |
| 3452 { "getObject", GetObject, | 3492 { "getObject", GetObject, |
| 3453 get_object_params }, | 3493 get_object_params }, |
| 3454 { "_getObjectByAddress", GetObjectByAddress, | 3494 { "_getObjectByAddress", GetObjectByAddress, |
| 3455 get_object_by_address_params }, | 3495 get_object_by_address_params }, |
| 3456 { "_getPorts", GetPorts, | 3496 { "_getPorts", GetPorts, |
| 3457 get_ports_params }, | 3497 get_ports_params }, |
| 3498 { "_getReachableSize", GetReachableSize, |
| 3499 get_reachable_size_params }, |
| 3458 { "_getRetainedSize", GetRetainedSize, | 3500 { "_getRetainedSize", GetRetainedSize, |
| 3459 get_retained_size_params }, | 3501 get_retained_size_params }, |
| 3460 { "_getRetainingPath", GetRetainingPath, | 3502 { "_getRetainingPath", GetRetainingPath, |
| 3461 get_retaining_path_params }, | 3503 get_retaining_path_params }, |
| 3462 { "getStack", GetStack, | 3504 { "getStack", GetStack, |
| 3463 get_stack_params }, | 3505 get_stack_params }, |
| 3464 { "_getTagProfile", GetTagProfile, | 3506 { "_getTagProfile", GetTagProfile, |
| 3465 get_tag_profile_params }, | 3507 get_tag_profile_params }, |
| 3466 { "_getTypeArgumentsList", GetTypeArgumentsList, | 3508 { "_getTypeArgumentsList", GetTypeArgumentsList, |
| 3467 get_type_arguments_list_params }, | 3509 get_type_arguments_list_params }, |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3511 ServiceMethodDescriptor& method = service_methods_[i]; | 3553 ServiceMethodDescriptor& method = service_methods_[i]; |
| 3512 if (strcmp(method_name, method.name) == 0) { | 3554 if (strcmp(method_name, method.name) == 0) { |
| 3513 return &method; | 3555 return &method; |
| 3514 } | 3556 } |
| 3515 } | 3557 } |
| 3516 return NULL; | 3558 return NULL; |
| 3517 } | 3559 } |
| 3518 | 3560 |
| 3519 | 3561 |
| 3520 } // namespace dart | 3562 } // namespace dart |
| OLD | NEW |