blob: 830584910af44534227df4c4e1805796e3ea1ef1 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
|
// Copyright 2020 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef V8_HEAP_CPPGC_CONCURRENT_MARKER_H_
#define V8_HEAP_CPPGC_CONCURRENT_MARKER_H_
#include "include/cppgc/platform.h"
#include "src/heap/cppgc/incremental-marking-schedule.h"
#include "src/heap/cppgc/marking-state.h"
#include "src/heap/cppgc/marking-visitor.h"
#include "src/heap/cppgc/marking-worklists.h"
namespace cppgc {
namespace internal {
class V8_EXPORT_PRIVATE ConcurrentMarkerBase {
public:
ConcurrentMarkerBase(HeapBase&, MarkingWorklists&,
IncrementalMarkingSchedule&, cppgc::Platform*);
virtual ~ConcurrentMarkerBase();
ConcurrentMarkerBase(const ConcurrentMarkerBase&) = delete;
ConcurrentMarkerBase& operator=(const ConcurrentMarkerBase&) = delete;
void Start();
void Cancel();
void JoinForTesting();
void NotifyIncrementalMutatorStepCompleted();
bool IsActive() const;
HeapBase& heap() const { return heap_; }
MarkingWorklists& marking_worklists() const { return marking_worklists_; }
IncrementalMarkingSchedule& incremental_marking_schedule() const {
return incremental_marking_schedule_;
}
virtual std::unique_ptr<Visitor> CreateConcurrentMarkingVisitor(
ConcurrentMarkingState&) const = 0;
protected:
void IncreaseMarkingPriorityIfNeeded();
private:
HeapBase& heap_;
MarkingWorklists& marking_worklists_;
IncrementalMarkingSchedule& incremental_marking_schedule_;
cppgc::Platform* const platform_;
// The job handle doubles as flag to denote concurrent marking was started.
std::unique_ptr<JobHandle> concurrent_marking_handle_{nullptr};
size_t last_concurrently_marked_bytes_ = 0;
v8::base::TimeTicks last_concurrently_marked_bytes_update_;
bool concurrent_marking_priority_increased_{false};
};
class V8_EXPORT_PRIVATE ConcurrentMarker : public ConcurrentMarkerBase {
public:
ConcurrentMarker(HeapBase& heap, MarkingWorklists& marking_worklists,
IncrementalMarkingSchedule& incremental_marking_schedule,
cppgc::Platform* platform)
: ConcurrentMarkerBase(heap, marking_worklists,
incremental_marking_schedule, platform) {}
std::unique_ptr<Visitor> CreateConcurrentMarkingVisitor(
ConcurrentMarkingState&) const final;
};
} // namespace internal
} // namespace cppgc
#endif // V8_HEAP_CPPGC_CONCURRENT_MARKER_H_
|