Index: src/incremental-marking.cc |
diff --git a/src/incremental-marking.cc b/src/incremental-marking.cc |
index 7aadd279dc6d4f739f2642515acbdb2e9673eb14..bacbb93ad2e8cb6a335c577e8ccf69ade8c82d63 100644 |
--- a/src/incremental-marking.cc |
+++ b/src/incremental-marking.cc |
@@ -490,10 +490,16 @@ bool IncrementalMarking::WorthActivating() { |
// debug tests run with incremental marking and some without. |
static const intptr_t kActivationThreshold = 0; |
#endif |
- |
+ // Only start incremental marking in a safe state: 1) when expose GC is |
+ // deactivated, 2) when incremental marking is turned on, 3) when we are |
+ // currently not in a GC, and 4) when we are currently not serializing |
+ // or deserializing the heap. |
return !FLAG_expose_gc && |
FLAG_incremental_marking && |
+ FLAG_incremental_marking_steps && |
+ heap_->gc_state() == Heap::NOT_IN_GC && |
!Serializer::enabled() && |
+ heap_->isolate()->IsInitialized() && |
heap_->PromotedSpaceSizeOfObjects() > kActivationThreshold; |
} |
@@ -561,7 +567,7 @@ void IncrementalMarking::UncommitMarkingDeque() { |
} |
-void IncrementalMarking::Start() { |
+void IncrementalMarking::Start(CompactionFlag flag) { |
if (FLAG_trace_incremental_marking) { |
PrintF("[IncrementalMarking] Start\n"); |
} |
@@ -575,7 +581,7 @@ void IncrementalMarking::Start() { |
ResetStepCounters(); |
if (heap_->IsSweepingComplete()) { |
- StartMarking(ALLOW_COMPACTION); |
+ StartMarking(flag); |
} else { |
if (FLAG_trace_incremental_marking) { |
PrintF("[IncrementalMarking] Start sweeping.\n"); |
@@ -866,17 +872,9 @@ void IncrementalMarking::MarkingComplete(CompletionAction action) { |
void IncrementalMarking::OldSpaceStep(intptr_t allocated) { |
if (IsStopped() && WorthActivating() && heap_->NextGCIsLikelyToBeFull()) { |
- // Only start incremental marking in a save state: 1) when we are not in |
- // a GC, 2) when we turned-on incremental marking, 3) when we are |
- // currently not serializing or deserializing the heap. |
- if (heap_->gc_state() != Heap::NOT_IN_GC || |
- !FLAG_incremental_marking || |
- !FLAG_incremental_marking_steps || |
- Serializer::enabled() || |
- !heap_->isolate()->IsInitialized()) { |
- return; |
- } |
- Start(); |
+ // TODO(hpayer): Let's play safe for now, but compaction should be |
+ // in principle possible. |
+ Start(PREVENT_COMPACTION); |
} else { |
Step(allocated * kFastMarking / kInitialMarkingSpeed, GC_VIA_STACK_GUARD); |
} |