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