| 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 #include "src/heap/incremental-marking-job.h" | 5 #include "src/heap/incremental-marking-job.h" |
| 6 | 6 |
| 7 #include "src/base/platform/time.h" | 7 #include "src/base/platform/time.h" |
| 8 #include "src/heap/heap-inl.h" | 8 #include "src/heap/heap-inl.h" |
| 9 #include "src/heap/heap.h" | 9 #include "src/heap/heap.h" |
| 10 #include "src/heap/incremental-marking.h" | 10 #include "src/heap/incremental-marking.h" |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 if (incremental_marking->IsSweeping()) { | 77 if (incremental_marking->IsSweeping()) { |
| 78 incremental_marking->FinalizeSweeping(); | 78 incremental_marking->FinalizeSweeping(); |
| 79 // TODO(hpayer): We can continue here if enough idle time is left. | 79 // TODO(hpayer): We can continue here if enough idle time is left. |
| 80 return kMoreWork; | 80 return kMoreWork; |
| 81 } | 81 } |
| 82 const double remaining_idle_time_in_ms = | 82 const double remaining_idle_time_in_ms = |
| 83 incremental_marking->AdvanceIncrementalMarking( | 83 incremental_marking->AdvanceIncrementalMarking( |
| 84 deadline_in_ms, IncrementalMarking::NO_GC_VIA_STACK_GUARD, | 84 deadline_in_ms, IncrementalMarking::NO_GC_VIA_STACK_GUARD, |
| 85 IncrementalMarking::DO_NOT_FORCE_COMPLETION); | 85 IncrementalMarking::DO_NOT_FORCE_COMPLETION); |
| 86 if (remaining_idle_time_in_ms > 0.0) { | 86 if (remaining_idle_time_in_ms > 0.0) { |
| 87 heap->TryFinalizeIdleIncrementalMarking(remaining_idle_time_in_ms); | 87 heap->TryFinalizeIdleIncrementalMarking( |
| 88 remaining_idle_time_in_ms, |
| 89 GarbageCollectionReason::kFinalizeMarkingViaTask); |
| 88 } | 90 } |
| 89 return incremental_marking->IsStopped() ? kDone : kMoreWork; | 91 return incremental_marking->IsStopped() ? kDone : kMoreWork; |
| 90 } | 92 } |
| 91 | 93 |
| 92 | 94 |
| 93 void IncrementalMarkingJob::IdleTask::RunInternal(double deadline_in_seconds) { | 95 void IncrementalMarkingJob::IdleTask::RunInternal(double deadline_in_seconds) { |
| 94 double deadline_in_ms = | 96 double deadline_in_ms = |
| 95 deadline_in_seconds * | 97 deadline_in_seconds * |
| 96 static_cast<double>(base::Time::kMillisecondsPerSecond); | 98 static_cast<double>(base::Time::kMillisecondsPerSecond); |
| 97 Heap* heap = isolate()->heap(); | 99 Heap* heap = isolate()->heap(); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 116 | 118 |
| 117 | 119 |
| 118 void IncrementalMarkingJob::DelayedTask::Step(Heap* heap) { | 120 void IncrementalMarkingJob::DelayedTask::Step(Heap* heap) { |
| 119 const int kIncrementalMarkingDelayMs = 50; | 121 const int kIncrementalMarkingDelayMs = 50; |
| 120 double deadline = | 122 double deadline = |
| 121 heap->MonotonicallyIncreasingTimeInMs() + kIncrementalMarkingDelayMs; | 123 heap->MonotonicallyIncreasingTimeInMs() + kIncrementalMarkingDelayMs; |
| 122 heap->incremental_marking()->AdvanceIncrementalMarking( | 124 heap->incremental_marking()->AdvanceIncrementalMarking( |
| 123 deadline, IncrementalMarking::NO_GC_VIA_STACK_GUARD, | 125 deadline, IncrementalMarking::NO_GC_VIA_STACK_GUARD, |
| 124 IncrementalMarking::FORCE_COMPLETION); | 126 IncrementalMarking::FORCE_COMPLETION); |
| 125 heap->FinalizeIncrementalMarkingIfComplete( | 127 heap->FinalizeIncrementalMarkingIfComplete( |
| 126 "Incremental marking task: finalize incremental marking"); | 128 GarbageCollectionReason::kFinalizeMarkingViaTask); |
| 127 } | 129 } |
| 128 | 130 |
| 129 | 131 |
| 130 void IncrementalMarkingJob::DelayedTask::RunInternal() { | 132 void IncrementalMarkingJob::DelayedTask::RunInternal() { |
| 131 Heap* heap = isolate()->heap(); | 133 Heap* heap = isolate()->heap(); |
| 132 job_->NotifyDelayedTask(); | 134 job_->NotifyDelayedTask(); |
| 133 IncrementalMarking* incremental_marking = heap->incremental_marking(); | 135 IncrementalMarking* incremental_marking = heap->incremental_marking(); |
| 134 if (!incremental_marking->IsStopped()) { | 136 if (!incremental_marking->IsStopped()) { |
| 135 if (job_->ShouldForceMarkingStep()) { | 137 if (job_->ShouldForceMarkingStep()) { |
| 136 Step(heap); | 138 Step(heap); |
| 137 } | 139 } |
| 138 // The Step() above could have finished incremental marking. | 140 // The Step() above could have finished incremental marking. |
| 139 if (!incremental_marking->IsStopped()) { | 141 if (!incremental_marking->IsStopped()) { |
| 140 job_->ScheduleDelayedTask(heap); | 142 job_->ScheduleDelayedTask(heap); |
| 141 } | 143 } |
| 142 } | 144 } |
| 143 } | 145 } |
| 144 | 146 |
| 145 } // namespace internal | 147 } // namespace internal |
| 146 } // namespace v8 | 148 } // namespace v8 |
| OLD | NEW |