libv8-node 15.14.0.1-aarch64-linux-musl → 18.8.0.0-aarch64-linux-musl
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 +4 -4
- data/ext/libv8-node/location.rb +1 -1
- data/ext/libv8-node/paths.rb +5 -1
- data/lib/libv8/node/version.rb +3 -3
- data/vendor/v8/{out.gn → aarch64-linux-musl}/libv8/obj/libv8_monolith.a +0 -0
- data/vendor/v8/include/cppgc/allocation.h +184 -47
- data/vendor/v8/include/cppgc/common.h +9 -6
- data/vendor/v8/include/cppgc/cross-thread-persistent.h +465 -0
- data/vendor/v8/include/cppgc/custom-space.h +37 -2
- data/vendor/v8/include/cppgc/default-platform.h +40 -49
- data/vendor/v8/include/cppgc/ephemeron-pair.h +30 -0
- data/vendor/v8/include/cppgc/explicit-management.h +100 -0
- data/vendor/v8/include/cppgc/garbage-collected.h +19 -29
- data/vendor/v8/include/cppgc/heap-consistency.h +266 -0
- data/vendor/v8/include/cppgc/heap-state.h +82 -0
- data/vendor/v8/include/cppgc/heap-statistics.h +120 -0
- data/vendor/v8/include/cppgc/heap.h +73 -6
- data/vendor/v8/include/cppgc/internal/api-constants.h +11 -3
- data/vendor/v8/include/cppgc/internal/caged-heap-local-data.h +27 -15
- data/vendor/v8/include/cppgc/internal/compiler-specific.h +2 -2
- data/vendor/v8/include/cppgc/internal/finalizer-trait.h +4 -1
- data/vendor/v8/include/cppgc/internal/gc-info.h +124 -13
- data/vendor/v8/include/cppgc/internal/logging.h +3 -3
- data/vendor/v8/include/cppgc/internal/name-trait.h +122 -0
- data/vendor/v8/include/cppgc/internal/persistent-node.h +116 -16
- data/vendor/v8/include/cppgc/internal/pointer-policies.h +84 -32
- data/vendor/v8/include/cppgc/internal/write-barrier.h +392 -35
- data/vendor/v8/include/cppgc/liveness-broker.h +11 -2
- data/vendor/v8/include/cppgc/macros.h +2 -0
- data/vendor/v8/include/cppgc/member.h +91 -26
- 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 +70 -41
- data/vendor/v8/include/cppgc/platform.h +52 -26
- data/vendor/v8/include/cppgc/prefinalizer.h +36 -13
- 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 +2 -1
- data/vendor/v8/include/cppgc/testing.h +106 -0
- data/vendor/v8/include/cppgc/trace-trait.h +8 -3
- data/vendor/v8/include/cppgc/type-traits.h +163 -32
- data/vendor/v8/include/cppgc/visitor.h +194 -28
- data/vendor/v8/include/libplatform/libplatform.h +11 -11
- data/vendor/v8/include/libplatform/v8-tracing.h +2 -1
- data/vendor/v8/include/v8-array-buffer.h +445 -0
- data/vendor/v8/include/v8-callbacks.h +397 -0
- data/vendor/v8/include/v8-container.h +129 -0
- data/vendor/v8/include/v8-context.h +407 -0
- data/vendor/v8/include/v8-cppgc.h +151 -159
- data/vendor/v8/include/v8-data.h +80 -0
- data/vendor/v8/include/v8-date.h +43 -0
- data/vendor/v8/include/v8-debug.h +168 -0
- data/vendor/v8/include/v8-embedder-heap.h +218 -0
- data/vendor/v8/include/v8-embedder-state-scope.h +51 -0
- data/vendor/v8/include/v8-exception.h +217 -0
- data/vendor/v8/include/v8-extension.h +62 -0
- data/vendor/v8/include/v8-external.h +37 -0
- data/vendor/v8/include/v8-fast-api-calls.h +703 -152
- data/vendor/v8/include/v8-forward.h +81 -0
- data/vendor/v8/include/v8-function-callback.h +475 -0
- data/vendor/v8/include/v8-function.h +125 -0
- data/vendor/v8/include/v8-initialization.h +315 -0
- data/vendor/v8/include/v8-inspector.h +76 -27
- data/vendor/v8/include/v8-internal.h +285 -51
- data/vendor/v8/include/v8-isolate.h +1709 -0
- data/vendor/v8/include/v8-json.h +47 -0
- data/vendor/v8/include/v8-local-handle.h +455 -0
- data/vendor/v8/include/v8-locker.h +149 -0
- data/vendor/v8/include/v8-maybe.h +137 -0
- data/vendor/v8/include/v8-memory-span.h +43 -0
- data/vendor/v8/include/v8-message.h +216 -0
- data/vendor/v8/include/v8-metrics.h +131 -9
- data/vendor/v8/include/v8-microtask-queue.h +152 -0
- data/vendor/v8/include/v8-microtask.h +28 -0
- data/vendor/v8/include/v8-object.h +775 -0
- data/vendor/v8/include/v8-persistent-handle.h +590 -0
- data/vendor/v8/include/v8-platform.h +433 -25
- data/vendor/v8/include/v8-primitive-object.h +118 -0
- data/vendor/v8/include/v8-primitive.h +866 -0
- data/vendor/v8/include/v8-profiler.h +149 -10
- data/vendor/v8/include/v8-promise.h +174 -0
- data/vendor/v8/include/v8-proxy.h +50 -0
- data/vendor/v8/include/v8-regexp.h +105 -0
- data/vendor/v8/include/v8-script.h +747 -0
- data/vendor/v8/include/v8-snapshot.h +196 -0
- data/vendor/v8/include/v8-statistics.h +217 -0
- data/vendor/v8/include/v8-template.h +1079 -0
- data/vendor/v8/include/v8-traced-handle.h +420 -0
- data/vendor/v8/include/v8-typed-array.h +282 -0
- data/vendor/v8/include/v8-unwinder-state.h +31 -0
- data/vendor/v8/include/v8-unwinder.h +132 -0
- data/vendor/v8/include/v8-util.h +8 -2
- data/vendor/v8/include/v8-value-serializer-version.h +1 -1
- data/vendor/v8/include/v8-value-serializer.h +279 -0
- data/vendor/v8/include/v8-value.h +526 -0
- data/vendor/v8/include/v8-version.h +4 -4
- data/vendor/v8/include/v8-wasm.h +257 -0
- data/vendor/v8/include/v8-weak-callback-info.h +87 -0
- data/vendor/v8/include/v8.h +41 -12051
- data/vendor/v8/include/v8config.h +142 -21
- metadata +64 -10
- data/vendor/v8/include/cppgc/internal/prefinalizer-handler.h +0 -30
- data/vendor/v8/include/cppgc/internal/process-heap.h +0 -34
@@ -10,6 +10,7 @@
|
|
10
10
|
#include <type_traits>
|
11
11
|
|
12
12
|
#include "cppgc/internal/pointer-policies.h"
|
13
|
+
#include "cppgc/sentinel-pointer.h"
|
13
14
|
#include "cppgc/type-traits.h"
|
14
15
|
#include "v8config.h" // NOLINT(build/include_directory)
|
15
16
|
|
@@ -19,28 +20,36 @@ class Visitor;
|
|
19
20
|
|
20
21
|
namespace internal {
|
21
22
|
|
23
|
+
// MemberBase always refers to the object as const object and defers to
|
24
|
+
// BasicMember on casting to the right type as needed.
|
22
25
|
class MemberBase {
|
23
26
|
protected:
|
24
|
-
|
25
|
-
explicit MemberBase(void* value) : raw_(value) {}
|
27
|
+
struct AtomicInitializerTag {};
|
26
28
|
|
27
|
-
|
28
|
-
void*
|
29
|
+
MemberBase() : raw_(nullptr) {}
|
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_; }
|
29
35
|
void SetRaw(void* value) { raw_ = value; }
|
30
36
|
|
31
|
-
void* GetRawAtomic() const {
|
32
|
-
return reinterpret_cast<const std::atomic<void*>*>(&raw_)->load(
|
37
|
+
const void* GetRawAtomic() const {
|
38
|
+
return reinterpret_cast<const std::atomic<const void*>*>(&raw_)->load(
|
33
39
|
std::memory_order_relaxed);
|
34
40
|
}
|
35
|
-
void SetRawAtomic(void* value) {
|
36
|
-
reinterpret_cast<std::atomic<void*>*>(&raw_)->store(
|
41
|
+
void SetRawAtomic(const void* value) {
|
42
|
+
reinterpret_cast<std::atomic<const void*>*>(&raw_)->store(
|
37
43
|
value, std::memory_order_relaxed);
|
38
44
|
}
|
39
45
|
|
40
46
|
void ClearFromGC() const { raw_ = nullptr; }
|
41
47
|
|
42
48
|
private:
|
43
|
-
|
49
|
+
// All constructors initialize `raw_`. Do not add a default value here as it
|
50
|
+
// results in a non-atomic write on some builds, even when the atomic version
|
51
|
+
// of the constructor is used.
|
52
|
+
mutable const void* raw_;
|
44
53
|
};
|
45
54
|
|
46
55
|
// The basic class from which all Member classes are 'generated'.
|
@@ -58,6 +67,21 @@ class BasicMember final : private MemberBase, private CheckingPolicy {
|
|
58
67
|
this->CheckPointer(Get());
|
59
68
|
}
|
60
69
|
BasicMember(T& raw) : BasicMember(&raw) {} // NOLINT
|
70
|
+
// Atomic ctor. Using the AtomicInitializerTag forces BasicMember to
|
71
|
+
// initialize using atomic assignments. This is required for preventing
|
72
|
+
// data races with concurrent marking.
|
73
|
+
using AtomicInitializerTag = MemberBase::AtomicInitializerTag;
|
74
|
+
BasicMember(std::nullptr_t, AtomicInitializerTag atomic)
|
75
|
+
: MemberBase(nullptr, atomic) {}
|
76
|
+
BasicMember(SentinelPointer s, AtomicInitializerTag atomic)
|
77
|
+
: MemberBase(s, atomic) {}
|
78
|
+
BasicMember(T* raw, AtomicInitializerTag atomic) : MemberBase(raw, atomic) {
|
79
|
+
InitializingWriteBarrier();
|
80
|
+
this->CheckPointer(Get());
|
81
|
+
}
|
82
|
+
BasicMember(T& raw, AtomicInitializerTag atomic)
|
83
|
+
: BasicMember(&raw, atomic) {}
|
84
|
+
// Copy ctor.
|
61
85
|
BasicMember(const BasicMember& other) : BasicMember(other.Get()) {}
|
62
86
|
// Allow heterogeneous construction.
|
63
87
|
template <typename U, typename OtherBarrierPolicy, typename OtherWeaknessTag,
|
@@ -67,21 +91,34 @@ class BasicMember final : private MemberBase, private CheckingPolicy {
|
|
67
91
|
const BasicMember<U, OtherWeaknessTag, OtherBarrierPolicy,
|
68
92
|
OtherCheckingPolicy>& other)
|
69
93
|
: BasicMember(other.Get()) {}
|
94
|
+
// Move ctor.
|
95
|
+
BasicMember(BasicMember&& other) noexcept : BasicMember(other.Get()) {
|
96
|
+
other.Clear();
|
97
|
+
}
|
98
|
+
// Allow heterogeneous move construction.
|
99
|
+
template <typename U, typename OtherBarrierPolicy, typename OtherWeaknessTag,
|
100
|
+
typename OtherCheckingPolicy,
|
101
|
+
typename = std::enable_if_t<std::is_base_of<T, U>::value>>
|
102
|
+
BasicMember(BasicMember<U, OtherWeaknessTag, OtherBarrierPolicy,
|
103
|
+
OtherCheckingPolicy>&& other) noexcept
|
104
|
+
: BasicMember(other.Get()) {
|
105
|
+
other.Clear();
|
106
|
+
}
|
70
107
|
// Construction from Persistent.
|
71
108
|
template <typename U, typename PersistentWeaknessPolicy,
|
72
109
|
typename PersistentLocationPolicy,
|
73
110
|
typename PersistentCheckingPolicy,
|
74
111
|
typename = std::enable_if_t<std::is_base_of<T, U>::value>>
|
75
|
-
BasicMember(
|
76
|
-
|
77
|
-
|
78
|
-
p)
|
112
|
+
BasicMember(const BasicPersistent<U, PersistentWeaknessPolicy,
|
113
|
+
PersistentLocationPolicy,
|
114
|
+
PersistentCheckingPolicy>& p)
|
79
115
|
: BasicMember(p.Get()) {}
|
80
116
|
|
117
|
+
// Copy assignment.
|
81
118
|
BasicMember& operator=(const BasicMember& other) {
|
82
119
|
return operator=(other.Get());
|
83
120
|
}
|
84
|
-
// Allow heterogeneous assignment.
|
121
|
+
// Allow heterogeneous copy assignment.
|
85
122
|
template <typename U, typename OtherWeaknessTag, typename OtherBarrierPolicy,
|
86
123
|
typename OtherCheckingPolicy,
|
87
124
|
typename = std::enable_if_t<std::is_base_of<T, U>::value>>
|
@@ -90,6 +127,22 @@ class BasicMember final : private MemberBase, private CheckingPolicy {
|
|
90
127
|
OtherCheckingPolicy>& other) {
|
91
128
|
return operator=(other.Get());
|
92
129
|
}
|
130
|
+
// Move assignment.
|
131
|
+
BasicMember& operator=(BasicMember&& other) noexcept {
|
132
|
+
operator=(other.Get());
|
133
|
+
other.Clear();
|
134
|
+
return *this;
|
135
|
+
}
|
136
|
+
// Heterogeneous move assignment.
|
137
|
+
template <typename U, typename OtherWeaknessTag, typename OtherBarrierPolicy,
|
138
|
+
typename OtherCheckingPolicy,
|
139
|
+
typename = std::enable_if_t<std::is_base_of<T, U>::value>>
|
140
|
+
BasicMember& operator=(BasicMember<U, OtherWeaknessTag, OtherBarrierPolicy,
|
141
|
+
OtherCheckingPolicy>&& other) noexcept {
|
142
|
+
operator=(other.Get());
|
143
|
+
other.Clear();
|
144
|
+
return *this;
|
145
|
+
}
|
93
146
|
// Assignment from Persistent.
|
94
147
|
template <typename U, typename PersistentWeaknessPolicy,
|
95
148
|
typename PersistentLocationPolicy,
|
@@ -126,7 +179,7 @@ class BasicMember final : private MemberBase, private CheckingPolicy {
|
|
126
179
|
}
|
127
180
|
|
128
181
|
explicit operator bool() const { return Get(); }
|
129
|
-
operator T*() const { return Get(); }
|
182
|
+
operator T*() const { return Get(); }
|
130
183
|
T* operator->() const { return Get(); }
|
131
184
|
T& operator*() const { return *Get(); }
|
132
185
|
|
@@ -135,7 +188,11 @@ class BasicMember final : private MemberBase, private CheckingPolicy {
|
|
135
188
|
// based on their actual types.
|
136
189
|
V8_CLANG_NO_SANITIZE("cfi-unrelated-cast") T* Get() const {
|
137
190
|
// Executed by the mutator, hence non atomic load.
|
138
|
-
|
191
|
+
//
|
192
|
+
// The const_cast below removes the constness from MemberBase storage. The
|
193
|
+
// following static_cast re-adds any constness if specified through the
|
194
|
+
// user-visible template parameter T.
|
195
|
+
return static_cast<T*>(const_cast<void*>(MemberBase::GetRaw()));
|
139
196
|
}
|
140
197
|
|
141
198
|
void Clear() { SetRawAtomic(nullptr); }
|
@@ -146,9 +203,13 @@ class BasicMember final : private MemberBase, private CheckingPolicy {
|
|
146
203
|
return result;
|
147
204
|
}
|
148
205
|
|
206
|
+
const T** GetSlotForTesting() const {
|
207
|
+
return reinterpret_cast<const T**>(GetRawSlot());
|
208
|
+
}
|
209
|
+
|
149
210
|
private:
|
150
|
-
T* GetRawAtomic() const {
|
151
|
-
return static_cast<T*>(MemberBase::GetRawAtomic());
|
211
|
+
const T* GetRawAtomic() const {
|
212
|
+
return static_cast<const T*>(MemberBase::GetRawAtomic());
|
152
213
|
}
|
153
214
|
|
154
215
|
void InitializingWriteBarrier() const {
|
@@ -160,26 +221,30 @@ class BasicMember final : private MemberBase, private CheckingPolicy {
|
|
160
221
|
|
161
222
|
void ClearFromGC() const { MemberBase::ClearFromGC(); }
|
162
223
|
|
224
|
+
T* GetFromGC() const { return Get(); }
|
225
|
+
|
163
226
|
friend class cppgc::Visitor;
|
227
|
+
template <typename U>
|
228
|
+
friend struct cppgc::TraceTrait;
|
164
229
|
};
|
165
230
|
|
166
231
|
template <typename T1, typename WeaknessTag1, typename WriteBarrierPolicy1,
|
167
232
|
typename CheckingPolicy1, typename T2, typename WeaknessTag2,
|
168
233
|
typename WriteBarrierPolicy2, typename CheckingPolicy2>
|
169
|
-
bool operator==(
|
170
|
-
|
171
|
-
|
172
|
-
|
234
|
+
bool operator==(const BasicMember<T1, WeaknessTag1, WriteBarrierPolicy1,
|
235
|
+
CheckingPolicy1>& member1,
|
236
|
+
const BasicMember<T2, WeaknessTag2, WriteBarrierPolicy2,
|
237
|
+
CheckingPolicy2>& member2) {
|
173
238
|
return member1.Get() == member2.Get();
|
174
239
|
}
|
175
240
|
|
176
241
|
template <typename T1, typename WeaknessTag1, typename WriteBarrierPolicy1,
|
177
242
|
typename CheckingPolicy1, typename T2, typename WeaknessTag2,
|
178
243
|
typename WriteBarrierPolicy2, typename CheckingPolicy2>
|
179
|
-
bool operator!=(
|
180
|
-
|
181
|
-
|
182
|
-
|
244
|
+
bool operator!=(const BasicMember<T1, WeaknessTag1, WriteBarrierPolicy1,
|
245
|
+
CheckingPolicy1>& member1,
|
246
|
+
const BasicMember<T2, WeaknessTag2, WriteBarrierPolicy2,
|
247
|
+
CheckingPolicy2>& member2) {
|
183
248
|
return !(member1 == member2);
|
184
249
|
}
|
185
250
|
|
@@ -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_
|
@@ -9,6 +9,7 @@
|
|
9
9
|
|
10
10
|
#include "cppgc/internal/persistent-node.h"
|
11
11
|
#include "cppgc/internal/pointer-policies.h"
|
12
|
+
#include "cppgc/sentinel-pointer.h"
|
12
13
|
#include "cppgc/source-location.h"
|
13
14
|
#include "cppgc/type-traits.h"
|
14
15
|
#include "cppgc/visitor.h"
|
@@ -20,13 +21,15 @@ class Visitor;
|
|
20
21
|
|
21
22
|
namespace internal {
|
22
23
|
|
24
|
+
// PersistentBase always refers to the object as const object and defers to
|
25
|
+
// BasicPersistent on casting to the right type as needed.
|
23
26
|
class PersistentBase {
|
24
27
|
protected:
|
25
28
|
PersistentBase() = default;
|
26
|
-
explicit PersistentBase(void* raw) : raw_(raw) {}
|
29
|
+
explicit PersistentBase(const void* raw) : raw_(raw) {}
|
27
30
|
|
28
|
-
void* GetValue() const { return raw_; }
|
29
|
-
void SetValue(void* value) { raw_ = value; }
|
31
|
+
const void* GetValue() const { return raw_; }
|
32
|
+
void SetValue(const void* value) { raw_ = value; }
|
30
33
|
|
31
34
|
PersistentNode* GetNode() const { return node_; }
|
32
35
|
void SetNode(PersistentNode* node) { node_ = node; }
|
@@ -38,11 +41,11 @@ class PersistentBase {
|
|
38
41
|
node_ = nullptr;
|
39
42
|
}
|
40
43
|
|
41
|
-
|
42
|
-
mutable void* raw_ = nullptr;
|
44
|
+
protected:
|
45
|
+
mutable const void* raw_ = nullptr;
|
43
46
|
mutable PersistentNode* node_ = nullptr;
|
44
47
|
|
45
|
-
friend class
|
48
|
+
friend class PersistentRegionBase;
|
46
49
|
};
|
47
50
|
|
48
51
|
// The basic class from which all Persistent classes are generated.
|
@@ -92,7 +95,7 @@ class BasicPersistent final : public PersistentBase,
|
|
92
95
|
template <typename U, typename OtherWeaknessPolicy,
|
93
96
|
typename OtherLocationPolicy, typename OtherCheckingPolicy,
|
94
97
|
typename = std::enable_if_t<std::is_base_of<T, U>::value>>
|
95
|
-
BasicPersistent(
|
98
|
+
BasicPersistent(
|
96
99
|
const BasicPersistent<U, OtherWeaknessPolicy, OtherLocationPolicy,
|
97
100
|
OtherCheckingPolicy>& other,
|
98
101
|
const SourceLocation& loc = SourceLocation::Current())
|
@@ -115,10 +118,10 @@ class BasicPersistent final : public PersistentBase,
|
|
115
118
|
template <typename U, typename MemberBarrierPolicy,
|
116
119
|
typename MemberWeaknessTag, typename MemberCheckingPolicy,
|
117
120
|
typename = std::enable_if_t<std::is_base_of<T, U>::value>>
|
118
|
-
BasicPersistent(
|
119
|
-
|
120
|
-
|
121
|
-
|
121
|
+
BasicPersistent(
|
122
|
+
const internal::BasicMember<U, MemberBarrierPolicy, MemberWeaknessTag,
|
123
|
+
MemberCheckingPolicy>& member,
|
124
|
+
const SourceLocation& loc = SourceLocation::Current())
|
122
125
|
: BasicPersistent(member.Get(), loc) {}
|
123
126
|
|
124
127
|
~BasicPersistent() { Clear(); }
|
@@ -138,7 +141,7 @@ class BasicPersistent final : public PersistentBase,
|
|
138
141
|
}
|
139
142
|
|
140
143
|
// Move assignment.
|
141
|
-
BasicPersistent& operator=(BasicPersistent&& other) {
|
144
|
+
BasicPersistent& operator=(BasicPersistent&& other) noexcept {
|
142
145
|
if (this == &other) return *this;
|
143
146
|
Clear();
|
144
147
|
PersistentBase::operator=(std::move(other));
|
@@ -156,9 +159,8 @@ class BasicPersistent final : public PersistentBase,
|
|
156
159
|
typename MemberWeaknessTag, typename MemberCheckingPolicy,
|
157
160
|
typename = std::enable_if_t<std::is_base_of<T, U>::value>>
|
158
161
|
BasicPersistent& operator=(
|
159
|
-
internal::BasicMember<U, MemberBarrierPolicy, MemberWeaknessTag,
|
160
|
-
|
161
|
-
member) {
|
162
|
+
const internal::BasicMember<U, MemberBarrierPolicy, MemberWeaknessTag,
|
163
|
+
MemberCheckingPolicy>& member) {
|
162
164
|
return operator=(member.Get());
|
163
165
|
}
|
164
166
|
|
@@ -186,10 +188,21 @@ class BasicPersistent final : public PersistentBase,
|
|
186
188
|
// heterogeneous assignments between different Member and Persistent handles
|
187
189
|
// based on their actual types.
|
188
190
|
V8_CLANG_NO_SANITIZE("cfi-unrelated-cast") T* Get() const {
|
189
|
-
|
191
|
+
// The const_cast below removes the constness from PersistentBase storage.
|
192
|
+
// The following static_cast re-adds any constness if specified through the
|
193
|
+
// user-visible template parameter T.
|
194
|
+
return static_cast<T*>(const_cast<void*>(GetValue()));
|
190
195
|
}
|
191
196
|
|
192
|
-
void Clear() {
|
197
|
+
void Clear() {
|
198
|
+
// Simplified version of `Assign()` to allow calling without a complete type
|
199
|
+
// `T`.
|
200
|
+
if (IsValid()) {
|
201
|
+
WeaknessPolicy::GetPersistentRegion(GetValue()).FreeNode(GetNode());
|
202
|
+
SetNode(nullptr);
|
203
|
+
}
|
204
|
+
SetValue(nullptr);
|
205
|
+
}
|
193
206
|
|
194
207
|
T* Release() {
|
195
208
|
T* result = Get();
|
@@ -197,6 +210,16 @@ class BasicPersistent final : public PersistentBase,
|
|
197
210
|
return result;
|
198
211
|
}
|
199
212
|
|
213
|
+
template <typename U, typename OtherWeaknessPolicy = WeaknessPolicy,
|
214
|
+
typename OtherLocationPolicy = LocationPolicy,
|
215
|
+
typename OtherCheckingPolicy = CheckingPolicy>
|
216
|
+
BasicPersistent<U, OtherWeaknessPolicy, OtherLocationPolicy,
|
217
|
+
OtherCheckingPolicy>
|
218
|
+
To() const {
|
219
|
+
return BasicPersistent<U, OtherWeaknessPolicy, OtherLocationPolicy,
|
220
|
+
OtherCheckingPolicy>(static_cast<U*>(Get()));
|
221
|
+
}
|
222
|
+
|
200
223
|
private:
|
201
224
|
static void Trace(Visitor* v, const void* ptr) {
|
202
225
|
const auto* persistent = static_cast<const BasicPersistent*>(ptr);
|
@@ -235,6 +258,12 @@ class BasicPersistent final : public PersistentBase,
|
|
235
258
|
}
|
236
259
|
}
|
237
260
|
|
261
|
+
// Set Get() for details.
|
262
|
+
V8_CLANG_NO_SANITIZE("cfi-unrelated-cast")
|
263
|
+
T* GetFromGC() const {
|
264
|
+
return static_cast<T*>(const_cast<void*>(GetValue()));
|
265
|
+
}
|
266
|
+
|
238
267
|
friend class cppgc::Visitor;
|
239
268
|
};
|
240
269
|
|
@@ -262,12 +291,12 @@ template <typename T1, typename PersistentWeaknessPolicy,
|
|
262
291
|
typename PersistentLocationPolicy, typename PersistentCheckingPolicy,
|
263
292
|
typename T2, typename MemberWriteBarrierPolicy,
|
264
293
|
typename MemberWeaknessTag, typename MemberCheckingPolicy>
|
265
|
-
bool operator==(
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
294
|
+
bool operator==(
|
295
|
+
const BasicPersistent<T1, PersistentWeaknessPolicy,
|
296
|
+
PersistentLocationPolicy, PersistentCheckingPolicy>&
|
297
|
+
p,
|
298
|
+
const BasicMember<T2, MemberWeaknessTag, MemberWriteBarrierPolicy,
|
299
|
+
MemberCheckingPolicy>& m) {
|
271
300
|
return p.Get() == m.Get();
|
272
301
|
}
|
273
302
|
|
@@ -275,12 +304,12 @@ template <typename T1, typename PersistentWeaknessPolicy,
|
|
275
304
|
typename PersistentLocationPolicy, typename PersistentCheckingPolicy,
|
276
305
|
typename T2, typename MemberWriteBarrierPolicy,
|
277
306
|
typename MemberWeaknessTag, typename MemberCheckingPolicy>
|
278
|
-
bool operator!=(
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
307
|
+
bool operator!=(
|
308
|
+
const BasicPersistent<T1, PersistentWeaknessPolicy,
|
309
|
+
PersistentLocationPolicy, PersistentCheckingPolicy>&
|
310
|
+
p,
|
311
|
+
const BasicMember<T2, MemberWeaknessTag, MemberWriteBarrierPolicy,
|
312
|
+
MemberCheckingPolicy>& m) {
|
284
313
|
return !(p == m);
|
285
314
|
}
|
286
315
|
|
@@ -288,12 +317,12 @@ template <typename T1, typename MemberWriteBarrierPolicy,
|
|
288
317
|
typename MemberWeaknessTag, typename MemberCheckingPolicy,
|
289
318
|
typename T2, typename PersistentWeaknessPolicy,
|
290
319
|
typename PersistentLocationPolicy, typename PersistentCheckingPolicy>
|
291
|
-
bool operator==(
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
320
|
+
bool operator==(
|
321
|
+
const BasicMember<T2, MemberWeaknessTag, MemberWriteBarrierPolicy,
|
322
|
+
MemberCheckingPolicy>& m,
|
323
|
+
const BasicPersistent<T1, PersistentWeaknessPolicy,
|
324
|
+
PersistentLocationPolicy, PersistentCheckingPolicy>&
|
325
|
+
p) {
|
297
326
|
return m.Get() == p.Get();
|
298
327
|
}
|
299
328
|
|
@@ -301,12 +330,12 @@ template <typename T1, typename MemberWriteBarrierPolicy,
|
|
301
330
|
typename MemberWeaknessTag, typename MemberCheckingPolicy,
|
302
331
|
typename T2, typename PersistentWeaknessPolicy,
|
303
332
|
typename PersistentLocationPolicy, typename PersistentCheckingPolicy>
|
304
|
-
bool operator!=(
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
333
|
+
bool operator!=(
|
334
|
+
const BasicMember<T2, MemberWeaknessTag, MemberWriteBarrierPolicy,
|
335
|
+
MemberCheckingPolicy>& m,
|
336
|
+
const BasicPersistent<T1, PersistentWeaknessPolicy,
|
337
|
+
PersistentLocationPolicy, PersistentCheckingPolicy>&
|
338
|
+
p) {
|
310
339
|
return !(m == p);
|
311
340
|
}
|
312
341
|
|