Revert "Reland "[heap] Remove sweeping state in incremental marking""
This reverts commitc25352f388
. Reason for revert: Causing raytrace timeouts on TSAN: https://ci.chromium.org/p/v8/builders/ci/V8%20Linux64%20TSAN%20-%20concurrent%20marking/13089 https://ci.chromium.org/p/v8/builders/ci/V8%20Linux64%20TSAN%20-%20concurrent%20marking/13090 https://ci.chromium.org/p/v8/builders/ci/V8%20Linux64%20TSAN%20-%20concurrent%20marking/13091 Original change's description: > Reland "[heap] Remove sweeping state in incremental marking" > > This is a reland of7f29c48ef6
> > After fixing TSAN failures in https://crrev.com/c/2192661 and https://crrev.com/c/2193712, this CL and be relanded without changes. > > Original change's description: > > [heap] Remove sweeping state in incremental marking > > > > Remove the SWEEPING state from incremental marking. Sweeping is now > > always completed when starting incremental marking. Before this change > > there needed to be a safepoint each for starting marking and completing > > sweeping. Now both happens within a single safepoint. > > > > Bug: v8:10315 > > Change-Id: Iad2835554865f2de24376372affe9a98992d1fa0 > > Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2190419 > > Reviewed-by: Ulan Degenbaev <ulan@chromium.org> > > Commit-Queue: Dominik Inführ <dinfuehr@chromium.org> > > Cr-Commit-Position: refs/heads/master@{#67678} > > Bug: v8:10315 > Change-Id: Ic949d125e72c4d17fd427d08d4b6f9056721eee9 > Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2196182 > Reviewed-by: Ulan Degenbaev <ulan@chromium.org> > Commit-Queue: Dominik Inführ <dinfuehr@chromium.org> > Cr-Commit-Position: refs/heads/master@{#67741} TBR=ulan@chromium.org,dinfuehr@chromium.org Change-Id: Ie529fd3bef13a28301f22876758d731e466d3939 No-Presubmit: true No-Tree-Checks: true No-Try: true Bug: v8:10315 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2197457 Reviewed-by: Shu-yu Guo <syg@chromium.org> Commit-Queue: Shu-yu Guo <syg@chromium.org> Cr-Commit-Position: refs/heads/master@{#67761}
This commit is contained in:
parent
758212a82e
commit
89577b6f78
@ -292,17 +292,16 @@ void IncrementalMarking::Start(GarbageCollectionReason gc_reason) {
|
||||
heap_->array_buffer_sweeper()->EnsureFinished();
|
||||
}
|
||||
|
||||
if (collector_->sweeping_in_progress()) {
|
||||
TRACE_GC(heap_->tracer(), GCTracer::Scope::MC_INCREMENTAL_SWEEPING);
|
||||
collector_->EnsureSweepingCompleted();
|
||||
#ifdef DEBUG
|
||||
heap_->VerifyCountersAfterSweeping();
|
||||
#endif
|
||||
if (!collector_->sweeping_in_progress()) {
|
||||
StartMarking();
|
||||
} else {
|
||||
if (FLAG_trace_incremental_marking) {
|
||||
heap()->isolate()->PrintWithTimestamp(
|
||||
"[IncrementalMarking] Start sweeping.\n");
|
||||
}
|
||||
SetState(SWEEPING);
|
||||
}
|
||||
|
||||
CHECK(!collector_->sweeping_in_progress());
|
||||
StartMarking();
|
||||
|
||||
heap_->AddAllocationObserversToAllSpaces(&old_generation_observer_,
|
||||
&new_generation_observer_);
|
||||
incremental_marking_job()->Start(heap_);
|
||||
@ -957,6 +956,28 @@ StepResult IncrementalMarking::AdvanceWithDeadline(
|
||||
return Step(kStepSizeInMs, completion_action, step_origin);
|
||||
}
|
||||
|
||||
void IncrementalMarking::FinalizeSweeping() {
|
||||
DCHECK(state_ == SWEEPING);
|
||||
#ifdef DEBUG
|
||||
// Enforce safepoint here such that background threads cannot allocate between
|
||||
// completing sweeping and VerifyCountersAfterSweeping().
|
||||
SafepointScope scope(heap());
|
||||
#endif
|
||||
if (collector_->sweeping_in_progress() &&
|
||||
(!FLAG_concurrent_sweeping ||
|
||||
!collector_->sweeper()->AreSweeperTasksRunning())) {
|
||||
collector_->EnsureSweepingCompleted();
|
||||
}
|
||||
if (!collector_->sweeping_in_progress()) {
|
||||
#ifdef DEBUG
|
||||
heap_->VerifyCountersAfterSweeping();
|
||||
#else
|
||||
SafepointScope scope(heap());
|
||||
#endif
|
||||
StartMarking();
|
||||
}
|
||||
}
|
||||
|
||||
size_t IncrementalMarking::StepSizeToKeepUpWithAllocations() {
|
||||
// Update bytes_allocated_ based on the allocation counter.
|
||||
size_t current_counter = heap_->OldGenerationAllocationCounter();
|
||||
@ -1047,7 +1068,7 @@ void IncrementalMarking::AdvanceOnAllocation() {
|
||||
// Code using an AlwaysAllocateScope assumes that the GC state does not
|
||||
// change; that implies that no marking steps must be performed.
|
||||
if (heap_->gc_state() != Heap::NOT_IN_GC || !FLAG_incremental_marking ||
|
||||
state_ != MARKING || heap_->always_allocate()) {
|
||||
(state_ != SWEEPING && state_ != MARKING) || heap_->always_allocate()) {
|
||||
return;
|
||||
}
|
||||
HistogramTimerScope incremental_marking_scope(
|
||||
@ -1063,6 +1084,11 @@ StepResult IncrementalMarking::Step(double max_step_size_in_ms,
|
||||
StepOrigin step_origin) {
|
||||
double start = heap_->MonotonicallyIncreasingTimeInMs();
|
||||
|
||||
if (state_ == SWEEPING) {
|
||||
TRACE_GC(heap_->tracer(), GCTracer::Scope::MC_INCREMENTAL_SWEEPING);
|
||||
FinalizeSweeping();
|
||||
}
|
||||
|
||||
StepResult combined_result = StepResult::kMoreWorkRemaining;
|
||||
size_t bytes_to_process = 0;
|
||||
size_t v8_bytes_processed = 0;
|
||||
|
@ -28,7 +28,7 @@ enum class StepResult {
|
||||
|
||||
class V8_EXPORT_PRIVATE IncrementalMarking final {
|
||||
public:
|
||||
enum State : uint8_t { STOPPED, MARKING, COMPLETE };
|
||||
enum State : uint8_t { STOPPED, SWEEPING, MARKING, COMPLETE };
|
||||
|
||||
enum CompletionAction { GC_VIA_STACK_GUARD, NO_GC_VIA_STACK_GUARD };
|
||||
|
||||
@ -115,6 +115,8 @@ class V8_EXPORT_PRIVATE IncrementalMarking final {
|
||||
|
||||
inline bool IsStopped() const { return state() == STOPPED; }
|
||||
|
||||
inline bool IsSweeping() const { return state() == SWEEPING; }
|
||||
|
||||
inline bool IsMarking() const { return state() >= MARKING; }
|
||||
|
||||
inline bool IsMarkingIncomplete() const { return state() == MARKING; }
|
||||
@ -165,6 +167,8 @@ class V8_EXPORT_PRIVATE IncrementalMarking final {
|
||||
CompletionAction completion_action,
|
||||
StepOrigin step_origin);
|
||||
|
||||
void FinalizeSweeping();
|
||||
|
||||
StepResult Step(double max_step_size_in_ms, CompletionAction action,
|
||||
StepOrigin step_origin);
|
||||
|
||||
|
@ -847,6 +847,10 @@ void MarkCompactCollector::Prepare() {
|
||||
heap_->array_buffer_sweeper()->EnsureFinished();
|
||||
}
|
||||
|
||||
if (heap()->incremental_marking()->IsSweeping()) {
|
||||
heap()->incremental_marking()->Stop();
|
||||
}
|
||||
|
||||
if (!was_marked_incrementally_) {
|
||||
{
|
||||
TRACE_GC(heap()->tracer(), GCTracer::Scope::MC_MARK_EMBEDDER_PROLOGUE);
|
||||
|
@ -162,6 +162,9 @@ void SimulateIncrementalMarking(i::Heap* heap, bool force_completion) {
|
||||
if (collector->sweeping_in_progress()) {
|
||||
collector->EnsureSweepingCompleted();
|
||||
}
|
||||
if (marking->IsSweeping()) {
|
||||
marking->FinalizeSweeping();
|
||||
}
|
||||
CHECK(marking->IsMarking() || marking->IsStopped() || marking->IsComplete());
|
||||
if (marking->IsStopped()) {
|
||||
heap->StartIncrementalMarking(i::Heap::kNoGCFlags,
|
||||
|
Loading…
Reference in New Issue
Block a user