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 = 1000000; | 13 const size_t GCIdleTimeHandler::kMaxMarkCompactTimeInMs = 1000000; |
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() { |
| 20 switch (type) { |
| 21 case DO_NOTHING: |
| 22 PrintF("no action"); |
| 23 break; |
| 24 case DO_INCREMENTAL_MARKING: |
| 25 PrintF("incremental marking with step %" V8_PTR_PREFIX "d", parameter); |
| 26 break; |
| 27 case DO_SCAVENGE: |
| 28 PrintF("scavenge"); |
| 29 break; |
| 30 case DO_FULL_GC: |
| 31 PrintF("full GC"); |
| 32 break; |
| 33 case DO_FINALIZE_SWEEPING: |
| 34 PrintF("finalize sweeping"); |
| 35 break; |
| 36 } |
| 37 } |
| 38 |
| 39 |
19 size_t GCIdleTimeHandler::EstimateMarkingStepSize( | 40 size_t GCIdleTimeHandler::EstimateMarkingStepSize( |
20 size_t idle_time_in_ms, size_t marking_speed_in_bytes_per_ms) { | 41 size_t idle_time_in_ms, size_t marking_speed_in_bytes_per_ms) { |
21 DCHECK(idle_time_in_ms > 0); | 42 DCHECK(idle_time_in_ms > 0); |
22 | 43 |
23 if (marking_speed_in_bytes_per_ms == 0) { | 44 if (marking_speed_in_bytes_per_ms == 0) { |
24 marking_speed_in_bytes_per_ms = kInitialConservativeMarkingSpeed; | 45 marking_speed_in_bytes_per_ms = kInitialConservativeMarkingSpeed; |
25 } | 46 } |
26 | 47 |
27 size_t marking_step_size = marking_speed_in_bytes_per_ms * idle_time_in_ms; | 48 size_t marking_step_size = marking_speed_in_bytes_per_ms * idle_time_in_ms; |
28 if (marking_step_size / marking_speed_in_bytes_per_ms != idle_time_in_ms) { | 49 if (marking_step_size / marking_speed_in_bytes_per_ms != idle_time_in_ms) { |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 idle_time_in_ms >= kMinTimeForFinalizeSweeping) { | 102 idle_time_in_ms >= kMinTimeForFinalizeSweeping) { |
82 return GCIdleTimeAction::FinalizeSweeping(); | 103 return GCIdleTimeAction::FinalizeSweeping(); |
83 } | 104 } |
84 | 105 |
85 size_t step_size = EstimateMarkingStepSize( | 106 size_t step_size = EstimateMarkingStepSize( |
86 idle_time_in_ms, heap_state.incremental_marking_speed_in_bytes_per_ms); | 107 idle_time_in_ms, heap_state.incremental_marking_speed_in_bytes_per_ms); |
87 return GCIdleTimeAction::IncrementalMarking(step_size); | 108 return GCIdleTimeAction::IncrementalMarking(step_size); |
88 } | 109 } |
89 } | 110 } |
90 } | 111 } |
OLD | NEW |