9d3d5f224c
Before a young GC, the scavenger finalizes a pending full GC sweeping, in case there are no more running sweeping jobs, to avoid unnecessarily pausing sweeping and then resuming it. This CL moves this sweeping finalization from ScavengerCollector::CollectGarbage to Heap::CompleteSweepingYoung, so that it is also performed for the minor mark-compactor and that sweeping is correctly attributed to the previous full GC cycle (instead of the beginning young cycle). Furthermore, it also finalizes CppGC sweeping if there are no more running sweeping jobs. Bug: chromium:1154636 Change-Id: Ic9ba4803f49db32c0a539f080329f012859bc8bc Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3508011 Reviewed-by: Omer Katz <omerkatz@chromium.org> Reviewed-by: Michael Lippautz <mlippautz@chromium.org> Reviewed-by: Nico Hartmann <nicohartmann@chromium.org> Commit-Queue: Nikolaos Papaspyrou <nikolaos@chromium.org> Cr-Commit-Position: refs/heads/main@{#79407}
46 lines
1.6 KiB
C++
46 lines
1.6 KiB
C++
// Copyright 2020 the V8 project authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
// found in the LICENSE file.
|
|
|
|
#include "test/unittests/heap/heap-utils.h"
|
|
|
|
#include "src/heap/incremental-marking.h"
|
|
#include "src/heap/mark-compact.h"
|
|
#include "src/heap/safepoint.h"
|
|
|
|
namespace v8 {
|
|
namespace internal {
|
|
|
|
void HeapInternalsBase::SimulateIncrementalMarking(Heap* heap,
|
|
bool force_completion) {
|
|
constexpr double kStepSizeInMs = 100;
|
|
CHECK(FLAG_incremental_marking);
|
|
i::IncrementalMarking* marking = heap->incremental_marking();
|
|
i::MarkCompactCollector* collector = heap->mark_compact_collector();
|
|
if (collector->sweeping_in_progress()) {
|
|
SafepointScope scope(heap);
|
|
collector->EnsureSweepingCompleted(
|
|
MarkCompactCollector::SweepingForcedFinalizationMode::kV8Only);
|
|
}
|
|
CHECK(marking->IsMarking() || marking->IsStopped() || marking->IsComplete());
|
|
if (marking->IsStopped()) {
|
|
heap->StartIncrementalMarking(i::Heap::kNoGCFlags,
|
|
i::GarbageCollectionReason::kTesting);
|
|
}
|
|
CHECK(marking->IsMarking() || marking->IsComplete());
|
|
if (!force_completion) return;
|
|
|
|
while (!marking->IsComplete()) {
|
|
marking->Step(kStepSizeInMs, i::IncrementalMarking::NO_GC_VIA_STACK_GUARD,
|
|
i::StepOrigin::kV8);
|
|
if (marking->IsReadyToOverApproximateWeakClosure()) {
|
|
SafepointScope scope(heap);
|
|
marking->FinalizeIncrementally();
|
|
}
|
|
}
|
|
CHECK(marking->IsComplete());
|
|
}
|
|
|
|
} // namespace internal
|
|
} // namespace v8
|