Commit 0be95494 authored by Keishi Hattori's avatar Keishi Hattori Committed by Commit Bot

Oilpan: Replace GCStates with GCPhase

Replaces the following GCStates with GCPhase counterparts.
- kGCRunning
- kSweeping
- kSweepingAndIdleGCScheduled
- kSweepingAndPreciseGCScheduled

Bug: 757440
Change-Id: I92b40d326bbedfe66ce41aca7d563968eaf3b28a
Reviewed-on: https://chromium-review.googlesource.com/980412
Commit-Queue: Keishi Hattori <keishi@chromium.org>
Reviewed-by: default avatarMichael Lippautz <mlippautz@chromium.org>
Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Cr-Commit-Position: refs/heads/master@{#546092}
parent 245d8f76
...@@ -266,7 +266,6 @@ void V8GCController::GcEpilogue(v8::Isolate* isolate, ...@@ -266,7 +266,6 @@ void V8GCController::GcEpilogue(v8::Isolate* isolate,
BlinkGC::kEagerSweeping, BlinkGC::kForcedGC); BlinkGC::kEagerSweeping, BlinkGC::kForcedGC);
// Forces a precise GC at the end of the current event loop. // Forces a precise GC at the end of the current event loop.
CHECK(!current_thread_state->IsInGC());
current_thread_state->SetGCState(ThreadState::kFullGCScheduled); current_thread_state->SetGCState(ThreadState::kFullGCScheduled);
} }
......
...@@ -162,7 +162,7 @@ ThreadHeap::~ThreadHeap() { ...@@ -162,7 +162,7 @@ ThreadHeap::~ThreadHeap() {
Address ThreadHeap::CheckAndMarkPointer(MarkingVisitor* visitor, Address ThreadHeap::CheckAndMarkPointer(MarkingVisitor* visitor,
Address address) { Address address) {
DCHECK(thread_state_->IsInGC()); DCHECK(thread_state_->InAtomicMarkingPause());
#if !DCHECK_IS_ON() #if !DCHECK_IS_ON()
if (heap_does_not_contain_cache_->Lookup(address)) if (heap_does_not_contain_cache_->Lookup(address))
...@@ -196,7 +196,7 @@ Address ThreadHeap::CheckAndMarkPointer( ...@@ -196,7 +196,7 @@ Address ThreadHeap::CheckAndMarkPointer(
MarkingVisitor* visitor, MarkingVisitor* visitor,
Address address, Address address,
MarkedPointerCallbackForTesting callback) { MarkedPointerCallbackForTesting callback) {
DCHECK(thread_state_->IsInGC()); DCHECK(thread_state_->InAtomicMarkingPause());
if (BasePage* page = LookupPageForAddress(address)) { if (BasePage* page = LookupPageForAddress(address)) {
DCHECK(page->Contains(address)); DCHECK(page->Contains(address));
...@@ -213,7 +213,7 @@ Address ThreadHeap::CheckAndMarkPointer( ...@@ -213,7 +213,7 @@ Address ThreadHeap::CheckAndMarkPointer(
void ThreadHeap::RegisterWeakTable(void* table, void ThreadHeap::RegisterWeakTable(void* table,
EphemeronCallback iteration_callback) { EphemeronCallback iteration_callback) {
DCHECK(thread_state_->IsInGC()); DCHECK(thread_state_->InAtomicMarkingPause());
#if DCHECK_IS_ON() #if DCHECK_IS_ON()
auto result = ephemeron_callbacks_.insert(table, iteration_callback); auto result = ephemeron_callbacks_.insert(table, iteration_callback);
DCHECK(result.is_new_entry || DCHECK(result.is_new_entry ||
...@@ -451,18 +451,16 @@ void ThreadHeap::ReportMemoryUsageForTracing() { ...@@ -451,18 +451,16 @@ void ThreadHeap::ReportMemoryUsageForTracing() {
} }
size_t ThreadHeap::ObjectPayloadSizeForTesting() { size_t ThreadHeap::ObjectPayloadSizeForTesting() {
ThreadState::AtomicPauseScope atomic_pause_scope(thread_state_);
size_t object_payload_size = 0; size_t object_payload_size = 0;
thread_state_->SetGCPhase(ThreadState::GCPhase::kMarking); thread_state_->SetGCPhase(ThreadState::GCPhase::kMarking);
thread_state_->SetGCState(ThreadState::kGCRunning);
thread_state_->Heap().MakeConsistentForGC(); thread_state_->Heap().MakeConsistentForGC();
thread_state_->Heap().PrepareForSweep(); thread_state_->Heap().PrepareForSweep();
for (int i = 0; i < BlinkGC::kNumberOfArenas; ++i) for (int i = 0; i < BlinkGC::kNumberOfArenas; ++i)
object_payload_size += arenas_[i]->ObjectPayloadSizeForTesting(); object_payload_size += arenas_[i]->ObjectPayloadSizeForTesting();
MakeConsistentForMutator(); MakeConsistentForMutator();
thread_state_->SetGCPhase(ThreadState::GCPhase::kSweeping); thread_state_->SetGCPhase(ThreadState::GCPhase::kSweeping);
thread_state_->SetGCState(ThreadState::kSweeping);
thread_state_->SetGCPhase(ThreadState::GCPhase::kNone); thread_state_->SetGCPhase(ThreadState::GCPhase::kNone);
thread_state_->SetGCState(ThreadState::kNoGCScheduled);
return object_payload_size; return object_payload_size;
} }
...@@ -487,19 +485,19 @@ bool ThreadHeap::IsAddressInHeapDoesNotContainCache(Address address) { ...@@ -487,19 +485,19 @@ bool ThreadHeap::IsAddressInHeapDoesNotContainCache(Address address) {
} }
void ThreadHeap::VisitPersistentRoots(Visitor* visitor) { void ThreadHeap::VisitPersistentRoots(Visitor* visitor) {
DCHECK(thread_state_->IsInGC()); DCHECK(thread_state_->InAtomicMarkingPause());
TRACE_EVENT0("blink_gc", "ThreadHeap::visitPersistentRoots"); TRACE_EVENT0("blink_gc", "ThreadHeap::visitPersistentRoots");
thread_state_->VisitPersistents(visitor); thread_state_->VisitPersistents(visitor);
} }
void ThreadHeap::VisitStackRoots(MarkingVisitor* visitor) { void ThreadHeap::VisitStackRoots(MarkingVisitor* visitor) {
DCHECK(thread_state_->IsInGC()); DCHECK(thread_state_->InAtomicMarkingPause());
TRACE_EVENT0("blink_gc", "ThreadHeap::visitStackRoots"); TRACE_EVENT0("blink_gc", "ThreadHeap::visitStackRoots");
thread_state_->VisitStack(visitor); thread_state_->VisitStack(visitor);
} }
BasePage* ThreadHeap::LookupPageForAddress(Address address) { BasePage* ThreadHeap::LookupPageForAddress(Address address) {
DCHECK(thread_state_->IsInGC()); DCHECK(thread_state_->InAtomicMarkingPause());
if (PageMemoryRegion* region = region_tree_->Lookup(address)) { if (PageMemoryRegion* region = region_tree_->Lookup(address)) {
return region->PageFromAddress(address); return region->PageFromAddress(address);
} }
...@@ -507,7 +505,7 @@ BasePage* ThreadHeap::LookupPageForAddress(Address address) { ...@@ -507,7 +505,7 @@ BasePage* ThreadHeap::LookupPageForAddress(Address address) {
} }
void ThreadHeap::ResetHeapCounters() { void ThreadHeap::ResetHeapCounters() {
DCHECK(thread_state_->IsInGC()); DCHECK(thread_state_->InAtomicMarkingPause());
ThreadHeap::ReportMemoryUsageForTracing(); ThreadHeap::ReportMemoryUsageForTracing();
...@@ -518,14 +516,14 @@ void ThreadHeap::ResetHeapCounters() { ...@@ -518,14 +516,14 @@ void ThreadHeap::ResetHeapCounters() {
} }
void ThreadHeap::MakeConsistentForGC() { void ThreadHeap::MakeConsistentForGC() {
DCHECK(thread_state_->IsInGC()); DCHECK(thread_state_->InAtomicMarkingPause());
TRACE_EVENT0("blink_gc", "ThreadHeap::MakeConsistentForGC"); TRACE_EVENT0("blink_gc", "ThreadHeap::MakeConsistentForGC");
for (int i = 0; i < BlinkGC::kNumberOfArenas; ++i) for (int i = 0; i < BlinkGC::kNumberOfArenas; ++i)
arenas_[i]->MakeConsistentForGC(); arenas_[i]->MakeConsistentForGC();
} }
void ThreadHeap::MakeConsistentForMutator() { void ThreadHeap::MakeConsistentForMutator() {
DCHECK(thread_state_->IsInGC()); DCHECK(thread_state_->InAtomicMarkingPause());
for (int i = 0; i < BlinkGC::kNumberOfArenas; ++i) for (int i = 0; i < BlinkGC::kNumberOfArenas; ++i)
arenas_[i]->MakeConsistentForMutator(); arenas_[i]->MakeConsistentForMutator();
} }
...@@ -555,7 +553,7 @@ void ThreadHeap::Compact() { ...@@ -555,7 +553,7 @@ void ThreadHeap::Compact() {
} }
void ThreadHeap::PrepareForSweep() { void ThreadHeap::PrepareForSweep() {
DCHECK(thread_state_->IsInGC()); DCHECK(thread_state_->InAtomicMarkingPause());
DCHECK(thread_state_->CheckThread()); DCHECK(thread_state_->CheckThread());
for (int i = 0; i < BlinkGC::kNumberOfArenas; i++) for (int i = 0; i < BlinkGC::kNumberOfArenas; i++)
arenas_[i]->PrepareForSweep(); arenas_[i]->PrepareForSweep();
...@@ -659,7 +657,7 @@ BasePage* ThreadHeap::FindPageFromAddress(Address address) { ...@@ -659,7 +657,7 @@ BasePage* ThreadHeap::FindPageFromAddress(Address address) {
#endif #endif
void ThreadHeap::TakeSnapshot(SnapshotType type) { void ThreadHeap::TakeSnapshot(SnapshotType type) {
DCHECK(thread_state_->IsInGC()); DCHECK(thread_state_->InAtomicMarkingPause());
// 0 is used as index for freelist entries. Objects are indexed 1 to // 0 is used as index for freelist entries. Objects are indexed 1 to
// gcInfoIndex. // gcInfoIndex.
......
...@@ -13,7 +13,7 @@ void HeapAllocator::BackingFree(void* address) { ...@@ -13,7 +13,7 @@ void HeapAllocator::BackingFree(void* address) {
ThreadState* state = ThreadState::Current(); ThreadState* state = ThreadState::Current();
if (state->SweepForbidden()) if (state->SweepForbidden())
return; return;
DCHECK(!state->IsInGC()); DCHECK(!state->in_atomic_pause());
// Don't promptly free large objects because their page is never reused. // Don't promptly free large objects because their page is never reused.
// Don't free backings allocated on other threads. // Don't free backings allocated on other threads.
...@@ -41,8 +41,7 @@ void HeapAllocator::FreeInlineVectorBacking(void* address) { ...@@ -41,8 +41,7 @@ void HeapAllocator::FreeInlineVectorBacking(void* address) {
} }
void HeapAllocator::FreeHashTableBacking(void* address, bool is_weak_table) { void HeapAllocator::FreeHashTableBacking(void* address, bool is_weak_table) {
if (!ThreadState::Current()->IsIncrementalMarkingInProgress() || if (!ThreadState::Current()->IsMarkingInProgress() || !is_weak_table)
!is_weak_table)
BackingFree(address); BackingFree(address);
} }
...@@ -53,7 +52,7 @@ bool HeapAllocator::BackingExpand(void* address, size_t new_size) { ...@@ -53,7 +52,7 @@ bool HeapAllocator::BackingExpand(void* address, size_t new_size) {
ThreadState* state = ThreadState::Current(); ThreadState* state = ThreadState::Current();
if (state->SweepForbidden()) if (state->SweepForbidden())
return false; return false;
DCHECK(!state->IsInGC()); DCHECK(!state->in_atomic_pause());
DCHECK(state->IsAllocationAllowed()); DCHECK(state->IsAllocationAllowed());
DCHECK_EQ(&state->Heap(), &ThreadState::FromObject(address)->Heap()); DCHECK_EQ(&state->Heap(), &ThreadState::FromObject(address)->Heap());
...@@ -94,7 +93,7 @@ bool HeapAllocator::BackingShrink(void* address, ...@@ -94,7 +93,7 @@ bool HeapAllocator::BackingShrink(void* address,
ThreadState* state = ThreadState::Current(); ThreadState* state = ThreadState::Current();
if (state->SweepForbidden()) if (state->SweepForbidden())
return false; return false;
DCHECK(!state->IsInGC()); DCHECK(!state->in_atomic_pause());
DCHECK(state->IsAllocationAllowed()); DCHECK(state->IsAllocationAllowed());
DCHECK_EQ(&state->Heap(), &ThreadState::FromObject(address)->Heap()); DCHECK_EQ(&state->Heap(), &ThreadState::FromObject(address)->Heap());
......
...@@ -226,7 +226,7 @@ size_t BaseArena::ObjectPayloadSizeForTesting() { ...@@ -226,7 +226,7 @@ size_t BaseArena::ObjectPayloadSizeForTesting() {
} }
void BaseArena::PrepareForSweep() { void BaseArena::PrepareForSweep() {
DCHECK(GetThreadState()->IsInGC()); DCHECK(GetThreadState()->InAtomicMarkingPause());
DCHECK(SweepingCompleted()); DCHECK(SweepingCompleted());
ClearFreeLists(); ClearFreeLists();
...@@ -1791,7 +1791,7 @@ size_t HeapDoesNotContainCache::GetHash(Address address) { ...@@ -1791,7 +1791,7 @@ size_t HeapDoesNotContainCache::GetHash(Address address) {
} }
bool HeapDoesNotContainCache::Lookup(Address address) { bool HeapDoesNotContainCache::Lookup(Address address) {
DCHECK(ThreadState::Current()->IsInGC()); DCHECK(ThreadState::Current()->InAtomicMarkingPause());
size_t index = GetHash(address); size_t index = GetHash(address);
DCHECK(!(index & 1)); DCHECK(!(index & 1));
...@@ -1804,7 +1804,7 @@ bool HeapDoesNotContainCache::Lookup(Address address) { ...@@ -1804,7 +1804,7 @@ bool HeapDoesNotContainCache::Lookup(Address address) {
} }
void HeapDoesNotContainCache::AddEntry(Address address) { void HeapDoesNotContainCache::AddEntry(Address address) {
DCHECK(ThreadState::Current()->IsInGC()); DCHECK(ThreadState::Current()->InAtomicMarkingPause());
has_entries_ = true; has_entries_ = true;
size_t index = GetHash(address); size_t index = GetHash(address);
......
...@@ -147,7 +147,7 @@ class PLATFORM_EXPORT MarkingVisitor final : public Visitor { ...@@ -147,7 +147,7 @@ class PLATFORM_EXPORT MarkingVisitor final : public Visitor {
inline bool MarkingVisitor::MarkHeaderNoTracing(HeapObjectHeader* header) { inline bool MarkingVisitor::MarkHeaderNoTracing(HeapObjectHeader* header) {
DCHECK(header); DCHECK(header);
DCHECK(State()->IsInGC() || State()->IsIncrementalMarking()); DCHECK(State()->InAtomicMarkingPause() || State()->IsIncrementalMarking());
// A GC should only mark the objects that belong in its heap. // A GC should only mark the objects that belong in its heap.
DCHECK_EQ(State(), DCHECK_EQ(State(),
PageFromObject(header->Payload())->Arena()->GetThreadState()); PageFromObject(header->Payload())->Arena()->GetThreadState());
......
...@@ -418,7 +418,7 @@ bool ThreadState::ShouldScheduleIncrementalMarking() const { ...@@ -418,7 +418,7 @@ bool ThreadState::ShouldScheduleIncrementalMarking() const {
#if BUILDFLAG(BLINK_HEAP_INCREMENTAL_MARKING) #if BUILDFLAG(BLINK_HEAP_INCREMENTAL_MARKING)
// TODO(mlippautz): For now immediately schedule incremental marking if // TODO(mlippautz): For now immediately schedule incremental marking if
// the runtime flag is provided, basically exercising a stress test. // the runtime flag is provided, basically exercising a stress test.
return (GcState() == kNoGCScheduled || GcState() == kSweeping) && return GcState() == kNoGCScheduled &&
RuntimeEnabledFeatures::HeapIncrementalMarkingEnabled(); RuntimeEnabledFeatures::HeapIncrementalMarkingEnabled();
#else #else
return false; return false;
...@@ -685,18 +685,19 @@ void ThreadState::ScheduleIncrementalMarkingFinalize() { ...@@ -685,18 +685,19 @@ void ThreadState::ScheduleIncrementalMarkingFinalize() {
} }
void ThreadState::ScheduleIdleGC() { void ThreadState::ScheduleIdleGC() {
if (IsSweepingInProgress()) { SetGCState(kIdleGCScheduled);
SetGCState(kSweepingAndIdleGCScheduled); if (IsSweepingInProgress())
return; return;
}
// Some threads (e.g. PPAPI thread) don't have a scheduler. // Some threads (e.g. PPAPI thread) don't have a scheduler.
if (!Platform::Current()->CurrentThread()->Scheduler()) // Also some tests can call Platform::SetCurrentPlatformForTesting() at any
// time, so we need to check for the scheduler here instead of
// ScheduleIdleGC().
if (!Platform::Current()->CurrentThread()->Scheduler()) {
SetGCState(kNoGCScheduled);
return; return;
}
Platform::Current()->CurrentThread()->Scheduler()->PostNonNestableIdleTask( Platform::Current()->CurrentThread()->Scheduler()->PostNonNestableIdleTask(
FROM_HERE, WTF::Bind(&ThreadState::PerformIdleGC, WTF::Unretained(this))); FROM_HERE, WTF::Bind(&ThreadState::PerformIdleGC, WTF::Unretained(this)));
SetGCState(kIdleGCScheduled);
} }
void ThreadState::ScheduleIdleLazySweep() { void ThreadState::ScheduleIdleLazySweep() {
...@@ -711,11 +712,6 @@ void ThreadState::ScheduleIdleLazySweep() { ...@@ -711,11 +712,6 @@ void ThreadState::ScheduleIdleLazySweep() {
void ThreadState::SchedulePreciseGC() { void ThreadState::SchedulePreciseGC() {
DCHECK(CheckThread()); DCHECK(CheckThread());
if (IsSweepingInProgress()) {
SetGCState(kSweepingAndPreciseGCScheduled);
return;
}
SetGCState(kPreciseGCScheduled); SetGCState(kPreciseGCScheduled);
} }
...@@ -732,10 +728,6 @@ void UnexpectedGCState(ThreadState::GCState gc_state) { ...@@ -732,10 +728,6 @@ void UnexpectedGCState(ThreadState::GCState gc_state) {
UNEXPECTED_GCSTATE(kIdleGCScheduled); UNEXPECTED_GCSTATE(kIdleGCScheduled);
UNEXPECTED_GCSTATE(kPreciseGCScheduled); UNEXPECTED_GCSTATE(kPreciseGCScheduled);
UNEXPECTED_GCSTATE(kFullGCScheduled); UNEXPECTED_GCSTATE(kFullGCScheduled);
UNEXPECTED_GCSTATE(kGCRunning);
UNEXPECTED_GCSTATE(kSweeping);
UNEXPECTED_GCSTATE(kSweepingAndIdleGCScheduled);
UNEXPECTED_GCSTATE(kSweepingAndPreciseGCScheduled);
UNEXPECTED_GCSTATE(kIncrementalMarkingStartScheduled); UNEXPECTED_GCSTATE(kIncrementalMarkingStartScheduled);
UNEXPECTED_GCSTATE(kIncrementalMarkingStepScheduled); UNEXPECTED_GCSTATE(kIncrementalMarkingStepScheduled);
UNEXPECTED_GCSTATE(kIncrementalMarkingFinalizeScheduled); UNEXPECTED_GCSTATE(kIncrementalMarkingFinalizeScheduled);
...@@ -756,13 +748,14 @@ void ThreadState::SetGCState(GCState gc_state) { ...@@ -756,13 +748,14 @@ void ThreadState::SetGCState(GCState gc_state) {
case kNoGCScheduled: case kNoGCScheduled:
DCHECK(CheckThread()); DCHECK(CheckThread());
VERIFY_STATE_TRANSITION( VERIFY_STATE_TRANSITION(
gc_state_ == kSweeping || gc_state_ == kSweepingAndIdleGCScheduled || gc_state_ == kNoGCScheduled || gc_state_ == kIdleGCScheduled ||
gc_state_ == kPreciseGCScheduled || gc_state_ == kFullGCScheduled ||
gc_state_ == kPageNavigationGCScheduled ||
gc_state_ == kIncrementalMarkingFinalizeScheduled); gc_state_ == kIncrementalMarkingFinalizeScheduled);
break; break;
case kIncrementalMarkingStartScheduled: case kIncrementalMarkingStartScheduled:
DCHECK(CheckThread()); DCHECK(CheckThread());
VERIFY_STATE_TRANSITION((gc_state_ == kSweeping) || VERIFY_STATE_TRANSITION(gc_state_ == kNoGCScheduled);
(gc_state_ == kNoGCScheduled));
break; break;
case kIncrementalMarkingStepScheduled: case kIncrementalMarkingStepScheduled:
DCHECK(CheckThread()); DCHECK(CheckThread());
...@@ -773,35 +766,20 @@ void ThreadState::SetGCState(GCState gc_state) { ...@@ -773,35 +766,20 @@ void ThreadState::SetGCState(GCState gc_state) {
DCHECK(CheckThread()); DCHECK(CheckThread());
VERIFY_STATE_TRANSITION(gc_state_ == kIncrementalMarkingStepScheduled); VERIFY_STATE_TRANSITION(gc_state_ == kIncrementalMarkingStepScheduled);
break; break;
case kIdleGCScheduled:
case kPreciseGCScheduled:
case kFullGCScheduled: case kFullGCScheduled:
case kPageNavigationGCScheduled: case kPageNavigationGCScheduled:
// These GCs should not be scheduled while sweeping is in progress.
DCHECK(!IsSweepingInProgress());
FALLTHROUGH;
case kIdleGCScheduled:
case kPreciseGCScheduled:
DCHECK(CheckThread()); DCHECK(CheckThread());
VERIFY_STATE_TRANSITION( VERIFY_STATE_TRANSITION(
gc_state_ == kNoGCScheduled || gc_state_ == kIdleGCScheduled || gc_state_ == kNoGCScheduled || gc_state_ == kIdleGCScheduled ||
gc_state_ == kPreciseGCScheduled || gc_state_ == kFullGCScheduled || gc_state_ == kPreciseGCScheduled || gc_state_ == kFullGCScheduled ||
gc_state_ == kPageNavigationGCScheduled || gc_state_ == kSweeping || gc_state_ == kPageNavigationGCScheduled);
gc_state_ == kSweepingAndIdleGCScheduled ||
gc_state_ == kSweepingAndPreciseGCScheduled);
CompleteSweep(); CompleteSweep();
break; break;
case kGCRunning:
DCHECK(!IsInGC());
VERIFY_STATE_TRANSITION(gc_state_ != kGCRunning);
break;
case kSweeping:
DCHECK(IsInGC());
DCHECK(CheckThread());
VERIFY_STATE_TRANSITION(gc_state_ == kGCRunning);
break;
case kSweepingAndIdleGCScheduled:
case kSweepingAndPreciseGCScheduled:
DCHECK(CheckThread());
VERIFY_STATE_TRANSITION(gc_state_ == kSweeping ||
gc_state_ == kSweepingAndIdleGCScheduled ||
gc_state_ == kSweepingAndPreciseGCScheduled);
break;
default: default:
NOTREACHED(); NOTREACHED();
} }
...@@ -869,7 +847,7 @@ void ThreadState::RunScheduledGC(BlinkGC::StackState stack_state) { ...@@ -869,7 +847,7 @@ void ThreadState::RunScheduledGC(BlinkGC::StackState stack_state) {
void ThreadState::PreSweep(BlinkGC::MarkingType marking_type, void ThreadState::PreSweep(BlinkGC::MarkingType marking_type,
BlinkGC::SweepingType sweeping_type) { BlinkGC::SweepingType sweeping_type) {
DCHECK(IsInGC()); DCHECK(InAtomicMarkingPause());
DCHECK(CheckThread()); DCHECK(CheckThread());
Heap().PrepareForSweep(); Heap().PrepareForSweep();
...@@ -892,9 +870,8 @@ void ThreadState::PreSweep(BlinkGC::MarkingType marking_type, ...@@ -892,9 +870,8 @@ void ThreadState::PreSweep(BlinkGC::MarkingType marking_type,
return; return;
} }
// We have to set the GCState to Sweeping before calling pre-finalizers // We have to set the GCPhase to Sweeping before calling pre-finalizers
// to disallow a GC during the pre-finalizers. // to disallow a GC during the pre-finalizers.
SetGCState(kSweeping);
SetGCPhase(GCPhase::kSweeping); SetGCPhase(GCPhase::kSweeping);
// Allocation is allowed during the pre-finalizers and destructors. // Allocation is allowed during the pre-finalizers and destructors.
...@@ -1040,20 +1017,8 @@ void ThreadState::PostSweep() { ...@@ -1040,20 +1017,8 @@ void ThreadState::PostSweep() {
} }
SetGCPhase(GCPhase::kNone); SetGCPhase(GCPhase::kNone);
switch (GcState()) { if (GcState() == kIdleGCScheduled)
case kSweeping: ScheduleIdleGC();
SetGCState(kNoGCScheduled);
break;
case kSweepingAndPreciseGCScheduled:
SetGCState(kPreciseGCScheduled);
break;
case kSweepingAndIdleGCScheduled:
SetGCState(kNoGCScheduled);
ScheduleIdleGC();
break;
default:
NOTREACHED();
}
gc_age_++; gc_age_++;
...@@ -1301,6 +1266,8 @@ void ThreadState::CollectGarbage(BlinkGC::StackState stack_state, ...@@ -1301,6 +1266,8 @@ void ThreadState::CollectGarbage(BlinkGC::StackState stack_state,
RUNTIME_CALL_TIMER_SCOPE_IF_ISOLATE_EXISTS( RUNTIME_CALL_TIMER_SCOPE_IF_ISOLATE_EXISTS(
GetIsolate(), RuntimeCallStats::CounterId::kCollectGarbage); GetIsolate(), RuntimeCallStats::CounterId::kCollectGarbage);
SetGCState(kNoGCScheduled);
{ {
AtomicPauseScope atomic_pause_scope(this); AtomicPauseScope atomic_pause_scope(this);
{ {
...@@ -1384,8 +1351,7 @@ void ThreadState::MarkPhasePrologue(BlinkGC::StackState stack_state, ...@@ -1384,8 +1351,7 @@ void ThreadState::MarkPhasePrologue(BlinkGC::StackState stack_state,
if (isolate_ && perform_cleanup_) if (isolate_ && perform_cleanup_)
perform_cleanup_(isolate_); perform_cleanup_(isolate_);
DCHECK(!IsInGC()); DCHECK(InAtomicMarkingPause());
SetGCState(kGCRunning);
Heap().MakeConsistentForGC(); Heap().MakeConsistentForGC();
Heap().FlushHeapDoesNotContainCacheIfNeeded(); Heap().FlushHeapDoesNotContainCacheIfNeeded();
Heap().ClearArenaAges(); Heap().ClearArenaAges();
......
...@@ -150,10 +150,6 @@ class PLATFORM_EXPORT ThreadState { ...@@ -150,10 +150,6 @@ class PLATFORM_EXPORT ThreadState {
kPreciseGCScheduled, kPreciseGCScheduled,
kFullGCScheduled, kFullGCScheduled,
kPageNavigationGCScheduled, kPageNavigationGCScheduled,
kGCRunning,
kSweeping,
kSweepingAndIdleGCScheduled,
kSweepingAndPreciseGCScheduled,
}; };
// The phase that the GC is in. The GCPhase will not return kNone for mutators // The phase that the GC is in. The GCPhase will not return kNone for mutators
...@@ -263,17 +259,13 @@ class PLATFORM_EXPORT ThreadState { ...@@ -263,17 +259,13 @@ class PLATFORM_EXPORT ThreadState {
void SchedulePageNavigationGCIfNeeded(float estimated_removal_ratio); void SchedulePageNavigationGCIfNeeded(float estimated_removal_ratio);
void SchedulePageNavigationGC(); void SchedulePageNavigationGC();
void ScheduleGCIfNeeded(); void ScheduleGCIfNeeded();
void PostIdleGCTask();
void WillStartV8GC(BlinkGC::V8GCType); void WillStartV8GC(BlinkGC::V8GCType);
void SetGCState(GCState); void SetGCState(GCState);
GCState GcState() const { return gc_state_; } GCState GcState() const { return gc_state_; }
void SetGCPhase(GCPhase); void SetGCPhase(GCPhase);
bool IsInGC() const { return GcState() == kGCRunning; }
bool IsMarkingInProgress() const { return gc_phase_ == GCPhase::kMarking; } bool IsMarkingInProgress() const { return gc_phase_ == GCPhase::kMarking; }
bool IsSweepingInProgress() const { bool IsSweepingInProgress() const { return gc_phase_ == GCPhase::kSweeping; }
return GcState() == kSweeping ||
GcState() == kSweepingAndPreciseGCScheduled ||
GcState() == kSweepingAndIdleGCScheduled;
}
// Incremental GC. // Incremental GC.
...@@ -285,11 +277,6 @@ class PLATFORM_EXPORT ThreadState { ...@@ -285,11 +277,6 @@ class PLATFORM_EXPORT ThreadState {
void IncrementalMarkingStep(); void IncrementalMarkingStep();
void IncrementalMarkingFinalize(); void IncrementalMarkingFinalize();
bool IsIncrementalMarkingInProgress() const {
return GcState() == kIncrementalMarkingStepScheduled ||
GcState() == kIncrementalMarkingFinalizeScheduled;
}
// A GC runs in the following sequence. // A GC runs in the following sequence.
// //
// 1) preGC() is called. // 1) preGC() is called.
...@@ -300,12 +287,6 @@ class PLATFORM_EXPORT ThreadState { ...@@ -300,12 +287,6 @@ class PLATFORM_EXPORT ThreadState {
// 4) Lazy sweeping sweeps heaps incrementally. completeSweep() may be called // 4) Lazy sweeping sweeps heaps incrementally. completeSweep() may be called
// to complete the sweeping. // to complete the sweeping.
// 5) postSweep() is called. // 5) postSweep() is called.
//
// Notes:
// - The world is stopped between 1) and 3).
// - isInGC() returns true between 1) and 3).
// - isSweepingInProgress() returns true while any sweeping operation is
// running.
void MarkPhasePrologue(BlinkGC::StackState, void MarkPhasePrologue(BlinkGC::StackState,
BlinkGC::MarkingType, BlinkGC::MarkingType,
BlinkGC::GCReason); BlinkGC::GCReason);
......
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