Index: runtime/vm/service.cc |
diff --git a/runtime/vm/service.cc b/runtime/vm/service.cc |
index f1614693021c5bbd79e46725777524b60c56b634..6a0bd6d9b4026ce06173c785f70eba22427c89a9 100644 |
--- a/runtime/vm/service.cc |
+++ b/runtime/vm/service.cc |
@@ -108,6 +108,7 @@ const ServiceMethodDescriptor* FindMethod(const char* method_name); |
Dart_ServiceStreamListenCallback Service::stream_listen_callback_ = NULL; |
Dart_ServiceStreamCancelCallback Service::stream_cancel_callback_ = NULL; |
Dart_GetVMServiceAssetsArchive Service::get_service_assets_callback_ = NULL; |
+Dart_GetEmbedderInformation Service::get_embedder_information_callback_ = NULL; |
// These are the set of streams known to the core VM. |
StreamInfo Service::vm_stream("VM"); |
@@ -1226,6 +1227,25 @@ void Service::SetGetServiceAssetsCallback( |
get_service_assets_callback_ = get_service_assets; |
} |
+void Service::SetGetEmbedderInformationCallback( |
+ Dart_GetEmbedderInformation get_embedder_information) { |
+ get_embedder_information_callback_ = get_embedder_information; |
+} |
+ |
+int64_t Service::CurrentRSS() { |
+ if (get_embedder_information_callback_ == NULL) { |
+ return -1; |
+ } |
+ return get_embedder_information_callback_()->current_rss; |
+} |
+ |
+int64_t Service::MaxRSS() { |
+ if (get_embedder_information_callback_ == NULL) { |
+ return -1; |
+ } |
+ return get_embedder_information_callback_()->max_rss; |
+} |
+ |
EmbedderServiceHandler* Service::FindRootEmbedderHandler(const char* name) { |
EmbedderServiceHandler* current = root_service_handler_head_; |
while (current != NULL) { |
@@ -3822,7 +3842,19 @@ void Service::PrintJSONForVM(JSONStream* js, bool ref) { |
jsobj.AddProperty64("_nativeZoneMemoryUsage", |
ApiNativeScope::current_memory_usage()); |
jsobj.AddProperty64("pid", OS::ProcessId()); |
- jsobj.AddProperty64("_maxRSS", OS::MaxRSS()); |
+ if (get_embedder_information_callback_ != NULL) { |
+ const Dart_EmbedderInformation* info = get_embedder_information_callback_(); |
+ ASSERT(info != NULL); |
+ if (info->name != NULL) { |
+ jsobj.AddProperty("_embedder", info->name); |
+ } |
+ if (info->max_rss > 0) { |
+ jsobj.AddProperty64("_maxRSS", info->max_rss); |
+ } |
+ if (info->max_rss > 0) { |
+ jsobj.AddProperty64("_currentRSS", info->current_rss); |
+ } |
+ } |
jsobj.AddPropertyTimeMillis( |
"startTime", OS::GetCurrentTimeMillis() - Dart::UptimeMillis()); |
MallocHooks::PrintToJSONObject(&jsobj); |