@downdraft/native-mobile-android-arm64 0.0.0 → 0.1.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 (138) hide show
  1. package/README.md +7 -0
  2. package/include/node/cppgc/allocation.h +308 -0
  3. package/include/node/cppgc/common.h +28 -0
  4. package/include/node/cppgc/cross-thread-persistent.h +462 -0
  5. package/include/node/cppgc/custom-space.h +97 -0
  6. package/include/node/cppgc/default-platform.h +68 -0
  7. package/include/node/cppgc/explicit-management.h +100 -0
  8. package/include/node/cppgc/garbage-collected.h +114 -0
  9. package/include/node/cppgc/heap-consistency.h +309 -0
  10. package/include/node/cppgc/heap-handle.h +48 -0
  11. package/include/node/cppgc/heap-state.h +82 -0
  12. package/include/node/cppgc/heap-statistics.h +126 -0
  13. package/include/node/cppgc/heap.h +202 -0
  14. package/include/node/cppgc/internal/api-constants.h +75 -0
  15. package/include/node/cppgc/internal/atomic-entry-flag.h +48 -0
  16. package/include/node/cppgc/internal/base-page-handle.h +43 -0
  17. package/include/node/cppgc/internal/caged-heap-local-data.h +117 -0
  18. package/include/node/cppgc/internal/caged-heap.h +64 -0
  19. package/include/node/cppgc/internal/compiler-specific.h +46 -0
  20. package/include/node/cppgc/internal/conditional-stack-allocated.h +41 -0
  21. package/include/node/cppgc/internal/finalizer-trait.h +93 -0
  22. package/include/node/cppgc/internal/gc-info.h +150 -0
  23. package/include/node/cppgc/internal/logging.h +50 -0
  24. package/include/node/cppgc/internal/member-storage.h +305 -0
  25. package/include/node/cppgc/internal/name-trait.h +141 -0
  26. package/include/node/cppgc/internal/persistent-node.h +219 -0
  27. package/include/node/cppgc/internal/pointer-policies.h +280 -0
  28. package/include/node/cppgc/internal/write-barrier.h +487 -0
  29. package/include/node/cppgc/liveness-broker.h +78 -0
  30. package/include/node/cppgc/macros.h +56 -0
  31. package/include/node/cppgc/member.h +669 -0
  32. package/include/node/cppgc/name-provider.h +75 -0
  33. package/include/node/cppgc/object-size-trait.h +58 -0
  34. package/include/node/cppgc/persistent.h +376 -0
  35. package/include/node/cppgc/platform.h +174 -0
  36. package/include/node/cppgc/prefinalizer.h +75 -0
  37. package/include/node/cppgc/process-heap-statistics.h +36 -0
  38. package/include/node/cppgc/sentinel-pointer.h +39 -0
  39. package/include/node/cppgc/source-location.h +16 -0
  40. package/include/node/cppgc/tagged-member.h +114 -0
  41. package/include/node/cppgc/testing.h +106 -0
  42. package/include/node/cppgc/trace-trait.h +127 -0
  43. package/include/node/cppgc/type-traits.h +272 -0
  44. package/include/node/cppgc/visitor.h +534 -0
  45. package/include/node/js_native_api.h +634 -0
  46. package/include/node/js_native_api_types.h +244 -0
  47. package/include/node/libplatform/libplatform-export.h +29 -0
  48. package/include/node/libplatform/libplatform.h +112 -0
  49. package/include/node/libplatform/v8-tracing.h +343 -0
  50. package/include/node/node.h +1744 -0
  51. package/include/node/node_api.h +265 -0
  52. package/include/node/node_api_types.h +58 -0
  53. package/include/node/node_buffer.h +94 -0
  54. package/include/node/node_object_wrap.h +145 -0
  55. package/include/node/node_version.h +116 -0
  56. package/include/node/uv/aix.h +32 -0
  57. package/include/node/uv/bsd.h +34 -0
  58. package/include/node/uv/darwin.h +61 -0
  59. package/include/node/uv/errno.h +483 -0
  60. package/include/node/uv/linux.h +34 -0
  61. package/include/node/uv/os390.h +33 -0
  62. package/include/node/uv/posix.h +31 -0
  63. package/include/node/uv/sunos.h +44 -0
  64. package/include/node/uv/threadpool.h +37 -0
  65. package/include/node/uv/tree.h +521 -0
  66. package/include/node/uv/unix.h +509 -0
  67. package/include/node/uv/version.h +43 -0
  68. package/include/node/uv/win.h +698 -0
  69. package/include/node/uv.h +1994 -0
  70. package/include/node/v8-array-buffer.h +646 -0
  71. package/include/node/v8-callbacks.h +533 -0
  72. package/include/node/v8-container.h +183 -0
  73. package/include/node/v8-context.h +580 -0
  74. package/include/node/v8-cpp-heap-external.h +56 -0
  75. package/include/node/v8-cppgc.h +194 -0
  76. package/include/node/v8-data.h +96 -0
  77. package/include/node/v8-date.h +57 -0
  78. package/include/node/v8-debug.h +210 -0
  79. package/include/node/v8-embedder-heap.h +54 -0
  80. package/include/node/v8-embedder-state-scope.h +52 -0
  81. package/include/node/v8-exception.h +298 -0
  82. package/include/node/v8-extension.h +60 -0
  83. package/include/node/v8-external-memory-accounter.h +60 -0
  84. package/include/node/v8-external.h +73 -0
  85. package/include/node/v8-fast-api-calls.h +784 -0
  86. package/include/node/v8-forward.h +82 -0
  87. package/include/node/v8-function-callback.h +708 -0
  88. package/include/node/v8-function.h +148 -0
  89. package/include/node/v8-handle-base.h +155 -0
  90. package/include/node/v8-initialization.h +343 -0
  91. package/include/node/v8-inspector-protocol.h +13 -0
  92. package/include/node/v8-inspector.h +458 -0
  93. package/include/node/v8-internal.h +1827 -0
  94. package/include/node/v8-isolate.h +1925 -0
  95. package/include/node/v8-json.h +54 -0
  96. package/include/node/v8-local-handle.h +884 -0
  97. package/include/node/v8-locker.h +138 -0
  98. package/include/node/v8-maybe.h +185 -0
  99. package/include/node/v8-memory-span.h +273 -0
  100. package/include/node/v8-message.h +215 -0
  101. package/include/node/v8-metrics.h +273 -0
  102. package/include/node/v8-microtask-queue.h +152 -0
  103. package/include/node/v8-microtask.h +28 -0
  104. package/include/node/v8-object.h +1134 -0
  105. package/include/node/v8-persistent-handle.h +556 -0
  106. package/include/node/v8-platform.h +1552 -0
  107. package/include/node/v8-primitive-object.h +118 -0
  108. package/include/node/v8-primitive.h +1056 -0
  109. package/include/node/v8-profiler.h +1401 -0
  110. package/include/node/v8-promise.h +185 -0
  111. package/include/node/v8-proxy.h +49 -0
  112. package/include/node/v8-regexp.h +105 -0
  113. package/include/node/v8-sandbox.h +170 -0
  114. package/include/node/v8-script.h +996 -0
  115. package/include/node/v8-snapshot.h +302 -0
  116. package/include/node/v8-source-location.h +91 -0
  117. package/include/node/v8-statistics.h +246 -0
  118. package/include/node/v8-template.h +1096 -0
  119. package/include/node/v8-trace-categories.h +28 -0
  120. package/include/node/v8-traced-handle.h +420 -0
  121. package/include/node/v8-typed-array.h +386 -0
  122. package/include/node/v8-unwinder-state.h +30 -0
  123. package/include/node/v8-unwinder.h +146 -0
  124. package/include/node/v8-util.h +549 -0
  125. package/include/node/v8-value-serializer-version.h +24 -0
  126. package/include/node/v8-value-serializer.h +316 -0
  127. package/include/node/v8-value.h +674 -0
  128. package/include/node/v8-version-string.h +38 -0
  129. package/include/node/v8-version.h +20 -0
  130. package/include/node/v8-wasm-trap-handler-posix.h +31 -0
  131. package/include/node/v8-wasm-trap-handler-win.h +28 -0
  132. package/include/node/v8-wasm.h +325 -0
  133. package/include/node/v8-weak-callback-info.h +88 -0
  134. package/include/node/v8.h +88 -0
  135. package/include/node/v8config.h +1077 -0
  136. package/lib/libc++_shared.so +0 -0
  137. package/lib/libnode.so +4 -0
  138. package/package.json +23 -3
