Commit 408f5927 authored by Michael Lippautz's avatar Michael Lippautz Committed by V8 LUCI CQ

cppgc-js: Discard memory on low memory notification

Low memory notification is historically used by Chromium to request
forced GCs during benchmarking. These should be more aggressive than
the regular GCs and thus we should also discard on such forced GCs.

Bug: chromium:1056170
Change-Id: Ic503e1f440f2b941ae60646b5984fe473bf26410
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3021384
Auto-Submit: Michael Lippautz <mlippautz@chromium.org>
Commit-Queue: Omer Katz <omerkatz@chromium.org>
Reviewed-by: 's avatarOmer Katz <omerkatz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#75692}
parent 59bcba21
......@@ -361,6 +361,15 @@ void CppHeap::RegisterV8References(
marking_done_ = false;
}
namespace {
bool ShouldReduceMemory(CppHeap::TraceFlags flags) {
return (flags == CppHeap::TraceFlags::kReduceMemory) ||
(flags == CppHeap::TraceFlags::kForced);
}
} // namespace
void CppHeap::TracePrologue(TraceFlags flags) {
// Finish sweeping in case it is still running.
sweeper_.FinishIfRunning();
......@@ -380,7 +389,7 @@ void CppHeap::TracePrologue(TraceFlags flags) {
DCHECK_IMPLIES(!isolate_, (cppgc::Heap::MarkingType::kAtomic ==
marking_config.marking_type) ||
force_incremental_marking_for_testing_);
if ((flags == TraceFlags::kReduceMemory) || (flags == TraceFlags::kForced)) {
if (ShouldReduceMemory(flags)) {
// Only enable compaction when in a memory reduction garbage collection as
// it may significantly increase the final garbage collection pause.
compactor_.InitializeIfShouldCompact(marking_config.marking_type,
......@@ -461,7 +470,7 @@ void CppHeap::TraceEpilogue(TraceSummary* trace_summary) {
: cppgc::internal::Sweeper::SweepingConfig::SweepingType::
kIncrementalAndConcurrent,
compactable_space_handling,
current_flags_ & TraceFlags::kReduceMemory
ShouldReduceMemory(current_flags_)
? cppgc::internal::Sweeper::SweepingConfig::FreeMemoryHandling::
kDiscardWherePossible
: cppgc::internal::Sweeper::SweepingConfig::FreeMemoryHandling::
......
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