v8 12.4.254 (node 22.4.1)
V8 is Google's open source JavaScript engine
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
10
11namespace cppgc {
12
13namespace internal {
14
16 public:
17 using Callback = bool (*)(const cppgc::LivenessBroker&, void*);
18
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_
bool(*)(const cppgc::LivenessBroker &, void *) Callback
#define V8_EXPORT
Definition v8config.h:753