Commit 14331ec5 authored by Anton Bikineev's avatar Anton Bikineev Committed by V8 LUCI CQ

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/+/3472500Reviewed-by: 's avatarMichael Lippautz <mlippautz@chromium.org>
Commit-Queue: Anton Bikineev <bikineev@chromium.org>
Cr-Commit-Position: refs/heads/main@{#79440}
parent b2425ff8
......@@ -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();
......
......@@ -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;
......
......@@ -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
......
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