Commit c88de19f authored by Michael Lippautz's avatar Michael Lippautz Committed by V8 LUCI CQ

heap: Stop sweeper tasks during Isolate::Deinit

Avoid stray sweeper tasks still accessing heap after teardown has been
initiated. This reverts https://crrev.com/c/2297466 and restores the
invariant that no GC is running during teardown.

Bug: v8:12025
Change-Id: I9974a63ef385783a9c3ec09725dce118f754b25f
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3081615Reviewed-by: 's avatarHannes Payer <hpayer@chromium.org>
Commit-Queue: Michael Lippautz <mlippautz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#76219}
parent 6241b522
......@@ -3138,12 +3138,6 @@ void Isolate::Deinit() {
// All client isolates should already be detached.
DCHECK_NULL(client_isolate_head_);
// Help sweeper threads complete sweeping to stop faster.
heap_.mark_compact_collector()->DrainSweepingWorklists();
heap_.mark_compact_collector()->sweeper()->EnsureIterabilityCompleted();
heap_.memory_allocator()->unmapper()->EnsureUnmappingCompleted();
DumpAndResetStats();
if (FLAG_print_deopt_stress) {
......
......@@ -5866,6 +5866,12 @@ void Heap::RegisterExternallyReferencedObject(Address* location) {
}
void Heap::StartTearDown() {
// Finish any ongoing sweeping to avoid stray background tasks still accessing
// the heap during teardown.
CompleteSweepingFull();
memory_allocator()->unmapper()->EnsureUnmappingCompleted();
SetGCState(TEAR_DOWN);
// Background threads may allocate and block until GC is performed. However
......
......@@ -666,11 +666,6 @@ void MarkCompactCollector::EnsurePageIsSwept(Page* page) {
sweeper()->EnsurePageIsSwept(page);
}
void MarkCompactCollector::DrainSweepingWorklists() {
if (!sweeper()->sweeping_in_progress()) return;
sweeper()->DrainSweepingWorklists();
}
void MarkCompactCollector::DrainSweepingWorklistForSpace(
AllocationSpace space) {
if (!sweeper()->sweeping_in_progress()) return;
......
......@@ -515,7 +515,6 @@ class MarkCompactCollector final : public MarkCompactCollectorBase {
void EnsurePageIsSwept(Page* page);
void DrainSweepingWorklists();
void DrainSweepingWorklistForSpace(AllocationSpace space);
// Checks if sweeping is in progress right now on any space.
......
......@@ -227,13 +227,6 @@ void Sweeper::EnsureCompleted() {
sweeping_in_progress_ = false;
}
void Sweeper::DrainSweepingWorklists() {
if (!sweeping_in_progress_) return;
ForAllSweepingSpaces(
[this](AllocationSpace space) { DrainSweepingWorklistForSpace(space); });
}
void Sweeper::DrainSweepingWorklistForSpace(AllocationSpace space) {
if (!sweeping_in_progress_) return;
ParallelSweepSpace(space, 0);
......
......@@ -111,7 +111,6 @@ class Sweeper {
void StartSweeping();
V8_EXPORT_PRIVATE void StartSweeperTasks();
void EnsureCompleted();
void DrainSweepingWorklists();
void DrainSweepingWorklistForSpace(AllocationSpace space);
bool AreSweeperTasksRunning();
......
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