OLD | NEW |
1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 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 #ifndef V8_HEAP_memory_reducer_H | 5 #ifndef V8_HEAP_memory_reducer_H |
6 #define V8_HEAP_memory_reducer_H | 6 #define V8_HEAP_memory_reducer_H |
7 | 7 |
8 #include "include/v8-platform.h" | 8 #include "include/v8-platform.h" |
9 #include "src/base/macros.h" | 9 #include "src/base/macros.h" |
10 #include "src/cancelable-task.h" | 10 #include "src/cancelable-task.h" |
| 11 #include "src/globals.h" |
11 | 12 |
12 namespace v8 { | 13 namespace v8 { |
13 namespace internal { | 14 namespace internal { |
14 | 15 |
15 class Heap; | 16 class Heap; |
16 | 17 |
17 | 18 |
18 // The goal of the MemoryReducer class is to detect transition of the mutator | 19 // The goal of the MemoryReducer class is to detect transition of the mutator |
19 // from high allocation phase to low allocation phase and to collect potential | 20 // from high allocation phase to low allocation phase and to collect potential |
20 // garbage created in the high allocation phase. | 21 // garbage created in the high allocation phase. |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 // (n > 1 and there is no more garbage to be collected) or | 73 // (n > 1 and there is no more garbage to be collected) or |
73 // n == kMaxNumberOfGCs. | 74 // n == kMaxNumberOfGCs. |
74 // RUN n t -> WAIT n (now_ms + short_delay_ms) now_ms happens: | 75 // RUN n t -> WAIT n (now_ms + short_delay_ms) now_ms happens: |
75 // - at end of the incremental GC initiated by the MemoryReducer if | 76 // - at end of the incremental GC initiated by the MemoryReducer if |
76 // (n == 1 or there is more garbage to be collected) and | 77 // (n == 1 or there is more garbage to be collected) and |
77 // n < kMaxNumberOfGCs. | 78 // n < kMaxNumberOfGCs. |
78 // | 79 // |
79 // now_ms is the current time, | 80 // now_ms is the current time, |
80 // t' is t if the current event is not a GC event and is now_ms otherwise, | 81 // t' is t if the current event is not a GC event and is now_ms otherwise, |
81 // long_delay_ms, short_delay_ms, and watchdog_delay_ms are constants. | 82 // long_delay_ms, short_delay_ms, and watchdog_delay_ms are constants. |
82 class MemoryReducer { | 83 class V8_EXPORT_PRIVATE MemoryReducer { |
83 public: | 84 public: |
84 enum Action { kDone, kWait, kRun }; | 85 enum Action { kDone, kWait, kRun }; |
85 | 86 |
86 struct State { | 87 struct State { |
87 State(Action action, int started_gcs, double next_gc_start_ms, | 88 State(Action action, int started_gcs, double next_gc_start_ms, |
88 double last_gc_time_ms) | 89 double last_gc_time_ms) |
89 : action(action), | 90 : action(action), |
90 started_gcs(started_gcs), | 91 started_gcs(started_gcs), |
91 next_gc_start_ms(next_gc_start_ms), | 92 next_gc_start_ms(next_gc_start_ms), |
92 last_gc_time_ms(last_gc_time_ms) {} | 93 last_gc_time_ms(last_gc_time_ms) {} |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
158 | 159 |
159 // Used in cctest. | 160 // Used in cctest. |
160 friend class HeapTester; | 161 friend class HeapTester; |
161 DISALLOW_COPY_AND_ASSIGN(MemoryReducer); | 162 DISALLOW_COPY_AND_ASSIGN(MemoryReducer); |
162 }; | 163 }; |
163 | 164 |
164 } // namespace internal | 165 } // namespace internal |
165 } // namespace v8 | 166 } // namespace v8 |
166 | 167 |
167 #endif // V8_HEAP_memory_reducer_H | 168 #endif // V8_HEAP_memory_reducer_H |
OLD | NEW |