diff options
Diffstat (limited to 'deps/v8/src/heap/cppgc/heap-page.cc')
-rw-r--r-- | deps/v8/src/heap/cppgc/heap-page.cc | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/deps/v8/src/heap/cppgc/heap-page.cc b/deps/v8/src/heap/cppgc/heap-page.cc index b2b3d83182..d573d675ee 100644 --- a/deps/v8/src/heap/cppgc/heap-page.cc +++ b/deps/v8/src/heap/cppgc/heap-page.cc @@ -15,6 +15,7 @@ #include "src/heap/cppgc/object-start-bitmap.h" #include "src/heap/cppgc/page-memory.h" #include "src/heap/cppgc/raw-heap.h" +#include "src/heap/cppgc/stats-collector.h" namespace cppgc { namespace internal { @@ -113,6 +114,7 @@ NormalPage* NormalPage::Create(PageBackend* page_backend, void* memory = page_backend->AllocateNormalPageMemory(space->index()); auto* normal_page = new (memory) NormalPage(space->raw_heap()->heap(), space); normal_page->SynchronizedStore(); + normal_page->heap()->stats_collector()->NotifyAllocatedMemory(kPageSize); return normal_page; } @@ -123,6 +125,7 @@ void NormalPage::Destroy(NormalPage* page) { DCHECK_EQ(space->end(), std::find(space->begin(), space->end(), page)); page->~NormalPage(); PageBackend* backend = page->heap()->page_backend(); + page->heap()->stats_collector()->NotifyFreedMemory(kPageSize); backend->FreeNormalPageMemory(space->index(), reinterpret_cast<Address>(page)); } @@ -177,20 +180,26 @@ LargePage::LargePage(HeapBase* heap, BaseSpace* space, size_t size) LargePage::~LargePage() = default; // static +size_t LargePage::AllocationSize(size_t payload_size) { + const size_t page_header_size = + RoundUp(sizeof(LargePage), kAllocationGranularity); + return page_header_size + payload_size; +} + +// static LargePage* LargePage::Create(PageBackend* page_backend, LargePageSpace* space, size_t size) { DCHECK_NOT_NULL(page_backend); DCHECK_NOT_NULL(space); DCHECK_LE(kLargeObjectSizeThreshold, size); - const size_t page_header_size = - RoundUp(sizeof(LargePage), kAllocationGranularity); - const size_t allocation_size = page_header_size + size; + const size_t allocation_size = AllocationSize(size); auto* heap = space->raw_heap()->heap(); void* memory = page_backend->AllocateLargePageMemory(allocation_size); LargePage* page = new (memory) LargePage(heap, space, size); page->SynchronizedStore(); + page->heap()->stats_collector()->NotifyAllocatedMemory(allocation_size); return page; } @@ -203,6 +212,8 @@ void LargePage::Destroy(LargePage* page) { #endif page->~LargePage(); PageBackend* backend = page->heap()->page_backend(); + page->heap()->stats_collector()->NotifyFreedMemory( + AllocationSize(page->PayloadSize())); backend->FreeLargePageMemory(reinterpret_cast<Address>(page)); } |