Chromium Code Reviews| 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 14 matching lines...) Expand all Loading... | |
| 25 class V8_EXPORT_PRIVATE IncrementalMarking { | 25 class V8_EXPORT_PRIVATE IncrementalMarking { |
| 26 public: | 26 public: |
| 27 enum State { STOPPED, SWEEPING, MARKING, COMPLETE }; | 27 enum State { STOPPED, SWEEPING, MARKING, COMPLETE }; |
| 28 | 28 |
| 29 enum CompletionAction { GC_VIA_STACK_GUARD, NO_GC_VIA_STACK_GUARD }; | 29 enum CompletionAction { GC_VIA_STACK_GUARD, NO_GC_VIA_STACK_GUARD }; |
| 30 | 30 |
| 31 enum ForceCompletionAction { FORCE_COMPLETION, DO_NOT_FORCE_COMPLETION }; | 31 enum ForceCompletionAction { FORCE_COMPLETION, DO_NOT_FORCE_COMPLETION }; |
| 32 | 32 |
| 33 enum GCRequestType { NONE, COMPLETE_MARKING, FINALIZATION }; | 33 enum GCRequestType { NONE, COMPLETE_MARKING, FINALIZATION }; |
| 34 | 34 |
| 35 static void MarkGrey(Heap* heap, HeapObject* object); | 35 static void Initialize(); |
|
Michael Lippautz
2017/04/28 12:49:40
MarkGrey and MarkBlack are now instance methods.
| |
| 36 | 36 |
| 37 static void MarkBlack(HeapObject* object, int size); | 37 explicit IncrementalMarking(Heap* heap); |
| 38 | |
| 39 MarkingState marking_state(HeapObject* object) const { | |
| 40 return MarkingState::Internal(object); | |
| 41 } | |
| 42 | |
| 43 MarkingState marking_state(MemoryChunk* chunk) const { | |
| 44 return MarkingState::Internal(chunk); | |
| 45 } | |
| 46 | |
| 47 void MarkBlack(HeapObject* object, int size); | |
| 48 void MarkGrey(Heap* heap, HeapObject* object); | |
| 38 | 49 |
| 39 // Transfers mark bits without requiring proper object headers. | 50 // Transfers mark bits without requiring proper object headers. |
| 40 static void TransferMark(Heap* heap, HeapObject* from, HeapObject* to); | 51 void TransferMark(Heap* heap, HeapObject* from, HeapObject* to); |
| 41 | 52 |
| 42 // Transfers color including live byte count, requiring properly set up | 53 // Transfers color including live byte count, requiring properly set up |
| 43 // objects. | 54 // objects. |
| 44 template <MarkBit::AccessMode access_mode = MarkBit::NON_ATOMIC> | 55 template <MarkBit::AccessMode access_mode = MarkBit::NON_ATOMIC> |
| 45 V8_INLINE static void TransferColor(HeapObject* from, HeapObject* to) { | 56 V8_INLINE void TransferColor(HeapObject* from, HeapObject* to) { |
| 46 if (ObjectMarking::IsBlack<access_mode>(to, MarkingState::Internal(to))) { | 57 if (ObjectMarking::IsBlack<access_mode>(to, marking_state(to))) { |
| 47 DCHECK(to->GetHeap()->incremental_marking()->black_allocation()); | 58 DCHECK(black_allocation()); |
| 48 return; | 59 return; |
| 49 } | 60 } |
| 50 | 61 |
| 51 DCHECK(ObjectMarking::IsWhite<access_mode>(to, MarkingState::Internal(to))); | 62 DCHECK(ObjectMarking::IsWhite<access_mode>(to, marking_state(to))); |
| 52 if (ObjectMarking::IsGrey<access_mode>(from, | 63 if (ObjectMarking::IsGrey<access_mode>(from, marking_state(from))) { |
| 53 MarkingState::Internal(from))) { | 64 ObjectMarking::WhiteToGrey<access_mode>(to, marking_state(to)); |
| 54 ObjectMarking::WhiteToGrey<access_mode>(to, MarkingState::Internal(to)); | 65 } else if (ObjectMarking::IsBlack<access_mode>(from, marking_state(from))) { |
| 55 } else if (ObjectMarking::IsBlack<access_mode>( | 66 ObjectMarking::WhiteToBlack<access_mode>(to, marking_state(to)); |
| 56 from, MarkingState::Internal(from))) { | |
| 57 ObjectMarking::WhiteToBlack<access_mode>(to, MarkingState::Internal(to)); | |
| 58 } | 67 } |
| 59 } | 68 } |
| 60 | 69 |
| 61 explicit IncrementalMarking(Heap* heap); | |
| 62 | |
| 63 static void Initialize(); | |
| 64 | 70 |
| 65 State state() { | 71 State state() { |
| 66 DCHECK(state_ == STOPPED || FLAG_incremental_marking); | 72 DCHECK(state_ == STOPPED || FLAG_incremental_marking); |
| 67 return state_; | 73 return state_; |
| 68 } | 74 } |
| 69 | 75 |
| 70 bool should_hurry() { return should_hurry_; } | 76 bool should_hurry() { return should_hurry_; } |
| 71 void set_should_hurry(bool val) { should_hurry_ = val; } | 77 void set_should_hurry(bool val) { should_hurry_ = val; } |
| 72 | 78 |
| 73 bool finalize_marking_completed() const { | 79 bool finalize_marking_completed() const { |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 212 IncrementalMarkingJob* incremental_marking_job() { | 218 IncrementalMarkingJob* incremental_marking_job() { |
| 213 return &incremental_marking_job_; | 219 return &incremental_marking_job_; |
| 214 } | 220 } |
| 215 | 221 |
| 216 bool black_allocation() { return black_allocation_; } | 222 bool black_allocation() { return black_allocation_; } |
| 217 | 223 |
| 218 void StartBlackAllocationForTesting() { StartBlackAllocation(); } | 224 void StartBlackAllocationForTesting() { StartBlackAllocation(); } |
| 219 | 225 |
| 220 void AbortBlackAllocation(); | 226 void AbortBlackAllocation(); |
| 221 | 227 |
| 228 MarkingDeque* marking_deque() { | |
| 229 SLOW_DCHECK(marking_deque_ != nullptr); | |
| 230 return marking_deque_; | |
| 231 } | |
| 232 | |
| 233 void set_marking_deque(MarkingDeque* marking_deque) { | |
| 234 marking_deque_ = marking_deque; | |
| 235 } | |
| 236 | |
| 222 private: | 237 private: |
| 223 class Observer : public AllocationObserver { | 238 class Observer : public AllocationObserver { |
| 224 public: | 239 public: |
| 225 Observer(IncrementalMarking& incremental_marking, intptr_t step_size) | 240 Observer(IncrementalMarking& incremental_marking, intptr_t step_size) |
| 226 : AllocationObserver(step_size), | 241 : AllocationObserver(step_size), |
| 227 incremental_marking_(incremental_marking) {} | 242 incremental_marking_(incremental_marking) {} |
| 228 | 243 |
| 229 void Step(int bytes_allocated, Address, size_t) override { | 244 void Step(int bytes_allocated, Address, size_t) override { |
| 230 incremental_marking_.AdvanceIncrementalMarkingOnAllocation(); | 245 incremental_marking_.AdvanceIncrementalMarkingOnAllocation(); |
| 231 } | 246 } |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 269 INLINE(void VisitObject(Map* map, HeapObject* obj, int size)); | 284 INLINE(void VisitObject(Map* map, HeapObject* obj, int size)); |
| 270 | 285 |
| 271 void IncrementIdleMarkingDelayCounter(); | 286 void IncrementIdleMarkingDelayCounter(); |
| 272 | 287 |
| 273 void AdvanceIncrementalMarkingOnAllocation(); | 288 void AdvanceIncrementalMarkingOnAllocation(); |
| 274 | 289 |
| 275 size_t StepSizeToKeepUpWithAllocations(); | 290 size_t StepSizeToKeepUpWithAllocations(); |
| 276 size_t StepSizeToMakeProgress(); | 291 size_t StepSizeToMakeProgress(); |
| 277 | 292 |
| 278 Heap* heap_; | 293 Heap* heap_; |
| 294 MarkingDeque* marking_deque_; | |
| 279 | 295 |
| 280 double start_time_ms_; | 296 double start_time_ms_; |
| 281 size_t initial_old_generation_size_; | 297 size_t initial_old_generation_size_; |
| 282 size_t old_generation_allocation_counter_; | 298 size_t old_generation_allocation_counter_; |
| 283 size_t bytes_allocated_; | 299 size_t bytes_allocated_; |
| 284 size_t bytes_marked_ahead_of_schedule_; | 300 size_t bytes_marked_ahead_of_schedule_; |
| 285 size_t unscanned_bytes_of_large_object_; | 301 size_t unscanned_bytes_of_large_object_; |
| 286 | 302 |
| 287 State state_; | 303 State state_; |
| 288 | 304 |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 301 | 317 |
| 302 Observer new_generation_observer_; | 318 Observer new_generation_observer_; |
| 303 Observer old_generation_observer_; | 319 Observer old_generation_observer_; |
| 304 | 320 |
| 305 DISALLOW_IMPLICIT_CONSTRUCTORS(IncrementalMarking); | 321 DISALLOW_IMPLICIT_CONSTRUCTORS(IncrementalMarking); |
| 306 }; | 322 }; |
| 307 } // namespace internal | 323 } // namespace internal |
| 308 } // namespace v8 | 324 } // namespace v8 |
| 309 | 325 |
| 310 #endif // V8_HEAP_INCREMENTAL_MARKING_H_ | 326 #endif // V8_HEAP_INCREMENTAL_MARKING_H_ |
| OLD | NEW |