Commit 8e32d8f3 authored by Dominik Inführ's avatar Dominik Inführ Committed by V8 LUCI CQ

[heap] Stop concurrent marking tasks in Heap::StartTearDown

Concurrent marking jobs were only joined in Heap::TearDown and
therefore may still update counters while DumpAndResetStats() emits
stats.

This CL stops concurrent marking tasks in Heap::StartTearDown when
also stopping other concurrent tasks like sweeping or unmapping of
pages.

Bug: v8:13175, v8:12775
Change-Id: Iccddbfce5e30002e0db63ba0bdea5ea6b2d5cc40
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3827869Reviewed-by: 's avatarMichael Lippautz <mlippautz@chromium.org>
Reviewed-by: 's avatarIgor Sheludko <ishell@chromium.org>
Commit-Queue: Dominik Inführ <dinfuehr@chromium.org>
Cr-Commit-Position: refs/heads/main@{#82849}
parent 911c7170
...@@ -3592,7 +3592,6 @@ void Isolate::Deinit() { ...@@ -3592,7 +3592,6 @@ void Isolate::Deinit() {
// not cause a GC. // not cause a GC.
heap_.StartTearDown(); heap_.StartTearDown();
// This stops cancelable tasks (i.e. concurrent marking tasks).
// Stop concurrent tasks before destroying resources since they might still // Stop concurrent tasks before destroying resources since they might still
// use those. // use those.
{ {
......
...@@ -5690,6 +5690,10 @@ void Heap::StartTearDown() { ...@@ -5690,6 +5690,10 @@ void Heap::StartTearDown() {
memory_allocator()->unmapper()->EnsureUnmappingCompleted(); memory_allocator()->unmapper()->EnsureUnmappingCompleted();
if (FLAG_concurrent_marking) {
concurrent_marking()->Pause();
}
SetGCState(TEAR_DOWN); SetGCState(TEAR_DOWN);
// Background threads may allocate and block until GC is performed. However // Background threads may allocate and block until GC is performed. However
...@@ -5730,8 +5734,7 @@ void Heap::TearDown() { ...@@ -5730,8 +5734,7 @@ void Heap::TearDown() {
safepoint()->AssertMainThreadIsOnlyThread(); safepoint()->AssertMainThreadIsOnlyThread();
DCHECK(main_thread_local_heap()->unprotected_memory_chunks_.empty()); DCHECK(main_thread_local_heap()->unprotected_memory_chunks_.empty());
if (FLAG_concurrent_marking || FLAG_parallel_marking) DCHECK(concurrent_marking()->IsStopped());
concurrent_marking_->Pause();
// It's too late for Heap::Verify() here, as parts of the Isolate are // It's too late for Heap::Verify() here, as parts of the Isolate are
// already gone by the time this is called. // already gone by the time this is called.
......
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