5 #ifndef V8_HEAP_CONCURRENT_MARKING_H_ 6 #define V8_HEAP_CONCURRENT_MARKING_H_ 8 #include "include/v8-platform.h" 9 #include "src/allocation.h" 10 #include "src/base/atomic-utils.h" 11 #include "src/base/platform/condition-variable.h" 12 #include "src/base/platform/mutex.h" 13 #include "src/cancelable-task.h" 14 #include "src/heap/spaces.h" 15 #include "src/heap/worklist.h" 16 #include "src/utils.h" 24 class MajorNonAtomicMarkingState;
28 std::unordered_map<MemoryChunk*, intptr_t, MemoryChunk::Hasher>;
42 const bool resume_on_exit_;
45 enum class StopRequest {
49 COMPLETE_ONGOING_TASKS,
53 COMPLETE_TASKS_FOR_TESTING,
59 static constexpr
int kMaxTasks = 7;
64 MarkingWorklist* bailout, MarkingWorklist* on_hold,
66 EmbedderTracingWorklist* embedder_objects);
75 bool Stop(StopRequest stop_request);
77 void RescheduleTasksIfNeeded();
84 int TaskCount() {
return task_count_; }
89 size_t TotalMarkedBytes();
91 void set_ephemeron_marked(
bool ephemeron_marked) {
92 ephemeron_marked_.store(ephemeron_marked);
94 bool ephemeron_marked() {
return ephemeron_marked_.load(); }
100 std::atomic<bool> preemption_request;
102 LiveBytesMap live_bytes;
103 size_t marked_bytes = 0;
104 char cache_line_padding[64];
107 void Run(
int task_id, TaskState* task_state);
109 MarkingWorklist*
const shared_;
110 MarkingWorklist*
const bailout_;
111 MarkingWorklist*
const on_hold_;
112 WeakObjects*
const weak_objects_;
113 EmbedderTracingWorklist*
const embedder_objects_;
114 TaskState task_state_[kMaxTasks + 1];
115 std::atomic<size_t> total_marked_bytes_{0};
116 std::atomic<bool> ephemeron_marked_{
false};
117 base::Mutex pending_lock_;
118 base::ConditionVariable pending_condition_;
119 int pending_task_count_ = 0;
120 bool is_pending_[kMaxTasks + 1] = {};
121 CancelableTaskManager::Id cancelable_id_[kMaxTasks + 1] = {};
128 #endif // V8_HEAP_CONCURRENT_MARKING_H_