[heap] Statistics extension needs to check whether new space exists

Bug: v8:12706
Change-Id: I01346cb069bd7a517384100f57ccc54a59fbfccf
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3541923
Reviewed-by: Michael Lippautz <mlippautz@chromium.org>
Commit-Queue: Dominik Inführ <dinfuehr@chromium.org>
Cr-Commit-Position: refs/heads/main@{#79563}
This commit is contained in:
Dominik Inführ 2022-03-22 14:04:03 +01:00 committed by V8 LUCI CQ
parent 8bde9dce23
commit bd5ab58ac9

View File

@ -99,11 +99,21 @@ void StatisticsExtension::GetCounters(
const char* name;
};
size_t new_space_size = 0;
size_t new_space_available = 0;
size_t new_space_committed_memory = 0;
if (heap->new_space()) {
new_space_size = heap->new_space()->Size();
new_space_available = heap->new_space()->Available();
new_space_committed_memory = heap->new_space()->CommittedMemory();
}
const StatisticNumber numbers[] = {
{heap->memory_allocator()->Size(), "total_committed_bytes"},
{heap->new_space()->Size(), "new_space_live_bytes"},
{heap->new_space()->Available(), "new_space_available_bytes"},
{heap->new_space()->CommittedMemory(), "new_space_commited_bytes"},
{new_space_size, "new_space_live_bytes"},
{new_space_available, "new_space_available_bytes"},
{new_space_committed_memory, "new_space_commited_bytes"},
{heap->old_space()->Size(), "old_space_live_bytes"},
{heap->old_space()->Available(), "old_space_available_bytes"},
{heap->old_space()->CommittedMemory(), "old_space_commited_bytes"},