Index: src/heap.cc |
diff --git a/src/heap.cc b/src/heap.cc |
index 9f27a49039225c76c6fede8e20ad1df3295ac87e..c4d0439e0d0b5dc940dca636b49635d7929757c7 100644 |
--- a/src/heap.cc |
+++ b/src/heap.cc |
@@ -4106,7 +4106,7 @@ bool Heap::ConfigureHeapDefault() { |
} |
-void Heap::RecordStats(HeapStats* stats) { |
+void Heap::RecordStats(HeapStats* stats, bool take_snapshot) { |
*stats->start_marker = 0xDECADE00; |
*stats->end_marker = 0xDECADE01; |
*stats->new_space_size = new_space_.Size(); |
@@ -4123,6 +4123,23 @@ void Heap::RecordStats(HeapStats* stats) { |
*stats->cell_space_capacity = cell_space_->Capacity(); |
*stats->lo_space_size = lo_space_->Size(); |
GlobalHandles::RecordStats(stats); |
+ *stats->memory_allocator_size = MemoryAllocator::Size(); |
+ *stats->memory_allocator_capacity = |
+ MemoryAllocator::Size() + MemoryAllocator::Available(); |
+ if (take_snapshot) { |
+ HeapIterator iterator; |
+ for (HeapObject* obj = iterator.next(); |
+ obj != NULL; |
+ obj = iterator.next()) { |
+ // Note: snapshot won't be precise because IsFreeListNode returns true |
+ // for any bytearray. |
+ if (FreeListNode::IsFreeListNode(obj)) continue; |
+ InstanceType type = obj->map()->instance_type(); |
+ ASSERT(0 <= type && type <= LAST_TYPE); |
+ stats->objects_per_type[type]++; |
+ stats->size_per_type[type] += obj->Size(); |
+ } |
+ } |
} |