@@ -0,0 +1,141 @@
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_INTERNAL_NAME_TRAIT_H_
6
+ #define INCLUDE_CPPGC_INTERNAL_NAME_TRAIT_H_
7
+
8
+ #include <cstddef>
9
+ #include <cstdint>
10
+ #include <type_traits>
11
+
12
+ #include "cppgc/name-provider.h"
13
+ #include "v8config.h" // NOLINT(build/include_directory)
14
+
15
+ namespace cppgc {
16
+ namespace internal {
17
+
18
+ #if CPPGC_SUPPORTS_OBJECT_NAMES && defined(__clang__)
19
+ #define CPPGC_SUPPORTS_COMPILE_TIME_TYPENAME 1
20
+
21
+ // Provides constexpr c-string storage for a name of fixed |Size| characters.
22
+ // Automatically appends terminating 0 byte.
23
+ template <size_t Size>
24
+ struct NameBuffer {
25
+ char name[Size + 1]{};
26
+
27
+ static constexpr NameBuffer FromCString(const char* str) {
28
+ NameBuffer result;
29
+ for (size_t i = 0; i < Size; ++i) result.name[i] = str[i];
30
+ result.name[Size] = 0;
31
+ return result;
32
+ }
33
+ };
34
+
35
+ template <typename T>
36
+ const char* GetTypename() {
37
+ static constexpr char kSelfPrefix[] =
38
+ "const char *cppgc::internal::GetTypename() [T =";
39
+ static_assert(__builtin_strncmp(__PRETTY_FUNCTION__, kSelfPrefix,
40
+ sizeof(kSelfPrefix) - 1) == 0,
41
+ "The prefix must match");
42
+ static constexpr const char* kTypenameStart =
43
+ __PRETTY_FUNCTION__ + sizeof(kSelfPrefix);
44
+ static constexpr size_t kTypenameSize =
45
+ __builtin_strlen(__PRETTY_FUNCTION__) - sizeof(kSelfPrefix) - 1;
46
+ // NameBuffer is an indirection that is needed to make sure that only a
47
+ // substring of __PRETTY_FUNCTION__ gets materialized in the binary.
48
+ static constexpr auto buffer =
49
+ NameBuffer<kTypenameSize>::FromCString(kTypenameStart);
50
+ return buffer.name;
51
+ }
52
+
53
+ #else
54
+ #define CPPGC_SUPPORTS_COMPILE_TIME_TYPENAME 0
55
+ #endif
56
+
57
+ struct HeapObjectName {
58
+ const char* value;
59
+ bool name_was_hidden;
60
+ };
61
+
62
+ enum class HeapObjectNameForUnnamedObject : uint8_t {
63
+ kUseClassNameIfSupported,
64
+ kUseHiddenName,
65
+ };
66
+
67
+ class V8_EXPORT NameTraitBase {
68
+ protected:
69
+ static HeapObjectName GetNameFromTypeSignature(const char*);
70
+ };
71
+
72
+ // Trait that specifies how the garbage collector retrieves the name for a
73
+ // given object.
74
+ template <typename T>
75
+ class NameTrait final : public NameTraitBase {
76
+ public:
77
+ static constexpr bool HasNonHiddenName() {
78
+ #if CPPGC_SUPPORTS_COMPILE_TIME_TYPENAME
79
+ return true;
80
+ #elif CPPGC_SUPPORTS_OBJECT_NAMES
81
+ return true;
82
+ #else // !CPPGC_SUPPORTS_OBJECT_NAMES
83
+ return std::is_base_of_v<NameProvider, T>;
84
+ #endif // !CPPGC_SUPPORTS_OBJECT_NAMES
85
+ }
86
+
87
+ static HeapObjectName GetName(
88
+ const void* obj, HeapObjectNameForUnnamedObject name_retrieval_mode) {
89
+ return GetNameFor(static_cast<const T*>(obj), name_retrieval_mode);
90
+ }
91
+
92
+ private:
93
+ static HeapObjectName GetNameFor(const NameProvider* name_provider,
94
+ HeapObjectNameForUnnamedObject) {
95
+ // Objects inheriting from `NameProvider` are not considered unnamed as
96
+ // users already provided a name for them.
97
+ return {name_provider->GetHumanReadableName(), false};
98
+ }
99
+
100
+ static HeapObjectName GetNameFor(
101
+ const void*, HeapObjectNameForUnnamedObject name_retrieval_mode) {
102
+ if (name_retrieval_mode == HeapObjectNameForUnnamedObject::kUseHiddenName)
103
+ return {NameProvider::kHiddenName, true};
104
+
105
+ #if CPPGC_SUPPORTS_COMPILE_TIME_TYPENAME
106
+ return {GetTypename<T>(), false};
107
+ #elif CPPGC_SUPPORTS_OBJECT_NAMES
108
+
109
+ #if defined(V8_CC_GNU)
110
+ #define PRETTY_FUNCTION_VALUE __PRETTY_FUNCTION__
111
+ #elif defined(V8_CC_MSVC)
112
+ #define PRETTY_FUNCTION_VALUE __FUNCSIG__
113
+ #else
114
+ #define PRETTY_FUNCTION_VALUE nullptr
115
+ #endif
116
+
117
+ static const HeapObjectName leaky_name =
118
+ GetNameFromTypeSignature(PRETTY_FUNCTION_VALUE);
119
+ return leaky_name;
120
+
121
+ #undef PRETTY_FUNCTION_VALUE
122
+
123
+ #else // !CPPGC_SUPPORTS_OBJECT_NAMES
124
+ // We wanted to use a class name but were unable to provide one due to
125
+ // compiler limitations or build configuration. As such, return the hidden
126
+ // name with name_was_hidden=false, which will cause this object to be
127
+ // visible in the snapshot.
128
+ return {NameProvider::kHiddenName, false};
129
+ #endif // !CPPGC_SUPPORTS_OBJECT_NAMES
130
+ }
131
+ };
132
+
133
+ using NameCallback = HeapObjectName (*)(const void*,
134
+ HeapObjectNameForUnnamedObject);
135
+
136
+ } // namespace internal
137
+ } // namespace cppgc
138
+
139
+ #undef CPPGC_SUPPORTS_COMPILE_TIME_TYPENAME
140
+
141
+ #endif // INCLUDE_CPPGC_INTERNAL_NAME_TRAIT_H_
@@ -0,0 +1,219 @@
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_INTERNAL_PERSISTENT_NODE_H_
6
+ #define INCLUDE_CPPGC_INTERNAL_PERSISTENT_NODE_H_
7
+
8
+ #include <array>
9
+ #include <memory>
10
+ #include <vector>
11
+
12
+ #include "cppgc/internal/logging.h"
13
+ #include "cppgc/trace-trait.h"
14
+ #include "v8config.h" // NOLINT(build/include_directory)
15
+
16
+ namespace cppgc {
17
+ namespace internal {
18
+
19
+ class CrossThreadPersistentRegion;
20
+ class FatalOutOfMemoryHandler;
21
+ class HeapBase;
22
+ class RootVisitor;
23
+
24
+ // PersistentNode represents a variant of two states:
25
+ // 1) traceable node with a back pointer to the Persistent object;
26
+ // 2) freelist entry.
27
+ class PersistentNode final {
28
+ public:
29
+ PersistentNode() = default;
30
+
31
+ PersistentNode(const PersistentNode&) = delete;
32
+ PersistentNode& operator=(const PersistentNode&) = delete;
33
+
34
+ void InitializeAsUsedNode(void* owner, TraceRootCallback trace) {
35
+ CPPGC_DCHECK(trace);
36
+ owner_ = owner;
37
+ trace_ = trace;
38
+ }
39
+
40
+ void InitializeAsFreeNode(PersistentNode* next) {
41
+ next_ = next;
42
+ trace_ = nullptr;
43
+ }
44
+
45
+ void UpdateOwner(void* owner) {
46
+ CPPGC_DCHECK(IsUsed());
47
+ owner_ = owner;
48
+ }
49
+
50
+ PersistentNode* FreeListNext() const {
51
+ CPPGC_DCHECK(!IsUsed());
52
+ return next_;
53
+ }
54
+
55
+ void Trace(RootVisitor& root_visitor) const {
56
+ CPPGC_DCHECK(IsUsed());
57
+ trace_(root_visitor, owner_);
58
+ }
59
+
60
+ bool IsUsed() const { return trace_; }
61
+
62
+ void* owner() const {
63
+ CPPGC_DCHECK(IsUsed());
64
+ return owner_;
65
+ }
66
+
67
+ private:
68
+ // PersistentNode acts as a designated union:
69
+ // If trace_ != nullptr, owner_ points to the corresponding Persistent handle.
70
+ // Otherwise, next_ points to the next freed PersistentNode.
71
+ union {
72
+ void* owner_ = nullptr;
73
+ PersistentNode* next_;
74
+ };
75
+ TraceRootCallback trace_ = nullptr;
76
+ };
77
+
78
+ class V8_EXPORT PersistentRegionBase {
79
+ using PersistentNodeSlots = std::array<PersistentNode, 256u>;
80
+
81
+ public:
82
+ // Clears Persistent fields to avoid stale pointers after heap teardown.
83
+ ~PersistentRegionBase();
84
+
85
+ PersistentRegionBase(const PersistentRegionBase&) = delete;
86
+ PersistentRegionBase& operator=(const PersistentRegionBase&) = delete;
87
+
88
+ void Iterate(RootVisitor&);
89
+
90
+ size_t NodesInUse() const;
91
+
92
+ void ClearAllUsedNodes();
93
+
94
+ protected:
95
+ explicit PersistentRegionBase(const FatalOutOfMemoryHandler& oom_handler);
96
+
97
+ PersistentNode* TryAllocateNodeFromFreeList(void* owner,
98
+ TraceRootCallback trace) {
99
+ PersistentNode* node = nullptr;
100
+ if (V8_LIKELY(free_list_head_)) {
101
+ node = free_list_head_;
102
+ free_list_head_ = free_list_head_->FreeListNext();
103
+ CPPGC_DCHECK(!node->IsUsed());
104
+ node->InitializeAsUsedNode(owner, trace);
105
+ nodes_in_use_++;
106
+ }
107
+ return node;
108
+ }
109
+
110
+ void FreeNode(PersistentNode* node) {
111
+ CPPGC_DCHECK(node);
112
+ CPPGC_DCHECK(node->IsUsed());
113
+ node->InitializeAsFreeNode(free_list_head_);
114
+ free_list_head_ = node;
115
+ CPPGC_DCHECK(nodes_in_use_ > 0);
116
+ nodes_in_use_--;
117
+ }
118
+
119
+ PersistentNode* RefillFreeListAndAllocateNode(void* owner,
120
+ TraceRootCallback trace);
121
+
122
+ private:
123
+ template <typename PersistentBaseClass>
124
+ void ClearAllUsedNodes();
125
+
126
+ void RefillFreeList();
127
+
128
+ std::vector<std::unique_ptr<PersistentNodeSlots>> nodes_;
129
+ PersistentNode* free_list_head_ = nullptr;
130
+ size_t nodes_in_use_ = 0;
131
+ const FatalOutOfMemoryHandler& oom_handler_;
132
+
133
+ friend class CrossThreadPersistentRegion;
134
+ };
135
+
136
+ // Variant of PersistentRegionBase that checks whether the allocation and
137
+ // freeing happens only on the thread that created the heap.
138
+ class V8_EXPORT PersistentRegion final : public PersistentRegionBase {
139
+ public:
140
+ V8_INLINE PersistentRegion(const HeapBase& heap,
141
+ const FatalOutOfMemoryHandler& oom_handler)
142
+ : PersistentRegionBase(oom_handler), heap_(heap) {
143
+ CPPGC_DCHECK(IsCreationThread());
144
+ }
145
+ // Clears Persistent fields to avoid stale pointers after heap teardown.
146
+ ~PersistentRegion() = default;
147
+
148
+ PersistentRegion(const PersistentRegion&) = delete;
149
+ PersistentRegion& operator=(const PersistentRegion&) = delete;
150
+
151
+ V8_INLINE PersistentNode* AllocateNode(void* owner, TraceRootCallback trace) {
152
+ CPPGC_DCHECK(IsCreationThread());
153
+ auto* node = TryAllocateNodeFromFreeList(owner, trace);
154
+ if (V8_LIKELY(node)) return node;
155
+
156
+ // Slow path allocation allows for checking thread correspondence.
157
+ CPPGC_CHECK(IsCreationThread());
158
+ return RefillFreeListAndAllocateNode(owner, trace);
159
+ }
160
+
161
+ V8_INLINE void FreeNode(PersistentNode* node) {
162
+ CPPGC_DCHECK(IsCreationThread());
163
+ PersistentRegionBase::FreeNode(node);
164
+ }
165
+
166
+ private:
167
+ bool IsCreationThread();
168
+
169
+ const HeapBase& heap_;
170
+ };
171
+
172
+ // CrossThreadPersistent uses PersistentRegionBase but protects it using this
173
+ // lock when needed.
174
+ class V8_EXPORT PersistentRegionLock final {
175
+ public:
176
+ PersistentRegionLock();
177
+ ~PersistentRegionLock();
178
+
179
+ static void AssertLocked();
180
+ };
181
+
182
+ // Variant of PersistentRegionBase that checks whether the PersistentRegionLock
183
+ // is locked.
184
+ class V8_EXPORT CrossThreadPersistentRegion final
185
+ : protected PersistentRegionBase {
186
+ public:
187
+ explicit CrossThreadPersistentRegion(const FatalOutOfMemoryHandler&);
188
+ // Clears Persistent fields to avoid stale pointers after heap teardown.
189
+ ~CrossThreadPersistentRegion();
190
+
191
+ CrossThreadPersistentRegion(const CrossThreadPersistentRegion&) = delete;
192
+ CrossThreadPersistentRegion& operator=(const CrossThreadPersistentRegion&) =
193
+ delete;
194
+
195
+ V8_INLINE PersistentNode* AllocateNode(void* owner, TraceRootCallback trace) {
196
+ PersistentRegionLock::AssertLocked();
197
+ auto* node = TryAllocateNodeFromFreeList(owner, trace);
198
+ if (V8_LIKELY(node)) return node;
199
+
200
+ return RefillFreeListAndAllocateNode(owner, trace);
201
+ }
202
+
203
+ V8_INLINE void FreeNode(PersistentNode* node) {
204
+ PersistentRegionLock::AssertLocked();
205
+ PersistentRegionBase::FreeNode(node);
206
+ }
207
+
208
+ void Iterate(RootVisitor&);
209
+
210
+ size_t NodesInUse() const;
211
+
212
+ void ClearAllUsedNodes();
213
+ };
214
+
215
+ } // namespace internal
216
+
217
+ } // namespace cppgc
218
+
219
+ #endif // INCLUDE_CPPGC_INTERNAL_PERSISTENT_NODE_H_
@@ -0,0 +1,280 @@
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_INTERNAL_POINTER_POLICIES_H_
6
+ #define INCLUDE_CPPGC_INTERNAL_POINTER_POLICIES_H_
7
+
8
+ #include <cstdint>
9
+ #include <type_traits>
10
+
11
+ #include "cppgc/internal/member-storage.h"
12
+ #include "cppgc/internal/write-barrier.h"
13
+ #include "cppgc/sentinel-pointer.h"
14
+ #include "cppgc/source-location.h"
15
+ #include "cppgc/type-traits.h"
16
+ #include "v8config.h" // NOLINT(build/include_directory)
17
+
18
+ namespace cppgc {
19
+ namespace internal {
20
+
21
+ class HeapBase;
22
+ class PersistentRegion;
23
+ class CrossThreadPersistentRegion;
24
+
25
+ // Tags to distinguish between strong and weak member types.
26
+ class StrongMemberTag;
27
+ class WeakMemberTag;
28
+ class UntracedMemberTag;
29
+
30
+ struct DijkstraWriteBarrierPolicy {
31
+ // Since in initializing writes the source object is always white, having no
32
+ // barrier doesn't break the tri-color invariant.
33
+ V8_INLINE static void InitializingBarrier(const void*, const void*) {}
34
+ V8_INLINE static void InitializingBarrier(const void*, RawPointer storage) {
35
+ }
36
+ #if defined(CPPGC_POINTER_COMPRESSION)
37
+ V8_INLINE static void InitializingBarrier(const void*,
38
+ CompressedPointer storage) {}
39
+ #endif
40
+
41
+ template <WriteBarrierSlotType SlotType>
42
+ V8_INLINE static void AssigningBarrier(const void* slot,
43
+ const void* value) {
44
+ #ifdef CPPGC_SLIM_WRITE_BARRIER
45
+ if (V8_UNLIKELY(WriteBarrier::IsEnabled()))
46
+ WriteBarrier::CombinedWriteBarrierSlow<SlotType>(slot);
47
+ #else // !CPPGC_SLIM_WRITE_BARRIER
48
+ WriteBarrier::Params params;
49
+ const WriteBarrier::Type type =
50
+ WriteBarrier::GetWriteBarrierType(slot, value, params);
51
+ WriteBarrier(type, params, slot, value);
52
+ #endif // !CPPGC_SLIM_WRITE_BARRIER
53
+ }
54
+
55
+ template <WriteBarrierSlotType SlotType>
56
+ V8_INLINE static void AssigningBarrier(const void* slot, RawPointer storage) {
57
+ static_assert(
58
+ SlotType == WriteBarrierSlotType::kUncompressed,
59
+ "Assigning storages of Member and UncompressedMember is not supported");
60
+ #ifdef CPPGC_SLIM_WRITE_BARRIER
61
+ if (V8_UNLIKELY(WriteBarrier::IsEnabled()))
62
+ WriteBarrier::CombinedWriteBarrierSlow<SlotType>(slot);
63
+ #else // !CPPGC_SLIM_WRITE_BARRIER
64
+ WriteBarrier::Params params;
65
+ const WriteBarrier::Type type =
66
+ WriteBarrier::GetWriteBarrierType(slot, storage, params);
67
+ WriteBarrier(type, params, slot, storage.Load());
68
+ #endif // !CPPGC_SLIM_WRITE_BARRIER
69
+ }
70
+
71
+ #if defined(CPPGC_POINTER_COMPRESSION)
72
+ template <WriteBarrierSlotType SlotType>
73
+ V8_INLINE static void AssigningBarrier(const void* slot,
74
+ CompressedPointer storage) {
75
+ static_assert(
76
+ SlotType == WriteBarrierSlotType::kCompressed,
77
+ "Assigning storages of Member and UncompressedMember is not supported");
78
+ #ifdef CPPGC_SLIM_WRITE_BARRIER
79
+ if (V8_UNLIKELY(WriteBarrier::IsEnabled()))
80
+ WriteBarrier::CombinedWriteBarrierSlow<SlotType>(slot);
81
+ #else // !CPPGC_SLIM_WRITE_BARRIER
82
+ WriteBarrier::Params params;
83
+ const WriteBarrier::Type type =
84
+ WriteBarrier::GetWriteBarrierType(slot, storage, params);
85
+ WriteBarrier(type, params, slot, storage.Load());
86
+ #endif // !CPPGC_SLIM_WRITE_BARRIER
87
+ }
88
+ #endif // defined(CPPGC_POINTER_COMPRESSION)
89
+
90
+ private:
91
+ V8_INLINE static void WriteBarrier(WriteBarrier::Type type,
92
+ const WriteBarrier::Params& params,
93
+ const void* slot, const void* value) {
94
+ switch (type) {
95
+ case WriteBarrier::Type::kGenerational:
96
+ WriteBarrier::GenerationalBarrier<
97
+ WriteBarrier::GenerationalBarrierType::kPreciseSlot>(params, slot);
98
+ break;
99
+ case WriteBarrier::Type::kMarking:
100
+ WriteBarrier::DijkstraMarkingBarrier(params, value);
101
+ break;
102
+ case WriteBarrier::Type::kNone:
103
+ break;
104
+ }
105
+ }
106
+ };
107
+
108
+ struct NoWriteBarrierPolicy {
109
+ V8_INLINE static void InitializingBarrier(const void*, const void*) {}
110
+ V8_INLINE static void InitializingBarrier(const void*, RawPointer storage) {}
111
+ #if defined(CPPGC_POINTER_COMPRESSION)
112
+ V8_INLINE static void InitializingBarrier(const void*,
113
+ CompressedPointer storage) {}
114
+ #endif
115
+ template <WriteBarrierSlotType>
116
+ V8_INLINE static void AssigningBarrier(const void*, const void*) {}
117
+ template <WriteBarrierSlotType, typename MemberStorage>
118
+ V8_INLINE static void AssigningBarrier(const void*, MemberStorage) {}
119
+ };
120
+
121
+ class V8_EXPORT SameThreadEnabledCheckingPolicyBase {
122
+ protected:
123
+ void CheckPointerImpl(const void* ptr, bool points_to_payload,
124
+ bool check_off_heap_assignments);
125
+
126
+ const HeapBase* heap_ = nullptr;
127
+ };
128
+
129
+ template <bool kCheckOffHeapAssignments>
130
+ class V8_EXPORT SameThreadEnabledCheckingPolicy
131
+ : private SameThreadEnabledCheckingPolicyBase {
132
+ protected:
133
+ template <typename T>
134
+ V8_INLINE void CheckPointer(RawPointer raw_pointer) {
135
+ if (raw_pointer.IsCleared() || raw_pointer.IsSentinel()) {
136
+ return;
137
+ }
138
+ CheckPointersImplTrampoline<T>::Call(
139
+ this, static_cast<const T*>(raw_pointer.Load()));
140
+ }
141
+ #if defined(CPPGC_POINTER_COMPRESSION)
142
+ template <typename T>
143
+ V8_INLINE void CheckPointer(CompressedPointer compressed_pointer) {
144
+ if (compressed_pointer.IsCleared() || compressed_pointer.IsSentinel()) {
145
+ return;
146
+ }
147
+ CheckPointersImplTrampoline<T>::Call(
148
+ this, static_cast<const T*>(compressed_pointer.Load()));
149
+ }
150
+ #endif
151
+ template <typename T>
152
+ void CheckPointer(const T* ptr) {
153
+ if (!ptr || (kSentinelPointer == ptr)) {
154
+ return;
155
+ }
156
+ CheckPointersImplTrampoline<T>::Call(this, ptr);
157
+ }
158
+
159
+ private:
160
+ template <typename T, bool = IsCompleteV<T>>
161
+ struct CheckPointersImplTrampoline {
162
+ static void Call(SameThreadEnabledCheckingPolicy* policy, const T* ptr) {
163
+ policy->CheckPointerImpl(ptr, false, kCheckOffHeapAssignments);
164
+ }
165
+ };
166
+
167
+ template <typename T>
168
+ struct CheckPointersImplTrampoline<T, true> {
169
+ static void Call(SameThreadEnabledCheckingPolicy* policy, const T* ptr) {
170
+ policy->CheckPointerImpl(ptr, IsGarbageCollectedTypeV<T>,
171
+ kCheckOffHeapAssignments);
172
+ }
173
+ };
174
+ };
175
+
176
+ class DisabledCheckingPolicy {
177
+ protected:
178
+ template <typename T>
179
+ V8_INLINE void CheckPointer(T*) {}
180
+ template <typename T>
181
+ V8_INLINE void CheckPointer(RawPointer) {}
182
+ #if defined(CPPGC_POINTER_COMPRESSION)
183
+ template <typename T>
184
+ V8_INLINE void CheckPointer(CompressedPointer) {}
185
+ #endif
186
+ };
187
+
188
+ #ifdef CPPGC_ENABLE_SLOW_API_CHECKS
189
+ // Off heap members are not connected to object graph and thus cannot ressurect
190
+ // dead objects.
191
+ using DefaultMemberCheckingPolicy =
192
+ SameThreadEnabledCheckingPolicy<false /* kCheckOffHeapAssignments*/>;
193
+ using DefaultPersistentCheckingPolicy =
194
+ SameThreadEnabledCheckingPolicy<true /* kCheckOffHeapAssignments*/>;
195
+ #else // !CPPGC_ENABLE_SLOW_API_CHECKS
196
+ using DefaultMemberCheckingPolicy = DisabledCheckingPolicy;
197
+ using DefaultPersistentCheckingPolicy = DisabledCheckingPolicy;
198
+ #endif // !CPPGC_ENABLE_SLOW_API_CHECKS
199
+ // For CT(W)P neither marking information (for value), nor objectstart bitmap
200
+ // (for slot) are guaranteed to be present because there's no synchronization
201
+ // between heaps after marking.
202
+ using DefaultCrossThreadPersistentCheckingPolicy = DisabledCheckingPolicy;
203
+
204
+ class KeepLocationPolicy {
205
+ public:
206
+ constexpr SourceLocation Location() const { return location_; }
207
+
208
+ protected:
209
+ constexpr KeepLocationPolicy() = default;
210
+ constexpr explicit KeepLocationPolicy(SourceLocation location)
211
+ : location_(location) {}
212
+
213
+ // KeepLocationPolicy must not copy underlying source locations.
214
+ KeepLocationPolicy(const KeepLocationPolicy&) = delete;
215
+ KeepLocationPolicy& operator=(const KeepLocationPolicy&) = delete;
216
+
217
+ // Location of the original moved from object should be preserved.
218
+ KeepLocationPolicy(KeepLocationPolicy&&) = default;
219
+ KeepLocationPolicy& operator=(KeepLocationPolicy&&) = default;
220
+
221
+ private:
222
+ SourceLocation location_;
223
+ };
224
+
225
+ class IgnoreLocationPolicy {
226
+ public:
227
+ constexpr SourceLocation Location() const { return {}; }
228
+
229
+ protected:
230
+ constexpr IgnoreLocationPolicy() = default;
231
+ constexpr explicit IgnoreLocationPolicy(SourceLocation) {}
232
+ };
233
+
234
+ #if CPPGC_SUPPORTS_OBJECT_NAMES
235
+ using DefaultLocationPolicy = KeepLocationPolicy;
236
+ #else
237
+ using DefaultLocationPolicy = IgnoreLocationPolicy;
238
+ #endif
239
+
240
+ struct StrongPersistentPolicy {
241
+ using IsStrongPersistent = std::true_type;
242
+ static V8_EXPORT PersistentRegion& GetPersistentRegion(const void* object);
243
+ };
244
+
245
+ struct WeakPersistentPolicy {
246
+ using IsStrongPersistent = std::false_type;
247
+ static V8_EXPORT PersistentRegion& GetPersistentRegion(const void* object);
248
+ };
249
+
250
+ struct StrongCrossThreadPersistentPolicy {
251
+ using IsStrongPersistent = std::true_type;
252
+ static V8_EXPORT CrossThreadPersistentRegion& GetPersistentRegion(
253
+ const void* object);
254
+ };
255
+
256
+ struct WeakCrossThreadPersistentPolicy {
257
+ using IsStrongPersistent = std::false_type;
258
+ static V8_EXPORT CrossThreadPersistentRegion& GetPersistentRegion(
259
+ const void* object);
260
+ };
261
+
262
+ // Forward declarations setting up the default policies.
263
+ template <typename T, typename WeaknessPolicy,
264
+ typename LocationPolicy = DefaultLocationPolicy,
265
+ typename CheckingPolicy = DefaultCrossThreadPersistentCheckingPolicy>
266
+ class BasicCrossThreadPersistent;
267
+ template <typename T, typename WeaknessPolicy,
268
+ typename LocationPolicy = DefaultLocationPolicy,
269
+ typename CheckingPolicy = DefaultPersistentCheckingPolicy>
270
+ class BasicPersistent;
271
+ template <typename T, typename WeaknessTag, typename WriteBarrierPolicy,
272
+ typename CheckingPolicy = DefaultMemberCheckingPolicy,
273
+ typename StorageType = DefaultMemberStorage>
274
+ class BasicMember;
275
+
276
+ } // namespace internal
277
+
278
+ } // namespace cppgc
279
+
280
+ #endif // INCLUDE_CPPGC_INTERNAL_POINTER_POLICIES_H_