libv8-node 22.7.0.4-x86_64-linux-musl → 24.1.0.0-x86_64-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.
Files changed (80) hide show
  1. checksums.yaml +4 -4
  2. data/lib/libv8/node/version.rb +3 -3
  3. data/vendor/v8/include/cppgc/allocation.h +11 -13
  4. data/vendor/v8/include/cppgc/default-platform.h +3 -2
  5. data/vendor/v8/include/cppgc/garbage-collected.h +8 -0
  6. data/vendor/v8/include/cppgc/heap-consistency.h +1 -1
  7. data/vendor/v8/include/cppgc/heap-statistics.h +2 -0
  8. data/vendor/v8/include/cppgc/internal/api-constants.h +2 -14
  9. data/vendor/v8/include/cppgc/internal/base-page-handle.h +2 -4
  10. data/vendor/v8/include/cppgc/internal/caged-heap-local-data.h +0 -4
  11. data/vendor/v8/include/cppgc/internal/caged-heap.h +0 -4
  12. data/vendor/v8/include/cppgc/internal/compiler-specific.h +9 -1
  13. data/vendor/v8/include/cppgc/internal/conditional-stack-allocated.h +41 -0
  14. data/vendor/v8/include/cppgc/internal/gc-info.h +12 -10
  15. data/vendor/v8/include/cppgc/internal/logging.h +3 -3
  16. data/vendor/v8/include/cppgc/internal/member-storage.h +69 -20
  17. data/vendor/v8/include/cppgc/internal/name-trait.h +5 -1
  18. data/vendor/v8/include/cppgc/internal/persistent-node.h +8 -3
  19. data/vendor/v8/include/cppgc/internal/pointer-policies.h +48 -11
  20. data/vendor/v8/include/cppgc/macros.h +21 -0
  21. data/vendor/v8/include/cppgc/member.h +70 -36
  22. data/vendor/v8/include/cppgc/name-provider.h +10 -0
  23. data/vendor/v8/include/cppgc/platform.h +11 -0
  24. data/vendor/v8/include/cppgc/type-traits.h +1 -0
  25. data/vendor/v8/include/cppgc/visitor.h +25 -1
  26. data/vendor/v8/include/libplatform/libplatform-export.h +2 -2
  27. data/vendor/v8/include/libplatform/v8-tracing.h +0 -1
  28. data/vendor/v8/include/v8-array-buffer.h +143 -46
  29. data/vendor/v8/include/v8-callbacks.h +94 -31
  30. data/vendor/v8/include/v8-context.h +48 -15
  31. data/vendor/v8/include/v8-cppgc.h +5 -56
  32. data/vendor/v8/include/v8-data.h +5 -0
  33. data/vendor/v8/include/v8-date.h +9 -0
  34. data/vendor/v8/include/v8-debug.h +11 -0
  35. data/vendor/v8/include/v8-embedder-heap.h +1 -29
  36. data/vendor/v8/include/v8-exception.h +72 -0
  37. data/vendor/v8/include/v8-external-memory-accounter.h +60 -0
  38. data/vendor/v8/include/v8-fast-api-calls.h +41 -206
  39. data/vendor/v8/include/v8-function-callback.h +190 -78
  40. data/vendor/v8/include/v8-function.h +11 -3
  41. data/vendor/v8/include/v8-handle-base.h +20 -2
  42. data/vendor/v8/include/v8-initialization.h +26 -1
  43. data/vendor/v8/include/v8-inspector.h +10 -3
  44. data/vendor/v8/include/v8-internal.h +638 -315
  45. data/vendor/v8/include/v8-isolate.h +275 -189
  46. data/vendor/v8/include/v8-local-handle.h +69 -42
  47. data/vendor/v8/include/v8-maybe.h +2 -1
  48. data/vendor/v8/include/v8-memory-span.h +149 -24
  49. data/vendor/v8/include/v8-message.h +9 -22
  50. data/vendor/v8/include/v8-metrics.h +14 -0
  51. data/vendor/v8/include/v8-microtask-queue.h +0 -5
  52. data/vendor/v8/include/v8-object.h +291 -37
  53. data/vendor/v8/include/v8-persistent-handle.h +17 -36
  54. data/vendor/v8/include/v8-platform.h +66 -45
  55. data/vendor/v8/include/v8-primitive.h +221 -5
  56. data/vendor/v8/include/v8-profiler.h +51 -2
  57. data/vendor/v8/include/v8-promise.h +2 -2
  58. data/vendor/v8/include/v8-proxy.h +0 -1
  59. data/vendor/v8/include/v8-regexp.h +0 -1
  60. data/vendor/v8/include/v8-sandbox.h +173 -0
  61. data/vendor/v8/include/v8-script.h +65 -17
  62. data/vendor/v8/include/v8-snapshot.h +38 -2
  63. data/vendor/v8/include/v8-source-location.h +6 -1
  64. data/vendor/v8/include/v8-template.h +111 -263
  65. data/vendor/v8/include/v8-trace-categories.h +23 -0
  66. data/vendor/v8/include/v8-traced-handle.h +20 -32
  67. data/vendor/v8/include/v8-typed-array.h +6 -10
  68. data/vendor/v8/include/v8-unwinder-state.h +2 -3
  69. data/vendor/v8/include/v8-unwinder.h +2 -1
  70. data/vendor/v8/include/v8-util.h +1 -117
  71. data/vendor/v8/include/v8-value-serializer-version.h +3 -3
  72. data/vendor/v8/include/v8-value.h +21 -2
  73. data/vendor/v8/include/v8-version.h +4 -4
  74. data/vendor/v8/include/v8-wasm.h +27 -0
  75. data/vendor/v8/include/v8-weak-callback-info.h +20 -12
  76. data/vendor/v8/include/v8.h +3 -3
  77. data/vendor/v8/include/v8config.h +83 -45
  78. data/vendor/v8/x86_64-linux-musl/libv8/obj/libv8_monolith.a +0 -0
  79. metadata +6 -3
  80. data/vendor/v8/include/cppgc/ephemeron-pair.h +0 -30
