@babylonjs/v8-android-jit-nointl-nosnapshot 11.110.1

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.
Files changed (126) hide show
  1. package/dist/include/APIDesign.md +72 -0
  2. package/dist/include/DEPS +10 -0
  3. package/dist/include/DIR_METADATA +11 -0
  4. package/dist/include/OWNERS +23 -0
  5. package/dist/include/cppgc/DEPS +8 -0
  6. package/dist/include/cppgc/OWNERS +2 -0
  7. package/dist/include/cppgc/README.md +135 -0
  8. package/dist/include/cppgc/allocation.h +310 -0
  9. package/dist/include/cppgc/common.h +28 -0
  10. package/dist/include/cppgc/cross-thread-persistent.h +464 -0
  11. package/dist/include/cppgc/custom-space.h +97 -0
  12. package/dist/include/cppgc/default-platform.h +67 -0
  13. package/dist/include/cppgc/ephemeron-pair.h +30 -0
  14. package/dist/include/cppgc/explicit-management.h +100 -0
  15. package/dist/include/cppgc/garbage-collected.h +106 -0
  16. package/dist/include/cppgc/heap-consistency.h +309 -0
  17. package/dist/include/cppgc/heap-handle.h +48 -0
  18. package/dist/include/cppgc/heap-state.h +82 -0
  19. package/dist/include/cppgc/heap-statistics.h +120 -0
  20. package/dist/include/cppgc/heap.h +202 -0
  21. package/dist/include/cppgc/internal/api-constants.h +65 -0
  22. package/dist/include/cppgc/internal/atomic-entry-flag.h +48 -0
  23. package/dist/include/cppgc/internal/base-page-handle.h +45 -0
  24. package/dist/include/cppgc/internal/caged-heap-local-data.h +111 -0
  25. package/dist/include/cppgc/internal/caged-heap.h +61 -0
  26. package/dist/include/cppgc/internal/compiler-specific.h +38 -0
  27. package/dist/include/cppgc/internal/finalizer-trait.h +93 -0
  28. package/dist/include/cppgc/internal/gc-info.h +155 -0
  29. package/dist/include/cppgc/internal/logging.h +50 -0
  30. package/dist/include/cppgc/internal/member-storage.h +236 -0
  31. package/dist/include/cppgc/internal/name-trait.h +137 -0
  32. package/dist/include/cppgc/internal/persistent-node.h +214 -0
  33. package/dist/include/cppgc/internal/pointer-policies.h +207 -0
  34. package/dist/include/cppgc/internal/write-barrier.h +477 -0
  35. package/dist/include/cppgc/liveness-broker.h +78 -0
  36. package/dist/include/cppgc/macros.h +26 -0
  37. package/dist/include/cppgc/member.h +566 -0
  38. package/dist/include/cppgc/name-provider.h +65 -0
  39. package/dist/include/cppgc/object-size-trait.h +58 -0
  40. package/dist/include/cppgc/persistent.h +366 -0
  41. package/dist/include/cppgc/platform.h +158 -0
  42. package/dist/include/cppgc/prefinalizer.h +75 -0
  43. package/dist/include/cppgc/process-heap-statistics.h +36 -0
  44. package/dist/include/cppgc/sentinel-pointer.h +32 -0
  45. package/dist/include/cppgc/source-location.h +92 -0
  46. package/dist/include/cppgc/testing.h +106 -0
  47. package/dist/include/cppgc/trace-trait.h +120 -0
  48. package/dist/include/cppgc/type-traits.h +249 -0
  49. package/dist/include/cppgc/visitor.h +411 -0
  50. package/dist/include/js_protocol-1.2.json +997 -0
  51. package/dist/include/js_protocol-1.3.json +1159 -0
  52. package/dist/include/js_protocol.pdl +1766 -0
  53. package/dist/include/libplatform/DEPS +9 -0
  54. package/dist/include/libplatform/libplatform-export.h +29 -0
  55. package/dist/include/libplatform/libplatform.h +106 -0
  56. package/dist/include/libplatform/v8-tracing.h +333 -0
  57. package/dist/include/v8-array-buffer.h +512 -0
  58. package/dist/include/v8-callbacks.h +412 -0
  59. package/dist/include/v8-container.h +129 -0
  60. package/dist/include/v8-context.h +415 -0
  61. package/dist/include/v8-cppgc.h +231 -0
  62. package/dist/include/v8-data.h +80 -0
  63. package/dist/include/v8-date.h +48 -0
  64. package/dist/include/v8-debug.h +168 -0
  65. package/dist/include/v8-embedder-heap.h +223 -0
  66. package/dist/include/v8-embedder-state-scope.h +51 -0
  67. package/dist/include/v8-exception.h +217 -0
  68. package/dist/include/v8-extension.h +62 -0
  69. package/dist/include/v8-external.h +37 -0
  70. package/dist/include/v8-fast-api-calls.h +957 -0
  71. package/dist/include/v8-forward.h +81 -0
  72. package/dist/include/v8-function-callback.h +475 -0
  73. package/dist/include/v8-function.h +133 -0
  74. package/dist/include/v8-initialization.h +289 -0
  75. package/dist/include/v8-inspector-protocol.h +13 -0
  76. package/dist/include/v8-inspector.h +397 -0
  77. package/dist/include/v8-internal.h +851 -0
  78. package/dist/include/v8-isolate.h +1695 -0
  79. package/dist/include/v8-json.h +47 -0
  80. package/dist/include/v8-local-handle.h +455 -0
  81. package/dist/include/v8-locker.h +138 -0
  82. package/dist/include/v8-maybe.h +160 -0
  83. package/dist/include/v8-memory-span.h +43 -0
  84. package/dist/include/v8-message.h +214 -0
  85. package/dist/include/v8-metrics.h +311 -0
  86. package/dist/include/v8-microtask-queue.h +157 -0
  87. package/dist/include/v8-microtask.h +28 -0
  88. package/dist/include/v8-object.h +768 -0
  89. package/dist/include/v8-persistent-handle.h +588 -0
  90. package/dist/include/v8-platform.h +1130 -0
  91. package/dist/include/v8-primitive-object.h +118 -0
  92. package/dist/include/v8-primitive.h +866 -0
  93. package/dist/include/v8-profiler.h +1277 -0
  94. package/dist/include/v8-promise.h +174 -0
  95. package/dist/include/v8-proxy.h +50 -0
  96. package/dist/include/v8-regexp.h +106 -0
  97. package/dist/include/v8-script.h +803 -0
  98. package/dist/include/v8-snapshot.h +196 -0
  99. package/dist/include/v8-statistics.h +217 -0
  100. package/dist/include/v8-template.h +1018 -0
  101. package/dist/include/v8-traced-handle.h +420 -0
  102. package/dist/include/v8-typed-array.h +282 -0
  103. package/dist/include/v8-unwinder-state.h +31 -0
  104. package/dist/include/v8-unwinder.h +132 -0
  105. package/dist/include/v8-util.h +656 -0
  106. package/dist/include/v8-value-serializer-version.h +24 -0
  107. package/dist/include/v8-value-serializer.h +302 -0
  108. package/dist/include/v8-value.h +531 -0
  109. package/dist/include/v8-version-string.h +38 -0
  110. package/dist/include/v8-version.h +20 -0
  111. package/dist/include/v8-wasm-trap-handler-posix.h +31 -0
  112. package/dist/include/v8-wasm-trap-handler-win.h +28 -0
  113. package/dist/include/v8-wasm.h +200 -0
  114. package/dist/include/v8-weak-callback-info.h +80 -0
  115. package/dist/include/v8.h +88 -0
  116. package/dist/include/v8config.h +904 -0
  117. package/dist/org/chromium/v8-android/11.110.1/v8-android-11.110.1.aar +0 -0
  118. package/dist/org/chromium/v8-android/11.110.1/v8-android-11.110.1.aar.md5 +1 -0
  119. package/dist/org/chromium/v8-android/11.110.1/v8-android-11.110.1.aar.sha1 +1 -0
  120. package/dist/org/chromium/v8-android/11.110.1/v8-android-11.110.1.pom +10 -0
  121. package/dist/org/chromium/v8-android/11.110.1/v8-android-11.110.1.pom.md5 +1 -0
  122. package/dist/org/chromium/v8-android/11.110.1/v8-android-11.110.1.pom.sha1 +1 -0
  123. package/dist/org/chromium/v8-android/maven-metadata.xml +12 -0
  124. package/dist/org/chromium/v8-android/maven-metadata.xml.md5 +1 -0
  125. package/dist/org/chromium/v8-android/maven-metadata.xml.sha1 +1 -0
  126. package/package.json +24 -0
