| 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_JOB_H_ | 5 #ifndef V8_HEAP_INCREMENTAL_MARKING_JOB_H_ |
| 6 #define V8_HEAP_INCREMENTAL_MARKING_JOB_H_ | 6 #define V8_HEAP_INCREMENTAL_MARKING_JOB_H_ |
| 7 | 7 |
| 8 #include "src/base/atomic-utils.h" |
| 8 #include "src/cancelable-task.h" | 9 #include "src/cancelable-task.h" |
| 9 | 10 |
| 10 namespace v8 { | 11 namespace v8 { |
| 11 namespace internal { | 12 namespace internal { |
| 12 | 13 |
| 13 class Heap; | 14 class Heap; |
| 14 class Isolate; | 15 class Isolate; |
| 15 | 16 |
| 16 // The incremental marking job uses platform tasks to perform incremental | 17 // The incremental marking job uses platform tasks to perform incremental |
| 17 // marking steps. The job posts a foreground task that makes a small (~1ms) | 18 // marking steps. The job posts a foreground task that makes a small (~1ms) |
| 18 // step and posts another task until the marking is completed. | 19 // step and posts another task until the marking is completed. |
| 19 class IncrementalMarkingJob { | 20 class IncrementalMarkingJob { |
| 20 public: | 21 public: |
| 21 class Task : public CancelableTask { | 22 class Task : public CancelableTask { |
| 22 public: | 23 public: |
| 23 explicit Task(Isolate* isolate, IncrementalMarkingJob* job) | 24 explicit Task(Isolate* isolate, IncrementalMarkingJob* job) |
| 24 : CancelableTask(isolate), job_(job) {} | 25 : CancelableTask(isolate), job_(job) {} |
| 25 static void Step(Heap* heap); | 26 static void Step(Heap* heap); |
| 26 // CancelableTask overrides. | 27 // CancelableTask overrides. |
| 27 void RunInternal() override; | 28 void RunInternal() override; |
| 28 | 29 |
| 29 private: | 30 private: |
| 30 IncrementalMarkingJob* job_; | 31 IncrementalMarkingJob* job_; |
| 31 }; | 32 }; |
| 32 | 33 |
| 33 IncrementalMarkingJob() : task_pending_(false) {} | 34 IncrementalMarkingJob() : task_pending_(false) {} |
| 34 | 35 |
| 35 bool TaskPending() { return task_pending_; } | |
| 36 | |
| 37 void Start(Heap* heap); | 36 void Start(Heap* heap); |
| 38 | 37 |
| 39 void NotifyTask(); | 38 void NotifyTask(); |
| 40 | 39 |
| 41 void ScheduleTask(Heap* heap); | 40 void ScheduleTask(Heap* heap); |
| 42 | 41 |
| 43 private: | 42 private: |
| 44 bool task_pending_; | 43 base::AtomicValue<bool> task_pending_; |
| 45 }; | 44 }; |
| 46 } // namespace internal | 45 } // namespace internal |
| 47 } // namespace v8 | 46 } // namespace v8 |
| 48 | 47 |
| 49 #endif // V8_HEAP_INCREMENTAL_MARKING_JOB_H_ | 48 #endif // V8_HEAP_INCREMENTAL_MARKING_JOB_H_ |
| OLD | NEW |