v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
prefinalizer.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_PREFINALIZER_H_
6
#define INCLUDE_CPPGC_PREFINALIZER_H_
7
8
#include "
cppgc/internal/compiler-specific.h
"
9
#include "
cppgc/liveness-broker.h
"
10
11
namespace
cppgc
{
12
13
namespace
internal
{
14
15
class
V8_EXPORT
PrefinalizerRegistration
final {
16
public
:
17
using
Callback
= bool (*)(
const
cppgc::LivenessBroker
&,
void
*);
18
19
PrefinalizerRegistration
(
void
*,
Callback
);
20
21
void
*
operator
new
(size_t,
void
* location) =
delete
;
22
void
*
operator
new
(size_t) =
delete
;
23
};
24
25
}
// namespace internal
26
56
#define CPPGC_USING_PRE_FINALIZER(Class, PreFinalizer) \
57
public: \
58
static bool InvokePreFinalizer(const cppgc::LivenessBroker& liveness_broker, \
59
void* object) { \
60
static_assert(cppgc::IsGarbageCollectedOrMixinTypeV<Class>, \
61
"Only garbage collected objects can have prefinalizers"); \
62
Class* self = static_cast<Class*>(object); \
63
if (liveness_broker.IsHeapObjectAlive(self)) return false; \
64
self->PreFinalizer(); \
65
return true; \
66
} \
67
\
68
private: \
69
CPPGC_NO_UNIQUE_ADDRESS cppgc::internal::PrefinalizerRegistration \
70
prefinalizer_dummy_{this, Class::InvokePreFinalizer}; \
71
static_assert(true, "Force semicolon.")
72
73
}
// namespace cppgc
74
75
#endif
// INCLUDE_CPPGC_PREFINALIZER_H_
cppgc::LivenessBroker
Definition
liveness-broker.h:44
cppgc::internal::PrefinalizerRegistration
Definition
prefinalizer.h:15
cppgc::internal::PrefinalizerRegistration::Callback
bool(*)(const cppgc::LivenessBroker &, void *) Callback
Definition
prefinalizer.h:17
compiler-specific.h
liveness-broker.h
cppgc
Definition
cross-heap-remembered-set.h:14
v8::internal::internal
internal
Definition
wasm-objects-inl.h:458
V8_EXPORT
#define V8_EXPORT
Definition
v8config.h:800
include
cppgc
prefinalizer.h
Generated on Sun Apr 6 2025 21:08:50 for v8 by
1.12.0