libv8-node 15.14.0.0-x86_64-linux → 16.17.0.0-x86_64-linux

Sign up to get free protection for your applications and to get access to all the features.
Files changed (57) hide show
  1. checksums.yaml +4 -4
  2. data/ext/libv8-node/location.rb +1 -1
  3. data/ext/libv8-node/paths.rb +5 -1
  4. data/lib/libv8/node/version.rb +3 -3
  5. data/vendor/v8/include/cppgc/allocation.h +105 -45
  6. data/vendor/v8/include/cppgc/common.h +9 -6
  7. data/vendor/v8/include/cppgc/cross-thread-persistent.h +413 -0
  8. data/vendor/v8/include/cppgc/custom-space.h +37 -2
  9. data/vendor/v8/include/cppgc/default-platform.h +47 -48
  10. data/vendor/v8/include/cppgc/ephemeron-pair.h +30 -0
  11. data/vendor/v8/include/cppgc/explicit-management.h +82 -0
  12. data/vendor/v8/include/cppgc/garbage-collected.h +4 -3
  13. data/vendor/v8/include/cppgc/heap-consistency.h +253 -0
  14. data/vendor/v8/include/cppgc/heap-state.h +70 -0
  15. data/vendor/v8/include/cppgc/heap-statistics.h +120 -0
  16. data/vendor/v8/include/cppgc/heap.h +68 -6
  17. data/vendor/v8/include/cppgc/internal/api-constants.h +3 -3
  18. data/vendor/v8/include/cppgc/internal/caged-heap-local-data.h +2 -1
  19. data/vendor/v8/include/cppgc/internal/compiler-specific.h +2 -2
  20. data/vendor/v8/include/cppgc/internal/gc-info.h +44 -13
  21. data/vendor/v8/include/cppgc/internal/name-trait.h +111 -0
  22. data/vendor/v8/include/cppgc/internal/persistent-node.h +58 -2
  23. data/vendor/v8/include/cppgc/internal/pointer-policies.h +69 -28
  24. data/vendor/v8/include/cppgc/internal/prefinalizer-handler.h +1 -1
  25. data/vendor/v8/include/cppgc/internal/write-barrier.h +390 -35
  26. data/vendor/v8/include/cppgc/liveness-broker.h +11 -2
  27. data/vendor/v8/include/cppgc/macros.h +2 -0
  28. data/vendor/v8/include/cppgc/member.h +87 -25
  29. data/vendor/v8/include/cppgc/name-provider.h +65 -0
  30. data/vendor/v8/include/cppgc/object-size-trait.h +58 -0
  31. data/vendor/v8/include/cppgc/persistent.h +40 -10
  32. data/vendor/v8/include/cppgc/platform.h +49 -25
  33. data/vendor/v8/include/cppgc/prefinalizer.h +1 -1
  34. data/vendor/v8/include/cppgc/process-heap-statistics.h +36 -0
  35. data/vendor/v8/include/cppgc/sentinel-pointer.h +32 -0
  36. data/vendor/v8/include/cppgc/source-location.h +2 -1
  37. data/vendor/v8/include/cppgc/testing.h +99 -0
  38. data/vendor/v8/include/cppgc/trace-trait.h +8 -3
  39. data/vendor/v8/include/cppgc/type-traits.h +157 -19
  40. data/vendor/v8/include/cppgc/visitor.h +194 -28
  41. data/vendor/v8/include/libplatform/libplatform.h +11 -0
  42. data/vendor/v8/include/libplatform/v8-tracing.h +2 -0
  43. data/vendor/v8/include/v8-cppgc.h +258 -159
  44. data/vendor/v8/include/v8-fast-api-calls.h +603 -155
  45. data/vendor/v8/include/v8-inspector.h +22 -4
  46. data/vendor/v8/include/v8-internal.h +111 -27
  47. data/vendor/v8/include/v8-metrics.h +77 -8
  48. data/vendor/v8/include/v8-platform.h +47 -22
  49. data/vendor/v8/include/v8-profiler.h +75 -11
  50. data/vendor/v8/include/v8-unwinder-state.h +30 -0
  51. data/vendor/v8/include/v8-util.h +1 -1
  52. data/vendor/v8/include/v8-version.h +4 -4
  53. data/vendor/v8/include/v8.h +1196 -642
  54. data/vendor/v8/include/v8config.h +87 -11
  55. data/vendor/v8/{out.gn → x86_64-linux}/libv8/obj/libv8_monolith.a +0 -0
  56. metadata +17 -5
  57. data/vendor/v8/include/cppgc/internal/process-heap.h +0 -34
@@ -19,6 +19,7 @@
19
19
  #include <stdint.h>
20
20
  #include <stdio.h>
21
21
 
22
+ #include <atomic>
22
23
  #include <memory>
23
24
  #include <string>
24
25
  #include <type_traits>
@@ -46,9 +47,13 @@ class BigIntObject;
46
47
  class Boolean;
47
48
  class BooleanObject;
48
49
  class CFunction;
50
+ class CallHandlerHelper;
49
51
  class Context;
52
+ class CppHeap;
53
+ class CTypeInfo;
50
54
  class Data;
51
55
  class Date;
56
+ class EscapableHandleScope;
52
57
  class External;
53
58
  class Function;
54
59
  class FunctionTemplate;
@@ -57,8 +62,7 @@ class ImplementationUtilities;
57
62
  class Int32;
58
63
  class Integer;
59
64
  class Isolate;
60
- template <class T>
61
- class Maybe;
65
+ class Isolate;
62
66
  class MicrotaskQueue;
63
67
  class Name;
64
68
  class Number;
@@ -68,6 +72,8 @@ class ObjectOperationDescriptor;
68
72
  class ObjectTemplate;
69
73
  class Platform;
70
74
  class Primitive;
75
+ class PrimitiveArray;
76
+ class Private;
71
77
  class Promise;
72
78
  class PropertyDescriptor;
73
79
  class Proxy;
@@ -75,72 +81,72 @@ class RawOperationDescriptor;
75
81
  class Script;
76
82
  class SharedArrayBuffer;
77
83
  class Signature;
78
- class StartupData;
79
84
  class StackFrame;
80
85
  class StackTrace;
86
+ class StartupData;
81
87
  class String;
82
88
  class StringObject;
83
89
  class Symbol;
84
90
  class SymbolObject;
85
- class PrimitiveArray;
86
- class Private;
91
+ class TracedReferenceBase;
87
92
  class Uint32;
88
93
  class Utils;
89
94
  class Value;
95
+ class WasmMemoryObject;
90
96
  class WasmModuleObject;
91
- template <class T> class Local;
92
- template <class T>
93
- class MaybeLocal;
94
- template <class T> class Eternal;
97
+ template <class K, class V, class T>
98
+ class GlobalValueMap;
99
+ template <class K, class V, class T>
100
+ class PersistentValueMapBase;
95
101
  template<class T> class NonCopyablePersistentTraits;
96
- template<class T> class PersistentBase;
97
- template <class T, class M = NonCopyablePersistentTraits<T> >
102
+ template <class T, class M = NonCopyablePersistentTraits<T>>
98
103
  class Persistent;
99
104
  template <class T>
105
+ class BasicTracedReference;
106
+ template <class T>
107
+ class Eternal;
108
+ template <class T>
100
109
  class Global;
101
110
  template <class T>
111
+ class Local;
112
+ template <class T>
113
+ class Maybe;
114
+ template <class T>
115
+ class MaybeLocal;
116
+ template <class T>
102
117
  class TracedGlobal;
103
118
  template <class T>
104
119
  class TracedReference;
105
- template <class T>
106
- class TracedReferenceBase;
107
120
  template<class K, class V, class T> class PersistentValueMap;
108
- template <class K, class V, class T>
109
- class PersistentValueMapBase;
110
- template <class K, class V, class T>
111
- class GlobalValueMap;
112
- template<class V, class T> class PersistentValueVector;
113
121
  template<class T, class P> class WeakCallbackObject;
114
- class FunctionTemplate;
115
- class ObjectTemplate;
122
+ template <class T>
123
+ class PersistentBase;
124
+ template <class V, class T>
125
+ class PersistentValueVector;
116
126
  template<typename T> class FunctionCallbackInfo;
117
127
  template<typename T> class PropertyCallbackInfo;
118
- class StackTrace;
119
- class StackFrame;
120
- class Isolate;
121
- class CallHandlerHelper;
122
- class EscapableHandleScope;
123
128
  template<typename T> class ReturnValue;
124
129
 
