Chromium Code Reviews| Index: runtime/vm/pages.cc |
| =================================================================== |
| --- runtime/vm/pages.cc (revision 33596) |
| +++ runtime/vm/pages.cc (working copy) |
| @@ -428,6 +428,37 @@ |
| } |
| +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); |
| + { |
| + // "pages" is an array [page0, page1, ..., pageN], each page an array |
| + // [size, class id, size, class id, ...] (size unit is kObjectAlignment). |
|
Cutch
2014/03/12 20:37:41
Should we send the value of kObjectAlignment or is
koda
2014/03/12 20:44:17
Added it as "unit_size_bytes".
(It's two words, h
|
| + 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(); |