Commit c25352f3 authored by Dominik Inführ's avatar Dominik Inführ Committed by Commit Bot

Reland "[heap] Remove sweeping state in incremental marking"

This is a reland of 7f29c48e

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/+/2196182Reviewed-by: 's avatarUlan Degenbaev <ulan@chromium.org>
Commit-Queue: Dominik Inführ <dinfuehr@chromium.org>
Cr-Commit-Position: refs/heads/master@{#67741}
parent 83234b1c
...@@ -292,16 +292,17 @@ void IncrementalMarking::Start(GarbageCollectionReason gc_reason) { ...@@ -292,16 +292,17 @@ void IncrementalMarking::Start(GarbageCollectionReason gc_reason) {
heap_->array_buffer_sweeper()->EnsureFinished(); heap_->array_buffer_sweeper()->EnsureFinished();
} }
if (!collector_->sweeping_in_progress()) { if (collector_->sweeping_in_progress()) {
StartMarking(); TRACE_GC(heap_->tracer(), GCTracer::Scope::MC_INCREMENTAL_SWEEPING);
} else { collector_->EnsureSweepingCompleted();
if (FLAG_trace_incremental_marking) { #ifdef DEBUG
heap()->isolate()->PrintWithTimestamp( heap_->VerifyCountersAfterSweeping();
"[IncrementalMarking] Start sweeping.\n"); #endif
}
SetState(SWEEPING);
} }
CHECK(!collector_->sweeping_in_progress());
StartMarking();
heap_->AddAllocationObserversToAllSpaces(&old_generation_observer_, heap_->AddAllocationObserversToAllSpaces(&old_generation_observer_,
&new_generation_observer_); &new_generation_observer_);
incremental_marking_job()->Start(heap_); incremental_marking_job()->Start(heap_);
...@@ -956,28 +957,6 @@ StepResult IncrementalMarking::AdvanceWithDeadline( ...@@ -956,28 +957,6 @@ StepResult IncrementalMarking::AdvanceWithDeadline(
return Step(kStepSizeInMs, completion_action, step_origin); 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() { size_t IncrementalMarking::StepSizeToKeepUpWithAllocations() {
// Update bytes_allocated_ based on the allocation counter. // Update bytes_allocated_ based on the allocation counter.
size_t current_counter = heap_->OldGenerationAllocationCounter(); size_t current_counter = heap_->OldGenerationAllocationCounter();
...@@ -1068,7 +1047,7 @@ void IncrementalMarking::AdvanceOnAllocation() { ...@@ -1068,7 +1047,7 @@ void IncrementalMarking::AdvanceOnAllocation() {
// Code using an AlwaysAllocateScope assumes that the GC state does not // Code using an AlwaysAllocateScope assumes that the GC state does not
// change; that implies that no marking steps must be performed. // change; that implies that no marking steps must be performed.
if (heap_->gc_state() != Heap::NOT_IN_GC || !FLAG_incremental_marking || if (heap_->gc_state() != Heap::NOT_IN_GC || !FLAG_incremental_marking ||
(state_ != SWEEPING && state_ != MARKING) || heap_->always_allocate()) { state_ != MARKING || heap_->always_allocate()) {
return; return;
} }
HistogramTimerScope incremental_marking_scope( HistogramTimerScope incremental_marking_scope(
...@@ -1084,11 +1063,6 @@ StepResult IncrementalMarking::Step(double max_step_size_in_ms, ...@@ -1084,11 +1063,6 @@ StepResult IncrementalMarking::Step(double max_step_size_in_ms,
StepOrigin step_origin) { StepOrigin step_origin) {
double start = heap_->MonotonicallyIncreasingTimeInMs(); double start = heap_->MonotonicallyIncreasingTimeInMs();
if (state_ == SWEEPING) {
TRACE_GC(heap_->tracer(), GCTracer::Scope::MC_INCREMENTAL_SWEEPING);
FinalizeSweeping();
}
StepResult combined_result = StepResult::kMoreWorkRemaining; StepResult combined_result = StepResult::kMoreWorkRemaining;
size_t bytes_to_process = 0; size_t bytes_to_process = 0;
size_t v8_bytes_processed = 0; size_t v8_bytes_processed = 0;
......
...@@ -28,7 +28,7 @@ enum class StepResult { ...@@ -28,7 +28,7 @@ enum class StepResult {
class V8_EXPORT_PRIVATE IncrementalMarking final { class V8_EXPORT_PRIVATE IncrementalMarking final {
public: public:
enum State : uint8_t { STOPPED, SWEEPING, MARKING, COMPLETE }; enum State : uint8_t { STOPPED, MARKING, COMPLETE };
enum CompletionAction { GC_VIA_STACK_GUARD, NO_GC_VIA_STACK_GUARD }; enum CompletionAction { GC_VIA_STACK_GUARD, NO_GC_VIA_STACK_GUARD };
...@@ -115,8 +115,6 @@ class V8_EXPORT_PRIVATE IncrementalMarking final { ...@@ -115,8 +115,6 @@ class V8_EXPORT_PRIVATE IncrementalMarking final {
inline bool IsStopped() const { return state() == STOPPED; } inline bool IsStopped() const { return state() == STOPPED; }
inline bool IsSweeping() const { return state() == SWEEPING; }
inline bool IsMarking() const { return state() >= MARKING; } inline bool IsMarking() const { return state() >= MARKING; }
inline bool IsMarkingIncomplete() const { return state() == MARKING; } inline bool IsMarkingIncomplete() const { return state() == MARKING; }
...@@ -167,8 +165,6 @@ class V8_EXPORT_PRIVATE IncrementalMarking final { ...@@ -167,8 +165,6 @@ class V8_EXPORT_PRIVATE IncrementalMarking final {
CompletionAction completion_action, CompletionAction completion_action,
StepOrigin step_origin); StepOrigin step_origin);
void FinalizeSweeping();
StepResult Step(double max_step_size_in_ms, CompletionAction action, StepResult Step(double max_step_size_in_ms, CompletionAction action,
StepOrigin step_origin); StepOrigin step_origin);
......
...@@ -847,10 +847,6 @@ void MarkCompactCollector::Prepare() { ...@@ -847,10 +847,6 @@ void MarkCompactCollector::Prepare() {
heap_->array_buffer_sweeper()->EnsureFinished(); heap_->array_buffer_sweeper()->EnsureFinished();
} }
if (heap()->incremental_marking()->IsSweeping()) {
heap()->incremental_marking()->Stop();
}
if (!was_marked_incrementally_) { if (!was_marked_incrementally_) {
{ {
TRACE_GC(heap()->tracer(), GCTracer::Scope::MC_MARK_EMBEDDER_PROLOGUE); TRACE_GC(heap()->tracer(), GCTracer::Scope::MC_MARK_EMBEDDER_PROLOGUE);
......
...@@ -162,9 +162,6 @@ void SimulateIncrementalMarking(i::Heap* heap, bool force_completion) { ...@@ -162,9 +162,6 @@ void SimulateIncrementalMarking(i::Heap* heap, bool force_completion) {
if (collector->sweeping_in_progress()) { if (collector->sweeping_in_progress()) {
collector->EnsureSweepingCompleted(); collector->EnsureSweepingCompleted();
} }
if (marking->IsSweeping()) {
marking->FinalizeSweeping();
}
CHECK(marking->IsMarking() || marking->IsStopped() || marking->IsComplete()); CHECK(marking->IsMarking() || marking->IsStopped() || marking->IsComplete());
if (marking->IsStopped()) { if (marking->IsStopped()) {
heap->StartIncrementalMarking(i::Heap::kNoGCFlags, heap->StartIncrementalMarking(i::Heap::kNoGCFlags,
......
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