| 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 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 MarkCompactCollector* mark_compact_collector = heap->mark_compact_collector(); | 70 MarkCompactCollector* mark_compact_collector = heap->mark_compact_collector(); |
| 71 if (incremental_marking->IsStopped()) { | 71 if (incremental_marking->IsStopped()) { |
| 72 return kDone; | 72 return kDone; |
| 73 } | 73 } |
| 74 if (mark_compact_collector->sweeping_in_progress()) { | 74 if (mark_compact_collector->sweeping_in_progress()) { |
| 75 if (mark_compact_collector->IsSweepingCompleted()) { | 75 if (mark_compact_collector->IsSweepingCompleted()) { |
| 76 mark_compact_collector->EnsureSweepingCompleted(); | 76 mark_compact_collector->EnsureSweepingCompleted(); |
| 77 } | 77 } |
| 78 return kMoreWork; | 78 return kMoreWork; |
| 79 } | 79 } |
| 80 const double remaining_idle_time_in_ms = heap->AdvanceIncrementalMarking( | 80 const double remaining_idle_time_in_ms = |
| 81 0, deadline_in_ms, IncrementalMarking::IdleStepActions()); | 81 incremental_marking->AdvanceIncrementalMarking( |
| 82 0, deadline_in_ms, IncrementalMarking::IdleStepActions()); |
| 82 if (remaining_idle_time_in_ms > 0.0) { | 83 if (remaining_idle_time_in_ms > 0.0) { |
| 83 heap->TryFinalizeIdleIncrementalMarking(remaining_idle_time_in_ms); | 84 heap->TryFinalizeIdleIncrementalMarking(remaining_idle_time_in_ms); |
| 84 } | 85 } |
| 85 return incremental_marking->IsStopped() ? kDone : kMoreWork; | 86 return incremental_marking->IsStopped() ? kDone : kMoreWork; |
| 86 } | 87 } |
| 87 | 88 |
| 88 | 89 |
| 89 void IncrementalMarkingJob::IdleTask::RunInternal(double deadline_in_seconds) { | 90 void IncrementalMarkingJob::IdleTask::RunInternal(double deadline_in_seconds) { |
| 90 double deadline_in_ms = | 91 double deadline_in_ms = |
| 91 deadline_in_seconds * | 92 deadline_in_seconds * |
| (...skipping 16 matching lines...) Expand all Loading... |
| 108 idle_time_in_ms, idle_time_in_ms - deadline_difference, | 109 idle_time_in_ms, idle_time_in_ms - deadline_difference, |
| 109 deadline_difference); | 110 deadline_difference); |
| 110 } | 111 } |
| 111 } | 112 } |
| 112 | 113 |
| 113 | 114 |
| 114 void IncrementalMarkingJob::DelayedTask::Step(Heap* heap) { | 115 void IncrementalMarkingJob::DelayedTask::Step(Heap* heap) { |
| 115 const int kIncrementalMarkingDelayMs = 50; | 116 const int kIncrementalMarkingDelayMs = 50; |
| 116 double deadline = | 117 double deadline = |
| 117 heap->MonotonicallyIncreasingTimeInMs() + kIncrementalMarkingDelayMs; | 118 heap->MonotonicallyIncreasingTimeInMs() + kIncrementalMarkingDelayMs; |
| 118 heap->AdvanceIncrementalMarking( | 119 heap->incremental_marking()->AdvanceIncrementalMarking( |
| 119 0, deadline, i::IncrementalMarking::StepActions( | 120 0, deadline, i::IncrementalMarking::StepActions( |
| 120 i::IncrementalMarking::NO_GC_VIA_STACK_GUARD, | 121 i::IncrementalMarking::NO_GC_VIA_STACK_GUARD, |
| 121 i::IncrementalMarking::FORCE_MARKING, | 122 i::IncrementalMarking::FORCE_MARKING, |
| 122 i::IncrementalMarking::FORCE_COMPLETION)); | 123 i::IncrementalMarking::FORCE_COMPLETION)); |
| 123 heap->FinalizeIncrementalMarkingIfComplete( | 124 heap->FinalizeIncrementalMarkingIfComplete( |
| 124 "Incremental marking task: finalize incremental marking"); | 125 "Incremental marking task: finalize incremental marking"); |
| 125 } | 126 } |
| 126 | 127 |
| 127 | 128 |
| 128 void IncrementalMarkingJob::DelayedTask::RunInternal() { | 129 void IncrementalMarkingJob::DelayedTask::RunInternal() { |
| 129 Heap* heap = isolate_->heap(); | 130 Heap* heap = isolate_->heap(); |
| 130 job_->NotifyDelayedTask(); | 131 job_->NotifyDelayedTask(); |
| 131 IncrementalMarking* incremental_marking = heap->incremental_marking(); | 132 IncrementalMarking* incremental_marking = heap->incremental_marking(); |
| 132 if (!incremental_marking->IsStopped()) { | 133 if (!incremental_marking->IsStopped()) { |
| 133 if (job_->ShouldForceMarkingStep()) { | 134 if (job_->ShouldForceMarkingStep()) { |
| 134 Step(heap); | 135 Step(heap); |
| 135 } | 136 } |
| 136 // The Step() above could have finished incremental marking. | 137 // The Step() above could have finished incremental marking. |
| 137 if (!incremental_marking->IsStopped()) { | 138 if (!incremental_marking->IsStopped()) { |
| 138 job_->ScheduleDelayedTask(heap); | 139 job_->ScheduleDelayedTask(heap); |
| 139 } | 140 } |
| 140 } | 141 } |
| 141 } | 142 } |
| 142 | 143 |
| 143 } // namespace internal | 144 } // namespace internal |
| 144 } // namespace v8 | 145 } // namespace v8 |
| OLD | NEW |