Chromium Code Reviews| Index: src/api.cc |
| diff --git a/src/api.cc b/src/api.cc |
| index 28c84106df4c260cfbd2e96972a12efcd1f10964..89e3b3714bef60c836b1d160eeda194332e95f0b 100644 |
| --- a/src/api.cc |
| +++ b/src/api.cc |
| @@ -30,6 +30,7 @@ |
| #include "src/deoptimizer.h" |
| #include "src/execution.h" |
| #include "src/global-handles.h" |
| +#include "src/heap/spaces.h" |
| #include "src/heap-profiler.h" |
| #include "src/heap-snapshot-generator-inl.h" |
| #include "src/icu_util.h" |
| @@ -6957,15 +6958,55 @@ Isolate::SuppressMicrotaskExecutionScope::~SuppressMicrotaskExecutionScope() { |
| } |
| +class HeapStatisticsHelper { |
|
rmcilroy
2015/04/13 12:48:23
I don't think we should have a seperate class just
|
| + public: |
| + static void ExtractHeapStatistics(HeapStatistics* heap_statistics, |
| + i::Heap* heap) { |
| + heap_statistics->total_heap_size_ = heap->CommittedMemory(); |
| + heap_statistics->total_heap_size_executable_ = |
| + heap->CommittedMemoryExecutable(); |
| + heap_statistics->total_physical_size_ = heap->CommittedPhysicalMemory(); |
| + heap_statistics->used_heap_size_ = heap->SizeOfObjects(); |
| + heap_statistics->heap_size_limit_ = heap->MaxReserved(); |
| + |
| + heap_statistics->new_space_statistics()->size_of_objects_ = |
| + heap->new_space()->Size(); |
| + heap_statistics->new_space_statistics()->available_memory_ = |
| + heap->new_space()->Available(); |
| + heap_statistics->new_space_statistics()->committed_memory_ = |
| + heap->new_space()->CommittedMemory(); |
| + |
| + heap_statistics->lo_space_statistics()->size_of_objects_ = |
| + heap->lo_space()->SizeOfObjects(); |
| + heap_statistics->lo_space_statistics()->available_memory_ = |
| + heap->lo_space()->Available(); |
| + heap_statistics->lo_space_statistics()->committed_memory_ = |
| + heap->lo_space()->CommittedMemory(); |
| + |
| + ExtractSpaceStatisticsFromPagedSpace( |
| + heap->old_space(), heap_statistics->old_space_statistics()); |
| + ExtractSpaceStatisticsFromPagedSpace( |
| + heap->code_space(), heap_statistics->code_space_statistics()); |
| + ExtractSpaceStatisticsFromPagedSpace( |
| + heap->map_space(), heap_statistics->map_space_statistics()); |
| + ExtractSpaceStatisticsFromPagedSpace( |
| + heap->cell_space(), heap_statistics->cell_space_statistics()); |
| + } |
| + |
| + static void ExtractSpaceStatisticsFromPagedSpace( |
| + i::PagedSpace* paged_space, |
| + HeapStatistics::SpaceStatistics* space_stats) { |
| + space_stats->size_of_objects_ = paged_space->SizeOfObjects(); |
| + space_stats->committed_memory_ = paged_space->CommittedMemory(); |
| + space_stats->available_memory_ = paged_space->Available(); |
| + } |
| +}; |
| + |
| + |
| void Isolate::GetHeapStatistics(HeapStatistics* heap_statistics) { |
| i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this); |
| i::Heap* heap = isolate->heap(); |
| - heap_statistics->total_heap_size_ = heap->CommittedMemory(); |
| - heap_statistics->total_heap_size_executable_ = |
| - heap->CommittedMemoryExecutable(); |
| - heap_statistics->total_physical_size_ = heap->CommittedPhysicalMemory(); |
| - heap_statistics->used_heap_size_ = heap->SizeOfObjects(); |
| - heap_statistics->heap_size_limit_ = heap->MaxReserved(); |
| + HeapStatisticsHelper::ExtractHeapStatistics(heap_statistics, heap); |
| } |