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

Unified Diff: runtime/vm/isolate.cc

Issue 12221022: Initial prototype of vmstats support, based on Dart VM Stats draft design doc. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 10 months 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 side-by-side diff with in-line comments
Download patch
« runtime/vm/debugger.cc ('K') | « runtime/vm/isolate.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/isolate.cc
===================================================================
--- runtime/vm/isolate.cc (revision 18152)
+++ runtime/vm/isolate.cc (working copy)
@@ -4,6 +4,8 @@
#include "vm/isolate.h"
+#include <sstream>
+
#include "include/dart_api.h"
#include "platform/assert.h"
#include "lib/mirrors.h"
@@ -627,4 +629,40 @@
}
}
+
+char* Isolate::GetStatus(const char* request) {
+ char* p = const_cast<char*>(request);
+ const char* service_type = "/isolate/";
+ ASSERT(strncmp(p, service_type, strlen(service_type)) == 0);
+ p += strlen(service_type);
+
+ // Extract isolate handle.
+ int64_t addr;
+ OS::StringToInt64(p, &addr);
+ Isolate* isolate = reinterpret_cast<Isolate*>(addr);
+ Heap* heap = isolate->heap();
+
+ std::ostringstream stream;
+ stream << '{' << std::endl;
+ stream << " \"name\": \"" << isolate->name() << "\"," << std::endl;
+ stream << " \"port\": " << isolate->main_port() << ',' << std::endl;
+ stream << " \"starttime\": " << (isolate->start_time() / 1000)
+ << ',' << std::endl;
+ stream << " \"stacklimit\": " << isolate->saved_stack_limit()
+ << ',' << std::endl;
+ stream << " \"newspace\": {" << std::endl;
+ stream << " \"used\": " <<
+ heap->Used(Heap::kNew) / KB << ',' << std::endl;
+ stream << " \"capacity\": " <<
+ heap->Capacity(Heap::kNew) / KB << std::endl;
+ stream << " }," << std::endl;
+ stream << " \"oldspace\": {" << std::endl;
+ stream << " \"used\": " <<
+ heap->Used(Heap::kOld) / KB << ',' << std::endl;
+ stream << " \"capacity\": " <<
+ heap->Capacity(Heap::kOld) / KB << std::endl;
+ stream << " }" << std::endl << "}";
siva 2013/02/09 01:00:57 Can this whole sequence be constructed using OS::S
Tom Ball 2013/02/14 23:45:16 Done.
+ return strdup(stream.str().c_str());
+}
+
} // namespace dart
« runtime/vm/debugger.cc ('K') | « runtime/vm/isolate.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698