[heap] Make ConcurrentSweepingState an enum class.
Change-Id: I5d98dac3cde530f2bac5ef1239bc0e8805a01f99 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1942609 Commit-Queue: Hannes Payer <hpayer@chromium.org> Reviewed-by: Ulan Degenbaev <ulan@chromium.org> Cr-Commit-Position: refs/heads/master@{#65249}
This commit is contained in:
parent
b26968ec43
commit
1253141ebc
@ -702,7 +702,7 @@ MemoryChunk* MemoryChunk::Initialize(Heap* heap, Address base, size_t size,
|
||||
chunk->invalidated_slots_[OLD_TO_OLD] = nullptr;
|
||||
chunk->progress_bar_ = 0;
|
||||
chunk->high_water_mark_ = static_cast<intptr_t>(area_start - base);
|
||||
chunk->set_concurrent_sweeping_state(kSweepingDone);
|
||||
chunk->set_concurrent_sweeping_state(ConcurrentSweepingState::kDone);
|
||||
chunk->page_protection_change_mutex_ = new base::Mutex();
|
||||
chunk->write_unprotect_counter_ = 0;
|
||||
chunk->mutex_ = new base::Mutex();
|
||||
|
@ -585,15 +585,15 @@ class MemoryChunk : public BasicMemoryChunk {
|
||||
static const Flags kSkipEvacuationSlotsRecordingMask =
|
||||
kEvacuationCandidateMask | kIsInYoungGenerationMask;
|
||||
|
||||
// |kSweepingDone|: The page state when sweeping is complete or sweeping must
|
||||
// not be performed on that page. Sweeper threads that are done with their
|
||||
// work will set this value and not touch the page anymore.
|
||||
// |kSweepingPending|: This page is ready for parallel sweeping.
|
||||
// |kSweepingInProgress|: This page is currently swept by a sweeper thread.
|
||||
enum ConcurrentSweepingState {
|
||||
kSweepingDone,
|
||||
kSweepingPending,
|
||||
kSweepingInProgress,
|
||||
// |kDone|: The page state when sweeping is complete or sweeping must not be
|
||||
// performed on that page. Sweeper threads that are done with their work
|
||||
// will set this value and not touch the page anymore.
|
||||
// |kPending|: This page is ready for parallel sweeping.
|
||||
// |kInProgress|: This page is currently swept by a sweeper thread.
|
||||
enum class ConcurrentSweepingState : intptr_t {
|
||||
kDone,
|
||||
kPending,
|
||||
kInProgress,
|
||||
};
|
||||
|
||||
static const size_t kHeaderSize =
|
||||
@ -673,7 +673,9 @@ class MemoryChunk : public BasicMemoryChunk {
|
||||
return static_cast<ConcurrentSweepingState>(concurrent_sweeping_.load());
|
||||
}
|
||||
|
||||
bool SweepingDone() { return concurrent_sweeping_ == kSweepingDone; }
|
||||
bool SweepingDone() {
|
||||
return concurrent_sweeping_ == ConcurrentSweepingState::kDone;
|
||||
}
|
||||
|
||||
inline Heap* heap() const {
|
||||
DCHECK_NOT_NULL(heap_);
|
||||
@ -925,7 +927,7 @@ class MemoryChunk : public BasicMemoryChunk {
|
||||
|
||||
base::Mutex* mutex_;
|
||||
|
||||
std::atomic<intptr_t> concurrent_sweeping_;
|
||||
std::atomic<ConcurrentSweepingState> concurrent_sweeping_;
|
||||
|
||||
base::Mutex* page_protection_change_mutex_;
|
||||
|
||||
|
@ -400,7 +400,7 @@ int Sweeper::RawSweep(
|
||||
// The allocated_bytes() counter is precisely the total size of objects.
|
||||
DCHECK_EQ(live_bytes, p->allocated_bytes());
|
||||
}
|
||||
p->set_concurrent_sweeping_state(Page::kSweepingDone);
|
||||
p->set_concurrent_sweeping_state(Page::ConcurrentSweepingState::kDone);
|
||||
if (code_object_registry) code_object_registry->Finalize();
|
||||
if (free_list_mode == IGNORE_FREE_LIST) return 0;
|
||||
|
||||
@ -468,8 +468,10 @@ int Sweeper::ParallelSweepPage(
|
||||
// the page protection mode from rx -> rw while sweeping.
|
||||
CodePageMemoryModificationScope code_page_scope(page);
|
||||
|
||||
DCHECK_EQ(Page::kSweepingPending, page->concurrent_sweeping_state());
|
||||
page->set_concurrent_sweeping_state(Page::kSweepingInProgress);
|
||||
DCHECK_EQ(Page::ConcurrentSweepingState::kPending,
|
||||
page->concurrent_sweeping_state());
|
||||
page->set_concurrent_sweeping_state(
|
||||
Page::ConcurrentSweepingState::kInProgress);
|
||||
const FreeSpaceTreatmentMode free_space_mode =
|
||||
Heap::ShouldZapGarbage() ? ZAP_FREE_SPACE : IGNORE_FREE_SPACE;
|
||||
max_freed = RawSweep(page, REBUILD_FREE_LIST, free_space_mode,
|
||||
@ -507,7 +509,8 @@ void Sweeper::AddPage(AllocationSpace space, Page* page,
|
||||
// happened when the page was initially added, so it is skipped here.
|
||||
DCHECK_EQ(Sweeper::READD_TEMPORARY_REMOVED_PAGE, mode);
|
||||
}
|
||||
DCHECK_EQ(Page::kSweepingPending, page->concurrent_sweeping_state());
|
||||
DCHECK_EQ(Page::ConcurrentSweepingState::kPending,
|
||||
page->concurrent_sweeping_state());
|
||||
sweeping_list_[GetSweepSpaceIndex(space)].push_back(page);
|
||||
}
|
||||
|
||||
@ -515,13 +518,14 @@ void Sweeper::PrepareToBeSweptPage(AllocationSpace space, Page* page) {
|
||||
#ifdef DEBUG
|
||||
DCHECK_GE(page->area_size(),
|
||||
static_cast<size_t>(marking_state_->live_bytes(page)));
|
||||
DCHECK_EQ(Page::kSweepingDone, page->concurrent_sweeping_state());
|
||||
DCHECK_EQ(Page::ConcurrentSweepingState::kDone,
|
||||
page->concurrent_sweeping_state());
|
||||
page->ForAllFreeListCategories([page](FreeListCategory* category) {
|
||||
DCHECK(!category->is_linked(page->owner()->free_list()));
|
||||
});
|
||||
#endif // DEBUG
|
||||
page->MoveOldToNewRememberedSetForSweeping();
|
||||
page->set_concurrent_sweeping_state(Page::kSweepingPending);
|
||||
page->set_concurrent_sweeping_state(Page::ConcurrentSweepingState::kPending);
|
||||
heap_->paged_space(space)->IncreaseAllocatedBytes(
|
||||
marking_state_->live_bytes(page), page);
|
||||
}
|
||||
@ -613,10 +617,11 @@ void Sweeper::AddPageForIterability(Page* page) {
|
||||
DCHECK(iterability_in_progress_);
|
||||
DCHECK(!iterability_task_started_);
|
||||
DCHECK(IsValidIterabilitySpace(page->owner_identity()));
|
||||
DCHECK_EQ(Page::kSweepingDone, page->concurrent_sweeping_state());
|
||||
DCHECK_EQ(Page::ConcurrentSweepingState::kDone,
|
||||
page->concurrent_sweeping_state());
|
||||
|
||||
iterability_list_.push_back(page);
|
||||
page->set_concurrent_sweeping_state(Page::kSweepingPending);
|
||||
page->set_concurrent_sweeping_state(Page::ConcurrentSweepingState::kPending);
|
||||
}
|
||||
|
||||
void Sweeper::MakeIterable(Page* page) {
|
||||
|
Loading…
Reference in New Issue
Block a user