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 3 // found in the LICENSE file. 4 5 #ifndef V8_HEAP_INCREMENTAL_MARKING_JOB_H_ 6 #define V8_HEAP_INCREMENTAL_MARKING_JOB_H_ 7 8 #include "src/cancelable-task.h" 9 10 namespace v8 { 11 namespace internal { 12 13 class Heap; 14 class Isolate; 15 16 // 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 // step and posts another task until the marking is completed. 19 class IncrementalMarkingJob { 20 public: 21 class Task : public CancelableTask { 22 public: Task(Isolate * isolate,IncrementalMarkingJob * job)23 explicit Task(Isolate* isolate, IncrementalMarkingJob* job) 24 : CancelableTask(isolate), isolate_(isolate), job_(job) {} 25 static void Step(Heap* heap); 26 // CancelableTask overrides. 27 void RunInternal() override; 28 isolate()29 Isolate* isolate() { return isolate_; } 30 31 private: 32 Isolate* isolate_; 33 IncrementalMarkingJob* job_; 34 }; 35 IncrementalMarkingJob()36 IncrementalMarkingJob() : task_pending_(false) {} 37 TaskPending()38 bool TaskPending() { return task_pending_; } 39 40 void Start(Heap* heap); 41 42 void ScheduleTask(Heap* heap); 43 44 private: 45 bool task_pending_; 46 }; 47 } // namespace internal 48 } // namespace v8 49 50 #endif // V8_HEAP_INCREMENTAL_MARKING_JOB_H_ 51