libv8-node 20.12.1.0-aarch64-linux → 22.5.1.0-aarch64-linux
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/libv8/node/version.rb +3 -3
- data/vendor/v8/aarch64-linux/libv8/obj/libv8_monolith.a +0 -0
- data/vendor/v8/include/cppgc/internal/api-constants.h +24 -5
- data/vendor/v8/include/cppgc/internal/caged-heap-local-data.h +16 -6
- data/vendor/v8/include/cppgc/internal/caged-heap.h +12 -5
- data/vendor/v8/include/cppgc/internal/gc-info.h +82 -91
- data/vendor/v8/include/cppgc/internal/member-storage.h +16 -8
- data/vendor/v8/include/cppgc/member.h +25 -0
- data/vendor/v8/include/cppgc/persistent.h +4 -0
- data/vendor/v8/include/cppgc/platform.h +6 -1
- data/vendor/v8/include/cppgc/sentinel-pointer.h +7 -0
- data/vendor/v8/include/cppgc/source-location.h +2 -78
- data/vendor/v8/include/cppgc/trace-trait.h +8 -0
- data/vendor/v8/include/cppgc/type-traits.h +25 -4
- data/vendor/v8/include/cppgc/visitor.h +82 -4
- data/vendor/v8/include/libplatform/libplatform.h +7 -1
- data/vendor/v8/include/v8-array-buffer.h +6 -0
- data/vendor/v8/include/v8-callbacks.h +57 -19
- data/vendor/v8/include/v8-container.h +54 -0
- data/vendor/v8/include/v8-context.h +58 -32
- data/vendor/v8/include/v8-embedder-heap.h +31 -3
- data/vendor/v8/include/v8-embedder-state-scope.h +2 -1
- data/vendor/v8/include/v8-exception.h +15 -9
- data/vendor/v8/include/v8-fast-api-calls.h +58 -31
- data/vendor/v8/include/v8-forward.h +1 -0
- data/vendor/v8/include/v8-function-callback.h +135 -30
- data/vendor/v8/include/v8-function.h +6 -0
- data/vendor/v8/include/v8-handle-base.h +137 -0
- data/vendor/v8/include/v8-inspector.h +35 -13
- data/vendor/v8/include/v8-internal.h +510 -71
- data/vendor/v8/include/v8-isolate.h +176 -100
- data/vendor/v8/include/v8-local-handle.h +383 -112
- data/vendor/v8/include/v8-memory-span.h +157 -2
- data/vendor/v8/include/v8-message.h +22 -3
- data/vendor/v8/include/v8-metrics.h +1 -0
- data/vendor/v8/include/v8-object.h +98 -77
- data/vendor/v8/include/v8-persistent-handle.h +68 -90
- data/vendor/v8/include/v8-platform.h +191 -23
- data/vendor/v8/include/v8-primitive.h +12 -8
- data/vendor/v8/include/v8-profiler.h +16 -2
- data/vendor/v8/include/v8-script.h +88 -14
- data/vendor/v8/include/v8-snapshot.h +96 -22
- data/vendor/v8/include/v8-source-location.h +92 -0
- data/vendor/v8/include/v8-statistics.h +31 -10
- data/vendor/v8/include/v8-template.h +410 -131
- data/vendor/v8/include/v8-traced-handle.h +108 -90
- data/vendor/v8/include/v8-typed-array.h +115 -7
- data/vendor/v8/include/v8-unwinder.h +1 -1
- data/vendor/v8/include/v8-util.h +23 -20
- data/vendor/v8/include/v8-value-serializer.h +14 -0
- data/vendor/v8/include/v8-value.h +105 -3
- data/vendor/v8/include/v8-version.h +4 -4
- data/vendor/v8/include/v8config.h +54 -20
- metadata +4 -2
@@ -30,14 +30,21 @@ class ThreadLocalTop;
|
|
30
30
|
*/
|
31
31
|
class V8_EXPORT Exception {
|
32
32
|
public:
|
33
|
-
static Local<Value> RangeError(Local<String> message
|
34
|
-
|
35
|
-
static Local<Value>
|
36
|
-
|
37
|
-
static Local<Value>
|
38
|
-
|
39
|
-
static Local<Value>
|
40
|
-
|
33
|
+
static Local<Value> RangeError(Local<String> message,
|
34
|
+
Local<Value> options = {});
|
35
|
+
static Local<Value> ReferenceError(Local<String> message,
|
36
|
+
Local<Value> options = {});
|
37
|
+
static Local<Value> SyntaxError(Local<String> message,
|
38
|
+
Local<Value> options = {});
|
39
|
+
static Local<Value> TypeError(Local<String> message,
|
40
|
+
Local<Value> options = {});
|
41
|
+
static Local<Value> WasmCompileError(Local<String> message,
|
42
|
+
Local<Value> options = {});
|
43
|
+
static Local<Value> WasmLinkError(Local<String> message,
|
44
|
+
Local<Value> options = {});
|
45
|
+
static Local<Value> WasmRuntimeError(Local<String> message,
|
46
|
+
Local<Value> options = {});
|
47
|
+
static Local<Value> Error(Local<String> message, Local<Value> options = {});
|
41
48
|
|
42
49
|
/**
|
43
50
|
* Creates an error message for the given exception.
|
@@ -206,7 +213,6 @@ class V8_EXPORT TryCatch {
|
|
206
213
|
bool can_continue_ : 1;
|
207
214
|
bool capture_message_ : 1;
|
208
215
|
bool rethrow_ : 1;
|
209
|
-
bool has_terminated_ : 1;
|
210
216
|
|
211
217
|
friend class internal::Isolate;
|
212
218
|
friend class internal::ThreadLocalTop;
|
@@ -254,8 +254,8 @@ class CTypeInfo {
|
|
254
254
|
// migrated from v8::ApiObject to v8::Local<v8::Value>.
|
255
255
|
kAny, // This is added to enable untyped representation of fast
|
256
256
|
// call arguments for test purposes. It can represent any of
|
257
|
-
// the other types stored in the same memory as a union
|
258
|
-
//
|
257
|
+
// the other types stored in the same memory as a union
|
258
|
+
// (see AnyCType declared below). This allows for
|
259
259
|
// uniform passing of arguments w.r.t. their location
|
260
260
|
// (in a register or on the stack), independent of their
|
261
261
|
// actual type. It's currently used by the arm64 simulator
|
@@ -344,7 +344,8 @@ struct FastApiTypedArray : public FastApiTypedArrayBase {
|
|
344
344
|
ValidateIndex(index);
|
345
345
|
#endif // DEBUG
|
346
346
|
T tmp;
|
347
|
-
memcpy(&tmp, reinterpret_cast<T*>(data_) + index,
|
347
|
+
memcpy(&tmp, static_cast<void*>(reinterpret_cast<T*>(data_) + index),
|
348
|
+
sizeof(T));
|
348
349
|
return tmp;
|
349
350
|
}
|
350
351
|
|
@@ -388,13 +389,19 @@ struct FastOneByteString {
|
|
388
389
|
|
389
390
|
class V8_EXPORT CFunctionInfo {
|
390
391
|
public:
|
392
|
+
enum class Int64Representation : uint8_t {
|
393
|
+
kNumber = 0, // Use numbers to represent 64 bit integers.
|
394
|
+
kBigInt = 1, // Use BigInts to represent 64 bit integers.
|
395
|
+
};
|
396
|
+
|
391
397
|
// Construct a struct to hold a CFunction's type information.
|
392
398
|
// |return_info| describes the function's return type.
|
393
399
|
// |arg_info| is an array of |arg_count| CTypeInfos describing the
|
394
400
|
// arguments. Only the last argument may be of the special type
|
395
401
|
// CTypeInfo::kCallbackOptionsType.
|
396
402
|
CFunctionInfo(const CTypeInfo& return_info, unsigned int arg_count,
|
397
|
-
const CTypeInfo* arg_info
|
403
|
+
const CTypeInfo* arg_info,
|
404
|
+
Int64Representation repr = Int64Representation::kNumber);
|
398
405
|
|
399
406
|
const CTypeInfo& ReturnInfo() const { return return_info_; }
|
400
407
|
|
@@ -404,6 +411,8 @@ class V8_EXPORT CFunctionInfo {
|
|
404
411
|
return HasOptions() ? arg_count_ - 1 : arg_count_;
|
405
412
|
}
|
406
413
|
|
414
|
+
Int64Representation GetInt64Representation() const { return repr_; }
|
415
|
+
|
407
416
|
// |index| must be less than ArgumentCount().
|
408
417
|
// Note: if the last argument passed on construction of CFunctionInfo
|
409
418
|
// has type CTypeInfo::kCallbackOptionsType, it is not included in
|
@@ -418,6 +427,7 @@ class V8_EXPORT CFunctionInfo {
|
|
418
427
|
|
419
428
|
private:
|
420
429
|
const CTypeInfo return_info_;
|
430
|
+
const Int64Representation repr_;
|
421
431
|
const unsigned int arg_count_;
|
422
432
|
const CTypeInfo* arg_info_;
|
423
433
|
};
|
@@ -425,35 +435,43 @@ class V8_EXPORT CFunctionInfo {
|
|
425
435
|
struct FastApiCallbackOptions;
|
426
436
|
|
427
437
|
// Provided for testing.
|
428
|
-
|
438
|
+
union V8_TRIVIAL_ABI AnyCType {
|
429
439
|
AnyCType() : int64_value(0) {}
|
430
440
|
|
431
|
-
|
432
|
-
|
433
|
-
|
434
|
-
|
435
|
-
|
436
|
-
|
437
|
-
|
438
|
-
|
439
|
-
|
440
|
-
|
441
|
-
|
442
|
-
|
443
|
-
|
444
|
-
|
445
|
-
|
446
|
-
|
447
|
-
|
448
|
-
|
449
|
-
|
450
|
-
|
451
|
-
|
441
|
+
#if defined(V8_ENABLE_LOCAL_OFF_STACK_CHECK) && V8_HAS_ATTRIBUTE_TRIVIAL_ABI
|
442
|
+
// In this case, Local<T> is not trivially copyable and the implicit
|
443
|
+
// copy constructor and copy assignment for the union are deleted.
|
444
|
+
AnyCType(const AnyCType& other) : int64_value(other.int64_value) {}
|
445
|
+
AnyCType& operator=(const AnyCType& other) {
|
446
|
+
int64_value = other.int64_value;
|
447
|
+
return *this;
|
448
|
+
}
|
449
|
+
#endif
|
450
|
+
|
451
|
+
bool bool_value;
|
452
|
+
int32_t int32_value;
|
453
|
+
uint32_t uint32_value;
|
454
|
+
int64_t int64_value;
|
455
|
+
uint64_t uint64_value;
|
456
|
+
float float_value;
|
457
|
+
double double_value;
|
458
|
+
void* pointer_value;
|
459
|
+
Local<Object> object_value;
|
460
|
+
Local<Array> sequence_value;
|
461
|
+
const FastApiTypedArray<uint8_t>* uint8_ta_value;
|
462
|
+
const FastApiTypedArray<int32_t>* int32_ta_value;
|
463
|
+
const FastApiTypedArray<uint32_t>* uint32_ta_value;
|
464
|
+
const FastApiTypedArray<int64_t>* int64_ta_value;
|
465
|
+
const FastApiTypedArray<uint64_t>* uint64_ta_value;
|
466
|
+
const FastApiTypedArray<float>* float_ta_value;
|
467
|
+
const FastApiTypedArray<double>* double_ta_value;
|
468
|
+
const FastOneByteString* string_value;
|
469
|
+
FastApiCallbackOptions* options_value;
|
452
470
|
};
|
453
471
|
|
454
472
|
static_assert(
|
455
473
|
sizeof(AnyCType) == 8,
|
456
|
-
"The AnyCType
|
474
|
+
"The union AnyCType should have size == 64 bits, as this is assumed "
|
457
475
|
"by EffectControlLinearizer.");
|
458
476
|
|
459
477
|
class V8_EXPORT CFunction {
|
@@ -469,6 +487,9 @@ class V8_EXPORT CFunction {
|
|
469
487
|
unsigned int ArgumentCount() const { return type_info_->ArgumentCount(); }
|
470
488
|
|
471
489
|
const void* GetAddress() const { return address_; }
|
490
|
+
CFunctionInfo::Int64Representation GetInt64Representation() const {
|
491
|
+
return type_info_->GetInt64Representation();
|
492
|
+
}
|
472
493
|
const CFunctionInfo* GetTypeInfo() const { return type_info_; }
|
473
494
|
|
474
495
|
enum class OverloadResolution { kImpossible, kAtRuntime, kAtCompileTime };
|
@@ -598,7 +619,8 @@ struct count<T, T, Args...>
|
|
598
619
|
template <typename T, typename U, typename... Args>
|
599
620
|
struct count<T, U, Args...> : count<T, Args...> {};
|
600
621
|
|
601
|
-
template <
|
622
|
+
template <CFunctionInfo::Int64Representation Representation,
|
623
|
+
typename RetBuilder, typename... ArgBuilders>
|
602
624
|
class CFunctionInfoImpl : public CFunctionInfo {
|
603
625
|
static constexpr int kOptionsArgCount =
|
604
626
|
count<FastApiCallbackOptions&, ArgBuilders...>();
|
@@ -613,18 +635,20 @@ class CFunctionInfoImpl : public CFunctionInfo {
|
|
613
635
|
public:
|
614
636
|
constexpr CFunctionInfoImpl()
|
615
637
|
: CFunctionInfo(RetBuilder::Build(), sizeof...(ArgBuilders),
|
616
|
-
arg_info_storage_),
|
638
|
+
arg_info_storage_, Representation),
|
617
639
|
arg_info_storage_{ArgBuilders::Build()...} {
|
618
640
|
constexpr CTypeInfo::Type kReturnType = RetBuilder::Build().GetType();
|
619
641
|
static_assert(kReturnType == CTypeInfo::Type::kVoid ||
|
620
642
|
kReturnType == CTypeInfo::Type::kBool ||
|
621
643
|
kReturnType == CTypeInfo::Type::kInt32 ||
|
622
644
|
kReturnType == CTypeInfo::Type::kUint32 ||
|
645
|
+
kReturnType == CTypeInfo::Type::kInt64 ||
|
646
|
+
kReturnType == CTypeInfo::Type::kUint64 ||
|
623
647
|
kReturnType == CTypeInfo::Type::kFloat32 ||
|
624
648
|
kReturnType == CTypeInfo::Type::kFloat64 ||
|
625
649
|
kReturnType == CTypeInfo::Type::kPointer ||
|
626
650
|
kReturnType == CTypeInfo::Type::kAny,
|
627
|
-
"
|
651
|
+
"String and api object values are not currently "
|
628
652
|
"supported return types.");
|
629
653
|
}
|
630
654
|
|
@@ -845,8 +869,11 @@ class CFunctionBuilderWithFunction {
|
|
845
869
|
return *this;
|
846
870
|
}
|
847
871
|
|
872
|
+
template <CFunctionInfo::Int64Representation Representation =
|
873
|
+
CFunctionInfo::Int64Representation::kNumber>
|
848
874
|
auto Build() {
|
849
|
-
static CFunctionInfoImpl<RetBuilder, ArgBuilders...>
|
875
|
+
static CFunctionInfoImpl<Representation, RetBuilder, ArgBuilders...>
|
876
|
+
instance;
|
850
877
|
return CFunction(fn_, &instance);
|
851
878
|
}
|
852
879
|
|
@@ -5,6 +5,9 @@
|
|
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
|
+
|
8
11
|
#include "v8-local-handle.h" // NOLINT(build/include_directory)
|
9
12
|
#include "v8-primitive.h" // NOLINT(build/include_directory)
|
10
13
|
#include "v8config.h" // NOLINT(build/include_directory)
|
@@ -39,14 +42,21 @@ class ReturnValue {
|
|
39
42
|
template <typename S>
|
40
43
|
V8_INLINE void Set(const Global<S>& handle);
|
41
44
|
template <typename S>
|
45
|
+
V8_INLINE void SetNonEmpty(const Global<S>& handle);
|
46
|
+
template <typename S>
|
42
47
|
V8_INLINE void Set(const BasicTracedReference<S>& handle);
|
43
48
|
template <typename S>
|
49
|
+
V8_INLINE void SetNonEmpty(const BasicTracedReference<S>& handle);
|
50
|
+
template <typename S>
|
44
51
|
V8_INLINE void Set(const Local<S> handle);
|
52
|
+
template <typename S>
|
53
|
+
V8_INLINE void SetNonEmpty(const Local<S> handle);
|
45
54
|
// Fast primitive setters
|
46
55
|
V8_INLINE void Set(bool value);
|
47
56
|
V8_INLINE void Set(double i);
|
48
57
|
V8_INLINE void Set(int32_t i);
|
49
58
|
V8_INLINE void Set(uint32_t i);
|
59
|
+
V8_INLINE void Set(uint16_t);
|
50
60
|
// Fast JS primitive setters
|
51
61
|
V8_INLINE void SetNull();
|
52
62
|
V8_INLINE void SetUndefined();
|
@@ -72,13 +82,19 @@ class ReturnValue {
|
|
72
82
|
friend class PropertyCallbackInfo;
|
73
83
|
template <class F, class G, class H>
|
74
84
|
friend class PersistentValueMapBase;
|
75
|
-
V8_INLINE void SetInternal(internal::Address value)
|
76
|
-
|
85
|
+
V8_INLINE void SetInternal(internal::Address value);
|
86
|
+
// Setting the hole value has different meanings depending on the usage:
|
87
|
+
// - for function template callbacks it means that the callback returns
|
88
|
+
// the undefined value,
|
89
|
+
// - for property getter callbacks is means that the callback returns
|
90
|
+
// the undefined value (for property setter callbacks the value returned
|
91
|
+
// is ignored),
|
92
|
+
// - for interceptor callbacks it means that the request was not handled.
|
93
|
+
V8_INLINE void SetTheHole();
|
77
94
|
V8_INLINE explicit ReturnValue(internal::Address* slot);
|
78
95
|
|
79
96
|
// See FunctionCallbackInfo.
|
80
97
|
static constexpr int kIsolateValueIndex = -2;
|
81
|
-
static constexpr int kDefaultValueValueIndex = -1;
|
82
98
|
|
83
99
|
internal::Address* value_;
|
84
100
|
};
|
@@ -127,16 +143,16 @@ class FunctionCallbackInfo {
|
|
127
143
|
friend class internal::FunctionCallbackArguments;
|
128
144
|
friend class internal::CustomArguments<FunctionCallbackInfo>;
|
129
145
|
friend class debug::ConsoleCallArguments;
|
130
|
-
|
146
|
+
|
131
147
|
static constexpr int kHolderIndex = 0;
|
132
148
|
static constexpr int kIsolateIndex = 1;
|
133
|
-
static constexpr int
|
149
|
+
static constexpr int kUnusedIndex = 2;
|
134
150
|
static constexpr int kReturnValueIndex = 3;
|
135
151
|
static constexpr int kDataIndex = 4;
|
136
152
|
static constexpr int kNewTargetIndex = 5;
|
137
|
-
|
138
153
|
static constexpr int kArgsLength = 6;
|
139
|
-
|
154
|
+
|
155
|
+
static constexpr int kArgsLengthWithReceiver = kArgsLength + 1;
|
140
156
|
|
141
157
|
// Codegen constants:
|
142
158
|
static constexpr int kSize = 3 * internal::kApiSystemPointerSize;
|
@@ -147,8 +163,6 @@ class FunctionCallbackInfo {
|
|
147
163
|
kValuesOffset + internal::kApiSystemPointerSize;
|
148
164
|
|
149
165
|
static constexpr int kThisValuesIndex = -1;
|
150
|
-
static_assert(ReturnValue<Value>::kDefaultValueValueIndex ==
|
151
|
-
kReturnValueDefaultValueIndex - kReturnValueIndex);
|
152
166
|
static_assert(ReturnValue<Value>::kIsolateValueIndex ==
|
153
167
|
kIsolateIndex - kReturnValueIndex);
|
154
168
|
|
@@ -258,17 +272,17 @@ class PropertyCallbackInfo {
|
|
258
272
|
static constexpr int kShouldThrowOnErrorIndex = 0;
|
259
273
|
static constexpr int kHolderIndex = 1;
|
260
274
|
static constexpr int kIsolateIndex = 2;
|
261
|
-
static constexpr int
|
275
|
+
static constexpr int kUnusedIndex = 3;
|
262
276
|
static constexpr int kReturnValueIndex = 4;
|
263
277
|
static constexpr int kDataIndex = 5;
|
264
278
|
static constexpr int kThisIndex = 6;
|
265
|
-
|
266
279
|
static constexpr int kArgsLength = 7;
|
267
280
|
|
268
281
|
static constexpr int kSize = 1 * internal::kApiSystemPointerSize;
|
269
282
|
|
270
283
|
V8_INLINE explicit PropertyCallbackInfo(internal::Address* args)
|
271
284
|
: args_(args) {}
|
285
|
+
|
272
286
|
internal::Address* args_;
|
273
287
|
};
|
274
288
|
|
@@ -279,44 +293,89 @@ using FunctionCallback = void (*)(const FunctionCallbackInfo<Value>& info);
|
|
279
293
|
template <typename T>
|
280
294
|
ReturnValue<T>::ReturnValue(internal::Address* slot) : value_(slot) {}
|
281
295
|
|
296
|
+
template <typename T>
|
297
|
+
void ReturnValue<T>::SetInternal(internal::Address value) {
|
298
|
+
#if V8_STATIC_ROOTS_BOOL
|
299
|
+
using I = internal::Internals;
|
300
|
+
// Ensure that the upper 32-bits are not modified. Compiler should be
|
301
|
+
// able to optimize this to a store of a lower 32-bits of the value.
|
302
|
+
// This is fine since the callback can return only JavaScript values which
|
303
|
+
// are either Smis or heap objects allocated in the main cage.
|
304
|
+
*value_ = I::DecompressTaggedField(*value_, I::CompressTagged(value));
|
305
|
+
#else
|
306
|
+
*value_ = value;
|
307
|
+
#endif // V8_STATIC_ROOTS_BOOL
|
308
|
+
}
|
309
|
+
|
282
310
|
template <typename T>
|
283
311
|
template <typename S>
|
284
312
|
void ReturnValue<T>::Set(const Global<S>& handle) {
|
285
313
|
static_assert(std::is_base_of<T, S>::value, "type check");
|
286
314
|
if (V8_UNLIKELY(handle.IsEmpty())) {
|
287
|
-
|
315
|
+
SetTheHole();
|
288
316
|
} else {
|
289
|
-
|
317
|
+
SetInternal(handle.ptr());
|
290
318
|
}
|
291
319
|
}
|
292
320
|
|
321
|
+
template <typename T>
|
322
|
+
template <typename S>
|
323
|
+
void ReturnValue<T>::SetNonEmpty(const Global<S>& handle) {
|
324
|
+
static_assert(std::is_base_of<T, S>::value, "type check");
|
325
|
+
#ifdef V8_ENABLE_CHECKS
|
326
|
+
internal::VerifyHandleIsNonEmpty(handle.IsEmpty());
|
327
|
+
#endif // V8_ENABLE_CHECKS
|
328
|
+
SetInternal(handle.ptr());
|
329
|
+
}
|
330
|
+
|
293
331
|
template <typename T>
|
294
332
|
template <typename S>
|
295
333
|
void ReturnValue<T>::Set(const BasicTracedReference<S>& handle) {
|
296
334
|
static_assert(std::is_base_of<T, S>::value, "type check");
|
297
335
|
if (V8_UNLIKELY(handle.IsEmpty())) {
|
298
|
-
|
336
|
+
SetTheHole();
|
299
337
|
} else {
|
300
|
-
|
338
|
+
SetInternal(handle.ptr());
|
301
339
|
}
|
302
340
|
}
|
303
341
|
|
342
|
+
template <typename T>
|
343
|
+
template <typename S>
|
344
|
+
void ReturnValue<T>::SetNonEmpty(const BasicTracedReference<S>& handle) {
|
345
|
+
static_assert(std::is_base_of<T, S>::value, "type check");
|
346
|
+
#ifdef V8_ENABLE_CHECKS
|
347
|
+
internal::VerifyHandleIsNonEmpty(handle.IsEmpty());
|
348
|
+
#endif // V8_ENABLE_CHECKS
|
349
|
+
SetInternal(handle.ptr());
|
350
|
+
}
|
351
|
+
|
304
352
|
template <typename T>
|
305
353
|
template <typename S>
|
306
354
|
void ReturnValue<T>::Set(const Local<S> handle) {
|
307
355
|
static_assert(std::is_void<T>::value || std::is_base_of<T, S>::value,
|
308
356
|
"type check");
|
309
357
|
if (V8_UNLIKELY(handle.IsEmpty())) {
|
310
|
-
|
358
|
+
SetTheHole();
|
311
359
|
} else {
|
312
|
-
|
360
|
+
SetInternal(handle.ptr());
|
313
361
|
}
|
314
362
|
}
|
315
363
|
|
364
|
+
template <typename T>
|
365
|
+
template <typename S>
|
366
|
+
void ReturnValue<T>::SetNonEmpty(const Local<S> handle) {
|
367
|
+
static_assert(std::is_void<T>::value || std::is_base_of<T, S>::value,
|
368
|
+
"type check");
|
369
|
+
#ifdef V8_ENABLE_CHECKS
|
370
|
+
internal::VerifyHandleIsNonEmpty(handle.IsEmpty());
|
371
|
+
#endif // V8_ENABLE_CHECKS
|
372
|
+
SetInternal(handle.ptr());
|
373
|
+
}
|
374
|
+
|
316
375
|
template <typename T>
|
317
376
|
void ReturnValue<T>::Set(double i) {
|
318
377
|
static_assert(std::is_base_of<T, Number>::value, "type check");
|
319
|
-
|
378
|
+
SetNonEmpty(Number::New(GetIsolate(), i));
|
320
379
|
}
|
321
380
|
|
322
381
|
template <typename T>
|
@@ -324,10 +383,10 @@ void ReturnValue<T>::Set(int32_t i) {
|
|
324
383
|
static_assert(std::is_base_of<T, Integer>::value, "type check");
|
325
384
|
using I = internal::Internals;
|
326
385
|
if (V8_LIKELY(I::IsValidSmi(i))) {
|
327
|
-
|
386
|
+
SetInternal(I::IntToSmi(i));
|
328
387
|
return;
|
329
388
|
}
|
330
|
-
|
389
|
+
SetNonEmpty(Integer::New(GetIsolate(), i));
|
331
390
|
}
|
332
391
|
|
333
392
|
template <typename T>
|
@@ -339,13 +398,30 @@ void ReturnValue<T>::Set(uint32_t i) {
|
|
339
398
|
Set(static_cast<int32_t>(i));
|
340
399
|
return;
|
341
400
|
}
|
342
|
-
|
401
|
+
SetNonEmpty(Integer::NewFromUnsigned(GetIsolate(), i));
|
402
|
+
}
|
403
|
+
|
404
|
+
template <typename T>
|
405
|
+
void ReturnValue<T>::Set(uint16_t i) {
|
406
|
+
static_assert(std::is_base_of<T, Integer>::value, "type check");
|
407
|
+
using I = internal::Internals;
|
408
|
+
static_assert(I::IsValidSmi(std::numeric_limits<uint16_t>::min()));
|
409
|
+
static_assert(I::IsValidSmi(std::numeric_limits<uint16_t>::max()));
|
410
|
+
SetInternal(I::IntToSmi(i));
|
343
411
|
}
|
344
412
|
|
345
413
|
template <typename T>
|
346
414
|
void ReturnValue<T>::Set(bool value) {
|
347
415
|
static_assert(std::is_base_of<T, Boolean>::value, "type check");
|
348
416
|
using I = internal::Internals;
|
417
|
+
#if V8_STATIC_ROOTS_BOOL
|
418
|
+
#ifdef V8_ENABLE_CHECKS
|
419
|
+
internal::PerformCastCheck(
|
420
|
+
internal::ValueHelper::SlotAsValue<Value, true>(value_));
|
421
|
+
#endif // V8_ENABLE_CHECKS
|
422
|
+
SetInternal(value ? I::StaticReadOnlyRoot::kTrueValue
|
423
|
+
: I::StaticReadOnlyRoot::kFalseValue);
|
424
|
+
#else
|
349
425
|
int root_index;
|
350
426
|
if (value) {
|
351
427
|
root_index = I::kTrueValueRootIndex;
|
@@ -353,32 +429,66 @@ void ReturnValue<T>::Set(bool value) {
|
|
353
429
|
root_index = I::kFalseValueRootIndex;
|
354
430
|
}
|
355
431
|
*value_ = I::GetRoot(GetIsolate(), root_index);
|
432
|
+
#endif // V8_STATIC_ROOTS_BOOL
|
433
|
+
}
|
434
|
+
|
435
|
+
template <typename T>
|
436
|
+
void ReturnValue<T>::SetTheHole() {
|
437
|
+
using I = internal::Internals;
|
438
|
+
#if V8_STATIC_ROOTS_BOOL
|
439
|
+
SetInternal(I::StaticReadOnlyRoot::kTheHoleValue);
|
440
|
+
#else
|
441
|
+
*value_ = I::GetRoot(GetIsolate(), I::kTheHoleValueRootIndex);
|
442
|
+
#endif // V8_STATIC_ROOTS_BOOL
|
356
443
|
}
|
357
444
|
|
358
445
|
template <typename T>
|
359
446
|
void ReturnValue<T>::SetNull() {
|
360
447
|
static_assert(std::is_base_of<T, Primitive>::value, "type check");
|
361
448
|
using I = internal::Internals;
|
449
|
+
#if V8_STATIC_ROOTS_BOOL
|
450
|
+
#ifdef V8_ENABLE_CHECKS
|
451
|
+
internal::PerformCastCheck(
|
452
|
+
internal::ValueHelper::SlotAsValue<Value, true>(value_));
|
453
|
+
#endif // V8_ENABLE_CHECKS
|
454
|
+
SetInternal(I::StaticReadOnlyRoot::kNullValue);
|
455
|
+
#else
|
362
456
|
*value_ = I::GetRoot(GetIsolate(), I::kNullValueRootIndex);
|
457
|
+
#endif // V8_STATIC_ROOTS_BOOL
|
363
458
|
}
|
364
459
|
|
365
460
|
template <typename T>
|
366
461
|
void ReturnValue<T>::SetUndefined() {
|
367
462
|
static_assert(std::is_base_of<T, Primitive>::value, "type check");
|
368
463
|
using I = internal::Internals;
|
464
|
+
#if V8_STATIC_ROOTS_BOOL
|
465
|
+
#ifdef V8_ENABLE_CHECKS
|
466
|
+
internal::PerformCastCheck(
|
467
|
+
internal::ValueHelper::SlotAsValue<Value, true>(value_));
|
468
|
+
#endif // V8_ENABLE_CHECKS
|
469
|
+
SetInternal(I::StaticReadOnlyRoot::kUndefinedValue);
|
470
|
+
#else
|
369
471
|
*value_ = I::GetRoot(GetIsolate(), I::kUndefinedValueRootIndex);
|
472
|
+
#endif // V8_STATIC_ROOTS_BOOL
|
370
473
|
}
|
371
474
|
|
372
475
|
template <typename T>
|
373
476
|
void ReturnValue<T>::SetEmptyString() {
|
374
477
|
static_assert(std::is_base_of<T, String>::value, "type check");
|
375
478
|
using I = internal::Internals;
|
479
|
+
#if V8_STATIC_ROOTS_BOOL
|
480
|
+
#ifdef V8_ENABLE_CHECKS
|
481
|
+
internal::PerformCastCheck(
|
482
|
+
internal::ValueHelper::SlotAsValue<Value, true>(value_));
|
483
|
+
#endif // V8_ENABLE_CHECKS
|
484
|
+
SetInternal(I::StaticReadOnlyRoot::kEmptyString);
|
485
|
+
#else
|
376
486
|
*value_ = I::GetRoot(GetIsolate(), I::kEmptyStringRootIndex);
|
487
|
+
#endif // V8_STATIC_ROOTS_BOOL
|
377
488
|
}
|
378
489
|
|
379
490
|
template <typename T>
|
380
491
|
Isolate* ReturnValue<T>::GetIsolate() const {
|
381
|
-
// Isolate is always the pointer below the default value on the stack.
|
382
492
|
return *reinterpret_cast<Isolate**>(&value_[kIsolateValueIndex]);
|
383
493
|
}
|
384
494
|
|
@@ -389,10 +499,11 @@ Local<Value> ReturnValue<T>::Get() const {
|
|
389
499
|
if (I::is_identical(*value_, I::StaticReadOnlyRoot::kTheHoleValue)) {
|
390
500
|
#else
|
391
501
|
if (*value_ == I::GetRoot(GetIsolate(), I::kTheHoleValueRootIndex)) {
|
392
|
-
#endif
|
502
|
+
#endif // V8_STATIC_ROOTS_BOOL
|
393
503
|
return Undefined(GetIsolate());
|
394
504
|
}
|
395
|
-
return Local<Value>::New(GetIsolate(),
|
505
|
+
return Local<Value>::New(GetIsolate(),
|
506
|
+
internal::ValueHelper::SlotAsValue<Value>(value_));
|
396
507
|
}
|
397
508
|
|
398
509
|
template <typename T>
|
@@ -401,12 +512,6 @@ void ReturnValue<T>::Set(S* whatever) {
|
|
401
512
|
static_assert(sizeof(S) < 0, "incompilable to prevent inadvertent misuse");
|
402
513
|
}
|
403
514
|
|
404
|
-
template <typename T>
|
405
|
-
internal::Address ReturnValue<T>::GetDefaultValue() {
|
406
|
-
// Default value is always the pointer below value_ on the stack.
|
407
|
-
return value_[kDefaultValueValueIndex];
|
408
|
-
}
|
409
|
-
|
410
515
|
template <typename T>
|
411
516
|
FunctionCallbackInfo<T>::FunctionCallbackInfo(internal::Address* implicit_args,
|
412
517
|
internal::Address* values,
|
@@ -87,6 +87,12 @@ class V8_EXPORT Function : public Object {
|
|
87
87
|
*/
|
88
88
|
int GetScriptColumnNumber() const;
|
89
89
|
|
90
|
+
/**
|
91
|
+
* Returns zero based start position (character offset) of function body and
|
92
|
+
* kLineOffsetNotFound if no information available.
|
93
|
+
*/
|
94
|
+
int GetScriptStartPosition() const;
|
95
|
+
|
90
96
|
/**
|
91
97
|
* Returns scriptId.
|
92
98
|
*/
|