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

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,36 @@
}
+class HeapMapAsJSONVisitor : public ObjectVisitor {
+ public:
+ explicit HeapMapAsJSONVisitor(JSONArray* array)
+ : ObjectVisitor(NULL), array_(array) {}
+ virtual void VisitObject(RawObject* obj) {
+ array_->AddValue(obj->Size() / kObjectAlignment);
+ // Freelist is most interesting, so map it to a fixed unused value.
+ ASSERT(0 == kIllegalCid);
+ array_->AddValue(obj->IsFreeListElement() ? 0 : obj->GetClassId());
Cutch 2014/03/12 19:02:02 I'm concerned about mapping kFreeListElement to kI
koda 2014/03/12 19:08:01 Good idea. Done.
+ }
+ private:
+ JSONArray* array_;
+};
+
+
+void PageSpace::PrintHeapMapToJSONStream(JSONStream* stream) {
+ JSONObject heap_map(stream);
+ heap_map.AddProperty("type", "HeapMap");
+ heap_map.AddProperty("id", "heapmap");
Cutch 2014/03/12 19:02:02 heap_map.AddProperty("free_class_id", kFreeListEle
koda 2014/03/12 19:08:01 Done.
+ {
+ JSONArray all_pages(&heap_map, "pages");
Cutch 2014/03/12 19:02:02 Maybe add a comment here saying the format of "pag
koda 2014/03/12 19:08:01 Done.
+ 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