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 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 heap->TryFinalizeIdleIncrementalMarking(remaining_idle_time_in_ms); | 84 heap->TryFinalizeIdleIncrementalMarking(remaining_idle_time_in_ms); |
85 } | 85 } |
86 return incremental_marking->IsStopped() ? kDone : kMoreWork; | 86 return incremental_marking->IsStopped() ? kDone : kMoreWork; |
87 } | 87 } |
88 | 88 |
89 | 89 |
90 void IncrementalMarkingJob::IdleTask::RunInternal(double deadline_in_seconds) { | 90 void IncrementalMarkingJob::IdleTask::RunInternal(double deadline_in_seconds) { |
91 double deadline_in_ms = | 91 double deadline_in_ms = |
92 deadline_in_seconds * | 92 deadline_in_seconds * |
93 static_cast<double>(base::Time::kMillisecondsPerSecond); | 93 static_cast<double>(base::Time::kMillisecondsPerSecond); |
94 Heap* heap = isolate_->heap(); | 94 Heap* heap = isolate()->heap(); |
95 double start_ms = heap->MonotonicallyIncreasingTimeInMs(); | 95 double start_ms = heap->MonotonicallyIncreasingTimeInMs(); |
96 job_->NotifyIdleTask(); | 96 job_->NotifyIdleTask(); |
97 job_->NotifyIdleTaskProgress(); | 97 job_->NotifyIdleTaskProgress(); |
98 if (Step(heap, deadline_in_ms) == kMoreWork) { | 98 if (Step(heap, deadline_in_ms) == kMoreWork) { |
99 job_->ScheduleIdleTask(heap); | 99 job_->ScheduleIdleTask(heap); |
100 } | 100 } |
101 if (FLAG_trace_idle_notification) { | 101 if (FLAG_trace_idle_notification) { |
102 double current_time_ms = heap->MonotonicallyIncreasingTimeInMs(); | 102 double current_time_ms = heap->MonotonicallyIncreasingTimeInMs(); |
103 double idle_time_in_ms = deadline_in_ms - start_ms; | 103 double idle_time_in_ms = deadline_in_ms - start_ms; |
104 double deadline_difference = deadline_in_ms - current_time_ms; | 104 double deadline_difference = deadline_in_ms - current_time_ms; |
105 PrintIsolate(isolate_, "%8.0f ms: ", isolate_->time_millis_since_init()); | 105 PrintIsolate(isolate(), "%8.0f ms: ", isolate()->time_millis_since_init()); |
106 PrintF( | 106 PrintF( |
107 "Idle task: requested idle time %.2f ms, used idle time %.2f " | 107 "Idle task: requested idle time %.2f ms, used idle time %.2f " |
108 "ms, deadline usage %.2f ms\n", | 108 "ms, deadline usage %.2f ms\n", |
109 idle_time_in_ms, idle_time_in_ms - deadline_difference, | 109 idle_time_in_ms, idle_time_in_ms - deadline_difference, |
110 deadline_difference); | 110 deadline_difference); |
111 } | 111 } |
112 } | 112 } |
113 | 113 |
114 | 114 |
115 void IncrementalMarkingJob::DelayedTask::Step(Heap* heap) { | 115 void IncrementalMarkingJob::DelayedTask::Step(Heap* heap) { |
116 const int kIncrementalMarkingDelayMs = 50; | 116 const int kIncrementalMarkingDelayMs = 50; |
117 double deadline = | 117 double deadline = |
118 heap->MonotonicallyIncreasingTimeInMs() + kIncrementalMarkingDelayMs; | 118 heap->MonotonicallyIncreasingTimeInMs() + kIncrementalMarkingDelayMs; |
119 heap->incremental_marking()->AdvanceIncrementalMarking( | 119 heap->incremental_marking()->AdvanceIncrementalMarking( |
120 0, deadline, i::IncrementalMarking::StepActions( | 120 0, deadline, i::IncrementalMarking::StepActions( |
121 i::IncrementalMarking::NO_GC_VIA_STACK_GUARD, | 121 i::IncrementalMarking::NO_GC_VIA_STACK_GUARD, |
122 i::IncrementalMarking::FORCE_MARKING, | 122 i::IncrementalMarking::FORCE_MARKING, |
123 i::IncrementalMarking::FORCE_COMPLETION)); | 123 i::IncrementalMarking::FORCE_COMPLETION)); |
124 heap->FinalizeIncrementalMarkingIfComplete( | 124 heap->FinalizeIncrementalMarkingIfComplete( |
125 "Incremental marking task: finalize incremental marking"); | 125 "Incremental marking task: finalize incremental marking"); |
126 } | 126 } |
127 | 127 |
128 | 128 |
129 void IncrementalMarkingJob::DelayedTask::RunInternal() { | 129 void IncrementalMarkingJob::DelayedTask::RunInternal() { |
130 Heap* heap = isolate_->heap(); | 130 Heap* heap = isolate()->heap(); |
131 job_->NotifyDelayedTask(); | 131 job_->NotifyDelayedTask(); |
132 IncrementalMarking* incremental_marking = heap->incremental_marking(); | 132 IncrementalMarking* incremental_marking = heap->incremental_marking(); |
133 if (!incremental_marking->IsStopped()) { | 133 if (!incremental_marking->IsStopped()) { |
134 if (job_->ShouldForceMarkingStep()) { | 134 if (job_->ShouldForceMarkingStep()) { |
135 Step(heap); | 135 Step(heap); |
136 } | 136 } |
137 // The Step() above could have finished incremental marking. | 137 // The Step() above could have finished incremental marking. |
138 if (!incremental_marking->IsStopped()) { | 138 if (!incremental_marking->IsStopped()) { |
139 job_->ScheduleDelayedTask(heap); | 139 job_->ScheduleDelayedTask(heap); |
140 } | 140 } |
141 } | 141 } |
142 } | 142 } |
143 | 143 |
144 } // namespace internal | 144 } // namespace internal |
145 } // namespace v8 | 145 } // namespace v8 |
OLD | NEW |