OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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_INCREMENTAL_MARKING_H_ | 5 #ifndef V8_HEAP_INCREMENTAL_MARKING_H_ |
6 #define V8_HEAP_INCREMENTAL_MARKING_H_ | 6 #define V8_HEAP_INCREMENTAL_MARKING_H_ |
7 | 7 |
8 | 8 |
9 #include "src/execution.h" | 9 #include "src/execution.h" |
10 #include "src/heap/mark-compact.h" | 10 #include "src/heap/mark-compact.h" |
11 #include "src/objects.h" | 11 #include "src/objects.h" |
12 | 12 |
13 namespace v8 { | 13 namespace v8 { |
14 namespace internal { | 14 namespace internal { |
15 | 15 |
16 | 16 |
17 class IncrementalMarking { | 17 class IncrementalMarking { |
18 public: | 18 public: |
19 enum State { STOPPED, SWEEPING, MARKING, COMPLETE }; | 19 enum State { STOPPED, SWEEPING, MARKING, COMPLETE }; |
20 | 20 |
21 enum CompletionAction { GC_VIA_STACK_GUARD, NO_GC_VIA_STACK_GUARD }; | 21 enum CompletionAction { GC_VIA_STACK_GUARD, NO_GC_VIA_STACK_GUARD }; |
22 | 22 |
| 23 enum ForceMarkingAction { FORCE_MARKING, DO_NOT_FORCE_MARKING }; |
| 24 |
| 25 enum ForceCompletionAction { FORCE_COMPLETION, DO_NOT_FORCE_COMPLETION }; |
| 26 |
23 explicit IncrementalMarking(Heap* heap); | 27 explicit IncrementalMarking(Heap* heap); |
24 | 28 |
25 static void Initialize(); | 29 static void Initialize(); |
26 | 30 |
27 void TearDown(); | 31 void TearDown(); |
28 | 32 |
29 State state() { | 33 State state() { |
30 DCHECK(state_ == STOPPED || FLAG_incremental_marking); | 34 DCHECK(state_ == STOPPED || FLAG_incremental_marking); |
31 return state_; | 35 return state_; |
32 } | 36 } |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 static const intptr_t kInitialMarkingSpeed = 1; | 80 static const intptr_t kInitialMarkingSpeed = 1; |
77 // But if we are promoting a lot of data we need to mark faster to keep up | 81 // But if we are promoting a lot of data we need to mark faster to keep up |
78 // with the data that is entering the old space through promotion. | 82 // with the data that is entering the old space through promotion. |
79 static const intptr_t kFastMarking = 3; | 83 static const intptr_t kFastMarking = 3; |
80 // After this many steps we increase the marking/allocating factor. | 84 // After this many steps we increase the marking/allocating factor. |
81 static const intptr_t kMarkingSpeedAccellerationInterval = 1024; | 85 static const intptr_t kMarkingSpeedAccellerationInterval = 1024; |
82 // This is how much we increase the marking/allocating factor by. | 86 // This is how much we increase the marking/allocating factor by. |
83 static const intptr_t kMarkingSpeedAccelleration = 2; | 87 static const intptr_t kMarkingSpeedAccelleration = 2; |
84 static const intptr_t kMaxMarkingSpeed = 1000; | 88 static const intptr_t kMaxMarkingSpeed = 1000; |
85 | 89 |
| 90 // This is the upper bound for how many times we allow finalization of |
| 91 // incremental marking to be postponed. |
| 92 static const size_t kMaxIdleMarkingDelayCounter = 3; |
| 93 |
86 void OldSpaceStep(intptr_t allocated); | 94 void OldSpaceStep(intptr_t allocated); |
87 | 95 |
88 void Step(intptr_t allocated, CompletionAction action, | 96 intptr_t Step(intptr_t allocated, CompletionAction action, |
89 bool force_marking = false); | 97 ForceMarkingAction marking = DO_NOT_FORCE_MARKING, |
| 98 ForceCompletionAction completion = FORCE_COMPLETION); |
90 | 99 |
91 inline void RestartIfNotMarking() { | 100 inline void RestartIfNotMarking() { |
92 if (state_ == COMPLETE) { | 101 if (state_ == COMPLETE) { |
93 state_ = MARKING; | 102 state_ = MARKING; |
94 if (FLAG_trace_incremental_marking) { | 103 if (FLAG_trace_incremental_marking) { |
95 PrintF("[IncrementalMarking] Restarting (new grey objects)\n"); | 104 PrintF("[IncrementalMarking] Restarting (new grey objects)\n"); |
96 } | 105 } |
97 } | 106 } |
98 } | 107 } |
99 | 108 |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
158 void EnterNoMarkingScope() { no_marking_scope_depth_++; } | 167 void EnterNoMarkingScope() { no_marking_scope_depth_++; } |
159 | 168 |
160 void LeaveNoMarkingScope() { no_marking_scope_depth_--; } | 169 void LeaveNoMarkingScope() { no_marking_scope_depth_--; } |
161 | 170 |
162 void UncommitMarkingDeque(); | 171 void UncommitMarkingDeque(); |
163 | 172 |
164 void NotifyIncompleteScanOfObject(int unscanned_bytes) { | 173 void NotifyIncompleteScanOfObject(int unscanned_bytes) { |
165 unscanned_bytes_of_large_object_ = unscanned_bytes; | 174 unscanned_bytes_of_large_object_ = unscanned_bytes; |
166 } | 175 } |
167 | 176 |
| 177 void ClearIdleMarkingDelayCounter(); |
| 178 |
| 179 bool IsIdleMarkingDelayCounterLimitReached(); |
| 180 |
168 private: | 181 private: |
169 int64_t SpaceLeftInOldSpace(); | 182 int64_t SpaceLeftInOldSpace(); |
170 | 183 |
171 void SpeedUp(); | 184 void SpeedUp(); |
172 | 185 |
173 void ResetStepCounters(); | 186 void ResetStepCounters(); |
174 | 187 |
175 void StartMarking(CompactionFlag flag); | 188 void StartMarking(CompactionFlag flag); |
176 | 189 |
177 void ActivateIncrementalWriteBarrier(PagedSpace* space); | 190 void ActivateIncrementalWriteBarrier(PagedSpace* space); |
(...skipping 10 matching lines...) Expand all Loading... |
188 static void SetNewSpacePageFlags(NewSpacePage* chunk, bool is_marking); | 201 static void SetNewSpacePageFlags(NewSpacePage* chunk, bool is_marking); |
189 | 202 |
190 void EnsureMarkingDequeIsCommitted(); | 203 void EnsureMarkingDequeIsCommitted(); |
191 | 204 |
192 INLINE(void ProcessMarkingDeque()); | 205 INLINE(void ProcessMarkingDeque()); |
193 | 206 |
194 INLINE(intptr_t ProcessMarkingDeque(intptr_t bytes_to_process)); | 207 INLINE(intptr_t ProcessMarkingDeque(intptr_t bytes_to_process)); |
195 | 208 |
196 INLINE(void VisitObject(Map* map, HeapObject* obj, int size)); | 209 INLINE(void VisitObject(Map* map, HeapObject* obj, int size)); |
197 | 210 |
| 211 void IncrementIdleMarkingDelayCounter(); |
| 212 |
198 Heap* heap_; | 213 Heap* heap_; |
199 | 214 |
200 State state_; | 215 State state_; |
201 bool is_compacting_; | 216 bool is_compacting_; |
202 | 217 |
203 base::VirtualMemory* marking_deque_memory_; | 218 base::VirtualMemory* marking_deque_memory_; |
204 bool marking_deque_memory_committed_; | 219 bool marking_deque_memory_committed_; |
205 MarkingDeque marking_deque_; | 220 MarkingDeque marking_deque_; |
206 | 221 |
207 int steps_count_; | 222 int steps_count_; |
208 int64_t old_generation_space_available_at_start_of_incremental_; | 223 int64_t old_generation_space_available_at_start_of_incremental_; |
209 int64_t old_generation_space_used_at_start_of_incremental_; | 224 int64_t old_generation_space_used_at_start_of_incremental_; |
210 int64_t bytes_rescanned_; | 225 int64_t bytes_rescanned_; |
211 bool should_hurry_; | 226 bool should_hurry_; |
212 int marking_speed_; | 227 int marking_speed_; |
213 intptr_t bytes_scanned_; | 228 intptr_t bytes_scanned_; |
214 intptr_t allocated_; | 229 intptr_t allocated_; |
215 intptr_t write_barriers_invoked_since_last_step_; | 230 intptr_t write_barriers_invoked_since_last_step_; |
| 231 size_t idle_marking_delay_counter_; |
216 | 232 |
217 int no_marking_scope_depth_; | 233 int no_marking_scope_depth_; |
218 | 234 |
219 int unscanned_bytes_of_large_object_; | 235 int unscanned_bytes_of_large_object_; |
220 | 236 |
221 DISALLOW_IMPLICIT_CONSTRUCTORS(IncrementalMarking); | 237 DISALLOW_IMPLICIT_CONSTRUCTORS(IncrementalMarking); |
222 }; | 238 }; |
223 } | 239 } |
224 } // namespace v8::internal | 240 } // namespace v8::internal |
225 | 241 |
226 #endif // V8_HEAP_INCREMENTAL_MARKING_H_ | 242 #endif // V8_HEAP_INCREMENTAL_MARKING_H_ |
OLD | NEW |