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

[heap] Finish sweeping without refilling free lists on shutdown

Help sweeper tasks complete sweeping sooner but do not refill free
lists on shutdown.

This races with allocating background threads. Background threads will
refill free lists themselves if more memory is required.

Bug: v8:10315
Change-Id: Ie615983229701e8c9434b4352bd055e9dbbb8671
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2297466Reviewed-by: 's avatarJakob Gruber <jgruber@chromium.org>
Reviewed-by: 's avatarUlan Degenbaev <ulan@chromium.org>
Commit-Queue: Dominik Inführ <dinfuehr@chromium.org>
Cr-Commit-Position: refs/heads/master@{#68842}
parent 12d04ed2
......@@ -2955,7 +2955,10 @@ void Isolate::Deinit() {
BackingStore::RemoveSharedWasmMemoryObjects(this);
heap_.mark_compact_collector()->EnsureSweepingCompleted();
// 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();
......
......@@ -622,6 +622,11 @@ void MarkCompactCollector::EnsureSweepingCompleted() {
#endif
}
void MarkCompactCollector::DrainSweepingWorklists() {
if (!sweeper()->sweeping_in_progress()) return;
sweeper()->DrainSweepingWorklists();
}
void MarkCompactCollector::DrainSweepingWorklistForSpace(
AllocationSpace space) {
if (!sweeper()->sweeping_in_progress()) return;
......
......@@ -516,6 +516,8 @@ class MarkCompactCollector final : public MarkCompactCollectorBase {
//
// Note: Can only be called safely from main thread.
V8_EXPORT_PRIVATE void EnsureSweepingCompleted();
void DrainSweepingWorklists();
void DrainSweepingWorklistForSpace(AllocationSpace space);
// Checks if sweeping is in progress right now on any space.
......
......@@ -247,6 +247,13 @@ 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);
......
......@@ -106,6 +106,7 @@ 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