v8 12.4.254 (node 22.4.1)
V8 is Google's open source JavaScript engine
Loading...
Searching...
No Matches
trace-trait.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 INCLUDE_CPPGC_TRACE_TRAIT_H_
6#define INCLUDE_CPPGC_TRACE_TRAIT_H_
7
8#include <type_traits>
9
10#include "cppgc/type-traits.h"
11#include "v8config.h" // NOLINT(build/include_directory)
12
13namespace cppgc {
14
15class Visitor;
16
17namespace internal {
18
19class RootVisitor;
20
21using TraceRootCallback = void (*)(RootVisitor&, const void* object);
22
23// Implementation of the default TraceTrait handling GarbageCollected and
24// GarbageCollectedMixin.
25template <typename T,
26 bool =
27 IsGarbageCollectedMixinTypeV<typename std::remove_const<T>::type>>
29
30} // namespace internal
31
38using TraceCallback = void (*)(Visitor* visitor, const void* object);
39
54};
55
62using TraceDescriptorCallback = TraceDescriptor (*)(const void* address);
63
64namespace internal {
65
67 static TraceDescriptor GetTraceDescriptor(const void* address);
68};
69
76template <typename T>
78 static_assert(internal::IsTraceableV<T>, "T must have a Trace() method");
79
86 static TraceDescriptor GetTraceDescriptor(const void* self) {
88 static_cast<const T*>(self));
89 }
90
97 static void Trace(Visitor* visitor, const void* self) {
98 static_cast<const T*>(self)->Trace(visitor);
99 }
100};
101
102} // namespace internal
103
104template <typename T>
106
107namespace internal {
108
109template <typename T>
111 static_assert(IsGarbageCollectedTypeV<T>,
112 "T must be of type GarbageCollected or GarbageCollectedMixin");
113 static TraceDescriptor GetTraceDescriptor(const void* self) {
114 return {self, TraceTrait<T>::Trace};
115 }
116};
117
118template <typename T>
120 static TraceDescriptor GetTraceDescriptor(const void* self) {
122 }
123};
124
125} // namespace internal
126} // namespace cppgc
127
128#endif // INCLUDE_CPPGC_TRACE_TRAIT_H_
void(*)(RootVisitor &, const void *object) TraceRootCallback
Definition trace-trait.h:21
TraceDescriptor(*)(const void *address) TraceDescriptorCallback
Definition trace-trait.h:62
void(*)(Visitor *visitor, const void *object) TraceCallback
Definition trace-trait.h:38
TraceCallback callback
Definition trace-trait.h:53
const void * base_object_payload
Definition trace-trait.h:49
static void Trace(Visitor *visitor, const void *self)
Definition trace-trait.h:97
static TraceDescriptor GetTraceDescriptor(const void *self)
Definition trace-trait.h:86
static TraceDescriptor GetTraceDescriptor(const void *address)
static TraceDescriptor GetTraceDescriptor(const void *self)
static TraceDescriptor GetTraceDescriptor(const void *self)
#define V8_EXPORT
Definition v8config.h:753