[heap] Fix concurrent marking in MinorMC

This CL merely maintains concurrent marking in MinorMC in a stable
state, i.e. it builds and passes tests.

Bug: v8:13012
Change-Id: I866fdbdfcdcc9ae101b63323aa43ceeeab882b45
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3934271
Reviewed-by: Michael Lippautz <mlippautz@chromium.org>
Reviewed-by: Dominik Inführ <dinfuehr@chromium.org>
Commit-Queue: Omer Katz <omerkatz@chromium.org>
Cr-Commit-Position: refs/heads/main@{#83510}
This commit is contained in:
Omer Katz 2022-10-04 10:43:52 +02:00 committed by V8 LUCI CQ
parent 700037367d
commit ac76e1eeef
4 changed files with 15 additions and 6 deletions

View File

@ -2040,9 +2040,13 @@ void Heap::StartIncrementalMarking(int gc_flags,
GarbageCollector collector) {
DCHECK(incremental_marking()->IsStopped());
// Sweeping needs to be completed such that markbits are all cleared before
// starting marking again.
CompleteSweepingFull();
if (IsYoungGenerationCollector(collector)) {
CompleteSweepingYoung(collector);
} else {
// Sweeping needs to be completed such that markbits are all cleared before
// starting marking again.
CompleteSweepingFull();
}
base::Optional<SafepointScope> safepoint_scope;
@ -5931,9 +5935,11 @@ void Heap::TearDown() {
}
if (new_space()) {
if (v8_flags.concurrent_minor_mc_marking) {
if (minor_mc_task_observer_) {
DCHECK_NULL(scavenge_task_observer_);
new_space()->RemoveAllocationObserver(minor_mc_task_observer_.get());
} else {
DCHECK_NOT_NULL(scavenge_task_observer_);
new_space()->RemoveAllocationObserver(scavenge_task_observer_.get());
}
}

View File

@ -751,6 +751,7 @@ void IncrementalMarking::AdvanceAndFinalizeIfComplete() {
}
void IncrementalMarking::AdvanceAndFinalizeIfNecessary() {
if (!IsMajorMarking()) return;
DCHECK(!heap_->always_allocate());
AdvanceOnAllocation();
@ -767,7 +768,7 @@ void IncrementalMarking::AdvanceForTesting(double max_step_size_in_ms) {
void IncrementalMarking::AdvanceOnAllocation() {
DCHECK_EQ(heap_->gc_state(), Heap::NOT_IN_GC);
DCHECK(v8_flags.incremental_marking);
DCHECK(IsMarking());
DCHECK(IsMajorMarking());
// Code using an AlwaysAllocateScope assumes that the GC state does not
// change; that implies that no marking steps must be performed.

View File

@ -34,7 +34,7 @@ void HeapInternalsBase::SimulateIncrementalMarking(Heap* heap,
heap->StartIncrementalMarking(i::Heap::kNoGCFlags,
i::GarbageCollectionReason::kTesting);
}
CHECK(marking->IsMarking());
CHECK(marking->IsMajorMarking());
if (!force_completion) return;
while (!marking->IsMajorMarkingComplete()) {

View File

@ -97,6 +97,8 @@ ManualGCScope::ManualGCScope(i::Isolate* isolate) {
i::v8_flags.concurrent_marking = false;
i::v8_flags.concurrent_sweeping = false;
i::v8_flags.concurrent_minor_mc_marking = false;
i::v8_flags.concurrent_minor_mc_sweeping = false;
i::v8_flags.stress_incremental_marking = false;
i::v8_flags.stress_concurrent_allocation = false;
// Parallel marking has a dependency on concurrent marking.