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

Unified Diff: runtime/vm/pages.cc

Issue 197663006: Heap maps: add VM service message. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 9 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
« no previous file with comments | « runtime/vm/pages.h ('k') | runtime/vm/raw_object.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/pages.cc
===================================================================
--- runtime/vm/pages.cc (revision 33596)
+++ runtime/vm/pages.cc (working copy)
@@ -428,6 +428,38 @@
}
+class HeapMapAsJSONVisitor : public ObjectVisitor {
+ public:
+ explicit HeapMapAsJSONVisitor(JSONArray* array)
+ : ObjectVisitor(NULL), array_(array) {}
+ virtual void VisitObject(RawObject* obj) {
+ array_->AddValue(obj->Size() / kObjectAlignment);
+ array_->AddValue(obj->GetClassId());
+ }
+ private:
+ JSONArray* array_;
+};
+
+
+void PageSpace::PrintHeapMapToJSONStream(JSONStream* stream) {
+ JSONObject heap_map(stream);
+ heap_map.AddProperty("type", "HeapMap");
+ heap_map.AddProperty("id", "heapmap");
+ heap_map.AddProperty("free_class_id", kFreeListElement);
+ heap_map.AddProperty("unit_size_bytes", kObjectAlignment);
+ {
+ // "pages" is an array [page0, page1, ..., pageN], each page an array
+ // [size, class id, size, class id, ...] (size unit is kObjectAlignment).
+ JSONArray all_pages(&heap_map, "pages");
+ for (HeapPage* page = pages_; page != NULL; page = page->next()) {
+ JSONArray page_map(&all_pages);
+ HeapMapAsJSONVisitor printer(&page_map);
+ page->VisitObjects(&printer);
+ }
+ }
+}
+
+
bool PageSpace::ShouldCollectCode() {
// Try to collect code if enough time has passed since the last attempt.
const int64_t start = OS::GetCurrentTimeMicros();
« no previous file with comments | « runtime/vm/pages.h ('k') | runtime/vm/raw_object.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698