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 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
102 // TODO(johnmccutchan): Unify embedder service handler lists and their APIs. | 102 // TODO(johnmccutchan): Unify embedder service handler lists and their APIs. |
103 EmbedderServiceHandler* Service::isolate_service_handler_head_ = NULL; | 103 EmbedderServiceHandler* Service::isolate_service_handler_head_ = NULL; |
104 EmbedderServiceHandler* Service::root_service_handler_head_ = NULL; | 104 EmbedderServiceHandler* Service::root_service_handler_head_ = NULL; |
105 struct ServiceMethodDescriptor; | 105 struct ServiceMethodDescriptor; |
106 const ServiceMethodDescriptor* FindMethod(const char* method_name); | 106 const ServiceMethodDescriptor* FindMethod(const char* method_name); |
107 | 107 |
108 // Support for streams defined in embedders. | 108 // Support for streams defined in embedders. |
109 Dart_ServiceStreamListenCallback Service::stream_listen_callback_ = NULL; | 109 Dart_ServiceStreamListenCallback Service::stream_listen_callback_ = NULL; |
110 Dart_ServiceStreamCancelCallback Service::stream_cancel_callback_ = NULL; | 110 Dart_ServiceStreamCancelCallback Service::stream_cancel_callback_ = NULL; |
111 Dart_GetVMServiceAssetsArchive Service::get_service_assets_callback_ = NULL; | 111 Dart_GetVMServiceAssetsArchive Service::get_service_assets_callback_ = NULL; |
112 Dart_EmbedderInformationCallback Service::embedder_information_callback_ = NULL; | |
112 | 113 |
113 // These are the set of streams known to the core VM. | 114 // These are the set of streams known to the core VM. |
114 StreamInfo Service::vm_stream("VM"); | 115 StreamInfo Service::vm_stream("VM"); |
115 StreamInfo Service::isolate_stream("Isolate"); | 116 StreamInfo Service::isolate_stream("Isolate"); |
116 StreamInfo Service::debug_stream("Debug"); | 117 StreamInfo Service::debug_stream("Debug"); |
117 StreamInfo Service::gc_stream("GC"); | 118 StreamInfo Service::gc_stream("GC"); |
118 StreamInfo Service::echo_stream("_Echo"); | 119 StreamInfo Service::echo_stream("_Echo"); |
119 StreamInfo Service::graph_stream("_Graph"); | 120 StreamInfo Service::graph_stream("_Graph"); |
120 StreamInfo Service::logging_stream("_Logging"); | 121 StreamInfo Service::logging_stream("_Logging"); |
121 StreamInfo Service::extension_stream("Extension"); | 122 StreamInfo Service::extension_stream("Extension"); |
(...skipping 1098 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1220 Dart_ServiceStreamCancelCallback cancel_callback) { | 1221 Dart_ServiceStreamCancelCallback cancel_callback) { |
1221 stream_listen_callback_ = listen_callback; | 1222 stream_listen_callback_ = listen_callback; |
1222 stream_cancel_callback_ = cancel_callback; | 1223 stream_cancel_callback_ = cancel_callback; |
1223 } | 1224 } |
1224 | 1225 |
1225 void Service::SetGetServiceAssetsCallback( | 1226 void Service::SetGetServiceAssetsCallback( |
1226 Dart_GetVMServiceAssetsArchive get_service_assets) { | 1227 Dart_GetVMServiceAssetsArchive get_service_assets) { |
1227 get_service_assets_callback_ = get_service_assets; | 1228 get_service_assets_callback_ = get_service_assets; |
1228 } | 1229 } |
1229 | 1230 |
1231 void Service::SetEmbedderInformationCallback( | |
1232 Dart_EmbedderInformationCallback callback) { | |
1233 embedder_information_callback_ = callback; | |
1234 } | |
1235 | |
1236 int64_t Service::CurrentRSS() { | |
1237 if (embedder_information_callback_ == NULL) { | |
1238 return -1; | |
1239 } | |
1240 Dart_EmbedderInformation info = { | |
1241 0, // version | |
1242 NULL, // name | |
1243 0, // max_rss | |
1244 0 // current_rss | |
1245 }; | |
1246 embedder_information_callback_(&info); | |
1247 ASSERT(info.version == DART_EMBEDDER_INFORMATION_CURRENT_VERSION); | |
1248 return info.current_rss; | |
1249 } | |
1250 | |
1251 int64_t Service::MaxRSS() { | |
1252 if (embedder_information_callback_ == NULL) { | |
1253 return -1; | |
1254 } | |
1255 Dart_EmbedderInformation info = { | |
1256 0, // version | |
1257 NULL, // name | |
1258 0, // max_rss | |
1259 0 // current_rss | |
1260 }; | |
1261 embedder_information_callback_(&info); | |
1262 ASSERT(info.version == DART_EMBEDDER_INFORMATION_CURRENT_VERSION); | |
1263 return info.max_rss; | |
1264 } | |
1265 | |
1230 EmbedderServiceHandler* Service::FindRootEmbedderHandler(const char* name) { | 1266 EmbedderServiceHandler* Service::FindRootEmbedderHandler(const char* name) { |
1231 EmbedderServiceHandler* current = root_service_handler_head_; | 1267 EmbedderServiceHandler* current = root_service_handler_head_; |
1232 while (current != NULL) { | 1268 while (current != NULL) { |
1233 if (strcmp(name, current->name()) == 0) { | 1269 if (strcmp(name, current->name()) == 0) { |
1234 return current; | 1270 return current; |
1235 } | 1271 } |
1236 current = current->next(); | 1272 current = current->next(); |
1237 } | 1273 } |
1238 return NULL; | 1274 return NULL; |
1239 } | 1275 } |
(...skipping 2589 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3829 return; | 3865 return; |
3830 } | 3866 } |
3831 jsobj.AddProperty("architectureBits", static_cast<intptr_t>(kBitsPerWord)); | 3867 jsobj.AddProperty("architectureBits", static_cast<intptr_t>(kBitsPerWord)); |
3832 jsobj.AddProperty("targetCPU", CPU::Id()); | 3868 jsobj.AddProperty("targetCPU", CPU::Id()); |
3833 jsobj.AddProperty("hostCPU", HostCPUFeatures::hardware()); | 3869 jsobj.AddProperty("hostCPU", HostCPUFeatures::hardware()); |
3834 jsobj.AddProperty("version", Version::String()); | 3870 jsobj.AddProperty("version", Version::String()); |
3835 jsobj.AddProperty("_profilerMode", FLAG_profile_vm ? "VM" : "Dart"); | 3871 jsobj.AddProperty("_profilerMode", FLAG_profile_vm ? "VM" : "Dart"); |
3836 jsobj.AddProperty64("_nativeZoneMemoryUsage", | 3872 jsobj.AddProperty64("_nativeZoneMemoryUsage", |
3837 ApiNativeScope::current_memory_usage()); | 3873 ApiNativeScope::current_memory_usage()); |
3838 jsobj.AddProperty64("pid", OS::ProcessId()); | 3874 jsobj.AddProperty64("pid", OS::ProcessId()); |
3839 jsobj.AddProperty64("_maxRSS", OS::MaxRSS()); | 3875 if (embedder_information_callback_ != NULL) { |
zra
2017/08/14 18:26:32
Possible cleanup: Pull this out into e.g. Service:
cbernaschina
2017/08/14 20:07:40
Done.
| |
3876 Dart_EmbedderInformation info = { | |
3877 0, // version | |
3878 NULL, // name | |
3879 0, // max_rss | |
3880 0 // current_rss | |
3881 }; | |
3882 embedder_information_callback_(&info); | |
3883 ASSERT(info.version == DART_EMBEDDER_INFORMATION_CURRENT_VERSION); | |
3884 if (info.name != NULL) { | |
3885 jsobj.AddProperty("_embedder", info.name); | |
3886 } | |
3887 if (info.max_rss > 0) { | |
3888 jsobj.AddProperty64("_maxRSS", info.max_rss); | |
3889 } | |
3890 if (info.max_rss > 0) { | |
3891 jsobj.AddProperty64("_currentRSS", info.current_rss); | |
3892 } | |
3893 } | |
3840 jsobj.AddPropertyTimeMillis( | 3894 jsobj.AddPropertyTimeMillis( |
3841 "startTime", OS::GetCurrentTimeMillis() - Dart::UptimeMillis()); | 3895 "startTime", OS::GetCurrentTimeMillis() - Dart::UptimeMillis()); |
3842 MallocHooks::PrintToJSONObject(&jsobj); | 3896 MallocHooks::PrintToJSONObject(&jsobj); |
3843 // Construct the isolate list. | 3897 // Construct the isolate list. |
3844 { | 3898 { |
3845 JSONArray jsarr(&jsobj, "isolates"); | 3899 JSONArray jsarr(&jsobj, "isolates"); |
3846 ServiceIsolateVisitor visitor(&jsarr); | 3900 ServiceIsolateVisitor visitor(&jsarr); |
3847 Isolate::VisitIsolates(&visitor); | 3901 Isolate::VisitIsolates(&visitor); |
3848 } | 3902 } |
3849 } | 3903 } |
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4142 if (strcmp(method_name, method.name) == 0) { | 4196 if (strcmp(method_name, method.name) == 0) { |
4143 return &method; | 4197 return &method; |
4144 } | 4198 } |
4145 } | 4199 } |
4146 return NULL; | 4200 return NULL; |
4147 } | 4201 } |
4148 | 4202 |
4149 #endif // !PRODUCT | 4203 #endif // !PRODUCT |
4150 | 4204 |
4151 } // namespace dart | 4205 } // namespace dart |
OLD | NEW |