| OLD | NEW |
| 1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "src/heap/gc-idle-time-handler.h" | 5 #include "src/heap/gc-idle-time-handler.h" |
| 6 #include "src/heap/gc-tracer.h" | 6 #include "src/heap/gc-tracer.h" |
| 7 #include "src/utils.h" | 7 #include "src/utils.h" |
| 8 | 8 |
| 9 namespace v8 { | 9 namespace v8 { |
| 10 namespace internal { | 10 namespace internal { |
| (...skipping 28 matching lines...) Expand all Loading... |
| 39 size_t size_of_objects, size_t mark_compact_speed_in_bytes_per_ms) { | 39 size_t size_of_objects, size_t mark_compact_speed_in_bytes_per_ms) { |
| 40 if (mark_compact_speed_in_bytes_per_ms == 0) { | 40 if (mark_compact_speed_in_bytes_per_ms == 0) { |
| 41 mark_compact_speed_in_bytes_per_ms = kInitialConservativeMarkCompactSpeed; | 41 mark_compact_speed_in_bytes_per_ms = kInitialConservativeMarkCompactSpeed; |
| 42 } | 42 } |
| 43 size_t result = size_of_objects / mark_compact_speed_in_bytes_per_ms; | 43 size_t result = size_of_objects / mark_compact_speed_in_bytes_per_ms; |
| 44 return Min(result, kMaxMarkCompactTimeInMs); | 44 return Min(result, kMaxMarkCompactTimeInMs); |
| 45 } | 45 } |
| 46 | 46 |
| 47 | 47 |
| 48 GCIdleTimeAction GCIdleTimeHandler::Compute(size_t idle_time_in_ms, | 48 GCIdleTimeAction GCIdleTimeHandler::Compute(size_t idle_time_in_ms, |
| 49 HeapState heap_state, | 49 HeapState heap_state) { |
| 50 GCTracer* gc_tracer) { | |
| 51 if (IsIdleRoundFinished()) { | 50 if (IsIdleRoundFinished()) { |
| 52 if (EnoughGarbageSinceLastIdleRound() || heap_state.contexts_disposed > 0) { | 51 if (EnoughGarbageSinceLastIdleRound() || heap_state.contexts_disposed > 0) { |
| 53 StartIdleRound(); | 52 StartIdleRound(); |
| 54 } else { | 53 } else { |
| 55 return GCIdleTimeAction::Nothing(); | 54 return GCIdleTimeAction::Nothing(); |
| 56 } | 55 } |
| 57 } | 56 } |
| 58 if (heap_state.incremental_marking_stopped) { | 57 if (heap_state.incremental_marking_stopped) { |
| 59 size_t speed = | 58 if (idle_time_in_ms >= EstimateMarkCompactTime( |
| 60 static_cast<size_t>(gc_tracer->MarkCompactSpeedInBytesPerMillisecond()); | 59 heap_state.size_of_objects, |
| 61 if (idle_time_in_ms >= | 60 heap_state.mark_compact_speed_in_bytes_per_ms)) { |
| 62 EstimateMarkCompactTime(heap_state.size_of_objects, speed)) { | |
| 63 // If there are no more than two GCs left in this idle round and we are | 61 // If there are no more than two GCs left in this idle round and we are |
| 64 // allowed to do a full GC, then make those GCs full in order to compact | 62 // allowed to do a full GC, then make those GCs full in order to compact |
| 65 // the code space. | 63 // the code space. |
| 66 // TODO(ulan): Once we enable code compaction for incremental marking, we | 64 // TODO(ulan): Once we enable code compaction for incremental marking, we |
| 67 // can get rid of this special case and always start incremental marking. | 65 // can get rid of this special case and always start incremental marking. |
| 68 int remaining_mark_sweeps = | 66 int remaining_mark_sweeps = |
| 69 kMaxMarkCompactsInIdleRound - mark_compacts_since_idle_round_started_; | 67 kMaxMarkCompactsInIdleRound - mark_compacts_since_idle_round_started_; |
| 70 if (heap_state.contexts_disposed > 0 || remaining_mark_sweeps <= 2 || | 68 if (heap_state.contexts_disposed > 0 || remaining_mark_sweeps <= 2 || |
| 71 !heap_state.can_start_incremental_marking) { | 69 !heap_state.can_start_incremental_marking) { |
| 72 return GCIdleTimeAction::FullGC(); | 70 return GCIdleTimeAction::FullGC(); |
| 73 } | 71 } |
| 74 } | 72 } |
| 75 if (!heap_state.can_start_incremental_marking) { | 73 if (!heap_state.can_start_incremental_marking) { |
| 76 return GCIdleTimeAction::Nothing(); | 74 return GCIdleTimeAction::Nothing(); |
| 77 } | 75 } |
| 78 } | 76 } |
| 79 // TODO(hpayer): Estimate finalize sweeping time. | 77 // TODO(hpayer): Estimate finalize sweeping time. |
| 80 if (heap_state.sweeping_in_progress && | 78 if (heap_state.sweeping_in_progress && |
| 81 idle_time_in_ms >= kMinTimeForFinalizeSweeping) { | 79 idle_time_in_ms >= kMinTimeForFinalizeSweeping) { |
| 82 return GCIdleTimeAction::FinalizeSweeping(); | 80 return GCIdleTimeAction::FinalizeSweeping(); |
| 83 } | 81 } |
| 84 | 82 |
| 85 intptr_t speed = gc_tracer->IncrementalMarkingSpeedInBytesPerMillisecond(); | 83 size_t step_size = EstimateMarkingStepSize( |
| 86 size_t step_size = | 84 idle_time_in_ms, heap_state.incremental_marking_speed_in_bytes_per_ms); |
| 87 static_cast<size_t>(EstimateMarkingStepSize(idle_time_in_ms, speed)); | |
| 88 return GCIdleTimeAction::IncrementalMarking(step_size); | 85 return GCIdleTimeAction::IncrementalMarking(step_size); |
| 89 } | 86 } |
| 90 } | 87 } |
| 91 } | 88 } |
| OLD | NEW |