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

[heap] Remove sweeping complexity around page iterability.

Change-Id: I60fdb6af5382e0ccd6bff16f89aad804c13cd900
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1943147Reviewed-by: 's avatarUlan Degenbaev <ulan@chromium.org>
Commit-Queue: Hannes Payer <hpayer@chromium.org>
Cr-Commit-Position: refs/heads/master@{#65267}
parent 88f8d801
...@@ -55,7 +55,9 @@ PagedSpaceObjectIterator::PagedSpaceObjectIterator(Heap* heap, ...@@ -55,7 +55,9 @@ PagedSpaceObjectIterator::PagedSpaceObjectIterator(Heap* heap,
heap_(heap), heap_(heap),
space_(space), space_(space),
page_range_(space->first_page(), nullptr), page_range_(space->first_page(), nullptr),
current_page_(page_range_.begin()) {} current_page_(page_range_.begin()) {
heap_->mark_compact_collector()->EnsureSweepingCompleted();
}
PagedSpaceObjectIterator::PagedSpaceObjectIterator(Heap* heap, PagedSpaceObjectIterator::PagedSpaceObjectIterator(Heap* heap,
PagedSpace* space, PagedSpace* space,
...@@ -66,6 +68,7 @@ PagedSpaceObjectIterator::PagedSpaceObjectIterator(Heap* heap, ...@@ -66,6 +68,7 @@ PagedSpaceObjectIterator::PagedSpaceObjectIterator(Heap* heap,
space_(space), space_(space),
page_range_(page), page_range_(page),
current_page_(page_range_.begin()) { current_page_(page_range_.begin()) {
heap_->mark_compact_collector()->EnsureSweepingCompleted();
#ifdef DEBUG #ifdef DEBUG
AllocationSpace owner = page->owner_identity(); AllocationSpace owner = page->owner_identity();
DCHECK(owner == RO_SPACE || owner == OLD_SPACE || owner == MAP_SPACE || DCHECK(owner == RO_SPACE || owner == OLD_SPACE || owner == MAP_SPACE ||
...@@ -80,17 +83,6 @@ bool PagedSpaceObjectIterator::AdvanceToNextPage() { ...@@ -80,17 +83,6 @@ bool PagedSpaceObjectIterator::AdvanceToNextPage() {
if (current_page_ == page_range_.end()) return false; if (current_page_ == page_range_.end()) return false;
Page* cur_page = *(current_page_++); Page* cur_page = *(current_page_++);
#ifdef ENABLE_MINOR_MC
heap_->mark_compact_collector()->sweeper()->EnsurePageIsIterable(cur_page);
if (cur_page->IsFlagSet(Page::SWEEP_TO_ITERATE)) {
heap_->minor_mark_compact_collector()->MakeIterable(
cur_page, MarkingTreatmentMode::CLEAR,
FreeSpaceTreatmentMode::IGNORE_FREE_SPACE);
}
#else
DCHECK(!cur_page->IsFlagSet(Page::SWEEP_TO_ITERATE));
#endif // ENABLE_MINOR_MC
cur_addr_ = cur_page->area_start(); cur_addr_ = cur_page->area_start();
cur_end_ = cur_page->area_end(); cur_end_ = cur_page->area_end();
DCHECK(cur_page->SweepingDone()); DCHECK(cur_page->SweepingDone());
......
...@@ -1052,15 +1052,6 @@ class Page : public MemoryChunk { ...@@ -1052,15 +1052,6 @@ class Page : public MemoryChunk {
return address_in_page; return address_in_page;
} }
// WaitUntilSweepingCompleted only works when concurrent sweeping is in
// progress. In particular, when we know that right before this call a
// sweeper thread was sweeping this page.
void WaitUntilSweepingCompleted() {
mutex_->Lock();
mutex_->Unlock();
DCHECK(SweepingDone());
}
void AllocateLocalTracker(); void AllocateLocalTracker();
inline LocalArrayBufferTracker* local_tracker() { return local_tracker_; } inline LocalArrayBufferTracker* local_tracker() { return local_tracker_; }
bool contains_array_buffers(); bool contains_array_buffers();
......
...@@ -191,18 +191,6 @@ void Sweeper::StartSweeperTasks() { ...@@ -191,18 +191,6 @@ void Sweeper::StartSweeperTasks() {
} }
} }
void Sweeper::SweepOrWaitUntilSweepingCompleted(Page* page) {
if (!page->SweepingDone()) {
ParallelSweepPage(page, page->owner_identity());
if (!page->SweepingDone()) {
// We were not able to sweep that page, i.e., a concurrent
// sweeper thread currently owns this page. Wait for the sweeper
// thread to be done with this page.
page->WaitUntilSweepingCompleted();
}
}
}
Page* Sweeper::GetSweptPageSafe(PagedSpace* space) { Page* Sweeper::GetSweptPageSafe(PagedSpace* space) {
base::MutexGuard guard(&mutex_); base::MutexGuard guard(&mutex_);
SweptList& list = swept_list_[GetSweepSpaceIndex(space->identity())]; SweptList& list = swept_list_[GetSweepSpaceIndex(space->identity())];
...@@ -453,17 +441,15 @@ int Sweeper::ParallelSweepSpace( ...@@ -453,17 +441,15 @@ int Sweeper::ParallelSweepSpace(
int Sweeper::ParallelSweepPage( int Sweeper::ParallelSweepPage(
Page* page, AllocationSpace identity, Page* page, AllocationSpace identity,
FreeSpaceMayContainInvalidatedSlots invalidated_slots_in_free_space) { FreeSpaceMayContainInvalidatedSlots invalidated_slots_in_free_space) {
// Early bailout for pages that are swept outside of the regular sweeping DCHECK(IsValidSweepingSpace(identity));
// path. This check here avoids taking the lock first, avoiding deadlocks.
// The Scavenger may add already swept pages back.
if (page->SweepingDone()) return 0; if (page->SweepingDone()) return 0;
DCHECK(IsValidSweepingSpace(identity));
int max_freed = 0; int max_freed = 0;
{ {
base::MutexGuard guard(page->mutex()); base::MutexGuard guard(page->mutex());
// If this page was already swept in the meantime, we can return here. DCHECK(!page->SweepingDone());
if (page->SweepingDone()) return 0;
// If the page is a code page, the CodePageMemoryModificationScope changes // If the page is a code page, the CodePageMemoryModificationScope changes
// the page protection mode from rx -> rw while sweeping. // the page protection mode from rx -> rw while sweeping.
CodePageMemoryModificationScope code_page_scope(page); CodePageMemoryModificationScope code_page_scope(page);
...@@ -542,16 +528,6 @@ Page* Sweeper::GetSweepingPageSafe(AllocationSpace space) { ...@@ -542,16 +528,6 @@ Page* Sweeper::GetSweepingPageSafe(AllocationSpace space) {
return page; return page;
} }
void Sweeper::EnsurePageIsIterable(Page* page) {
AllocationSpace space = page->owner_identity();
if (IsValidSweepingSpace(space)) {
SweepOrWaitUntilSweepingCompleted(page);
} else {
DCHECK(IsValidIterabilitySpace(space));
EnsureIterabilityCompleted();
}
}
void Sweeper::EnsureIterabilityCompleted() { void Sweeper::EnsureIterabilityCompleted() {
if (!iterability_in_progress_) return; if (!iterability_in_progress_) return;
......
...@@ -105,8 +105,6 @@ class Sweeper { ...@@ -105,8 +105,6 @@ class Sweeper {
Page* GetSweptPageSafe(PagedSpace* space); Page* GetSweptPageSafe(PagedSpace* space);
void EnsurePageIsIterable(Page* page);
void AddPageForIterability(Page* page); void AddPageForIterability(Page* page);
void StartIterabilityTasks(); void StartIterabilityTasks();
void EnsureIterabilityCompleted(); void EnsureIterabilityCompleted();
...@@ -149,8 +147,6 @@ class Sweeper { ...@@ -149,8 +147,6 @@ class Sweeper {
void PrepareToBeSweptPage(AllocationSpace space, Page* page); void PrepareToBeSweptPage(AllocationSpace space, Page* page);
void SweepOrWaitUntilSweepingCompleted(Page* page);
void MakeIterable(Page* page); void MakeIterable(Page* page);
bool IsValidIterabilitySpace(AllocationSpace space) { bool IsValidIterabilitySpace(AllocationSpace space) {
......
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