| OLD | NEW |
| 1 // Copyright 2017 the V8 project authors. All rights reserved. | 1 // Copyright 2017 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_CONCURRENT_MARKING_ | 5 #ifndef V8_HEAP_CONCURRENT_MARKING_ |
| 6 #define V8_HEAP_CONCURRENT_MARKING_ | 6 #define V8_HEAP_CONCURRENT_MARKING_ |
| 7 | 7 |
| 8 #include <vector> |
| 9 |
| 8 #include "src/allocation.h" | 10 #include "src/allocation.h" |
| 9 #include "src/cancelable-task.h" | 11 #include "src/cancelable-task.h" |
| 10 #include "src/locked-queue.h" | |
| 11 #include "src/utils.h" | 12 #include "src/utils.h" |
| 12 #include "src/v8.h" | 13 #include "src/v8.h" |
| 13 | 14 |
| 14 namespace v8 { | 15 namespace v8 { |
| 15 namespace internal { | 16 namespace internal { |
| 16 | 17 |
| 17 class Heap; | 18 class Heap; |
| 18 class Isolate; | 19 class Isolate; |
| 19 | 20 |
| 20 class ConcurrentMarking { | 21 class ConcurrentMarking { |
| 21 public: | 22 public: |
| 22 static const int kMaxNumberOfTasks = 10; | |
| 23 | |
| 24 explicit ConcurrentMarking(Heap* heap); | 23 explicit ConcurrentMarking(Heap* heap); |
| 25 ~ConcurrentMarking(); | 24 ~ConcurrentMarking(); |
| 26 | 25 |
| 27 void EnqueueObject(HeapObject* object); | 26 void AddRoot(HeapObject* object); |
| 28 bool IsQueueEmpty(); | |
| 29 | 27 |
| 30 void StartMarkingTasks(int number_of_tasks); | 28 void StartMarkingTask(); |
| 31 void WaitForTasksToComplete(); | 29 void WaitForTaskToComplete(); |
| 32 | 30 |
| 33 private: | 31 private: |
| 34 class Task; | 32 class Task; |
| 35 // TODO(ulan): Replace with faster queue. | |
| 36 typedef LockedQueue<HeapObject*> Queue; | |
| 37 | |
| 38 Heap* heap_; | 33 Heap* heap_; |
| 39 base::Semaphore pending_tasks_; | 34 base::Semaphore pending_task_; |
| 40 Queue queue_; | 35 std::vector<HeapObject*> root_set_; |
| 41 int number_of_tasks_; | |
| 42 uint32_t task_ids_[kMaxNumberOfTasks]; | |
| 43 }; | 36 }; |
| 44 | 37 |
| 45 } // namespace internal | 38 } // namespace internal |
| 46 } // namespace v8 | 39 } // namespace v8 |
| 47 | 40 |
| 48 #endif // V8_HEAP_PAGE_PARALLEL_JOB_ | 41 #endif // V8_HEAP_PAGE_PARALLEL_JOB_ |
| OLD | NEW |