V8
latest master commit
V8 is Google's open source JavaScript engine
Main Page
Related Pages
Namespaces
Namespace List
Namespace Members
All
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
r
s
t
u
v
w
Functions
a
c
d
f
g
h
i
j
m
n
o
p
r
s
t
u
Variables
Typedefs
a
b
c
d
e
f
g
h
i
j
l
m
n
o
p
r
s
t
u
v
w
Enumerations
a
c
e
g
i
j
k
m
n
p
r
s
t
w
Enumerator
a
b
c
d
e
g
i
j
k
n
o
p
r
s
Data Structures
Data Structures
Data Structure Index
Class Hierarchy
Data Fields
All
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
~
Functions
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
~
Variables
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
Typedefs
a
b
c
d
e
g
i
m
n
p
r
s
t
u
w
Enumerations
a
b
c
e
f
g
m
n
o
p
s
t
u
w
Enumerator
b
c
d
e
h
j
k
n
o
p
r
s
t
u
Related Functions
a
c
d
e
f
g
h
i
j
l
m
n
o
p
r
s
t
u
v
w
Files
File List
Globals
All
c
m
s
u
v
Macros
c
m
s
u
v
Examples
•
All
Data Structures
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Pages
garbage-collected.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_GARBAGE_COLLECTED_H_
6
#define INCLUDE_CPPGC_GARBAGE_COLLECTED_H_
7
8
#include <type_traits>
9
10
#include "
cppgc/internal/api-constants.h
"
11
#include "
cppgc/platform.h
"
12
#include "
cppgc/trace-trait.h
"
13
#include "
cppgc/type-traits.h
"
14
15
namespace
cppgc
{
16
17
class
Visitor;
18
19
namespace
internal {
20
21
class
GarbageCollectedBase
{
22
public
:
23
// Must use MakeGarbageCollected.
24
void
*
operator
new
(size_t) =
delete
;
25
void
*
operator
new
[](size_t) =
delete
;
26
// The garbage collector is taking care of reclaiming the object. Also,
27
// virtual destructor requires an unambiguous, accessible 'operator delete'.
28
void
operator
delete
(
void
*) {
29
#ifdef V8_ENABLE_CHECKS
30
internal::Abort
();
31
#endif // V8_ENABLE_CHECKS
32
}
33
void
operator
delete
[](
void
*) =
delete
;
34
35
protected
:
36
GarbageCollectedBase
() =
default
;
37
};
38
39
}
// namespace internal
40
76
template
<
typename
>
77
class
GarbageCollected
:
public
internal::GarbageCollectedBase
{
78
public
:
79
using
IsGarbageCollectedTypeMarker
= void;
80
81
protected
:
82
GarbageCollected
() =
default
;
83
};
84
103
class
GarbageCollectedMixin
:
public
internal::GarbageCollectedBase
{
104
public
:
105
using
IsGarbageCollectedMixinTypeMarker
= void;
106
107
// Sentinel used to mark not-fully-constructed mixins.
108
static
constexpr
void
*
kNotFullyConstructedObject
=
nullptr
;
109
110
// Provide default implementation that indicate that the vtable is not yet
111
// set up properly. This is used to to get GCInfo objects for mixins so that
112
// these objects can be processed later on.
113
virtual
TraceDescriptor
GetTraceDescriptor
()
const
{
114
return
{
kNotFullyConstructedObject
,
nullptr
};
115
}
116
121
virtual
void
Trace
(
cppgc::Visitor
*)
const
{}
122
};
123
147
#define USING_GARBAGE_COLLECTED_MIXIN() \
148
public: \
149
/* Marker is used by clang to check for proper usages of the macro. */
\
150
typedef int HasUsingGarbageCollectedMixinMacro; \
151
\
152
TraceDescriptor GetTraceDescriptor() const override { \
153
static_assert( \
154
internal::IsSubclassOfTemplate< \
155
std::remove_const_t<std::remove_pointer_t<decltype(this)>>, \
156
cppgc::GarbageCollected>::value, \
157
"Only garbage collected objects can have garbage collected mixins"); \
158
return {this, TraceTrait<std::remove_const_t< \
159
std::remove_pointer_t<decltype(this)>>>::Trace}; \
160
} \
161
\
162
private: \
163
static_assert(true, "Force semicolon.")
164
177
#define MERGE_GARBAGE_COLLECTED_MIXINS() \
178
public: \
179
/* When using multiple mixins the methods become */
\
180
/* ambigous. Providing additional implementations */
\
181
/* disambiguate them again. */
\
182
TraceDescriptor GetTraceDescriptor() const override { \
183
return {kNotFullyConstructedObject, nullptr}; \
184
} \
185
\
186
private: \
187
static_assert(true, "Force semicolon.")
188
189
}
// namespace cppgc
190
191
#endif // INCLUDE_CPPGC_GARBAGE_COLLECTED_H_
cppgc::internal::Abort
V8_EXPORT void Abort()
cppgc::GarbageCollected
Definition:
garbage-collected.h:77
cppgc::GarbageCollected::GarbageCollected
GarbageCollected()=default
cppgc
Definition:
allocation.h:18
cppgc::GarbageCollectedMixin::kNotFullyConstructedObject
static constexpr void * kNotFullyConstructedObject
Definition:
garbage-collected.h:108
api-constants.h
cppgc::TraceDescriptor
Definition:
trace-trait.h:27
cppgc::GarbageCollectedMixin::Trace
virtual void Trace(cppgc::Visitor *) const
Definition:
garbage-collected.h:121
trace-trait.h
cppgc::GarbageCollectedMixin::GetTraceDescriptor
virtual TraceDescriptor GetTraceDescriptor() const
Definition:
garbage-collected.h:113
cppgc::GarbageCollectedMixin::IsGarbageCollectedMixinTypeMarker
void IsGarbageCollectedMixinTypeMarker
Definition:
garbage-collected.h:105
cppgc::Visitor
Definition:
visitor.h:27
platform.h
cppgc::internal::GarbageCollectedBase::GarbageCollectedBase
GarbageCollectedBase()=default
cppgc::GarbageCollectedMixin
Definition:
garbage-collected.h:103
type-traits.h
cppgc::internal::GarbageCollectedBase
Definition:
garbage-collected.h:21
cppgc::GarbageCollected::IsGarbageCollectedTypeMarker
void IsGarbageCollectedTypeMarker
Definition:
garbage-collected.h:79
v8
include
cppgc
garbage-collected.h
Generated by
1.8.17