Commit e5c3dd59 authored by Dominik Inführ's avatar Dominik Inführ Committed by Commit Bot

[heap] Finish sweeping in safepoint

Refactor Heap::FinalizeSweeping such that EnsureSweepingCompleted
is executed in a safepoint.

Bug: v8:10315
Change-Id: Iee09765ba5fd35e3e696b018bd616954d609ef72
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2204098Reviewed-by: 's avatarUlan Degenbaev <ulan@chromium.org>
Commit-Queue: Dominik Inführ <dinfuehr@chromium.org>
Cr-Commit-Position: refs/heads/master@{#67827}
parent b5aa78d0
......@@ -958,24 +958,21 @@ StepResult IncrementalMarking::AdvanceWithDeadline(
void IncrementalMarking::FinalizeSweeping() {
DCHECK(state_ == SWEEPING);
#ifdef DEBUG
// Enforce safepoint here such that background threads cannot allocate between
// completing sweeping and VerifyCountersAfterSweeping().
if (ContinueConcurrentSweeping()) return;
SafepointScope scope(heap());
#endif
if (collector_->sweeping_in_progress() &&
(!FLAG_concurrent_sweeping ||
!collector_->sweeper()->AreSweeperTasksRunning())) {
collector_->EnsureSweepingCompleted();
}
if (!collector_->sweeping_in_progress()) {
collector_->EnsureSweepingCompleted();
DCHECK(!collector_->sweeping_in_progress());
#ifdef DEBUG
heap_->VerifyCountersAfterSweeping();
#else
SafepointScope scope(heap());
heap_->VerifyCountersAfterSweeping();
#endif
StartMarking();
}
StartMarking();
}
bool IncrementalMarking::ContinueConcurrentSweeping() {
if (!collector_->sweeping_in_progress()) return false;
return FLAG_concurrent_sweeping &&
collector_->sweeper()->AreSweeperTasksRunning();
}
size_t IncrementalMarking::StepSizeToKeepUpWithAllocations() {
......
......@@ -168,6 +168,7 @@ class V8_EXPORT_PRIVATE IncrementalMarking final {
StepOrigin step_origin);
void FinalizeSweeping();
bool ContinueConcurrentSweeping();
StepResult Step(double max_step_size_in_ms, CompletionAction action,
StepOrigin step_origin);
......
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