diff --git a/src/heap/heap.cc b/src/heap/heap.cc index 82589c7fd9..38a31bc210 100644 --- a/src/heap/heap.cc +++ b/src/heap/heap.cc @@ -874,7 +874,8 @@ bool Heap::CollectGarbage(GarbageCollector collector, const char* gc_reason, // Start incremental marking for the next cycle. The heap snapshot // generator needs incremental marking to stay off after it aborted. if (!mark_compact_collector()->abort_incremental_marking() && - WorthActivatingIncrementalMarking()) { + incremental_marking()->IsStopped() && + incremental_marking()->ShouldActivateEvenWithoutIdleNotification()) { incremental_marking()->Start(); } @@ -4545,12 +4546,6 @@ bool Heap::TryFinalizeIdleIncrementalMarking( } -bool Heap::WorthActivatingIncrementalMarking() { - return incremental_marking()->IsStopped() && - incremental_marking()->ShouldActivate(); -} - - static double MonotonicallyIncreasingTimeInMs() { return V8::GetCurrentPlatform()->MonotonicallyIncreasingTime() * static_cast(base::Time::kMillisecondsPerSecond); @@ -4588,8 +4583,8 @@ bool Heap::IdleNotification(double deadline_in_seconds) { } heap_state.can_start_incremental_marking = - incremental_marking()->WorthActivating() && - NextGCIsLikelyToBeFull(limit) && FLAG_incremental_marking && + incremental_marking()->CanBeActivated() && + HeapIsFullEnoughToStartIncrementalMarking(limit) && !mark_compact_collector()->sweeping_in_progress(); heap_state.sweeping_in_progress = mark_compact_collector()->sweeping_in_progress(); diff --git a/src/heap/heap.h b/src/heap/heap.h index 5dfae06c3a..4bcfcbb80a 100644 --- a/src/heap/heap.h +++ b/src/heap/heap.h @@ -1241,9 +1241,7 @@ class Heap { survived_since_last_expansion_ += survived; } - inline bool NextGCIsLikelyToBeFull(intptr_t limit) { - if (FLAG_gc_global) return true; - + inline bool HeapIsFullEnoughToStartIncrementalMarking(intptr_t limit) { if (FLAG_stress_compaction && (gc_count_ & 1) != 0) return true; intptr_t adjusted_allocation_limit = limit - new_space_.Capacity(); @@ -2083,8 +2081,6 @@ class Heap { double idle_time_in_ms, size_t size_of_objects, size_t mark_compact_speed_in_bytes_per_ms); - bool WorthActivatingIncrementalMarking(); - void ClearObjectStats(bool clear_last_time_stats = false); inline void UpdateAllocationsHash(HeapObject* object); diff --git a/src/heap/incremental-marking.cc b/src/heap/incremental-marking.cc index ef2e113785..17c609c3f6 100644 --- a/src/heap/incremental-marking.cc +++ b/src/heap/incremental-marking.cc @@ -386,9 +386,9 @@ void IncrementalMarking::ActivateIncrementalWriteBarrier() { } -bool IncrementalMarking::ShouldActivate() { - return WorthActivating() && - heap_->NextGCIsLikelyToBeFull( +bool IncrementalMarking::ShouldActivateEvenWithoutIdleNotification() { + return CanBeActivated() && + heap_->HeapIsFullEnoughToStartIncrementalMarking( heap_->old_generation_allocation_limit()); } @@ -396,7 +396,7 @@ bool IncrementalMarking::ShouldActivate() { bool IncrementalMarking::WasActivated() { return was_activated_; } -bool IncrementalMarking::WorthActivating() { +bool IncrementalMarking::CanBeActivated() { #ifndef DEBUG static const intptr_t kActivationThreshold = 8 * MB; #else @@ -407,6 +407,7 @@ bool IncrementalMarking::WorthActivating() { // Only start incremental marking in a safe state: 1) when incremental // marking is turned on, 2) when we are currently not in a GC, and // 3) when we are currently not serializing or deserializing the heap. + // Don't switch on for very small heaps. return FLAG_incremental_marking && FLAG_incremental_marking_steps && heap_->gc_state() == Heap::NOT_IN_GC && heap_->deserialization_complete() && @@ -814,7 +815,7 @@ void IncrementalMarking::Epilogue() { void IncrementalMarking::OldSpaceStep(intptr_t allocated) { - if (IsStopped() && ShouldActivate()) { + if (IsStopped() && ShouldActivateEvenWithoutIdleNotification()) { Start(); } else { Step(allocated * kOldSpaceAllocationMarkingFactor, GC_VIA_STACK_GUARD); diff --git a/src/heap/incremental-marking.h b/src/heap/incremental-marking.h index 03642c1020..51633233fe 100644 --- a/src/heap/incremental-marking.h +++ b/src/heap/incremental-marking.h @@ -64,9 +64,9 @@ class IncrementalMarking { GCRequestType request_type() const { return request_type_; } - bool WorthActivating(); + bool CanBeActivated(); - bool ShouldActivate(); + bool ShouldActivateEvenWithoutIdleNotification(); bool WasActivated();