| Index: runtime/bin/main.cc
|
| ===================================================================
|
| --- runtime/bin/main.cc (revision 18152)
|
| +++ runtime/bin/main.cc (working copy)
|
| @@ -20,6 +20,7 @@
|
| #include "bin/log.h"
|
| #include "bin/platform.h"
|
| #include "bin/process.h"
|
| +#include "bin/vmstats.h"
|
| #include "platform/globals.h"
|
|
|
| // snapshot_buffer points to a snapshot if we link in a snapshot otherwise
|
| @@ -47,6 +48,8 @@
|
| static const char* debug_ip = DEFAULT_DEBUG_IP;
|
| static int debug_port = 0;
|
|
|
| +// Global state that defines the VmStats web server port.
|
| +static int visual_vm_port = 0;
|
|
|
| // Value of the --package-root flag.
|
| // (This pointer points into an argv buffer and does not need to be
|
| @@ -164,6 +167,17 @@
|
| }
|
|
|
|
|
| +static bool ProcessVmStatsPortOption(const char* port) {
|
| + ASSERT(port != NULL);
|
| + if (*port == '\0') {
|
| + visual_vm_port = 0;
|
| + } else {
|
| + visual_vm_port = atoi(port);
|
| + }
|
| + return true;
|
| +}
|
| +
|
| +
|
| static bool ProcessGenScriptSnapshotOption(const char* filename) {
|
| if (filename != NULL && strlen(filename) != 0) {
|
| // Ensure that are already running using a full snapshot.
|
| @@ -207,6 +221,7 @@
|
| { "--debug", ProcessDebugOption },
|
| { "--use-script-snapshot=", ProcessUseScriptSnapshotOption },
|
| { "--generate-script-snapshot=", ProcessGenScriptSnapshotOption },
|
| + { "--vmstats_port=", ProcessVmStatsPortOption },
|
| { NULL, NULL }
|
| };
|
|
|
| @@ -488,6 +503,7 @@
|
| return false;
|
| }
|
| Dart_ExitScope();
|
| + dart::VmStats::AddIsolate(reinterpret_cast<IsolateData*>(data), isolate);
|
| return true;
|
| }
|
|
|
| @@ -627,6 +643,7 @@
|
|
|
| static void ShutdownIsolate(void* callback_data) {
|
| IsolateData* isolate_data = reinterpret_cast<IsolateData*>(callback_data);
|
| + dart::VmStats::RemoveIsolate(isolate_data);
|
| EventHandler* handler = isolate_data->event_handler;
|
| if (handler != NULL) handler->Shutdown();
|
| delete isolate_data;
|
| @@ -713,6 +730,10 @@
|
|
|
| Dart_EnterScope();
|
|
|
| + if (visual_vm_port > 0) {
|
| + dart::VmStats::Start(visual_vm_port);
|
| + }
|
| +
|
| if (generate_script_snapshot) {
|
| // First create a snapshot.
|
| Dart_Handle result;
|
| @@ -773,6 +794,7 @@
|
| }
|
|
|
| Dart_ExitScope();
|
| + dart::VmStats::Stop();
|
| // Shutdown the isolate.
|
| Dart_ShutdownIsolate();
|
| // Terminate process exit-code handler.
|
|
|