Index: src/heap/gc-idle-time-handler.cc |
diff --git a/src/heap/gc-idle-time-handler.cc b/src/heap/gc-idle-time-handler.cc |
index 83e95acc0526f5c46740b1e8ddc4f32619577a14..904d9190707494cc5b380f6e382e70a77e211449 100644 |
--- a/src/heap/gc-idle-time-handler.cc |
+++ b/src/heap/gc-idle-time-handler.cc |
@@ -10,10 +10,8 @@ |
namespace v8 { |
namespace internal { |
- |
const double GCIdleTimeHandler::kConservativeTimeRatio = 0.9; |
- |
intptr_t GCIdleTimeHandler::EstimateMarkingStepSize( |
int idle_time_in_ms, intptr_t marking_speed_in_bytes_per_ms) { |
DCHECK(idle_time_in_ms > 0); |
@@ -33,5 +31,50 @@ intptr_t GCIdleTimeHandler::EstimateMarkingStepSize( |
return static_cast<intptr_t>(marking_step_size * |
GCIdleTimeHandler::kConservativeTimeRatio); |
} |
+ |
+ |
+int GCIdleTimeHandler::EstimateMarkSweepTime( |
+ intptr_t size_of_objects, intptr_t mark_sweep_speed_in_bytes_per_ms) { |
+ const intptr_t kInitialConservativeMarkSweepSpeed = 2 * MB; |
+ const intptr_t kMaxTimeInMs = 1000000; |
+ if (mark_sweep_speed_in_bytes_per_ms == 0) { |
+ mark_sweep_speed_in_bytes_per_ms = kInitialConservativeMarkSweepSpeed; |
+ } |
+ intptr_t result = size_of_objects / mark_sweep_speed_in_bytes_per_ms; |
+ return static_cast<int>(Min(result, kMaxTimeInMs)); |
+} |
+ |
+ |
+GCIdleTimeAction GCIdleTimeHandler::Compute(int idle_time_in_ms, |
+ int contexts_disposed, |
+ intptr_t size_of_objects, |
+ bool incremental_marking_stopped, |
+ GCTracer* gc_tracer) { |
+ if (IsIdleRoundFinished()) { |
+ if (EnoughGarbageSinceLastIdleRound() || contexts_disposed > 0) { |
+ StartIdleRound(); |
+ } else { |
+ return GCIdleTimeAction::Nothing(); |
+ } |
+ } |
+ if (incremental_marking_stopped) { |
+ intptr_t speed = gc_tracer->MaxMarkSweepSpeedInBytesPerMillisecond(); |
Hannes Payer (out of office)
2014/08/20 18:24:11
Why are we taking the maximum?
ulan
2014/08/21 08:45:19
Good catch, it should be either minimum or average
|
+ if (idle_time_in_ms >= EstimateMarkSweepTime(size_of_objects, speed)) { |
+ // If there are no more than two GCs left in this idle round and we are |
+ // allowed to do a full GC, then make those GCs full in order to compact |
+ // the code space. |
+ // TODO(ulan): Once we enable code compaction for incremental marking, we |
+ // can get rid of this special case and always start incremental marking. |
+ int remaining_mark_sweeps = |
+ kMaxMarkSweepsInIdleRound - mark_sweeps_since_idle_round_started_; |
+ if (contexts_disposed > 0 || remaining_mark_sweeps <= 2) { |
+ return GCIdleTimeAction::FullGC(); |
+ } |
+ } |
+ } |
+ intptr_t speed = gc_tracer->IncrementalMarkingSpeedInBytesPerMillisecond(); |
+ intptr_t step_size = EstimateMarkingStepSize(idle_time_in_ms, speed); |
+ return GCIdleTimeAction::IncrementalMarking(step_size); |
+} |
} |
} |