cppgc: young-gen: Schedule Minor GCs

The CL runs Oilpan minor GCs after each Scavenger cycle.

Bug: chromium:1029379
Change-Id: Ic67cf4dc9158759207f0209640f1720bf188cc1d
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3472500
Reviewed-by: Michael Lippautz <mlippautz@chromium.org>
Commit-Queue: Anton Bikineev <bikineev@chromium.org>
Cr-Commit-Position: refs/heads/main@{#79440}
This commit is contained in:
Anton Bikineev 2022-02-25 15:42:53 +01:00 committed by V8 LUCI CQ
parent b2425ff8ad
commit 14331ec537
3 changed files with 28 additions and 0 deletions

View File

@ -642,6 +642,28 @@ void CppHeap::TraceEpilogue() {
sweeper().NotifyDoneIfNeeded();
}
void CppHeap::RunMinorGC() {
#if defined(CPPGC_YOUNG_GENERATION)
if (in_no_gc_scope()) return;
// Minor GC does not support nesting in full GCs.
if (IsMarking()) return;
// Finish sweeping in case it is still running.
sweeper().FinishIfRunning();
SetStackEndOfCurrentGC(v8::base::Stack::GetCurrentStackPosition());
// Perform an atomic GC, with starting incremental/concurrent marking and
// immediately finalizing the garbage collection.
InitializeTracing(
cppgc::internal::GarbageCollector::Config::CollectionType::kMinor,
GarbageCollectionFlagValues::kForced);
StartTracing();
EnterFinalPause(cppgc::EmbedderStackState::kMayContainHeapPointers);
AdvanceTracing(std::numeric_limits<double>::infinity());
TraceEpilogue();
#endif // defined(CPPGC_YOUNG_GENERATION)
}
void CppHeap::AllocatedObjectSizeIncreased(size_t bytes) {
buffered_allocated_bytes_ += static_cast<int64_t>(bytes);
ReportBufferedAllocationSizeIfPossible();

View File

@ -129,6 +129,8 @@ class V8_EXPORT_PRIVATE CppHeap final
void TraceEpilogue();
void EnterFinalPause(cppgc::EmbedderStackState stack_state);
void RunMinorGC();
// StatsCollector::AllocationObserver interface.
void AllocatedObjectSizeIncreased(size_t) final;
void AllocatedObjectSizeDecreased(size_t) final;

View File

@ -2327,6 +2327,10 @@ size_t Heap::PerformGarbageCollection(
local_embedder_heap_tracer()->TraceEpilogue();
}
if (collector == GarbageCollector::SCAVENGER && cpp_heap()) {
CppHeap::From(cpp_heap())->RunMinorGC();
}
#ifdef VERIFY_HEAP
if (FLAG_verify_heap) {
// We don't really perform a GC here but need this scope for the nested