125
130
  namespace internal {
126
- enum class ArgumentsType;
127
- template <ArgumentsType>
128
- class Arguments;
129
- template <typename T>
130
- class CustomArguments;
131
+ class BasicTracedReferenceExtractor;
132
+ class ExternalString;
131
133
  class FunctionCallbackArguments;
132
134
  class GlobalHandles;
133
135
  class Heap;
134
136
  class HeapObject;
135
- class ExternalString;
136
137
  class Isolate;
137
138
  class LocalEmbedderHeapTracer;
138
139
  class MicrotaskQueue;
139
140
  class PropertyCallbackArguments;
140
141
  class ReadOnlyHeap;
141
142
  class ScopedExternalStringLock;
142
- struct ScriptStreamingData;
143
143
  class ThreadLocalTop;
144
+ struct ScriptStreamingData;
145
+ enum class ArgumentsType;
146
+ template <ArgumentsType>
147
+ class Arguments;
148
+ template <typename T>
149
+ class CustomArguments;
144
150
 
145
151
  namespace wasm {
146
152
  class NativeModule;
@@ -300,9 +306,10 @@ class Local {
300
306
  V8_INLINE static Local<T> New(Isolate* isolate,
301
307
  const PersistentBase<T>& that);
302
308
  V8_INLINE static Local<T> New(Isolate* isolate,
303
- const TracedReferenceBase<T>& that);
309
+ const BasicTracedReference<T>& that);
304
310
 
305
311
  private:
312
+ friend class TracedReferenceBase;
306
313
  friend class Utils;
307
314
  template<class F> friend class Eternal;
308
315
  template<class F> friend class PersistentBase;
@@ -334,7 +341,7 @@ class Local {
334
341
  template <class F>
335
342
  friend class TracedGlobal;
336
343
  template <class F>
337
- friend class TracedReferenceBase;
344
+ friend class BasicTracedReference;
338
345
  template <class F>
339
346
  friend class TracedReference;
340
347
 
@@ -429,7 +436,7 @@ static const int kEmbedderFieldsInWeakCallback = 2;
429
436
  template <typename T>
430
437
  class WeakCallbackInfo {
431
438
  public:
432
- typedef void (*Callback)(const WeakCallbackInfo<T>& data);
439
+ using Callback = void (*)(const WeakCallbackInfo<T>& data);
433
440
 
434
441
  WeakCallbackInfo(Isolate* isolate, T* parameter,
435
442
  void* embedder_fields[kEmbedderFieldsInWeakCallback],
@@ -590,7 +597,7 @@ template <class T> class PersistentBase {
590
597
  */
591
598
  V8_INLINE uint16_t WrapperClassId() const;
592
599
 
593
- PersistentBase(const PersistentBase& other) = delete; // NOLINT
600
+ PersistentBase(const PersistentBase& other) = delete;
594
601
  void operator=(const PersistentBase&) = delete;
595
602
 
596
603
  private:
@@ -623,7 +630,7 @@ template <class T> class PersistentBase {
623
630
  template<class T>
624
631
  class NonCopyablePersistentTraits {
625
632
  public:
626
- typedef Persistent<T, NonCopyablePersistentTraits<T> > NonCopyablePersistent;
633
+ using NonCopyablePersistent = Persistent<T, NonCopyablePersistentTraits<T>>;
627
634
  static const bool kResetInDestructor = false;
628
635
  template<class S, class M>
629
636
  V8_INLINE static void Copy(const Persistent<S, M>& source,
@@ -640,7 +647,7 @@ class NonCopyablePersistentTraits {
640
647
  */
641
648
  template<class T>
642
649
  struct CopyablePersistentTraits {
643
- typedef Persistent<T, CopyablePersistentTraits<T> > CopyablePersistent;
650
+ using CopyablePersistent = Persistent<T, CopyablePersistentTraits<T>>;
644
651
  static const bool kResetInDestructor = true;
645
652
  template<class S, class M>
646
653
  static V8_INLINE void Copy(const Persistent<S, M>& source,
@@ -702,7 +709,7 @@ template <class T, class M> class Persistent : public PersistentBase<T> {
702
709
  return *this;
703
710
  }
704
711
  template <class S, class M2>
705
- V8_INLINE Persistent& operator=(const Persistent<S, M2>& that) { // NOLINT
712
+ V8_INLINE Persistent& operator=(const Persistent<S, M2>& that) {
706
713
  Copy(that);
707
714
  return *this;
708
715
  }
@@ -717,7 +724,7 @@ template <class T, class M> class Persistent : public PersistentBase<T> {
717
724
 
718
725
  // TODO(dcarney): this is pretty useless, fix or remove
719
726
  template <class S>
720
- V8_INLINE static Persistent<T>& Cast(const Persistent<S>& that) { // NOLINT
727
+ V8_INLINE static Persistent<T>& Cast(const Persistent<S>& that) {
721
728
  #ifdef V8_ENABLE_CHECKS
722
729
  // If we're going to perform the type check then we have to check
723
730
  // that the handle isn't empty before doing the checked cast.
@@ -728,7 +735,7 @@ template <class T, class M> class Persistent : public PersistentBase<T> {
728
735
 
729
736
  // TODO(dcarney): this is pretty useless, fix or remove
730
737
  template <class S>
731
- V8_INLINE Persistent<S>& As() const { // NOLINT
738
+ V8_INLINE Persistent<S>& As() const {
732
739
  return Persistent<S>::Cast(*this);
733
740
  }
734
741
 
@@ -797,12 +804,12 @@ class Global : public PersistentBase<T> {
797
804
  /**
798
805
  * Pass allows returning uniques from functions, etc.
799
806
  */
800
- Global Pass() { return static_cast<Global&&>(*this); } // NOLINT
807
+ Global Pass() { return static_cast<Global&&>(*this); }
801
808
 
802
809
  /*
803
810
  * For compatibility with Chromium's base::Bind (base::Passed).
804
811
  */
805
- typedef void MoveOnlyTypeForCPP03;
812
+ using MoveOnlyTypeForCPP03 = void;
806
813
 
807
814
  Global(const Global&) = delete;
808
815
  void operator=(const Global&) = delete;
@@ -824,27 +831,11 @@ using UniquePersistent = Global<T>;
824
831
  template <typename T>
825
832
  struct TracedGlobalTrait {};
826
833
 
827
- /**
828
- * A traced handle with copy and move semantics. The handle is to be used
829
- * together with |v8::EmbedderHeapTracer| and specifies edges from the embedder
830
- * into V8's heap.
831
- *
832
- * The exact semantics are:
833
- * - Tracing garbage collections use |v8::EmbedderHeapTracer|.
834
- * - Non-tracing garbage collections refer to
835
- * |v8::EmbedderHeapTracer::IsRootForNonTracingGC()| whether the handle should
836
- * be treated as root or not.
837
- *
838
- * Note that the base class cannot be instantiated itself. Choose from
839
- * - TracedGlobal
840
- * - TracedReference
841
- */
842
- template <typename T>
843
834
  class TracedReferenceBase {
844
835
  public:
845
836
  /**
846
- * Returns true if this TracedReferenceBase is empty, i.e., has not been
847
- * assigned an object.
837
+ * Returns true if the reference is empty, i.e., has not been assigned
838
+ * object.
848
839
  */
849
840
  bool IsEmpty() const { return val_ == nullptr; }
850
841
 
@@ -855,36 +846,16 @@ class TracedReferenceBase {
855
846
  V8_INLINE void Reset();
856
847
 
857
848
  /**
858
- * Construct a Local<T> from this handle.
849
+ * Construct a Local<Value> from this handle.
859
850
  */
860
- Local<T> Get(Isolate* isolate) const { return Local<T>::New(isolate, *this); }
861
-
862
- template <class S>
863
- V8_INLINE bool operator==(const TracedReferenceBase<S>& that) const {
864
- internal::Address* a = reinterpret_cast<internal::Address*>(val_);
865
- internal::Address* b = reinterpret_cast<internal::Address*>(that.val_);
866
- if (a == nullptr) return b == nullptr;
867
- if (b == nullptr) return false;
868
- return *a == *b;
869
- }
870
-
871
- template <class S>
872
- V8_INLINE bool operator==(const Local<S>& that) const {
873
- internal::Address* a = reinterpret_cast<internal::Address*>(val_);
874
- internal::Address* b = reinterpret_cast<internal::Address*>(that.val_);
875
- if (a == nullptr) return b == nullptr;
876
- if (b == nullptr) return false;
877
- return *a == *b;
878
- }
879
-
880
- template <class S>
881
- V8_INLINE bool operator!=(const TracedReferenceBase<S>& that) const {
882
- return !operator==(that);
883
- }
851
+ V8_INLINE v8::Local<v8::Value> Get(v8::Isolate* isolate) const;
884
852
 
885
- template <class S>
886
- V8_INLINE bool operator!=(const Local<S>& that) const {
887
- return !operator==(that);
853
+ /**
854
+ * Returns true if this TracedReference is empty, i.e., has not been
855
+ * assigned an object. This version of IsEmpty is thread-safe.
856
+ */
857
+ bool IsEmptyThreadSafe() const {
858
+ return this->GetSlotThreadSafe() == nullptr;
888
859
  }
889
860
 
890
861
  /**
@@ -898,41 +869,89 @@ class TracedReferenceBase {
898
869
  */
899
870
  V8_INLINE uint16_t WrapperClassId() const;
900
871
 
901
- template <class S>
902
- V8_INLINE TracedReferenceBase<S>& As() const {
903
- return reinterpret_cast<TracedReferenceBase<S>&>(
904
- const_cast<TracedReferenceBase<T>&>(*this));
905
- }
906
-
907
872
  protected:
908
873
  /**
909
- * Update this reference in a thread-safe way
874
+ * Update this reference in a thread-safe way.
910
875
  */
911
- void SetSlotThreadSafe(T* new_val) {
912
- reinterpret_cast<std::atomic<T*>*>(&val_)->store(new_val,
913
- std::memory_order_relaxed);
876
+ void SetSlotThreadSafe(void* new_val) {
877
+ reinterpret_cast<std::atomic<void*>*>(&val_)->store(
878
+ new_val, std::memory_order_relaxed);
914
879
  }
915
880
 
916
881
  /**
917
882
  * Get this reference in a thread-safe way
918
883
  */
919
- const T* GetSlotThreadSafe() const {
920
- return reinterpret_cast<std::atomic<const T*> const*>(&val_)->load(
884
+ const void* GetSlotThreadSafe() const {
885
+ return reinterpret_cast<std::atomic<const void*> const*>(&val_)->load(
921
886
  std::memory_order_relaxed);
922
887
  }
923
888
 
889
+ V8_EXPORT void CheckValue() const;
890
+
891
+ // val_ points to a GlobalHandles node.
892
+ internal::Address* val_ = nullptr;
893
+
894
+ friend class internal::BasicTracedReferenceExtractor;
895
+ template <typename F>
896
+ friend class Local;
897
+ template <typename U>
898
+ friend bool operator==(const TracedReferenceBase&, const Local<U>&);
899
+ friend bool operator==(const TracedReferenceBase&,
900
+ const TracedReferenceBase&);
901
+ };
902
+
903
+ /**
904
+ * A traced handle with copy and move semantics. The handle is to be used
905
+ * together with |v8::EmbedderHeapTracer| or as part of GarbageCollected objects
906
+ * (see v8-cppgc.h) and specifies edges from C++ objects to JavaScript.
907
+ *
908
+ * The exact semantics are:
909
+ * - Tracing garbage collections use |v8::EmbedderHeapTracer| or cppgc.
910
+ * - Non-tracing garbage collections refer to
911
+ * |v8::EmbedderRootsHandler::IsRoot()| whether the handle should
912
+ * be treated as root or not.
913
+ *
914
+ * Note that the base class cannot be instantiated itself. Choose from
915
+ * - TracedGlobal
916
+ * - TracedReference
917
+ */
918
+ template <typename T>
919
+ class BasicTracedReference : public TracedReferenceBase {
920
+ public:
921
+ /**
922
+ * Construct a Local<T> from this handle.
923
+ */
924
+ Local<T> Get(Isolate* isolate) const { return Local<T>::New(isolate, *this); }
925
+
926
+ template <class S>
927
+ V8_INLINE BasicTracedReference<S>& As() const {
928
+ return reinterpret_cast<BasicTracedReference<S>&>(
929
+ const_cast<BasicTracedReference<T>&>(*this));
930
+ }
931
+
932
+ T* operator->() const {
933
+ #ifdef V8_ENABLE_CHECKS
934
+ CheckValue();
935
+ #endif // V8_ENABLE_CHECKS
936
+ return reinterpret_cast<T*>(val_);
937
+ }
938
+ T* operator*() const {
939
+ #ifdef V8_ENABLE_CHECKS
940
+ CheckValue();
941
+ #endif // V8_ENABLE_CHECKS
942
+ return reinterpret_cast<T*>(val_);
943
+ }
944
+
924
945
  private:
925
946
  enum DestructionMode { kWithDestructor, kWithoutDestructor };
926
947
 
927
948
  /**
928
- * An empty TracedReferenceBase without storage cell.
949
+ * An empty BasicTracedReference without storage cell.
929
950
  */
930
- TracedReferenceBase() = default;
951
+ BasicTracedReference() = default;
931
952
 
932
- V8_INLINE static T* New(Isolate* isolate, T* that, void* slot,
933
- DestructionMode destruction_mode);
934
-
935
- T* val_ = nullptr;
953
+ V8_INLINE static internal::Address* New(Isolate* isolate, T* that, void* slot,
954
+ DestructionMode destruction_mode);
936
955
 
937
956
  friend class EmbedderHeapTracer;
938
957
  template <typename F>
@@ -943,27 +962,29 @@ class TracedReferenceBase {
943
962
  template <typename F>
944
963
  friend class TracedReference;
945
964
  template <typename F>
965
+ friend class BasicTracedReference;
966
+ template <typename F>
946
967
  friend class ReturnValue;
947
968
  };
948
969
 
949
970
  /**
950
971
  * A traced handle with destructor that clears the handle. For more details see
951
- * TracedReferenceBase.
972
+ * BasicTracedReference.
952
973
  */
953
974
  template <typename T>
954
- class TracedGlobal : public TracedReferenceBase<T> {
975
+ class TracedGlobal : public BasicTracedReference<T> {
955
976
  public:
956
- using TracedReferenceBase<T>::Reset;
977
+ using BasicTracedReference<T>::Reset;
957
978
 
958
979
  /**
959
- * Destructor resetting the handle.
980
+ * Destructor resetting the handle.Is
960
981
  */
961
982
  ~TracedGlobal() { this->Reset(); }
962
983
 
963
984
  /**
964
985
  * An empty TracedGlobal without storage cell.
965
986
  */
966
- TracedGlobal() : TracedReferenceBase<T>() {}
987
+ TracedGlobal() : BasicTracedReference<T>() {}
967
988
 
968
989
  /**
969
990
  * Construct a TracedGlobal from a Local.
@@ -972,9 +993,9 @@ class TracedGlobal : public TracedReferenceBase<T> {
972
993
  * pointing to the same object.
973
994
  */
974
995
  template <class S>
975
- TracedGlobal(Isolate* isolate, Local<S> that) : TracedReferenceBase<T>() {
996
+ TracedGlobal(Isolate* isolate, Local<S> that) : BasicTracedReference<T>() {
976
997
  this->val_ = this->New(isolate, that.val_, &this->val_,
977
- TracedReferenceBase<T>::kWithDestructor);
998
+ BasicTracedReference<T>::kWithDestructor);
978
999
  static_assert(std::is_base_of<T, S>::value, "type check");
979
1000
  }
980
1001
 
@@ -1071,7 +1092,7 @@ class TracedGlobal : public TracedReferenceBase<T> {
1071
1092
  * A traced handle without destructor that clears the handle. The embedder needs
1072
1093
  * to ensure that the handle is not accessed once the V8 object has been
1073
1094
  * reclaimed. This can happen when the handle is not passed through the
1074
- * EmbedderHeapTracer. For more details see TracedReferenceBase.
1095
+ * EmbedderHeapTracer. For more details see BasicTracedReference.
1075
1096
  *
1076
1097
  * The reference assumes the embedder has precise knowledge about references at
1077
1098
  * all times. In case V8 needs to separately handle on-stack references, the
@@ -1079,14 +1100,14 @@ class TracedGlobal : public TracedReferenceBase<T> {
1079
1100
  * |EmbedderHeapTracer::SetStackStart|.
1080
1101
  */
1081
1102
  template <typename T>
1082
- class TracedReference : public TracedReferenceBase<T> {
1103
+ class TracedReference : public BasicTracedReference<T> {
1083
1104
  public:
1084
- using TracedReferenceBase<T>::Reset;
1105
+ using BasicTracedReference<T>::Reset;
1085
1106
 
1086
1107
  /**
1087
1108
  * An empty TracedReference without storage cell.
1088
1109
  */
1089
- TracedReference() : TracedReferenceBase<T>() {}
1110
+ TracedReference() : BasicTracedReference<T>() {}
1090
1111
 
1091
1112
  /**
1092
1113
  * Construct a TracedReference from a Local.
@@ -1095,9 +1116,9 @@ class TracedReference : public TracedReferenceBase<T> {
1095
1116
  * pointing to the same object.
1096
1117
  */
1097
1118
  template <class S>
1098
- TracedReference(Isolate* isolate, Local<S> that) : TracedReferenceBase<T>() {
1119
+ TracedReference(Isolate* isolate, Local<S> that) : BasicTracedReference<T>() {
1099
1120
  this->val_ = this->New(isolate, that.val_, &this->val_,
1100
- TracedReferenceBase<T>::kWithoutDestructor);
1121
+ BasicTracedReference<T>::kWithoutDestructor);
1101
1122
  static_assert(std::is_base_of<T, S>::value, "type check");
1102
1123
  }
1103
1124
 
@@ -1173,14 +1194,6 @@ class TracedReference : public TracedReferenceBase<T> {
1173
1194
  return reinterpret_cast<TracedReference<S>&>(
1174
1195
  const_cast<TracedReference<T>&>(*this));
1175
1196
  }
1176
-
1177
- /**
1178
- * Returns true if this TracedReference is empty, i.e., has not been
1179
- * assigned an object. This version of IsEmpty is thread-safe.
1180
- */
1181
- bool IsEmptyThreadSafe() const {
1182
- return this->GetSlotThreadSafe() == nullptr;
1183
- }
1184
1197
  };
1185
1198
 
1186
1199
  /**
@@ -1197,7 +1210,7 @@ class TracedReference : public TracedReferenceBase<T> {
1197
1210
  * handle and may deallocate it. The behavior of accessing a handle
1198
1211
  * for which the handle scope has been deleted is undefined.
1199
1212
  */
1200
- class V8_EXPORT HandleScope {
1213
+ class V8_EXPORT V8_NODISCARD HandleScope {
1201
1214
  public:
1202
1215
  explicit HandleScope(Isolate* isolate);
1203
1216
 
@@ -1244,12 +1257,11 @@ class V8_EXPORT HandleScope {
1244
1257
  friend class Context;
1245
1258
  };
1246
1259
 
1247
-
1248
1260
  /**
1249
1261
  * A HandleScope which first allocates a handle in the current scope
1250
1262
  * which will be later filled with the escape value.
1251
1263
  */
1252
- class V8_EXPORT EscapableHandleScope : public HandleScope {
1264
+ class V8_EXPORT V8_NODISCARD EscapableHandleScope : public HandleScope {
1253
1265
  public:
1254
1266
  explicit EscapableHandleScope(Isolate* isolate);
1255
1267
  V8_INLINE ~EscapableHandleScope() = default;
@@ -1290,7 +1302,7 @@ class V8_EXPORT EscapableHandleScope : public HandleScope {
1290
1302
  * are allowed. It can be useful for debugging handle leaks.
1291
1303
  * Handles can be allocated within inner normal HandleScopes.
1292
1304
  */
1293
- class V8_EXPORT SealHandleScope {
1305
+ class V8_EXPORT V8_NODISCARD SealHandleScope {
1294
1306
  public:
1295
1307
  explicit SealHandleScope(Isolate* isolate);
1296
1308
  ~SealHandleScope();
@@ -1311,13 +1323,43 @@ class V8_EXPORT SealHandleScope {
1311
1323
  int prev_sealed_level_;
1312
1324
  };
1313
1325
 
1314
-
1315
1326
  // --- Special objects ---
1316
1327
 
1317
1328
  /**
1318
1329
  * The superclass of objects that can reside on V8's heap.
1319
1330
  */
1320
1331
  class V8_EXPORT Data {
1332
+ public:
1333
+ /**
1334
+ * Returns true if this data is a |v8::Value|.
1335
+ */
1336
+ bool IsValue() const;
1337
+
1338
+ /**
1339
+ * Returns true if this data is a |v8::Module|.
1340
+ */
1341
+ bool IsModule() const;
1342
+
1343
+ /**
1344
+ * Returns true if this data is a |v8::Private|.
1345
+ */
1346
+ bool IsPrivate() const;
1347
+
1348
+ /**
1349
+ * Returns true if this data is a |v8::ObjectTemplate|.
1350
+ */
1351
+ bool IsObjectTemplate() const;
1352
+
1353
+ /**
1354
+ * Returns true if this data is a |v8::FunctionTemplate|.
1355
+ */
1356
+ bool IsFunctionTemplate() const;
1357
+
1358
+ /**
1359
+ * Returns true if this data is a |v8::Context|.
1360
+ */
1361
+ bool IsContext() const;
1362
+
1321
1363
  private:
1322
1364
  Data();
1323
1365
  };
@@ -1398,10 +1440,12 @@ class ScriptOriginOptions {
1398
1440
  */
1399
1441
  class ScriptOrigin {
1400
1442
  public:
1401
- V8_INLINE ScriptOrigin(
1402
- Local<Value> resource_name,
1403
- Local<Integer> resource_line_offset = Local<Integer>(),
1404
- Local<Integer> resource_column_offset = Local<Integer>(),
1443
+ #if defined(_MSC_VER) && _MSC_VER >= 1910 /* Disable on VS2015 */
1444
+ V8_DEPRECATED("Use constructor with primitive C++ types")
1445
+ #endif
1446
+ V8_INLINE explicit ScriptOrigin(
1447
+ Local<Value> resource_name, Local<Integer> resource_line_offset,
1448
+ Local<Integer> resource_column_offset,
1405
1449
  Local<Boolean> resource_is_shared_cross_origin = Local<Boolean>(),
1406
1450
  Local<Integer> script_id = Local<Integer>(),
1407
1451
  Local<Value> source_map_url = Local<Value>(),
@@ -1409,21 +1453,47 @@ class ScriptOrigin {
1409
1453
  Local<Boolean> is_wasm = Local<Boolean>(),
1410
1454
  Local<Boolean> is_module = Local<Boolean>(),
1411
1455
  Local<PrimitiveArray> host_defined_options = Local<PrimitiveArray>());
1456
+ #if defined(_MSC_VER) && _MSC_VER >= 1910 /* Disable on VS2015 */
1457
+ V8_DEPRECATED("Use constructor that takes an isolate")
1458
+ #endif
1459
+ V8_INLINE explicit ScriptOrigin(
1460
+ Local<Value> resource_name, int resource_line_offset = 0,
1461
+ int resource_column_offset = 0,
1462
+ bool resource_is_shared_cross_origin = false, int script_id = -1,
1463
+ Local<Value> source_map_url = Local<Value>(),
1464
+ bool resource_is_opaque = false, bool is_wasm = false,
1465
+ bool is_module = false,
1466
+ Local<PrimitiveArray> host_defined_options = Local<PrimitiveArray>());
1467
+ V8_INLINE explicit ScriptOrigin(
1468
+ Isolate* isolate, Local<Value> resource_name,
1469
+ int resource_line_offset = 0, int resource_column_offset = 0,
1470
+ bool resource_is_shared_cross_origin = false, int script_id = -1,
1471
+ Local<Value> source_map_url = Local<Value>(),
1472
+ bool resource_is_opaque = false, bool is_wasm = false,
1473
+ bool is_module = false,
1474
+ Local<PrimitiveArray> host_defined_options = Local<PrimitiveArray>());
1412
1475
 
1413
1476
  V8_INLINE Local<Value> ResourceName() const;
1477
+ V8_DEPRECATED("Use getter with primitvie C++ types.")
1414
1478
  V8_INLINE Local<Integer> ResourceLineOffset() const;
1479
+ V8_DEPRECATED("Use getter with primitvie C++ types.")
1415
1480
  V8_INLINE Local<Integer> ResourceColumnOffset() const;
1481
+ V8_DEPRECATED("Use getter with primitvie C++ types.")
1416
1482
  V8_INLINE Local<Integer> ScriptID() const;
1483
+ V8_INLINE int LineOffset() const;
1484
+ V8_INLINE int ColumnOffset() const;
1485
+ V8_INLINE int ScriptId() const;
1417
1486
  V8_INLINE Local<Value> SourceMapUrl() const;
1418
1487
  V8_INLINE Local<PrimitiveArray> HostDefinedOptions() const;
1419
1488
  V8_INLINE ScriptOriginOptions Options() const { return options_; }
1420
1489
 
1421
1490
  private:
1491
+ Isolate* isolate_;
1422
1492
  Local<Value> resource_name_;
1423
- Local<Integer> resource_line_offset_;
1424
- Local<Integer> resource_column_offset_;
1493
+ int resource_line_offset_;
1494
+ int resource_column_offset_;
1425
1495
  ScriptOriginOptions options_;
1426
- Local<Integer> script_id_;
1496
+ int script_id_;
1427
1497
  Local<Value> source_map_url_;
1428
1498
  Local<PrimitiveArray> host_defined_options_;
1429
1499
  };
@@ -1482,6 +1552,50 @@ class V8_EXPORT Location {
1482
1552
  int column_number_;
1483
1553
  };
1484
1554
 
1555
+ /**
1556
+ * A fixed-sized array with elements of type Data.
1557
+ */
1558
+ class V8_EXPORT FixedArray : public Data {
1559
+ public:
1560
+ int Length() const;
1561
+ Local<Data> Get(Local<Context> context, int i) const;
1562
+ };
1563
+
1564
+ class V8_EXPORT ModuleRequest : public Data {
1565
+ public:
1566
+ /**
1567
+ * Returns the module specifier for this ModuleRequest.
1568
+ */
1569
+ Local<String> GetSpecifier() const;
1570
+
1571
+ /**
1572
+ * Returns the source code offset of this module request.
1573
+ * Use Module::SourceOffsetToLocation to convert this to line/column numbers.
1574
+ */
1575
+ int GetSourceOffset() const;
1576
+
1577
+ /**
1578
+ * Contains the import assertions for this request in the form:
1579
+ * [key1, value1, source_offset1, key2, value2, source_offset2, ...].
1580
+ * The keys and values are of type v8::String, and the source offsets are of
1581
+ * type Int32. Use Module::SourceOffsetToLocation to convert the source
1582
+ * offsets to Locations with line/column numbers.
1583
+ *
1584
+ * All assertions present in the module request will be supplied in this
1585
+ * list, regardless of whether they are supported by the host. Per
1586
+ * https://tc39.es/proposal-import-assertions/#sec-hostgetsupportedimportassertions,
1587
+ * hosts are expected to ignore assertions that they do not support (as
1588
+ * opposed to, for example, triggering an error if an unsupported assertion is
1589
+ * present).
1590
+ */
1591
+ Local<FixedArray> GetImportAssertions() const;
1592
+
1593
+ V8_INLINE static ModuleRequest* Cast(Data* data);
1594
+
1595
+ private:
1596
+ static void CheckCast(Data* obj);
1597
+ };
1598
+
1485
1599
  /**
1486
1600
  * A compiled JavaScript module.
1487
1601
  */
@@ -1516,28 +1630,48 @@ class V8_EXPORT Module : public Data {
1516
1630
  /**
1517
1631
  * Returns the number of modules requested by this module.
1518
1632
  */
1633
+ V8_DEPRECATED("Use Module::GetModuleRequests() and FixedArray::Length().")
1519
1634
  int GetModuleRequestsLength() const;
1520
1635
 
1521
1636
  /**
1522
1637
  * Returns the ith module specifier in this module.
1523
1638
  * i must be < GetModuleRequestsLength() and >= 0.
1524
1639
  */
1640
+ V8_DEPRECATED(
1641
+ "Use Module::GetModuleRequests() and ModuleRequest::GetSpecifier().")
1525
1642
  Local<String> GetModuleRequest(int i) const;
1526
1643
 
1527
1644
  /**
1528
1645
  * Returns the source location (line number and column number) of the ith
1529
1646
  * module specifier's first occurrence in this module.
1530
1647
  */
1648
+ V8_DEPRECATED(
1649
+ "Use Module::GetModuleRequests(), ModuleRequest::GetSourceOffset(), and "
1650
+ "Module::SourceOffsetToLocation().")
1531
1651
  Location GetModuleRequestLocation(int i) const;
1532
1652
 
1653
+ /**
1654
+ * Returns the ModuleRequests for this module.
1655
+ */
1656
+ Local<FixedArray> GetModuleRequests() const;
1657
+
1658
+ /**
1659
+ * For the given source text offset in this module, returns the corresponding
1660
+ * Location with line and column numbers.
1661
+ */
1662
+ Location SourceOffsetToLocation(int offset) const;
1663
+
1533
1664
  /**
1534
1665
  * Returns the identity hash for this object.
1535
1666
  */
1536
1667
  int GetIdentityHash() const;
1537
1668
 
1538
- typedef MaybeLocal<Module> (*ResolveCallback)(Local<Context> context,
1539
- Local<String> specifier,
1540
- Local<Module> referrer);
1669
+ using ResolveCallback =
1670
+ MaybeLocal<Module> (*)(Local<Context> context, Local<String> specifier,
1671
+ Local<Module> referrer);
1672
+ using ResolveModuleCallback = MaybeLocal<Module> (*)(
1673
+ Local<Context> context, Local<String> specifier,
1674
+ Local<FixedArray> import_assertions, Local<Module> referrer);
1541
1675
 
1542
1676
  /**
1543
1677
  * Instantiates the module and its dependencies.
@@ -1546,16 +1680,23 @@ class V8_EXPORT Module : public Data {
1546
1680
  * instantiation. (In the case where the callback throws an exception, that
1547
1681
  * exception is propagated.)
1548
1682
  */
1683
+ V8_DEPRECATED(
1684
+ "Use the version of InstantiateModule that takes a ResolveModuleCallback "
1685
+ "parameter")
1549
1686
  V8_WARN_UNUSED_RESULT Maybe<bool> InstantiateModule(Local<Context> context,
1550
1687
  ResolveCallback callback);
1688
+ V8_WARN_UNUSED_RESULT Maybe<bool> InstantiateModule(
1689
+ Local<Context> context, ResolveModuleCallback callback);
1551
1690
 
1552
1691
  /**
1553
1692
  * Evaluates the module and its dependencies.
1554
1693
  *
1555
- * If status is kInstantiated, run the module's code. On success, set status
1556
- * to kEvaluated and return the completion value; on failure, set status to
1557
- * kErrored and propagate the thrown exception (which is then also available
1558
- * via |GetException|).
1694
+ * If status is kInstantiated, run the module's code and return a Promise
1695
+ * object. On success, set status to kEvaluated and resolve the Promise with
1696
+ * the completion value; on failure, set status to kErrored and reject the
1697
+ * Promise with the error.
1698
+ *
1699
+ * If IsGraphAsync() is false, the returned Promise is settled.
1559
1700
  */
1560
1701
  V8_WARN_UNUSED_RESULT MaybeLocal<Value> Evaluate(Local<Context> context);
1561
1702
 
@@ -1581,6 +1722,14 @@ class V8_EXPORT Module : public Data {
1581
1722
  */
1582
1723
  int ScriptId();
1583
1724
 
1725
+ /**
1726
+ * Returns whether this module or any of its requested modules is async,
1727
+ * i.e. contains top-level await.
1728
+ *
1729
+ * The module's status must be at least kInstantiated.
1730
+ */
1731
+ bool IsGraphAsync() const;
1732
+
1584
1733
  /**
1585
1734
  * Returns whether the module is a SourceTextModule.
1586
1735
  */
@@ -1594,12 +1743,12 @@ class V8_EXPORT Module : public Data {
1594
1743
  /*
1595
1744
  * Callback defined in the embedder. This is responsible for setting
1596
1745
  * the module's exported values with calls to SetSyntheticModuleExport().
1597
- * The callback must return a Value to indicate success (where no
1746
+ * The callback must return a resolved Promise to indicate success (where no
1598
1747
  * exception was thrown) and return an empy MaybeLocal to indicate falure
1599
1748
  * (where an exception was thrown).
1600
1749
  */
1601
- typedef MaybeLocal<Value> (*SyntheticModuleEvaluationSteps)(
1602
- Local<Context> context, Local<Module> module);
1750
+ using SyntheticModuleEvaluationSteps =
1751
+ MaybeLocal<Value> (*)(Local<Context> context, Local<Module> module);
1603
1752
 
1604
1753
  /**
1605
1754
  * Creates a new SyntheticModule with the specified export names, where
@@ -1622,13 +1771,18 @@ class V8_EXPORT Module : public Data {
1622
1771
  */
1623
1772
  V8_WARN_UNUSED_RESULT Maybe<bool> SetSyntheticModuleExport(
1624
1773
  Isolate* isolate, Local<String> export_name, Local<Value> export_value);
1625
- V8_DEPRECATE_SOON(
1774
+ V8_DEPRECATED(
1626
1775
  "Use the preceding SetSyntheticModuleExport with an Isolate parameter, "
1627
1776
  "instead of the one that follows. The former will throw a runtime "
1628
1777
  "error if called for an export that doesn't exist (as per spec); "
1629
1778
  "the latter will crash with a failed CHECK().")
1630
1779
  void SetSyntheticModuleExport(Local<String> export_name,
1631
1780
  Local<Value> export_value);
1781
+
1782
+ V8_INLINE static Module* Cast(Data* data);
1783
+
1784
+ private:
1785
+ static void CheckCast(Data* obj);
1632
1786
  };
1633
1787
 
1634
1788
  /**
@@ -1657,6 +1811,7 @@ class V8_EXPORT Script {
1657
1811
  Local<UnboundScript> GetUnboundScript();
1658
1812
  };
1659
1813
 
1814
+ enum class ScriptType { kClassic, kModule };
1660
1815
 
1661
1816
  /**
1662
1817
  * For compiling scripts.
@@ -1709,8 +1864,8 @@ class V8_EXPORT ScriptCompiler {
1709
1864
  // Source takes ownership of CachedData.
1710
1865
  V8_INLINE Source(Local<String> source_string, const ScriptOrigin& origin,
1711
1866
  CachedData* cached_data = nullptr);
1712
- V8_INLINE Source(Local<String> source_string,
1713
- CachedData* cached_data = nullptr);
1867
+ V8_INLINE explicit Source(Local<String> source_string,
1868
+ CachedData* cached_data = nullptr);
1714
1869
  V8_INLINE ~Source();
1715
1870
 
1716
1871
  // Ownership of the CachedData or its buffers is *not* transferred to the
@@ -1731,8 +1886,8 @@ class V8_EXPORT ScriptCompiler {
1731
1886
 
1732
1887
  // Origin information
1733
1888
  Local<Value> resource_name;
1734
- Local<Integer> resource_line_offset;
1735
- Local<Integer> resource_column_offset;
1889
+ int resource_line_offset;
1890
+ int resource_column_offset;
1736
1891
  ScriptOriginOptions resource_options;
1737
1892
  Local<Value> source_map_url;
1738
1893
  Local<PrimitiveArray> host_defined_options;
@@ -1800,10 +1955,10 @@ class V8_EXPORT ScriptCompiler {
1800
1955
  */
1801
1956
  class V8_EXPORT StreamedSource {
1802
1957
  public:
1803
- enum Encoding { ONE_BYTE, TWO_BYTE, UTF8 };
1958
+ enum Encoding { ONE_BYTE, TWO_BYTE, UTF8, WINDOWS_1252 };
1804
1959
 
1805
1960
  #if defined(_MSC_VER) && _MSC_VER >= 1910 /* Disable on VS2015 */
1806
- V8_DEPRECATE_SOON(
1961
+ V8_DEPRECATED(
1807
1962
  "This class takes ownership of source_stream, so use the constructor "
1808
1963
  "taking a unique_ptr to make these semantics clearer")
1809
1964
  #endif
@@ -1824,7 +1979,7 @@ class V8_EXPORT ScriptCompiler {
1824
1979
 
1825
1980
  /**
1826
1981
  * A streaming task which the embedder must run on a background thread to
1827
- * stream scripts into V8. Returned by ScriptCompiler::StartStreamingScript.
1982
+ * stream scripts into V8. Returned by ScriptCompiler::StartStreaming.
1828
1983
  */
1829
1984
  class V8_EXPORT ScriptStreamingTask final {
1830
1985
  public:
@@ -1873,7 +2028,8 @@ class V8_EXPORT ScriptCompiler {
1873
2028
  *
1874
2029
  * Note that when producing cached data, the source must point to NULL for
1875
2030
  * cached data. When consuming cached data, the cached data must have been
1876
- * produced by the same version of V8.
2031
+ * produced by the same version of V8, and the embedder needs to ensure the
2032
+ * cached data is the correct one for the given script.
1877
2033
  *
1878
2034
  * \param source Script source code.
1879
2035
  * \return Compiled script object (context independent; for running it must be
@@ -1911,9 +2067,13 @@ class V8_EXPORT ScriptCompiler {
1911
2067
  * This API allows to start the streaming with as little data as possible, and
1912
2068
  * the remaining data (for example, the ScriptOrigin) is passed to Compile.
1913
2069
  */
2070
+ V8_DEPRECATED("Use ScriptCompiler::StartStreaming instead.")
1914
2071
  static ScriptStreamingTask* StartStreamingScript(
1915
2072
  Isolate* isolate, StreamedSource* source,
1916
2073
  CompileOptions options = kNoCompileOptions);
2074
+ static ScriptStreamingTask* StartStreaming(
2075
+ Isolate* isolate, StreamedSource* source,
2076
+ ScriptType type = ScriptType::kClassic);
1917
2077
 
1918
2078
  /**
1919
2079
  * Compiles a streamed script (bound to current context).
@@ -1958,6 +2118,17 @@ class V8_EXPORT ScriptCompiler {
1958
2118
  CompileOptions options = kNoCompileOptions,
1959
2119
  NoCacheReason no_cache_reason = kNoCacheNoReason);
1960
2120
 
2121
+ /**
2122
+ * Compiles a streamed module script.
2123
+ *
2124
+ * This can only be called after the streaming has finished
2125
+ * (ScriptStreamingTask has been run). V8 doesn't construct the source string
2126
+ * during streaming, so the embedder needs to pass the full source here.
2127
+ */
2128
+ static V8_WARN_UNUSED_RESULT MaybeLocal<Module> CompileModule(
2129
+ Local<Context> context, StreamedSource* v8_source,
2130
+ Local<String> full_source_string, const ScriptOrigin& origin);
2131
+
1961
2132
  /**
1962
2133
  * Compile a function for a given context. This is equivalent to running
1963
2134
  *
@@ -2018,6 +2189,8 @@ class V8_EXPORT Message {
2018
2189
  */
2019
2190
  Isolate* GetIsolate() const;
2020
2191
 
2192
+ V8_WARN_UNUSED_RESULT MaybeLocal<String> GetSource(
2193
+ Local<Context> context) const;
2021
2194
  V8_WARN_UNUSED_RESULT MaybeLocal<String> GetSourceLine(
2022
2195
  Local<Context> context) const;
2023
2196
 
@@ -2192,6 +2365,17 @@ class V8_EXPORT StackFrame {
2192
2365
  */
2193
2366
  Local<String> GetScriptNameOrSourceURL() const;
2194
2367
 
2368
+ /**
2369
+ * Returns the source of the script for the function for this StackFrame.
2370
+ */
2371
+ Local<String> GetScriptSource() const;
2372
+
2373
+ /**
2374
+ * Returns the source mapping URL (if one is present) of the script for
2375
+ * the function for this StackFrame.
2376
+ */
2377
+ Local<String> GetScriptSourceMappingURL() const;
2378
+
2195
2379
  /**
2196
2380
  * Returns the name of the function associated with this stack frame.
2197
2381
  */
@@ -2234,14 +2418,25 @@ enum StateTag {
2234
2418
  IDLE
2235
2419
  };
2236
2420
 
2421
+ // Holds the callee saved registers needed for the stack unwinder. It is the
2422
+ // empty struct if no registers are required. Implemented in
2423
+ // include/v8-unwinder-state.h.
2424
+ struct CalleeSavedRegisters;
2425
+
2237
2426
  // A RegisterState represents the current state of registers used
2238
2427
  // by the sampling profiler API.
2239
- struct RegisterState {
2240
- RegisterState() : pc(nullptr), sp(nullptr), fp(nullptr), lr(nullptr) {}
2428
+ struct V8_EXPORT RegisterState {
2429
+ RegisterState();
2430
+ ~RegisterState();
2431
+ RegisterState(const RegisterState& other);
2432
+ RegisterState& operator=(const RegisterState& other);
2433
+
2241
2434
  void* pc; // Instruction pointer.
2242
2435
  void* sp; // Stack pointer.
2243
2436
  void* fp; // Frame pointer.
2244
2437
  void* lr; // Link register (or nullptr on platforms without a link register).
2438
+ // Callee saved registers (or null if no callee saved registers were stored)
2439
+ std::unique_ptr<CalleeSavedRegisters> callee_saved;
2245
2440
  };
2246
2441
 
2247
2442
  // The output structure filled up by GetStackSample API function.
@@ -2262,14 +2457,6 @@ struct JSEntryStub {
2262
2457
  MemoryRange code;
2263
2458
  };
2264
2459
 
2265
- struct UnwindState {
2266
- MemoryRange code_range;
2267
- MemoryRange embedded_code_range;
2268
- JSEntryStub js_entry_stub;
2269
- JSEntryStub js_construct_entry_stub;
2270
- JSEntryStub js_run_microtasks_entry_stub;
2271
- };
2272
-
2273
2460
  struct JSEntryStubs {
2274
2461
  JSEntryStub js_entry_stub;
2275
2462
  JSEntryStub js_construct_entry_stub;
@@ -2830,6 +3017,11 @@ class V8_EXPORT Value : public Data {
2830
3017
  */
2831
3018
  bool IsProxy() const;
2832
3019
 
3020
+ /**
3021
+ * Returns true if this value is a WasmMemoryObject.
3022
+ */
3023
+ bool IsWasmMemoryObject() const;
3024
+
2833
3025
  /**
2834
3026
  * Returns true if this value is a WasmModuleObject.
2835
3027
  */
@@ -2934,6 +3126,8 @@ class V8_EXPORT Value : public Data {
2934
3126
  bool FullIsUndefined() const;
2935
3127
  bool FullIsNull() const;
2936
3128
  bool FullIsString() const;
3129
+
3130
+ static void CheckCast(Data* that);
2937
3131
  };
2938
3132
 
2939
3133
 
@@ -2950,11 +3144,11 @@ class V8_EXPORT Primitive : public Value { };
2950
3144
  class V8_EXPORT Boolean : public Primitive {
2951
3145
  public:
2952
3146
  bool Value() const;
2953
- V8_INLINE static Boolean* Cast(v8::Value* obj);
3147
+ V8_INLINE static Boolean* Cast(v8::Data* data);
2954
3148
  V8_INLINE static Local<Boolean> New(Isolate* isolate, bool value);
2955
3149
 
2956
3150
  private:
2957
- static void CheckCast(v8::Value* obj);
3151
+ static void CheckCast(v8::Data* that);
2958
3152
  };
2959
3153
 
2960
3154
 
@@ -2972,10 +3166,10 @@ class V8_EXPORT Name : public Primitive {
2972
3166
  */
2973
3167
  int GetIdentityHash();
2974
3168
 
2975
- V8_INLINE static Name* Cast(Value* obj);
3169
+ V8_INLINE static Name* Cast(Data* data);
2976
3170
 
2977
3171
  private:
2978
- static void CheckCast(Value* obj);
3172
+ static void CheckCast(Data* that);
2979
3173
  };
2980
3174
 
2981
3175
  /**
@@ -3089,16 +3283,21 @@ class V8_EXPORT String : public Name {
3089
3283
  V8_INLINE static Local<String> Empty(Isolate* isolate);
3090
3284
 
3091
3285
  /**
3092
- * Returns true if the string is external
3286
+ * Returns true if the string is external.
3093
3287
  */
3094
3288
  bool IsExternal() const;
3095
3289
 
3290
+ /**
3291
+ * Returns true if the string is both external and two-byte.
3292
+ */
3293
+ bool IsExternalTwoByte() const;
3294
+
3096
3295
  /**
3097
3296
  * Returns true if the string is both external and one-byte.
3098
3297
  */
3099
3298
  bool IsExternalOneByte() const;
3100
3299
 
3101
- class V8_EXPORT ExternalStringResourceBase { // NOLINT
3300
+ class V8_EXPORT ExternalStringResourceBase {
3102
3301
  public:
3103
3302
  virtual ~ExternalStringResourceBase() = default;
3104
3303
 
@@ -3164,7 +3363,8 @@ class V8_EXPORT String : public Name {
3164
3363
  ~ExternalStringResource() override = default;
3165
3364
 
3166
3365
  /**
3167
- * The string data from the underlying buffer.
3366
+ * The string data from the underlying buffer. If the resource is cacheable
3367
+ * then data() must return the same value for all invocations.
3168
3368
  */
3169
3369
  virtual const uint16_t* data() const = 0;
3170
3370
 
@@ -3173,8 +3373,29 @@ class V8_EXPORT String : public Name {
3173
3373
  */
3174
3374
  virtual size_t length() const = 0;
3175
3375
 
3376
+ /**
3377
+ * Returns the cached data from the underlying buffer. This method can be
3378
+ * called only for cacheable resources (i.e. IsCacheable() == true) and only
3379
+ * after UpdateDataCache() was called.
3380
+ */
3381
+ const uint16_t* cached_data() const {
3382
+ CheckCachedDataInvariants();
3383
+ return cached_data_;
3384
+ }
3385
+
3386
+ /**
3387
+ * Update {cached_data_} with the data from the underlying buffer. This can
3388
+ * be called only for cacheable resources.
3389
+ */
3390
+ void UpdateDataCache();
3391
+
3176
3392
  protected:
3177
3393
  ExternalStringResource() = default;
3394
+
3395
+ private:
3396
+ void CheckCachedDataInvariants() const;
3397
+
3398
+ const uint16_t* cached_data_ = nullptr;
3178
3399
  };
3179
3400
 
3180
3401
  /**
@@ -3195,12 +3416,39 @@ class V8_EXPORT String : public Name {
3195
3416
  * buffer.
3196
3417
  */
3197
3418
  ~ExternalOneByteStringResource() override = default;
3198
- /** The string data from the underlying buffer.*/
3419
+
3420
+ /**
3421
+ * The string data from the underlying buffer. If the resource is cacheable
3422
+ * then data() must return the same value for all invocations.
3423
+ */
3199
3424
  virtual const char* data() const = 0;
3425
+
3200
3426
  /** The number of Latin-1 characters in the string.*/
3201
3427
  virtual size_t length() const = 0;
3428
+
3429
+ /**
3430
+ * Returns the cached data from the underlying buffer. If the resource is
3431
+ * uncacheable or if UpdateDataCache() was not called before, it has
3432
+ * undefined behaviour.
3433
+ */
3434
+ const char* cached_data() const {
3435
+ CheckCachedDataInvariants();
3436
+ return cached_data_;
3437
+ }
3438
+
3439
+ /**
3440
+ * Update {cached_data_} with the data from the underlying buffer. This can
3441
+ * be called only for cacheable resources.
3442
+ */
3443
+ void UpdateDataCache();
3444
+
3202
3445
  protected:
3203
3446
  ExternalOneByteStringResource() = default;
3447
+
3448
+ private:
3449
+ void CheckCachedDataInvariants() const;
3450
+
3451
+ const char* cached_data_ = nullptr;
3204
3452
  };
3205
3453
 
3206
3454
  /**
@@ -3223,7 +3471,7 @@ class V8_EXPORT String : public Name {
3223
3471
  */
3224
3472
  const ExternalOneByteStringResource* GetExternalOneByteStringResource() const;
3225
3473
 
3226
- V8_INLINE static String* Cast(v8::Value* obj);
3474
+ V8_INLINE static String* Cast(v8::Data* data);
3227
3475
 
3228
3476
  /**
3229
3477
  * Allocates a new string from a UTF-8 literal. This is equivalent to calling
@@ -3380,7 +3628,7 @@ class V8_EXPORT String : public Name {
3380
3628
  const char* literal,
3381
3629
  NewStringType type, int length);
3382
3630
 
3383
- static void CheckCast(v8::Value* obj);
3631
+ static void CheckCast(v8::Data* that);
3384
3632
  };
3385
3633
 
3386
3634
  // Zero-length string specialization (templated string size includes
@@ -3400,8 +3648,9 @@ class V8_EXPORT Symbol : public Name {
3400
3648
  * Returns the description string of the symbol, or undefined if none.
3401
3649
  */
3402
3650
  Local<Value> Description() const;
3651
+ Local<Value> Description(Isolate* isolate) const;
3403
3652
 
3404
- V8_DEPRECATE_SOON("Use Symbol::Description()")
3653
+ V8_DEPRECATED("Use Symbol::Description()")
3405
3654
  Local<Value> Name() const { return Description(); }
3406
3655
 
3407
3656
  /**
@@ -3440,11 +3689,11 @@ class V8_EXPORT Symbol : public Name {
3440
3689
  static Local<Symbol> GetToStringTag(Isolate* isolate);
3441
3690
  static Local<Symbol> GetUnscopables(Isolate* isolate);
3442
3691
 
3443
- V8_INLINE static Symbol* Cast(Value* obj);
3692
+ V8_INLINE static Symbol* Cast(Data* data);
3444
3693
 
3445
3694
  private:
3446
3695
  Symbol();
3447
- static void CheckCast(Value* obj);
3696
+ static void CheckCast(Data* that);
3448
3697
  };
3449
3698
 
3450
3699
 
@@ -3493,10 +3742,11 @@ class V8_EXPORT Number : public Primitive {
3493
3742
  public:
3494
3743
  double Value() const;
3495
3744
  static Local<Number> New(Isolate* isolate, double value);
3496
- V8_INLINE static Number* Cast(v8::Value* obj);
3745
+ V8_INLINE static Number* Cast(v8::Data* data);
3746
+
3497
3747
  private:
3498
3748
  Number();
3499
- static void CheckCast(v8::Value* obj);
3749
+ static void CheckCast(v8::Data* that);
3500
3750
  };
3501
3751
 
3502
3752
 
@@ -3508,10 +3758,11 @@ class V8_EXPORT Integer : public Number {
3508
3758
  static Local<Integer> New(Isolate* isolate, int32_t value);
3509
3759
  static Local<Integer> NewFromUnsigned(Isolate* isolate, uint32_t value);
3510
3760
  int64_t Value() const;
3511
- V8_INLINE static Integer* Cast(v8::Value* obj);
3761
+ V8_INLINE static Integer* Cast(v8::Data* data);
3762
+
3512
3763
  private:
3513
3764
  Integer();
3514
- static void CheckCast(v8::Value* obj);
3765
+ static void CheckCast(v8::Data* that);
3515
3766
  };
3516
3767
 
3517
3768
 
@@ -3521,11 +3772,11 @@ class V8_EXPORT Integer : public Number {
3521
3772
  class V8_EXPORT Int32 : public Integer {
3522
3773
  public:
3523
3774
  int32_t Value() const;
3524
- V8_INLINE static Int32* Cast(v8::Value* obj);
3775
+ V8_INLINE static Int32* Cast(v8::Data* data);
3525
3776
 
3526
3777
  private:
3527
3778
  Int32();
3528
- static void CheckCast(v8::Value* obj);
3779
+ static void CheckCast(v8::Data* that);
3529
3780
  };
3530
3781
 
3531
3782
 
@@ -3535,11 +3786,11 @@ class V8_EXPORT Int32 : public Integer {
3535
3786
  class V8_EXPORT Uint32 : public Integer {
3536
3787
  public:
3537
3788
  uint32_t Value() const;
3538
- V8_INLINE static Uint32* Cast(v8::Value* obj);
3789
+ V8_INLINE static Uint32* Cast(v8::Data* data);
3539
3790
 
3540
3791
  private:
3541
3792
  Uint32();
3542
- static void CheckCast(v8::Value* obj);
3793
+ static void CheckCast(v8::Data* that);
3543
3794
  };
3544
3795
 
3545
3796
  /**
@@ -3590,11 +3841,11 @@ class V8_EXPORT BigInt : public Primitive {
3590
3841
  */
3591
3842
  void ToWordsArray(int* sign_bit, int* word_count, uint64_t* words) const;
3592
3843
 
3593
- V8_INLINE static BigInt* Cast(v8::Value* obj);
3844
+ V8_INLINE static BigInt* Cast(v8::Data* data);
3594
3845
 
3595
3846
  private:
3596
3847
  BigInt();
3597
- static void CheckCast(v8::Value* obj);
3848
+ static void CheckCast(v8::Data* that);
3598
3849
  };
3599
3850
 
3600
3851
  /**
@@ -3616,23 +3867,17 @@ enum PropertyAttribute {
3616
3867
  * setting|getting a particular property. See Object and ObjectTemplate's
3617
3868
  * method SetAccessor.
3618
3869
  */
3619
- typedef void (*AccessorGetterCallback)(
3620
- Local<String> property,
3621
- const PropertyCallbackInfo<Value>& info);
3622
- typedef void (*AccessorNameGetterCallback)(
3623
- Local<Name> property,
3624
- const PropertyCallbackInfo<Value>& info);
3625
-
3626
-
3627
- typedef void (*AccessorSetterCallback)(
3628
- Local<String> property,
3629
- Local<Value> value,
3630
- const PropertyCallbackInfo<void>& info);
3631
- typedef void (*AccessorNameSetterCallback)(
3632
- Local<Name> property,
3633
- Local<Value> value,
3634
- const PropertyCallbackInfo<void>& info);
3870
+ using AccessorGetterCallback =
3871
+ void (*)(Local<String> property, const PropertyCallbackInfo<Value>& info);
3872
+ using AccessorNameGetterCallback =
3873
+ void (*)(Local<Name> property, const PropertyCallbackInfo<Value>& info);
3635
3874
 
3875
+ using AccessorSetterCallback = void (*)(Local<String> property,
3876
+ Local<Value> value,
3877
+ const PropertyCallbackInfo<void>& info);
3878
+ using AccessorNameSetterCallback =
3879
+ void (*)(Local<Name> property, Local<Value> value,
3880
+ const PropertyCallbackInfo<void>& info);
3636
3881
 
3637
3882
  /**
3638
3883
  * Access control specifications.
@@ -3757,8 +4002,7 @@ class V8_EXPORT Object : public Value {
3757
4002
  //
3758
4003
  // Returns true on success.
3759
4004
  V8_WARN_UNUSED_RESULT Maybe<bool> DefineProperty(
3760
- Local<Context> context, Local<Name> key,
3761
- PropertyDescriptor& descriptor); // NOLINT(runtime/references)
4005
+ Local<Context> context, Local<Name> key, PropertyDescriptor& descriptor);
3762
4006
 
3763
4007
  V8_WARN_UNUSED_RESULT MaybeLocal<Value> Get(Local<Context> context,
3764
4008
  Local<Value> key);
@@ -3941,10 +4185,10 @@ class V8_EXPORT Object : public Value {
3941
4185
  return object.val_->InternalFieldCount();
3942
4186
  }
3943
4187
 
3944
- /** Same as above, but works for TracedReferenceBase. */
4188
+ /** Same as above, but works for BasicTracedReference. */
3945
4189
  V8_INLINE static int InternalFieldCount(
3946
- const TracedReferenceBase<Object>& object) {
3947
- return object.val_->InternalFieldCount();
4190
+ const BasicTracedReference<Object>& object) {
4191
+ return object->InternalFieldCount();
3948
4192
  }
3949
4193
 
3950
4194
  /** Gets the value from an internal field. */
@@ -3968,8 +4212,8 @@ class V8_EXPORT Object : public Value {
3968
4212
 
3969
4213
  /** Same as above, but works for TracedGlobal. */
3970
4214
  V8_INLINE static void* GetAlignedPointerFromInternalField(
3971
- const TracedReferenceBase<Object>& object, int index) {
3972
- return object.val_->GetAlignedPointerFromInternalField(index);
4215
+ const BasicTracedReference<Object>& object, int index) {
4216
+ return object->GetAlignedPointerFromInternalField(index);
3973
4217
  }
3974
4218
 
3975
4219
  /**
@@ -4067,12 +4311,20 @@ class V8_EXPORT Object : public Value {
4067
4311
  /**
4068
4312
  * Returns the context in which the object was created.
4069
4313
  */
4314
+ // TODO(chromium:1166077): Mark as deprecate once users are updated.
4315
+ V8_DEPRECATE_SOON("Use MaybeLocal<Context> GetCreationContext()")
4070
4316
  Local<Context> CreationContext();
4317
+ MaybeLocal<Context> GetCreationContext();
4071
4318
 
4072
4319
  /** Same as above, but works for Persistents */
4073
- V8_INLINE static Local<Context> CreationContext(
4320
+ // TODO(chromium:1166077): Mark as deprecate once users are updated.
4321
+ V8_DEPRECATE_SOON(
4322
+ "Use MaybeLocal<Context> GetCreationContext(const "
4323
+ "PersistentBase<Object>& object)")
4324
+ static Local<Context> CreationContext(const PersistentBase<Object>& object);
4325
+ V8_INLINE static MaybeLocal<Context> GetCreationContext(
4074
4326
  const PersistentBase<Object>& object) {
4075
- return object.val_->CreationContext();
4327
+ return object.val_->GetCreationContext();
4076
4328
  }
4077
4329
 
4078
4330
  /**
@@ -4152,6 +4404,16 @@ class V8_EXPORT Object : public Value {
4152
4404
 
4153
4405
  V8_INLINE static Object* Cast(Value* obj);
4154
4406
 
4407
+ /**
4408
+ * Support for TC39 "dynamic code brand checks" proposal.
4409
+ *
4410
+ * This API allows to query whether an object was constructed from a
4411
+ * "code like" ObjectTemplate.
4412
+ *
4413
+ * See also: v8::ObjectTemplate::SetCodeLike
4414
+ */
4415
+ bool IsCodeLike(Isolate* isolate);
4416
+
4155
4417
  private:
4156
4418
  Object();
4157
4419
  static void CheckCast(Value* obj);
@@ -4180,6 +4442,7 @@ class V8_EXPORT Array : public Object {
4180
4442
  static Local<Array> New(Isolate* isolate, Local<Value>* elements,
4181
4443
  size_t length);
4182
4444
  V8_INLINE static Array* Cast(Value* obj);
4445
+
4183
4446
  private:
4184
4447
  Array();
4185
4448
  static void CheckCast(Value* obj);
@@ -4265,7 +4528,7 @@ class ReturnValue {
4265
4528
  template <typename S>
4266
4529
  V8_INLINE void Set(const Global<S>& handle);
4267
4530
  template <typename S>
4268
- V8_INLINE void Set(const TracedReferenceBase<S>& handle);
4531
+ V8_INLINE void Set(const BasicTracedReference<S>& handle);
4269
4532
  template <typename S>
4270
4533
  V8_INLINE void Set(const Local<S> handle);
4271
4534
  // Fast primitive setters
@@ -4474,8 +4737,7 @@ class PropertyCallbackInfo {
4474
4737
  internal::Address* args_;
4475
4738
  };
4476
4739
 
4477
-
4478
- typedef void (*FunctionCallback)(const FunctionCallbackInfo<Value>& info);
4740
+ using FunctionCallback = void (*)(const FunctionCallbackInfo<Value>& info);
4479
4741
 
4480
4742
  enum class ConstructorBehavior { kThrow, kAllow };
4481
4743
 
@@ -4536,6 +4798,11 @@ class V8_EXPORT Function : public Object {
4536
4798
  * User-defined name assigned to the "displayName" property of this function.
4537
4799
  * Used to facilitate debugging and profiling of JavaScript code.
4538
4800
  */
4801
+ V8_DEPRECATED(
4802
+ "Use v8::Object::Get() instead to look up \"displayName\". "
4803
+ "V8 and DevTools no longer use \"displayName\" in stack "
4804
+ "traces, but the standard \"name\" property. "
4805
+ "See http://crbug.com/1177685.")
4539
4806
  Local<Value> GetDisplayName() const;
4540
4807
 
4541
4808
  /**
@@ -4560,6 +4827,15 @@ class V8_EXPORT Function : public Object {
4560
4827
  */
4561
4828
  Local<Value> GetBoundFunction() const;
4562
4829
 
4830
+ /**
4831
+ * Calls builtin Function.prototype.toString on this function.
4832
+ * This is different from Value::ToString() that may call a user-defined
4833
+ * toString() function, and different than Object::ObjectProtoToString() which
4834
+ * always serializes "[object Function]".
4835
+ */
4836
+ V8_WARN_UNUSED_RESULT MaybeLocal<String> FunctionProtoToString(
4837
+ Local<Context> context);
4838
+
4563
4839
  ScriptOrigin GetScriptOrigin() const;
4564
4840
  V8_INLINE static Function* Cast(Value* obj);
4565
4841
  static const int kLineOffsetNotFound;
@@ -4653,6 +4929,12 @@ class V8_EXPORT Promise : public Object {
4653
4929
  */
4654
4930
  void MarkAsHandled();
4655
4931
 
4932
+ /**
4933
+ * Marks this promise as silent to prevent pausing the debugger when the
4934
+ * promise is rejected.
4935
+ */
4936
+ void MarkAsSilent();
4937
+
4656
4938
  V8_INLINE static Promise* Cast(Value* obj);
4657
4939
 
4658
4940
  static const int kEmbedderFieldCount = V8_PROMISE_INTERNAL_FIELD_COUNT;
@@ -4827,6 +5109,22 @@ class V8_EXPORT CompiledWasmModule {
4827
5109
  const std::string source_url_;
4828
5110
  };
4829
5111
 
5112
+ // An instance of WebAssembly.Memory.
5113
+ class V8_EXPORT WasmMemoryObject : public Object {
5114
+ public:
5115
+ WasmMemoryObject() = delete;
5116
+
5117
+ /**
5118
+ * Returns underlying ArrayBuffer.
5119
+ */
5120
+ Local<ArrayBuffer> Buffer();
5121
+
5122
+ V8_INLINE static WasmMemoryObject* Cast(Value* obj);
5123
+
5124
+ private:
5125
+ static void CheckCast(Value* object);
5126
+ };
5127
+
4830
5128
  // An instance of WebAssembly.Module.
4831
5129
  class V8_EXPORT WasmModuleObject : public Object {
4832
5130
  public:
@@ -5090,7 +5388,7 @@ class V8_EXPORT ArrayBuffer : public Object {
5090
5388
  * Note that it is unsafe to call back into V8 from any of the allocator
5091
5389
  * functions.
5092
5390
  */
5093
- class V8_EXPORT Allocator { // NOLINT
5391
+ class V8_EXPORT Allocator {
5094
5392
  public:
5095
5393
  virtual ~Allocator() = default;
5096
5394
 
@@ -5215,7 +5513,7 @@ class V8_EXPORT ArrayBuffer : public Object {
5215
5513
  * |Allocator::Free| once all ArrayBuffers referencing it are collected by
5216
5514
  * the garbage collector.
5217
5515
  */
5218
- V8_DEPRECATE_SOON(
5516
+ V8_DEPRECATED(
5219
5517
  "Use the version that takes a BackingStore. "
5220
5518
  "See http://crbug.com/v8/9908.")
5221
5519
  static Local<ArrayBuffer> New(
@@ -5264,7 +5562,7 @@ class V8_EXPORT ArrayBuffer : public Object {
5264
5562
  * Returns true if ArrayBuffer is externalized, that is, does not
5265
5563
  * own its memory block.
5266
5564
  */
5267
- V8_DEPRECATE_SOON(
5565
+ V8_DEPRECATED(
5268
5566
  "With v8::BackingStore externalized ArrayBuffers are "
5269
5567
  "the same as ordinary ArrayBuffers. See http://crbug.com/v8/9908.")
5270
5568
  bool IsExternal() const;
@@ -5292,8 +5590,7 @@ class V8_EXPORT ArrayBuffer : public Object {
5292
5590
  * deleter, which will call ArrayBuffer::Allocator::Free if the buffer
5293
5591
  * was allocated with ArrayBuffer::Allocator::Allocate.
5294
5592
  */
5295
- V8_DEPRECATE_SOON(
5296
- "Use GetBackingStore or Detach. See http://crbug.com/v8/9908.")
5593
+ V8_DEPRECATED("Use GetBackingStore or Detach. See http://crbug.com/v8/9908.")
5297
5594
  Contents Externalize();
5298
5595
 
5299
5596
  /**
@@ -5303,7 +5600,7 @@ class V8_EXPORT ArrayBuffer : public Object {
5303
5600
  * With the new lifetime management of backing stores there is no need for
5304
5601
  * externalizing, so this function exists only to make the transition easier.
5305
5602
  */
5306
- V8_DEPRECATE_SOON("This will be removed together with IsExternal.")
5603
+ V8_DEPRECATED("This will be removed together with IsExternal.")
5307
5604
  void Externalize(const std::shared_ptr<BackingStore>& backing_store);
5308
5605
 
5309
5606
  /**
@@ -5314,7 +5611,7 @@ class V8_EXPORT ArrayBuffer : public Object {
5314
5611
  * The embedder should make sure to hold a strong reference to the
5315
5612
  * ArrayBuffer while accessing this pointer.
5316
5613
  */
5317
- V8_DEPRECATE_SOON("Use GetBackingStore. See http://crbug.com/v8/9908.")
5614
+ V8_DEPRECATED("Use GetBackingStore. See http://crbug.com/v8/9908.")
5318
5615
  Contents GetContents();
5319
5616
 
5320
5617
  /**
@@ -5698,7 +5995,7 @@ class V8_EXPORT SharedArrayBuffer : public Object {
5698
5995
  * specified. The memory block will not be reclaimed when a created
5699
5996
  * SharedArrayBuffer is garbage-collected.
5700
5997
  */
5701
- V8_DEPRECATE_SOON(
5998
+ V8_DEPRECATED(
5702
5999
  "Use the version that takes a BackingStore. "
5703
6000
  "See http://crbug.com/v8/9908.")
5704
6001
  static Local<SharedArrayBuffer> New(
@@ -5758,7 +6055,7 @@ class V8_EXPORT SharedArrayBuffer : public Object {
5758
6055
  * Returns true if SharedArrayBuffer is externalized, that is, does not
5759
6056
  * own its memory block.
5760
6057
  */
5761
- V8_DEPRECATE_SOON(
6058
+ V8_DEPRECATED(
5762
6059
  "With v8::BackingStore externalized SharedArrayBuffers are the same "
5763
6060
  "as ordinary SharedArrayBuffers. See http://crbug.com/v8/9908.")
5764
6061
  bool IsExternal() const;
@@ -5775,8 +6072,7 @@ class V8_EXPORT SharedArrayBuffer : public Object {
5775
6072
  * v8::Isolate::CreateParams::array_buffer_allocator.
5776
6073
  *
5777
6074
  */
5778
- V8_DEPRECATE_SOON(
5779
- "Use GetBackingStore or Detach. See http://crbug.com/v8/9908.")
6075
+ V8_DEPRECATED("Use GetBackingStore or Detach. See http://crbug.com/v8/9908.")
5780
6076
  Contents Externalize();
5781
6077
 
5782
6078
  /**
@@ -5786,7 +6082,7 @@ class V8_EXPORT SharedArrayBuffer : public Object {
5786
6082
  * With the new lifetime management of backing stores there is no need for
5787
6083
  * externalizing, so this function exists only to make the transition easier.
5788
6084
  */
5789
- V8_DEPRECATE_SOON("This will be removed together with IsExternal.")
6085
+ V8_DEPRECATED("This will be removed together with IsExternal.")
5790
6086
  void Externalize(const std::shared_ptr<BackingStore>& backing_store);
5791
6087
 
5792
6088
  /**
@@ -5801,7 +6097,7 @@ class V8_EXPORT SharedArrayBuffer : public Object {
5801
6097
  * by the allocator specified in
5802
6098
  * v8::Isolate::CreateParams::array_buffer_allocator.
5803
6099
  */
5804
- V8_DEPRECATE_SOON("Use GetBackingStore. See http://crbug.com/v8/9908.")
6100
+ V8_DEPRECATED("Use GetBackingStore. See http://crbug.com/v8/9908.")
5805
6101
  Contents GetContents();
5806
6102
 
5807
6103
  /**
@@ -5932,6 +6228,10 @@ class V8_EXPORT RegExp : public Object {
5932
6228
  /**
5933
6229
  * Regular expression flag bits. They can be or'ed to enable a set
5934
6230
  * of flags.
6231
+ * The kLinear value ('l') is experimental and can only be used with
6232
+ * --enable-experimental-regexp-engine. RegExps with kLinear flag are
6233
+ * guaranteed to be executed in asymptotic linear time wrt. the length of
6234
+ * the subject string.
5935
6235
  */
5936
6236
  enum Flags {
5937
6237
  kNone = 0,
@@ -5941,9 +6241,11 @@ class V8_EXPORT RegExp : public Object {
5941
6241
  kSticky = 1 << 3,
5942
6242
  kUnicode = 1 << 4,
5943
6243
  kDotAll = 1 << 5,
6244
+ kLinear = 1 << 6,
6245
+ kHasIndices = 1 << 7,
5944
6246
  };
5945
6247
 
5946
- static constexpr int kFlagCount = 6;
6248
+ static constexpr int kFlagCount = 8;
5947
6249
 
5948
6250
  /**
5949
6251
  * Creates a regular expression from the given pattern string and
@@ -6085,7 +6387,6 @@ class V8_EXPORT Template : public Data {
6085
6387
  void SetNativeDataProperty(
6086
6388
  Local<String> name, AccessorGetterCallback getter,
6087
6389
  AccessorSetterCallback setter = nullptr,
6088
- // TODO(dcarney): gcc can't handle Local below
6089
6390
  Local<Value> data = Local<Value>(), PropertyAttribute attribute = None,
6090
6391
  Local<AccessorSignature> signature = Local<AccessorSignature>(),
6091
6392
  AccessControl settings = DEFAULT,
@@ -6094,7 +6395,6 @@ class V8_EXPORT Template : public Data {
6094
6395
  void SetNativeDataProperty(
6095
6396
  Local<Name> name, AccessorNameGetterCallback getter,
6096
6397
  AccessorNameSetterCallback setter = nullptr,
6097
- // TODO(dcarney): gcc can't handle Local below
6098
6398
  Local<Value> data = Local<Value>(), PropertyAttribute attribute = None,
6099
6399
  Local<AccessorSignature> signature = Local<AccessorSignature>(),
6100
6400
  AccessControl settings = DEFAULT,
@@ -6164,8 +6464,8 @@ class V8_EXPORT Template : public Data {
6164
6464
  *
6165
6465
  * See also `ObjectTemplate::SetHandler`.
6166
6466
  */
6167
- typedef void (*GenericNamedPropertyGetterCallback)(
6168
- Local<Name> property, const PropertyCallbackInfo<Value>& info);
6467
+ using GenericNamedPropertyGetterCallback =
6468
+ void (*)(Local<Name> property, const PropertyCallbackInfo<Value>& info);
6169
6469
 
6170
6470
  /**
6171
6471
  * Interceptor for set requests on an object.
@@ -6188,9 +6488,9 @@ typedef void (*GenericNamedPropertyGetterCallback)(
6188
6488
  * See also
6189
6489
  * `ObjectTemplate::SetHandler.`
6190
6490
  */
6191
- typedef void (*GenericNamedPropertySetterCallback)(
6192
- Local<Name> property, Local<Value> value,
6193
- const PropertyCallbackInfo<Value>& info);
6491
+ using GenericNamedPropertySetterCallback =
6492
+ void (*)(Local<Name> property, Local<Value> value,
6493
+ const PropertyCallbackInfo<Value>& info);
6194
6494
 
6195
6495
  /**
6196
6496
  * Intercepts all requests that query the attributes of the
@@ -6213,8 +6513,8 @@ typedef void (*GenericNamedPropertySetterCallback)(
6213
6513
  * See also
6214
6514
  * `ObjectTemplate::SetHandler.`
6215
6515
  */
6216
- typedef void (*GenericNamedPropertyQueryCallback)(
6217
- Local<Name> property, const PropertyCallbackInfo<Integer>& info);
6516
+ using GenericNamedPropertyQueryCallback =
6517
+ void (*)(Local<Name> property, const PropertyCallbackInfo<Integer>& info);
6218
6518
 
6219
6519
  /**
6220
6520
  * Interceptor for delete requests on an object.
@@ -6237,8 +6537,8 @@ typedef void (*GenericNamedPropertyQueryCallback)(
6237
6537
  *
6238
6538
  * See also `ObjectTemplate::SetHandler.`
6239
6539
  */
6240
- typedef void (*GenericNamedPropertyDeleterCallback)(
6241
- Local<Name> property, const PropertyCallbackInfo<Boolean>& info);
6540
+ using GenericNamedPropertyDeleterCallback =
6541
+ void (*)(Local<Name> property, const PropertyCallbackInfo<Boolean>& info);
6242
6542
 
6243
6543
  /**
6244
6544
  * Returns an array containing the names of the properties the named
@@ -6246,8 +6546,8 @@ typedef void (*GenericNamedPropertyDeleterCallback)(
6246
6546
  *
6247
6547
  * Note: The values in the array must be of type v8::Name.
6248
6548
  */
6249
- typedef void (*GenericNamedPropertyEnumeratorCallback)(
6250
- const PropertyCallbackInfo<Array>& info);
6549
+ using GenericNamedPropertyEnumeratorCallback =
6550
+ void (*)(const PropertyCallbackInfo<Array>& info);
6251
6551
 
6252
6552
  /**
6253
6553
  * Interceptor for defineProperty requests on an object.
@@ -6269,9 +6569,9 @@ typedef void (*GenericNamedPropertyEnumeratorCallback)(
6269
6569
  *
6270
6570
  * See also `ObjectTemplate::SetHandler`.
6271
6571
  */
6272
- typedef void (*GenericNamedPropertyDefinerCallback)(
6273
- Local<Name> property, const PropertyDescriptor& desc,
6274
- const PropertyCallbackInfo<Value>& info);
6572
+ using GenericNamedPropertyDefinerCallback =
6573
+ void (*)(Local<Name> property, const PropertyDescriptor& desc,
6574
+ const PropertyCallbackInfo<Value>& info);
6275
6575
 
6276
6576
  /**
6277
6577
  * Interceptor for getOwnPropertyDescriptor requests on an object.
@@ -6292,37 +6592,33 @@ typedef void (*GenericNamedPropertyDefinerCallback)(
6292
6592
  *
6293
6593
  * See also `ObjectTemplate::SetHandler`.
6294
6594
  */
6295
- typedef void (*GenericNamedPropertyDescriptorCallback)(
6296
- Local<Name> property, const PropertyCallbackInfo<Value>& info);
6595
+ using GenericNamedPropertyDescriptorCallback =
6596
+ void (*)(Local<Name> property, const PropertyCallbackInfo<Value>& info);
6297
6597
 
6298
6598
  /**
6299
6599
  * See `v8::GenericNamedPropertyGetterCallback`.
6300
6600
  */
6301
- typedef void (*IndexedPropertyGetterCallback)(
6302
- uint32_t index,
6303
- const PropertyCallbackInfo<Value>& info);
6601
+ using IndexedPropertyGetterCallback =
6602
+ void (*)(uint32_t index, const PropertyCallbackInfo<Value>& info);
6304
6603
 
6305
6604
  /**
6306
6605
  * See `v8::GenericNamedPropertySetterCallback`.
6307
6606
  */
6308
- typedef void (*IndexedPropertySetterCallback)(
6309
- uint32_t index,
6310
- Local<Value> value,
6311
- const PropertyCallbackInfo<Value>& info);
6607
+ using IndexedPropertySetterCallback =
6608
+ void (*)(uint32_t index, Local<Value> value,
6609
+ const PropertyCallbackInfo<Value>& info);
6312
6610
 
6313
6611
  /**
6314
6612
  * See `v8::GenericNamedPropertyQueryCallback`.
6315
6613
  */
6316
- typedef void (*IndexedPropertyQueryCallback)(
6317
- uint32_t index,
6318
- const PropertyCallbackInfo<Integer>& info);
6614
+ using IndexedPropertyQueryCallback =
6615
+ void (*)(uint32_t index, const PropertyCallbackInfo<Integer>& info);
6319
6616
 
6320
6617
  /**
6321
6618
  * See `v8::GenericNamedPropertyDeleterCallback`.
6322
6619
  */
6323
- typedef void (*IndexedPropertyDeleterCallback)(
6324
- uint32_t index,
6325
- const PropertyCallbackInfo<Boolean>& info);
6620
+ using IndexedPropertyDeleterCallback =
6621
+ void (*)(uint32_t index, const PropertyCallbackInfo<Boolean>& info);
6326
6622
 
6327
6623
  /**
6328
6624
  * Returns an array containing the indices of the properties the indexed
@@ -6330,21 +6626,21 @@ typedef void (*IndexedPropertyDeleterCallback)(
6330
6626
  *
6331
6627
  * Note: The values in the array must be uint32_t.
6332
6628
  */
6333
- typedef void (*IndexedPropertyEnumeratorCallback)(
6334
- const PropertyCallbackInfo<Array>& info);
6629
+ using IndexedPropertyEnumeratorCallback =
6630
+ void (*)(const PropertyCallbackInfo<Array>& info);
6335
6631
 
6336
6632
  /**
6337
6633
  * See `v8::GenericNamedPropertyDefinerCallback`.
6338
6634
  */
6339
- typedef void (*IndexedPropertyDefinerCallback)(
6340
- uint32_t index, const PropertyDescriptor& desc,
6341
- const PropertyCallbackInfo<Value>& info);
6635
+ using IndexedPropertyDefinerCallback =
6636
+ void (*)(uint32_t index, const PropertyDescriptor& desc,
6637
+ const PropertyCallbackInfo<Value>& info);
6342
6638
 
6343
6639
  /**
6344
6640
  * See `v8::GenericNamedPropertyDescriptorCallback`.
6345
6641
  */
6346
- typedef void (*IndexedPropertyDescriptorCallback)(
6347
- uint32_t index, const PropertyCallbackInfo<Value>& info);
6642
+ using IndexedPropertyDescriptorCallback =
6643
+ void (*)(uint32_t index, const PropertyCallbackInfo<Value>& info);
6348
6644
 
6349
6645
  /**
6350
6646
  * Access type specification.
@@ -6362,9 +6658,9 @@ enum AccessType {
6362
6658
  * Returns true if the given context should be allowed to access the given
6363
6659
  * object.
6364
6660
  */
6365
- typedef bool (*AccessCheckCallback)(Local<Context> accessing_context,
6366
- Local<Object> accessed_object,
6367
- Local<Value> data);
6661
+ using AccessCheckCallback = bool (*)(Local<Context> accessing_context,
6662
+ Local<Object> accessed_object,
6663
+ Local<Value> data);
6368
6664
 
6369
6665
  /**
6370
6666
  * A FunctionTemplate is used to create functions at runtime. There
@@ -6484,6 +6780,15 @@ class V8_EXPORT FunctionTemplate : public Template {
6484
6780
  SideEffectType side_effect_type = SideEffectType::kHasSideEffect,
6485
6781
  const CFunction* c_function = nullptr);
6486
6782
 
6783
+ /** Creates a function template for multiple overloaded fast API calls.*/
6784
+ static Local<FunctionTemplate> NewWithCFunctionOverloads(
6785
+ Isolate* isolate, FunctionCallback callback = nullptr,
6786
+ Local<Value> data = Local<Value>(),
6787
+ Local<Signature> signature = Local<Signature>(), int length = 0,
6788
+ ConstructorBehavior behavior = ConstructorBehavior::kAllow,
6789
+ SideEffectType side_effect_type = SideEffectType::kHasSideEffect,
6790
+ const MemorySpan<const CFunction>& c_function_overloads = {});
6791
+
6487
6792
  /**
6488
6793
  * Creates a function template backed/cached by a private property.
6489
6794
  */
@@ -6517,6 +6822,17 @@ class V8_EXPORT FunctionTemplate : public Template {
6517
6822
  SideEffectType side_effect_type = SideEffectType::kHasSideEffect,
6518
6823
  const CFunction* c_function = nullptr);
6519
6824
 
6825
+ /**
6826
+ * Set the call-handler callback for a FunctionTemplate. This
6827
+ * callback is called whenever the function created from this
6828
+ * FunctionTemplate is called. The 'c_function' represents a fast
6829
+ * API call, see the comment above the class declaration.
6830
+ */
6831
+ void SetCallHandlerV8_92(
6832
+ FunctionCallback callback, Local<Value> data = Local<Value>(),
6833
+ SideEffectType side_effect_type = SideEffectType::kHasSideEffect,
6834
+ const MemorySpan<const CFunction>& c_function_overloads = {});
6835
+
6520
6836
  /** Set the predefined length property for the FunctionTemplate. */
6521
6837
  void SetLength(int length);
6522
6838
 
@@ -6576,6 +6892,15 @@ class V8_EXPORT FunctionTemplate : public Template {
6576
6892
  */
6577
6893
  bool HasInstance(Local<Value> object);
6578
6894
 
6895
+ /**
6896
+ * Returns true if the given value is an API object that was constructed by an
6897
+ * instance of this function template (without checking for inheriting
6898
+ * function templates).
6899
+ *
6900
+ * This is an experimental feature and may still change significantly.
6901
+ */
6902
+ bool IsLeafTemplateForApiObject(v8::Local<v8::Value> value) const;
6903
+
6579
6904
  V8_INLINE static FunctionTemplate* Cast(Data* data);
6580
6905
 
6581
6906
  private:
@@ -6940,6 +7265,18 @@ class V8_EXPORT ObjectTemplate : public Template {
6940
7265
  */
6941
7266
  void SetImmutableProto();
6942
7267
 
7268
+ /**
7269
+ * Support for TC39 "dynamic code brand checks" proposal.
7270
+ *
7271
+ * This API allows to mark (& query) objects as "code like", which causes
7272
+ * them to be treated like Strings in the context of eval and function
7273
+ * constructor.
7274
+ *
7275
+ * Reference: https://github.com/tc39/proposal-dynamic-code-brand-checks
7276
+ */
7277
+ void SetCodeLike();
7278
+ bool IsCodeLike();
7279
+
6943
7280
  V8_INLINE static ObjectTemplate* Cast(Data* data);
6944
7281
 
6945
7282
  private:
@@ -6997,7 +7334,7 @@ class V8_EXPORT AccessorSignature : public Data {
6997
7334
  /**
6998
7335
  * Ignore
6999
7336
  */
7000
- class V8_EXPORT Extension { // NOLINT
7337
+ class V8_EXPORT Extension {
7001
7338
  public:
7002
7339
  // Note that the strings passed into this constructor must live as long
7003
7340
  // as the Extension itself.
@@ -7099,6 +7436,11 @@ class V8_EXPORT ResourceConstraints {
7099
7436
  /**
7100
7437
  * The amount of virtual memory reserved for generated code. This is relevant
7101
7438
  * for 64-bit architectures that rely on code range for calls in code.
7439
+ *
7440
+ * When V8_COMPRESS_POINTERS_IN_SHARED_CAGE is defined, there is a shared
7441
+ * process-wide code range that is lazily initialized. This value is used to
7442
+ * configure that shared code range when the first Isolate is
7443
+ * created. Subsequent Isolates ignore this value.
7102
7444
  */
7103
7445
  size_t code_range_size_in_bytes() const { return code_range_size_; }
7104
7446
  void set_code_range_size_in_bytes(size_t limit) { code_range_size_ = limit; }
@@ -7143,36 +7485,11 @@ class V8_EXPORT ResourceConstraints {
7143
7485
  initial_young_generation_size_ = initial_size;
7144
7486
  }
7145
7487
 
7146
- /**
7147
- * Deprecated functions. Do not use in new code.
7148
- */
7149
- V8_DEPRECATE_SOON("Use code_range_size_in_bytes.")
7150
- size_t code_range_size() const { return code_range_size_ / kMB; }
7151
- V8_DEPRECATE_SOON("Use set_code_range_size_in_bytes.")
7152
- void set_code_range_size(size_t limit_in_mb) {
7153
- code_range_size_ = limit_in_mb * kMB;
7154
- }
7155
- V8_DEPRECATE_SOON("Use max_young_generation_size_in_bytes.")
7156
- size_t max_semi_space_size_in_kb() const;
7157
- V8_DEPRECATE_SOON("Use set_max_young_generation_size_in_bytes.")
7158
- void set_max_semi_space_size_in_kb(size_t limit_in_kb);
7159
- V8_DEPRECATE_SOON("Use max_old_generation_size_in_bytes.")
7160
- size_t max_old_space_size() const { return max_old_generation_size_ / kMB; }
7161
- V8_DEPRECATE_SOON("Use set_max_old_generation_size_in_bytes.")
7162
- void set_max_old_space_size(size_t limit_in_mb) {
7163
- max_old_generation_size_ = limit_in_mb * kMB;
7164
- }
7165
- V8_DEPRECATE_SOON("Zone does not pool memory any more.")
7166
- size_t max_zone_pool_size() const { return max_zone_pool_size_; }
7167
- V8_DEPRECATE_SOON("Zone does not pool memory any more.")
7168
- void set_max_zone_pool_size(size_t bytes) { max_zone_pool_size_ = bytes; }
7169
-
7170
7488
  private:
7171
7489
  static constexpr size_t kMB = 1048576u;
7172
7490
  size_t code_range_size_ = 0;
7173
7491
  size_t max_old_generation_size_ = 0;
7174
7492
  size_t max_young_generation_size_ = 0;
7175
- size_t max_zone_pool_size_ = 0;
7176
7493
  size_t initial_old_generation_size_ = 0;
7177
7494
  size_t initial_young_generation_size_ = 0;
7178
7495
  uint32_t* stack_limit_ = nullptr;
@@ -7181,19 +7498,20 @@ class V8_EXPORT ResourceConstraints {
7181
7498
 
7182
7499
  // --- Exceptions ---
7183
7500
 
7501
+ using FatalErrorCallback = void (*)(const char* location, const char* message);
7184
7502
 
7185
- typedef void (*FatalErrorCallback)(const char* location, const char* message);
7186
-
7187
- typedef void (*OOMErrorCallback)(const char* location, bool is_heap_oom);
7503
+ using OOMErrorCallback = void (*)(const char* location, bool is_heap_oom);
7188
7504
 
7189
- typedef void (*DcheckErrorCallback)(const char* file, int line,
7190
- const char* message);
7505
+ using DcheckErrorCallback = void (*)(const char* file, int line,
7506
+ const char* message);
7191
7507
 
7192
- typedef void (*MessageCallback)(Local<Message> message, Local<Value> data);
7508
+ using MessageCallback = void (*)(Local<Message> message, Local<Value> data);
7193
7509
 
7194
7510
  // --- Tracing ---
7195
7511
 
7196
- typedef void (*LogEventCallback)(const char* name, int event);
7512
+ enum LogEventStatus : int { kStart = 0, kEnd = 1, kStamp = 2 };
7513
+ using LogEventCallback = void (*)(const char* name,
7514
+ int /* LogEventStatus */ status);
7197
7515
 
7198
7516
  /**
7199
7517
  * Create new error objects by calling the corresponding error object
@@ -7227,14 +7545,12 @@ class V8_EXPORT Exception {
7227
7545
 
7228
7546
  // --- Counters Callbacks ---
7229
7547
 
7230
- typedef int* (*CounterLookupCallback)(const char* name);
7548
+ using CounterLookupCallback = int* (*)(const char* name);
7231
7549
 
7232
- typedef void* (*CreateHistogramCallback)(const char* name,
7233
- int min,
7234
- int max,
7235
- size_t buckets);
7550
+ using CreateHistogramCallback = void* (*)(const char* name, int min, int max,
7551
+ size_t buckets);
7236
7552
 
7237
- typedef void (*AddHistogramSampleCallback)(void* histogram, int sample);
7553
+ using AddHistogramSampleCallback = void (*)(void* histogram, int sample);
7238
7554
 
7239
7555
  // --- Crashkeys Callback ---
7240
7556
  enum class CrashKeyId {
@@ -7245,11 +7561,11 @@ enum class CrashKeyId {
7245
7561
  kDumpType,
7246
7562
  };
7247
7563
 
7248
- typedef void (*AddCrashKeyCallback)(CrashKeyId id, const std::string& value);
7564
+ using AddCrashKeyCallback = void (*)(CrashKeyId id, const std::string& value);
7249
7565
 
7250
7566
  // --- Enter/Leave Script Callback ---
7251
- typedef void (*BeforeCallEnteredCallback)(Isolate*);
7252
- typedef void (*CallCompletedCallback)(Isolate*);
7567
+ using BeforeCallEnteredCallback = void (*)(Isolate*);
7568
+ using CallCompletedCallback = void (*)(Isolate*);
7253
7569
 
7254
7570
  /**
7255
7571
  * HostImportModuleDynamicallyCallback is called when we require the
@@ -7262,7 +7578,38 @@ typedef void (*CallCompletedCallback)(Isolate*);
7262
7578
  * The specifier is the name of the module that should be imported.
7263
7579
  *
7264
7580
  * The embedder must compile, instantiate, evaluate the Module, and
7265
- * obtain it's namespace object.
7581
+ * obtain its namespace object.
7582
+ *
7583
+ * The Promise returned from this function is forwarded to userland
7584
+ * JavaScript. The embedder must resolve this promise with the module
7585
+ * namespace object. In case of an exception, the embedder must reject
7586
+ * this promise with the exception. If the promise creation itself
7587
+ * fails (e.g. due to stack overflow), the embedder must propagate
7588
+ * that exception by returning an empty MaybeLocal.
7589
+ */
7590
+ using HostImportModuleDynamicallyCallback =
7591
+ MaybeLocal<Promise> (*)(Local<Context> context,
7592
+ Local<ScriptOrModule> referrer,
7593
+ Local<String> specifier);
7594
+
7595
+ /**
7596
+ * HostImportModuleDynamicallyWithImportAssertionsCallback is called when we
7597
+ * require the embedder to load a module. This is used as part of the dynamic
7598
+ * import syntax.
7599
+ *
7600
+ * The referrer contains metadata about the script/module that calls
7601
+ * import.
7602
+ *
7603
+ * The specifier is the name of the module that should be imported.
7604
+ *
7605
+ * The import_assertions are import assertions for this request in the form:
7606
+ * [key1, value1, key2, value2, ...] where the keys and values are of type
7607
+ * v8::String. Note, unlike the FixedArray passed to ResolveModuleCallback and
7608
+ * returned from ModuleRequest::GetImportAssertions(), this array does not
7609
+ * contain the source Locations of the assertions.
7610
+ *
7611
+ * The embedder must compile, instantiate, evaluate the Module, and
7612
+ * obtain its namespace object.
7266
7613
  *
7267
7614
  * The Promise returned from this function is forwarded to userland
7268
7615
  * JavaScript. The embedder must resolve this promise with the module
@@ -7271,9 +7618,11 @@ typedef void (*CallCompletedCallback)(Isolate*);
7271
7618
  * fails (e.g. due to stack overflow), the embedder must propagate
7272
7619
  * that exception by returning an empty MaybeLocal.
7273
7620
  */
7274
- typedef MaybeLocal<Promise> (*HostImportModuleDynamicallyCallback)(
7275
- Local<Context> context, Local<ScriptOrModule> referrer,
7276
- Local<String> specifier);
7621
+ using HostImportModuleDynamicallyWithImportAssertionsCallback =
7622
+ MaybeLocal<Promise> (*)(Local<Context> context,
7623
+ Local<ScriptOrModule> referrer,
7624
+ Local<String> specifier,
7625
+ Local<FixedArray> import_assertions);
7277
7626
 
7278
7627
  /**
7279
7628
  * HostInitializeImportMetaObjectCallback is called the first time import.meta
@@ -7285,9 +7634,9 @@ typedef MaybeLocal<Promise> (*HostImportModuleDynamicallyCallback)(
7285
7634
  * The embedder should use v8::Object::CreateDataProperty to add properties on
7286
7635
  * the meta object.
7287
7636
  */
7288
- typedef void (*HostInitializeImportMetaObjectCallback)(Local<Context> context,
7289
- Local<Module> module,
7290
- Local<Object> meta);
7637
+ using HostInitializeImportMetaObjectCallback = void (*)(Local<Context> context,
7638
+ Local<Module> module,
7639
+ Local<Object> meta);
7291
7640
 
7292
7641
  /**
7293
7642
  * PrepareStackTraceCallback is called when the stack property of an error is
@@ -7296,9 +7645,9 @@ typedef void (*HostInitializeImportMetaObjectCallback)(Local<Context> context,
7296
7645
  * |sites| is an array of call sites, specified in
7297
7646
  * https://v8.dev/docs/stack-trace-api
7298
7647
  */
7299
- typedef MaybeLocal<Value> (*PrepareStackTraceCallback)(Local<Context> context,
7300
- Local<Value> error,
7301
- Local<Array> sites);
7648
+ using PrepareStackTraceCallback = MaybeLocal<Value> (*)(Local<Context> context,
7649
+ Local<Value> error,
7650
+ Local<Array> sites);
7302
7651
 
7303
7652
  /**
7304
7653
  * PromiseHook with type kInit is called when a new promise is
@@ -7318,8 +7667,8 @@ typedef MaybeLocal<Value> (*PrepareStackTraceCallback)(Local<Context> context,
7318
7667
  */
7319
7668
  enum class PromiseHookType { kInit, kResolve, kBefore, kAfter };
7320
7669
 
7321
- typedef void (*PromiseHook)(PromiseHookType type, Local<Promise> promise,
7322
- Local<Value> parent);
7670
+ using PromiseHook = void (*)(PromiseHookType type, Local<Promise> promise,
7671
+ Local<Value> parent);
7323
7672
 
7324
7673
  // --- Promise Reject Callback ---
7325
7674
  enum PromiseRejectEvent {
@@ -7345,12 +7694,11 @@ class PromiseRejectMessage {
7345
7694
  Local<Value> value_;
7346
7695
  };
7347
7696
 
7348
- typedef void (*PromiseRejectCallback)(PromiseRejectMessage message);
7697
+ using PromiseRejectCallback = void (*)(PromiseRejectMessage message);
7349
7698
 
7350
7699
  // --- Microtasks Callbacks ---
7351
- typedef void (*MicrotasksCompletedCallback)(Isolate*);
7352
- typedef void (*MicrotasksCompletedCallbackWithData)(Isolate*, void*);
7353
- typedef void (*MicrotaskCallback)(void* data);
7700
+ using MicrotasksCompletedCallbackWithData = void (*)(Isolate*, void*);
7701
+ using MicrotaskCallback = void (*)(void* data);
7354
7702
 
7355
7703
  /**
7356
7704
  * Policy for running microtasks:
@@ -7454,7 +7802,7 @@ class V8_EXPORT MicrotaskQueue {
7454
7802
  * kDoNotRunMicrotasks should be used to annotate calls not intended to trigger
7455
7803
  * microtasks.
7456
7804
  */
7457
- class V8_EXPORT MicrotasksScope {
7805
+ class V8_EXPORT V8_NODISCARD MicrotasksScope {
7458
7806
  public:
7459
7807
  enum Type { kRunMicrotasks, kDoNotRunMicrotasks };
7460
7808
 
@@ -7487,11 +7835,9 @@ class V8_EXPORT MicrotasksScope {
7487
7835
  bool run_;
7488
7836
  };
7489
7837
 
7490
-
7491
7838
  // --- Failed Access Check Callback ---
7492
- typedef void (*FailedAccessCheckCallback)(Local<Object> target,
7493
- AccessType type,
7494
- Local<Value> data);
7839
+ using FailedAccessCheckCallback = void (*)(Local<Object> target,
7840
+ AccessType type, Local<Value> data);
7495
7841
 
7496
7842
  // --- AllowCodeGenerationFromStrings callbacks ---
7497
7843
 
@@ -7499,8 +7845,8 @@ typedef void (*FailedAccessCheckCallback)(Local<Object> target,
7499
7845
  * Callback to check if code generation from strings is allowed. See
7500
7846
  * Context::AllowCodeGenerationFromStrings.
7501
7847
  */
7502
- typedef bool (*AllowCodeGenerationFromStringsCallback)(Local<Context> context,
7503
- Local<String> source);
7848
+ using AllowCodeGenerationFromStringsCallback = bool (*)(Local<Context> context,
7849
+ Local<String> source);
7504
7850
 
7505
7851
  struct ModifyCodeGenerationFromStringsResult {
7506
7852
  // If true, proceed with the codegen algorithm. Otherwise, block it.
@@ -7513,34 +7859,42 @@ struct ModifyCodeGenerationFromStringsResult {
7513
7859
 
7514
7860
  /**
7515
7861
  * Callback to check if codegen is allowed from a source object, and convert
7516
- * the source to string if necessary.See ModifyCodeGenerationFromStrings.
7862
+ * the source to string if necessary. See: ModifyCodeGenerationFromStrings.
7517
7863
  */
7518
- typedef ModifyCodeGenerationFromStringsResult (
7519
- *ModifyCodeGenerationFromStringsCallback)(Local<Context> context,
7864
+ using ModifyCodeGenerationFromStringsCallback =
7865
+ ModifyCodeGenerationFromStringsResult (*)(Local<Context> context,
7520
7866
  Local<Value> source);
7867
+ using ModifyCodeGenerationFromStringsCallback2 =
7868
+ ModifyCodeGenerationFromStringsResult (*)(Local<Context> context,
7869
+ Local<Value> source,
7870
+ bool is_code_like);
7521
7871
 
7522
7872
  // --- WebAssembly compilation callbacks ---
7523
- typedef bool (*ExtensionCallback)(const FunctionCallbackInfo<Value>&);
7873
+ using ExtensionCallback = bool (*)(const FunctionCallbackInfo<Value>&);
7524
7874
 
7525
- typedef bool (*AllowWasmCodeGenerationCallback)(Local<Context> context,
7526
- Local<String> source);
7875
+ using AllowWasmCodeGenerationCallback = bool (*)(Local<Context> context,
7876
+ Local<String> source);
7527
7877
 
7528
7878
  // --- Callback for APIs defined on v8-supported objects, but implemented
7529
7879
  // by the embedder. Example: WebAssembly.{compile|instantiate}Streaming ---
7530
- typedef void (*ApiImplementationCallback)(const FunctionCallbackInfo<Value>&);
7880
+ using ApiImplementationCallback = void (*)(const FunctionCallbackInfo<Value>&);
7531
7881
 
7532
7882
  // --- Callback for WebAssembly.compileStreaming ---
7533
- typedef void (*WasmStreamingCallback)(const FunctionCallbackInfo<Value>&);
7534
-
7535
- // --- Callback for checking if WebAssembly threads are enabled ---
7536
- typedef bool (*WasmThreadsEnabledCallback)(Local<Context> context);
7883
+ using WasmStreamingCallback = void (*)(const FunctionCallbackInfo<Value>&);
7537
7884
 
7538
7885
  // --- Callback for loading source map file for Wasm profiling support
7539
- typedef Local<String> (*WasmLoadSourceMapCallback)(Isolate* isolate,
7540
- const char* name);
7886
+ using WasmLoadSourceMapCallback = Local<String> (*)(Isolate* isolate,
7887
+ const char* name);
7541
7888
 
7542
7889
  // --- Callback for checking if WebAssembly Simd is enabled ---
7543
- typedef bool (*WasmSimdEnabledCallback)(Local<Context> context);
7890
+ using WasmSimdEnabledCallback = bool (*)(Local<Context> context);
7891
+
7892
+ // --- Callback for checking if WebAssembly exceptions are enabled ---
7893
+ using WasmExceptionsEnabledCallback = bool (*)(Local<Context> context);
7894
+
7895
+ // --- Callback for checking if the SharedArrayBuffer constructor is enabled ---
7896
+ using SharedArrayBufferConstructorEnabledCallback =
7897
+ bool (*)(Local<Context> context);
7544
7898
 
7545
7899
  // --- Garbage Collection Callbacks ---
7546
7900
 
@@ -7584,9 +7938,9 @@ enum GCCallbackFlags {
7584
7938
  kGCCallbackScheduleIdleGarbageCollection = 1 << 6,
7585
7939
  };
7586
7940
 
7587
- typedef void (*GCCallback)(GCType type, GCCallbackFlags flags);
7941
+ using GCCallback = void (*)(GCType type, GCCallbackFlags flags);
7588
7942
 
7589
- typedef void (*InterruptCallback)(Isolate* isolate, void* data);
7943
+ using InterruptCallback = void (*)(Isolate* isolate, void* data);
7590
7944
 
7591
7945
  /**
7592
7946
  * This callback is invoked when the heap size is close to the heap limit and
@@ -7595,8 +7949,8 @@ typedef void (*InterruptCallback)(Isolate* isolate, void* data);
7595
7949
  * than the current_heap_limit. The initial heap limit is the limit that was
7596
7950
  * set after heap setup.
7597
7951
  */
7598
- typedef size_t (*NearHeapLimitCallback)(void* data, size_t current_heap_limit,
7599
- size_t initial_heap_limit);
7952
+ using NearHeapLimitCallback = size_t (*)(void* data, size_t current_heap_limit,
7953
+ size_t initial_heap_limit);
7600
7954
 
7601
7955
  /**
7602
7956
  * Collection of shared per-process V8 memory information.
@@ -7850,30 +8204,29 @@ enum JitCodeEventOptions {
7850
8204
  *
7851
8205
  * \param event code add, move or removal event.
7852
8206
  */
7853
- typedef void (*JitCodeEventHandler)(const JitCodeEvent* event);
8207
+ using JitCodeEventHandler = void (*)(const JitCodeEvent* event);
7854
8208
 
7855
8209
  /**
7856
8210
  * Callback function passed to SetUnhandledExceptionCallback.
7857
8211
  */
7858
8212
  #if defined(V8_OS_WIN)
7859
- typedef int (*UnhandledExceptionCallback)(
7860
- _EXCEPTION_POINTERS* exception_pointers);
8213
+ using UnhandledExceptionCallback =
8214
+ int (*)(_EXCEPTION_POINTERS* exception_pointers);
7861
8215
  #endif
7862
8216
 
7863
8217
  /**
7864
8218
  * Interface for iterating through all external resources in the heap.
7865
8219
  */
7866
- class V8_EXPORT ExternalResourceVisitor { // NOLINT
8220
+ class V8_EXPORT ExternalResourceVisitor {
7867
8221
  public:
7868
8222
  virtual ~ExternalResourceVisitor() = default;
7869
8223
  virtual void VisitExternalString(Local<String> string) {}
7870
8224
  };
7871
8225
 
7872
-
7873
8226
  /**
7874
8227
  * Interface for iterating through all the persistent handles in the heap.
7875
8228
  */
7876
- class V8_EXPORT PersistentHandleVisitor { // NOLINT
8229
+ class V8_EXPORT PersistentHandleVisitor {
7877
8230
  public:
7878
8231
  virtual ~PersistentHandleVisitor() = default;
7879
8232
  virtual void VisitPersistentHandle(Persistent<Value>* value,
@@ -7890,6 +8243,45 @@ class V8_EXPORT PersistentHandleVisitor { // NOLINT
7890
8243
  */
7891
8244
  enum class MemoryPressureLevel { kNone, kModerate, kCritical };
7892
8245
 
8246
+ /**
8247
+ * Handler for embedder roots on non-unified heap garbage collections.
8248
+ */
8249
+ class V8_EXPORT EmbedderRootsHandler {
8250
+ public:
8251
+ virtual ~EmbedderRootsHandler() = default;
8252
+
8253
+ /**
8254
+ * Returns true if the TracedGlobal handle should be considered as root for
8255
+ * the currently running non-tracing garbage collection and false otherwise.
8256
+ * The default implementation will keep all TracedGlobal references as roots.
8257
+ *
8258
+ * If this returns false, then V8 may decide that the object referred to by
8259
+ * such a handle is reclaimed. In that case:
8260
+ * - No action is required if handles are used with destructors, i.e., by just
8261
+ * using |TracedGlobal|.
8262
+ * - When run without destructors, i.e., by using |TracedReference|, V8 calls
8263
+ * |ResetRoot|.
8264
+ *
8265
+ * Note that the |handle| is different from the handle that the embedder holds
8266
+ * for retaining the object. The embedder may use |WrapperClassId()| to
8267
+ * distinguish cases where it wants handles to be treated as roots from not
8268
+ * being treated as roots.
8269
+ */
8270
+ virtual bool IsRoot(const v8::TracedReference<v8::Value>& handle) = 0;
8271
+ virtual bool IsRoot(const v8::TracedGlobal<v8::Value>& handle) = 0;
8272
+
8273
+ /**
8274
+ * Used in combination with |IsRoot|. Called by V8 when an
8275
+ * object that is backed by a handle is reclaimed by a non-tracing garbage
8276
+ * collection. It is up to the embedder to reset the original handle.
8277
+ *
8278
+ * Note that the |handle| is different from the handle that the embedder holds
8279
+ * for retaining the object. It is up to the embedder to find the original
8280
+ * handle via the object or class id.
8281
+ */
8282
+ virtual void ResetRoot(const v8::TracedReference<v8::Value>& handle) = 0;
8283
+ };
8284
+
7893
8285
  /**
7894
8286
  * Interface for tracing through the embedder heap. During a V8 garbage
7895
8287
  * collection, V8 collects hidden fields of all potential wrappers, and at the
@@ -7952,6 +8344,9 @@ class V8_EXPORT EmbedderHeapTracer {
7952
8344
  /**
7953
8345
  * Called by the embedder to notify V8 of an empty execution stack.
7954
8346
  */
8347
+ V8_DEPRECATE_SOON(
8348
+ "This call only optimized internal caches which V8 is able to figure out "
8349
+ "on its own now.")
7955
8350
  void NotifyEmptyEmbedderStack();
7956
8351
 
7957
8352
  /**
@@ -7963,7 +8358,7 @@ class V8_EXPORT EmbedderHeapTracer {
7963
8358
  virtual void RegisterV8References(
7964
8359
  const std::vector<std::pair<void*, void*> >& embedder_fields) = 0;
7965
8360
 
7966
- void RegisterEmbedderReference(const TracedReferenceBase<v8::Data>& ref);
8361
+ void RegisterEmbedderReference(const BasicTracedReference<v8::Data>& ref);
7967
8362
 
7968
8363
  /**
7969
8364
  * Called at the beginning of a GC cycle.
@@ -8015,34 +8410,14 @@ class V8_EXPORT EmbedderHeapTracer {
8015
8410
  void FinalizeTracing();
8016
8411
 
8017
8412
  /**
8018
- * Returns true if the TracedGlobal handle should be considered as root for
8019
- * the currently running non-tracing garbage collection and false otherwise.
8020
- * The default implementation will keep all TracedGlobal references as roots.
8021
- *
8022
- * If this returns false, then V8 may decide that the object referred to by
8023
- * such a handle is reclaimed. In that case:
8024
- * - No action is required if handles are used with destructors, i.e., by just
8025
- * using |TracedGlobal|.
8026
- * - When run without destructors, i.e., by using
8027
- * |TracedReference|, V8 calls |ResetHandleInNonTracingGC|.
8028
- *
8029
- * Note that the |handle| is different from the handle that the embedder holds
8030
- * for retaining the object. The embedder may use |WrapperClassId()| to
8031
- * distinguish cases where it wants handles to be treated as roots from not
8032
- * being treated as roots.
8413
+ * See documentation on EmbedderRootsHandler.
8033
8414
  */
8034
8415
  virtual bool IsRootForNonTracingGC(
8035
8416
  const v8::TracedReference<v8::Value>& handle);
8036
8417
  virtual bool IsRootForNonTracingGC(const v8::TracedGlobal<v8::Value>& handle);
8037
8418
 
8038
8419
  /**
8039
- * Used in combination with |IsRootForNonTracingGC|. Called by V8 when an
8040
- * object that is backed by a handle is reclaimed by a non-tracing garbage
8041
- * collection. It is up to the embedder to reset the original handle.
8042
- *
8043
- * Note that the |handle| is different from the handle that the embedder holds
8044
- * for retaining the object. It is up to the embedder to find the original
8045
- * handle via the object or class id.
8420
+ * See documentation on EmbedderRootsHandler.
8046
8421
  */
8047
8422
  virtual void ResetHandleInNonTracingGC(
8048
8423
  const v8::TracedReference<v8::Value>& handle);
@@ -8084,8 +8459,8 @@ class V8_EXPORT EmbedderHeapTracer {
8084
8459
  * serialized verbatim.
8085
8460
  */
8086
8461
  struct SerializeInternalFieldsCallback {
8087
- typedef StartupData (*CallbackFunction)(Local<Object> holder, int index,
8088
- void* data);
8462
+ using CallbackFunction = StartupData (*)(Local<Object> holder, int index,
8463
+ void* data);
8089
8464
  SerializeInternalFieldsCallback(CallbackFunction function = nullptr,
8090
8465
  void* data_arg = nullptr)
8091
8466
  : callback(function), data(data_arg) {}
@@ -8094,15 +8469,15 @@ struct SerializeInternalFieldsCallback {
8094
8469
  };
8095
8470
  // Note that these fields are called "internal fields" in the API and called
8096
8471
  // "embedder fields" within V8.
8097
- typedef SerializeInternalFieldsCallback SerializeEmbedderFieldsCallback;
8472
+ using SerializeEmbedderFieldsCallback = SerializeInternalFieldsCallback;
8098
8473
 
8099
8474
  /**
8100
8475
  * Callback and supporting data used to implement embedder logic to deserialize
8101
8476
  * internal fields.
8102
8477
  */
8103
8478
  struct DeserializeInternalFieldsCallback {
8104
- typedef void (*CallbackFunction)(Local<Object> holder, int index,
8105
- StartupData payload, void* data);
8479
+ using CallbackFunction = void (*)(Local<Object> holder, int index,
8480
+ StartupData payload, void* data);
8106
8481
  DeserializeInternalFieldsCallback(CallbackFunction function = nullptr,
8107
8482
  void* data_arg = nullptr)
8108
8483
  : callback(function), data(data_arg) {}
@@ -8110,7 +8485,7 @@ struct DeserializeInternalFieldsCallback {
8110
8485
  void* data);
8111
8486
  void* data;
8112
8487
  };
8113
- typedef DeserializeInternalFieldsCallback DeserializeEmbedderFieldsCallback;
8488
+ using DeserializeEmbedderFieldsCallback = DeserializeInternalFieldsCallback;
8114
8489
 
8115
8490
  /**
8116
8491
  * Controls how the default MeasureMemoryDelegate reports the result of
@@ -8186,26 +8561,15 @@ class V8_EXPORT Isolate {
8186
8561
  /**
8187
8562
  * Initial configuration parameters for a new Isolate.
8188
8563
  */
8189
- struct CreateParams {
8190
- CreateParams()
8191
- : code_event_handler(nullptr),
8192
- snapshot_blob(nullptr),
8193
- counter_lookup_callback(nullptr),
8194
- create_histogram_callback(nullptr),
8195
- add_histogram_sample_callback(nullptr),
8196
- array_buffer_allocator(nullptr),
8197
- array_buffer_allocator_shared(),
8198
- external_references(nullptr),
8199
- allow_atomics_wait(true),
8200
- only_terminate_in_safe_scope(false),
8201
- embedder_wrapper_type_index(-1),
8202
- embedder_wrapper_object_index(-1) {}
8564
+ struct V8_EXPORT CreateParams {
8565
+ CreateParams();
8566
+ ~CreateParams();
8203
8567
 
8204
8568
  /**
8205
8569
  * Allows the host application to provide the address of a function that is
8206
8570
  * notified each time code is added, moved or removed.
8207
8571
  */
8208
- JitCodeEventHandler code_event_handler;
8572
+ JitCodeEventHandler code_event_handler = nullptr;
8209
8573
 
8210
8574
  /**
8211
8575
  * ResourceConstraints to use for the new Isolate.
@@ -8215,14 +8579,13 @@ class V8_EXPORT Isolate {
8215
8579
  /**
8216
8580
  * Explicitly specify a startup snapshot blob. The embedder owns the blob.
8217
8581
  */
8218
- StartupData* snapshot_blob;
8219
-
8582
+ StartupData* snapshot_blob = nullptr;
8220
8583
 
8221
8584
  /**
8222
8585
  * Enables the host application to provide a mechanism for recording
8223
8586
  * statistics counters.
8224
8587
  */
8225
- CounterLookupCallback counter_lookup_callback;
8588
+ CounterLookupCallback counter_lookup_callback = nullptr;
8226
8589
 
8227
8590
  /**
8228
8591
  * Enables the host application to provide a mechanism for recording
@@ -8230,8 +8593,8 @@ class V8_EXPORT Isolate {
8230
8593
  * histogram which will later be passed to the AddHistogramSample
8231
8594
  * function.
8232
8595
  */
8233
- CreateHistogramCallback create_histogram_callback;
8234
- AddHistogramSampleCallback add_histogram_sample_callback;
8596
+ CreateHistogramCallback create_histogram_callback = nullptr;
8597
+ AddHistogramSampleCallback add_histogram_sample_callback = nullptr;
8235
8598
 
8236
8599
  /**
8237
8600
  * The ArrayBuffer::Allocator to use for allocating and freeing the backing
@@ -8242,7 +8605,7 @@ class V8_EXPORT Isolate {
8242
8605
  * to the allocator, in order to facilitate lifetime
8243
8606
  * management for the allocator instance.
8244
8607
  */
8245
- ArrayBuffer::Allocator* array_buffer_allocator;
8608
+ ArrayBuffer::Allocator* array_buffer_allocator = nullptr;
8246
8609
  std::shared_ptr<ArrayBuffer::Allocator> array_buffer_allocator_shared;
8247
8610
 
8248
8611
  /**
@@ -8251,34 +8614,38 @@ class V8_EXPORT Isolate {
8251
8614
  * deserialization. This array and its content must stay valid for the
8252
8615
  * entire lifetime of the isolate.
8253
8616
  */
8254
- const intptr_t* external_references;
8617
+ const intptr_t* external_references = nullptr;
8255
8618
 
8256
8619
  /**
8257
8620
  * Whether calling Atomics.wait (a function that may block) is allowed in
8258
8621
  * this isolate. This can also be configured via SetAllowAtomicsWait.
8259
8622
  */
8260
- bool allow_atomics_wait;
8623
+ bool allow_atomics_wait = true;
8261
8624
 
8262
8625
  /**
8263
8626
  * Termination is postponed when there is no active SafeForTerminationScope.
8264
8627
  */
8265
- bool only_terminate_in_safe_scope;
8628
+ bool only_terminate_in_safe_scope = false;
8266
8629
 
8267
8630
  /**
8268
8631
  * The following parameters describe the offsets for addressing type info
8269
8632
  * for wrapped API objects and are used by the fast C API
8270
8633
  * (for details see v8-fast-api-calls.h).
8271
8634
  */
8272
- int embedder_wrapper_type_index;
8273
- int embedder_wrapper_object_index;
8274
- };
8635
+ int embedder_wrapper_type_index = -1;
8636
+ int embedder_wrapper_object_index = -1;
8275
8637
 
8638
+ V8_DEPRECATED(
8639
+ "Setting this has no effect. Embedders should ignore import assertions "
8640
+ "that they do not use.")
8641
+ std::vector<std::string> supported_import_assertions;
8642
+ };
8276
8643
 
8277
8644
  /**
8278
8645
  * Stack-allocated class which sets the isolate for all operations
8279
8646
  * executed within a local scope.
8280
8647
  */
8281
- class V8_EXPORT Scope {
8648
+ class V8_EXPORT V8_NODISCARD Scope {
8282
8649
  public:
8283
8650
  explicit Scope(Isolate* isolate) : isolate_(isolate) {
8284
8651
  isolate->Enter();
@@ -8294,11 +8661,10 @@ class V8_EXPORT Isolate {
8294
8661
  Isolate* const isolate_;
8295
8662
  };
8296
8663
 
8297
-
8298
8664
  /**
8299
8665
  * Assert that no Javascript code is invoked.
8300
8666
  */
8301
- class V8_EXPORT DisallowJavascriptExecutionScope {
8667
+ class V8_EXPORT V8_NODISCARD DisallowJavascriptExecutionScope {
8302
8668
  public:
8303
8669
  enum OnFailure { CRASH_ON_FAILURE, THROW_ON_FAILURE, DUMP_ON_FAILURE };
8304
8670
 
@@ -8313,14 +8679,17 @@ class V8_EXPORT Isolate {
8313
8679
 
8314
8680
  private:
8315
8681
  OnFailure on_failure_;
8316
- void* internal_;
8317
- };
8682
+ Isolate* isolate_;
8318
8683
 
8684
+ bool was_execution_allowed_assert_;
8685
+ bool was_execution_allowed_throws_;
8686
+ bool was_execution_allowed_dump_;
8687
+ };
8319
8688
 
8320
8689
  /**
8321
8690
  * Introduce exception to DisallowJavascriptExecutionScope.
8322
8691
  */
8323
- class V8_EXPORT AllowJavascriptExecutionScope {
8692
+ class V8_EXPORT V8_NODISCARD AllowJavascriptExecutionScope {
8324
8693
  public:
8325
8694
  explicit AllowJavascriptExecutionScope(Isolate* isolate);
8326
8695
  ~AllowJavascriptExecutionScope();
@@ -8332,16 +8701,17 @@ class V8_EXPORT Isolate {
8332
8701
  const AllowJavascriptExecutionScope&) = delete;
8333
8702
 
8334
8703
  private:
8335
- void* internal_throws_;
8336
- void* internal_assert_;
8337
- void* internal_dump_;
8704
+ Isolate* isolate_;
8705
+ bool was_execution_allowed_assert_;
8706
+ bool was_execution_allowed_throws_;
8707
+ bool was_execution_allowed_dump_;
8338
8708
  };
8339
8709
 
8340
8710
  /**
8341
8711
  * Do not run microtasks while this scope is active, even if microtasks are
8342
8712
  * automatically executed otherwise.
8343
8713
  */
8344
- class V8_EXPORT SuppressMicrotaskExecutionScope {
8714
+ class V8_EXPORT V8_NODISCARD SuppressMicrotaskExecutionScope {
8345
8715
  public:
8346
8716
  explicit SuppressMicrotaskExecutionScope(
8347
8717
  Isolate* isolate, MicrotaskQueue* microtask_queue = nullptr);
@@ -8365,7 +8735,7 @@ class V8_EXPORT Isolate {
8365
8735
  * This scope allows terminations inside direct V8 API calls and forbid them
8366
8736
  * inside any recursive API calls without explicit SafeForTerminationScope.
8367
8737
  */
8368
- class V8_EXPORT SafeForTerminationScope {
8738
+ class V8_EXPORT V8_NODISCARD SafeForTerminationScope {
8369
8739
  public:
8370
8740
  explicit SafeForTerminationScope(v8::Isolate* isolate);
8371
8741
  ~SafeForTerminationScope();
@@ -8424,8 +8794,8 @@ class V8_EXPORT Isolate {
8424
8794
  kArrayInstanceProtoModified = 27,
8425
8795
  kArrayInstanceConstructorModified = 28,
8426
8796
  kLegacyFunctionDeclaration = 29,
8427
- kRegExpPrototypeSourceGetter = 30,
8428
- kRegExpPrototypeOldFlagGetter = 31,
8797
+ kRegExpPrototypeSourceGetter = 30, // Unused.
8798
+ kRegExpPrototypeOldFlagGetter = 31, // Unused.
8429
8799
  kDecimalWithLeadingZeroInStrictMode = 32,
8430
8800
  kLegacyDateParser = 33,
8431
8801
  kDefineGetterOrSetterWouldThrow = 34,
@@ -8465,7 +8835,7 @@ class V8_EXPORT Isolate {
8465
8835
  kDateToLocaleTimeString = 68,
8466
8836
  kAttemptOverrideReadOnlyOnPrototypeSloppy = 69,
8467
8837
  kAttemptOverrideReadOnlyOnPrototypeStrict = 70,
8468
- kOptimizedFunctionWithOneShotBytecode = 71,
8838
+ kOptimizedFunctionWithOneShotBytecode = 71, // Unused.
8469
8839
  kRegExpMatchIsTrueishOnNonJSRegExp = 72,
8470
8840
  kRegExpMatchIsFalseishOnJSRegExp = 73,
8471
8841
  kDateGetTimezoneOffset = 74, // Unused.
@@ -8503,8 +8873,10 @@ class V8_EXPORT Isolate {
8503
8873
  kWasmSimdOpcodes = 106,
8504
8874
  kVarRedeclaredCatchBinding = 107,
8505
8875
  kWasmRefTypes = 108,
8506
- kWasmBulkMemory = 109,
8876
+ kWasmBulkMemory = 109, // Unused.
8507
8877
  kWasmMultiValue = 110,
8878
+ kWasmExceptionHandling = 111,
8879
+ kInvalidatedMegaDOMProtector = 112,
8508
8880
 
8509
8881
  // If you add new values here, you'll also need to update Chromium's:
8510
8882
  // web_feature.mojom, use_counter_callback.cc, and enums.xml. V8 changes to
@@ -8522,8 +8894,8 @@ class V8_EXPORT Isolate {
8522
8894
  kMessageWarning,
8523
8895
  };
8524
8896
 
8525
- typedef void (*UseCounterCallback)(Isolate* isolate,
8526
- UseCounterFeature feature);
8897
+ using UseCounterCallback = void (*)(Isolate* isolate,
8898
+ UseCounterFeature feature);
8527
8899
 
8528
8900
  /**
8529
8901
  * Allocates a new isolate but does not initialize it. Does not change the
@@ -8565,6 +8937,14 @@ class V8_EXPORT Isolate {
8565
8937
  */
8566
8938
  static Isolate* GetCurrent();
8567
8939
 
8940
+ /**
8941
+ * Returns the entered isolate for the current thread or NULL in
8942
+ * case there is no current isolate.
8943
+ *
8944
+ * No checks are performed by this method.
8945
+ */
8946
+ static Isolate* TryGetCurrent();
8947
+
8568
8948
  /**
8569
8949
  * Clears the set of objects held strongly by the heap. This set of
8570
8950
  * objects are originally built when a WeakRef is created or
@@ -8589,7 +8969,7 @@ class V8_EXPORT Isolate {
8589
8969
  * - the custom callback set returns true.
8590
8970
  * Otherwise, the custom callback will not be called and V8 will not abort.
8591
8971
  */
8592
- typedef bool (*AbortOnUncaughtExceptionCallback)(Isolate*);
8972
+ using AbortOnUncaughtExceptionCallback = bool (*)(Isolate*);
8593
8973
  void SetAbortOnUncaughtExceptionCallback(
8594
8974
  AbortOnUncaughtExceptionCallback callback);
8595
8975
 
@@ -8597,9 +8977,19 @@ class V8_EXPORT Isolate {
8597
8977
  * This specifies the callback called by the upcoming dynamic
8598
8978
  * import() language feature to load modules.
8599
8979
  */
8980
+ V8_DEPRECATED(
8981
+ "Use the version of SetHostImportModuleDynamicallyCallback that takes a "
8982
+ "HostImportModuleDynamicallyWithImportAssertionsCallback instead")
8600
8983
  void SetHostImportModuleDynamicallyCallback(
8601
8984
  HostImportModuleDynamicallyCallback callback);
8602
8985
 
8986
+ /**
8987
+ * This specifies the callback called by the upcoming dynamic
8988
+ * import() language feature to load modules.
8989
+ */
8990
+ void SetHostImportModuleDynamicallyCallback(
8991
+ HostImportModuleDynamicallyWithImportAssertionsCallback callback);
8992
+
8603
8993
  /**
8604
8994
  * This specifies the callback called by the upcoming import.meta
8605
8995
  * language feature to retrieve host-defined meta data for a module.
@@ -8621,6 +9011,13 @@ class V8_EXPORT Isolate {
8621
9011
  */
8622
9012
  void MemoryPressureNotification(MemoryPressureLevel level);
8623
9013
 
9014
+ /**
9015
+ * Drop non-essential caches. Should only be called from testing code.
9016
+ * The method can potentially block for a long time and does not necessarily
9017
+ * trigger GC.
9018
+ */
9019
+ void ClearCachesForTesting();
9020
+
8624
9021
  /**
8625
9022
  * Methods below this point require holding a lock (using Locker) in
8626
9023
  * a multi-threaded environment.
@@ -8753,7 +9150,7 @@ class V8_EXPORT Isolate {
8753
9150
  std::unique_ptr<MeasureMemoryDelegate> delegate,
8754
9151
  MeasureMemoryExecution execution = MeasureMemoryExecution::kDefault);
8755
9152
 
8756
- V8_DEPRECATE_SOON("Use the version with a delegate")
9153
+ V8_DEPRECATED("Use the version with a delegate")
8757
9154
  MaybeLocal<Promise> MeasureMemory(Local<Context> context,
8758
9155
  MeasureMemoryMode mode);
8759
9156
 
@@ -8816,10 +9213,6 @@ class V8_EXPORT Isolate {
8816
9213
  */
8817
9214
  Local<Context> GetCurrentContext();
8818
9215
 
8819
- /** Returns the last context entered through V8's C++ API. */
8820
- V8_DEPRECATED("Use GetEnteredOrMicrotaskContext().")
8821
- Local<Context> GetEnteredContext();
8822
-
8823
9216
  /**
8824
9217
  * Returns either the last context entered through V8's C++ API, or the
8825
9218
  * context of the currently running microtask while processing microtasks.
@@ -8834,6 +9227,17 @@ class V8_EXPORT Isolate {
8834
9227
  */
8835
9228
  Local<Context> GetIncumbentContext();
8836
9229
 
9230
+ /**
9231
+ * Schedules a v8::Exception::Error with the given message.
9232
+ * See ThrowException for more details. Templatized to provide compile-time
9233
+ * errors in case of too long strings (see v8::String::NewFromUtf8Literal).
9234
+ */
9235
+ template <int N>
9236
+ Local<Value> ThrowError(const char (&message)[N]) {
9237
+ return ThrowError(String::NewFromUtf8Literal(this, message));
9238
+ }
9239
+ Local<Value> ThrowError(Local<String> message);
9240
+
8837
9241
  /**
8838
9242
  * Schedules an exception to be thrown when returning to JavaScript. When an
8839
9243
  * exception has been scheduled it is illegal to invoke any JavaScript
@@ -8842,10 +9246,10 @@ class V8_EXPORT Isolate {
8842
9246
  */
8843
9247
  Local<Value> ThrowException(Local<Value> exception);
8844
9248
 
8845
- typedef void (*GCCallback)(Isolate* isolate, GCType type,
8846
- GCCallbackFlags flags);
8847
- typedef void (*GCCallbackWithData)(Isolate* isolate, GCType type,
8848
- GCCallbackFlags flags, void* data);
9249
+ using GCCallback = void (*)(Isolate* isolate, GCType type,
9250
+ GCCallbackFlags flags);
9251
+ using GCCallbackWithData = void (*)(Isolate* isolate, GCType type,
9252
+ GCCallbackFlags flags, void* data);
8849
9253
 
8850
9254
  /**
8851
9255
  * Enables the host application to receive a notification before a
@@ -8878,6 +9282,42 @@ class V8_EXPORT Isolate {
8878
9282
  */
8879
9283
  EmbedderHeapTracer* GetEmbedderHeapTracer();
8880
9284
 
9285
+ /**
9286
+ * Sets an embedder roots handle that V8 should consider when performing
9287
+ * non-unified heap garbage collections.
9288
+ *
9289
+ * Using only EmbedderHeapTracer automatically sets up a default handler.
9290
+ * The intended use case is for setting a custom handler after invoking
9291
+ * `AttachCppHeap()`.
9292
+ *
9293
+ * V8 does not take ownership of the handler.
9294
+ */
9295
+ void SetEmbedderRootsHandler(EmbedderRootsHandler* handler);
9296
+
9297
+ /**
9298
+ * Attaches a managed C++ heap as an extension to the JavaScript heap. The
9299
+ * embedder maintains ownership of the CppHeap. At most one C++ heap can be
9300
+ * attached to V8.
9301
+ *
9302
+ * This is an experimental feature and may still change significantly.
9303
+ */
9304
+ void AttachCppHeap(CppHeap*);
9305
+
9306
+ /**
9307
+ * Detaches a managed C++ heap if one was attached using `AttachCppHeap()`.
9308
+ *
9309
+ * This is an experimental feature and may still change significantly.
9310
+ */
9311
+ void DetachCppHeap();
9312
+
9313
+ /**
9314
+ * This is an experimental feature and may still change significantly.
9315
+
9316
+ * \returns the C++ heap managed by V8. Only available if such a heap has been
9317
+ * attached using `AttachCppHeap()`.
9318
+ */
9319
+ CppHeap* GetCppHeap() const;
9320
+
8881
9321
  /**
8882
9322
  * Use for |AtomicsWaitCallback| to indicate the type of event it receives.
8883
9323
  */
@@ -8942,12 +9382,12 @@ class V8_EXPORT Isolate {
8942
9382
  * This callback may schedule exceptions, *unless* |event| is equal to
8943
9383
  * |kTerminatedExecution|.
8944
9384
  */
8945
- typedef void (*AtomicsWaitCallback)(AtomicsWaitEvent event,
8946
- Local<SharedArrayBuffer> array_buffer,
8947
- size_t offset_in_bytes, int64_t value,
8948
- double timeout_in_ms,
8949
- AtomicsWaitWakeHandle* stop_handle,
8950
- void* data);
9385
+ using AtomicsWaitCallback = void (*)(AtomicsWaitEvent event,
9386
+ Local<SharedArrayBuffer> array_buffer,
9387
+ size_t offset_in_bytes, int64_t value,
9388
+ double timeout_in_ms,
9389
+ AtomicsWaitWakeHandle* stop_handle,
9390
+ void* data);
8951
9391
 
8952
9392
  /**
8953
9393
  * Set a new |AtomicsWaitCallback|. This overrides an earlier
@@ -8979,7 +9419,7 @@ class V8_EXPORT Isolate {
8979
9419
  void* data = nullptr);
8980
9420
  void RemoveGCEpilogueCallback(GCCallback callback);
8981
9421
 
8982
- typedef size_t (*GetExternallyAllocatedMemoryInBytesCallback)();
9422
+ using GetExternallyAllocatedMemoryInBytesCallback = size_t (*)();
8983
9423
 
8984
9424
  /**
8985
9425
  * Set the callback that tells V8 how much memory is currently allocated
@@ -9098,12 +9538,6 @@ class V8_EXPORT Isolate {
9098
9538
  */
9099
9539
  void SetPromiseRejectCallback(PromiseRejectCallback callback);
9100
9540
 
9101
- /**
9102
- * An alias for PerformMicrotaskCheckpoint.
9103
- */
9104
- V8_DEPRECATE_SOON("Use PerformMicrotaskCheckpoint.")
9105
- void RunMicrotasks() { PerformMicrotaskCheckpoint(); }
9106
-
9107
9541
  /**
9108
9542
  * Runs the default MicrotaskQueue until it gets empty and perform other
9109
9543
  * microtask checkpoint steps, such as calling ClearKeptObjects. Asserts that
@@ -9145,16 +9579,12 @@ class V8_EXPORT Isolate {
9145
9579
  * Executing scripts inside the callback will not re-trigger microtasks and
9146
9580
  * the callback.
9147
9581
  */
9148
- V8_DEPRECATE_SOON("Use *WithData version.")
9149
- void AddMicrotasksCompletedCallback(MicrotasksCompletedCallback callback);
9150
9582
  void AddMicrotasksCompletedCallback(
9151
9583
  MicrotasksCompletedCallbackWithData callback, void* data = nullptr);
9152
9584
 
9153
9585
  /**
9154
9586
  * Removes callback that was installed by AddMicrotasksCompletedCallback.
9155
9587
  */
9156
- V8_DEPRECATE_SOON("Use *WithData version.")
9157
- void RemoveMicrotasksCompletedCallback(MicrotasksCompletedCallback callback);
9158
9588
  void RemoveMicrotasksCompletedCallback(
9159
9589
  MicrotasksCompletedCallbackWithData callback, void* data = nullptr);
9160
9590
 
@@ -9263,6 +9693,11 @@ class V8_EXPORT Isolate {
9263
9693
  */
9264
9694
  void SetRAILMode(RAILMode rail_mode);
9265
9695
 
9696
+ /**
9697
+ * Update load start time of the RAIL mode
9698
+ */
9699
+ void UpdateLoadStartTime();
9700
+
9266
9701
  /**
9267
9702
  * Optional notification to tell V8 the current isolate is used for debugging
9268
9703
  * and requires higher heap limit.
@@ -9334,11 +9769,10 @@ class V8_EXPORT Isolate {
9334
9769
  void GetCodeRange(void** start, size_t* length_in_bytes);
9335
9770
 
9336
9771
  /**
9337
- * Returns the UnwindState necessary for use with the Unwinder API.
9772
+ * As GetCodeRange, but for embedded builtins (these live in a distinct
9773
+ * memory region from other V8 Code objects).
9338
9774
  */
9339
- // TODO(petermarshall): Remove this API.
9340
- V8_DEPRECATED("Use entry_stubs + code_pages version.")
9341
- UnwindState GetUnwindState();
9775
+ void GetEmbeddedCodeRange(const void** start, size_t* length_in_bytes);
9342
9776
 
9343
9777
  /**
9344
9778
  * Returns the JSEntryStubs necessary for use with the Unwinder API.
@@ -9398,12 +9832,14 @@ class V8_EXPORT Isolate {
9398
9832
  * strings should be allowed.
9399
9833
  */
9400
9834
  V8_DEPRECATED(
9401
- "Use Isolate::SetModifyCodeGenerationFromStringsCallback instead. "
9402
- "See http://crbug.com/v8/10096.")
9403
- void SetAllowCodeGenerationFromStringsCallback(
9404
- AllowCodeGenerationFromStringsCallback callback);
9835
+ "Use Isolate::SetModifyCodeGenerationFromStringsCallback with "
9836
+ "ModifyCodeGenerationFromStringsCallback2 instead. See "
9837
+ "http://crbug.com/1096017 and TC39 Dynamic Code Brand Checks proposal "
9838
+ "at https://github.com/tc39/proposal-dynamic-code-brand-checks.")
9405
9839
  void SetModifyCodeGenerationFromStringsCallback(
9406
9840
  ModifyCodeGenerationFromStringsCallback callback);
9841
+ void SetModifyCodeGenerationFromStringsCallback(
9842
+ ModifyCodeGenerationFromStringsCallback2 callback);
9407
9843
 
9408
9844
  /**
9409
9845
  * Set the callback to invoke to check if wasm code generation should
@@ -9421,12 +9857,22 @@ class V8_EXPORT Isolate {
9421
9857
 
9422
9858
  void SetWasmStreamingCallback(WasmStreamingCallback callback);
9423
9859
 
9424
- void SetWasmThreadsEnabledCallback(WasmThreadsEnabledCallback callback);
9425
-
9426
9860
  void SetWasmLoadSourceMapCallback(WasmLoadSourceMapCallback callback);
9427
9861
 
9428
9862
  void SetWasmSimdEnabledCallback(WasmSimdEnabledCallback callback);
9429
9863
 
9864
+ void SetWasmExceptionsEnabledCallback(WasmExceptionsEnabledCallback callback);
9865
+
9866
+ void SetSharedArrayBufferConstructorEnabledCallback(
9867
+ SharedArrayBufferConstructorEnabledCallback callback);
9868
+
9869
+ /**
9870
+ * This function can be called by the embedder to signal V8 that the dynamic
9871
+ * enabling of features has finished. V8 can now set up dynamically added
9872
+ * features.
9873
+ */
9874
+ void InstallConditionalFeatures(Local<Context> context);
9875
+
9430
9876
  /**
9431
9877
  * Check if V8 is dead and therefore unusable. This is the case after
9432
9878
  * fatal errors such as out-of-memory situations.
@@ -9589,7 +10035,7 @@ class V8_EXPORT StartupData {
9589
10035
  * EntropySource is used as a callback function when v8 needs a source
9590
10036
  * of entropy.
9591
10037
  */
9592
- typedef bool (*EntropySource)(unsigned char* buffer, size_t length);
10038
+ using EntropySource = bool (*)(unsigned char* buffer, size_t length);
9593
10039
 
9594
10040
  /**
9595
10041
  * ReturnAddressLocationResolver is used as a callback function when v8 is
@@ -9604,9 +10050,8 @@ typedef bool (*EntropySource)(unsigned char* buffer, size_t length);
9604
10050
  *
9605
10051
  * \note The resolver function must not cause garbage collection.
9606
10052
  */
9607
- typedef uintptr_t (*ReturnAddressLocationResolver)(
9608
- uintptr_t return_addr_location);
9609
-
10053
+ using ReturnAddressLocationResolver =
10054
+ uintptr_t (*)(uintptr_t return_addr_location);
9610
10055
 
9611
10056
  /**
9612
10057
  * Container class for static utility functions.
@@ -9760,7 +10205,7 @@ class V8_EXPORT V8 {
9760
10205
  * \param context The third argument passed to the Linux signal handler, which
9761
10206
  * points to a ucontext_t structure.
9762
10207
  */
9763
- V8_DEPRECATE_SOON("Use TryHandleWebAssemblyTrapPosix")
10208
+ V8_DEPRECATED("Use TryHandleWebAssemblyTrapPosix")
9764
10209
  static bool TryHandleSignal(int signal_number, void* info, void* context);
9765
10210
  #endif // V8_OS_POSIX
9766
10211
 
@@ -9791,6 +10236,15 @@ class V8_EXPORT V8 {
9791
10236
  */
9792
10237
  static void GetSharedMemoryStatistics(SharedMemoryStatistics* statistics);
9793
10238
 
10239
+ /**
10240
+ * Notifies V8 that the process is cross-origin-isolated, which enables
10241
+ * defining the SharedArrayBuffer function on the global object of Contexts.
10242
+ */
10243
+ V8_DEPRECATED(
10244
+ "Use the command line argument --enable-sharedarraybuffer-per-context "
10245
+ "together with SetSharedArrayBufferConstructorEnabledCallback")
10246
+ static void SetIsCrossOriginIsolated();
10247
+
9794
10248
  private:
9795
10249
  V8();
9796
10250
 
@@ -9840,6 +10294,8 @@ class V8_EXPORT V8 {
9840
10294
  static void ToLocalEmpty();
9841
10295
  static void InternalFieldOutOfBounds(int index);
9842
10296
  template <class T>
10297
+ friend class BasicTracedReference;
10298
+ template <class T>
9843
10299
  friend class Global;
9844
10300
  template <class T> friend class Local;
9845
10301
  template <class T>
@@ -9847,9 +10303,8 @@ class V8_EXPORT V8 {
9847
10303
  template <class T>
9848
10304
  friend class Maybe;
9849
10305
  template <class T>
9850
- friend class TracedReferenceBase;
9851
- template <class T>
9852
10306
  friend class TracedGlobal;
10307
+ friend class TracedReferenceBase;
9853
10308
  template <class T>
9854
10309
  friend class TracedReference;
9855
10310
  template <class T>
@@ -10269,7 +10724,7 @@ class V8_EXPORT ExtensionConfiguration {
10269
10724
  * A sandboxed execution context with its own set of built-in objects
10270
10725
  * and functions.
10271
10726
  */
10272
- class V8_EXPORT Context {
10727
+ class V8_EXPORT Context : public Data {
10273
10728
  public:
10274
10729
  /**
10275
10730
  * Returns the global proxy object.
@@ -10484,8 +10939,8 @@ class V8_EXPORT Context {
10484
10939
  * context, call the specified callback, and throw an exception.
10485
10940
  * To unset abort, pass nullptr as callback.
10486
10941
  */
10487
- typedef void (*AbortScriptExecutionCallback)(Isolate* isolate,
10488
- Local<Context> context);
10942
+ using AbortScriptExecutionCallback = void (*)(Isolate* isolate,
10943
+ Local<Context> context);
10489
10944
  void SetAbortScriptExecution(AbortScriptExecutionCallback callback);
10490
10945
 
10491
10946
  /**
@@ -10500,11 +10955,23 @@ class V8_EXPORT Context {
10500
10955
  */
10501
10956
  void SetContinuationPreservedEmbedderData(Local<Value> context);
10502
10957
 
10958
+ /**
10959
+ * Set or clear hooks to be invoked for promise lifecycle operations.
10960
+ * To clear a hook, set it to an empty v8::Function. Each function will
10961
+ * receive the observed promise as the first argument. If a chaining
10962
+ * operation is used on a promise, the init will additionally receive
10963
+ * the parent promise as the second argument.
10964
+ */
10965
+ void SetPromiseHooks(Local<Function> init_hook,
10966
+ Local<Function> before_hook,
10967
+ Local<Function> after_hook,
10968
+ Local<Function> resolve_hook);
10969
+
10503
10970
  /**
10504
10971
  * Stack-allocated class which sets the execution context for all
10505
10972
  * operations executed within a local scope.
10506
10973
  */
10507
- class Scope {
10974
+ class V8_NODISCARD Scope {
10508
10975
  public:
10509
10976
  explicit V8_INLINE Scope(Local<Context> context) : context_(context) {
10510
10977
  context_->Enter();
@@ -10520,7 +10987,7 @@ class V8_EXPORT Context {
10520
10987
  * stack.
10521
10988
  * https://html.spec.whatwg.org/multipage/webappapis.html#backup-incumbent-settings-object-stack
10522
10989
  */
10523
- class V8_EXPORT BackupIncumbentScope final {
10990
+ class V8_EXPORT V8_NODISCARD BackupIncumbentScope final {
10524
10991
  public:
10525
10992
  /**
10526
10993
  * |backup_incumbent_context| is pushed onto the backup incumbent settings
@@ -10546,18 +11013,21 @@ class V8_EXPORT Context {
10546
11013
  const BackupIncumbentScope* prev_ = nullptr;
10547
11014
  };
10548
11015
 
11016
+ V8_INLINE static Context* Cast(Data* data);
11017
+
10549
11018
  private:
10550
11019
  friend class Value;
10551
11020
  friend class Script;
10552
11021
  friend class Object;
10553
11022
  friend class Function;
10554
11023
 
11024
+ static void CheckCast(Data* obj);
11025
+
10555
11026
  internal::Address* GetDataFromSnapshotOnce(size_t index);
10556
11027
  Local<Value> SlowGetEmbedderData(int index);
10557
11028
  void* SlowGetAlignedPointerFromEmbedderData(int index);
10558
11029
  };
10559
11030
 
10560
-
10561
11031
  /**
10562
11032
  * Multiple threads in V8 are allowed, but only one thread at a time is allowed
10563
11033
  * to use any given V8 isolate, see the comments in the Isolate class. The
@@ -10700,12 +11170,14 @@ class V8_EXPORT Unwinder {
10700
11170
  *
10701
11171
  * The unwinder also needs the virtual memory range of all possible V8 code
10702
11172
  * objects. There are two ranges required - the heap code range and the range
10703
- * for code embedded in the binary. The V8 API provides all required inputs
10704
- * via an UnwindState object through the Isolate::GetUnwindState() API. These
10705
- * values will not change after Isolate initialization, so the same
10706
- * |unwind_state| can be used for multiple calls.
11173
+ * for code embedded in the binary.
11174
+ *
11175
+ * Available on x64, ARM64 and ARM32.
10707
11176
  *
10708
- * \param unwind_state Input state for the Isolate that the stack comes from.
11177
+ * \param code_pages A list of all of the ranges in which V8 has allocated
11178
+ * executable code. The caller should obtain this list by calling
11179
+ * Isolate::CopyCodePages() during the same interrupt/thread suspension that
11180
+ * captures the stack.
10709
11181
  * \param register_state The current registers. This is an in-out param that
10710
11182
  * will be overwritten with the register values after unwinding, on success.
10711
11183
  * \param stack_base The resulting stack pointer and frame pointer values are
@@ -10716,20 +11188,6 @@ class V8_EXPORT Unwinder {
10716
11188
  *
10717
11189
  * \return True on success.
10718
11190
  */
10719
- // TODO(petermarshall): Remove this API
10720
- V8_DEPRECATED("Use entry_stubs + code_pages version.")
10721
- static bool TryUnwindV8Frames(const UnwindState& unwind_state,
10722
- RegisterState* register_state,
10723
- const void* stack_base);
10724
-
10725
- /**
10726
- * The same as above, but is available on x64, ARM64 and ARM32.
10727
- *
10728
- * \param code_pages A list of all of the ranges in which V8 has allocated
10729
- * executable code. The caller should obtain this list by calling
10730
- * Isolate::CopyCodePages() during the same interrupt/thread suspension that
10731
- * captures the stack.
10732
- */
10733
11191
  static bool TryUnwindV8Frames(const JSEntryStubs& entry_stubs,
10734
11192
  size_t code_pages_length,
10735
11193
  const MemoryRange* code_pages,
@@ -10737,20 +11195,13 @@ class V8_EXPORT Unwinder {
10737
11195
  const void* stack_base);
10738
11196
 
10739
11197
  /**
10740
- * Whether the PC is within the V8 code range represented by code_range or
10741
- * embedded_code_range in |unwind_state|.
11198
+ * Whether the PC is within the V8 code range represented by code_pages.
10742
11199
  *
10743
11200
  * If this returns false, then calling UnwindV8Frames() with the same PC
10744
11201
  * and unwind_state will always fail. If it returns true, then unwinding may
10745
11202
  * (but not necessarily) be successful.
10746
- */
10747
- // TODO(petermarshall): Remove this API
10748
- V8_DEPRECATED("Use code_pages version.")
10749
- static bool PCIsInV8(const UnwindState& unwind_state, void* pc);
10750
-
10751
- /**
10752
- * The same as above, but is available on x64, ARM64 and ARM32. See the
10753
- * comment on TryUnwindV8Frames.
11203
+ *
11204
+ * Available on x64, ARM64 and ARM32
10754
11205
  */
10755
11206
  static bool PCIsInV8(size_t code_pages_length, const MemoryRange* code_pages,
10756
11207
  void* pc);
@@ -10769,8 +11220,8 @@ Local<T> Local<T>::New(Isolate* isolate, const PersistentBase<T>& that) {
10769
11220
  }
10770
11221
 
10771
11222
  template <class T>
10772
- Local<T> Local<T>::New(Isolate* isolate, const TracedReferenceBase<T>& that) {
10773
- return New(isolate, that.val_);
11223
+ Local<T> Local<T>::New(Isolate* isolate, const BasicTracedReference<T>& that) {
11224
+ return New(isolate, *that);
10774
11225
  }
10775
11226
 
10776
11227
  template <class T>
@@ -10840,7 +11291,7 @@ void Persistent<T, M>::Copy(const Persistent<S, M2>& that) {
10840
11291
 
10841
11292
  template <class T>
10842
11293
  bool PersistentBase<T>::IsWeak() const {
10843
- typedef internal::Internals I;
11294
+ using I = internal::Internals;
10844
11295
  if (this->IsEmpty()) return false;
10845
11296
  return I::GetNodeState(reinterpret_cast<internal::Address*>(this->val_)) ==
10846
11297
  I::kNodeStateIsWeakValue;
@@ -10881,7 +11332,7 @@ template <typename P>
10881
11332
  V8_INLINE void PersistentBase<T>::SetWeak(
10882
11333
  P* parameter, typename WeakCallbackInfo<P>::Callback callback,
10883
11334
  WeakCallbackType type) {
10884
- typedef typename WeakCallbackInfo<void>::Callback Callback;
11335
+ using Callback = WeakCallbackInfo<void>::Callback;
10885
11336
  #if (__GNUC__ >= 8) && !defined(__clang__)
10886
11337
  #pragma GCC diagnostic push
10887
11338
  #pragma GCC diagnostic ignored "-Wcast-function-type"
@@ -10913,7 +11364,7 @@ void PersistentBase<T>::AnnotateStrongRetainer(const char* label) {
10913
11364
 
10914
11365
  template <class T>
10915
11366
  void PersistentBase<T>::SetWrapperClassId(uint16_t class_id) {
10916
- typedef internal::Internals I;
11367
+ using I = internal::Internals;
10917
11368
  if (this->IsEmpty()) return;
10918
11369
  internal::Address* obj = reinterpret_cast<internal::Address*>(this->val_);
10919
11370
  uint8_t* addr = reinterpret_cast<uint8_t*>(obj) + I::kNodeClassIdOffset;
@@ -10923,7 +11374,7 @@ void PersistentBase<T>::SetWrapperClassId(uint16_t class_id) {
10923
11374
 
10924
11375
  template <class T>
10925
11376
  uint16_t PersistentBase<T>::WrapperClassId() const {
10926
- typedef internal::Internals I;
11377
+ using I = internal::Internals;
10927
11378
  if (this->IsEmpty()) return 0;
10928
11379
  internal::Address* obj = reinterpret_cast<internal::Address*>(this->val_);
10929
11380
  uint8_t* addr = reinterpret_cast<uint8_t*>(obj) + I::kNodeClassIdOffset;
@@ -10957,23 +11408,69 @@ Global<T>& Global<T>::operator=(Global<S>&& rhs) {
10957
11408
  }
10958
11409
 
10959
11410
  template <class T>
10960
- T* TracedReferenceBase<T>::New(Isolate* isolate, T* that, void* slot,
10961
- DestructionMode destruction_mode) {
11411
+ internal::Address* BasicTracedReference<T>::New(
11412
+ Isolate* isolate, T* that, void* slot, DestructionMode destruction_mode) {
10962
11413
  if (that == nullptr) return nullptr;
10963
11414
  internal::Address* p = reinterpret_cast<internal::Address*>(that);
10964
- return reinterpret_cast<T*>(V8::GlobalizeTracedReference(
11415
+ return V8::GlobalizeTracedReference(
10965
11416
  reinterpret_cast<internal::Isolate*>(isolate), p,
10966
11417
  reinterpret_cast<internal::Address*>(slot),
10967
- destruction_mode == kWithDestructor));
11418
+ destruction_mode == kWithDestructor);
10968
11419
  }
10969
11420
 
10970
- template <class T>
10971
- void TracedReferenceBase<T>::Reset() {
11421
+ void TracedReferenceBase::Reset() {
10972
11422
  if (IsEmpty()) return;
10973
11423
  V8::DisposeTracedGlobal(reinterpret_cast<internal::Address*>(val_));
10974
11424
  SetSlotThreadSafe(nullptr);
10975
11425
  }
10976
11426
 
11427
+ v8::Local<v8::Value> TracedReferenceBase::Get(v8::Isolate* isolate) const {
11428
+ if (IsEmpty()) return Local<Value>();
11429
+ return Local<Value>::New(isolate, reinterpret_cast<Value*>(val_));
11430
+ }
11431
+
11432
+ V8_INLINE bool operator==(const TracedReferenceBase& lhs,
11433
+ const TracedReferenceBase& rhs) {
11434
+ v8::internal::Address* a = reinterpret_cast<v8::internal::Address*>(lhs.val_);
11435
+ v8::internal::Address* b = reinterpret_cast<v8::internal::Address*>(rhs.val_);
11436
+ if (a == nullptr) return b == nullptr;
11437
+ if (b == nullptr) return false;
11438
+ return *a == *b;
11439
+ }
11440
+
11441
+ template <typename U>
11442
+ V8_INLINE bool operator==(const TracedReferenceBase& lhs,
11443
+ const v8::Local<U>& rhs) {
11444
+ v8::internal::Address* a = reinterpret_cast<v8::internal::Address*>(lhs.val_);
11445
+ v8::internal::Address* b = reinterpret_cast<v8::internal::Address*>(*rhs);
11446
+ if (a == nullptr) return b == nullptr;
11447
+ if (b == nullptr) return false;
11448
+ return *a == *b;
11449
+ }
11450
+
11451
+ template <typename U>
11452
+ V8_INLINE bool operator==(const v8::Local<U>& lhs,
11453
+ const TracedReferenceBase& rhs) {
11454
+ return rhs == lhs;
11455
+ }
11456
+
11457
+ V8_INLINE bool operator!=(const TracedReferenceBase& lhs,
11458
+ const TracedReferenceBase& rhs) {
11459
+ return !(lhs == rhs);
11460
+ }
11461
+
11462
+ template <typename U>
11463
+ V8_INLINE bool operator!=(const TracedReferenceBase& lhs,
11464
+ const v8::Local<U>& rhs) {
11465
+ return !(lhs == rhs);
11466
+ }
11467
+
11468
+ template <typename U>
11469
+ V8_INLINE bool operator!=(const v8::Local<U>& lhs,
11470
+ const TracedReferenceBase& rhs) {
11471
+ return !(rhs == lhs);
11472
+ }
11473
+
10977
11474
  template <class T>
10978
11475
  template <class S>
10979
11476
  void TracedGlobal<T>::Reset(Isolate* isolate, const Local<S>& other) {
@@ -10981,7 +11478,7 @@ void TracedGlobal<T>::Reset(Isolate* isolate, const Local<S>& other) {
10981
11478
  Reset();
10982
11479
  if (other.IsEmpty()) return;
10983
11480
  this->val_ = this->New(isolate, other.val_, &this->val_,
10984
- TracedReferenceBase<T>::kWithDestructor);
11481
+ BasicTracedReference<T>::kWithDestructor);
10985
11482
  }
10986
11483
 
10987
11484
  template <class T>
@@ -11031,7 +11528,7 @@ void TracedReference<T>::Reset(Isolate* isolate, const Local<S>& other) {
11031
11528
  if (other.IsEmpty()) return;
11032
11529
  this->SetSlotThreadSafe(
11033
11530
  this->New(isolate, other.val_, &this->val_,
11034
- TracedReferenceBase<T>::kWithoutDestructor));
11531
+ BasicTracedReference<T>::kWithoutDestructor));
11035
11532
  }
11036
11533
 
11037
11534
  template <class T>
@@ -11074,18 +11571,16 @@ TracedReference<T>& TracedReference<T>::operator=(const TracedReference& rhs) {
11074
11571
  return *this;
11075
11572
  }
11076
11573
 
11077
- template <class T>
11078
- void TracedReferenceBase<T>::SetWrapperClassId(uint16_t class_id) {
11079
- typedef internal::Internals I;
11574
+ void TracedReferenceBase::SetWrapperClassId(uint16_t class_id) {
11575
+ using I = internal::Internals;
11080
11576
  if (IsEmpty()) return;
11081
11577
  internal::Address* obj = reinterpret_cast<internal::Address*>(val_);
11082
11578
  uint8_t* addr = reinterpret_cast<uint8_t*>(obj) + I::kNodeClassIdOffset;
11083
11579
  *reinterpret_cast<uint16_t*>(addr) = class_id;
11084
11580
  }
11085
11581
 
11086
- template <class T>
11087
- uint16_t TracedReferenceBase<T>::WrapperClassId() const {
11088
- typedef internal::Internals I;
11582
+ uint16_t TracedReferenceBase::WrapperClassId() const {
11583
+ using I = internal::Internals;
11089
11584
  if (IsEmpty()) return 0;
11090
11585
  internal::Address* obj = reinterpret_cast<internal::Address*>(val_);
11091
11586
  uint8_t* addr = reinterpret_cast<uint8_t*>(obj) + I::kNodeClassIdOffset;
@@ -11115,7 +11610,7 @@ void ReturnValue<T>::Set(const Global<S>& handle) {
11115
11610
 
11116
11611
  template <typename T>
11117
11612
  template <typename S>
11118
- void ReturnValue<T>::Set(const TracedReferenceBase<S>& handle) {
11613
+ void ReturnValue<T>::Set(const BasicTracedReference<S>& handle) {
11119
11614
  static_assert(std::is_base_of<T, S>::value, "type check");
11120
11615
  if (V8_UNLIKELY(handle.IsEmpty())) {
11121
11616
  *value_ = GetDefaultValue();
@@ -11145,7 +11640,7 @@ void ReturnValue<T>::Set(double i) {
11145
11640
  template<typename T>
11146
11641
  void ReturnValue<T>::Set(int32_t i) {
11147
11642
  static_assert(std::is_base_of<T, Integer>::value, "type check");
11148
- typedef internal::Internals I;
11643
+ using I = internal::Internals;
11149
11644
  if (V8_LIKELY(I::IsValidSmi(i))) {
11150
11645
  *value_ = I::IntToSmi(i);
11151
11646
  return;
@@ -11168,7 +11663,7 @@ void ReturnValue<T>::Set(uint32_t i) {
11168
11663
  template<typename T>
11169
11664
  void ReturnValue<T>::Set(bool value) {
11170
11665
  static_assert(std::is_base_of<T, Boolean>::value, "type check");
11171
- typedef internal::Internals I;
11666
+ using I = internal::Internals;
11172
11667
  int root_index;
11173
11668
  if (value) {
11174
11669
  root_index = I::kTrueValueRootIndex;
@@ -11181,21 +11676,21 @@ void ReturnValue<T>::Set(bool value) {
11181
11676
  template<typename T>
11182
11677
  void ReturnValue<T>::SetNull() {
11183
11678
  static_assert(std::is_base_of<T, Primitive>::value, "type check");
11184
- typedef internal::Internals I;
11679
+ using I = internal::Internals;
11185
11680
  *value_ = *I::GetRoot(GetIsolate(), I::kNullValueRootIndex);
11186
11681
  }
11187
11682
 
11188
11683
  template<typename T>
11189
11684
  void ReturnValue<T>::SetUndefined() {
11190
11685
  static_assert(std::is_base_of<T, Primitive>::value, "type check");
11191
- typedef internal::Internals I;
11686
+ using I = internal::Internals;
11192
11687
  *value_ = *I::GetRoot(GetIsolate(), I::kUndefinedValueRootIndex);
11193
11688
  }
11194
11689
 
11195
11690
  template<typename T>
11196
11691
  void ReturnValue<T>::SetEmptyString() {
11197
11692
  static_assert(std::is_base_of<T, String>::value, "type check");
11198
- typedef internal::Internals I;
11693
+ using I = internal::Internals;
11199
11694
  *value_ = *I::GetRoot(GetIsolate(), I::kEmptyStringRootIndex);
11200
11695
  }
11201
11696
 
@@ -11207,7 +11702,7 @@ Isolate* ReturnValue<T>::GetIsolate() const {
11207
11702
 
11208
11703
  template <typename T>
11209
11704
  Local<Value> ReturnValue<T>::Get() const {
11210
- typedef internal::Internals I;
11705
+ using I = internal::Internals;
11211
11706
  if (*value_ == *I::GetRoot(GetIsolate(), I::kTheHoleValueRootIndex))
11212
11707
  return Local<Value>(*Undefined(GetIsolate()));
11213
11708
  return Local<Value>::New(GetIsolate(), reinterpret_cast<Value*>(value_));
@@ -11235,22 +11730,14 @@ template<typename T>
11235
11730
  Local<Value> FunctionCallbackInfo<T>::operator[](int i) const {
11236
11731
  // values_ points to the first argument (not the receiver).
11237
11732
  if (i < 0 || length_ <= i) return Local<Value>(*Undefined(GetIsolate()));
11238
- #ifdef V8_REVERSE_JSARGS
11239
11733
  return Local<Value>(reinterpret_cast<Value*>(values_ + i));
11240
- #else
11241
- return Local<Value>(reinterpret_cast<Value*>(values_ - i));
11242
- #endif
11243
11734
  }
11244
11735
 
11245
11736
 
11246
11737
  template<typename T>
11247
11738
  Local<Object> FunctionCallbackInfo<T>::This() const {
11248
11739
  // values_ points to the first argument (not the receiver).
11249
- #ifdef V8_REVERSE_JSARGS
11250
11740
  return Local<Object>(reinterpret_cast<Object*>(values_ - 1));
11251
- #else
11252
- return Local<Object>(reinterpret_cast<Object*>(values_ + 1));
11253
- #endif
11254
11741
  }
11255
11742
 
11256
11743
 
@@ -11295,23 +11782,48 @@ int FunctionCallbackInfo<T>::Length() const {
11295
11782
  return length_;
11296
11783
  }
11297
11784
 
11298
- ScriptOrigin::ScriptOrigin(Local<Value> resource_name,
11299
- Local<Integer> resource_line_offset,
11300
- Local<Integer> resource_column_offset,
11301
- Local<Boolean> resource_is_shared_cross_origin,
11302
- Local<Integer> script_id,
11303
- Local<Value> source_map_url,
11304
- Local<Boolean> resource_is_opaque,
11305
- Local<Boolean> is_wasm, Local<Boolean> is_module,
11785
+ ScriptOrigin::ScriptOrigin(
11786
+ Local<Value> resource_name, Local<Integer> line_offset,
11787
+ Local<Integer> column_offset, Local<Boolean> is_shared_cross_origin,
11788
+ Local<Integer> script_id, Local<Value> source_map_url,
11789
+ Local<Boolean> is_opaque, Local<Boolean> is_wasm, Local<Boolean> is_module,
11790
+ Local<PrimitiveArray> host_defined_options)
11791
+ : ScriptOrigin(
11792
+ Isolate::GetCurrent(), resource_name,
11793
+ line_offset.IsEmpty() ? 0 : static_cast<int>(line_offset->Value()),
11794
+ column_offset.IsEmpty() ? 0
11795
+ : static_cast<int>(column_offset->Value()),
11796
+ !is_shared_cross_origin.IsEmpty() && is_shared_cross_origin->IsTrue(),
11797
+ static_cast<int>(script_id.IsEmpty() ? -1 : script_id->Value()),
11798
+ source_map_url, !is_opaque.IsEmpty() && is_opaque->IsTrue(),
11799
+ !is_wasm.IsEmpty() && is_wasm->IsTrue(),
11800
+ !is_module.IsEmpty() && is_module->IsTrue(), host_defined_options) {}
11801
+
11802
+ ScriptOrigin::ScriptOrigin(Local<Value> resource_name, int line_offset,
11803
+ int column_offset, bool is_shared_cross_origin,
11804
+ int script_id, Local<Value> source_map_url,
11805
+ bool is_opaque, bool is_wasm, bool is_module,
11806
+ Local<PrimitiveArray> host_defined_options)
11807
+ : isolate_(Isolate::GetCurrent()),
11808
+ resource_name_(resource_name),
11809
+ resource_line_offset_(line_offset),
11810
+ resource_column_offset_(column_offset),
11811
+ options_(is_shared_cross_origin, is_opaque, is_wasm, is_module),
11812
+ script_id_(script_id),
11813
+ source_map_url_(source_map_url),
11814
+ host_defined_options_(host_defined_options) {}
11815
+
11816
+ ScriptOrigin::ScriptOrigin(Isolate* isolate, Local<Value> resource_name,
11817
+ int line_offset, int column_offset,
11818
+ bool is_shared_cross_origin, int script_id,
11819
+ Local<Value> source_map_url, bool is_opaque,
11820
+ bool is_wasm, bool is_module,
11306
11821
  Local<PrimitiveArray> host_defined_options)
11307
- : resource_name_(resource_name),
11308
- resource_line_offset_(resource_line_offset),
11309
- resource_column_offset_(resource_column_offset),
11310
- options_(!resource_is_shared_cross_origin.IsEmpty() &&
11311
- resource_is_shared_cross_origin->IsTrue(),
11312
- !resource_is_opaque.IsEmpty() && resource_is_opaque->IsTrue(),
11313
- !is_wasm.IsEmpty() && is_wasm->IsTrue(),
11314
- !is_module.IsEmpty() && is_module->IsTrue()),
11822
+ : isolate_(isolate),
11823
+ resource_name_(resource_name),
11824
+ resource_line_offset_(line_offset),
11825
+ resource_column_offset_(column_offset),
11826
+ options_(is_shared_cross_origin, is_opaque, is_wasm, is_module),
11315
11827
  script_id_(script_id),
11316
11828
  source_map_url_(source_map_url),
11317
11829
  host_defined_options_(host_defined_options) {}
@@ -11323,17 +11835,22 @@ Local<PrimitiveArray> ScriptOrigin::HostDefinedOptions() const {
11323
11835
  }
11324
11836
 
11325
11837
  Local<Integer> ScriptOrigin::ResourceLineOffset() const {
11326
- return resource_line_offset_;
11838
+ return v8::Integer::New(isolate_, resource_line_offset_);
11327
11839
  }
11328
11840
 
11329
-
11330
11841
  Local<Integer> ScriptOrigin::ResourceColumnOffset() const {
11331
- return resource_column_offset_;
11842
+ return v8::Integer::New(isolate_, resource_column_offset_);
11332
11843
  }
11333
11844
 
11845
+ Local<Integer> ScriptOrigin::ScriptID() const {
11846
+ return v8::Integer::New(isolate_, script_id_);
11847
+ }
11848
+
11849
+ int ScriptOrigin::LineOffset() const { return resource_line_offset_; }
11334
11850
 
11335
- Local<Integer> ScriptOrigin::ScriptID() const { return script_id_; }
11851
+ int ScriptOrigin::ColumnOffset() const { return resource_column_offset_; }
11336
11852
 
11853
+ int ScriptOrigin::ScriptId() const { return script_id_; }
11337
11854
 
11338
11855
  Local<Value> ScriptOrigin::SourceMapUrl() const { return source_map_url_; }
11339
11856
 
@@ -11341,8 +11858,8 @@ ScriptCompiler::Source::Source(Local<String> string, const ScriptOrigin& origin,
11341
11858
  CachedData* data)
11342
11859
  : source_string(string),
11343
11860
  resource_name(origin.ResourceName()),
11344
- resource_line_offset(origin.ResourceLineOffset()),
11345
- resource_column_offset(origin.ResourceColumnOffset()),
11861
+ resource_line_offset(origin.LineOffset()),
11862
+ resource_column_offset(origin.ColumnOffset()),
11346
11863
  resource_options(origin.Options()),
11347
11864
  source_map_url(origin.SourceMapUrl()),
11348
11865
  host_defined_options(origin.HostDefinedOptions()),
@@ -11407,8 +11924,8 @@ AccessorSignature* AccessorSignature::Cast(Data* data) {
11407
11924
 
11408
11925
  Local<Value> Object::GetInternalField(int index) {
11409
11926
  #ifndef V8_ENABLE_CHECKS
11410
- typedef internal::Address A;
11411
- typedef internal::Internals I;
11927
+ using A = internal::Address;
11928
+ using I = internal::Internals;
11412
11929
  A obj = *reinterpret_cast<A*>(this);
11413
11930
  // Fast path: If the object is a plain JSObject, which is the common case, we
11414
11931
  // know where to find the internal fields and can return the value directly.
@@ -11435,8 +11952,8 @@ Local<Value> Object::GetInternalField(int index) {
11435
11952
 
11436
11953
  void* Object::GetAlignedPointerFromInternalField(int index) {
11437
11954
  #ifndef V8_ENABLE_CHECKS
11438
- typedef internal::Address A;
11439
- typedef internal::Internals I;
11955
+ using A = internal::Address;
11956
+ using I = internal::Internals;
11440
11957
  A obj = *reinterpret_cast<A*>(this);
11441
11958
  // Fast path: If the object is a plain JSObject, which is the common case, we
11442
11959
  // know where to find the internal fields and can return the value directly.
@@ -11445,25 +11962,28 @@ void* Object::GetAlignedPointerFromInternalField(int index) {
11445
11962
  instance_type == I::kJSApiObjectType ||
11446
11963
  instance_type == I::kJSSpecialApiObjectType)) {
11447
11964
  int offset = I::kJSObjectHeaderSize + (I::kEmbedderDataSlotSize * index);
11965
+ #ifdef V8_HEAP_SANDBOX
11966
+ offset += I::kEmbedderDataSlotRawPayloadOffset;
11967
+ #endif
11448
11968
  internal::Isolate* isolate = I::GetIsolateForHeapSandbox(obj);
11449
- A value = I::ReadExternalPointerField(isolate, obj, offset);
11969
+ A value = I::ReadExternalPointerField(
11970
+ isolate, obj, offset, internal::kEmbedderDataSlotPayloadTag);
11450
11971
  return reinterpret_cast<void*>(value);
11451
11972
  }
11452
11973
  #endif
11453
11974
  return SlowGetAlignedPointerFromInternalField(index);
11454
11975
  }
11455
11976
 
11456
- String* String::Cast(v8::Value* value) {
11977
+ String* String::Cast(v8::Data* data) {
11457
11978
  #ifdef V8_ENABLE_CHECKS
11458
- CheckCast(value);
11979
+ CheckCast(data);
11459
11980
  #endif
11460
- return static_cast<String*>(value);
11981
+ return static_cast<String*>(data);
11461
11982
  }
11462
11983
 
11463
-
11464
11984
  Local<String> String::Empty(Isolate* isolate) {
11465
- typedef internal::Address S;
11466
- typedef internal::Internals I;
11985
+ using S = internal::Address;
11986
+ using I = internal::Internals;
11467
11987
  I::CheckInitialized(isolate);
11468
11988
  S* slot = I::GetRoot(isolate, I::kEmptyStringRootIndex);
11469
11989
  return Local<String>(reinterpret_cast<String*>(slot));
@@ -11471,15 +11991,16 @@ Local<String> String::Empty(Isolate* isolate) {
11471
11991
 
11472
11992
 
11473
11993
  String::ExternalStringResource* String::GetExternalStringResource() const {
11474
- typedef internal::Address A;
11475
- typedef internal::Internals I;
11994
+ using A = internal::Address;
11995
+ using I = internal::Internals;
11476
11996
  A obj = *reinterpret_cast<const A*>(this);
11477
11997
 
11478
11998
  ExternalStringResource* result;
11479
11999
  if (I::IsExternalTwoByteString(I::GetInstanceType(obj))) {
11480
12000
  internal::Isolate* isolate = I::GetIsolateForHeapSandbox(obj);
11481
12001
  A value =
11482
- I::ReadExternalPointerField(isolate, obj, I::kStringResourceOffset);
12002
+ I::ReadExternalPointerField(isolate, obj, I::kStringResourceOffset,
12003
+ internal::kExternalStringResourceTag);
11483
12004
  result = reinterpret_cast<String::ExternalStringResource*>(value);
11484
12005
  } else {
11485
12006
  result = GetExternalStringResourceSlow();
@@ -11493,8 +12014,8 @@ String::ExternalStringResource* String::GetExternalStringResource() const {
11493
12014
 
11494
12015
  String::ExternalStringResourceBase* String::GetExternalStringResourceBase(
11495
12016
  String::Encoding* encoding_out) const {
11496
- typedef internal::Address A;
11497
- typedef internal::Internals I;
12017
+ using A = internal::Address;
12018
+ using I = internal::Internals;
11498
12019
  A obj = *reinterpret_cast<const A*>(this);
11499
12020
  int type = I::GetInstanceType(obj) & I::kFullStringRepresentationMask;
11500
12021
  *encoding_out = static_cast<Encoding>(type & I::kStringEncodingMask);
@@ -11503,7 +12024,8 @@ String::ExternalStringResourceBase* String::GetExternalStringResourceBase(
11503
12024
  type == I::kExternalTwoByteRepresentationTag) {
11504
12025
  internal::Isolate* isolate = I::GetIsolateForHeapSandbox(obj);
11505
12026
  A value =
11506
- I::ReadExternalPointerField(isolate, obj, I::kStringResourceOffset);
12027
+ I::ReadExternalPointerField(isolate, obj, I::kStringResourceOffset,
12028
+ internal::kExternalStringResourceTag);
11507
12029
  resource = reinterpret_cast<ExternalStringResourceBase*>(value);
11508
12030
  } else {
11509
12031
  resource = GetExternalStringResourceBaseSlow(encoding_out);
@@ -11524,8 +12046,8 @@ bool Value::IsUndefined() const {
11524
12046
  }
11525
12047
 
11526
12048
  bool Value::QuickIsUndefined() const {
11527
- typedef internal::Address A;
11528
- typedef internal::Internals I;
12049
+ using A = internal::Address;
12050
+ using I = internal::Internals;
11529
12051
  A obj = *reinterpret_cast<const A*>(this);
11530
12052
  if (!I::HasHeapObjectTag(obj)) return false;
11531
12053
  if (I::GetInstanceType(obj) != I::kOddballType) return false;
@@ -11542,8 +12064,8 @@ bool Value::IsNull() const {
11542
12064
  }
11543
12065
 
11544
12066
  bool Value::QuickIsNull() const {
11545
- typedef internal::Address A;
11546
- typedef internal::Internals I;
12067
+ using A = internal::Address;
12068
+ using I = internal::Internals;
11547
12069
  A obj = *reinterpret_cast<const A*>(this);
11548
12070
  if (!I::HasHeapObjectTag(obj)) return false;
11549
12071
  if (I::GetInstanceType(obj) != I::kOddballType) return false;
@@ -11559,8 +12081,8 @@ bool Value::IsNullOrUndefined() const {
11559
12081
  }
11560
12082
 
11561
12083
  bool Value::QuickIsNullOrUndefined() const {
11562
- typedef internal::Address A;
11563
- typedef internal::Internals I;
12084
+ using A = internal::Address;
12085
+ using I = internal::Internals;
11564
12086
  A obj = *reinterpret_cast<const A*>(this);
11565
12087
  if (!I::HasHeapObjectTag(obj)) return false;
11566
12088
  if (I::GetInstanceType(obj) != I::kOddballType) return false;
@@ -11577,8 +12099,8 @@ bool Value::IsString() const {
11577
12099
  }
11578
12100
 
11579
12101
  bool Value::QuickIsString() const {
11580
- typedef internal::Address A;
11581
- typedef internal::Internals I;
12102
+ using A = internal::Address;
12103
+ using I = internal::Internals;
11582
12104
  A obj = *reinterpret_cast<const A*>(this);
11583
12105
  if (!I::HasHeapObjectTag(obj)) return false;
11584
12106
  return (I::GetInstanceType(obj) < I::kFirstNonstringType);
@@ -11589,30 +12111,34 @@ template <class T> Value* Value::Cast(T* value) {
11589
12111
  return static_cast<Value*>(value);
11590
12112
  }
11591
12113
 
11592
-
11593
- Boolean* Boolean::Cast(v8::Value* value) {
12114
+ template <>
12115
+ V8_INLINE Value* Value::Cast(Data* value) {
11594
12116
  #ifdef V8_ENABLE_CHECKS
11595
12117
  CheckCast(value);
11596
12118
  #endif
11597
- return static_cast<Boolean*>(value);
12119
+ return static_cast<Value*>(value);
11598
12120
  }
11599
12121
 
11600
-
11601
- Name* Name::Cast(v8::Value* value) {
12122
+ Boolean* Boolean::Cast(v8::Data* data) {
11602
12123
  #ifdef V8_ENABLE_CHECKS
11603
- CheckCast(value);
12124
+ CheckCast(data);
11604
12125
  #endif
11605
- return static_cast<Name*>(value);
12126
+ return static_cast<Boolean*>(data);
11606
12127
  }
11607
12128
 
11608
-
11609
- Symbol* Symbol::Cast(v8::Value* value) {
12129
+ Name* Name::Cast(v8::Data* data) {
11610
12130
  #ifdef V8_ENABLE_CHECKS
11611
- CheckCast(value);
12131
+ CheckCast(data);
11612
12132
  #endif
11613
- return static_cast<Symbol*>(value);
12133
+ return static_cast<Name*>(data);
11614
12134
  }
11615
12135
 
12136
+ Symbol* Symbol::Cast(v8::Data* data) {
12137
+ #ifdef V8_ENABLE_CHECKS
12138
+ CheckCast(data);
12139
+ #endif
12140
+ return static_cast<Symbol*>(data);
12141
+ }
11616
12142
 
11617
12143
  Private* Private::Cast(Data* data) {
11618
12144
  #ifdef V8_ENABLE_CHECKS
@@ -11621,43 +12147,60 @@ Private* Private::Cast(Data* data) {
11621
12147
  return reinterpret_cast<Private*>(data);
11622
12148
  }
11623
12149
 
11624
-
11625
- Number* Number::Cast(v8::Value* value) {
12150
+ ModuleRequest* ModuleRequest::Cast(Data* data) {
11626
12151
  #ifdef V8_ENABLE_CHECKS
11627
- CheckCast(value);
12152
+ CheckCast(data);
11628
12153
  #endif
11629
- return static_cast<Number*>(value);
12154
+ return reinterpret_cast<ModuleRequest*>(data);
11630
12155
  }
11631
12156
 
12157
+ Module* Module::Cast(Data* data) {
12158
+ #ifdef V8_ENABLE_CHECKS
12159
+ CheckCast(data);
12160
+ #endif
12161
+ return reinterpret_cast<Module*>(data);
12162
+ }
11632
12163
 
11633
- Integer* Integer::Cast(v8::Value* value) {
12164
+ Number* Number::Cast(v8::Data* data) {
11634
12165
  #ifdef V8_ENABLE_CHECKS
11635
- CheckCast(value);
12166
+ CheckCast(data);
11636
12167
  #endif
11637
- return static_cast<Integer*>(value);
12168
+ return static_cast<Number*>(data);
11638
12169
  }
11639
12170
 
12171
+ Integer* Integer::Cast(v8::Data* data) {
12172
+ #ifdef V8_ENABLE_CHECKS
12173
+ CheckCast(data);
12174
+ #endif
12175
+ return static_cast<Integer*>(data);
12176
+ }
11640
12177
 
11641
- Int32* Int32::Cast(v8::Value* value) {
12178
+ Int32* Int32::Cast(v8::Data* data) {
11642
12179
  #ifdef V8_ENABLE_CHECKS
11643
- CheckCast(value);
12180
+ CheckCast(data);
11644
12181
  #endif
11645
- return static_cast<Int32*>(value);
12182
+ return static_cast<Int32*>(data);
11646
12183
  }
11647
12184
 
12185
+ Uint32* Uint32::Cast(v8::Data* data) {
12186
+ #ifdef V8_ENABLE_CHECKS
12187
+ CheckCast(data);
12188
+ #endif
12189
+ return static_cast<Uint32*>(data);
12190
+ }
11648
12191
 
11649
- Uint32* Uint32::Cast(v8::Value* value) {
12192
+ BigInt* BigInt::Cast(v8::Data* data) {
11650
12193
  #ifdef V8_ENABLE_CHECKS
11651
- CheckCast(value);
12194
+ CheckCast(data);
11652
12195
  #endif
11653
- return static_cast<Uint32*>(value);
12196
+ return static_cast<BigInt*>(data);
11654
12197
  }
11655
12198
 
11656
- BigInt* BigInt::Cast(v8::Value* value) {
12199
+ Context* Context::Cast(v8::Data* data) {
11657
12200
  #ifdef V8_ENABLE_CHECKS
11658
- CheckCast(value);
12201
+ CheckCast(data);
11659
12202
  #endif
11660
- return static_cast<BigInt*>(value);
12203
+ return static_cast<Context*>(data);
11661
12204
  }
11662
12205
 
11663
12206
  Date* Date::Cast(v8::Value* value) {
@@ -11761,6 +12304,13 @@ Proxy* Proxy::Cast(v8::Value* value) {
11761
12304
  return static_cast<Proxy*>(value);
11762
12305
  }
11763
12306
 
12307
+ WasmMemoryObject* WasmMemoryObject::Cast(v8::Value* value) {
12308
+ #ifdef V8_ENABLE_CHECKS
12309
+ CheckCast(value);
12310
+ #endif
12311
+ return static_cast<WasmMemoryObject*>(value);
12312
+ }
12313
+
11764
12314
  WasmModuleObject* WasmModuleObject::Cast(v8::Value* value) {
11765
12315
  #ifdef V8_ENABLE_CHECKS
11766
12316
  CheckCast(value);
@@ -11948,7 +12498,7 @@ ReturnValue<T> PropertyCallbackInfo<T>::GetReturnValue() const {
11948
12498
 
11949
12499
  template <typename T>
11950
12500
  bool PropertyCallbackInfo<T>::ShouldThrowOnError() const {
11951
- typedef internal::Internals I;
12501
+ using I = internal::Internals;
11952
12502
  if (args_[kShouldThrowOnErrorIndex] !=
11953
12503
  I::IntToSmi(I::kInferShouldThrowMode)) {
11954
12504
  return args_[kShouldThrowOnErrorIndex] != I::IntToSmi(I::kDontThrow);
@@ -11958,8 +12508,8 @@ bool PropertyCallbackInfo<T>::ShouldThrowOnError() const {
11958
12508
  }
11959
12509
 
11960
12510
  Local<Primitive> Undefined(Isolate* isolate) {
11961
- typedef internal::Address S;
11962
- typedef internal::Internals I;
12511
+ using S = internal::Address;
12512
+ using I = internal::Internals;
11963
12513
  I::CheckInitialized(isolate);
11964
12514
  S* slot = I::GetRoot(isolate, I::kUndefinedValueRootIndex);
11965
12515
  return Local<Primitive>(reinterpret_cast<Primitive*>(slot));
@@ -11967,8 +12517,8 @@ Local<Primitive> Undefined(Isolate* isolate) {
11967
12517
 
11968
12518
 
11969
12519
  Local<Primitive> Null(Isolate* isolate) {
11970
- typedef internal::Address S;
11971
- typedef internal::Internals I;
12520
+ using S = internal::Address;
12521
+ using I = internal::Internals;
11972
12522
  I::CheckInitialized(isolate);
11973
12523
  S* slot = I::GetRoot(isolate, I::kNullValueRootIndex);
11974
12524
  return Local<Primitive>(reinterpret_cast<Primitive*>(slot));
@@ -11976,8 +12526,8 @@ Local<Primitive> Null(Isolate* isolate) {
11976
12526
 
11977
12527
 
11978
12528
  Local<Boolean> True(Isolate* isolate) {
11979
- typedef internal::Address S;
11980
- typedef internal::Internals I;
12529
+ using S = internal::Address;
12530
+ using I = internal::Internals;
11981
12531
  I::CheckInitialized(isolate);
11982
12532
  S* slot = I::GetRoot(isolate, I::kTrueValueRootIndex);
11983
12533
  return Local<Boolean>(reinterpret_cast<Boolean*>(slot));
@@ -11985,8 +12535,8 @@ Local<Boolean> True(Isolate* isolate) {
11985
12535
 
11986
12536
 
11987
12537
  Local<Boolean> False(Isolate* isolate) {
11988
- typedef internal::Address S;
11989
- typedef internal::Internals I;
12538
+ using S = internal::Address;
12539
+ using I = internal::Internals;
11990
12540
  I::CheckInitialized(isolate);
11991
12541
  S* slot = I::GetRoot(isolate, I::kFalseValueRootIndex);
11992
12542
  return Local<Boolean>(reinterpret_cast<Boolean*>(slot));
@@ -11994,19 +12544,19 @@ Local<Boolean> False(Isolate* isolate) {
11994
12544
 
11995
12545
 
11996
12546
  void Isolate::SetData(uint32_t slot, void* data) {
11997
- typedef internal::Internals I;
12547
+ using I = internal::Internals;
11998
12548
  I::SetEmbedderData(this, slot, data);
11999
12549
  }
12000
12550
 
12001
12551
 
12002
12552
  void* Isolate::GetData(uint32_t slot) {
12003
- typedef internal::Internals I;
12553
+ using I = internal::Internals;
12004
12554
  return I::GetEmbedderData(this, slot);
12005
12555
  }
12006
12556
 
12007
12557
 
12008
12558
  uint32_t Isolate::GetNumberOfDataSlots() {
12009
- typedef internal::Internals I;
12559
+ using I = internal::Internals;
12010
12560
  return I::kNumIsolateDataSlots;
12011
12561
  }
12012
12562
 
@@ -12019,8 +12569,8 @@ MaybeLocal<T> Isolate::GetDataFromSnapshotOnce(size_t index) {
12019
12569
 
12020
12570
  Local<Value> Context::GetEmbedderData(int index) {
12021
12571
  #ifndef V8_ENABLE_CHECKS
12022
- typedef internal::Address A;
12023
- typedef internal::Internals I;
12572
+ using A = internal::Address;
12573
+ using I = internal::Internals;
12024
12574
  A ctx = *reinterpret_cast<const A*>(this);
12025
12575
  A embedder_data =
12026
12576
  I::ReadTaggedPointerField(ctx, I::kNativeContextEmbedderDataOffset);
@@ -12045,16 +12595,20 @@ Local<Value> Context::GetEmbedderData(int index) {
12045
12595
 
12046
12596
  void* Context::GetAlignedPointerFromEmbedderData(int index) {
12047
12597
  #ifndef V8_ENABLE_CHECKS
12048
- typedef internal::Address A;
12049
- typedef internal::Internals I;
12598
+ using A = internal::Address;
12599
+ using I = internal::Internals;
12050
12600
  A ctx = *reinterpret_cast<const A*>(this);
12051
12601
  A embedder_data =
12052
12602
  I::ReadTaggedPointerField(ctx, I::kNativeContextEmbedderDataOffset);
12053
12603
  int value_offset =
12054
12604
  I::kEmbedderDataArrayHeaderSize + (I::kEmbedderDataSlotSize * index);
12605
+ #ifdef V8_HEAP_SANDBOX
12606
+ value_offset += I::kEmbedderDataSlotRawPayloadOffset;
12607
+ #endif
12055
12608
  internal::Isolate* isolate = I::GetIsolateForHeapSandbox(ctx);
12056
12609
  return reinterpret_cast<void*>(
12057
- I::ReadExternalPointerField(isolate, embedder_data, value_offset));
12610
+ I::ReadExternalPointerField(isolate, embedder_data, value_offset,
12611
+ internal::kEmbedderDataSlotPayloadTag));
12058
12612
  #else
12059
12613
  return SlowGetAlignedPointerFromEmbedderData(index);
12060
12614
  #endif