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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
|
// 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_JS_UNIFIED_HEAP_MARKING_VISITOR_H_
#define V8_HEAP_CPPGC_JS_UNIFIED_HEAP_MARKING_VISITOR_H_
#include "include/cppgc/trace-trait.h"
#include "include/v8-cppgc.h"
#include "src/base/macros.h"
#include "src/heap/cppgc-js/unified-heap-marking-state.h"
#include "src/heap/cppgc/marking-visitor.h"
namespace cppgc {
class SourceLocation;
namespace internal {
class ConcurrentMarkingState;
class MarkingStateBase;
class MutatorMarkingState;
} // namespace internal
} // namespace cppgc
namespace v8 {
namespace internal {
using cppgc::SourceLocation;
using cppgc::TraceDescriptor;
using cppgc::WeakCallback;
using cppgc::internal::HeapBase;
using cppgc::internal::MutatorMarkingState;
class V8_EXPORT_PRIVATE UnifiedHeapMarkingVisitorBase : public JSVisitor {
public:
UnifiedHeapMarkingVisitorBase(HeapBase&, cppgc::internal::MarkingStateBase&,
UnifiedHeapMarkingState&);
~UnifiedHeapMarkingVisitorBase() override = default;
protected:
// C++ handling.
void Visit(const void*, TraceDescriptor) final;
void VisitWeak(const void*, TraceDescriptor, WeakCallback, const void*) final;
void VisitEphemeron(const void*, TraceDescriptor) final;
void VisitWeakContainer(const void* self, TraceDescriptor strong_desc,
TraceDescriptor weak_desc, WeakCallback callback,
const void* data) final;
void RegisterWeakCallback(WeakCallback, const void*) final;
void HandleMovableReference(const void**) final;
// JS handling.
void Visit(const TracedReferenceBase& ref) final;
cppgc::internal::MarkingStateBase& marking_state_;
UnifiedHeapMarkingState& unified_heap_marking_state_;
};
class V8_EXPORT_PRIVATE MutatorUnifiedHeapMarkingVisitor final
: public UnifiedHeapMarkingVisitorBase {
public:
MutatorUnifiedHeapMarkingVisitor(HeapBase&, MutatorMarkingState&,
UnifiedHeapMarkingState&);
~MutatorUnifiedHeapMarkingVisitor() override = default;
protected:
void VisitRoot(const void*, TraceDescriptor, const SourceLocation&) final;
void VisitWeakRoot(const void*, TraceDescriptor, WeakCallback, const void*,
const SourceLocation&) final;
};
class V8_EXPORT_PRIVATE ConcurrentUnifiedHeapMarkingVisitor final
: public UnifiedHeapMarkingVisitorBase {
public:
ConcurrentUnifiedHeapMarkingVisitor(HeapBase&,
cppgc::internal::ConcurrentMarkingState&,
UnifiedHeapMarkingState&);
~ConcurrentUnifiedHeapMarkingVisitor() override = default;
protected:
void VisitRoot(const void*, TraceDescriptor, const SourceLocation&) final {
UNREACHABLE();
}
void VisitWeakRoot(const void*, TraceDescriptor, WeakCallback, const void*,
const SourceLocation&) final {
UNREACHABLE();
}
bool DeferTraceToMutatorThreadIfConcurrent(const void*, cppgc::TraceCallback,
size_t) final;
};
} // namespace internal
} // namespace v8
#endif // V8_HEAP_CPPGC_JS_UNIFIED_HEAP_MARKING_VISITOR_H_
|