Commit 240ed3c3 authored by Michael Lippautz's avatar Michael Lippautz Committed by Commit Bot

cppgc-js: Use atomic sweeping for forced GCs

Forced GCs are used in testing configurations and under memory
pressure. Use atomic sweeping for C++ in those scenarios as testing
GCs require that destructors are immediately invoked after the GC
call.

Bug: chromium:1056170
Change-Id: I03c13fa7a30cf74076807834c5e6d0c1fe52bb87
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2704543
Commit-Queue: Michael Lippautz <mlippautz@chromium.org>
Reviewed-by: 's avatarOmer Katz <omerkatz@chromium.org>
Reviewed-by: 's avatarUlan Degenbaev <ulan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#72873}
parent 457a86fb
......@@ -271,11 +271,12 @@ void CppHeap::TracePrologue(TraceFlags flags) {
// Finish sweeping in case it is still running.
sweeper_.FinishIfRunning();
current_flags_ = flags;
const UnifiedHeapMarker::MarkingConfig marking_config{
UnifiedHeapMarker::MarkingConfig::CollectionType::kMajor,
cppgc::Heap::StackState::kNoHeapPointers,
cppgc::Heap::MarkingType::kIncrementalAndConcurrent,
flags == TraceFlags::kForced
flags & TraceFlags::kForced
? UnifiedHeapMarker::MarkingConfig::IsForcedGC::kForced
: UnifiedHeapMarker::MarkingConfig::IsForcedGC::kNotForced};
if ((flags == TraceFlags::kReduceMemory) || (flags == TraceFlags::kForced)) {
......@@ -353,8 +354,11 @@ void CppHeap::TraceEpilogue(TraceSummary* trace_summary) {
cppgc::internal::Sweeper::SweepingConfig::CompactableSpaceHandling
compactable_space_handling = compactor_.CompactSpacesIfEnabled();
const cppgc::internal::Sweeper::SweepingConfig sweeping_config{
cppgc::internal::Sweeper::SweepingConfig::SweepingType::
kIncrementalAndConcurrent,
// In case the GC was forced, also finalize sweeping right away.
current_flags_ & TraceFlags::kForced
? cppgc::internal::Sweeper::SweepingConfig::SweepingType::kAtomic
: cppgc::internal::Sweeper::SweepingConfig::SweepingType::
kIncrementalAndConcurrent,
compactable_space_handling};
sweeper().Start(sweeping_config);
}
......
......@@ -75,6 +75,7 @@ class V8_EXPORT_PRIVATE CppHeap final
Isolate* isolate_ = nullptr;
bool marking_done_ = false;
TraceFlags current_flags_ = TraceFlags::kNoFlags;
// Buffered allocated bytes. Reporting allocated bytes to V8 can trigger a GC
// atomic pause. Allocated bytes are buffer in case this is temporarily
......
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