v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
concurrent-marker.h
Go to the documentation of this file.
1// Copyright 2020 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_CPPGC_CONCURRENT_MARKER_H_
6#define V8_HEAP_CPPGC_CONCURRENT_MARKER_H_
7
13
14namespace cppgc {
15namespace internal {
16
18 public:
22 virtual ~ConcurrentMarkerBase();
23
26
27 void Start();
28 // Returns whether the job has been joined.
29 bool Join();
30 // Returns whether the job has been cancelled.
31 bool Cancel();
32
33 void NotifyIncrementalMutatorStepCompleted();
34 void NotifyOfWorkIfNeeded(cppgc::TaskPriority priority);
35
36 bool IsActive() const;
37
38 HeapBase& heap() const { return heap_; }
41 return incremental_marking_schedule_;
42 }
43
44 void AddConcurrentlyMarkedBytes(size_t marked_bytes);
46 return concurrently_marked_bytes_.load(std::memory_order_relaxed);
47 }
48
49 virtual std::unique_ptr<Visitor> CreateConcurrentMarkingVisitor(
50 ConcurrentMarkingState&) const = 0;
51
52 protected:
53 void IncreaseMarkingPriorityIfNeeded();
54
55 private:
60
61 // The job handle doubles as flag to denote concurrent marking was started.
62 std::unique_ptr<JobHandle> concurrent_marking_handle_{nullptr};
63
64 std::atomic<size_t> concurrently_marked_bytes_ = 0;
65 bool concurrent_marking_priority_increased_{false};
66};
67
69 public:
71 HeapBase& heap, MarkingWorklists& marking_worklists,
72 heap::base::IncrementalMarkingSchedule& incremental_marking_schedule,
73 cppgc::Platform* platform)
74 : ConcurrentMarkerBase(heap, marking_worklists,
75 incremental_marking_schedule, platform) {}
76
77 std::unique_ptr<Visitor> CreateConcurrentMarkingVisitor(
78 ConcurrentMarkingState&) const final;
79};
80
81} // namespace internal
82} // namespace cppgc
83
84#endif // V8_HEAP_CPPGC_CONCURRENT_MARKER_H_
ConcurrentMarkerBase(const ConcurrentMarkerBase &)=delete
heap::base::IncrementalMarkingSchedule & incremental_marking_schedule_
heap::base::IncrementalMarkingSchedule & incremental_marking_schedule() const
virtual std::unique_ptr< Visitor > CreateConcurrentMarkingVisitor(ConcurrentMarkingState &) const =0
ConcurrentMarkerBase & operator=(const ConcurrentMarkerBase &)=delete
MarkingWorklists & marking_worklists() const
ConcurrentMarker(HeapBase &heap, MarkingWorklists &marking_worklists, heap::base::IncrementalMarkingSchedule &incremental_marking_schedule, cppgc::Platform *platform)
size_t priority
TaskPriority
Definition v8-platform.h:24
MarkingWorklists marking_worklists_
#define V8_EXPORT_PRIVATE
Definition macros.h:460
Heap * heap_