@@ -8,6 +8,7 @@
8
8
  #include <cstdint>
9
9
  #include <limits>
10
10
 
11
+ #include "v8-internal.h" // NOLINT(build/include_directory)
11
12
  #include "v8-local-handle.h" // NOLINT(build/include_directory)
12
13
  #include "v8-primitive.h" // NOLINT(build/include_directory)
13
14
  #include "v8config.h" // NOLINT(build/include_directory)
@@ -31,6 +32,11 @@ namespace debug {
31
32
  class ConsoleCallArguments;
32
33
  } // namespace debug
33
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
+
34
40
  template <typename T>
35
41
  class ReturnValue {
36
42
  public:
@@ -38,7 +44,7 @@ class ReturnValue {
38
44
  V8_INLINE ReturnValue(const ReturnValue<S>& that) : value_(that.value_) {
39
45
  static_assert(std::is_base_of<T, S>::value, "type check");
40
46
  }
41
- // Local setters
47
+ // Handle-based setters.
42
48
  template <typename S>
43
49
  V8_INLINE void Set(const Global<S>& handle);
44
50
  template <typename S>
@@ -51,15 +57,19 @@ class ReturnValue {
51
57
  V8_INLINE void Set(const Local<S> handle);
52
58
  template <typename S>
53
59
  V8_INLINE void SetNonEmpty(const Local<S> handle);
54
- // Fast primitive setters
60
+ // Fast primitive number setters.
55
61
  V8_INLINE void Set(bool value);
56
62
  V8_INLINE void Set(double i);
63
+ V8_INLINE void Set(int16_t i);
57
64
  V8_INLINE void Set(int32_t i);
65
+ V8_INLINE void Set(int64_t i);
66
+ V8_INLINE void Set(uint16_t i);
58
67
  V8_INLINE void Set(uint32_t i);
59
- V8_INLINE void Set(uint16_t);
68
+ V8_INLINE void Set(uint64_t i);
60
69
  // Fast JS primitive setters
61
70
  V8_INLINE void SetNull();
62
71
  V8_INLINE void SetUndefined();
72
+ V8_INLINE void SetFalse();
63
73
  V8_INLINE void SetEmptyString();
64
74
  // Convenience getter for Isolate
65
75
  V8_INLINE Isolate* GetIsolate() const;
@@ -83,14 +93,13 @@ class ReturnValue {
83
93
  template <class F, class G, class H>
84
94
  friend class PersistentValueMapBase;
85
95
  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();
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();
94
103
  V8_INLINE explicit ReturnValue(internal::Address* slot);
95
104
 
96
105
  // See FunctionCallbackInfo.
@@ -117,17 +126,6 @@ class FunctionCallbackInfo {
117
126
  V8_INLINE Local<Value> operator[](int i) const;
118
127
  /** Returns the receiver. This corresponds to the "this" value. */
119
128
  V8_INLINE Local<Object> This() const;
120
- /**
121
- * If the callback was created without a Signature, this is the same
122
- * value as This(). If there is a signature, and the signature didn't match
123
- * This() but one of its hidden prototypes, this will be the respective
124
- * hidden prototype.
125
- *
126
- * Note that this is not the prototype of This() on which the accessor
127
- * referencing this callback was found (which in V8 internally is often
128
- * referred to as holder [sic]).
129
- */
130
- V8_INLINE Local<Object> Holder() const;
131
129
  /** For construct calls, this returns the "new.target" value. */
132
130
  V8_INLINE Local<Value> NewTarget() const;
133
131
  /** Indicates whether this is a regular call or a construct call. */
@@ -143,12 +141,16 @@ class FunctionCallbackInfo {
143
141
  friend class internal::FunctionCallbackArguments;
144
142
  friend class internal::CustomArguments<FunctionCallbackInfo>;
145
143
  friend class debug::ConsoleCallArguments;
144
+ friend void internal::PrintFunctionCallbackInfo(void*);
146
145
 
147
- static constexpr int kHolderIndex = 0;
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;
148
150
  static constexpr int kIsolateIndex = 1;
149
- static constexpr int kUnusedIndex = 2;
151
+ static constexpr int kContextIndex = 2;
150
152
  static constexpr int kReturnValueIndex = 3;
151
- static constexpr int kDataIndex = 4;
153
+ static constexpr int kTargetIndex = 4;
152
154
  static constexpr int kNewTargetIndex = 5;
153
155
  static constexpr int kArgsLength = 6;
154
156
 
@@ -168,9 +170,13 @@ class FunctionCallbackInfo {
168
170
 
169
171
  V8_INLINE FunctionCallbackInfo(internal::Address* implicit_args,
170
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.
171
177
  internal::Address* implicit_args_;
172
178
  internal::Address* values_;
173
- int length_;
179
+ internal::Address length_;
174
180
  };
175
181
 
176
182
  /**
@@ -244,8 +250,23 @@ class PropertyCallbackInfo {
244
250
  *
245
251
  * \note For security reasons, do not pass the object back into the runtime.
246
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. ")
247
259
  V8_INLINE Local<Object> Holder() const;
248
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
+
249
270
  /**
250
271
  * \return The return value of the callback.
251
272
  * Can be changed by calling Set().
@@ -266,24 +287,28 @@ class PropertyCallbackInfo {
266
287
  V8_INLINE bool ShouldThrowOnError() const;
267
288
 
268
289
  private:
290
+ template <typename U>
291
+ friend class PropertyCallbackInfo;
269
292
  friend class MacroAssembler;
270
293
  friend class internal::PropertyCallbackArguments;
271
294
  friend class internal::CustomArguments<PropertyCallbackInfo>;
272
- static constexpr int kShouldThrowOnErrorIndex = 0;
273
- static constexpr int kHolderIndex = 1;
274
- static constexpr int kIsolateIndex = 2;
275
- static constexpr int kUnusedIndex = 3;
276
- static constexpr int kReturnValueIndex = 4;
277
- static constexpr int kDataIndex = 5;
278
- static constexpr int kThisIndex = 6;
279
- static constexpr int kArgsLength = 7;
295
+ friend void internal::PrintPropertyCallbackInfo(void*);
280
296
 
281
- static constexpr int kSize = 1 * internal::kApiSystemPointerSize;
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;
282
306
 
283
- V8_INLINE explicit PropertyCallbackInfo(internal::Address* args)
284
- : args_(args) {}
307
+ static constexpr int kSize = kArgsLength * internal::kApiSystemPointerSize;
285
308
 
286
- internal::Address* args_;
309
+ PropertyCallbackInfo() = default;
310
+
311
+ mutable internal::Address args_[kArgsLength];
287
312
  };
288
313
 
289
314
  using FunctionCallback = void (*)(const FunctionCallbackInfo<Value>& info);
@@ -312,7 +337,7 @@ template <typename S>
312
337
  void ReturnValue<T>::Set(const Global<S>& handle) {
313
338
  static_assert(std::is_base_of<T, S>::value, "type check");
314
339
  if (V8_UNLIKELY(handle.IsEmpty())) {
315
- SetTheHole();
340
+ SetDefaultValue();
316
341
  } else {
317
342
  SetInternal(handle.ptr());
318
343
  }
@@ -333,7 +358,7 @@ template <typename S>
333
358
  void ReturnValue<T>::Set(const BasicTracedReference<S>& handle) {
334
359
  static_assert(std::is_base_of<T, S>::value, "type check");
335
360
  if (V8_UNLIKELY(handle.IsEmpty())) {
336
- SetTheHole();
361
+ SetDefaultValue();
337
362
  } else {
338
363
  SetInternal(handle.ptr());
339
364
  }
@@ -352,10 +377,25 @@ void ReturnValue<T>::SetNonEmpty(const BasicTracedReference<S>& handle) {
352
377
  template <typename T>
353
378
  template <typename S>
354
379
  void ReturnValue<T>::Set(const Local<S> handle) {
355
- static_assert(std::is_void<T>::value || std::is_base_of<T, S>::value,
356
- "type check");
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");
357
393
  if (V8_UNLIKELY(handle.IsEmpty())) {
358
- SetTheHole();
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()));
359
399
  } else {
360
400
  SetInternal(handle.ptr());
361
401
  }
@@ -364,12 +404,29 @@ void ReturnValue<T>::Set(const Local<S> handle) {
364
404
  template <typename T>
365
405
  template <typename S>
366
406
  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");
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");
369
420
  #ifdef V8_ENABLE_CHECKS
370
421
  internal::VerifyHandleIsNonEmpty(handle.IsEmpty());
371
422
  #endif // V8_ENABLE_CHECKS
372
- SetInternal(handle.ptr());
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());
429
+ }
373
430
  }
374
431
 
375
432
  template <typename T>
@@ -379,26 +436,32 @@ void ReturnValue<T>::Set(double i) {
379
436
  }
380
437
 
381
438
  template <typename T>
382
- void ReturnValue<T>::Set(int32_t i) {
439
+ void ReturnValue<T>::Set(int16_t i) {
383
440
  static_assert(std::is_base_of<T, Integer>::value, "type check");
384
441
  using I = internal::Internals;
385
- if (V8_LIKELY(I::IsValidSmi(i))) {
386
- SetInternal(I::IntToSmi(i));
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);
387
452
  return;
388
453
  }
389
454
  SetNonEmpty(Integer::New(GetIsolate(), i));
390
455
  }
391
456
 
392
457
  template <typename T>
393
- void ReturnValue<T>::Set(uint32_t i) {
458
+ void ReturnValue<T>::Set(int64_t i) {
394
459
  static_assert(std::is_base_of<T, Integer>::value, "type check");
395
- // Can't simply use INT32_MAX here for whatever reason.
396
- bool fits_into_int32_t = (i & (1U << 31)) == 0;
397
- if (V8_LIKELY(fits_into_int32_t)) {
398
- Set(static_cast<int32_t>(i));
460
+ if (const auto result = internal::Internals::TryIntegralToSmi(i)) {
461
+ SetInternal(*result);
399
462
  return;
400
463
  }
401
- SetNonEmpty(Integer::NewFromUnsigned(GetIsolate(), i));
464
+ SetNonEmpty(Number::New(GetIsolate(), static_cast<double>(i)));
402
465
  }
403
466
 
404
467
  template <typename T>
@@ -407,12 +470,33 @@ void ReturnValue<T>::Set(uint16_t i) {
407
470
  using I = internal::Internals;
408
471
  static_assert(I::IsValidSmi(std::numeric_limits<uint16_t>::min()));
409
472
  static_assert(I::IsValidSmi(std::numeric_limits<uint16_t>::max()));
410
- SetInternal(I::IntToSmi(i));
473
+ SetInternal(I::IntegralToSmi(i));
474
+ }
475
+
476
+ template <typename T>
477
+ void ReturnValue<T>::Set(uint32_t i) {
478
+ static_assert(std::is_base_of<T, Integer>::value, "type check");
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);
491
+ return;
492
+ }
493
+ SetNonEmpty(Number::New(GetIsolate(), static_cast<double>(i)));
411
494
  }
412
495
 
413
496
  template <typename T>
414
497
  void ReturnValue<T>::Set(bool value) {
415
- static_assert(std::is_base_of<T, Boolean>::value, "type check");
498
+ static_assert(std::is_void<T>::value || std::is_base_of<T, Boolean>::value,
499
+ "type check");
416
500
  using I = internal::Internals;
417
501
  #if V8_STATIC_ROOTS_BOOL
418
502
  #ifdef V8_ENABLE_CHECKS
@@ -433,13 +517,20 @@ void ReturnValue<T>::Set(bool value) {
433
517
  }
434
518
 
435
519
  template <typename T>
436
- void ReturnValue<T>::SetTheHole() {
520
+ void ReturnValue<T>::SetDefaultValue() {
437
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>);
438
528
  #if V8_STATIC_ROOTS_BOOL
439
- SetInternal(I::StaticReadOnlyRoot::kTheHoleValue);
529
+ SetInternal(I::StaticReadOnlyRoot::kUndefinedValue);
440
530
  #else
441
- *value_ = I::GetRoot(GetIsolate(), I::kTheHoleValueRootIndex);
531
+ *value_ = I::GetRoot(GetIsolate(), I::kUndefinedValueRootIndex);
442
532
  #endif // V8_STATIC_ROOTS_BOOL
533
+ }
443
534
  }
444
535
 
445
536
  template <typename T>
@@ -472,6 +563,22 @@ void ReturnValue<T>::SetUndefined() {
472
563
  #endif // V8_STATIC_ROOTS_BOOL
473
564
  }
474
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
580
+ }
581
+
475
582
  template <typename T>
476
583
  void ReturnValue<T>::SetEmptyString() {
477
584
  static_assert(std::is_base_of<T, String>::value, "type check");
@@ -494,14 +601,6 @@ Isolate* ReturnValue<T>::GetIsolate() const {
494
601
 
495
602
  template <typename T>
496
603
  Local<Value> ReturnValue<T>::Get() const {
497
- using I = internal::Internals;
498
- #if V8_STATIC_ROOTS_BOOL
499
- if (I::is_identical(*value_, I::StaticReadOnlyRoot::kTheHoleValue)) {
500
- #else
501
- if (*value_ == I::GetRoot(GetIsolate(), I::kTheHoleValueRootIndex)) {
502
- #endif // V8_STATIC_ROOTS_BOOL
503
- return Undefined(GetIsolate());
504
- }
505
604
  return Local<Value>::New(GetIsolate(),
506
605
  internal::ValueHelper::SlotAsValue<Value>(value_));
507
606
  }
@@ -521,7 +620,7 @@ FunctionCallbackInfo<T>::FunctionCallbackInfo(internal::Address* implicit_args,
521
620
  template <typename T>
522
621
  Local<Value> FunctionCallbackInfo<T>::operator[](int i) const {
523
622
  // values_ points to the first argument (not the receiver).
524
- if (i < 0 || length_ <= i) return Undefined(GetIsolate());
623
+ if (i < 0 || Length() <= i) return Undefined(GetIsolate());
525
624
  return Local<Value>::FromSlot(values_ + i);
526
625
  }
527
626
 
@@ -531,11 +630,6 @@ Local<Object> FunctionCallbackInfo<T>::This() const {
531
630
  return Local<Object>::FromSlot(values_ + kThisValuesIndex);
532
631
  }
533
632
 
534
- template <typename T>
535
- Local<Object> FunctionCallbackInfo<T>::Holder() const {
536
- return Local<Object>::FromSlot(&implicit_args_[kHolderIndex]);
537
- }
538
-
539
633
  template <typename T>
540
634
  Local<Value> FunctionCallbackInfo<T>::NewTarget() const {
541
635
  return Local<Value>::FromSlot(&implicit_args_[kNewTargetIndex]);
@@ -543,7 +637,8 @@ Local<Value> FunctionCallbackInfo<T>::NewTarget() const {
543
637
 
544
638
  template <typename T>
545
639
  Local<Value> FunctionCallbackInfo<T>::Data() const {
546
- return Local<Value>::FromSlot(&implicit_args_[kDataIndex]);
640
+ auto target = Local<v8::Data>::FromSlot(&implicit_args_[kTargetIndex]);
641
+ return api_internal::GetFunctionTemplateData(GetIsolate(), target);
547
642
  }
548
643
 
549
644
  template <typename T>
@@ -563,7 +658,7 @@ bool FunctionCallbackInfo<T>::IsConstructCall() const {
563
658
 
564
659
  template <typename T>
565
660
  int FunctionCallbackInfo<T>::Length() const {
566
- return length_;
661
+ return static_cast<int>(length_);
567
662
  }
568
663
 
569
664
  template <typename T>
@@ -586,6 +681,23 @@ Local<Object> PropertyCallbackInfo<T>::Holder() const {
586
681
  return Local<Object>::FromSlot(&args_[kHolderIndex]);
587
682
  }
588
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
+
589
701
  template <typename T>
590
702
  ReturnValue<T> PropertyCallbackInfo<T>::GetReturnValue() const {
591
703
  return ReturnValue<T>(&args_[kReturnValueIndex]);
@@ -595,8 +707,8 @@ template <typename T>
595
707
  bool PropertyCallbackInfo<T>::ShouldThrowOnError() const {
596
708
  using I = internal::Internals;
597
709
  if (args_[kShouldThrowOnErrorIndex] !=
598
- I::IntToSmi(I::kInferShouldThrowMode)) {
599
- return args_[kShouldThrowOnErrorIndex] != I::IntToSmi(I::kDontThrow);
710
+ I::IntegralToSmi(I::kInferShouldThrowMode)) {
711
+ return args_[kShouldThrowOnErrorIndex] != I::IntegralToSmi(I::kDontThrow);
600
712
  }
601
713
  return v8::internal::ShouldThrowOnError(
602
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.
@@ -43,7 +43,11 @@ class V8_TRIVIAL_ABI StackAllocated<true> : public StackAllocated<false> {
43
43
  no_checking_tag tag)
44
44
  : StackAllocated<false>(other, tag) {}
45
45
 
46
+ #ifdef ENABLE_SLOW_DCHECKS
46
47
  V8_EXPORT void VerifyOnStack() const;
48
+ #else
49
+ V8_INLINE V8_EXPORT void VerifyOnStack() const {}
50
+ #endif
47
51
  };
48
52
 
49
53
  /**
@@ -86,11 +90,21 @@ class IndirectHandleBase {
86
90
  return internal::ValueHelper::SlotAsValue<T, check_null>(slot());
87
91
  }
88
92
 
93
+ #ifdef V8_ENABLE_DIRECT_HANDLE
94
+ V8_INLINE internal::ValueHelper::InternalRepresentationType repr() const {
95
+ return location_ ? *location_ : internal::ValueHelper::kEmpty;
96
+ }
97
+ #else
98
+ V8_INLINE internal::ValueHelper::InternalRepresentationType repr() const {
99
+ return location_;
100
+ }
101
+ #endif // V8_ENABLE_DIRECT_HANDLE
102
+
89
103
  private:
90
104
  internal::Address* location_ = nullptr;
91
105
  };
92
106
 
93
- #ifdef V8_ENABLE_DIRECT_LOCAL
107
+ #ifdef V8_ENABLE_DIRECT_HANDLE
94
108
 
95
109
  /**
96
110
  * A base class for abstract handles containing direct pointers.
@@ -126,11 +140,15 @@ class DirectHandleBase {
126
140
  return reinterpret_cast<T*>(ptr_);
127
141
  }
128
142
 
143
+ V8_INLINE internal::ValueHelper::InternalRepresentationType repr() const {
144
+ return ptr_;
145
+ }
146
+
129
147
  private:
130
148
  internal::Address ptr_ = internal::ValueHelper::kEmpty;
131
149
  };
132
150
 
133
- #endif // V8_ENABLE_DIRECT_LOCAL
151
+ #endif // V8_ENABLE_DIRECT_HANDLE
134
152
 
135
153
  } // namespace v8::api_internal
136
154
 
@@ -52,6 +52,9 @@ using ReturnAddressLocationResolver =
52
52
  using DcheckErrorCallback = void (*)(const char* file, int line,
53
53
  const char* message);
54
54
 
55
+ using V8FatalErrorCallback = void (*)(const char* file, int line,
56
+ const char* message);
57
+
55
58
  /**
56
59
  * Container class for static utility functions.
57
60
  */
@@ -77,6 +80,12 @@ class V8_EXPORT V8 {
77
80
  /** Set the callback to invoke in case of Dcheck failures. */
78
81
  static void SetDcheckErrorHandler(DcheckErrorCallback that);
79
82
 
83
+ /** Set the callback to invoke in the case of CHECK failures or fatal
84
+ * errors. This is distinct from Isolate::SetFatalErrorHandler, which
85
+ * is invoked in response to API usage failures.
86
+ * */
87
+ static void SetFatalErrorHandler(V8FatalErrorCallback that);
88
+
80
89
  /**
81
90
  * Sets V8 flags from a string.
82
91
  */
@@ -97,10 +106,24 @@ class V8_EXPORT V8 {
97
106
  * is created. It always returns true.
98
107
  */
99
108
  V8_INLINE static bool Initialize() {
109
+ #ifdef V8_TARGET_OS_ANDROID
110
+ const bool kV8TargetOsIsAndroid = true;
111
+ #else
112
+ const bool kV8TargetOsIsAndroid = false;
113
+ #endif
114
+
115
+ #ifdef V8_ENABLE_CHECKS
116
+ const bool kV8EnableChecks = true;
117
+ #else
118
+ const bool kV8EnableChecks = false;
119
+ #endif
120
+
100
121
  const int kBuildConfiguration =
101
122
  (internal::PointerCompressionIsEnabled() ? kPointerCompression : 0) |
102
123
  (internal::SmiValuesAre31Bits() ? k31BitSmis : 0) |
103
- (internal::SandboxIsEnabled() ? kSandbox : 0);
124
+ (internal::SandboxIsEnabled() ? kSandbox : 0) |
125
+ (kV8TargetOsIsAndroid ? kTargetOsIsAndroid : 0) |
126
+ (kV8EnableChecks ? kEnableChecks : 0);
104
127
  return Initialize(kBuildConfiguration);
105
128
  }
106
129
 
@@ -271,6 +294,8 @@ class V8_EXPORT V8 {
271
294
  kPointerCompression = 1 << 0,
272
295
  k31BitSmis = 1 << 1,
273
296
  kSandbox = 1 << 2,
297
+ kTargetOsIsAndroid = 1 << 3,
298
+ kEnableChecks = 1 << 4,
274
299
  };
275
300
 
276
301
  /**
@@ -139,6 +139,7 @@ struct V8_EXPORT V8StackFrame {
139
139
  StringView functionName;
140
140
  int lineNumber;
141
141
  int columnNumber;
142
+ int scriptId;
142
143
  };
143
144
 
144
145
  class V8_EXPORT V8StackTrace {
@@ -297,9 +298,14 @@ class V8_EXPORT V8InspectorClient {
297
298
  return v8::MaybeLocal<v8::Value>();
298
299
  }
299
300
 
300
- virtual void consoleTime(const StringView& title) {}
301
- virtual void consoleTimeEnd(const StringView& title) {}
302
- virtual void consoleTimeStamp(const StringView& title) {}
301
+ virtual void consoleTime(v8::Isolate* isolate, v8::Local<v8::String> label) {}
302
+ virtual void consoleTimeEnd(v8::Isolate* isolate,
303
+ v8::Local<v8::String> label) {}
304
+ virtual void consoleTimeStamp(v8::Isolate* isolate,
305
+ v8::Local<v8::String> label) {}
306
+ virtual void consoleTimeStampWithArgs(
307
+ v8::Isolate* isolate, v8::Local<v8::String> label,
308
+ const v8::LocalVector<v8::Value>& args) {}
303
309
  virtual void consoleClear(int contextGroupId) {}
304
310
  virtual double currentTimeMS() { return 0; }
305
311
  typedef void (*TimerCallback)(void*);
@@ -358,6 +364,7 @@ class V8_EXPORT V8Inspector {
358
364
  virtual void resetContextGroup(int contextGroupId) = 0;
359
365
  virtual v8::MaybeLocal<v8::Context> contextById(int contextId) = 0;
360
366
  virtual V8DebuggerId uniqueDebuggerId(int contextId) = 0;
367
+ virtual uint64_t isolateId() = 0;
361
368
 
362
369
  // Various instrumentation.
363
370
  virtual void idleStarted() = 0;