[heap] Support concurrent sweepers from main thread

With --stress-incremental-marking we want to start concurrent marking
faster by also sweeping pages on incremental marking steps.

Bug: v8:10315
Change-Id: Ie3fa04acc5e59a4b81c3351f4b522c78368bb1a6
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2210247
Commit-Queue: Dominik Inführ <dinfuehr@chromium.org>
Reviewed-by: Ulan Degenbaev <ulan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#67968}
This commit is contained in:
Dominik Inführ 2020-05-26 14:42:58 +02:00 committed by Commit Bot
parent cf19f5f4e1
commit 008c5a6a79
4 changed files with 23 additions and 1 deletions

View File

@ -989,7 +989,14 @@ StepResult IncrementalMarking::AdvanceWithDeadline(
void IncrementalMarking::FinalizeSweeping() {
DCHECK(state_ == SWEEPING);
if (ContinueConcurrentSweeping()) return;
if (ContinueConcurrentSweeping()) {
if (FLAG_stress_incremental_marking) {
// To start concurrent marking a bit earlier, support concurrent sweepers
// from main thread by sweeping some pages.
SupportConcurrentSweeping();
}
return;
}
SafepointScope scope(heap());
collector_->EnsureSweepingCompleted();
@ -1006,6 +1013,10 @@ bool IncrementalMarking::ContinueConcurrentSweeping() {
collector_->sweeper()->AreSweeperTasksRunning();
}
void IncrementalMarking::SupportConcurrentSweeping() {
collector_->sweeper()->SupportConcurrentSweeping();
}
size_t IncrementalMarking::StepSizeToKeepUpWithAllocations() {
// Update bytes_allocated_ based on the allocation counter.
size_t current_counter = heap_->OldGenerationAllocationCounter();

View File

@ -170,6 +170,7 @@ class V8_EXPORT_PRIVATE IncrementalMarking final {
void FinalizeSweeping();
bool ContinueConcurrentSweeping();
void SupportConcurrentSweeping();
StepResult Step(double max_step_size_in_ms, CompletionAction action,
StepOrigin step_origin);

View File

@ -246,6 +246,13 @@ void Sweeper::EnsureCompleted() {
sweeping_in_progress_ = false;
}
void Sweeper::SupportConcurrentSweeping() {
ForAllSweepingSpaces([this](AllocationSpace space) {
const int kMaxPagesToSweepPerSpace = 1;
ParallelSweepSpace(space, 0, kMaxPagesToSweepPerSpace);
});
}
bool Sweeper::AreSweeperTasksRunning() { return num_sweeping_tasks_ != 0; }
V8_INLINE size_t Sweeper::FreeAndProcessFreedMemory(

View File

@ -108,6 +108,9 @@ class Sweeper {
void EnsureCompleted();
bool AreSweeperTasksRunning();
// Support concurrent sweepers from main thread
void SupportConcurrentSweeping();
Page* GetSweptPageSafe(PagedSpace* space);
void AddPageForIterability(Page* page);