libv8-node 23.6.1.0-arm64-darwin → 24.1.0.0-arm64-darwin
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/libv8/node/version.rb +3 -3
- data/vendor/v8/arm64-darwin/libv8/obj/libv8_monolith.a +0 -0
- data/vendor/v8/include/cppgc/allocation.h +1 -2
- data/vendor/v8/include/cppgc/default-platform.h +3 -2
- data/vendor/v8/include/cppgc/heap-consistency.h +1 -1
- data/vendor/v8/include/cppgc/internal/api-constants.h +0 -17
- data/vendor/v8/include/cppgc/internal/base-page-handle.h +2 -4
- data/vendor/v8/include/cppgc/internal/caged-heap-local-data.h +0 -4
- data/vendor/v8/include/cppgc/internal/caged-heap.h +0 -4
- data/vendor/v8/include/cppgc/internal/conditional-stack-allocated.h +41 -0
- data/vendor/v8/include/cppgc/internal/logging.h +3 -3
- data/vendor/v8/include/cppgc/internal/member-storage.h +63 -20
- data/vendor/v8/include/cppgc/internal/persistent-node.h +8 -3
- data/vendor/v8/include/cppgc/internal/pointer-policies.h +48 -11
- data/vendor/v8/include/cppgc/macros.h +21 -0
- data/vendor/v8/include/cppgc/member.h +70 -36
- data/vendor/v8/include/cppgc/name-provider.h +3 -0
- data/vendor/v8/include/cppgc/platform.h +11 -0
- data/vendor/v8/include/cppgc/type-traits.h +1 -0
- data/vendor/v8/include/cppgc/visitor.h +25 -1
- data/vendor/v8/include/libplatform/libplatform-export.h +2 -2
- data/vendor/v8/include/libplatform/v8-tracing.h +0 -1
- data/vendor/v8/include/v8-array-buffer.h +111 -34
- data/vendor/v8/include/v8-callbacks.h +84 -26
- data/vendor/v8/include/v8-context.h +7 -6
- data/vendor/v8/include/v8-cppgc.h +2 -1
- data/vendor/v8/include/v8-data.h +5 -0
- data/vendor/v8/include/v8-debug.h +11 -0
- data/vendor/v8/include/v8-embedder-heap.h +1 -32
- data/vendor/v8/include/v8-exception.h +2 -0
- data/vendor/v8/include/v8-external-memory-accounter.h +60 -0
- data/vendor/v8/include/v8-fast-api-calls.h +17 -175
- data/vendor/v8/include/v8-function-callback.h +4 -33
- data/vendor/v8/include/v8-function.h +7 -0
- data/vendor/v8/include/v8-handle-base.h +18 -0
- data/vendor/v8/include/v8-initialization.h +9 -1
- data/vendor/v8/include/v8-inspector.h +8 -4
- data/vendor/v8/include/v8-internal.h +477 -399
- data/vendor/v8/include/v8-isolate.h +218 -151
- data/vendor/v8/include/v8-local-handle.h +56 -28
- data/vendor/v8/include/v8-maybe.h +2 -1
- data/vendor/v8/include/v8-memory-span.h +149 -24
- data/vendor/v8/include/v8-message.h +9 -1
- data/vendor/v8/include/v8-metrics.h +10 -0
- data/vendor/v8/include/v8-object.h +7 -2
- data/vendor/v8/include/v8-persistent-handle.h +17 -17
- data/vendor/v8/include/v8-platform.h +48 -13
- data/vendor/v8/include/v8-primitive.h +131 -6
- data/vendor/v8/include/v8-profiler.h +13 -1
- data/vendor/v8/include/v8-proxy.h +0 -1
- data/vendor/v8/include/v8-regexp.h +0 -1
- data/vendor/v8/include/v8-sandbox.h +3 -3
- data/vendor/v8/include/v8-script.h +21 -3
- data/vendor/v8/include/v8-source-location.h +6 -1
- data/vendor/v8/include/v8-template.h +8 -2
- data/vendor/v8/include/v8-trace-categories.h +23 -0
- data/vendor/v8/include/v8-traced-handle.h +16 -17
- data/vendor/v8/include/v8-typed-array.h +6 -10
- data/vendor/v8/include/v8-unwinder-state.h +2 -3
- data/vendor/v8/include/v8-value-serializer-version.h +3 -3
- data/vendor/v8/include/v8-value.h +18 -0
- data/vendor/v8/include/v8-version.h +4 -4
- data/vendor/v8/include/v8-wasm.h +24 -0
- data/vendor/v8/include/v8-weak-callback-info.h +20 -12
- data/vendor/v8/include/v8.h +3 -3
- data/vendor/v8/include/v8config.h +34 -40
- metadata +6 -7
- data/vendor/v8/include/cppgc/ephemeron-pair.h +0 -30
@@ -38,9 +38,8 @@ class V8_TRIVIAL_ABI MemberBase {
|
|
38
38
|
|
39
39
|
V8_INLINE MemberBase() = default;
|
40
40
|
V8_INLINE explicit MemberBase(const void* value) : raw_(value) {}
|
41
|
-
V8_INLINE MemberBase(const void* value, AtomicInitializerTag)
|
42
|
-
|
43
|
-
}
|
41
|
+
V8_INLINE MemberBase(const void* value, AtomicInitializerTag)
|
42
|
+
: raw_(value, typename RawStorage::AtomicInitializerTag{}) {}
|
44
43
|
|
45
44
|
V8_INLINE explicit MemberBase(RawStorage raw) : raw_(raw) {}
|
46
45
|
V8_INLINE explicit MemberBase(std::nullptr_t) : raw_(nullptr) {}
|
@@ -87,7 +86,7 @@ class V8_TRIVIAL_ABI BasicMember final : private MemberBase<StorageType>,
|
|
87
86
|
V8_INLINE BasicMember(SentinelPointer s) : Base(s) {} // NOLINT
|
88
87
|
V8_INLINE BasicMember(T* raw) : Base(raw) { // NOLINT
|
89
88
|
InitializingWriteBarrier(raw);
|
90
|
-
|
89
|
+
CheckPointer(raw);
|
91
90
|
}
|
92
91
|
V8_INLINE BasicMember(T& raw) // NOLINT
|
93
92
|
: BasicMember(&raw) {}
|
@@ -103,7 +102,7 @@ class V8_TRIVIAL_ABI BasicMember final : private MemberBase<StorageType>,
|
|
103
102
|
V8_INLINE BasicMember(T* raw, AtomicInitializerTag atomic)
|
104
103
|
: Base(raw, atomic) {
|
105
104
|
InitializingWriteBarrier(raw);
|
106
|
-
|
105
|
+
CheckPointer(raw);
|
107
106
|
}
|
108
107
|
V8_INLINE BasicMember(T& raw, AtomicInitializerTag atomic)
|
109
108
|
: BasicMember(&raw, atomic) {}
|
@@ -117,7 +116,7 @@ class V8_TRIVIAL_ABI BasicMember final : private MemberBase<StorageType>,
|
|
117
116
|
// need to be adjusted.
|
118
117
|
template <typename U, typename OtherBarrierPolicy, typename OtherWeaknessTag,
|
119
118
|
typename OtherCheckingPolicy,
|
120
|
-
std::enable_if_t<
|
119
|
+
std::enable_if_t<IsDecayedSameV<T, U>>* = nullptr>
|
121
120
|
V8_INLINE BasicMember( // NOLINT
|
122
121
|
const BasicMember<U, OtherWeaknessTag, OtherBarrierPolicy,
|
123
122
|
OtherCheckingPolicy, StorageType>& other)
|
@@ -125,7 +124,7 @@ class V8_TRIVIAL_ABI BasicMember final : private MemberBase<StorageType>,
|
|
125
124
|
|
126
125
|
template <typename U, typename OtherBarrierPolicy, typename OtherWeaknessTag,
|
127
126
|
typename OtherCheckingPolicy,
|
128
|
-
std::enable_if_t<
|
127
|
+
std::enable_if_t<IsStrictlyBaseOfV<T, U>>* = nullptr>
|
129
128
|
V8_INLINE BasicMember( // NOLINT
|
130
129
|
const BasicMember<U, OtherWeaknessTag, OtherBarrierPolicy,
|
131
130
|
OtherCheckingPolicy, StorageType>& other)
|
@@ -142,7 +141,7 @@ class V8_TRIVIAL_ABI BasicMember final : private MemberBase<StorageType>,
|
|
142
141
|
// need to be adjusted.
|
143
142
|
template <typename U, typename OtherBarrierPolicy, typename OtherWeaknessTag,
|
144
143
|
typename OtherCheckingPolicy,
|
145
|
-
std::enable_if_t<
|
144
|
+
std::enable_if_t<IsDecayedSameV<T, U>>* = nullptr>
|
146
145
|
V8_INLINE BasicMember(
|
147
146
|
BasicMember<U, OtherWeaknessTag, OtherBarrierPolicy, OtherCheckingPolicy,
|
148
147
|
StorageType>&& other) noexcept
|
@@ -152,7 +151,7 @@ class V8_TRIVIAL_ABI BasicMember final : private MemberBase<StorageType>,
|
|
152
151
|
|
153
152
|
template <typename U, typename OtherBarrierPolicy, typename OtherWeaknessTag,
|
154
153
|
typename OtherCheckingPolicy,
|
155
|
-
std::enable_if_t<
|
154
|
+
std::enable_if_t<IsStrictlyBaseOfV<T, U>>* = nullptr>
|
156
155
|
V8_INLINE BasicMember(
|
157
156
|
BasicMember<U, OtherWeaknessTag, OtherBarrierPolicy, OtherCheckingPolicy,
|
158
157
|
StorageType>&& other) noexcept
|
@@ -183,10 +182,10 @@ class V8_TRIVIAL_ABI BasicMember final : private MemberBase<StorageType>,
|
|
183
182
|
V8_INLINE BasicMember& operator=(
|
184
183
|
const BasicMember<U, OtherWeaknessTag, OtherBarrierPolicy,
|
185
184
|
OtherCheckingPolicy, StorageType>& other) {
|
186
|
-
if constexpr (
|
185
|
+
if constexpr (IsDecayedSameV<T, U>) {
|
187
186
|
return operator=(other.GetRawStorage());
|
188
187
|
} else {
|
189
|
-
static_assert(
|
188
|
+
static_assert(IsStrictlyBaseOfV<T, U>);
|
190
189
|
return operator=(other.Get());
|
191
190
|
}
|
192
191
|
}
|
@@ -206,10 +205,10 @@ class V8_TRIVIAL_ABI BasicMember final : private MemberBase<StorageType>,
|
|
206
205
|
V8_INLINE BasicMember& operator=(
|
207
206
|
BasicMember<U, OtherWeaknessTag, OtherBarrierPolicy, OtherCheckingPolicy,
|
208
207
|
StorageType>&& other) noexcept {
|
209
|
-
if constexpr (
|
208
|
+
if constexpr (IsDecayedSameV<T, U>) {
|
210
209
|
operator=(other.GetRawStorage());
|
211
210
|
} else {
|
212
|
-
static_assert(
|
211
|
+
static_assert(IsStrictlyBaseOfV<T, U>);
|
213
212
|
operator=(other.Get());
|
214
213
|
}
|
215
214
|
other.Clear();
|
@@ -231,7 +230,7 @@ class V8_TRIVIAL_ABI BasicMember final : private MemberBase<StorageType>,
|
|
231
230
|
V8_INLINE BasicMember& operator=(T* other) {
|
232
231
|
Base::SetRawAtomic(other);
|
233
232
|
AssigningWriteBarrier(other);
|
234
|
-
|
233
|
+
CheckPointer(other);
|
235
234
|
return *this;
|
236
235
|
}
|
237
236
|
|
@@ -270,9 +269,7 @@ class V8_TRIVIAL_ABI BasicMember final : private MemberBase<StorageType>,
|
|
270
269
|
return static_cast<T*>(const_cast<void*>(Base::GetRaw()));
|
271
270
|
}
|
272
271
|
|
273
|
-
V8_INLINE void Clear() {
|
274
|
-
Base::SetRawStorageAtomic(RawStorage{});
|
275
|
-
}
|
272
|
+
V8_INLINE void Clear() { Base::SetRawStorageAtomic(RawStorage{}); }
|
276
273
|
|
277
274
|
V8_INLINE T* Release() {
|
278
275
|
T* result = Get();
|
@@ -284,20 +281,18 @@ class V8_TRIVIAL_ABI BasicMember final : private MemberBase<StorageType>,
|
|
284
281
|
return reinterpret_cast<const T**>(Base::GetRawSlot());
|
285
282
|
}
|
286
283
|
|
287
|
-
V8_INLINE RawStorage GetRawStorage() const {
|
288
|
-
return Base::GetRawStorage();
|
289
|
-
}
|
284
|
+
V8_INLINE RawStorage GetRawStorage() const { return Base::GetRawStorage(); }
|
290
285
|
|
291
286
|
private:
|
292
287
|
V8_INLINE explicit BasicMember(RawStorage raw) : Base(raw) {
|
293
|
-
InitializingWriteBarrier(
|
294
|
-
|
288
|
+
InitializingWriteBarrier();
|
289
|
+
CheckPointer();
|
295
290
|
}
|
296
291
|
|
297
292
|
V8_INLINE BasicMember& operator=(RawStorage other) {
|
298
293
|
Base::SetRawStorageAtomic(other);
|
299
294
|
AssigningWriteBarrier();
|
300
|
-
|
295
|
+
CheckPointer();
|
301
296
|
return *this;
|
302
297
|
}
|
303
298
|
|
@@ -308,6 +303,10 @@ class V8_TRIVIAL_ABI BasicMember final : private MemberBase<StorageType>,
|
|
308
303
|
V8_INLINE void InitializingWriteBarrier(T* value) const {
|
309
304
|
WriteBarrierPolicy::InitializingBarrier(Base::GetRawSlot(), value);
|
310
305
|
}
|
306
|
+
V8_INLINE void InitializingWriteBarrier() const {
|
307
|
+
WriteBarrierPolicy::InitializingBarrier(Base::GetRawSlot(),
|
308
|
+
Base::GetRawStorage());
|
309
|
+
}
|
311
310
|
V8_INLINE void AssigningWriteBarrier(T* value) const {
|
312
311
|
WriteBarrierPolicy::template AssigningBarrier<
|
313
312
|
StorageType::kWriteBarrierSlotType>(Base::GetRawSlot(), value);
|
@@ -317,6 +316,12 @@ class V8_TRIVIAL_ABI BasicMember final : private MemberBase<StorageType>,
|
|
317
316
|
StorageType::kWriteBarrierSlotType>(Base::GetRawSlot(),
|
318
317
|
Base::GetRawStorage());
|
319
318
|
}
|
319
|
+
V8_INLINE void CheckPointer(T* value) {
|
320
|
+
CheckingPolicy::template CheckPointer<T>(value);
|
321
|
+
}
|
322
|
+
V8_INLINE void CheckPointer() {
|
323
|
+
CheckingPolicy::template CheckPointer<T>(Base::GetRawStorage());
|
324
|
+
}
|
320
325
|
|
321
326
|
V8_INLINE void ClearFromGC() const { Base::ClearFromGC(); }
|
322
327
|
|
@@ -341,12 +346,11 @@ V8_INLINE bool operator==(
|
|
341
346
|
StorageType>& member1,
|
342
347
|
const BasicMember<T2, WeaknessTag2, WriteBarrierPolicy2, CheckingPolicy2,
|
343
348
|
StorageType>& member2) {
|
344
|
-
if constexpr (
|
349
|
+
if constexpr (IsDecayedSameV<T1, T2>) {
|
345
350
|
// Check compressed pointers if types are the same.
|
346
351
|
return member1.GetRawStorage() == member2.GetRawStorage();
|
347
352
|
} else {
|
348
|
-
static_assert(
|
349
|
-
internal::IsStrictlyBaseOfV<T2, T1>);
|
353
|
+
static_assert(IsStrictlyBaseOfV<T1, T2> || IsStrictlyBaseOfV<T2, T1>);
|
350
354
|
// Otherwise, check decompressed pointers.
|
351
355
|
return member1.Get() == member2.Get();
|
352
356
|
}
|
@@ -372,12 +376,12 @@ V8_INLINE bool operator==(
|
|
372
376
|
StorageType>& member,
|
373
377
|
U* raw) {
|
374
378
|
// Never allow comparison with erased pointers.
|
375
|
-
static_assert(!
|
379
|
+
static_assert(!IsDecayedSameV<void, U>);
|
376
380
|
|
377
|
-
if constexpr (
|
381
|
+
if constexpr (IsDecayedSameV<T, U>) {
|
378
382
|
// Check compressed pointers if types are the same.
|
379
383
|
return member.GetRawStorage() == StorageType(raw);
|
380
|
-
} else if constexpr (
|
384
|
+
} else if constexpr (IsStrictlyBaseOfV<T, U>) {
|
381
385
|
// Cast the raw pointer to T, which may adjust the pointer.
|
382
386
|
return member.GetRawStorage() == StorageType(static_cast<T*>(raw));
|
383
387
|
} else {
|
@@ -494,7 +498,7 @@ V8_INLINE bool operator<(
|
|
494
498
|
const BasicMember<T2, WeaknessTag2, WriteBarrierPolicy2, CheckingPolicy2,
|
495
499
|
StorageType>& member2) {
|
496
500
|
static_assert(
|
497
|
-
|
501
|
+
IsDecayedSameV<T1, T2>,
|
498
502
|
"Comparison works only for same pointer type modulo cv-qualifiers");
|
499
503
|
return member1.GetRawStorage() < member2.GetRawStorage();
|
500
504
|
}
|
@@ -509,7 +513,7 @@ V8_INLINE bool operator<=(
|
|
509
513
|
const BasicMember<T2, WeaknessTag2, WriteBarrierPolicy2, CheckingPolicy2,
|
510
514
|
StorageType>& member2) {
|
511
515
|
static_assert(
|
512
|
-
|
516
|
+
IsDecayedSameV<T1, T2>,
|
513
517
|
"Comparison works only for same pointer type modulo cv-qualifiers");
|
514
518
|
return member1.GetRawStorage() <= member2.GetRawStorage();
|
515
519
|
}
|
@@ -524,7 +528,7 @@ V8_INLINE bool operator>(
|
|
524
528
|
const BasicMember<T2, WeaknessTag2, WriteBarrierPolicy2, CheckingPolicy2,
|
525
529
|
StorageType>& member2) {
|
526
530
|
static_assert(
|
527
|
-
|
531
|
+
IsDecayedSameV<T1, T2>,
|
528
532
|
"Comparison works only for same pointer type modulo cv-qualifiers");
|
529
533
|
return member1.GetRawStorage() > member2.GetRawStorage();
|
530
534
|
}
|
@@ -539,16 +543,15 @@ V8_INLINE bool operator>=(
|
|
539
543
|
const BasicMember<T2, WeaknessTag2, WriteBarrierPolicy2, CheckingPolicy2,
|
540
544
|
StorageType>& member2) {
|
541
545
|
static_assert(
|
542
|
-
|
546
|
+
IsDecayedSameV<T1, T2>,
|
543
547
|
"Comparison works only for same pointer type modulo cv-qualifiers");
|
544
548
|
return member1.GetRawStorage() >= member2.GetRawStorage();
|
545
549
|
}
|
546
550
|
|
547
551
|
template <typename T, typename WriteBarrierPolicy, typename CheckingPolicy,
|
548
552
|
typename StorageType>
|
549
|
-
struct IsWeak<
|
550
|
-
|
551
|
-
: std::true_type {};
|
553
|
+
struct IsWeak<BasicMember<T, WeakMemberTag, WriteBarrierPolicy, CheckingPolicy,
|
554
|
+
StorageType>> : std::true_type {};
|
552
555
|
|
553
556
|
} // namespace internal
|
554
557
|
|
@@ -626,4 +629,35 @@ static constexpr size_t kSizeofCompressedMember =
|
|
626
629
|
|
627
630
|
} // namespace cppgc
|
628
631
|
|
632
|
+
// Mark `BasicMember<T>` and `T*` as having a common reference type of `T*` (the
|
633
|
+
// type to which both can be converted or bound). This makes them satisfy
|
634
|
+
// `std::equality_comparable`, which allows usage like the following:
|
635
|
+
// ```
|
636
|
+
// HeapVector<Member<T>> v;
|
637
|
+
// T* e;
|
638
|
+
// auto it = std::ranges::find(v, e);
|
639
|
+
// ```
|
640
|
+
// Without this, the `find()` call above would fail to compile with an error
|
641
|
+
// about being unable to invoke `std::ranges::equal_to()`.
|
642
|
+
template <typename T, typename WeaknessTag, typename WriteBarrierPolicy,
|
643
|
+
typename CheckingPolicy, typename StorageType,
|
644
|
+
template <typename> typename TQ, template <typename> typename UQ>
|
645
|
+
struct std::basic_common_reference<
|
646
|
+
cppgc::internal::BasicMember<T, WeaknessTag, WriteBarrierPolicy,
|
647
|
+
CheckingPolicy, StorageType>,
|
648
|
+
T*, TQ, UQ> {
|
649
|
+
using type = T*;
|
650
|
+
};
|
651
|
+
|
652
|
+
template <typename T, typename WeaknessTag, typename WriteBarrierPolicy,
|
653
|
+
typename CheckingPolicy, typename StorageType,
|
654
|
+
template <typename> typename TQ, template <typename> typename UQ>
|
655
|
+
struct std::basic_common_reference<
|
656
|
+
T*,
|
657
|
+
cppgc::internal::BasicMember<T, WeaknessTag, WriteBarrierPolicy,
|
658
|
+
CheckingPolicy, StorageType>,
|
659
|
+
TQ, UQ> {
|
660
|
+
using type = T*;
|
661
|
+
};
|
662
|
+
|
629
663
|
#endif // INCLUDE_CPPGC_MEMBER_H_
|
@@ -55,6 +55,9 @@ class V8_EXPORT NameProvider {
|
|
55
55
|
* Specifies a name for the garbage-collected object. Such names will never
|
56
56
|
* be hidden, as they are explicitly specified by the user of this API.
|
57
57
|
*
|
58
|
+
* Implementations of this function must not allocate garbage-collected
|
59
|
+
* objects or otherwise modify the cppgc heap.
|
60
|
+
*
|
58
61
|
* V8 may call this function while generating a heap snapshot or at other
|
59
62
|
* times. If V8 is currently generating a heap snapshot (according to
|
60
63
|
* HeapProfiler::IsTakingSnapshot), then the returned string must stay alive
|
@@ -52,6 +52,15 @@ class V8_EXPORT Platform {
|
|
52
52
|
* Foreground task runner that should be used by a Heap.
|
53
53
|
*/
|
54
54
|
virtual std::shared_ptr<TaskRunner> GetForegroundTaskRunner() {
|
55
|
+
return GetForegroundTaskRunner(TaskPriority::kUserBlocking);
|
56
|
+
}
|
57
|
+
|
58
|
+
/**
|
59
|
+
* Returns a TaskRunner with a specific |priority| which can be used to post a
|
60
|
+
* task on the foreground thread.
|
61
|
+
*/
|
62
|
+
virtual std::shared_ptr<TaskRunner> GetForegroundTaskRunner(
|
63
|
+
TaskPriority priority) {
|
55
64
|
return nullptr;
|
56
65
|
}
|
57
66
|
|
@@ -127,6 +136,8 @@ class V8_EXPORT Platform {
|
|
127
136
|
virtual TracingController* GetTracingController();
|
128
137
|
};
|
129
138
|
|
139
|
+
V8_EXPORT bool IsInitialized();
|
140
|
+
|
130
141
|
/**
|
131
142
|
* Process-global initialization of the garbage collector. Must be called before
|
132
143
|
* creating a Heap.
|
@@ -8,12 +8,12 @@
|
|
8
8
|
#include <type_traits>
|
9
9
|
|
10
10
|
#include "cppgc/custom-space.h"
|
11
|
-
#include "cppgc/ephemeron-pair.h"
|
12
11
|
#include "cppgc/garbage-collected.h"
|
13
12
|
#include "cppgc/internal/logging.h"
|
14
13
|
#include "cppgc/internal/member-storage.h"
|
15
14
|
#include "cppgc/internal/pointer-policies.h"
|
16
15
|
#include "cppgc/liveness-broker.h"
|
16
|
+
#include "cppgc/macros.h"
|
17
17
|
#include "cppgc/member.h"
|
18
18
|
#include "cppgc/sentinel-pointer.h"
|
19
19
|
#include "cppgc/source-location.h"
|
@@ -36,6 +36,25 @@ class VisitorFactory;
|
|
36
36
|
|
37
37
|
using WeakCallback = void (*)(const LivenessBroker&, const void*);
|
38
38
|
|
39
|
+
/**
|
40
|
+
* An ephemeron pair is used to conditionally retain an object.
|
41
|
+
* The `value` will be kept alive only if the `key` is alive.
|
42
|
+
*/
|
43
|
+
template <typename K, typename V>
|
44
|
+
struct EphemeronPair {
|
45
|
+
CPPGC_DISALLOW_NEW();
|
46
|
+
|
47
|
+
EphemeronPair(K* k, V* v) : key(k), value(v) {}
|
48
|
+
WeakMember<K> key;
|
49
|
+
Member<V> value;
|
50
|
+
|
51
|
+
void ClearValueIfKeyIsDead(const LivenessBroker& broker) {
|
52
|
+
if (!broker.IsHeapObjectAlive(key)) value = nullptr;
|
53
|
+
}
|
54
|
+
|
55
|
+
void Trace(Visitor* visitor) const;
|
56
|
+
};
|
57
|
+
|
39
58
|
/**
|
40
59
|
* Visitor passed to trace methods. All managed pointers must have called the
|
41
60
|
* Visitor's trace method on them.
|
@@ -436,6 +455,11 @@ class V8_EXPORT Visitor {
|
|
436
455
|
friend class internal::VisitorBase;
|
437
456
|
};
|
438
457
|
|
458
|
+
template <typename K, typename V>
|
459
|
+
void EphemeronPair<K, V>::Trace(Visitor* visitor) const {
|
460
|
+
visitor->TraceEphemeron(key, value);
|
461
|
+
}
|
462
|
+
|
439
463
|
namespace internal {
|
440
464
|
|
441
465
|
class V8_EXPORT RootVisitor {
|
@@ -18,11 +18,11 @@
|
|
18
18
|
#else // defined(_WIN32)
|
19
19
|
|
20
20
|
// Setup for Linux shared library export.
|
21
|
-
#
|
21
|
+
#if defined(BUILDING_V8_PLATFORM_SHARED) || USING_V8_PLATFORM_SHARED
|
22
22
|
#define V8_PLATFORM_EXPORT __attribute__((visibility("default")))
|
23
23
|
#else
|
24
24
|
#define V8_PLATFORM_EXPORT
|
25
|
-
#endif
|
25
|
+
#endif // defined(BUILDING_V8_PLATFORM_SHARED) || ...
|
26
26
|
|
27
27
|
#endif // defined(_WIN32)
|
28
28
|
|
@@ -10,13 +10,20 @@
|
|
10
10
|
#include <memory>
|
11
11
|
|
12
12
|
#include "v8-local-handle.h" // NOLINT(build/include_directory)
|
13
|
+
#include "v8-memory-span.h" // NOLINT(build/include_directory)
|
13
14
|
#include "v8-object.h" // NOLINT(build/include_directory)
|
15
|
+
#include "v8-platform.h" // NOLINT(build/include_directory)
|
14
16
|
#include "v8config.h" // NOLINT(build/include_directory)
|
15
17
|
|
16
18
|
namespace v8 {
|
17
19
|
|
18
20
|
class SharedArrayBuffer;
|
19
21
|
|
22
|
+
#if defined(V8_COMPRESS_POINTERS) && \
|
23
|
+
!defined(V8_COMPRESS_POINTERS_IN_SHARED_CAGE)
|
24
|
+
class IsolateGroup;
|
25
|
+
#endif
|
26
|
+
|
20
27
|
#ifndef V8_ARRAY_BUFFER_INTERNAL_FIELD_COUNT
|
21
28
|
// Defined using gn arg `v8_array_buffer_internal_field_count`.
|
22
29
|
#define V8_ARRAY_BUFFER_INTERNAL_FIELD_COUNT 2
|
@@ -24,6 +31,7 @@ class SharedArrayBuffer;
|
|
24
31
|
|
25
32
|
enum class ArrayBufferCreationMode { kInternalized, kExternalized };
|
26
33
|
enum class BackingStoreInitializationMode { kZeroInitialized, kUninitialized };
|
34
|
+
enum class BackingStoreOnFailureMode { kReturnNull, kOutOfMemory };
|
27
35
|
|
28
36
|
/**
|
29
37
|
* A wrapper around the backing store (i.e. the raw memory) of an array buffer.
|
@@ -83,18 +91,6 @@ class V8_EXPORT BackingStore : public v8::internal::BackingStoreBase {
|
|
83
91
|
*/
|
84
92
|
void operator delete(void* ptr) { ::operator delete(ptr); }
|
85
93
|
|
86
|
-
/**
|
87
|
-
* Wrapper around ArrayBuffer::Allocator::Reallocate that preserves IsShared.
|
88
|
-
* Assumes that the backing_store was allocated by the ArrayBuffer allocator
|
89
|
-
* of the given isolate.
|
90
|
-
*/
|
91
|
-
V8_DEPRECATED(
|
92
|
-
"Reallocate is unsafe, please do not use. Please allocate a new "
|
93
|
-
"BackingStore and copy instead.")
|
94
|
-
static std::unique_ptr<BackingStore> Reallocate(
|
95
|
-
v8::Isolate* isolate, std::unique_ptr<BackingStore> backing_store,
|
96
|
-
size_t byte_length);
|
97
|
-
|
98
94
|
/**
|
99
95
|
* This callback is used only if the memory block for a BackingStore cannot be
|
100
96
|
* allocated with an ArrayBuffer::Allocator. In such cases the destructor of
|
@@ -172,21 +168,13 @@ class V8_EXPORT ArrayBuffer : public Object {
|
|
172
168
|
virtual void Free(void* data, size_t length) = 0;
|
173
169
|
|
174
170
|
/**
|
175
|
-
*
|
176
|
-
*
|
177
|
-
*
|
178
|
-
*
|
179
|
-
*
|
180
|
-
*
|
181
|
-
* The caller guarantees that the memory block was previously allocated
|
182
|
-
* using Allocate or AllocateUninitialized.
|
183
|
-
*
|
184
|
-
* The default implementation allocates a new block and copies data.
|
171
|
+
* Returns a size_t that determines the largest ArrayBuffer that can be
|
172
|
+
* allocated. Override if your Allocator is more restrictive than the
|
173
|
+
* default. Will only be called once, and the value returned will be
|
174
|
+
* cached.
|
175
|
+
* Should not return a value that is larger than kMaxByteLength.
|
185
176
|
*/
|
186
|
-
|
187
|
-
"Reallocate is unsafe, please do not use. Please allocate new memory "
|
188
|
-
"and copy instead.")
|
189
|
-
virtual void* Reallocate(void* data, size_t old_length, size_t new_length);
|
177
|
+
virtual size_t MaxAllocationSize() const { return kMaxByteLength; }
|
190
178
|
|
191
179
|
/**
|
192
180
|
* ArrayBuffer allocation mode. kNormal is a malloc/free style allocation,
|
@@ -195,11 +183,37 @@ class V8_EXPORT ArrayBuffer : public Object {
|
|
195
183
|
*/
|
196
184
|
enum class AllocationMode { kNormal, kReservation };
|
197
185
|
|
186
|
+
/**
|
187
|
+
* Returns page allocator used by this Allocator instance.
|
188
|
+
*
|
189
|
+
* When the sandbox used by Allocator it is expected that this returns
|
190
|
+
* sandbox's page allocator.
|
191
|
+
* Otherwise, it should return system page allocator.
|
192
|
+
*/
|
193
|
+
virtual PageAllocator* GetPageAllocator() { return nullptr; }
|
194
|
+
|
195
|
+
#if defined(V8_COMPRESS_POINTERS) && \
|
196
|
+
!defined(V8_COMPRESS_POINTERS_IN_SHARED_CAGE)
|
198
197
|
/**
|
199
198
|
* Convenience allocator.
|
200
199
|
*
|
201
200
|
* When the sandbox is enabled, this allocator will allocate its backing
|
202
|
-
* memory inside the sandbox
|
201
|
+
* memory inside the sandbox that belongs to passed isolate group.
|
202
|
+
* Otherwise, it will rely on malloc/free.
|
203
|
+
*
|
204
|
+
* Caller takes ownership, i.e. the returned object needs to be freed using
|
205
|
+
* |delete allocator| once it is no longer in use.
|
206
|
+
*/
|
207
|
+
static Allocator* NewDefaultAllocator(const IsolateGroup& group);
|
208
|
+
#endif // defined(V8_COMPRESS_POINTERS) &&
|
209
|
+
// !defined(V8_COMPRESS_POINTERS_IN_SHARED_CAGE)
|
210
|
+
|
211
|
+
/**
|
212
|
+
* Convenience allocator.
|
213
|
+
*
|
214
|
+
* When the sandbox is enabled, this allocator will allocate its backing
|
215
|
+
* memory inside the default global sandbox. Otherwise, it will rely on
|
216
|
+
* malloc/free.
|
203
217
|
*
|
204
218
|
* Caller takes ownership, i.e. the returned object needs to be freed using
|
205
219
|
* |delete allocator| once it is no longer in use.
|
@@ -217,6 +231,18 @@ class V8_EXPORT ArrayBuffer : public Object {
|
|
217
231
|
*/
|
218
232
|
size_t MaxByteLength() const;
|
219
233
|
|
234
|
+
/**
|
235
|
+
* Attempt to create a new ArrayBuffer. Allocate |byte_length| bytes.
|
236
|
+
* Allocated memory will be owned by a created ArrayBuffer and
|
237
|
+
* will be deallocated when it is garbage-collected,
|
238
|
+
* unless the object is externalized. If allocation fails, the Maybe
|
239
|
+
* returned will be empty.
|
240
|
+
*/
|
241
|
+
static MaybeLocal<ArrayBuffer> MaybeNew(
|
242
|
+
Isolate* isolate, size_t byte_length,
|
243
|
+
BackingStoreInitializationMode initialization_mode =
|
244
|
+
BackingStoreInitializationMode::kZeroInitialized);
|
245
|
+
|
220
246
|
/**
|
221
247
|
* Create a new ArrayBuffer. Allocate |byte_length| bytes, which are either
|
222
248
|
* zero-initialized or uninitialized. Allocated memory will be owned by a
|
@@ -246,17 +272,25 @@ class V8_EXPORT ArrayBuffer : public Object {
|
|
246
272
|
/**
|
247
273
|
* Returns a new standalone BackingStore that is allocated using the array
|
248
274
|
* buffer allocator of the isolate. The allocation can either be zero
|
249
|
-
*
|
275
|
+
* initialized, or uninitialized. The result can be later passed to
|
250
276
|
* ArrayBuffer::New.
|
251
277
|
*
|
252
278
|
* If the allocator returns nullptr, then the function may cause GCs in the
|
253
|
-
* given isolate and re-try the allocation.
|
279
|
+
* given isolate and re-try the allocation.
|
280
|
+
*
|
281
|
+
* If GCs do not help and on_failure is kOutOfMemory, then the
|
254
282
|
* function will crash with an out-of-memory error.
|
283
|
+
*
|
284
|
+
* Otherwise if GCs do not help (or the allocation is too large for GCs to
|
285
|
+
* help) and on_failure is kReturnNull, then a null result is returned.
|
255
286
|
*/
|
256
287
|
static std::unique_ptr<BackingStore> NewBackingStore(
|
257
288
|
Isolate* isolate, size_t byte_length,
|
258
289
|
BackingStoreInitializationMode initialization_mode =
|
259
|
-
BackingStoreInitializationMode::kZeroInitialized
|
290
|
+
BackingStoreInitializationMode::kZeroInitialized,
|
291
|
+
BackingStoreOnFailureMode on_failure =
|
292
|
+
BackingStoreOnFailureMode::kOutOfMemory);
|
293
|
+
|
260
294
|
/**
|
261
295
|
* Returns a new standalone BackingStore that takes over the ownership of
|
262
296
|
* the given buffer. The destructor of the BackingStore invokes the given
|
@@ -354,9 +388,21 @@ class V8_EXPORT ArrayBuffer : public Object {
|
|
354
388
|
V8_ARRAY_BUFFER_INTERNAL_FIELD_COUNT;
|
355
389
|
static constexpr int kEmbedderFieldCount = kInternalFieldCount;
|
356
390
|
|
391
|
+
#if V8_ENABLE_SANDBOX
|
392
|
+
static constexpr size_t kMaxByteLength =
|
393
|
+
internal::kMaxSafeBufferSizeForSandbox;
|
394
|
+
#elif V8_HOST_ARCH_32_BIT
|
395
|
+
static constexpr size_t kMaxByteLength = std::numeric_limits<int>::max();
|
396
|
+
#else
|
397
|
+
// The maximum safe integer (2^53 - 1).
|
398
|
+
static constexpr size_t kMaxByteLength =
|
399
|
+
static_cast<size_t>((uint64_t{1} << 53) - 1);
|
400
|
+
#endif
|
401
|
+
|
357
402
|
private:
|
358
403
|
ArrayBuffer();
|
359
404
|
static void CheckCast(Value* obj);
|
405
|
+
friend class TypedArray;
|
360
406
|
};
|
361
407
|
|
362
408
|
#ifndef V8_ARRAY_BUFFER_VIEW_INTERNAL_FIELD_COUNT
|
@@ -394,6 +440,16 @@ class V8_EXPORT ArrayBufferView : public Object {
|
|
394
440
|
*/
|
395
441
|
size_t CopyContents(void* dest, size_t byte_length);
|
396
442
|
|
443
|
+
/**
|
444
|
+
* Returns the contents of the ArrayBufferView's buffer as a MemorySpan. If
|
445
|
+
* the contents are on the V8 heap, they get copied into `storage`. Otherwise
|
446
|
+
* a view into the off-heap backing store is returned. The provided storage
|
447
|
+
* should be at least as large as the maximum on-heap size of a TypedArray,
|
448
|
+
* was defined in gn with `typed_array_max_size_in_heap`. The default value is
|
449
|
+
* 64 bytes.
|
450
|
+
*/
|
451
|
+
v8::MemorySpan<uint8_t> GetContents(v8::MemorySpan<uint8_t> storage);
|
452
|
+
|
397
453
|
/**
|
398
454
|
* Returns true if ArrayBufferView's backing ArrayBuffer has already been
|
399
455
|
* allocated.
|
@@ -463,6 +519,18 @@ class V8_EXPORT SharedArrayBuffer : public Object {
|
|
463
519
|
BackingStoreInitializationMode initialization_mode =
|
464
520
|
BackingStoreInitializationMode::kZeroInitialized);
|
465
521
|
|
522
|
+
/**
|
523
|
+
* Create a new SharedArrayBuffer. Allocate |byte_length| bytes, which are
|
524
|
+
* either zero-initialized or uninitialized. Allocated memory will be owned by
|
525
|
+
* a created SharedArrayBuffer and will be deallocated when it is
|
526
|
+
* garbage-collected, unless the object is externalized. If allocation
|
527
|
+
* fails, the Maybe returned will be empty.
|
528
|
+
*/
|
529
|
+
static MaybeLocal<SharedArrayBuffer> MaybeNew(
|
530
|
+
Isolate* isolate, size_t byte_length,
|
531
|
+
BackingStoreInitializationMode initialization_mode =
|
532
|
+
BackingStoreInitializationMode::kZeroInitialized);
|
533
|
+
|
466
534
|
/**
|
467
535
|
* Create a new SharedArrayBuffer with an existing backing store.
|
468
536
|
* The created array keeps a reference to the backing store until the array
|
@@ -481,17 +549,26 @@ class V8_EXPORT SharedArrayBuffer : public Object {
|
|
481
549
|
/**
|
482
550
|
* Returns a new standalone BackingStore that is allocated using the array
|
483
551
|
* buffer allocator of the isolate. The allocation can either be zero
|
484
|
-
*
|
552
|
+
* initialized, or uninitialized. The result can be later passed to
|
485
553
|
* SharedArrayBuffer::New.
|
486
554
|
*
|
487
555
|
* If the allocator returns nullptr, then the function may cause GCs in the
|
488
|
-
* given isolate and re-try the allocation.
|
489
|
-
*
|
556
|
+
* given isolate and re-try the allocation.
|
557
|
+
*
|
558
|
+
* If on_failure is kOutOfMemory and GCs do not help, then the function will
|
559
|
+
* crash with an out-of-memory error.
|
560
|
+
*
|
561
|
+
* Otherwise, if on_failure is kReturnNull and GCs do not help (or the
|
562
|
+
* byte_length is so large that the allocation cannot succeed), then a null
|
563
|
+
* result is returned.
|
490
564
|
*/
|
491
565
|
static std::unique_ptr<BackingStore> NewBackingStore(
|
492
566
|
Isolate* isolate, size_t byte_length,
|
493
567
|
BackingStoreInitializationMode initialization_mode =
|
494
|
-
BackingStoreInitializationMode::kZeroInitialized
|
568
|
+
BackingStoreInitializationMode::kZeroInitialized,
|
569
|
+
BackingStoreOnFailureMode on_failure =
|
570
|
+
BackingStoreOnFailureMode::kOutOfMemory);
|
571
|
+
|
495
572
|
/**
|
496
573
|
* Returns a new standalone BackingStore that takes over the ownership of
|
497
574
|
* the given buffer. The destructor of the BackingStore invokes the given
|