Chromium Code Reviews| 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 5ff4017c233f071b742974b9fcf242609de03de3..81ed4c48a41b71d20ca73ba6eb54d544326eb5dd 100644 |
| --- a/src/heap/gc-idle-time-handler.cc |
| +++ b/src/heap/gc-idle-time-handler.cc |
| @@ -3,11 +3,11 @@ |
| // found in the LICENSE file. |
| #include "src/heap/gc-idle-time-handler.h" |
| +#include "src/heap/gc-tracer.h" |
| namespace v8 { |
| namespace internal { |
| - |
| const double GCIdleTimeHandler::kConservativeTimeRatio = 0.9; |
| @@ -32,5 +32,51 @@ size_t GCIdleTimeHandler::EstimateMarkingStepSize( |
| return static_cast<size_t>(marking_step_size * |
| GCIdleTimeHandler::kConservativeTimeRatio); |
| } |
| + |
| + |
| +int GCIdleTimeHandler::EstimateMarkSweepTime( |
| + intptr_t size_of_objects, intptr_t mark_sweep_speed_in_bytes_per_ms) { |
|
Hannes Payer (out of office)
2014/08/21 09:47:53
Can we make the parameters size_t, c.f. EstimateMa
ulan
2014/08/21 11:44:00
Done.
|
| + const intptr_t kInitialConservativeMarkSweepSpeed = 2 * MB; |
| + const int kMaxTimeInMs = 1000000; |
|
Hannes Payer (out of office)
2014/08/21 09:47:53
I think these constant should be in GCIdleTImeHand
ulan
2014/08/21 11:44:00
Done.
|
| + 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; |
| + if (result > kMaxTimeInMs) return kMaxTimeInMs; |
| + return static_cast<int>(result); |
| +} |
| + |
| + |
| +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->MarkCompactSpeedInBytesPerMillisecond(); |
| + 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 = |
| + kMaxMarkCompactsInIdleRound - mark_compacts_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); |
| +} |
| } |
| } |