Commit f5124b42 authored by Hannes Payer's avatar Hannes Payer Committed by Commit Bot

[heap] Clear wasted_memory_ counter right before sweeping a page.

Bug: v8:9093
Change-Id: I1172f7de24683aea05648f5c6fe1ab3d0dad6655
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1585724
Auto-Submit: Hannes Payer <hpayer@chromium.org>
Commit-Queue: Hannes Payer <hpayer@chromium.org>
Commit-Queue: Michael Lippautz <mlippautz@chromium.org>
Reviewed-by: 's avatarMichael Lippautz <mlippautz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#61033}
parent 47b325db
......@@ -697,7 +697,7 @@ Page* PagedSpace::InitializePage(MemoryChunk* chunk, Executability executable) {
page->owner()->identity()),
page->area_size());
// Make sure that categories are initialized before freeing the area.
page->ResetAllocatedBytes();
page->ResetAllocationStatistics();
page->SetOldGenerationPageFlags(heap()->incremental_marking()->IsMarking());
page->AllocateFreeListCategories();
page->InitializeFreeListCategories();
......@@ -947,7 +947,10 @@ void MemoryChunk::SetYoungGenerationPageFlags(bool is_marking) {
}
}
void Page::ResetAllocatedBytes() { allocated_bytes_ = area_size(); }
void Page::ResetAllocationStatistics() {
allocated_bytes_ = area_size();
wasted_memory_ = 0;
}
void Page::AllocateLocalTracker() {
DCHECK_NULL(local_tracker_);
......@@ -958,10 +961,6 @@ bool Page::contains_array_buffers() {
return local_tracker_ != nullptr && !local_tracker_->IsEmpty();
}
void Page::ResetFreeListStatistics() {
wasted_memory_ = 0;
}
size_t Page::AvailableInFreeList() {
size_t sum = 0;
ForAllFreeListCategories([&sum](FreeListCategory* category) {
......@@ -1740,13 +1739,6 @@ int PagedSpace::CountTotalPages() {
return count;
}
void PagedSpace::ResetFreeListStatistics() {
for (Page* page : *this) {
page->ResetFreeListStatistics();
}
}
void PagedSpace::SetLinearAllocationArea(Address top, Address limit) {
SetTopAndLimit(top, limit);
if (top != kNullAddress && top != limit &&
......
......@@ -883,8 +883,6 @@ class Page : public MemoryChunk {
inline LocalArrayBufferTracker* local_tracker() { return local_tracker_; }
bool contains_array_buffers();
void ResetFreeListStatistics();
size_t AvailableInFreeList();
size_t AvailableInFreeListFromAllocatedBytes() {
......@@ -909,7 +907,7 @@ class Page : public MemoryChunk {
allocated_bytes_ -= bytes;
}
void ResetAllocatedBytes();
void ResetAllocationStatistics();
size_t ShrinkToHighWaterMark();
......@@ -2146,8 +2144,6 @@ class V8_EXPORT_PRIVATE PagedSpace
// Approximate amount of physical memory committed for this space.
size_t CommittedPhysicalMemory() override;
void ResetFreeListStatistics();
// Sets the capacity, the available space and the wasted space to zero.
// The stats are rebuilt during sweeping by adding each page to the
// capacity and the size when it is encountered. As free spaces are
......@@ -2156,7 +2152,6 @@ class V8_EXPORT_PRIVATE PagedSpace
void ClearStats() {
accounting_stats_.ClearSize();
free_list_.ResetStats();
ResetFreeListStatistics();
}
// Available bytes without growing. These are the bytes on the free list.
......
......@@ -279,9 +279,10 @@ int Sweeper::RawSweep(Page* p, FreeListRebuildingMode free_list_mode,
intptr_t max_freed_bytes = 0;
int curr_region = -1;
// Set the allocated_bytes counter to area_size. The free operations below
// will decrease the counter to actual live bytes.
p->ResetAllocatedBytes();
// Set the allocated_bytes_ counter to area_size and clear the wasted_memory_
// counter. The free operations below will decrease allocated_bytes_ to actual
// live bytes and keep track of wasted_memory_.
p->ResetAllocationStatistics();
for (auto object_and_size :
LiveObjectRange<kBlackObjects>(p, marking_state_->bitmap(p))) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment