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 #include "src/cancelable-task.h" | 8 #include "src/cancelable-task.h" |
9 #include "src/execution.h" | 9 #include "src/execution.h" |
10 #include "src/heap/heap.h" | 10 #include "src/heap/heap.h" |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 | 92 |
93 void Epilogue(); | 93 void Epilogue(); |
94 | 94 |
95 // Performs incremental marking steps until deadline_in_ms is reached. It | 95 // Performs incremental marking steps until deadline_in_ms is reached. It |
96 // returns the remaining time that cannot be used for incremental marking | 96 // returns the remaining time that cannot be used for incremental marking |
97 // anymore because a single step would exceed the deadline. | 97 // anymore because a single step would exceed the deadline. |
98 double AdvanceIncrementalMarking(double deadline_in_ms, | 98 double AdvanceIncrementalMarking(double deadline_in_ms, |
99 CompletionAction completion_action, | 99 CompletionAction completion_action, |
100 ForceCompletionAction force_completion, | 100 ForceCompletionAction force_completion, |
101 StepOrigin step_origin); | 101 StepOrigin step_origin); |
| 102 void AdvanceIncrementalMarkingOnAllocation(); |
102 | 103 |
103 // It's hard to know how much work the incremental marker should do to make | 104 // It's hard to know how much work the incremental marker should do to make |
104 // progress in the face of the mutator creating new work for it. We start | 105 // progress in the face of the mutator creating new work for it. We start |
105 // of at a moderate rate of work and gradually increase the speed of the | 106 // of at a moderate rate of work and gradually increase the speed of the |
106 // incremental marker until it completes. | 107 // incremental marker until it completes. |
107 // Do some marking every time this much memory has been allocated or that many | 108 // Do some marking every time this much memory has been allocated or that many |
108 // heavy (color-checking) write barriers have been invoked. | 109 // heavy (color-checking) write barriers have been invoked. |
109 static const size_t kAllocatedThreshold = 64 * KB; | 110 static const size_t kAllocatedThreshold = 64 * KB; |
110 | 111 |
111 static const int kStepSizeInMs = 1; | 112 static const int kStepSizeInMs = 1; |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
211 return &incremental_marking_job_; | 212 return &incremental_marking_job_; |
212 } | 213 } |
213 | 214 |
214 bool black_allocation() { return black_allocation_; } | 215 bool black_allocation() { return black_allocation_; } |
215 | 216 |
216 void StartBlackAllocationForTesting() { StartBlackAllocation(); } | 217 void StartBlackAllocationForTesting() { StartBlackAllocation(); } |
217 | 218 |
218 void AbortBlackAllocation(); | 219 void AbortBlackAllocation(); |
219 | 220 |
220 private: | 221 private: |
221 class Observer : public AllocationObserver { | |
222 public: | |
223 Observer(IncrementalMarking& incremental_marking, intptr_t step_size) | |
224 : AllocationObserver(step_size), | |
225 incremental_marking_(incremental_marking) {} | |
226 | |
227 void Step(int bytes_allocated, Address, size_t) override { | |
228 incremental_marking_.AdvanceIncrementalMarkingOnAllocation(); | |
229 } | |
230 | |
231 private: | |
232 IncrementalMarking& incremental_marking_; | |
233 }; | |
234 | |
235 int64_t SpaceLeftInOldSpace(); | 222 int64_t SpaceLeftInOldSpace(); |
236 | 223 |
237 void StartMarking(); | 224 void StartMarking(); |
238 | 225 |
239 void StartBlackAllocation(); | 226 void StartBlackAllocation(); |
240 void FinishBlackAllocation(); | 227 void FinishBlackAllocation(); |
241 | 228 |
242 void MarkRoots(); | 229 void MarkRoots(); |
243 void MarkObjectGroups(); | 230 void MarkObjectGroups(); |
244 void ProcessWeakCells(); | 231 void ProcessWeakCells(); |
(...skipping 17 matching lines...) Expand all Loading... |
262 INLINE(void ProcessMarkingDeque()); | 249 INLINE(void ProcessMarkingDeque()); |
263 | 250 |
264 INLINE(intptr_t ProcessMarkingDeque( | 251 INLINE(intptr_t ProcessMarkingDeque( |
265 intptr_t bytes_to_process, | 252 intptr_t bytes_to_process, |
266 ForceCompletionAction completion = DO_NOT_FORCE_COMPLETION)); | 253 ForceCompletionAction completion = DO_NOT_FORCE_COMPLETION)); |
267 | 254 |
268 INLINE(void VisitObject(Map* map, HeapObject* obj, int size)); | 255 INLINE(void VisitObject(Map* map, HeapObject* obj, int size)); |
269 | 256 |
270 void IncrementIdleMarkingDelayCounter(); | 257 void IncrementIdleMarkingDelayCounter(); |
271 | 258 |
272 void AdvanceIncrementalMarkingOnAllocation(); | |
273 | |
274 size_t StepSizeToKeepUpWithAllocations(); | 259 size_t StepSizeToKeepUpWithAllocations(); |
275 size_t StepSizeToMakeProgress(); | 260 size_t StepSizeToMakeProgress(); |
276 | 261 |
277 Heap* heap_; | 262 Heap* heap_; |
278 | 263 |
279 State state_; | 264 State state_; |
280 | 265 |
281 double start_time_ms_; | 266 double start_time_ms_; |
282 size_t initial_old_generation_size_; | 267 size_t initial_old_generation_size_; |
283 size_t old_generation_allocation_counter_; | 268 size_t old_generation_allocation_counter_; |
284 size_t bytes_allocated_; | 269 size_t bytes_allocated_; |
285 size_t bytes_marked_ahead_of_schedule_; | 270 size_t bytes_marked_ahead_of_schedule_; |
286 size_t unscanned_bytes_of_large_object_; | 271 size_t unscanned_bytes_of_large_object_; |
287 | 272 |
288 int idle_marking_delay_counter_; | 273 int idle_marking_delay_counter_; |
289 int incremental_marking_finalization_rounds_; | 274 int incremental_marking_finalization_rounds_; |
290 | 275 |
291 bool is_compacting_; | 276 bool is_compacting_; |
292 bool should_hurry_; | 277 bool should_hurry_; |
293 bool was_activated_; | 278 bool was_activated_; |
294 bool black_allocation_; | 279 bool black_allocation_; |
295 bool finalize_marking_completed_; | 280 bool finalize_marking_completed_; |
296 | 281 |
297 GCRequestType request_type_; | 282 GCRequestType request_type_; |
298 | 283 |
299 IncrementalMarkingJob incremental_marking_job_; | 284 IncrementalMarkingJob incremental_marking_job_; |
300 Observer new_generation_observer_; | |
301 Observer old_generation_observer_; | |
302 | 285 |
303 DISALLOW_IMPLICIT_CONSTRUCTORS(IncrementalMarking); | 286 DISALLOW_IMPLICIT_CONSTRUCTORS(IncrementalMarking); |
304 }; | 287 }; |
305 } // namespace internal | 288 } // namespace internal |
306 } // namespace v8 | 289 } // namespace v8 |
307 | 290 |
308 #endif // V8_HEAP_INCREMENTAL_MARKING_H_ | 291 #endif // V8_HEAP_INCREMENTAL_MARKING_H_ |
OLD | NEW |