libv8-node 16.10.0.0-x86_64-darwin
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/ext/libv8-node/.location.yml +1 -0
- data/ext/libv8-node/location.rb +76 -0
- data/ext/libv8-node/paths.rb +34 -0
- data/lib/libv8/node/version.rb +7 -0
- data/lib/libv8/node.rb +11 -0
- data/lib/libv8-node.rb +1 -0
- data/vendor/v8/include/cppgc/allocation.h +232 -0
- data/vendor/v8/include/cppgc/common.h +29 -0
- data/vendor/v8/include/cppgc/cross-thread-persistent.h +384 -0
- data/vendor/v8/include/cppgc/custom-space.h +97 -0
- data/vendor/v8/include/cppgc/default-platform.h +75 -0
- data/vendor/v8/include/cppgc/ephemeron-pair.h +30 -0
- data/vendor/v8/include/cppgc/explicit-management.h +82 -0
- data/vendor/v8/include/cppgc/garbage-collected.h +117 -0
- data/vendor/v8/include/cppgc/heap-consistency.h +236 -0
- data/vendor/v8/include/cppgc/heap-state.h +70 -0
- data/vendor/v8/include/cppgc/heap-statistics.h +120 -0
- data/vendor/v8/include/cppgc/heap.h +201 -0
- data/vendor/v8/include/cppgc/internal/api-constants.h +47 -0
- data/vendor/v8/include/cppgc/internal/atomic-entry-flag.h +48 -0
- data/vendor/v8/include/cppgc/internal/caged-heap-local-data.h +68 -0
- data/vendor/v8/include/cppgc/internal/compiler-specific.h +38 -0
- data/vendor/v8/include/cppgc/internal/finalizer-trait.h +90 -0
- data/vendor/v8/include/cppgc/internal/gc-info.h +76 -0
- data/vendor/v8/include/cppgc/internal/logging.h +50 -0
- data/vendor/v8/include/cppgc/internal/name-trait.h +111 -0
- data/vendor/v8/include/cppgc/internal/persistent-node.h +172 -0
- data/vendor/v8/include/cppgc/internal/pointer-policies.h +175 -0
- data/vendor/v8/include/cppgc/internal/prefinalizer-handler.h +30 -0
- data/vendor/v8/include/cppgc/internal/write-barrier.h +396 -0
- data/vendor/v8/include/cppgc/liveness-broker.h +74 -0
- data/vendor/v8/include/cppgc/macros.h +26 -0
- data/vendor/v8/include/cppgc/member.h +286 -0
- data/vendor/v8/include/cppgc/name-provider.h +65 -0
- data/vendor/v8/include/cppgc/object-size-trait.h +58 -0
- data/vendor/v8/include/cppgc/persistent.h +365 -0
- data/vendor/v8/include/cppgc/platform.h +153 -0
- data/vendor/v8/include/cppgc/prefinalizer.h +52 -0
- data/vendor/v8/include/cppgc/process-heap-statistics.h +36 -0
- data/vendor/v8/include/cppgc/sentinel-pointer.h +32 -0
- data/vendor/v8/include/cppgc/source-location.h +92 -0
- data/vendor/v8/include/cppgc/testing.h +99 -0
- data/vendor/v8/include/cppgc/trace-trait.h +116 -0
- data/vendor/v8/include/cppgc/type-traits.h +247 -0
- data/vendor/v8/include/cppgc/visitor.h +377 -0
- data/vendor/v8/include/libplatform/libplatform-export.h +29 -0
- data/vendor/v8/include/libplatform/libplatform.h +117 -0
- data/vendor/v8/include/libplatform/v8-tracing.h +334 -0
- data/vendor/v8/include/v8-cppgc.h +325 -0
- data/vendor/v8/include/v8-fast-api-calls.h +791 -0
- data/vendor/v8/include/v8-inspector-protocol.h +13 -0
- data/vendor/v8/include/v8-inspector.h +348 -0
- data/vendor/v8/include/v8-internal.h +499 -0
- data/vendor/v8/include/v8-metrics.h +202 -0
- data/vendor/v8/include/v8-platform.h +709 -0
- data/vendor/v8/include/v8-profiler.h +1123 -0
- data/vendor/v8/include/v8-unwinder-state.h +30 -0
- data/vendor/v8/include/v8-util.h +652 -0
- data/vendor/v8/include/v8-value-serializer-version.h +24 -0
- data/vendor/v8/include/v8-version-string.h +38 -0
- data/vendor/v8/include/v8-version.h +20 -0
- data/vendor/v8/include/v8-wasm-trap-handler-posix.h +31 -0
- data/vendor/v8/include/v8-wasm-trap-handler-win.h +28 -0
- data/vendor/v8/include/v8.h +12648 -0
- data/vendor/v8/include/v8config.h +515 -0
- data/vendor/v8/x86_64-darwin/libv8/obj/libv8_monolith.a +0 -0
- metadata +138 -0
@@ -0,0 +1,286 @@
|
|
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_MEMBER_H_
|
6
|
+
#define INCLUDE_CPPGC_MEMBER_H_
|
7
|
+
|
8
|
+
#include <atomic>
|
9
|
+
#include <cstddef>
|
10
|
+
#include <type_traits>
|
11
|
+
|
12
|
+
#include "cppgc/internal/pointer-policies.h"
|
13
|
+
#include "cppgc/sentinel-pointer.h"
|
14
|
+
#include "cppgc/type-traits.h"
|
15
|
+
#include "v8config.h" // NOLINT(build/include_directory)
|
16
|
+
|
17
|
+
namespace cppgc {
|
18
|
+
|
19
|
+
class Visitor;
|
20
|
+
|
21
|
+
namespace internal {
|
22
|
+
|
23
|
+
// MemberBase always refers to the object as const object and defers to
|
24
|
+
// BasicMember on casting to the right type as needed.
|
25
|
+
class MemberBase {
|
26
|
+
protected:
|
27
|
+
struct AtomicInitializerTag {};
|
28
|
+
|
29
|
+
MemberBase() = default;
|
30
|
+
explicit MemberBase(const void* value) : raw_(value) {}
|
31
|
+
MemberBase(const void* value, AtomicInitializerTag) { SetRawAtomic(value); }
|
32
|
+
|
33
|
+
const void** GetRawSlot() const { return &raw_; }
|
34
|
+
const void* GetRaw() const { return raw_; }
|
35
|
+
void SetRaw(void* value) { raw_ = value; }
|
36
|
+
|
37
|
+
const void* GetRawAtomic() const {
|
38
|
+
return reinterpret_cast<const std::atomic<const void*>*>(&raw_)->load(
|
39
|
+
std::memory_order_relaxed);
|
40
|
+
}
|
41
|
+
void SetRawAtomic(const void* value) {
|
42
|
+
reinterpret_cast<std::atomic<const void*>*>(&raw_)->store(
|
43
|
+
value, std::memory_order_relaxed);
|
44
|
+
}
|
45
|
+
|
46
|
+
void ClearFromGC() const { raw_ = nullptr; }
|
47
|
+
|
48
|
+
private:
|
49
|
+
mutable const void* raw_ = nullptr;
|
50
|
+
};
|
51
|
+
|
52
|
+
// The basic class from which all Member classes are 'generated'.
|
53
|
+
template <typename T, typename WeaknessTag, typename WriteBarrierPolicy,
|
54
|
+
typename CheckingPolicy>
|
55
|
+
class BasicMember final : private MemberBase, private CheckingPolicy {
|
56
|
+
public:
|
57
|
+
using PointeeType = T;
|
58
|
+
|
59
|
+
constexpr BasicMember() = default;
|
60
|
+
constexpr BasicMember(std::nullptr_t) {} // NOLINT
|
61
|
+
BasicMember(SentinelPointer s) : MemberBase(s) {} // NOLINT
|
62
|
+
BasicMember(T* raw) : MemberBase(raw) { // NOLINT
|
63
|
+
InitializingWriteBarrier();
|
64
|
+
this->CheckPointer(Get());
|
65
|
+
}
|
66
|
+
BasicMember(T& raw) : BasicMember(&raw) {} // NOLINT
|
67
|
+
// Atomic ctor. Using the AtomicInitializerTag forces BasicMember to
|
68
|
+
// initialize using atomic assignments. This is required for preventing
|
69
|
+
// data races with concurrent marking.
|
70
|
+
using AtomicInitializerTag = MemberBase::AtomicInitializerTag;
|
71
|
+
BasicMember(std::nullptr_t, AtomicInitializerTag atomic)
|
72
|
+
: MemberBase(nullptr, atomic) {}
|
73
|
+
BasicMember(SentinelPointer s, AtomicInitializerTag atomic)
|
74
|
+
: MemberBase(s, atomic) {}
|
75
|
+
BasicMember(T* raw, AtomicInitializerTag atomic) : MemberBase(raw, atomic) {
|
76
|
+
InitializingWriteBarrier();
|
77
|
+
this->CheckPointer(Get());
|
78
|
+
}
|
79
|
+
BasicMember(T& raw, AtomicInitializerTag atomic)
|
80
|
+
: BasicMember(&raw, atomic) {}
|
81
|
+
// Copy ctor.
|
82
|
+
BasicMember(const BasicMember& other) : BasicMember(other.Get()) {}
|
83
|
+
// Allow heterogeneous construction.
|
84
|
+
template <typename U, typename OtherBarrierPolicy, typename OtherWeaknessTag,
|
85
|
+
typename OtherCheckingPolicy,
|
86
|
+
typename = std::enable_if_t<std::is_base_of<T, U>::value>>
|
87
|
+
BasicMember( // NOLINT
|
88
|
+
const BasicMember<U, OtherWeaknessTag, OtherBarrierPolicy,
|
89
|
+
OtherCheckingPolicy>& other)
|
90
|
+
: BasicMember(other.Get()) {}
|
91
|
+
// Move ctor.
|
92
|
+
BasicMember(BasicMember&& other) noexcept : BasicMember(other.Get()) {
|
93
|
+
other.Clear();
|
94
|
+
}
|
95
|
+
// Allow heterogeneous move construction.
|
96
|
+
template <typename U, typename OtherBarrierPolicy, typename OtherWeaknessTag,
|
97
|
+
typename OtherCheckingPolicy,
|
98
|
+
typename = std::enable_if_t<std::is_base_of<T, U>::value>>
|
99
|
+
BasicMember(BasicMember<U, OtherWeaknessTag, OtherBarrierPolicy,
|
100
|
+
OtherCheckingPolicy>&& other) noexcept
|
101
|
+
: BasicMember(other.Get()) {
|
102
|
+
other.Clear();
|
103
|
+
}
|
104
|
+
// Construction from Persistent.
|
105
|
+
template <typename U, typename PersistentWeaknessPolicy,
|
106
|
+
typename PersistentLocationPolicy,
|
107
|
+
typename PersistentCheckingPolicy,
|
108
|
+
typename = std::enable_if_t<std::is_base_of<T, U>::value>>
|
109
|
+
BasicMember(const BasicPersistent<U, PersistentWeaknessPolicy,
|
110
|
+
PersistentLocationPolicy,
|
111
|
+
PersistentCheckingPolicy>& p)
|
112
|
+
: BasicMember(p.Get()) {}
|
113
|
+
|
114
|
+
// Copy assignment.
|
115
|
+
BasicMember& operator=(const BasicMember& other) {
|
116
|
+
return operator=(other.Get());
|
117
|
+
}
|
118
|
+
// Allow heterogeneous copy assignment.
|
119
|
+
template <typename U, typename OtherWeaknessTag, typename OtherBarrierPolicy,
|
120
|
+
typename OtherCheckingPolicy,
|
121
|
+
typename = std::enable_if_t<std::is_base_of<T, U>::value>>
|
122
|
+
BasicMember& operator=(
|
123
|
+
const BasicMember<U, OtherWeaknessTag, OtherBarrierPolicy,
|
124
|
+
OtherCheckingPolicy>& other) {
|
125
|
+
return operator=(other.Get());
|
126
|
+
}
|
127
|
+
// Move assignment.
|
128
|
+
BasicMember& operator=(BasicMember&& other) noexcept {
|
129
|
+
operator=(other.Get());
|
130
|
+
other.Clear();
|
131
|
+
return *this;
|
132
|
+
}
|
133
|
+
// Heterogeneous move assignment.
|
134
|
+
template <typename U, typename OtherWeaknessTag, typename OtherBarrierPolicy,
|
135
|
+
typename OtherCheckingPolicy,
|
136
|
+
typename = std::enable_if_t<std::is_base_of<T, U>::value>>
|
137
|
+
BasicMember& operator=(BasicMember<U, OtherWeaknessTag, OtherBarrierPolicy,
|
138
|
+
OtherCheckingPolicy>&& other) noexcept {
|
139
|
+
operator=(other.Get());
|
140
|
+
other.Clear();
|
141
|
+
return *this;
|
142
|
+
}
|
143
|
+
// Assignment from Persistent.
|
144
|
+
template <typename U, typename PersistentWeaknessPolicy,
|
145
|
+
typename PersistentLocationPolicy,
|
146
|
+
typename PersistentCheckingPolicy,
|
147
|
+
typename = std::enable_if_t<std::is_base_of<T, U>::value>>
|
148
|
+
BasicMember& operator=(
|
149
|
+
const BasicPersistent<U, PersistentWeaknessPolicy,
|
150
|
+
PersistentLocationPolicy, PersistentCheckingPolicy>&
|
151
|
+
other) {
|
152
|
+
return operator=(other.Get());
|
153
|
+
}
|
154
|
+
BasicMember& operator=(T* other) {
|
155
|
+
SetRawAtomic(other);
|
156
|
+
AssigningWriteBarrier();
|
157
|
+
this->CheckPointer(Get());
|
158
|
+
return *this;
|
159
|
+
}
|
160
|
+
BasicMember& operator=(std::nullptr_t) {
|
161
|
+
Clear();
|
162
|
+
return *this;
|
163
|
+
}
|
164
|
+
BasicMember& operator=(SentinelPointer s) {
|
165
|
+
SetRawAtomic(s);
|
166
|
+
return *this;
|
167
|
+
}
|
168
|
+
|
169
|
+
template <typename OtherWeaknessTag, typename OtherBarrierPolicy,
|
170
|
+
typename OtherCheckingPolicy>
|
171
|
+
void Swap(BasicMember<T, OtherWeaknessTag, OtherBarrierPolicy,
|
172
|
+
OtherCheckingPolicy>& other) {
|
173
|
+
T* tmp = Get();
|
174
|
+
*this = other;
|
175
|
+
other = tmp;
|
176
|
+
}
|
177
|
+
|
178
|
+
explicit operator bool() const { return Get(); }
|
179
|
+
operator T*() const { return Get(); }
|
180
|
+
T* operator->() const { return Get(); }
|
181
|
+
T& operator*() const { return *Get(); }
|
182
|
+
|
183
|
+
// CFI cast exemption to allow passing SentinelPointer through T* and support
|
184
|
+
// heterogeneous assignments between different Member and Persistent handles
|
185
|
+
// based on their actual types.
|
186
|
+
V8_CLANG_NO_SANITIZE("cfi-unrelated-cast") T* Get() const {
|
187
|
+
// Executed by the mutator, hence non atomic load.
|
188
|
+
//
|
189
|
+
// The const_cast below removes the constness from MemberBase storage. The
|
190
|
+
// following static_cast re-adds any constness if specified through the
|
191
|
+
// user-visible template parameter T.
|
192
|
+
return static_cast<T*>(const_cast<void*>(MemberBase::GetRaw()));
|
193
|
+
}
|
194
|
+
|
195
|
+
void Clear() { SetRawAtomic(nullptr); }
|
196
|
+
|
197
|
+
T* Release() {
|
198
|
+
T* result = Get();
|
199
|
+
Clear();
|
200
|
+
return result;
|
201
|
+
}
|
202
|
+
|
203
|
+
const T** GetSlotForTesting() const {
|
204
|
+
return reinterpret_cast<const T**>(GetRawSlot());
|
205
|
+
}
|
206
|
+
|
207
|
+
private:
|
208
|
+
const T* GetRawAtomic() const {
|
209
|
+
return static_cast<const T*>(MemberBase::GetRawAtomic());
|
210
|
+
}
|
211
|
+
|
212
|
+
void InitializingWriteBarrier() const {
|
213
|
+
WriteBarrierPolicy::InitializingBarrier(GetRawSlot(), GetRaw());
|
214
|
+
}
|
215
|
+
void AssigningWriteBarrier() const {
|
216
|
+
WriteBarrierPolicy::AssigningBarrier(GetRawSlot(), GetRaw());
|
217
|
+
}
|
218
|
+
|
219
|
+
void ClearFromGC() const { MemberBase::ClearFromGC(); }
|
220
|
+
|
221
|
+
friend class cppgc::Visitor;
|
222
|
+
template <typename U>
|
223
|
+
friend struct cppgc::TraceTrait;
|
224
|
+
};
|
225
|
+
|
226
|
+
template <typename T1, typename WeaknessTag1, typename WriteBarrierPolicy1,
|
227
|
+
typename CheckingPolicy1, typename T2, typename WeaknessTag2,
|
228
|
+
typename WriteBarrierPolicy2, typename CheckingPolicy2>
|
229
|
+
bool operator==(const BasicMember<T1, WeaknessTag1, WriteBarrierPolicy1,
|
230
|
+
CheckingPolicy1>& member1,
|
231
|
+
const BasicMember<T2, WeaknessTag2, WriteBarrierPolicy2,
|
232
|
+
CheckingPolicy2>& member2) {
|
233
|
+
return member1.Get() == member2.Get();
|
234
|
+
}
|
235
|
+
|
236
|
+
template <typename T1, typename WeaknessTag1, typename WriteBarrierPolicy1,
|
237
|
+
typename CheckingPolicy1, typename T2, typename WeaknessTag2,
|
238
|
+
typename WriteBarrierPolicy2, typename CheckingPolicy2>
|
239
|
+
bool operator!=(const BasicMember<T1, WeaknessTag1, WriteBarrierPolicy1,
|
240
|
+
CheckingPolicy1>& member1,
|
241
|
+
const BasicMember<T2, WeaknessTag2, WriteBarrierPolicy2,
|
242
|
+
CheckingPolicy2>& member2) {
|
243
|
+
return !(member1 == member2);
|
244
|
+
}
|
245
|
+
|
246
|
+
template <typename T, typename WriteBarrierPolicy, typename CheckingPolicy>
|
247
|
+
struct IsWeak<
|
248
|
+
internal::BasicMember<T, WeakMemberTag, WriteBarrierPolicy, CheckingPolicy>>
|
249
|
+
: std::true_type {};
|
250
|
+
|
251
|
+
} // namespace internal
|
252
|
+
|
253
|
+
/**
|
254
|
+
* Members are used in classes to contain strong pointers to other garbage
|
255
|
+
* collected objects. All Member fields of a class must be traced in the class'
|
256
|
+
* trace method.
|
257
|
+
*/
|
258
|
+
template <typename T>
|
259
|
+
using Member = internal::BasicMember<T, internal::StrongMemberTag,
|
260
|
+
internal::DijkstraWriteBarrierPolicy>;
|
261
|
+
|
262
|
+
/**
|
263
|
+
* WeakMember is similar to Member in that it is used to point to other garbage
|
264
|
+
* collected objects. However instead of creating a strong pointer to the
|
265
|
+
* object, the WeakMember creates a weak pointer, which does not keep the
|
266
|
+
* pointee alive. Hence if all pointers to to a heap allocated object are weak
|
267
|
+
* the object will be garbage collected. At the time of GC the weak pointers
|
268
|
+
* will automatically be set to null.
|
269
|
+
*/
|
270
|
+
template <typename T>
|
271
|
+
using WeakMember = internal::BasicMember<T, internal::WeakMemberTag,
|
272
|
+
internal::DijkstraWriteBarrierPolicy>;
|
273
|
+
|
274
|
+
/**
|
275
|
+
* UntracedMember is a pointer to an on-heap object that is not traced for some
|
276
|
+
* reason. Do not use this unless you know what you are doing. Keeping raw
|
277
|
+
* pointers to on-heap objects is prohibited unless used from stack. Pointee
|
278
|
+
* must be kept alive through other means.
|
279
|
+
*/
|
280
|
+
template <typename T>
|
281
|
+
using UntracedMember = internal::BasicMember<T, internal::UntracedMemberTag,
|
282
|
+
internal::NoWriteBarrierPolicy>;
|
283
|
+
|
284
|
+
} // namespace cppgc
|
285
|
+
|
286
|
+
#endif // INCLUDE_CPPGC_MEMBER_H_
|
@@ -0,0 +1,65 @@
|
|
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_NAME_PROVIDER_H_
|
6
|
+
#define INCLUDE_CPPGC_NAME_PROVIDER_H_
|
7
|
+
|
8
|
+
#include "v8config.h" // NOLINT(build/include_directory)
|
9
|
+
|
10
|
+
namespace cppgc {
|
11
|
+
|
12
|
+
/**
|
13
|
+
* NameProvider allows for providing a human-readable name for garbage-collected
|
14
|
+
* objects.
|
15
|
+
*
|
16
|
+
* There's two cases of names to distinguish:
|
17
|
+
* a. Explicitly specified names via using NameProvider. Such names are always
|
18
|
+
* preserved in the system.
|
19
|
+
* b. Internal names that Oilpan infers from a C++ type on the class hierarchy
|
20
|
+
* of the object. This is not necessarily the type of the actually
|
21
|
+
* instantiated object.
|
22
|
+
*
|
23
|
+
* Depending on the build configuration, Oilpan may hide names, i.e., represent
|
24
|
+
* them with kHiddenName, of case b. to avoid exposing internal details.
|
25
|
+
*/
|
26
|
+
class V8_EXPORT NameProvider {
|
27
|
+
public:
|
28
|
+
/**
|
29
|
+
* Name that is used when hiding internals.
|
30
|
+
*/
|
31
|
+
static constexpr const char kHiddenName[] = "InternalNode";
|
32
|
+
|
33
|
+
/**
|
34
|
+
* Name that is used in case compiler support is missing for composing a name
|
35
|
+
* from C++ types.
|
36
|
+
*/
|
37
|
+
static constexpr const char kNoNameDeducible[] = "<No name>";
|
38
|
+
|
39
|
+
/**
|
40
|
+
* Indicating whether internal names are hidden or not.
|
41
|
+
*
|
42
|
+
* @returns true if C++ names should be hidden and represented by kHiddenName.
|
43
|
+
*/
|
44
|
+
static constexpr bool HideInternalNames() {
|
45
|
+
#if CPPGC_SUPPORTS_OBJECT_NAMES
|
46
|
+
return false;
|
47
|
+
#else // !CPPGC_SUPPORTS_OBJECT_NAMES
|
48
|
+
return true;
|
49
|
+
#endif // !CPPGC_SUPPORTS_OBJECT_NAMES
|
50
|
+
}
|
51
|
+
|
52
|
+
virtual ~NameProvider() = default;
|
53
|
+
|
54
|
+
/**
|
55
|
+
* Specifies a name for the garbage-collected object. Such names will never
|
56
|
+
* be hidden, as they are explicitly specified by the user of this API.
|
57
|
+
*
|
58
|
+
* @returns a human readable name for the object.
|
59
|
+
*/
|
60
|
+
virtual const char* GetHumanReadableName() const = 0;
|
61
|
+
};
|
62
|
+
|
63
|
+
} // namespace cppgc
|
64
|
+
|
65
|
+
#endif // INCLUDE_CPPGC_NAME_PROVIDER_H_
|
@@ -0,0 +1,58 @@
|
|
1
|
+
// Copyright 2021 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_OBJECT_SIZE_TRAIT_H_
|
6
|
+
#define INCLUDE_CPPGC_OBJECT_SIZE_TRAIT_H_
|
7
|
+
|
8
|
+
#include <cstddef>
|
9
|
+
|
10
|
+
#include "cppgc/type-traits.h"
|
11
|
+
#include "v8config.h" // NOLINT(build/include_directory)
|
12
|
+
|
13
|
+
namespace cppgc {
|
14
|
+
|
15
|
+
namespace internal {
|
16
|
+
|
17
|
+
struct V8_EXPORT BaseObjectSizeTrait {
|
18
|
+
protected:
|
19
|
+
static size_t GetObjectSizeForGarbageCollected(const void*);
|
20
|
+
static size_t GetObjectSizeForGarbageCollectedMixin(const void*);
|
21
|
+
};
|
22
|
+
|
23
|
+
} // namespace internal
|
24
|
+
|
25
|
+
namespace subtle {
|
26
|
+
|
27
|
+
/**
|
28
|
+
* Trait specifying how to get the size of an object that was allocated using
|
29
|
+
* `MakeGarbageCollected()`. Also supports querying the size with an inner
|
30
|
+
* pointer to a mixin.
|
31
|
+
*/
|
32
|
+
template <typename T, bool = IsGarbageCollectedMixinTypeV<T>>
|
33
|
+
struct ObjectSizeTrait;
|
34
|
+
|
35
|
+
template <typename T>
|
36
|
+
struct ObjectSizeTrait<T, false> : cppgc::internal::BaseObjectSizeTrait {
|
37
|
+
static_assert(sizeof(T), "T must be fully defined");
|
38
|
+
static_assert(IsGarbageCollectedTypeV<T>,
|
39
|
+
"T must be of type GarbageCollected or GarbageCollectedMixin");
|
40
|
+
|
41
|
+
static size_t GetSize(const T& object) {
|
42
|
+
return GetObjectSizeForGarbageCollected(&object);
|
43
|
+
}
|
44
|
+
};
|
45
|
+
|
46
|
+
template <typename T>
|
47
|
+
struct ObjectSizeTrait<T, true> : cppgc::internal::BaseObjectSizeTrait {
|
48
|
+
static_assert(sizeof(T), "T must be fully defined");
|
49
|
+
|
50
|
+
static size_t GetSize(const T& object) {
|
51
|
+
return GetObjectSizeForGarbageCollectedMixin(&object);
|
52
|
+
}
|
53
|
+
};
|
54
|
+
|
55
|
+
} // namespace subtle
|
56
|
+
} // namespace cppgc
|
57
|
+
|
58
|
+
#endif // INCLUDE_CPPGC_OBJECT_SIZE_TRAIT_H_
|