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(int idle_time_in_ms, | 48 GCIdleTimeAction GCIdleTimeHandler::Compute(int idle_time_in_ms, |
49 int contexts_disposed, | 49 HeapState heap_state, |
50 size_t size_of_objects, | |
51 bool incremental_marking_stopped, | |
52 GCTracer* gc_tracer) { | 50 GCTracer* gc_tracer) { |
53 if (IsIdleRoundFinished()) { | 51 if (IsIdleRoundFinished()) { |
54 if (EnoughGarbageSinceLastIdleRound() || contexts_disposed > 0) { | 52 if (EnoughGarbageSinceLastIdleRound() || heap_state.contexts_disposed > 0) { |
55 StartIdleRound(); | 53 StartIdleRound(); |
56 } else { | 54 } else { |
57 return GCIdleTimeAction::Nothing(); | 55 return GCIdleTimeAction::Nothing(); |
58 } | 56 } |
59 } | 57 } |
60 if (incremental_marking_stopped) { | 58 if (heap_state.incremental_marking_stopped) { |
61 size_t speed = | 59 size_t speed = |
62 static_cast<size_t>(gc_tracer->MarkCompactSpeedInBytesPerMillisecond()); | 60 static_cast<size_t>(gc_tracer->MarkCompactSpeedInBytesPerMillisecond()); |
63 if (idle_time_in_ms >= | 61 if (idle_time_in_ms >= static_cast<int>(EstimateMarkCompactTime( |
64 static_cast<int>(EstimateMarkCompactTime(size_of_objects, speed))) { | 62 heap_state.size_of_objects, speed))) { |
65 // If there are no more than two GCs left in this idle round and we are | 63 // If there are no more than two GCs left in this idle round and we are |
66 // allowed to do a full GC, then make those GCs full in order to compact | 64 // allowed to do a full GC, then make those GCs full in order to compact |
67 // the code space. | 65 // the code space. |
68 // TODO(ulan): Once we enable code compaction for incremental marking, we | 66 // TODO(ulan): Once we enable code compaction for incremental marking, we |
69 // can get rid of this special case and always start incremental marking. | 67 // can get rid of this special case and always start incremental marking. |
70 int remaining_mark_sweeps = | 68 int remaining_mark_sweeps = |
71 kMaxMarkCompactsInIdleRound - mark_compacts_since_idle_round_started_; | 69 kMaxMarkCompactsInIdleRound - mark_compacts_since_idle_round_started_; |
72 if (contexts_disposed > 0 || remaining_mark_sweeps <= 2) { | 70 if (heap_state.contexts_disposed > 0 || remaining_mark_sweeps <= 2 || |
| 71 !heap_state.can_start_incremental_marking) { |
73 return GCIdleTimeAction::FullGC(); | 72 return GCIdleTimeAction::FullGC(); |
74 } | 73 } |
75 } | 74 } |
| 75 if (!heap_state.can_start_incremental_marking) { |
| 76 return GCIdleTimeAction::Nothing(); |
| 77 } |
76 } | 78 } |
77 intptr_t speed = gc_tracer->IncrementalMarkingSpeedInBytesPerMillisecond(); | 79 intptr_t speed = gc_tracer->IncrementalMarkingSpeedInBytesPerMillisecond(); |
78 size_t step_size = | 80 size_t step_size = |
79 static_cast<size_t>(EstimateMarkingStepSize(idle_time_in_ms, speed)); | 81 static_cast<size_t>(EstimateMarkingStepSize(idle_time_in_ms, speed)); |
80 return GCIdleTimeAction::IncrementalMarking(step_size); | 82 return GCIdleTimeAction::IncrementalMarking(step_size); |
81 } | 83 } |
82 } | 84 } |
83 } | 85 } |
OLD | NEW |