Index: src/heap/incremental-marking.cc |
diff --git a/src/heap/incremental-marking.cc b/src/heap/incremental-marking.cc |
index d72423a60aa81619516404c2995ebc26df4e60a2..84a439d2aedfa58308d260a39ae8f1d70810d7f8 100644 |
--- a/src/heap/incremental-marking.cc |
+++ b/src/heap/incremental-marking.cc |
@@ -27,6 +27,7 @@ IncrementalMarking::IncrementalMarking(Heap* heap) |
should_hurry_(false), |
marking_speed_(0), |
allocated_(0), |
+ idle_marking_delay_counter_(0), |
no_marking_scope_depth_(0), |
unscanned_bytes_of_large_object_(0) {} |
@@ -893,7 +894,8 @@ void IncrementalMarking::SpeedUp() { |
void IncrementalMarking::Step(intptr_t allocated_bytes, CompletionAction action, |
- bool force_marking) { |
+ ForceMarkingAction marking, |
+ ForceCompletionAction completion) { |
if (heap_->gc_state() != Heap::NOT_IN_GC || !FLAG_incremental_marking || |
!FLAG_incremental_marking_steps || |
(state_ != SWEEPING && state_ != MARKING)) { |
@@ -902,7 +904,7 @@ void IncrementalMarking::Step(intptr_t allocated_bytes, CompletionAction action, |
allocated_ += allocated_bytes; |
- if (!force_marking && allocated_ < kAllocatedThreshold && |
+ if (marking == DO_NOT_FORCE_MARKING && allocated_ < kAllocatedThreshold && |
write_barriers_invoked_since_last_step_ < |
kWriteBarriersInvokedThreshold) { |
return; |
@@ -943,7 +945,14 @@ void IncrementalMarking::Step(intptr_t allocated_bytes, CompletionAction action, |
} |
} else if (state_ == MARKING) { |
bytes_processed = ProcessMarkingDeque(bytes_to_process); |
- if (marking_deque_.IsEmpty()) MarkingComplete(action); |
+ if (marking_deque_.IsEmpty()) { |
+ if (completion == FORCE_COMPLETION || |
+ IsIdleMarkingDelayCounterLimitReached()) { |
+ MarkingComplete(action); |
+ } else { |
+ IncrementIdleMarkingDelayCounter(); |
+ } |
+ } |
} |
steps_count_++; |
@@ -978,5 +987,20 @@ void IncrementalMarking::ResetStepCounters() { |
int64_t IncrementalMarking::SpaceLeftInOldSpace() { |
return heap_->MaxOldGenerationSize() - heap_->PromotedSpaceSizeOfObjects(); |
} |
+ |
+ |
+bool IncrementalMarking::IsIdleMarkingDelayCounterLimitReached() { |
+ return idle_marking_delay_counter_ >= kMaxIdleMarkingDelayCounter; |
+} |
+ |
+ |
+void IncrementalMarking::IncrementIdleMarkingDelayCounter() { |
+ idle_marking_delay_counter_++; |
+} |
+ |
+ |
+void IncrementalMarking::ClearIdleMarkingDelayCounter() { |
+ idle_marking_delay_counter_ = 0; |
+} |
} |
} // namespace v8::internal |