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

[heap] Do not use always_allocate() when starting tear down

Do not use the already existing always_allocate() method for allowing
all allocations after tear down was started. Use explicit checks
of gc_state() == TEAR_DOWN instead.

This ensures that background threads extend the heap beyond its limits
only when tearing down the isolate. always_allocate() is also used
during regular execution in C++ code.

Bug: v8:10315
Change-Id: I66b5bfb06fa854048f37305a5d0cb7d60fadb30f
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2390764
Commit-Queue: Dominik Inführ <dinfuehr@chromium.org>
Reviewed-by: 's avatarUlan Degenbaev <ulan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#69699}
parent d02ab0e1
...@@ -4920,6 +4920,10 @@ bool Heap::ShouldExpandOldGenerationOnSlowAllocation(LocalHeap* local_heap) { ...@@ -4920,6 +4920,10 @@ bool Heap::ShouldExpandOldGenerationOnSlowAllocation(LocalHeap* local_heap) {
if (always_allocate() || OldGenerationSpaceAvailable() > 0) return true; if (always_allocate() || OldGenerationSpaceAvailable() > 0) return true;
// We reached the old generation allocation limit. // We reached the old generation allocation limit.
// Background threads need to be allowed to allocate without GC after teardown
// was initiated.
if (gc_state() == TEAR_DOWN) return true;
// Ensure that retry of allocation on background thread succeeds // Ensure that retry of allocation on background thread succeeds
if (IsRetryOfFailedAllocation(local_heap)) return true; if (IsRetryOfFailedAllocation(local_heap)) return true;
...@@ -4944,11 +4948,6 @@ bool Heap::IsRetryOfFailedAllocation(LocalHeap* local_heap) { ...@@ -4944,11 +4948,6 @@ bool Heap::IsRetryOfFailedAllocation(LocalHeap* local_heap) {
return local_heap->allocation_failed_; return local_heap->allocation_failed_;
} }
void Heap::AlwaysAllocateAfterTearDownStarted() {
always_allocate_scope_count_++;
collection_barrier_.ShutdownRequested();
}
Heap::HeapGrowingMode Heap::CurrentHeapGrowingMode() { Heap::HeapGrowingMode Heap::CurrentHeapGrowingMode() {
if (ShouldReduceMemory() || FLAG_stress_compaction) { if (ShouldReduceMemory() || FLAG_stress_compaction) {
return Heap::HeapGrowingMode::kMinimal; return Heap::HeapGrowingMode::kMinimal;
...@@ -5507,7 +5506,7 @@ void Heap::StartTearDown() { ...@@ -5507,7 +5506,7 @@ void Heap::StartTearDown() {
// process the event queue anymore. Avoid this deadlock by allowing all // process the event queue anymore. Avoid this deadlock by allowing all
// allocations after tear down was requested to make sure all background // allocations after tear down was requested to make sure all background
// threads finish. // threads finish.
AlwaysAllocateAfterTearDownStarted(); collection_barrier_.ShutdownRequested();
#ifdef VERIFY_HEAP #ifdef VERIFY_HEAP
// {StartTearDown} is called fairly early during Isolate teardown, so it's // {StartTearDown} is called fairly early during Isolate teardown, so it's
......
...@@ -1903,8 +1903,6 @@ class Heap { ...@@ -1903,8 +1903,6 @@ class Heap {
LocalHeap* local_heap = nullptr); LocalHeap* local_heap = nullptr);
bool IsRetryOfFailedAllocation(LocalHeap* local_heap); bool IsRetryOfFailedAllocation(LocalHeap* local_heap);
void AlwaysAllocateAfterTearDownStarted();
HeapGrowingMode CurrentHeapGrowingMode(); HeapGrowingMode CurrentHeapGrowingMode();
double PercentToOldGenerationLimit(); double PercentToOldGenerationLimit();
......
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