aha-libv8-node 16.0.0.0-linux

Sign up to get free protection for your applications and to get access to all the features.
Files changed (67) hide show
  1. checksums.yaml +7 -0
  2. data/ext/libv8-node/.location.yml +1 -0
  3. data/ext/libv8-node/location.rb +76 -0
  4. data/ext/libv8-node/paths.rb +30 -0
  5. data/lib/libv8-node.rb +1 -0
  6. data/lib/libv8/node.rb +11 -0
  7. data/lib/libv8/node/version.rb +7 -0
  8. data/vendor/v8/include/cppgc/allocation.h +229 -0
  9. data/vendor/v8/include/cppgc/common.h +29 -0
  10. data/vendor/v8/include/cppgc/cross-thread-persistent.h +345 -0
  11. data/vendor/v8/include/cppgc/custom-space.h +97 -0
  12. data/vendor/v8/include/cppgc/default-platform.h +75 -0
  13. data/vendor/v8/include/cppgc/ephemeron-pair.h +30 -0
  14. data/vendor/v8/include/cppgc/garbage-collected.h +116 -0
  15. data/vendor/v8/include/cppgc/heap-consistency.h +236 -0
  16. data/vendor/v8/include/cppgc/heap-state.h +59 -0
  17. data/vendor/v8/include/cppgc/heap-statistics.h +110 -0
  18. data/vendor/v8/include/cppgc/heap.h +199 -0
  19. data/vendor/v8/include/cppgc/internal/api-constants.h +47 -0
  20. data/vendor/v8/include/cppgc/internal/atomic-entry-flag.h +48 -0
  21. data/vendor/v8/include/cppgc/internal/caged-heap-local-data.h +68 -0
  22. data/vendor/v8/include/cppgc/internal/compiler-specific.h +38 -0
  23. data/vendor/v8/include/cppgc/internal/finalizer-trait.h +90 -0
  24. data/vendor/v8/include/cppgc/internal/gc-info.h +47 -0
  25. data/vendor/v8/include/cppgc/internal/logging.h +50 -0
  26. data/vendor/v8/include/cppgc/internal/name-trait.h +111 -0
  27. data/vendor/v8/include/cppgc/internal/persistent-node.h +132 -0
  28. data/vendor/v8/include/cppgc/internal/pointer-policies.h +143 -0
  29. data/vendor/v8/include/cppgc/internal/prefinalizer-handler.h +30 -0
  30. data/vendor/v8/include/cppgc/internal/write-barrier.h +390 -0
  31. data/vendor/v8/include/cppgc/liveness-broker.h +74 -0
  32. data/vendor/v8/include/cppgc/macros.h +26 -0
  33. data/vendor/v8/include/cppgc/member.h +271 -0
  34. data/vendor/v8/include/cppgc/name-provider.h +65 -0
  35. data/vendor/v8/include/cppgc/object-size-trait.h +58 -0
  36. data/vendor/v8/include/cppgc/persistent.h +365 -0
  37. data/vendor/v8/include/cppgc/platform.h +151 -0
  38. data/vendor/v8/include/cppgc/prefinalizer.h +52 -0
  39. data/vendor/v8/include/cppgc/process-heap-statistics.h +36 -0
  40. data/vendor/v8/include/cppgc/sentinel-pointer.h +32 -0
  41. data/vendor/v8/include/cppgc/source-location.h +91 -0
  42. data/vendor/v8/include/cppgc/testing.h +50 -0
  43. data/vendor/v8/include/cppgc/trace-trait.h +116 -0
  44. data/vendor/v8/include/cppgc/type-traits.h +228 -0
  45. data/vendor/v8/include/cppgc/visitor.h +340 -0
  46. data/vendor/v8/include/libplatform/libplatform-export.h +29 -0
  47. data/vendor/v8/include/libplatform/libplatform.h +117 -0
  48. data/vendor/v8/include/libplatform/v8-tracing.h +334 -0
  49. data/vendor/v8/include/v8-cppgc.h +278 -0
  50. data/vendor/v8/include/v8-fast-api-calls.h +419 -0
  51. data/vendor/v8/include/v8-inspector-protocol.h +13 -0
  52. data/vendor/v8/include/v8-inspector.h +336 -0
  53. data/vendor/v8/include/v8-internal.h +462 -0
  54. data/vendor/v8/include/v8-metrics.h +189 -0
  55. data/vendor/v8/include/v8-platform.h +710 -0
  56. data/vendor/v8/include/v8-profiler.h +1116 -0
  57. data/vendor/v8/include/v8-unwinder-state.h +30 -0
  58. data/vendor/v8/include/v8-util.h +652 -0
  59. data/vendor/v8/include/v8-value-serializer-version.h +24 -0
  60. data/vendor/v8/include/v8-version-string.h +38 -0
  61. data/vendor/v8/include/v8-version.h +20 -0
  62. data/vendor/v8/include/v8-wasm-trap-handler-posix.h +31 -0
  63. data/vendor/v8/include/v8-wasm-trap-handler-win.h +28 -0
  64. data/vendor/v8/include/v8.h +12479 -0
  65. data/vendor/v8/include/v8config.h +521 -0
  66. data/vendor/v8/out.gn/libv8/obj/libv8_monolith.a +0 -0
  67. metadata +137 -0