@@ -0,0 +1,566 @@
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/api-constants.h"
13
+ #include "cppgc/internal/member-storage.h"
14
+ #include "cppgc/internal/pointer-policies.h"
15
+ #include "cppgc/sentinel-pointer.h"
16
+ #include "cppgc/type-traits.h"
17
+ #include "v8config.h" // NOLINT(build/include_directory)
18
+
19
+ namespace cppgc {
20
+
21
+ namespace subtle {
22
+ class HeapConsistency;
23
+ } // namespace subtle
24
+
25
+ class Visitor;
26
+
27
+ namespace internal {
28
+
29
+ // MemberBase always refers to the object as const object and defers to
30
+ // BasicMember on casting to the right type as needed.
31
+ class V8_TRIVIAL_ABI MemberBase {
32
+ public:
33
+ #if defined(CPPGC_POINTER_COMPRESSION)
34
+ using RawStorage = CompressedPointer;
35
+ #else // !defined(CPPGC_POINTER_COMPRESSION)
36
+ using RawStorage = RawPointer;
37
+ #endif // !defined(CPPGC_POINTER_COMPRESSION)
38
+ protected:
39
+ struct AtomicInitializerTag {};
40
+
41
+ V8_INLINE MemberBase() = default;
42
+ V8_INLINE explicit MemberBase(const void* value) : raw_(value) {}
43
+ V8_INLINE MemberBase(const void* value, AtomicInitializerTag) {
44
+ SetRawAtomic(value);
45
+ }
46
+
47
+ V8_INLINE explicit MemberBase(RawStorage raw) : raw_(raw) {}
48
+ V8_INLINE explicit MemberBase(std::nullptr_t) : raw_(nullptr) {}
49
+ V8_INLINE explicit MemberBase(SentinelPointer s) : raw_(s) {}
50
+
51
+ V8_INLINE const void** GetRawSlot() const {
52
+ return reinterpret_cast<const void**>(const_cast<MemberBase*>(this));
53
+ }
54
+ V8_INLINE const void* GetRaw() const { return raw_.Load(); }
55
+ V8_INLINE void SetRaw(void* value) { raw_.Store(value); }
56
+
57
+ V8_INLINE const void* GetRawAtomic() const { return raw_.LoadAtomic(); }
58
+ V8_INLINE void SetRawAtomic(const void* value) { raw_.StoreAtomic(value); }
59
+
60
+ V8_INLINE RawStorage GetRawStorage() const { return raw_; }
61
+ V8_INLINE void SetRawStorageAtomic(RawStorage other) {
62
+ reinterpret_cast<std::atomic<RawStorage>&>(raw_).store(
63
+ other, std::memory_order_relaxed);
64
+ }
65
+
66
+ V8_INLINE bool IsCleared() const { return raw_.IsCleared(); }
67
+
68
+ V8_INLINE void ClearFromGC() const { raw_.Clear(); }
69
+
70
+ private:
71
+ friend class MemberDebugHelper;
72
+
73
+ mutable RawStorage raw_;
74
+ };
75
+
76
+ // The basic class from which all Member classes are 'generated'.
77
+ template <typename T, typename WeaknessTag, typename WriteBarrierPolicy,
78
+ typename CheckingPolicy>
79
+ class V8_TRIVIAL_ABI BasicMember final : private MemberBase,
80
+ private CheckingPolicy {
81
+ public:
82
+ using PointeeType = T;
83
+
84
+ V8_INLINE constexpr BasicMember() = default;
85
+ V8_INLINE constexpr BasicMember(std::nullptr_t) {} // NOLINT
86
+ V8_INLINE BasicMember(SentinelPointer s) : MemberBase(s) {} // NOLINT
87
+ V8_INLINE BasicMember(T* raw) : MemberBase(raw) { // NOLINT
88
+ InitializingWriteBarrier(raw);
89
+ this->CheckPointer(Get());
90
+ }
91
+ V8_INLINE BasicMember(T& raw) // NOLINT
92
+ : BasicMember(&raw) {}
93
+
94
+ // Atomic ctor. Using the AtomicInitializerTag forces BasicMember to
95
+ // initialize using atomic assignments. This is required for preventing
96
+ // data races with concurrent marking.
97
+ using AtomicInitializerTag = MemberBase::AtomicInitializerTag;
98
+ V8_INLINE BasicMember(std::nullptr_t, AtomicInitializerTag atomic)
99
+ : MemberBase(nullptr, atomic) {}
100
+ V8_INLINE BasicMember(SentinelPointer s, AtomicInitializerTag atomic)
101
+ : MemberBase(s, atomic) {}
102
+ V8_INLINE BasicMember(T* raw, AtomicInitializerTag atomic)
103
+ : MemberBase(raw, atomic) {
104
+ InitializingWriteBarrier(raw);
105
+ this->CheckPointer(Get());
106
+ }
107
+ V8_INLINE BasicMember(T& raw, AtomicInitializerTag atomic)
108
+ : BasicMember(&raw, atomic) {}
109
+
110
+ // Copy ctor.
111
+ V8_INLINE BasicMember(const BasicMember& other)
112
+ : BasicMember(other.GetRawStorage()) {}
113
+
114
+ // Heterogeneous copy constructors. When the source pointer have a different
115
+ // type, perform a compress-decompress round, because the source pointer may
116
+ // need to be adjusted.
117
+ template <typename U, typename OtherBarrierPolicy, typename OtherWeaknessTag,
118
+ typename OtherCheckingPolicy,
119
+ std::enable_if_t<internal::IsDecayedSameV<T, U>>* = nullptr>
120
+ V8_INLINE BasicMember( // NOLINT
121
+ const BasicMember<U, OtherWeaknessTag, OtherBarrierPolicy,
122
+ OtherCheckingPolicy>& other)
123
+ : BasicMember(other.GetRawStorage()) {}
124
+
125
+ template <typename U, typename OtherBarrierPolicy, typename OtherWeaknessTag,
126
+ typename OtherCheckingPolicy,
127
+ std::enable_if_t<internal::IsStrictlyBaseOfV<T, U>>* = nullptr>
128
+ V8_INLINE BasicMember( // NOLINT
129
+ const BasicMember<U, OtherWeaknessTag, OtherBarrierPolicy,
130
+ OtherCheckingPolicy>& other)
131
+ : BasicMember(other.Get()) {}
132
+
133
+ // Move ctor.
134
+ V8_INLINE BasicMember(BasicMember&& other) noexcept
135
+ : BasicMember(other.GetRawStorage()) {
136
+ other.Clear();
137
+ }
138
+
139
+ // Heterogeneous move constructors. When the source pointer have a different
140
+ // type, perform a compress-decompress round, because the source pointer may
141
+ // need to be adjusted.
142
+ template <typename U, typename OtherBarrierPolicy, typename OtherWeaknessTag,
143
+ typename OtherCheckingPolicy,
144
+ std::enable_if_t<internal::IsDecayedSameV<T, U>>* = nullptr>
145
+ V8_INLINE BasicMember(BasicMember<U, OtherWeaknessTag, OtherBarrierPolicy,
146
+ OtherCheckingPolicy>&& other) noexcept
147
+ : BasicMember(other.GetRawStorage()) {
148
+ other.Clear();
149
+ }
150
+
151
+ template <typename U, typename OtherBarrierPolicy, typename OtherWeaknessTag,
152
+ typename OtherCheckingPolicy,
153
+ std::enable_if_t<internal::IsStrictlyBaseOfV<T, U>>* = nullptr>
154
+ V8_INLINE BasicMember(BasicMember<U, OtherWeaknessTag, OtherBarrierPolicy,
155
+ OtherCheckingPolicy>&& other) noexcept
156
+ : BasicMember(other.Get()) {
157
+ other.Clear();
158
+ }
159
+
160
+ // Construction from Persistent.
161
+ template <typename U, typename PersistentWeaknessPolicy,
162
+ typename PersistentLocationPolicy,
163
+ typename PersistentCheckingPolicy,
164
+ typename = std::enable_if_t<std::is_base_of<T, U>::value>>
165
+ V8_INLINE BasicMember(const BasicPersistent<U, PersistentWeaknessPolicy,
166
+ PersistentLocationPolicy,
167
+ PersistentCheckingPolicy>& p)
168
+ : BasicMember(p.Get()) {}
169
+
170
+ // Copy assignment.
171
+ V8_INLINE BasicMember& operator=(const BasicMember& other) {
172
+ return operator=(other.GetRawStorage());
173
+ }
174
+
175
+ // Heterogeneous copy assignment. When the source pointer have a different
176
+ // type, perform a compress-decompress round, because the source pointer may
177
+ // need to be adjusted.
178
+ template <typename U, typename OtherWeaknessTag, typename OtherBarrierPolicy,
179
+ typename OtherCheckingPolicy>
180
+ V8_INLINE BasicMember& operator=(
181
+ const BasicMember<U, OtherWeaknessTag, OtherBarrierPolicy,
182
+ OtherCheckingPolicy>& other) {
183
+ if constexpr (internal::IsDecayedSameV<T, U>) {
184
+ return operator=(other.GetRawStorage());
185
+ } else {
186
+ static_assert(internal::IsStrictlyBaseOfV<T, U>);
187
+ return operator=(other.Get());
188
+ }
189
+ }
190
+
191
+ // Move assignment.
192
+ V8_INLINE BasicMember& operator=(BasicMember&& other) noexcept {
193
+ operator=(other.GetRawStorage());
194
+ other.Clear();
195
+ return *this;
196
+ }
197
+
198
+ // Heterogeneous move assignment. When the source pointer have a different
199
+ // type, perform a compress-decompress round, because the source pointer may
200
+ // need to be adjusted.
201
+ template <typename U, typename OtherWeaknessTag, typename OtherBarrierPolicy,
202
+ typename OtherCheckingPolicy>
203
+ V8_INLINE BasicMember& operator=(
204
+ BasicMember<U, OtherWeaknessTag, OtherBarrierPolicy,
205
+ OtherCheckingPolicy>&& other) noexcept {
206
+ if constexpr (internal::IsDecayedSameV<T, U>) {
207
+ operator=(other.GetRawStorage());
208
+ } else {
209
+ static_assert(internal::IsStrictlyBaseOfV<T, U>);
210
+ operator=(other.Get());
211
+ }
212
+ other.Clear();
213
+ return *this;
214
+ }
215
+
216
+ // Assignment from Persistent.
217
+ template <typename U, typename PersistentWeaknessPolicy,
218
+ typename PersistentLocationPolicy,
219
+ typename PersistentCheckingPolicy,
220
+ typename = std::enable_if_t<std::is_base_of<T, U>::value>>
221
+ V8_INLINE BasicMember& operator=(
222
+ const BasicPersistent<U, PersistentWeaknessPolicy,
223
+ PersistentLocationPolicy, PersistentCheckingPolicy>&
224
+ other) {
225
+ return operator=(other.Get());
226
+ }
227
+
228
+ V8_INLINE BasicMember& operator=(T* other) {
229
+ SetRawAtomic(other);
230
+ AssigningWriteBarrier(other);
231
+ this->CheckPointer(Get());
232
+ return *this;
233
+ }
234
+
235
+ V8_INLINE BasicMember& operator=(std::nullptr_t) {
236
+ Clear();
237
+ return *this;
238
+ }
239
+ V8_INLINE BasicMember& operator=(SentinelPointer s) {
240
+ SetRawAtomic(s);
241
+ return *this;
242
+ }
243
+
244
+ template <typename OtherWeaknessTag, typename OtherBarrierPolicy,
245
+ typename OtherCheckingPolicy>
246
+ V8_INLINE void Swap(BasicMember<T, OtherWeaknessTag, OtherBarrierPolicy,
247
+ OtherCheckingPolicy>& other) {
248
+ auto tmp = GetRawStorage();
249
+ *this = other;
250
+ other = tmp;
251
+ }
252
+
253
+ V8_INLINE explicit operator bool() const { return !IsCleared(); }
254
+ V8_INLINE operator T*() const { return Get(); }
255
+ V8_INLINE T* operator->() const { return Get(); }
256
+ V8_INLINE T& operator*() const { return *Get(); }
257
+
258
+ // CFI cast exemption to allow passing SentinelPointer through T* and support
259
+ // heterogeneous assignments between different Member and Persistent handles
260
+ // based on their actual types.
261
+ V8_INLINE V8_CLANG_NO_SANITIZE("cfi-unrelated-cast") T* Get() const {
262
+ // Executed by the mutator, hence non atomic load.
263
+ //
264
+ // The const_cast below removes the constness from MemberBase storage. The
265
+ // following static_cast re-adds any constness if specified through the
266
+ // user-visible template parameter T.
267
+ return static_cast<T*>(const_cast<void*>(MemberBase::GetRaw()));
268
+ }
269
+
270
+ V8_INLINE void Clear() { SetRawStorageAtomic(RawStorage{}); }
271
+
272
+ V8_INLINE T* Release() {
273
+ T* result = Get();
274
+ Clear();
275
+ return result;
276
+ }
277
+
278
+ V8_INLINE const T** GetSlotForTesting() const {
279
+ return reinterpret_cast<const T**>(GetRawSlot());
280
+ }
281
+
282
+ V8_INLINE RawStorage GetRawStorage() const {
283
+ return MemberBase::GetRawStorage();
284
+ }
285
+
286
+ private:
287
+ V8_INLINE explicit BasicMember(RawStorage raw) : MemberBase(raw) {
288
+ InitializingWriteBarrier(Get());
289
+ this->CheckPointer(Get());
290
+ }
291
+
292
+ V8_INLINE BasicMember& operator=(RawStorage other) {
293
+ SetRawStorageAtomic(other);
294
+ AssigningWriteBarrier();
295
+ this->CheckPointer(Get());
296
+ return *this;
297
+ }
298
+
299
+ V8_INLINE const T* GetRawAtomic() const {
300
+ return static_cast<const T*>(MemberBase::GetRawAtomic());
301
+ }
302
+
303
+ V8_INLINE void InitializingWriteBarrier(T* value) const {
304
+ WriteBarrierPolicy::InitializingBarrier(GetRawSlot(), value);
305
+ }
306
+ V8_INLINE void AssigningWriteBarrier(T* value) const {
307
+ WriteBarrierPolicy::AssigningBarrier(GetRawSlot(), value);
308
+ }
309
+ V8_INLINE void AssigningWriteBarrier() const {
310
+ WriteBarrierPolicy::AssigningBarrier(GetRawSlot(), GetRawStorage());
311
+ }
312
+
313
+ V8_INLINE void ClearFromGC() const { MemberBase::ClearFromGC(); }
314
+
315
+ V8_INLINE T* GetFromGC() const { return Get(); }
316
+
317
+ friend class cppgc::subtle::HeapConsistency;
318
+ friend class cppgc::Visitor;
319
+ template <typename U>
320
+ friend struct cppgc::TraceTrait;
321
+ template <typename T1, typename WeaknessTag1, typename WriteBarrierPolicy1,
322
+ typename CheckingPolicy1>
323
+ friend class BasicMember;
324
+ };
325
+
326
+ // Member equality operators.
327
+ template <typename T1, typename WeaknessTag1, typename WriteBarrierPolicy1,
328
+ typename CheckingPolicy1, typename T2, typename WeaknessTag2,
329
+ typename WriteBarrierPolicy2, typename CheckingPolicy2>
330
+ V8_INLINE bool operator==(
331
+ const BasicMember<T1, WeaknessTag1, WriteBarrierPolicy1, CheckingPolicy1>&
332
+ member1,
333
+ const BasicMember<T2, WeaknessTag2, WriteBarrierPolicy2, CheckingPolicy2>&
334
+ member2) {
335
+ if constexpr (internal::IsDecayedSameV<T1, T2>) {
336
+ // Check compressed pointers if types are the same.
337
+ return member1.GetRawStorage() == member2.GetRawStorage();
338
+ } else {
339
+ static_assert(internal::IsStrictlyBaseOfV<T1, T2> ||
340
+ internal::IsStrictlyBaseOfV<T2, T1>);
341
+ // Otherwise, check decompressed pointers.
342
+ return member1.Get() == member2.Get();
343
+ }
344
+ }
345
+
346
+ template <typename T1, typename WeaknessTag1, typename WriteBarrierPolicy1,
347
+ typename CheckingPolicy1, typename T2, typename WeaknessTag2,
348
+ typename WriteBarrierPolicy2, typename CheckingPolicy2>
349
+ V8_INLINE bool operator!=(
350
+ const BasicMember<T1, WeaknessTag1, WriteBarrierPolicy1, CheckingPolicy1>&
351
+ member1,
352
+ const BasicMember<T2, WeaknessTag2, WriteBarrierPolicy2, CheckingPolicy2>&
353
+ member2) {
354
+ return !(member1 == member2);
355
+ }
356
+
357
+ // Equality with raw pointers.
358
+ template <typename T, typename WeaknessTag, typename WriteBarrierPolicy,
359
+ typename CheckingPolicy, typename U>
360
+ V8_INLINE bool operator==(const BasicMember<T, WeaknessTag, WriteBarrierPolicy,
361
+ CheckingPolicy>& member,
362
+ U* raw) {
363
+ // Never allow comparison with erased pointers.
364
+ static_assert(!internal::IsDecayedSameV<void, U>);
365
+
366
+ if constexpr (internal::IsDecayedSameV<T, U>) {
367
+ // Check compressed pointers if types are the same.
368
+ return member.GetRawStorage() == MemberBase::RawStorage(raw);
369
+ } else if constexpr (internal::IsStrictlyBaseOfV<T, U>) {
370
+ // Cast the raw pointer to T, which may adjust the pointer.
371
+ return member.GetRawStorage() ==
372
+ MemberBase::RawStorage(static_cast<T*>(raw));
373
+ } else {
374
+ // Otherwise, decompressed the member.
375
+ return member.Get() == raw;
376
+ }
377
+ }
378
+
379
+ template <typename T, typename WeaknessTag, typename WriteBarrierPolicy,
380
+ typename CheckingPolicy, typename U>
381
+ V8_INLINE bool operator!=(const BasicMember<T, WeaknessTag, WriteBarrierPolicy,
382
+ CheckingPolicy>& member,
383
+ U* raw) {
384
+ return !(member == raw);
385
+ }
386
+
387
+ template <typename T, typename U, typename WeaknessTag,
388
+ typename WriteBarrierPolicy, typename CheckingPolicy>
389
+ V8_INLINE bool operator==(T* raw,
390
+ const BasicMember<U, WeaknessTag, WriteBarrierPolicy,
391
+ CheckingPolicy>& member) {
392
+ return member == raw;
393
+ }
394
+
395
+ template <typename T, typename U, typename WeaknessTag,
396
+ typename WriteBarrierPolicy, typename CheckingPolicy>
397
+ V8_INLINE bool operator!=(T* raw,
398
+ const BasicMember<U, WeaknessTag, WriteBarrierPolicy,
399
+ CheckingPolicy>& member) {
400
+ return !(raw == member);
401
+ }
402
+
403
+ // Equality with sentinel.
404
+ template <typename T, typename WeaknessTag, typename WriteBarrierPolicy,
405
+ typename CheckingPolicy>
406
+ V8_INLINE bool operator==(const BasicMember<T, WeaknessTag, WriteBarrierPolicy,
407
+ CheckingPolicy>& member,
408
+ SentinelPointer) {
409
+ return member.GetRawStorage().IsSentinel();
410
+ }
411
+
412
+ template <typename T, typename WeaknessTag, typename WriteBarrierPolicy,
413
+ typename CheckingPolicy>
414
+ V8_INLINE bool operator!=(const BasicMember<T, WeaknessTag, WriteBarrierPolicy,
415
+ CheckingPolicy>& member,
416
+ SentinelPointer s) {
417
+ return !(member == s);
418
+ }
419
+
420
+ template <typename T, typename WeaknessTag, typename WriteBarrierPolicy,
421
+ typename CheckingPolicy>
422
+ V8_INLINE bool operator==(SentinelPointer s,
423
+ const BasicMember<T, WeaknessTag, WriteBarrierPolicy,
424
+ CheckingPolicy>& member) {
425
+ return member == s;
426
+ }
427
+
428
+ template <typename T, typename WeaknessTag, typename WriteBarrierPolicy,
429
+ typename CheckingPolicy>
430
+ V8_INLINE bool operator!=(SentinelPointer s,
431
+ const BasicMember<T, WeaknessTag, WriteBarrierPolicy,
432
+ CheckingPolicy>& member) {
433
+ return !(s == member);
434
+ }
435
+
436
+ // Equality with nullptr.
437
+ template <typename T, typename WeaknessTag, typename WriteBarrierPolicy,
438
+ typename CheckingPolicy>
439
+ V8_INLINE bool operator==(const BasicMember<T, WeaknessTag, WriteBarrierPolicy,
440
+ CheckingPolicy>& member,
441
+ std::nullptr_t) {
442
+ return !static_cast<bool>(member);
443
+ }
444
+
445
+ template <typename T, typename WeaknessTag, typename WriteBarrierPolicy,
446
+ typename CheckingPolicy>
447
+ V8_INLINE bool operator!=(const BasicMember<T, WeaknessTag, WriteBarrierPolicy,
448
+ CheckingPolicy>& member,
449
+ std::nullptr_t n) {
450
+ return !(member == n);
451
+ }
452
+
453
+ template <typename T, typename WeaknessTag, typename WriteBarrierPolicy,
454
+ typename CheckingPolicy>
455
+ V8_INLINE bool operator==(std::nullptr_t n,
456
+ const BasicMember<T, WeaknessTag, WriteBarrierPolicy,
457
+ CheckingPolicy>& member) {
458
+ return member == n;
459
+ }
460
+
461
+ template <typename T, typename WeaknessTag, typename WriteBarrierPolicy,
462
+ typename CheckingPolicy>
463
+ V8_INLINE bool operator!=(std::nullptr_t n,
464
+ const BasicMember<T, WeaknessTag, WriteBarrierPolicy,
465
+ CheckingPolicy>& member) {
466
+ return !(n == member);
467
+ }
468
+
469
+ // Relational operators.
470
+ template <typename T1, typename WeaknessTag1, typename WriteBarrierPolicy1,
471
+ typename CheckingPolicy1, typename T2, typename WeaknessTag2,
472
+ typename WriteBarrierPolicy2, typename CheckingPolicy2>
473
+ V8_INLINE bool operator<(
474
+ const BasicMember<T1, WeaknessTag1, WriteBarrierPolicy1, CheckingPolicy1>&
475
+ member1,
476
+ const BasicMember<T2, WeaknessTag2, WriteBarrierPolicy2, CheckingPolicy2>&
477
+ member2) {
478
+ static_assert(
479
+ internal::IsDecayedSameV<T1, T2>,
480
+ "Comparison works only for same pointer type modulo cv-qualifiers");
481
+ return member1.GetRawStorage() < member2.GetRawStorage();
482
+ }
483
+
484
+ template <typename T1, typename WeaknessTag1, typename WriteBarrierPolicy1,
485
+ typename CheckingPolicy1, typename T2, typename WeaknessTag2,
486
+ typename WriteBarrierPolicy2, typename CheckingPolicy2>
487
+ V8_INLINE bool operator<=(
488
+ const BasicMember<T1, WeaknessTag1, WriteBarrierPolicy1, CheckingPolicy1>&
489
+ member1,
490
+ const BasicMember<T2, WeaknessTag2, WriteBarrierPolicy2, CheckingPolicy2>&
491
+ member2) {
492
+ static_assert(
493
+ internal::IsDecayedSameV<T1, T2>,
494
+ "Comparison works only for same pointer type modulo cv-qualifiers");
495
+ return member1.GetRawStorage() <= member2.GetRawStorage();
496
+ }
497
+
498
+ template <typename T1, typename WeaknessTag1, typename WriteBarrierPolicy1,
499
+ typename CheckingPolicy1, typename T2, typename WeaknessTag2,
500
+ typename WriteBarrierPolicy2, typename CheckingPolicy2>
501
+ V8_INLINE bool operator>(
502
+ const BasicMember<T1, WeaknessTag1, WriteBarrierPolicy1, CheckingPolicy1>&
503
+ member1,
504
+ const BasicMember<T2, WeaknessTag2, WriteBarrierPolicy2, CheckingPolicy2>&
505
+ member2) {
506
+ static_assert(
507
+ internal::IsDecayedSameV<T1, T2>,
508
+ "Comparison works only for same pointer type modulo cv-qualifiers");
509
+ return member1.GetRawStorage() > member2.GetRawStorage();
510
+ }
511
+
512
+ template <typename T1, typename WeaknessTag1, typename WriteBarrierPolicy1,
513
+ typename CheckingPolicy1, typename T2, typename WeaknessTag2,
514
+ typename WriteBarrierPolicy2, typename CheckingPolicy2>
515
+ V8_INLINE bool operator>=(
516
+ const BasicMember<T1, WeaknessTag1, WriteBarrierPolicy1, CheckingPolicy1>&
517
+ member1,
518
+ const BasicMember<T2, WeaknessTag2, WriteBarrierPolicy2, CheckingPolicy2>&
519
+ member2) {
520
+ static_assert(
521
+ internal::IsDecayedSameV<T1, T2>,
522
+ "Comparison works only for same pointer type modulo cv-qualifiers");
523
+ return member1.GetRawStorage() >= member2.GetRawStorage();
524
+ }
525
+
526
+ template <typename T, typename WriteBarrierPolicy, typename CheckingPolicy>
527
+ struct IsWeak<
528
+ internal::BasicMember<T, WeakMemberTag, WriteBarrierPolicy, CheckingPolicy>>
529
+ : std::true_type {};
530
+
531
+ } // namespace internal
532
+
533
+ /**
534
+ * Members are used in classes to contain strong pointers to other garbage
535
+ * collected objects. All Member fields of a class must be traced in the class'
536
+ * trace method.
537
+ */
538
+ template <typename T>
539
+ using Member = internal::BasicMember<T, internal::StrongMemberTag,
540
+ internal::DijkstraWriteBarrierPolicy>;
541
+
542
+ /**
543
+ * WeakMember is similar to Member in that it is used to point to other garbage
544
+ * collected objects. However instead of creating a strong pointer to the
545
+ * object, the WeakMember creates a weak pointer, which does not keep the
546
+ * pointee alive. Hence if all pointers to to a heap allocated object are weak
547
+ * the object will be garbage collected. At the time of GC the weak pointers
548
+ * will automatically be set to null.
549
+ */
550
+ template <typename T>
551
+ using WeakMember = internal::BasicMember<T, internal::WeakMemberTag,
552
+ internal::DijkstraWriteBarrierPolicy>;
553
+
554
+ /**
555
+ * UntracedMember is a pointer to an on-heap object that is not traced for some
556
+ * reason. Do not use this unless you know what you are doing. Keeping raw
557
+ * pointers to on-heap objects is prohibited unless used from stack. Pointee
558
+ * must be kept alive through other means.
559
+ */
560
+ template <typename T>
561
+ using UntracedMember = internal::BasicMember<T, internal::UntracedMemberTag,
562
+ internal::NoWriteBarrierPolicy>;
563
+
564
+ } // namespace cppgc
565
+
566
+ #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 the build supports extracting C++ names as object names.
41
+ *
42
+ * @returns true if C++ names should be hidden and represented by kHiddenName.
43
+ */
44
+ static constexpr bool SupportsCppClassNamesAsObjectNames() {
45
+ #if CPPGC_SUPPORTS_OBJECT_NAMES
46
+ return true;
47
+ #else // !CPPGC_SUPPORTS_OBJECT_NAMES
48
+ return false;
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_