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
@@ -179,8 +179,14 @@ class LocalBase : public api_internal::DirectHandleBase {
|
|
179
179
|
}
|
180
180
|
|
181
181
|
V8_INLINE static LocalBase<T> FromSlot(internal::Address* slot) {
|
182
|
+
if (slot == nullptr) return LocalBase<T>();
|
182
183
|
return LocalBase<T>(*slot);
|
183
184
|
}
|
185
|
+
|
186
|
+
V8_INLINE static LocalBase<T> FromRepr(
|
187
|
+
internal::ValueHelper::InternalRepresentationType repr) {
|
188
|
+
return LocalBase<T>(repr);
|
189
|
+
}
|
184
190
|
};
|
185
191
|
|
186
192
|
#else // !V8_ENABLE_DIRECT_HANDLE
|
@@ -213,6 +219,11 @@ class LocalBase : public api_internal::IndirectHandleBase {
|
|
213
219
|
V8_INLINE static LocalBase<T> FromSlot(internal::Address* slot) {
|
214
220
|
return LocalBase<T>(slot);
|
215
221
|
}
|
222
|
+
|
223
|
+
V8_INLINE static LocalBase<T> FromRepr(
|
224
|
+
internal::ValueHelper::InternalRepresentationType repr) {
|
225
|
+
return LocalBase<T>(repr);
|
226
|
+
}
|
216
227
|
};
|
217
228
|
|
218
229
|
#endif // V8_ENABLE_DIRECT_HANDLE
|
@@ -255,17 +266,19 @@ class V8_TRIVIAL_ABI Local : public LocalBase<T>,
|
|
255
266
|
#endif
|
256
267
|
{
|
257
268
|
public:
|
269
|
+
/**
|
270
|
+
* Default constructor: Returns an empty handle.
|
271
|
+
*/
|
258
272
|
V8_INLINE Local() = default;
|
259
273
|
|
274
|
+
/**
|
275
|
+
* Constructor for handling automatic up casting.
|
276
|
+
* Ex. Local<Object> can be passed when Local<Value> is expected but not
|
277
|
+
* the other way round.
|
278
|
+
*/
|
260
279
|
template <class S>
|
261
|
-
|
262
|
-
|
263
|
-
* This check fails when trying to convert between incompatible
|
264
|
-
* handles. For example, converting from a Local<String> to a
|
265
|
-
* Local<Number>.
|
266
|
-
*/
|
267
|
-
static_assert(std::is_base_of<T, S>::value, "type check");
|
268
|
-
}
|
280
|
+
requires std::is_base_of_v<T, S>
|
281
|
+
V8_INLINE Local(Local<S> that) : LocalBase<T>(that) {}
|
269
282
|
|
270
283
|
V8_INLINE T* operator->() const { return this->template value<T>(); }
|
271
284
|
|
@@ -305,7 +318,7 @@ class V8_TRIVIAL_ABI Local : public LocalBase<T>,
|
|
305
318
|
/**
|
306
319
|
* Cast a handle to a subclass, e.g. Local<Value> to Local<Object>.
|
307
320
|
* This is only valid if the handle actually refers to a value of the
|
308
|
-
* target type.
|
321
|
+
* target type or if the handle is empty.
|
309
322
|
*/
|
310
323
|
template <class S>
|
311
324
|
V8_INLINE static Local<T> Cast(Local<S> that) {
|
@@ -321,7 +334,7 @@ class V8_TRIVIAL_ABI Local : public LocalBase<T>,
|
|
321
334
|
/**
|
322
335
|
* Calling this is equivalent to Local<S>::Cast().
|
323
336
|
* In particular, this is only valid if the handle actually refers to a value
|
324
|
-
* of the target type.
|
337
|
+
* of the target type or if the handle is empty.
|
325
338
|
*/
|
326
339
|
template <class S>
|
327
340
|
V8_INLINE Local<S> As() const {
|
@@ -396,6 +409,11 @@ class V8_TRIVIAL_ABI Local : public LocalBase<T>,
|
|
396
409
|
|
397
410
|
V8_INLINE explicit Local(const LocalBase<T>& other) : LocalBase<T>(other) {}
|
398
411
|
|
412
|
+
V8_INLINE static Local<T> FromRepr(
|
413
|
+
internal::ValueHelper::InternalRepresentationType repr) {
|
414
|
+
return Local<T>(LocalBase<T>::FromRepr(repr));
|
415
|
+
}
|
416
|
+
|
399
417
|
V8_INLINE static Local<T> FromSlot(internal::Address* slot) {
|
400
418
|
return Local<T>(LocalBase<T>::FromSlot(slot));
|
401
419
|
}
|
@@ -434,8 +452,9 @@ class V8_TRIVIAL_ABI LocalUnchecked : public Local<T> {
|
|
434
452
|
#if defined(V8_ENABLE_LOCAL_OFF_STACK_CHECK) && V8_HAS_ATTRIBUTE_TRIVIAL_ABI
|
435
453
|
// In this case, the check is also enforced in the copy constructor and we
|
436
454
|
// need to suppress it.
|
437
|
-
LocalUnchecked(
|
438
|
-
|
455
|
+
LocalUnchecked(
|
456
|
+
const LocalUnchecked& other) noexcept // NOLINT(runtime/explicit)
|
457
|
+
: Local<T>(other, Local<T>::do_not_check) {}
|
439
458
|
LocalUnchecked& operator=(const LocalUnchecked&) noexcept = default;
|
440
459
|
#endif
|
441
460
|
|
@@ -455,11 +474,9 @@ class StrongRootAllocator<LocalUnchecked<T>> : public StrongRootAllocatorBase {
|
|
455
474
|
static_assert(std::is_standard_layout_v<value_type>);
|
456
475
|
static_assert(sizeof(value_type) == sizeof(Address));
|
457
476
|
|
458
|
-
|
459
|
-
explicit StrongRootAllocator(
|
460
|
-
: StrongRootAllocatorBase(
|
461
|
-
explicit StrongRootAllocator(v8::Isolate* isolate)
|
462
|
-
: StrongRootAllocatorBase(reinterpret_cast<Isolate*>(isolate)) {}
|
477
|
+
template <typename HeapOrIsolateT>
|
478
|
+
explicit StrongRootAllocator(HeapOrIsolateT* heap_or_isolate)
|
479
|
+
: StrongRootAllocatorBase(heap_or_isolate) {}
|
463
480
|
template <typename U>
|
464
481
|
StrongRootAllocator(const StrongRootAllocator<U>& other) noexcept
|
465
482
|
: StrongRootAllocatorBase(other) {}
|
@@ -565,7 +582,11 @@ class LocalVector {
|
|
565
582
|
|
566
583
|
void push_back(const Local<T>& x) { backing_.push_back(x); }
|
567
584
|
void pop_back() { backing_.pop_back(); }
|
568
|
-
|
585
|
+
|
586
|
+
template <typename... Args>
|
587
|
+
void emplace_back(Args&&... args) {
|
588
|
+
backing_.push_back(value_type{std::forward<Args>(args)...});
|
589
|
+
}
|
569
590
|
|
570
591
|
void clear() noexcept { backing_.clear(); }
|
571
592
|
void resize(size_t n) { backing_.resize(n); }
|
@@ -613,9 +634,22 @@ using Handle = Local<T>;
|
|
613
634
|
template <class T>
|
614
635
|
class MaybeLocal {
|
615
636
|
public:
|
616
|
-
|
637
|
+
/**
|
638
|
+
* Default constructor: Returns an empty handle.
|
639
|
+
*/
|
640
|
+
V8_INLINE MaybeLocal() = default;
|
641
|
+
/**
|
642
|
+
* Implicitly construct MaybeLocal from Local.
|
643
|
+
*/
|
617
644
|
template <class S>
|
645
|
+
requires std::is_base_of_v<T, S>
|
618
646
|
V8_INLINE MaybeLocal(Local<S> that) : local_(that) {}
|
647
|
+
/**
|
648
|
+
* Implicitly up-cast MaybeLocal<S> to MaybeLocal<T> if T is a base of S.
|
649
|
+
*/
|
650
|
+
template <class S>
|
651
|
+
requires std::is_base_of_v<T, S>
|
652
|
+
V8_INLINE MaybeLocal(MaybeLocal<S> that) : local_(that.local_) {}
|
619
653
|
|
620
654
|
V8_INLINE bool IsEmpty() const { return local_.IsEmpty(); }
|
621
655
|
|
@@ -650,23 +684,17 @@ class MaybeLocal {
|
|
650
684
|
/**
|
651
685
|
* Cast a handle to a subclass, e.g. MaybeLocal<Value> to MaybeLocal<Object>.
|
652
686
|
* This is only valid if the handle actually refers to a value of the target
|
653
|
-
* type.
|
687
|
+
* type or if the handle is empty.
|
654
688
|
*/
|
655
689
|
template <class S>
|
656
690
|
V8_INLINE static MaybeLocal<T> Cast(MaybeLocal<S> that) {
|
657
|
-
|
658
|
-
// If we're going to perform the type check then we have to check
|
659
|
-
// that the handle isn't empty before doing the checked cast.
|
660
|
-
if (that.IsEmpty()) return MaybeLocal<T>();
|
661
|
-
T::Cast(that.local_.template value<S>());
|
662
|
-
#endif
|
663
|
-
return MaybeLocal<T>(that.local_);
|
691
|
+
return MaybeLocal<T>{Local<T>::Cast(that.local_)};
|
664
692
|
}
|
665
693
|
|
666
694
|
/**
|
667
695
|
* Calling this is equivalent to MaybeLocal<S>::Cast().
|
668
696
|
* In particular, this is only valid if the handle actually refers to a value
|
669
|
-
* of the target type.
|
697
|
+
* of the target type or if the handle is empty.
|
670
698
|
*/
|
671
699
|
template <class S>
|
672
700
|
V8_INLINE MaybeLocal<S> As() const {
|
@@ -8,6 +8,7 @@
|
|
8
8
|
#include <type_traits>
|
9
9
|
#include <utility>
|
10
10
|
|
11
|
+
#include "cppgc/internal/conditional-stack-allocated.h" // NOLINT(build/include_directory)
|
11
12
|
#include "v8-internal.h" // NOLINT(build/include_directory)
|
12
13
|
#include "v8config.h" // NOLINT(build/include_directory)
|
13
14
|
|
@@ -29,7 +30,7 @@ V8_EXPORT void FromJustIsNothing();
|
|
29
30
|
* "Nothing" value is returned.
|
30
31
|
*/
|
31
32
|
template <class T>
|
32
|
-
class Maybe {
|
33
|
+
class Maybe : public cppgc::internal::ConditionalStackAllocatedBase<T> {
|
33
34
|
public:
|
34
35
|
V8_INLINE bool IsNothing() const { return !has_value_; }
|
35
36
|
V8_INLINE bool IsJust() const { return has_value_; }
|
@@ -8,11 +8,46 @@
|
|
8
8
|
#include <stddef.h>
|
9
9
|
|
10
10
|
#include <array>
|
11
|
+
#include <cstddef>
|
11
12
|
#include <iterator>
|
12
13
|
#include <type_traits>
|
13
14
|
|
14
15
|
#include "v8config.h" // NOLINT(build/include_directory)
|
15
16
|
|
17
|
+
// TODO(pkasting): Use <compare>/spaceship unconditionally after dropping
|
18
|
+
// support for old libstdc++ versions.
|
19
|
+
#if __has_include(<version>)
|
20
|
+
#include <version>
|
21
|
+
#endif
|
22
|
+
#if defined(__cpp_lib_three_way_comparison) && \
|
23
|
+
__cpp_lib_three_way_comparison >= 201711L
|
24
|
+
#define V8_HAVE_SPACESHIP_OPERATOR 1
|
25
|
+
#else
|
26
|
+
#define V8_HAVE_SPACESHIP_OPERATOR 0
|
27
|
+
#endif
|
28
|
+
|
29
|
+
// TODO(pkasting): Make this block unconditional after dropping support for old
|
30
|
+
// libstdc++ versions.
|
31
|
+
#if __has_include(<ranges>)
|
32
|
+
#include <ranges>
|
33
|
+
|
34
|
+
namespace v8 {
|
35
|
+
|
36
|
+
template <typename T>
|
37
|
+
class V8_EXPORT MemorySpan;
|
38
|
+
|
39
|
+
} // namespace v8
|
40
|
+
|
41
|
+
// Mark `MemorySpan` as satisfying the `view` and `borrowed_range` concepts.
|
42
|
+
// This should be done before the definition of `MemorySpan`, so that any
|
43
|
+
// inlined calls to range functionality use the correct specializations.
|
44
|
+
template <typename T>
|
45
|
+
inline constexpr bool std::ranges::enable_view<v8::MemorySpan<T>> = true;
|
46
|
+
template <typename T>
|
47
|
+
inline constexpr bool std::ranges::enable_borrowed_range<v8::MemorySpan<T>> =
|
48
|
+
true;
|
49
|
+
#endif
|
50
|
+
|
16
51
|
namespace v8 {
|
17
52
|
|
18
53
|
/**
|
@@ -53,13 +88,13 @@ class V8_EXPORT MemorySpan {
|
|
53
88
|
is_compatible_iterator<It>::value;
|
54
89
|
|
55
90
|
template <typename U>
|
56
|
-
static constexpr U* to_address(U* p) noexcept {
|
91
|
+
[[nodiscard]] static constexpr U* to_address(U* p) noexcept {
|
57
92
|
return p;
|
58
93
|
}
|
59
94
|
|
60
95
|
template <typename It,
|
61
96
|
typename = std::void_t<decltype(std::declval<It&>().operator->())>>
|
62
|
-
static constexpr auto to_address(It it) noexcept {
|
97
|
+
[[nodiscard]] static constexpr auto to_address(It it) noexcept {
|
63
98
|
return it.operator->();
|
64
99
|
}
|
65
100
|
|
@@ -108,50 +143,139 @@ class V8_EXPORT MemorySpan {
|
|
108
143
|
: data_(a.data()), size_{N} {}
|
109
144
|
|
110
145
|
/** Returns a pointer to the beginning of the buffer. */
|
111
|
-
constexpr T* data() const { return data_; }
|
146
|
+
[[nodiscard]] constexpr T* data() const { return data_; }
|
112
147
|
/** Returns the number of elements that the buffer holds. */
|
113
|
-
constexpr size_t size() const { return size_; }
|
148
|
+
[[nodiscard]] constexpr size_t size() const { return size_; }
|
114
149
|
|
115
|
-
constexpr T& operator[](size_t i) const { return data_[i]; }
|
150
|
+
[[nodiscard]] constexpr T& operator[](size_t i) const { return data_[i]; }
|
116
151
|
|
117
152
|
/** Returns true if the buffer is empty. */
|
118
|
-
constexpr bool empty() const { return size() == 0; }
|
153
|
+
[[nodiscard]] constexpr bool empty() const { return size() == 0; }
|
119
154
|
|
120
155
|
class Iterator {
|
121
156
|
public:
|
122
|
-
using iterator_category = std::forward_iterator_tag;
|
123
|
-
using value_type = T;
|
124
157
|
using difference_type = std::ptrdiff_t;
|
158
|
+
using value_type = T;
|
125
159
|
using pointer = value_type*;
|
126
160
|
using reference = value_type&;
|
161
|
+
using iterator_category = std::random_access_iterator_tag;
|
162
|
+
// There seems to be no feature-test macro covering this, so use the
|
163
|
+
// presence of `<ranges>` as a crude proxy, since it was added to the
|
164
|
+
// standard as part of the Ranges papers.
|
165
|
+
// TODO(pkasting): Add this unconditionally after dropping support for old
|
166
|
+
// libstdc++ versions.
|
167
|
+
#if __has_include(<ranges>)
|
168
|
+
using iterator_concept = std::contiguous_iterator_tag;
|
169
|
+
#endif
|
170
|
+
|
171
|
+
// Required to satisfy `std::semiregular<>`.
|
172
|
+
constexpr Iterator() = default;
|
173
|
+
|
174
|
+
[[nodiscard]] friend constexpr bool operator==(const Iterator& a,
|
175
|
+
const Iterator& b) {
|
176
|
+
// TODO(pkasting): Replace this body with `= default` after dropping
|
177
|
+
// support for old gcc versions.
|
178
|
+
return a.ptr_ == b.ptr_;
|
179
|
+
}
|
180
|
+
#if V8_HAVE_SPACESHIP_OPERATOR
|
181
|
+
[[nodiscard]] friend constexpr auto operator<=>(const Iterator&,
|
182
|
+
const Iterator&) = default;
|
183
|
+
#else
|
184
|
+
// Assume that if spaceship isn't present, operator rewriting might not be
|
185
|
+
// either.
|
186
|
+
[[nodiscard]] friend constexpr bool operator!=(const Iterator& a,
|
187
|
+
const Iterator& b) {
|
188
|
+
return a.ptr_ != b.ptr_;
|
189
|
+
}
|
127
190
|
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
bool operator
|
191
|
+
[[nodiscard]] friend constexpr bool operator<(const Iterator& a,
|
192
|
+
const Iterator& b) {
|
193
|
+
return a.ptr_ < b.ptr_;
|
194
|
+
}
|
195
|
+
[[nodiscard]] friend constexpr bool operator<=(const Iterator& a,
|
196
|
+
const Iterator& b) {
|
197
|
+
return a.ptr_ <= b.ptr_;
|
198
|
+
}
|
199
|
+
[[nodiscard]] friend constexpr bool operator>(const Iterator& a,
|
200
|
+
const Iterator& b) {
|
201
|
+
return a.ptr_ > b.ptr_;
|
202
|
+
}
|
203
|
+
[[nodiscard]] friend constexpr bool operator>=(const Iterator& a,
|
204
|
+
const Iterator& b) {
|
205
|
+
return a.ptr_ >= b.ptr_;
|
206
|
+
}
|
207
|
+
#endif
|
133
208
|
|
134
|
-
Iterator& operator++() {
|
209
|
+
constexpr Iterator& operator++() {
|
135
210
|
++ptr_;
|
136
211
|
return *this;
|
137
212
|
}
|
138
213
|
|
139
|
-
Iterator operator++(int) {
|
140
|
-
Iterator temp
|
141
|
-
|
214
|
+
constexpr Iterator operator++(int) {
|
215
|
+
Iterator temp = *this;
|
216
|
+
++*this;
|
142
217
|
return temp;
|
143
218
|
}
|
144
219
|
|
220
|
+
constexpr Iterator& operator--() {
|
221
|
+
--ptr_;
|
222
|
+
return *this;
|
223
|
+
}
|
224
|
+
|
225
|
+
constexpr Iterator operator--(int) {
|
226
|
+
Iterator temp = *this;
|
227
|
+
--*this;
|
228
|
+
return temp;
|
229
|
+
}
|
230
|
+
|
231
|
+
constexpr Iterator& operator+=(difference_type rhs) {
|
232
|
+
ptr_ += rhs;
|
233
|
+
return *this;
|
234
|
+
}
|
235
|
+
|
236
|
+
[[nodiscard]] friend constexpr Iterator operator+(Iterator lhs,
|
237
|
+
difference_type rhs) {
|
238
|
+
lhs += rhs;
|
239
|
+
return lhs;
|
240
|
+
}
|
241
|
+
|
242
|
+
[[nodiscard]] friend constexpr Iterator operator+(difference_type lhs,
|
243
|
+
const Iterator& rhs) {
|
244
|
+
return rhs + lhs;
|
245
|
+
}
|
246
|
+
|
247
|
+
constexpr Iterator& operator-=(difference_type rhs) {
|
248
|
+
ptr_ -= rhs;
|
249
|
+
return *this;
|
250
|
+
}
|
251
|
+
|
252
|
+
[[nodiscard]] friend constexpr Iterator operator-(Iterator lhs,
|
253
|
+
difference_type rhs) {
|
254
|
+
lhs -= rhs;
|
255
|
+
return lhs;
|
256
|
+
}
|
257
|
+
|
258
|
+
[[nodiscard]] friend constexpr difference_type operator-(
|
259
|
+
const Iterator& lhs, const Iterator& rhs) {
|
260
|
+
return lhs.ptr_ - rhs.ptr_;
|
261
|
+
}
|
262
|
+
|
263
|
+
[[nodiscard]] constexpr reference operator*() const { return *ptr_; }
|
264
|
+
[[nodiscard]] constexpr pointer operator->() const { return ptr_; }
|
265
|
+
[[nodiscard]] constexpr reference operator[](size_t offset) const {
|
266
|
+
return ptr_[offset];
|
267
|
+
}
|
268
|
+
|
145
269
|
private:
|
146
270
|
friend class MemorySpan<T>;
|
147
271
|
|
148
|
-
explicit Iterator(T* ptr) : ptr_(ptr) {}
|
272
|
+
constexpr explicit Iterator(T* ptr) : ptr_(ptr) {}
|
149
273
|
|
150
274
|
T* ptr_ = nullptr;
|
151
275
|
};
|
152
276
|
|
153
|
-
Iterator begin() const { return Iterator(data_); }
|
154
|
-
Iterator end() const { return Iterator(data_ + size_); }
|
277
|
+
[[nodiscard]] Iterator begin() const { return Iterator(data_); }
|
278
|
+
[[nodiscard]] Iterator end() const { return Iterator(data_ + size_); }
|
155
279
|
|
156
280
|
private:
|
157
281
|
T* data_ = nullptr;
|
@@ -171,25 +295,26 @@ class V8_EXPORT MemorySpan {
|
|
171
295
|
|
172
296
|
namespace detail {
|
173
297
|
template <class T, std::size_t N, std::size_t... I>
|
174
|
-
constexpr std::array<std::remove_cv_t<T>, N> to_array_lvalue_impl(
|
298
|
+
[[nodiscard]] constexpr std::array<std::remove_cv_t<T>, N> to_array_lvalue_impl(
|
175
299
|
T (&a)[N], std::index_sequence<I...>) {
|
176
300
|
return {{a[I]...}};
|
177
301
|
}
|
178
302
|
|
179
303
|
template <class T, std::size_t N, std::size_t... I>
|
180
|
-
constexpr std::array<std::remove_cv_t<T>, N> to_array_rvalue_impl(
|
304
|
+
[[nodiscard]] constexpr std::array<std::remove_cv_t<T>, N> to_array_rvalue_impl(
|
181
305
|
T (&&a)[N], std::index_sequence<I...>) {
|
182
306
|
return {{std::move(a[I])...}};
|
183
307
|
}
|
184
308
|
} // namespace detail
|
185
309
|
|
186
310
|
template <class T, std::size_t N>
|
187
|
-
constexpr std::array<std::remove_cv_t<T>, N> to_array(T (&a)[N]) {
|
311
|
+
[[nodiscard]] constexpr std::array<std::remove_cv_t<T>, N> to_array(T (&a)[N]) {
|
188
312
|
return detail::to_array_lvalue_impl(a, std::make_index_sequence<N>{});
|
189
313
|
}
|
190
314
|
|
191
315
|
template <class T, std::size_t N>
|
192
|
-
constexpr std::array<std::remove_cv_t<T>, N> to_array(
|
316
|
+
[[nodiscard]] constexpr std::array<std::remove_cv_t<T>, N> to_array(
|
317
|
+
T (&&a)[N]) {
|
193
318
|
return detail::to_array_rvalue_impl(std::move(a),
|
194
319
|
std::make_index_sequence<N>{});
|
195
320
|
}
|
@@ -9,6 +9,7 @@
|
|
9
9
|
|
10
10
|
#include <iosfwd>
|
11
11
|
|
12
|
+
#include "v8-callbacks.h" // NOLINT(build/include_directory)
|
12
13
|
#include "v8-local-handle.h" // NOLINT(build/include_directory)
|
13
14
|
#include "v8-maybe.h" // NOLINT(build/include_directory)
|
14
15
|
#include "v8-primitive.h" // NOLINT(build/include_directory)
|
@@ -185,7 +186,14 @@ class V8_EXPORT Message {
|
|
185
186
|
bool IsSharedCrossOrigin() const;
|
186
187
|
bool IsOpaque() const;
|
187
188
|
|
188
|
-
|
189
|
+
/**
|
190
|
+
* If provided, the callback can be used to selectively include
|
191
|
+
* or redact frames based on their script names. (true to include a frame)
|
192
|
+
*/
|
193
|
+
static void PrintCurrentStackTrace(
|
194
|
+
Isolate* isolate, std::ostream& out,
|
195
|
+
PrintCurrentStackTraceFilterCallback should_include_frame_callback =
|
196
|
+
nullptr);
|
189
197
|
|
190
198
|
static const int kNoLineNumberInfo = 0;
|
191
199
|
static const int kNoColumnInfo = 0;
|
@@ -8,9 +8,11 @@
|
|
8
8
|
#include <stddef.h>
|
9
9
|
#include <stdint.h>
|
10
10
|
|
11
|
+
#include <optional>
|
11
12
|
#include <vector>
|
12
13
|
|
13
14
|
#include "v8-internal.h" // NOLINT(build/include_directory)
|
15
|
+
#include "v8-isolate.h" // NOLINT(build/include_directory)
|
14
16
|
#include "v8-local-handle.h" // NOLINT(build/include_directory)
|
15
17
|
#include "v8config.h" // NOLINT(build/include_directory)
|
16
18
|
|
@@ -37,6 +39,10 @@ struct GarbageCollectionSizes {
|
|
37
39
|
|
38
40
|
struct GarbageCollectionFullCycle {
|
39
41
|
int reason = -1;
|
42
|
+
// The priority of the isolate during the GC cycle. A nullopt value denotes a
|
43
|
+
// mixed priority cycle, meaning the Isolate's priority was changed while the
|
44
|
+
// cycle was in progress.
|
45
|
+
std::optional<v8::Isolate::Priority> priority = std::nullopt;
|
40
46
|
GarbageCollectionPhases total;
|
41
47
|
GarbageCollectionPhases total_cpp;
|
42
48
|
GarbageCollectionPhases main_thread;
|
@@ -86,6 +92,10 @@ using GarbageCollectionFullMainThreadBatchedIncrementalSweep =
|
|
86
92
|
|
87
93
|
struct GarbageCollectionYoungCycle {
|
88
94
|
int reason = -1;
|
95
|
+
// The priority of the isolate during the GC cycle. A nullopt value denotes a
|
96
|
+
// mixed priority cycle, meaning the Isolate's priority was changed while the
|
97
|
+
// cycle was in progress.
|
98
|
+
std::optional<v8::Isolate::Priority> priority = std::nullopt;
|
89
99
|
int64_t total_wall_clock_duration_in_us = -1;
|
90
100
|
int64_t main_thread_wall_clock_duration_in_us = -1;
|
91
101
|
double collection_rate_in_percent = -1.0;
|
@@ -704,6 +704,7 @@ class V8_EXPORT Object : public Value {
|
|
704
704
|
* Prefer using version with Isolate parameter.
|
705
705
|
*/
|
706
706
|
MaybeLocal<Context> GetCreationContext(v8::Isolate* isolate);
|
707
|
+
V8_DEPRECATE_SOON("Use the version with the isolate argument.")
|
707
708
|
MaybeLocal<Context> GetCreationContext();
|
708
709
|
|
709
710
|
/**
|
@@ -712,13 +713,17 @@ class V8_EXPORT Object : public Value {
|
|
712
713
|
* Prefer using version with Isolate parameter.
|
713
714
|
**/
|
714
715
|
Local<Context> GetCreationContextChecked(v8::Isolate* isolate);
|
716
|
+
V8_DEPRECATE_SOON("Use the version with the isolate argument.")
|
715
717
|
Local<Context> GetCreationContextChecked();
|
716
718
|
|
717
719
|
/** Same as above, but works for Persistents */
|
718
720
|
V8_INLINE static MaybeLocal<Context> GetCreationContext(
|
719
|
-
const PersistentBase<Object>& object) {
|
720
|
-
return object.template value<Object>()->GetCreationContext();
|
721
|
+
v8::Isolate* isolate, const PersistentBase<Object>& object) {
|
722
|
+
return object.template value<Object>()->GetCreationContext(isolate);
|
721
723
|
}
|
724
|
+
V8_DEPRECATE_SOON("Use the version with the isolate argument.")
|
725
|
+
V8_INLINE static MaybeLocal<Context> GetCreationContext(
|
726
|
+
const PersistentBase<Object>& object);
|
722
727
|
|
723
728
|
/**
|
724
729
|
* Gets the context in which the object was created (see GetCreationContext())
|
@@ -46,7 +46,11 @@ class Eternal : public api_internal::IndirectHandleBase {
|
|
46
46
|
public:
|
47
47
|
V8_INLINE Eternal() = default;
|
48
48
|
|
49
|
+
/**
|
50
|
+
* Constructor for handling automatic up casting.
|
51
|
+
*/
|
49
52
|
template <class S>
|
53
|
+
requires(std::is_base_of_v<T, S>)
|
50
54
|
V8_INLINE Eternal(Isolate* isolate, Local<S> handle) {
|
51
55
|
Set(isolate, handle);
|
52
56
|
}
|
@@ -59,8 +63,8 @@ class Eternal : public api_internal::IndirectHandleBase {
|
|
59
63
|
}
|
60
64
|
|
61
65
|
template <class S>
|
66
|
+
requires(std::is_base_of_v<T, S>)
|
62
67
|
void Set(Isolate* isolate, Local<S> handle) {
|
63
|
-
static_assert(std::is_base_of<T, S>::value, "type check");
|
64
68
|
slot() =
|
65
69
|
api_internal::Eternalize(isolate, *handle.template UnsafeAs<Value>());
|
66
70
|
}
|
@@ -251,28 +255,26 @@ class Persistent : public PersistentBase<T> {
|
|
251
255
|
V8_INLINE Persistent() = default;
|
252
256
|
|
253
257
|
/**
|
254
|
-
* Construct a Persistent from a Local.
|
258
|
+
* Construct a Persistent from a Local with automatic up casting.
|
255
259
|
* When the Local is non-empty, a new storage cell is created
|
256
260
|
* pointing to the same object, and no flags are set.
|
257
261
|
*/
|
258
262
|
template <class S>
|
263
|
+
requires(std::is_base_of_v<T, S>)
|
259
264
|
V8_INLINE Persistent(Isolate* isolate, Local<S> that)
|
260
265
|
: PersistentBase<T>(
|
261
|
-
PersistentBase<T>::New(isolate, that.template value<S>())) {
|
262
|
-
static_assert(std::is_base_of<T, S>::value, "type check");
|
263
|
-
}
|
266
|
+
PersistentBase<T>::New(isolate, that.template value<S>())) {}
|
264
267
|
|
265
268
|
/**
|
266
|
-
* Construct a Persistent from a Persistent.
|
269
|
+
* Construct a Persistent from a Persistent with automatic up casting.
|
267
270
|
* When the Persistent is non-empty, a new storage cell is created
|
268
271
|
* pointing to the same object, and no flags are set.
|
269
272
|
*/
|
270
273
|
template <class S, class M2>
|
274
|
+
requires(std::is_base_of_v<T, S>)
|
271
275
|
V8_INLINE Persistent(Isolate* isolate, const Persistent<S, M2>& that)
|
272
276
|
: PersistentBase<T>(
|
273
|
-
PersistentBase<T>::New(isolate, that.template value<S>())) {
|
274
|
-
static_assert(std::is_base_of<T, S>::value, "type check");
|
275
|
-
}
|
277
|
+
PersistentBase<T>::New(isolate, that.template value<S>())) {}
|
276
278
|
|
277
279
|
/**
|
278
280
|
* The copy constructors and assignment operator create a Persistent
|
@@ -352,28 +354,26 @@ class Global : public PersistentBase<T> {
|
|
352
354
|
V8_INLINE Global() = default;
|
353
355
|
|
354
356
|
/**
|
355
|
-
* Construct a Global from a Local.
|
357
|
+
* Construct a Global from a Local with automatic up casting.
|
356
358
|
* When the Local is non-empty, a new storage cell is created
|
357
359
|
* pointing to the same object, and no flags are set.
|
358
360
|
*/
|
359
361
|
template <class S>
|
362
|
+
requires(std::is_base_of_v<T, S>)
|
360
363
|
V8_INLINE Global(Isolate* isolate, Local<S> that)
|
361
364
|
: PersistentBase<T>(
|
362
|
-
PersistentBase<T>::New(isolate, that.template value<S>())) {
|
363
|
-
static_assert(std::is_base_of<T, S>::value, "type check");
|
364
|
-
}
|
365
|
+
PersistentBase<T>::New(isolate, that.template value<S>())) {}
|
365
366
|
|
366
367
|
/**
|
367
|
-
* Construct a Global from a PersistentBase.
|
368
|
+
* Construct a Global from a PersistentBase with automatic up casting.
|
368
369
|
* When the Persistent is non-empty, a new storage cell is created
|
369
370
|
* pointing to the same object, and no flags are set.
|
370
371
|
*/
|
371
372
|
template <class S>
|
373
|
+
requires(std::is_base_of_v<T, S>)
|
372
374
|
V8_INLINE Global(Isolate* isolate, const PersistentBase<S>& that)
|
373
375
|
: PersistentBase<T>(
|
374
|
-
PersistentBase<T>::New(isolate, that.template value<S>())) {
|
375
|
-
static_assert(std::is_base_of<T, S>::value, "type check");
|
376
|
-
}
|
376
|
+
PersistentBase<T>::New(isolate, that.template value<S>())) {}
|
377
377
|
|
378
378
|
/**
|
379
379
|
* Move constructor.
|