diff --git a/deps/v8/src/heap/heap.cc b/deps/v8/src/heap/heap.cc index 0b5a90afb08b1c..9f29717803a0ab 100644 --- a/deps/v8/src/heap/heap.cc +++ b/deps/v8/src/heap/heap.cc @@ -1885,6 +1885,12 @@ void Heap::Scavenge() { IncrementalMarking::PauseBlackAllocationScope pause_black_allocation( incremental_marking()); + if (mark_compact_collector()->sweeper().sweeping_in_progress() && + memory_allocator_->unmapper()->NumberOfDelayedChunks() > + kMaxSemiSpaceSizeInKB / Page::kPageSize) { + mark_compact_collector()->EnsureSweepingCompleted(); + } + mark_compact_collector()->sweeper().EnsureNewSpaceCompleted(); SetGCState(SCAVENGE); diff --git a/deps/v8/src/heap/spaces.h b/deps/v8/src/heap/spaces.h index d5dc5b1115cccb..230a127809a697 100644 --- a/deps/v8/src/heap/spaces.h +++ b/deps/v8/src/heap/spaces.h @@ -1199,6 +1199,11 @@ class V8_EXPORT_PRIVATE MemoryAllocator { bool has_delayed_chunks() { return delayed_regular_chunks_.size() > 0; } + int NumberOfDelayedChunks() { + base::LockGuard guard(&mutex_); + return static_cast(delayed_regular_chunks_.size()); + } + private: static const int kReservedQueueingSlots = 64; static const int kMaxUnmapperTasks = 24;