libv8-node 21.7.2.0-aarch64-linux-musl → 24.12.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 +3 -5
- data/ext/libv8-node/paths.rb +2 -0
- data/lib/libv8/node/version.rb +7 -4
- data/lib/libv8/node.rb +2 -0
- data/lib/libv8-node.rb +2 -0
- data/vendor/v8/aarch64-linux-musl/libv8/obj/libv8_monolith.a +0 -0
- data/vendor/v8/include/cppgc/allocation.h +11 -13
- data/vendor/v8/include/cppgc/default-platform.h +3 -2
- data/vendor/v8/include/cppgc/garbage-collected.h +8 -0
- data/vendor/v8/include/cppgc/heap-consistency.h +1 -1
- data/vendor/v8/include/cppgc/heap-statistics.h +2 -0
- data/vendor/v8/include/cppgc/internal/api-constants.h +2 -14
- 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/compiler-specific.h +9 -1
- data/vendor/v8/include/cppgc/internal/conditional-stack-allocated.h +41 -0
- data/vendor/v8/include/cppgc/internal/gc-info.h +12 -10
- data/vendor/v8/include/cppgc/internal/logging.h +3 -3
- data/vendor/v8/include/cppgc/internal/member-storage.h +69 -20
- data/vendor/v8/include/cppgc/internal/name-trait.h +5 -1
- 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 +10 -0
- data/vendor/v8/include/cppgc/platform.h +11 -0
- data/vendor/v8/include/cppgc/type-traits.h +26 -4
- 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 +149 -46
- data/vendor/v8/include/v8-callbacks.h +100 -43
- data/vendor/v8/include/v8-container.h +54 -0
- data/vendor/v8/include/v8-context.h +92 -30
- data/vendor/v8/include/v8-cppgc.h +5 -56
- data/vendor/v8/include/v8-data.h +5 -0
- data/vendor/v8/include/v8-date.h +9 -0
- data/vendor/v8/include/v8-debug.h +11 -0
- data/vendor/v8/include/v8-embedder-heap.h +8 -20
- data/vendor/v8/include/v8-embedder-state-scope.h +2 -1
- data/vendor/v8/include/v8-exception.h +87 -9
- data/vendor/v8/include/v8-external-memory-accounter.h +60 -0
- data/vendor/v8/include/v8-fast-api-calls.h +67 -223
- data/vendor/v8/include/v8-forward.h +1 -0
- data/vendor/v8/include/v8-function-callback.h +296 -75
- data/vendor/v8/include/v8-function.h +11 -3
- data/vendor/v8/include/v8-handle-base.h +52 -82
- data/vendor/v8/include/v8-initialization.h +26 -1
- data/vendor/v8/include/v8-inspector.h +26 -27
- data/vendor/v8/include/v8-internal.h +960 -230
- data/vendor/v8/include/v8-isolate.h +347 -226
- data/vendor/v8/include/v8-local-handle.h +307 -55
- data/vendor/v8/include/v8-maybe.h +2 -1
- data/vendor/v8/include/v8-memory-span.h +284 -4
- data/vendor/v8/include/v8-message.h +11 -5
- data/vendor/v8/include/v8-metrics.h +15 -0
- data/vendor/v8/include/v8-microtask-queue.h +0 -5
- data/vendor/v8/include/v8-object.h +314 -41
- data/vendor/v8/include/v8-persistent-handle.h +29 -39
- data/vendor/v8/include/v8-platform.h +135 -77
- data/vendor/v8/include/v8-primitive.h +223 -5
- data/vendor/v8/include/v8-profiler.h +51 -2
- data/vendor/v8/include/v8-promise.h +2 -2
- 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 +173 -0
- data/vendor/v8/include/v8-script.h +125 -27
- data/vendor/v8/include/v8-snapshot.h +130 -23
- data/vendor/v8/include/v8-source-location.h +6 -1
- data/vendor/v8/include/v8-statistics.h +10 -24
- data/vendor/v8/include/v8-template.h +320 -193
- data/vendor/v8/include/v8-trace-categories.h +23 -0
- data/vendor/v8/include/v8-traced-handle.h +99 -76
- data/vendor/v8/include/v8-typed-array.h +111 -7
- data/vendor/v8/include/v8-unwinder-state.h +2 -3
- data/vendor/v8/include/v8-unwinder.h +2 -1
- data/vendor/v8/include/v8-util.h +10 -125
- data/vendor/v8/include/v8-value-serializer-version.h +3 -3
- data/vendor/v8/include/v8-value.h +113 -6
- data/vendor/v8/include/v8-version.h +3 -3
- data/vendor/v8/include/v8-wasm.h +27 -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 +116 -53
- metadata +55 -12
- data/vendor/v8/include/cppgc/ephemeron-pair.h +0 -30
|
@@ -5,6 +5,10 @@
|
|
|
5
5
|
#ifndef INCLUDE_V8_FUNCTION_CALLBACK_H_
|
|
6
6
|
#define INCLUDE_V8_FUNCTION_CALLBACK_H_
|
|
7
7
|
|
|
8
|
+
#include <cstdint>
|
|
9
|
+
#include <limits>
|
|
10
|
+
|
|
11
|
+
#include "v8-internal.h" // NOLINT(build/include_directory)
|
|
8
12
|
#include "v8-local-handle.h" // NOLINT(build/include_directory)
|
|
9
13
|
#include "v8-primitive.h" // NOLINT(build/include_directory)
|
|
10
14
|
#include "v8config.h" // NOLINT(build/include_directory)
|
|
@@ -28,6 +32,11 @@ namespace debug {
|
|
|
28
32
|
class ConsoleCallArguments;
|
|
29
33
|
} // namespace debug
|
|
30
34
|
|
|
35
|
+
namespace api_internal {
|
|
36
|
+
V8_EXPORT v8::Local<v8::Value> GetFunctionTemplateData(
|
|
37
|
+
v8::Isolate* isolate, v8::Local<v8::Data> raw_target);
|
|
38
|
+
} // namespace api_internal
|
|
39
|
+
|
|
31
40
|
template <typename T>
|
|
32
41
|
class ReturnValue {
|
|
33
42
|
public:
|
|
@@ -35,21 +44,32 @@ class ReturnValue {
|
|
|
35
44
|
V8_INLINE ReturnValue(const ReturnValue<S>& that) : value_(that.value_) {
|
|
36
45
|
static_assert(std::is_base_of<T, S>::value, "type check");
|
|
37
46
|
}
|
|
38
|
-
//
|
|
47
|
+
// Handle-based setters.
|
|
39
48
|
template <typename S>
|
|
40
49
|
V8_INLINE void Set(const Global<S>& handle);
|
|
41
50
|
template <typename S>
|
|
51
|
+
V8_INLINE void SetNonEmpty(const Global<S>& handle);
|
|
52
|
+
template <typename S>
|
|
42
53
|
V8_INLINE void Set(const BasicTracedReference<S>& handle);
|
|
43
54
|
template <typename S>
|
|
55
|
+
V8_INLINE void SetNonEmpty(const BasicTracedReference<S>& handle);
|
|
56
|
+
template <typename S>
|
|
44
57
|
V8_INLINE void Set(const Local<S> handle);
|
|
45
|
-
|
|
58
|
+
template <typename S>
|
|
59
|
+
V8_INLINE void SetNonEmpty(const Local<S> handle);
|
|
60
|
+
// Fast primitive number setters.
|
|
46
61
|
V8_INLINE void Set(bool value);
|
|
47
62
|
V8_INLINE void Set(double i);
|
|
63
|
+
V8_INLINE void Set(int16_t i);
|
|
48
64
|
V8_INLINE void Set(int32_t i);
|
|
65
|
+
V8_INLINE void Set(int64_t i);
|
|
66
|
+
V8_INLINE void Set(uint16_t i);
|
|
49
67
|
V8_INLINE void Set(uint32_t i);
|
|
68
|
+
V8_INLINE void Set(uint64_t i);
|
|
50
69
|
// Fast JS primitive setters
|
|
51
70
|
V8_INLINE void SetNull();
|
|
52
71
|
V8_INLINE void SetUndefined();
|
|
72
|
+
V8_INLINE void SetFalse();
|
|
53
73
|
V8_INLINE void SetEmptyString();
|
|
54
74
|
// Convenience getter for Isolate
|
|
55
75
|
V8_INLINE Isolate* GetIsolate() const;
|
|
@@ -72,8 +92,14 @@ class ReturnValue {
|
|
|
72
92
|
friend class PropertyCallbackInfo;
|
|
73
93
|
template <class F, class G, class H>
|
|
74
94
|
friend class PersistentValueMapBase;
|
|
75
|
-
V8_INLINE void SetInternal(internal::Address value)
|
|
76
|
-
|
|
95
|
+
V8_INLINE void SetInternal(internal::Address value);
|
|
96
|
+
// Default value depends on <T>:
|
|
97
|
+
// - <void> -> true_value,
|
|
98
|
+
// - <v8::Boolean> -> true_value,
|
|
99
|
+
// - <v8::Integer> -> 0,
|
|
100
|
+
// - <v8::Value> -> undefined_value,
|
|
101
|
+
// - <v8::Array> -> undefined_value.
|
|
102
|
+
V8_INLINE void SetDefaultValue();
|
|
77
103
|
V8_INLINE explicit ReturnValue(internal::Address* slot);
|
|
78
104
|
|
|
79
105
|
// See FunctionCallbackInfo.
|
|
@@ -100,17 +126,6 @@ class FunctionCallbackInfo {
|
|
|
100
126
|
V8_INLINE Local<Value> operator[](int i) const;
|
|
101
127
|
/** Returns the receiver. This corresponds to the "this" value. */
|
|
102
128
|
V8_INLINE Local<Object> This() const;
|
|
103
|
-
/**
|
|
104
|
-
* If the callback was created without a Signature, this is the same
|
|
105
|
-
* value as This(). If there is a signature, and the signature didn't match
|
|
106
|
-
* This() but one of its hidden prototypes, this will be the respective
|
|
107
|
-
* hidden prototype.
|
|
108
|
-
*
|
|
109
|
-
* Note that this is not the prototype of This() on which the accessor
|
|
110
|
-
* referencing this callback was found (which in V8 internally is often
|
|
111
|
-
* referred to as holder [sic]).
|
|
112
|
-
*/
|
|
113
|
-
V8_INLINE Local<Object> Holder() const;
|
|
114
129
|
/** For construct calls, this returns the "new.target" value. */
|
|
115
130
|
V8_INLINE Local<Value> NewTarget() const;
|
|
116
131
|
/** Indicates whether this is a regular call or a construct call. */
|
|
@@ -126,12 +141,16 @@ class FunctionCallbackInfo {
|
|
|
126
141
|
friend class internal::FunctionCallbackArguments;
|
|
127
142
|
friend class internal::CustomArguments<FunctionCallbackInfo>;
|
|
128
143
|
friend class debug::ConsoleCallArguments;
|
|
144
|
+
friend void internal::PrintFunctionCallbackInfo(void*);
|
|
129
145
|
|
|
130
|
-
|
|
146
|
+
// TODO(ishell, http://crbug.com/326505377): in case of non-constructor
|
|
147
|
+
// call, don't pass kNewTarget and kUnused. Add IsConstructCall flag to
|
|
148
|
+
// kIsolate field.
|
|
149
|
+
static constexpr int kUnusedIndex = 0;
|
|
131
150
|
static constexpr int kIsolateIndex = 1;
|
|
132
|
-
static constexpr int
|
|
151
|
+
static constexpr int kContextIndex = 2;
|
|
133
152
|
static constexpr int kReturnValueIndex = 3;
|
|
134
|
-
static constexpr int
|
|
153
|
+
static constexpr int kTargetIndex = 4;
|
|
135
154
|
static constexpr int kNewTargetIndex = 5;
|
|
136
155
|
static constexpr int kArgsLength = 6;
|
|
137
156
|
|
|
@@ -151,9 +170,13 @@ class FunctionCallbackInfo {
|
|
|
151
170
|
|
|
152
171
|
V8_INLINE FunctionCallbackInfo(internal::Address* implicit_args,
|
|
153
172
|
internal::Address* values, int length);
|
|
173
|
+
|
|
174
|
+
// TODO(https://crbug.com/326505377): flatten the v8::FunctionCallbackInfo
|
|
175
|
+
// object to avoid indirect loads through values_ and implicit_args_ and
|
|
176
|
+
// reduce the number of instructions in the CallApiCallback builtin.
|
|
154
177
|
internal::Address* implicit_args_;
|
|
155
178
|
internal::Address* values_;
|
|
156
|
-
|
|
179
|
+
internal::Address length_;
|
|
157
180
|
};
|
|
158
181
|
|
|
159
182
|
/**
|
|
@@ -227,8 +250,23 @@ class PropertyCallbackInfo {
|
|
|
227
250
|
*
|
|
228
251
|
* \note For security reasons, do not pass the object back into the runtime.
|
|
229
252
|
*/
|
|
253
|
+
V8_DEPRECATE_SOON(
|
|
254
|
+
"V8 will stop providing access to hidden prototype (i.e. "
|
|
255
|
+
"JSGlobalObject). Use HolderV2() instead. \n"
|
|
256
|
+
"DO NOT try to workaround this by accessing JSGlobalObject via "
|
|
257
|
+
"v8::Object::GetPrototype() - it'll be deprecated soon too. \n"
|
|
258
|
+
"See http://crbug.com/333672197. ")
|
|
230
259
|
V8_INLINE Local<Object> Holder() const;
|
|
231
260
|
|
|
261
|
+
/**
|
|
262
|
+
* \return The object in the prototype chain of the receiver that has the
|
|
263
|
+
* interceptor. Suppose you have `x` and its prototype is `y`, and `y`
|
|
264
|
+
* has an interceptor. Then `info.This()` is `x` and `info.Holder()` is `y`.
|
|
265
|
+
* In case the property is installed on the global object the Holder()
|
|
266
|
+
* would return the global proxy.
|
|
267
|
+
*/
|
|
268
|
+
V8_INLINE Local<Object> HolderV2() const;
|
|
269
|
+
|
|
232
270
|
/**
|
|
233
271
|
* \return The return value of the callback.
|
|
234
272
|
* Can be changed by calling Set().
|
|
@@ -249,24 +287,28 @@ class PropertyCallbackInfo {
|
|
|
249
287
|
V8_INLINE bool ShouldThrowOnError() const;
|
|
250
288
|
|
|
251
289
|
private:
|
|
290
|
+
template <typename U>
|
|
291
|
+
friend class PropertyCallbackInfo;
|
|
252
292
|
friend class MacroAssembler;
|
|
253
293
|
friend class internal::PropertyCallbackArguments;
|
|
254
294
|
friend class internal::CustomArguments<PropertyCallbackInfo>;
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
static constexpr int
|
|
258
|
-
static constexpr int
|
|
259
|
-
static constexpr int
|
|
260
|
-
static constexpr int
|
|
261
|
-
static constexpr int
|
|
262
|
-
static constexpr int
|
|
295
|
+
friend void internal::PrintPropertyCallbackInfo(void*);
|
|
296
|
+
|
|
297
|
+
static constexpr int kPropertyKeyIndex = 0;
|
|
298
|
+
static constexpr int kShouldThrowOnErrorIndex = 1;
|
|
299
|
+
static constexpr int kHolderIndex = 2;
|
|
300
|
+
static constexpr int kIsolateIndex = 3;
|
|
301
|
+
static constexpr int kHolderV2Index = 4;
|
|
302
|
+
static constexpr int kReturnValueIndex = 5;
|
|
303
|
+
static constexpr int kDataIndex = 6;
|
|
304
|
+
static constexpr int kThisIndex = 7;
|
|
305
|
+
static constexpr int kArgsLength = 8;
|
|
263
306
|
|
|
264
|
-
static constexpr int kSize =
|
|
307
|
+
static constexpr int kSize = kArgsLength * internal::kApiSystemPointerSize;
|
|
265
308
|
|
|
266
|
-
|
|
267
|
-
: args_(args) {}
|
|
309
|
+
PropertyCallbackInfo() = default;
|
|
268
310
|
|
|
269
|
-
internal::Address
|
|
311
|
+
mutable internal::Address args_[kArgsLength];
|
|
270
312
|
};
|
|
271
313
|
|
|
272
314
|
using FunctionCallback = void (*)(const FunctionCallbackInfo<Value>& info);
|
|
@@ -276,73 +318,194 @@ using FunctionCallback = void (*)(const FunctionCallbackInfo<Value>& info);
|
|
|
276
318
|
template <typename T>
|
|
277
319
|
ReturnValue<T>::ReturnValue(internal::Address* slot) : value_(slot) {}
|
|
278
320
|
|
|
321
|
+
template <typename T>
|
|
322
|
+
void ReturnValue<T>::SetInternal(internal::Address value) {
|
|
323
|
+
#if V8_STATIC_ROOTS_BOOL
|
|
324
|
+
using I = internal::Internals;
|
|
325
|
+
// Ensure that the upper 32-bits are not modified. Compiler should be
|
|
326
|
+
// able to optimize this to a store of a lower 32-bits of the value.
|
|
327
|
+
// This is fine since the callback can return only JavaScript values which
|
|
328
|
+
// are either Smis or heap objects allocated in the main cage.
|
|
329
|
+
*value_ = I::DecompressTaggedField(*value_, I::CompressTagged(value));
|
|
330
|
+
#else
|
|
331
|
+
*value_ = value;
|
|
332
|
+
#endif // V8_STATIC_ROOTS_BOOL
|
|
333
|
+
}
|
|
334
|
+
|
|
279
335
|
template <typename T>
|
|
280
336
|
template <typename S>
|
|
281
337
|
void ReturnValue<T>::Set(const Global<S>& handle) {
|
|
282
338
|
static_assert(std::is_base_of<T, S>::value, "type check");
|
|
283
339
|
if (V8_UNLIKELY(handle.IsEmpty())) {
|
|
284
|
-
|
|
340
|
+
SetDefaultValue();
|
|
285
341
|
} else {
|
|
286
|
-
|
|
342
|
+
SetInternal(handle.ptr());
|
|
287
343
|
}
|
|
288
344
|
}
|
|
289
345
|
|
|
346
|
+
template <typename T>
|
|
347
|
+
template <typename S>
|
|
348
|
+
void ReturnValue<T>::SetNonEmpty(const Global<S>& handle) {
|
|
349
|
+
static_assert(std::is_base_of<T, S>::value, "type check");
|
|
350
|
+
#ifdef V8_ENABLE_CHECKS
|
|
351
|
+
internal::VerifyHandleIsNonEmpty(handle.IsEmpty());
|
|
352
|
+
#endif // V8_ENABLE_CHECKS
|
|
353
|
+
SetInternal(handle.ptr());
|
|
354
|
+
}
|
|
355
|
+
|
|
290
356
|
template <typename T>
|
|
291
357
|
template <typename S>
|
|
292
358
|
void ReturnValue<T>::Set(const BasicTracedReference<S>& handle) {
|
|
293
359
|
static_assert(std::is_base_of<T, S>::value, "type check");
|
|
294
360
|
if (V8_UNLIKELY(handle.IsEmpty())) {
|
|
295
|
-
|
|
361
|
+
SetDefaultValue();
|
|
296
362
|
} else {
|
|
297
|
-
|
|
363
|
+
SetInternal(handle.ptr());
|
|
298
364
|
}
|
|
299
365
|
}
|
|
300
366
|
|
|
367
|
+
template <typename T>
|
|
368
|
+
template <typename S>
|
|
369
|
+
void ReturnValue<T>::SetNonEmpty(const BasicTracedReference<S>& handle) {
|
|
370
|
+
static_assert(std::is_base_of<T, S>::value, "type check");
|
|
371
|
+
#ifdef V8_ENABLE_CHECKS
|
|
372
|
+
internal::VerifyHandleIsNonEmpty(handle.IsEmpty());
|
|
373
|
+
#endif // V8_ENABLE_CHECKS
|
|
374
|
+
SetInternal(handle.ptr());
|
|
375
|
+
}
|
|
376
|
+
|
|
301
377
|
template <typename T>
|
|
302
378
|
template <typename S>
|
|
303
379
|
void ReturnValue<T>::Set(const Local<S> handle) {
|
|
304
|
-
|
|
305
|
-
|
|
380
|
+
// "V8_DEPRECATE_SOON" this method if |T| is |void|.
|
|
381
|
+
#ifdef V8_IMMINENT_DEPRECATION_WARNINGS
|
|
382
|
+
static constexpr bool is_allowed_void = false;
|
|
383
|
+
static_assert(!std::is_void<T>::value,
|
|
384
|
+
"ReturnValue<void>::Set(const Local<S>) is deprecated. "
|
|
385
|
+
"Do nothing to indicate that the operation succeeded or use "
|
|
386
|
+
"SetFalse() to indicate that the operation failed (don't "
|
|
387
|
+
"forget to handle info.ShouldThrowOnError()). "
|
|
388
|
+
"See http://crbug.com/348660658 for details.");
|
|
389
|
+
#else
|
|
390
|
+
static constexpr bool is_allowed_void = std::is_void<T>::value;
|
|
391
|
+
#endif // V8_IMMINENT_DEPRECATION_WARNINGS
|
|
392
|
+
static_assert(is_allowed_void || std::is_base_of<T, S>::value, "type check");
|
|
306
393
|
if (V8_UNLIKELY(handle.IsEmpty())) {
|
|
307
|
-
|
|
394
|
+
SetDefaultValue();
|
|
395
|
+
} else if constexpr (is_allowed_void) {
|
|
396
|
+
// Simulate old behaviour for "v8::AccessorSetterCallback" for which
|
|
397
|
+
// it was possible to set the return value even for ReturnValue<void>.
|
|
398
|
+
Set(handle->BooleanValue(GetIsolate()));
|
|
308
399
|
} else {
|
|
309
|
-
|
|
400
|
+
SetInternal(handle.ptr());
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
template <typename T>
|
|
405
|
+
template <typename S>
|
|
406
|
+
void ReturnValue<T>::SetNonEmpty(const Local<S> handle) {
|
|
407
|
+
// "V8_DEPRECATE_SOON" this method if |T| is |void|.
|
|
408
|
+
#ifdef V8_IMMINENT_DEPRECATION_WARNINGS
|
|
409
|
+
static constexpr bool is_allowed_void = false;
|
|
410
|
+
static_assert(!std::is_void<T>::value,
|
|
411
|
+
"ReturnValue<void>::SetNonEmpty(const Local<S>) is deprecated. "
|
|
412
|
+
"Do nothing to indicate that the operation succeeded or use "
|
|
413
|
+
"SetFalse() to indicate that the operation failed (don't "
|
|
414
|
+
"forget to handle info.ShouldThrowOnError()). "
|
|
415
|
+
"See http://crbug.com/348660658 for details.");
|
|
416
|
+
#else
|
|
417
|
+
static constexpr bool is_allowed_void = std::is_void<T>::value;
|
|
418
|
+
#endif // V8_IMMINENT_DEPRECATION_WARNINGS
|
|
419
|
+
static_assert(is_allowed_void || std::is_base_of<T, S>::value, "type check");
|
|
420
|
+
#ifdef V8_ENABLE_CHECKS
|
|
421
|
+
internal::VerifyHandleIsNonEmpty(handle.IsEmpty());
|
|
422
|
+
#endif // V8_ENABLE_CHECKS
|
|
423
|
+
if constexpr (is_allowed_void) {
|
|
424
|
+
// Simulate old behaviour for "v8::AccessorSetterCallback" for which
|
|
425
|
+
// it was possible to set the return value even for ReturnValue<void>.
|
|
426
|
+
Set(handle->BooleanValue(GetIsolate()));
|
|
427
|
+
} else {
|
|
428
|
+
SetInternal(handle.ptr());
|
|
310
429
|
}
|
|
311
430
|
}
|
|
312
431
|
|
|
313
432
|
template <typename T>
|
|
314
433
|
void ReturnValue<T>::Set(double i) {
|
|
315
434
|
static_assert(std::is_base_of<T, Number>::value, "type check");
|
|
316
|
-
|
|
435
|
+
SetNonEmpty(Number::New(GetIsolate(), i));
|
|
317
436
|
}
|
|
318
437
|
|
|
319
438
|
template <typename T>
|
|
320
|
-
void ReturnValue<T>::Set(
|
|
439
|
+
void ReturnValue<T>::Set(int16_t i) {
|
|
321
440
|
static_assert(std::is_base_of<T, Integer>::value, "type check");
|
|
322
441
|
using I = internal::Internals;
|
|
323
|
-
|
|
324
|
-
|
|
442
|
+
static_assert(I::IsValidSmi(std::numeric_limits<int16_t>::min()));
|
|
443
|
+
static_assert(I::IsValidSmi(std::numeric_limits<int16_t>::max()));
|
|
444
|
+
SetInternal(I::IntegralToSmi(i));
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
template <typename T>
|
|
448
|
+
void ReturnValue<T>::Set(int32_t i) {
|
|
449
|
+
static_assert(std::is_base_of<T, Integer>::value, "type check");
|
|
450
|
+
if (const auto result = internal::Internals::TryIntegralToSmi(i)) {
|
|
451
|
+
SetInternal(*result);
|
|
325
452
|
return;
|
|
326
453
|
}
|
|
327
|
-
|
|
454
|
+
SetNonEmpty(Integer::New(GetIsolate(), i));
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
template <typename T>
|
|
458
|
+
void ReturnValue<T>::Set(int64_t i) {
|
|
459
|
+
static_assert(std::is_base_of<T, Integer>::value, "type check");
|
|
460
|
+
if (const auto result = internal::Internals::TryIntegralToSmi(i)) {
|
|
461
|
+
SetInternal(*result);
|
|
462
|
+
return;
|
|
463
|
+
}
|
|
464
|
+
SetNonEmpty(Number::New(GetIsolate(), static_cast<double>(i)));
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
template <typename T>
|
|
468
|
+
void ReturnValue<T>::Set(uint16_t i) {
|
|
469
|
+
static_assert(std::is_base_of<T, Integer>::value, "type check");
|
|
470
|
+
using I = internal::Internals;
|
|
471
|
+
static_assert(I::IsValidSmi(std::numeric_limits<uint16_t>::min()));
|
|
472
|
+
static_assert(I::IsValidSmi(std::numeric_limits<uint16_t>::max()));
|
|
473
|
+
SetInternal(I::IntegralToSmi(i));
|
|
328
474
|
}
|
|
329
475
|
|
|
330
476
|
template <typename T>
|
|
331
477
|
void ReturnValue<T>::Set(uint32_t i) {
|
|
332
478
|
static_assert(std::is_base_of<T, Integer>::value, "type check");
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
479
|
+
if (const auto result = internal::Internals::TryIntegralToSmi(i)) {
|
|
480
|
+
SetInternal(*result);
|
|
481
|
+
return;
|
|
482
|
+
}
|
|
483
|
+
SetNonEmpty(Integer::NewFromUnsigned(GetIsolate(), i));
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
template <typename T>
|
|
487
|
+
void ReturnValue<T>::Set(uint64_t i) {
|
|
488
|
+
static_assert(std::is_base_of<T, Integer>::value, "type check");
|
|
489
|
+
if (const auto result = internal::Internals::TryIntegralToSmi(i)) {
|
|
490
|
+
SetInternal(*result);
|
|
337
491
|
return;
|
|
338
492
|
}
|
|
339
|
-
|
|
493
|
+
SetNonEmpty(Number::New(GetIsolate(), static_cast<double>(i)));
|
|
340
494
|
}
|
|
341
495
|
|
|
342
496
|
template <typename T>
|
|
343
497
|
void ReturnValue<T>::Set(bool value) {
|
|
344
|
-
static_assert(std::is_base_of<T, Boolean>::value,
|
|
498
|
+
static_assert(std::is_void<T>::value || std::is_base_of<T, Boolean>::value,
|
|
499
|
+
"type check");
|
|
345
500
|
using I = internal::Internals;
|
|
501
|
+
#if V8_STATIC_ROOTS_BOOL
|
|
502
|
+
#ifdef V8_ENABLE_CHECKS
|
|
503
|
+
internal::PerformCastCheck(
|
|
504
|
+
internal::ValueHelper::SlotAsValue<Value, true>(value_));
|
|
505
|
+
#endif // V8_ENABLE_CHECKS
|
|
506
|
+
SetInternal(value ? I::StaticReadOnlyRoot::kTrueValue
|
|
507
|
+
: I::StaticReadOnlyRoot::kFalseValue);
|
|
508
|
+
#else
|
|
346
509
|
int root_index;
|
|
347
510
|
if (value) {
|
|
348
511
|
root_index = I::kTrueValueRootIndex;
|
|
@@ -350,27 +513,85 @@ void ReturnValue<T>::Set(bool value) {
|
|
|
350
513
|
root_index = I::kFalseValueRootIndex;
|
|
351
514
|
}
|
|
352
515
|
*value_ = I::GetRoot(GetIsolate(), root_index);
|
|
516
|
+
#endif // V8_STATIC_ROOTS_BOOL
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
template <typename T>
|
|
520
|
+
void ReturnValue<T>::SetDefaultValue() {
|
|
521
|
+
using I = internal::Internals;
|
|
522
|
+
if constexpr (std::is_same_v<void, T> || std::is_same_v<v8::Boolean, T>) {
|
|
523
|
+
Set(true);
|
|
524
|
+
} else if constexpr (std::is_same_v<v8::Integer, T>) {
|
|
525
|
+
SetInternal(I::IntegralToSmi(0));
|
|
526
|
+
} else {
|
|
527
|
+
static_assert(std::is_same_v<v8::Value, T> || std::is_same_v<v8::Array, T>);
|
|
528
|
+
#if V8_STATIC_ROOTS_BOOL
|
|
529
|
+
SetInternal(I::StaticReadOnlyRoot::kUndefinedValue);
|
|
530
|
+
#else
|
|
531
|
+
*value_ = I::GetRoot(GetIsolate(), I::kUndefinedValueRootIndex);
|
|
532
|
+
#endif // V8_STATIC_ROOTS_BOOL
|
|
533
|
+
}
|
|
353
534
|
}
|
|
354
535
|
|
|
355
536
|
template <typename T>
|
|
356
537
|
void ReturnValue<T>::SetNull() {
|
|
357
538
|
static_assert(std::is_base_of<T, Primitive>::value, "type check");
|
|
358
539
|
using I = internal::Internals;
|
|
540
|
+
#if V8_STATIC_ROOTS_BOOL
|
|
541
|
+
#ifdef V8_ENABLE_CHECKS
|
|
542
|
+
internal::PerformCastCheck(
|
|
543
|
+
internal::ValueHelper::SlotAsValue<Value, true>(value_));
|
|
544
|
+
#endif // V8_ENABLE_CHECKS
|
|
545
|
+
SetInternal(I::StaticReadOnlyRoot::kNullValue);
|
|
546
|
+
#else
|
|
359
547
|
*value_ = I::GetRoot(GetIsolate(), I::kNullValueRootIndex);
|
|
548
|
+
#endif // V8_STATIC_ROOTS_BOOL
|
|
360
549
|
}
|
|
361
550
|
|
|
362
551
|
template <typename T>
|
|
363
552
|
void ReturnValue<T>::SetUndefined() {
|
|
364
553
|
static_assert(std::is_base_of<T, Primitive>::value, "type check");
|
|
365
554
|
using I = internal::Internals;
|
|
555
|
+
#if V8_STATIC_ROOTS_BOOL
|
|
556
|
+
#ifdef V8_ENABLE_CHECKS
|
|
557
|
+
internal::PerformCastCheck(
|
|
558
|
+
internal::ValueHelper::SlotAsValue<Value, true>(value_));
|
|
559
|
+
#endif // V8_ENABLE_CHECKS
|
|
560
|
+
SetInternal(I::StaticReadOnlyRoot::kUndefinedValue);
|
|
561
|
+
#else
|
|
366
562
|
*value_ = I::GetRoot(GetIsolate(), I::kUndefinedValueRootIndex);
|
|
563
|
+
#endif // V8_STATIC_ROOTS_BOOL
|
|
564
|
+
}
|
|
565
|
+
|
|
566
|
+
template <typename T>
|
|
567
|
+
void ReturnValue<T>::SetFalse() {
|
|
568
|
+
static_assert(std::is_void<T>::value || std::is_base_of<T, Boolean>::value,
|
|
569
|
+
"type check");
|
|
570
|
+
using I = internal::Internals;
|
|
571
|
+
#if V8_STATIC_ROOTS_BOOL
|
|
572
|
+
#ifdef V8_ENABLE_CHECKS
|
|
573
|
+
internal::PerformCastCheck(
|
|
574
|
+
internal::ValueHelper::SlotAsValue<Value, true>(value_));
|
|
575
|
+
#endif // V8_ENABLE_CHECKS
|
|
576
|
+
SetInternal(I::StaticReadOnlyRoot::kFalseValue);
|
|
577
|
+
#else
|
|
578
|
+
*value_ = I::GetRoot(GetIsolate(), I::kFalseValueRootIndex);
|
|
579
|
+
#endif // V8_STATIC_ROOTS_BOOL
|
|
367
580
|
}
|
|
368
581
|
|
|
369
582
|
template <typename T>
|
|
370
583
|
void ReturnValue<T>::SetEmptyString() {
|
|
371
584
|
static_assert(std::is_base_of<T, String>::value, "type check");
|
|
372
585
|
using I = internal::Internals;
|
|
586
|
+
#if V8_STATIC_ROOTS_BOOL
|
|
587
|
+
#ifdef V8_ENABLE_CHECKS
|
|
588
|
+
internal::PerformCastCheck(
|
|
589
|
+
internal::ValueHelper::SlotAsValue<Value, true>(value_));
|
|
590
|
+
#endif // V8_ENABLE_CHECKS
|
|
591
|
+
SetInternal(I::StaticReadOnlyRoot::kEmptyString);
|
|
592
|
+
#else
|
|
373
593
|
*value_ = I::GetRoot(GetIsolate(), I::kEmptyStringRootIndex);
|
|
594
|
+
#endif // V8_STATIC_ROOTS_BOOL
|
|
374
595
|
}
|
|
375
596
|
|
|
376
597
|
template <typename T>
|
|
@@ -380,15 +601,8 @@ Isolate* ReturnValue<T>::GetIsolate() const {
|
|
|
380
601
|
|
|
381
602
|
template <typename T>
|
|
382
603
|
Local<Value> ReturnValue<T>::Get() const {
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
if (I::is_identical(*value_, I::StaticReadOnlyRoot::kTheHoleValue)) {
|
|
386
|
-
#else
|
|
387
|
-
if (*value_ == I::GetRoot(GetIsolate(), I::kTheHoleValueRootIndex)) {
|
|
388
|
-
#endif
|
|
389
|
-
return Undefined(GetIsolate());
|
|
390
|
-
}
|
|
391
|
-
return Local<Value>::New(GetIsolate(), reinterpret_cast<Value*>(value_));
|
|
604
|
+
return Local<Value>::New(GetIsolate(),
|
|
605
|
+
internal::ValueHelper::SlotAsValue<Value>(value_));
|
|
392
606
|
}
|
|
393
607
|
|
|
394
608
|
template <typename T>
|
|
@@ -397,12 +611,6 @@ void ReturnValue<T>::Set(S* whatever) {
|
|
|
397
611
|
static_assert(sizeof(S) < 0, "incompilable to prevent inadvertent misuse");
|
|
398
612
|
}
|
|
399
613
|
|
|
400
|
-
template <typename T>
|
|
401
|
-
internal::Address ReturnValue<T>::GetDefaultValue() {
|
|
402
|
-
using I = internal::Internals;
|
|
403
|
-
return I::GetRoot(GetIsolate(), I::kTheHoleValueRootIndex);
|
|
404
|
-
}
|
|
405
|
-
|
|
406
614
|
template <typename T>
|
|
407
615
|
FunctionCallbackInfo<T>::FunctionCallbackInfo(internal::Address* implicit_args,
|
|
408
616
|
internal::Address* values,
|
|
@@ -412,7 +620,7 @@ FunctionCallbackInfo<T>::FunctionCallbackInfo(internal::Address* implicit_args,
|
|
|
412
620
|
template <typename T>
|
|
413
621
|
Local<Value> FunctionCallbackInfo<T>::operator[](int i) const {
|
|
414
622
|
// values_ points to the first argument (not the receiver).
|
|
415
|
-
if (i < 0 ||
|
|
623
|
+
if (i < 0 || Length() <= i) return Undefined(GetIsolate());
|
|
416
624
|
return Local<Value>::FromSlot(values_ + i);
|
|
417
625
|
}
|
|
418
626
|
|
|
@@ -422,11 +630,6 @@ Local<Object> FunctionCallbackInfo<T>::This() const {
|
|
|
422
630
|
return Local<Object>::FromSlot(values_ + kThisValuesIndex);
|
|
423
631
|
}
|
|
424
632
|
|
|
425
|
-
template <typename T>
|
|
426
|
-
Local<Object> FunctionCallbackInfo<T>::Holder() const {
|
|
427
|
-
return Local<Object>::FromSlot(&implicit_args_[kHolderIndex]);
|
|
428
|
-
}
|
|
429
|
-
|
|
430
633
|
template <typename T>
|
|
431
634
|
Local<Value> FunctionCallbackInfo<T>::NewTarget() const {
|
|
432
635
|
return Local<Value>::FromSlot(&implicit_args_[kNewTargetIndex]);
|
|
@@ -434,7 +637,8 @@ Local<Value> FunctionCallbackInfo<T>::NewTarget() const {
|
|
|
434
637
|
|
|
435
638
|
template <typename T>
|
|
436
639
|
Local<Value> FunctionCallbackInfo<T>::Data() const {
|
|
437
|
-
|
|
640
|
+
auto target = Local<v8::Data>::FromSlot(&implicit_args_[kTargetIndex]);
|
|
641
|
+
return api_internal::GetFunctionTemplateData(GetIsolate(), target);
|
|
438
642
|
}
|
|
439
643
|
|
|
440
644
|
template <typename T>
|
|
@@ -454,7 +658,7 @@ bool FunctionCallbackInfo<T>::IsConstructCall() const {
|
|
|
454
658
|
|
|
455
659
|
template <typename T>
|
|
456
660
|
int FunctionCallbackInfo<T>::Length() const {
|
|
457
|
-
return length_;
|
|
661
|
+
return static_cast<int>(length_);
|
|
458
662
|
}
|
|
459
663
|
|
|
460
664
|
template <typename T>
|
|
@@ -477,6 +681,23 @@ Local<Object> PropertyCallbackInfo<T>::Holder() const {
|
|
|
477
681
|
return Local<Object>::FromSlot(&args_[kHolderIndex]);
|
|
478
682
|
}
|
|
479
683
|
|
|
684
|
+
namespace api_internal {
|
|
685
|
+
// Returns JSGlobalProxy if holder is JSGlobalObject or unmodified holder
|
|
686
|
+
// otherwise.
|
|
687
|
+
V8_EXPORT internal::Address ConvertToJSGlobalProxyIfNecessary(
|
|
688
|
+
internal::Address holder);
|
|
689
|
+
} // namespace api_internal
|
|
690
|
+
|
|
691
|
+
template <typename T>
|
|
692
|
+
Local<Object> PropertyCallbackInfo<T>::HolderV2() const {
|
|
693
|
+
using I = internal::Internals;
|
|
694
|
+
if (!I::HasHeapObjectTag(args_[kHolderV2Index])) {
|
|
695
|
+
args_[kHolderV2Index] =
|
|
696
|
+
api_internal::ConvertToJSGlobalProxyIfNecessary(args_[kHolderIndex]);
|
|
697
|
+
}
|
|
698
|
+
return Local<Object>::FromSlot(&args_[kHolderV2Index]);
|
|
699
|
+
}
|
|
700
|
+
|
|
480
701
|
template <typename T>
|
|
481
702
|
ReturnValue<T> PropertyCallbackInfo<T>::GetReturnValue() const {
|
|
482
703
|
return ReturnValue<T>(&args_[kReturnValueIndex]);
|
|
@@ -486,8 +707,8 @@ template <typename T>
|
|
|
486
707
|
bool PropertyCallbackInfo<T>::ShouldThrowOnError() const {
|
|
487
708
|
using I = internal::Internals;
|
|
488
709
|
if (args_[kShouldThrowOnErrorIndex] !=
|
|
489
|
-
I::
|
|
490
|
-
return args_[kShouldThrowOnErrorIndex] != I::
|
|
710
|
+
I::IntegralToSmi(I::kInferShouldThrowMode)) {
|
|
711
|
+
return args_[kShouldThrowOnErrorIndex] != I::IntegralToSmi(I::kDontThrow);
|
|
491
712
|
}
|
|
492
713
|
return v8::internal::ShouldThrowOnError(
|
|
493
714
|
reinterpret_cast<v8::internal::Isolate*>(GetIsolate()));
|
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
namespace v8 {
|
|
19
19
|
|
|
20
20
|
class Context;
|
|
21
|
+
class Location;
|
|
21
22
|
class UnboundScript;
|
|
22
23
|
|
|
23
24
|
/**
|
|
@@ -52,6 +53,10 @@ class V8_EXPORT Function : public Object {
|
|
|
52
53
|
Local<Context> context, int argc, Local<Value> argv[],
|
|
53
54
|
SideEffectType side_effect_type = SideEffectType::kHasSideEffect) const;
|
|
54
55
|
|
|
56
|
+
V8_WARN_UNUSED_RESULT MaybeLocal<Value> Call(v8::Isolate* isolate,
|
|
57
|
+
Local<Context> context,
|
|
58
|
+
Local<Value> recv, int argc,
|
|
59
|
+
Local<Value> argv[]);
|
|
55
60
|
V8_WARN_UNUSED_RESULT MaybeLocal<Value> Call(Local<Context> context,
|
|
56
61
|
Local<Value> recv, int argc,
|
|
57
62
|
Local<Value> argv[]);
|
|
@@ -59,9 +64,6 @@ class V8_EXPORT Function : public Object {
|
|
|
59
64
|
void SetName(Local<String> name);
|
|
60
65
|
Local<Value> GetName() const;
|
|
61
66
|
|
|
62
|
-
V8_DEPRECATED("No direct replacement")
|
|
63
|
-
MaybeLocal<UnboundScript> GetUnboundScript() const;
|
|
64
|
-
|
|
65
67
|
/**
|
|
66
68
|
* Name inferred from variable or property assignment of this function.
|
|
67
69
|
* Used to facilitate debugging and profiling of JavaScript code written
|
|
@@ -87,6 +89,12 @@ class V8_EXPORT Function : public Object {
|
|
|
87
89
|
*/
|
|
88
90
|
int GetScriptColumnNumber() const;
|
|
89
91
|
|
|
92
|
+
/**
|
|
93
|
+
* Returns zero based line and column number of function body, else returns
|
|
94
|
+
* {-1, -1}.
|
|
95
|
+
*/
|
|
96
|
+
Location GetScriptLocation() const;
|
|
97
|
+
|
|
90
98
|
/**
|
|
91
99
|
* Returns zero based start position (character offset) of function body and
|
|
92
100
|
* kLineOffsetNotFound if no information available.
|