@@ -0,0 +1,74 @@
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_LIVENESS_BROKER_H_
6
+ #define INCLUDE_CPPGC_LIVENESS_BROKER_H_
7
+
8
+ #include "cppgc/heap.h"
9
+ #include "cppgc/member.h"
10
+ #include "cppgc/trace-trait.h"
11
+ #include "v8config.h" // NOLINT(build/include_directory)
12
+
13
+ namespace cppgc {
14
+
15
+ namespace internal {
16
+ class LivenessBrokerFactory;
17
+ } // namespace internal
18
+
19
+ /**
20
+ * The broker is passed to weak callbacks to allow (temporarily) querying
21
+ * the liveness state of an object. References to non-live objects must be
22
+ * cleared when `IsHeapObjectAlive()` returns false.
23
+ *
24
+ * \code
25
+ * class GCedWithCustomWeakCallback final
26
+ * : public GarbageCollected<GCedWithCustomWeakCallback> {
27
+ * public:
28
+ * UntracedMember<Bar> bar;
29
+ *
30
+ * void CustomWeakCallbackMethod(const LivenessBroker& broker) {
31
+ * if (!broker.IsHeapObjectAlive(bar))
32
+ * bar = nullptr;
33
+ * }
34
+ *
35
+ * void Trace(cppgc::Visitor* visitor) const {
36
+ * visitor->RegisterWeakCallbackMethod<
37
+ * GCedWithCustomWeakCallback,
38
+ * &GCedWithCustomWeakCallback::CustomWeakCallbackMethod>(this);
39
+ * }
40
+ * };
41
+ * \endcode
42
+ */
43
+ class V8_EXPORT LivenessBroker final {
44
+ public:
45
+ template <typename T>
46
+ bool IsHeapObjectAlive(const T* object) const {
47
+ return object &&
48
+ IsHeapObjectAliveImpl(
49
+ TraceTrait<T>::GetTraceDescriptor(object).base_object_payload);
50
+ }
51
+
52
+ template <typename T>
53
+ bool IsHeapObjectAlive(const WeakMember<T>& weak_member) const {
54
+ return (weak_member != kSentinelPointer) &&
55
+ IsHeapObjectAlive<T>(weak_member.Get());
56
+ }
57
+
58
+ template <typename T>
59
+ bool IsHeapObjectAlive(const UntracedMember<T>& untraced_member) const {
60
+ return (untraced_member != kSentinelPointer) &&
61
+ IsHeapObjectAlive<T>(untraced_member.Get());
62
+ }
63
+
64
+ private:
65
+ LivenessBroker() = default;
66
+
67
+ bool IsHeapObjectAliveImpl(const void*) const;
68
+
69
+ friend class internal::LivenessBrokerFactory;
70
+ };
71
+
72
+ } // namespace cppgc
73
+
74
+ #endif // INCLUDE_CPPGC_LIVENESS_BROKER_H_
@@ -0,0 +1,26 @@
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_MACROS_H_
6
+ #define INCLUDE_CPPGC_MACROS_H_
7
+
8
+ #include <stddef.h>
9
+
10
+ #include "cppgc/internal/compiler-specific.h"
11
+
12
+ namespace cppgc {
13
+
14
+ // Use if the object is only stack allocated.
15
+ #define CPPGC_STACK_ALLOCATED() \
16
+ public: \
17
+ using IsStackAllocatedTypeMarker CPPGC_UNUSED = int; \
18
+ \
19
+ private: \
20
+ void* operator new(size_t) = delete; \
21
+ void* operator new(size_t, void*) = delete; \
22
+ static_assert(true, "Force semicolon.")
23
+
24
+ } // namespace cppgc
25
+
26
+ #endif // INCLUDE_CPPGC_MACROS_H_
@@ -0,0 +1,271 @@
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
+ MemberBase() = default;
28
+ explicit MemberBase(const void* value) : raw_(value) {}
29
+
30
+ const void** GetRawSlot() const { return &raw_; }
31
+ const void* GetRaw() const { return raw_; }
32
+ void SetRaw(void* value) { raw_ = value; }
33
+
34
+ const void* GetRawAtomic() const {
35
+ return reinterpret_cast<const std::atomic<const void*>*>(&raw_)->load(
36
+ std::memory_order_relaxed);
37
+ }
38
+ void SetRawAtomic(const void* value) {
39
+ reinterpret_cast<std::atomic<const void*>*>(&raw_)->store(
40
+ value, std::memory_order_relaxed);
41
+ }
42
+
43
+ void ClearFromGC() const { raw_ = nullptr; }
44
+
45
+ private:
46
+ mutable const void* raw_ = nullptr;
47
+ };
48
+
49
+ // The basic class from which all Member classes are 'generated'.
50
+ template <typename T, typename WeaknessTag, typename WriteBarrierPolicy,
51
+ typename CheckingPolicy>
52
+ class BasicMember final : private MemberBase, private CheckingPolicy {
53
+ public:
54
+ using PointeeType = T;
55
+
56
+ constexpr BasicMember() = default;
57
+ constexpr BasicMember(std::nullptr_t) {} // NOLINT
58
+ BasicMember(SentinelPointer s) : MemberBase(s) {} // NOLINT
59
+ BasicMember(T* raw) : MemberBase(raw) { // NOLINT
60
+ InitializingWriteBarrier();
61
+ this->CheckPointer(Get());
62
+ }
63
+ BasicMember(T& raw) : BasicMember(&raw) {} // NOLINT
64
+ // Copy ctor.
65
+ BasicMember(const BasicMember& other) : BasicMember(other.Get()) {}
66
+ // Allow heterogeneous construction.
67
+ template <typename U, typename OtherBarrierPolicy, typename OtherWeaknessTag,
68
+ typename OtherCheckingPolicy,
69
+ typename = std::enable_if_t<std::is_base_of<T, U>::value>>
70
+ BasicMember( // NOLINT
71
+ const BasicMember<U, OtherWeaknessTag, OtherBarrierPolicy,
72
+ OtherCheckingPolicy>& other)
73
+ : BasicMember(other.Get()) {}
74
+ // Move ctor.
75
+ BasicMember(BasicMember&& other) noexcept : BasicMember(other.Get()) {
76
+ other.Clear();
77
+ }
78
+ // Allow heterogeneous move construction.
79
+ template <typename U, typename OtherBarrierPolicy, typename OtherWeaknessTag,
80
+ typename OtherCheckingPolicy,
81
+ typename = std::enable_if_t<std::is_base_of<T, U>::value>>
82
+ BasicMember( // NOLINT
83
+ BasicMember<U, OtherWeaknessTag, OtherBarrierPolicy,
84
+ OtherCheckingPolicy>&& other) noexcept
85
+ : BasicMember(other.Get()) {
86
+ other.Clear();
87
+ }
88
+ // Construction from Persistent.
89
+ template <typename U, typename PersistentWeaknessPolicy,
90
+ typename PersistentLocationPolicy,
91
+ typename PersistentCheckingPolicy,
92
+ typename = std::enable_if_t<std::is_base_of<T, U>::value>>
93
+ BasicMember( // NOLINT
94
+ const BasicPersistent<U, PersistentWeaknessPolicy,
95
+ PersistentLocationPolicy, PersistentCheckingPolicy>&
96
+ p)
97
+ : BasicMember(p.Get()) {}
98
+
99
+ // Copy assignment.
100
+ BasicMember& operator=(const BasicMember& other) {
101
+ return operator=(other.Get());
102
+ }
103
+ // Allow heterogeneous copy assignment.
104
+ template <typename U, typename OtherWeaknessTag, typename OtherBarrierPolicy,
105
+ typename OtherCheckingPolicy,
106
+ typename = std::enable_if_t<std::is_base_of<T, U>::value>>
107
+ BasicMember& operator=(
108
+ const BasicMember<U, OtherWeaknessTag, OtherBarrierPolicy,
109
+ OtherCheckingPolicy>& other) {
110
+ return operator=(other.Get());
111
+ }
112
+ // Move assignment.
113
+ BasicMember& operator=(BasicMember&& other) noexcept {
114
+ operator=(other.Get());
115
+ other.Clear();
116
+ return *this;
117
+ }
118
+ // Heterogeneous move 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=(BasicMember<U, OtherWeaknessTag, OtherBarrierPolicy,
123
+ OtherCheckingPolicy>&& other) noexcept {
124
+ operator=(other.Get());
125
+ other.Clear();
126
+ return *this;
127
+ }
128
+ // Assignment from Persistent.
129
+ template <typename U, typename PersistentWeaknessPolicy,
130
+ typename PersistentLocationPolicy,
131
+ typename PersistentCheckingPolicy,
132
+ typename = std::enable_if_t<std::is_base_of<T, U>::value>>
133
+ BasicMember& operator=(
134
+ const BasicPersistent<U, PersistentWeaknessPolicy,
135
+ PersistentLocationPolicy, PersistentCheckingPolicy>&
136
+ other) {
137
+ return operator=(other.Get());
138
+ }
139
+ BasicMember& operator=(T* other) {
140
+ SetRawAtomic(other);
141
+ AssigningWriteBarrier();
142
+ this->CheckPointer(Get());
143
+ return *this;
144
+ }
145
+ BasicMember& operator=(std::nullptr_t) {
146
+ Clear();
147
+ return *this;
148
+ }
149
+ BasicMember& operator=(SentinelPointer s) {
150
+ SetRawAtomic(s);
151
+ return *this;
152
+ }
153
+
154
+ template <typename OtherWeaknessTag, typename OtherBarrierPolicy,
155
+ typename OtherCheckingPolicy>
156
+ void Swap(BasicMember<T, OtherWeaknessTag, OtherBarrierPolicy,
157
+ OtherCheckingPolicy>& other) {
158
+ T* tmp = Get();
159
+ *this = other;
160
+ other = tmp;
161
+ }
162
+
163
+ explicit operator bool() const { return Get(); }
164
+ operator T*() const { return Get(); } // NOLINT
165
+ T* operator->() const { return Get(); }
166
+ T& operator*() const { return *Get(); }
167
+
168
+ // CFI cast exemption to allow passing SentinelPointer through T* and support
169
+ // heterogeneous assignments between different Member and Persistent handles
170
+ // based on their actual types.
171
+ V8_CLANG_NO_SANITIZE("cfi-unrelated-cast") T* Get() const {
172
+ // Executed by the mutator, hence non atomic load.
173
+ //
174
+ // The const_cast below removes the constness from MemberBase storage. The
175
+ // following static_cast re-adds any constness if specified through the
176
+ // user-visible template parameter T.
177
+ return static_cast<T*>(const_cast<void*>(MemberBase::GetRaw()));
178
+ }
179
+
180
+ void Clear() { SetRawAtomic(nullptr); }
181
+
182
+ T* Release() {
183
+ T* result = Get();
184
+ Clear();
185
+ return result;
186
+ }
187
+
188
+ const T** GetSlotForTesting() const {
189
+ return reinterpret_cast<const T**>(GetRawSlot());
190
+ }
191
+
192
+ private:
193
+ const T* GetRawAtomic() const {
194
+ return static_cast<const T*>(MemberBase::GetRawAtomic());
195
+ }
196
+
197
+ void InitializingWriteBarrier() const {
198
+ WriteBarrierPolicy::InitializingBarrier(GetRawSlot(), GetRaw());
199
+ }
200
+ void AssigningWriteBarrier() const {
201
+ WriteBarrierPolicy::AssigningBarrier(GetRawSlot(), GetRaw());
202
+ }
203
+
204
+ void ClearFromGC() const { MemberBase::ClearFromGC(); }
205
+
206
+ friend class cppgc::Visitor;
207
+ template <typename U>
208
+ friend struct cppgc::TraceTrait;
209
+ };
210
+
211
+ template <typename T1, typename WeaknessTag1, typename WriteBarrierPolicy1,
212
+ typename CheckingPolicy1, typename T2, typename WeaknessTag2,
213
+ typename WriteBarrierPolicy2, typename CheckingPolicy2>
214
+ bool operator==(
215
+ BasicMember<T1, WeaknessTag1, WriteBarrierPolicy1, CheckingPolicy1> member1,
216
+ BasicMember<T2, WeaknessTag2, WriteBarrierPolicy2, CheckingPolicy2>
217
+ member2) {
218
+ return member1.Get() == member2.Get();
219
+ }
220
+
221
+ template <typename T1, typename WeaknessTag1, typename WriteBarrierPolicy1,
222
+ typename CheckingPolicy1, typename T2, typename WeaknessTag2,
223
+ typename WriteBarrierPolicy2, typename CheckingPolicy2>
224
+ bool operator!=(
225
+ BasicMember<T1, WeaknessTag1, WriteBarrierPolicy1, CheckingPolicy1> member1,
226
+ BasicMember<T2, WeaknessTag2, WriteBarrierPolicy2, CheckingPolicy2>
227
+ member2) {
228
+ return !(member1 == member2);
229
+ }
230
+
231
+ template <typename T, typename WriteBarrierPolicy, typename CheckingPolicy>
232
+ struct IsWeak<
233
+ internal::BasicMember<T, WeakMemberTag, WriteBarrierPolicy, CheckingPolicy>>
234
+ : std::true_type {};
235
+
236
+ } // namespace internal
237
+
238
+ /**
239
+ * Members are used in classes to contain strong pointers to other garbage
240
+ * collected objects. All Member fields of a class must be traced in the class'
241
+ * trace method.
242
+ */
243
+ template <typename T>
244
+ using Member = internal::BasicMember<T, internal::StrongMemberTag,
245
+ internal::DijkstraWriteBarrierPolicy>;
246
+
247
+ /**
248
+ * WeakMember is similar to Member in that it is used to point to other garbage
249
+ * collected objects. However instead of creating a strong pointer to the
250
+ * object, the WeakMember creates a weak pointer, which does not keep the
251
+ * pointee alive. Hence if all pointers to to a heap allocated object are weak
252
+ * the object will be garbage collected. At the time of GC the weak pointers
253
+ * will automatically be set to null.
254
+ */
255
+ template <typename T>
256
+ using WeakMember = internal::BasicMember<T, internal::WeakMemberTag,
257
+ internal::DijkstraWriteBarrierPolicy>;
258
+
259
+ /**
260
+ * UntracedMember is a pointer to an on-heap object that is not traced for some
261
+ * reason. Do not use this unless you know what you are doing. Keeping raw
262
+ * pointers to on-heap objects is prohibited unless used from stack. Pointee
263
+ * must be kept alive through other means.
264
+ */
265
+ template <typename T>
266
+ using UntracedMember = internal::BasicMember<T, internal::UntracedMemberTag,
267
+ internal::NoWriteBarrierPolicy>;
268
+
269
+ } // namespace cppgc
270
+
271
+ #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* GetName() 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_