| 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" |
| 11 #include "src/isolate.h" | 11 #include "src/isolate.h" |
| 12 #include "src/v8.h" | 12 #include "src/v8.h" |
| 13 | 13 |
| 14 namespace v8 { | 14 namespace v8 { |
| 15 namespace internal { | 15 namespace internal { |
| 16 | 16 |
| 17 void IncrementalMarkingJob::Start(Heap* heap) { | 17 void IncrementalMarkingJob::Start(Heap* heap) { |
| 18 DCHECK(!heap->incremental_marking()->IsStopped()); | 18 DCHECK(!heap->incremental_marking()->IsStopped()); |
| 19 ScheduleTask(heap); | 19 ScheduleTask(heap); |
| 20 } | 20 } |
| 21 | 21 |
| 22 void IncrementalMarkingJob::NotifyTask() { task_pending_ = false; } | 22 void IncrementalMarkingJob::NotifyTask() { task_pending_.SetValue(false); } |
| 23 | 23 |
| 24 void IncrementalMarkingJob::ScheduleTask(Heap* heap) { | 24 void IncrementalMarkingJob::ScheduleTask(Heap* heap) { |
| 25 if (!task_pending_) { | 25 if (task_pending_.TrySetValue(false, true)) { |
| 26 v8::Isolate* isolate = reinterpret_cast<v8::Isolate*>(heap->isolate()); | 26 v8::Isolate* isolate = reinterpret_cast<v8::Isolate*>(heap->isolate()); |
| 27 task_pending_ = true; | |
| 28 auto task = new Task(heap->isolate(), this); | 27 auto task = new Task(heap->isolate(), this); |
| 29 V8::GetCurrentPlatform()->CallOnForegroundThread(isolate, task); | 28 V8::GetCurrentPlatform()->CallOnForegroundThread(isolate, task); |
| 30 } | 29 } |
| 31 } | 30 } |
| 32 | 31 |
| 33 void IncrementalMarkingJob::Task::Step(Heap* heap) { | 32 void IncrementalMarkingJob::Task::Step(Heap* heap) { |
| 34 const int kIncrementalMarkingDelayMs = 1; | 33 const int kIncrementalMarkingDelayMs = 1; |
| 35 double deadline = | 34 double deadline = |
| 36 heap->MonotonicallyIncreasingTimeInMs() + kIncrementalMarkingDelayMs; | 35 heap->MonotonicallyIncreasingTimeInMs() + kIncrementalMarkingDelayMs; |
| 37 heap->incremental_marking()->AdvanceIncrementalMarking( | 36 heap->incremental_marking()->AdvanceIncrementalMarking( |
| (...skipping 18 matching lines...) Expand all Loading... |
| 56 if (!incremental_marking->IsStopped()) { | 55 if (!incremental_marking->IsStopped()) { |
| 57 Step(heap); | 56 Step(heap); |
| 58 if (!incremental_marking->IsStopped()) { | 57 if (!incremental_marking->IsStopped()) { |
| 59 job_->ScheduleTask(heap); | 58 job_->ScheduleTask(heap); |
| 60 } | 59 } |
| 61 } | 60 } |
| 62 } | 61 } |
| 63 | 62 |
| 64 } // namespace internal | 63 } // namespace internal |
| 65 } // namespace v8 | 64 } // namespace v8 |
| OLD | NEW |