| 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/incremental-marking-job.h" | 10 #include "src/heap/incremental-marking-job.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 // Forward declarations. | 16 // Forward declarations. |
| 17 class MarkBit; | 17 class MarkBit; |
| 18 class PagedSpace; | 18 class PagedSpace; |
| 19 | 19 |
| 20 class IncrementalMarking { | 20 class IncrementalMarking { |
| 21 public: | 21 public: |
| 22 enum State { STOPPED, SWEEPING, MARKING, COMPLETE }; | 22 enum State { STOPPED, SWEEPING, MARKING, COMPLETE }; |
| 23 | 23 |
| 24 enum CompletionAction { GC_VIA_STACK_GUARD, NO_GC_VIA_STACK_GUARD }; | 24 enum CompletionAction { GC_VIA_STACK_GUARD, NO_GC_VIA_STACK_GUARD }; |
| 25 | 25 |
| 26 enum ForceMarkingAction { FORCE_MARKING, DO_NOT_FORCE_MARKING }; | 26 enum ForceMarkingAction { FORCE_MARKING, DO_NOT_FORCE_MARKING }; |
| 27 | 27 |
| 28 enum ForceCompletionAction { FORCE_COMPLETION, DO_NOT_FORCE_COMPLETION }; | 28 enum ForceCompletionAction { FORCE_COMPLETION, DO_NOT_FORCE_COMPLETION }; |
| 29 | 29 |
| 30 enum GCRequestType { COMPLETE_MARKING, OVERAPPROXIMATION }; | 30 enum GCRequestType { COMPLETE_MARKING, FINALIZATION }; |
| 31 | 31 |
| 32 struct StepActions { | 32 struct StepActions { |
| 33 StepActions(CompletionAction complete_action_, | 33 StepActions(CompletionAction complete_action_, |
| 34 ForceMarkingAction force_marking_, | 34 ForceMarkingAction force_marking_, |
| 35 ForceCompletionAction force_completion_) | 35 ForceCompletionAction force_completion_) |
| 36 : completion_action(complete_action_), | 36 : completion_action(complete_action_), |
| 37 force_marking(force_marking_), | 37 force_marking(force_marking_), |
| 38 force_completion(force_completion_) {} | 38 force_completion(force_completion_) {} |
| 39 | 39 |
| 40 CompletionAction completion_action; | 40 CompletionAction completion_action; |
| 41 ForceMarkingAction force_marking; | 41 ForceMarkingAction force_marking; |
| 42 ForceCompletionAction force_completion; | 42 ForceCompletionAction force_completion; |
| 43 }; | 43 }; |
| 44 | 44 |
| 45 static StepActions IdleStepActions(); | 45 static StepActions IdleStepActions(); |
| 46 | 46 |
| 47 explicit IncrementalMarking(Heap* heap); | 47 explicit IncrementalMarking(Heap* heap); |
| 48 | 48 |
| 49 static void Initialize(); | 49 static void Initialize(); |
| 50 | 50 |
| 51 State state() { | 51 State state() { |
| 52 DCHECK(state_ == STOPPED || FLAG_incremental_marking); | 52 DCHECK(state_ == STOPPED || FLAG_incremental_marking); |
| 53 return state_; | 53 return state_; |
| 54 } | 54 } |
| 55 | 55 |
| 56 bool should_hurry() { return should_hurry_; } | 56 bool should_hurry() { return should_hurry_; } |
| 57 void set_should_hurry(bool val) { should_hurry_ = val; } | 57 void set_should_hurry(bool val) { should_hurry_ = val; } |
| 58 | 58 |
| 59 bool weak_closure_was_overapproximated() const { | 59 bool weak_closure_was_overapproximated() const { |
| 60 return weak_closure_was_overapproximated_; | 60 return finalize_marking_completed_; |
| 61 } | 61 } |
| 62 | 62 |
| 63 void SetWeakClosureWasOverApproximatedForTesting(bool val) { | 63 void SetWeakClosureWasOverApproximatedForTesting(bool val) { |
| 64 weak_closure_was_overapproximated_ = val; | 64 finalize_marking_completed_ = val; |
| 65 } | 65 } |
| 66 | 66 |
| 67 inline bool IsStopped() { return state() == STOPPED; } | 67 inline bool IsStopped() { return state() == STOPPED; } |
| 68 | 68 |
| 69 INLINE(bool IsMarking()) { return state() >= MARKING; } | 69 INLINE(bool IsMarking()) { return state() >= MARKING; } |
| 70 | 70 |
| 71 inline bool IsMarkingIncomplete() { return state() == MARKING; } | 71 inline bool IsMarkingIncomplete() { return state() == MARKING; } |
| 72 | 72 |
| 73 inline bool IsComplete() { return state() == COMPLETE; } | 73 inline bool IsComplete() { return state() == COMPLETE; } |
| 74 | 74 |
| 75 inline bool IsReadyToOverApproximateWeakClosure() const { | 75 inline bool IsReadyToOverApproximateWeakClosure() const { |
| 76 return request_type_ == OVERAPPROXIMATION && | 76 return request_type_ == FINALIZATION && !finalize_marking_completed_; |
| 77 !weak_closure_was_overapproximated_; | |
| 78 } | 77 } |
| 79 | 78 |
| 80 GCRequestType request_type() const { return request_type_; } | 79 GCRequestType request_type() const { return request_type_; } |
| 81 | 80 |
| 82 bool CanBeActivated(); | 81 bool CanBeActivated(); |
| 83 | 82 |
| 84 bool ShouldActivateEvenWithoutIdleNotification(); | 83 bool ShouldActivateEvenWithoutIdleNotification(); |
| 85 | 84 |
| 86 bool WasActivated(); | 85 bool WasActivated(); |
| 87 | 86 |
| 88 void Start(const char* reason = nullptr); | 87 void Start(const char* reason = nullptr); |
| 89 | 88 |
| 90 void MarkObjectGroups(); | 89 void FinalizeIncrementally(); |
| 91 | 90 |
| 92 void UpdateMarkingDequeAfterScavenge(); | 91 void UpdateMarkingDequeAfterScavenge(); |
| 93 | 92 |
| 94 void Hurry(); | 93 void Hurry(); |
| 95 | 94 |
| 96 void Finalize(); | 95 void Finalize(); |
| 97 | 96 |
| 98 void Stop(); | 97 void Stop(); |
| 99 | 98 |
| 100 void OverApproximateWeakClosure(CompletionAction action); | 99 void FinalizeMarking(CompletionAction action); |
| 101 | 100 |
| 102 void MarkingComplete(CompletionAction action); | 101 void MarkingComplete(CompletionAction action); |
| 103 | 102 |
| 104 void Epilogue(); | 103 void Epilogue(); |
| 105 | 104 |
| 106 // Performs incremental marking steps of step_size_in_bytes as long as | 105 // Performs incremental marking steps of step_size_in_bytes as long as |
| 107 // deadline_ins_ms is not reached. step_size_in_bytes can be 0 to compute | 106 // deadline_ins_ms is not reached. step_size_in_bytes can be 0 to compute |
| 108 // an estimate increment. Returns the remaining time that cannot be used | 107 // an estimate increment. Returns the remaining time that cannot be used |
| 109 // for incremental marking anymore because a single step would exceed the | 108 // for incremental marking anymore because a single step would exceed the |
| 110 // deadline. | 109 // deadline. |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 216 | 215 |
| 217 private: | 216 private: |
| 218 int64_t SpaceLeftInOldSpace(); | 217 int64_t SpaceLeftInOldSpace(); |
| 219 | 218 |
| 220 void SpeedUp(); | 219 void SpeedUp(); |
| 221 | 220 |
| 222 void ResetStepCounters(); | 221 void ResetStepCounters(); |
| 223 | 222 |
| 224 void StartMarking(); | 223 void StartMarking(); |
| 225 | 224 |
| 225 void MarkRoots(); |
| 226 void MarkObjectGroups(); |
| 227 |
| 226 void ActivateIncrementalWriteBarrier(PagedSpace* space); | 228 void ActivateIncrementalWriteBarrier(PagedSpace* space); |
| 227 static void ActivateIncrementalWriteBarrier(NewSpace* space); | 229 static void ActivateIncrementalWriteBarrier(NewSpace* space); |
| 228 void ActivateIncrementalWriteBarrier(); | 230 void ActivateIncrementalWriteBarrier(); |
| 229 | 231 |
| 230 static void DeactivateIncrementalWriteBarrierForSpace(PagedSpace* space); | 232 static void DeactivateIncrementalWriteBarrierForSpace(PagedSpace* space); |
| 231 static void DeactivateIncrementalWriteBarrierForSpace(NewSpace* space); | 233 static void DeactivateIncrementalWriteBarrierForSpace(NewSpace* space); |
| 232 void DeactivateIncrementalWriteBarrier(); | 234 void DeactivateIncrementalWriteBarrier(); |
| 233 | 235 |
| 234 static void SetOldSpacePageFlags(MemoryChunk* chunk, bool is_marking, | 236 static void SetOldSpacePageFlags(MemoryChunk* chunk, bool is_marking, |
| 235 bool is_compacting); | 237 bool is_compacting); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 259 intptr_t allocated_; | 261 intptr_t allocated_; |
| 260 intptr_t write_barriers_invoked_since_last_step_; | 262 intptr_t write_barriers_invoked_since_last_step_; |
| 261 size_t idle_marking_delay_counter_; | 263 size_t idle_marking_delay_counter_; |
| 262 | 264 |
| 263 int no_marking_scope_depth_; | 265 int no_marking_scope_depth_; |
| 264 | 266 |
| 265 int unscanned_bytes_of_large_object_; | 267 int unscanned_bytes_of_large_object_; |
| 266 | 268 |
| 267 bool was_activated_; | 269 bool was_activated_; |
| 268 | 270 |
| 269 bool weak_closure_was_overapproximated_; | 271 bool finalize_marking_completed_; |
| 270 | 272 |
| 271 int weak_closure_approximation_rounds_; | 273 int incremental_marking_finalization_rounds_; |
| 272 | 274 |
| 273 GCRequestType request_type_; | 275 GCRequestType request_type_; |
| 274 | 276 |
| 275 IncrementalMarkingJob incremental_marking_job_; | 277 IncrementalMarkingJob incremental_marking_job_; |
| 276 | 278 |
| 277 DISALLOW_IMPLICIT_CONSTRUCTORS(IncrementalMarking); | 279 DISALLOW_IMPLICIT_CONSTRUCTORS(IncrementalMarking); |
| 278 }; | 280 }; |
| 279 } // namespace internal | 281 } // namespace internal |
| 280 } // namespace v8 | 282 } // namespace v8 |
| 281 | 283 |
| 282 #endif // V8_HEAP_INCREMENTAL_MARKING_H_ | 284 #endif // V8_HEAP_INCREMENTAL_MARKING_H_ |
| OLD | NEW |