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 { |
11 | 11 |
12 const double GCIdleTimeHandler::kConservativeTimeRatio = 0.9; | 12 const double GCIdleTimeHandler::kConservativeTimeRatio = 0.9; |
13 const size_t GCIdleTimeHandler::kMaxMarkCompactTimeInMs = 1000; | 13 const size_t GCIdleTimeHandler::kMaxMarkCompactTimeInMs = 1000; |
14 const size_t GCIdleTimeHandler::kMinTimeForFinalizeSweeping = 100; | 14 const size_t GCIdleTimeHandler::kMinTimeForFinalizeSweeping = 100; |
15 const int GCIdleTimeHandler::kMaxMarkCompactsInIdleRound = 7; | 15 const int GCIdleTimeHandler::kMaxMarkCompactsInIdleRound = 7; |
16 const int GCIdleTimeHandler::kIdleScavengeThreshold = 5; | 16 const int GCIdleTimeHandler::kIdleScavengeThreshold = 5; |
17 | 17 |
18 | 18 |
19 void GCIdleTimeAction::Print() { | 19 void GCIdleTimeAction::Print() { |
20 switch (type) { | 20 switch (type) { |
| 21 case DONE: |
| 22 PrintF("done"); |
| 23 break; |
21 case DO_NOTHING: | 24 case DO_NOTHING: |
22 PrintF("no action"); | 25 PrintF("no action"); |
23 break; | 26 break; |
24 case DO_INCREMENTAL_MARKING: | 27 case DO_INCREMENTAL_MARKING: |
25 PrintF("incremental marking with step %" V8_PTR_PREFIX "d", parameter); | 28 PrintF("incremental marking with step %" V8_PTR_PREFIX "d", parameter); |
26 break; | 29 break; |
27 case DO_SCAVENGE: | 30 case DO_SCAVENGE: |
28 PrintF("scavenge"); | 31 PrintF("scavenge"); |
29 break; | 32 break; |
30 case DO_FULL_GC: | 33 case DO_FULL_GC: |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 return Min(result, kMaxMarkCompactTimeInMs); | 70 return Min(result, kMaxMarkCompactTimeInMs); |
68 } | 71 } |
69 | 72 |
70 | 73 |
71 GCIdleTimeAction GCIdleTimeHandler::Compute(size_t idle_time_in_ms, | 74 GCIdleTimeAction GCIdleTimeHandler::Compute(size_t idle_time_in_ms, |
72 HeapState heap_state) { | 75 HeapState heap_state) { |
73 if (IsIdleRoundFinished()) { | 76 if (IsIdleRoundFinished()) { |
74 if (EnoughGarbageSinceLastIdleRound() || heap_state.contexts_disposed > 0) { | 77 if (EnoughGarbageSinceLastIdleRound() || heap_state.contexts_disposed > 0) { |
75 StartIdleRound(); | 78 StartIdleRound(); |
76 } else { | 79 } else { |
77 return GCIdleTimeAction::Nothing(); | 80 return GCIdleTimeAction::Done(); |
78 } | 81 } |
79 } | 82 } |
80 if (heap_state.incremental_marking_stopped) { | 83 if (heap_state.incremental_marking_stopped) { |
81 size_t estimated_time_in_ms = | 84 size_t estimated_time_in_ms = |
82 EstimateMarkCompactTime(heap_state.size_of_objects, | 85 EstimateMarkCompactTime(heap_state.size_of_objects, |
83 heap_state.mark_compact_speed_in_bytes_per_ms); | 86 heap_state.mark_compact_speed_in_bytes_per_ms); |
84 if (idle_time_in_ms >= estimated_time_in_ms || | 87 if (idle_time_in_ms >= estimated_time_in_ms || |
85 (heap_state.size_of_objects < kSmallHeapSize && | 88 (heap_state.size_of_objects < kSmallHeapSize && |
86 heap_state.contexts_disposed > 0)) { | 89 heap_state.contexts_disposed > 0)) { |
87 // If there are no more than two GCs left in this idle round and we are | 90 // If there are no more than two GCs left in this idle round and we are |
(...skipping 17 matching lines...) Expand all Loading... |
105 idle_time_in_ms >= kMinTimeForFinalizeSweeping) { | 108 idle_time_in_ms >= kMinTimeForFinalizeSweeping) { |
106 return GCIdleTimeAction::FinalizeSweeping(); | 109 return GCIdleTimeAction::FinalizeSweeping(); |
107 } | 110 } |
108 | 111 |
109 size_t step_size = EstimateMarkingStepSize( | 112 size_t step_size = EstimateMarkingStepSize( |
110 idle_time_in_ms, heap_state.incremental_marking_speed_in_bytes_per_ms); | 113 idle_time_in_ms, heap_state.incremental_marking_speed_in_bytes_per_ms); |
111 return GCIdleTimeAction::IncrementalMarking(step_size); | 114 return GCIdleTimeAction::IncrementalMarking(step_size); |
112 } | 115 } |
113 } | 116 } |
114 } | 117 } |
OLD | NEW |