Chromium Code Reviews| 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(); |