libv8-node 15.14.0.1-aarch64-linux → 16.10.0.0-aarch64-linux
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ext/libv8-node/location.rb +1 -1
- data/ext/libv8-node/paths.rb +1 -1
- data/lib/libv8/node/version.rb +3 -3
- data/vendor/v8/{out.gn → aarch64-linux}/libv8/obj/libv8_monolith.a +0 -0
- data/vendor/v8/include/cppgc/allocation.h +104 -45
- data/vendor/v8/include/cppgc/common.h +9 -6
- data/vendor/v8/include/cppgc/cross-thread-persistent.h +384 -0
- data/vendor/v8/include/cppgc/custom-space.h +37 -2
- data/vendor/v8/include/cppgc/default-platform.h +47 -48
- data/vendor/v8/include/cppgc/ephemeron-pair.h +30 -0
- data/vendor/v8/include/cppgc/explicit-management.h +82 -0
- data/vendor/v8/include/cppgc/garbage-collected.h +4 -3
- data/vendor/v8/include/cppgc/heap-consistency.h +236 -0
- data/vendor/v8/include/cppgc/heap-state.h +70 -0
- data/vendor/v8/include/cppgc/heap-statistics.h +120 -0
- data/vendor/v8/include/cppgc/heap.h +68 -6
- data/vendor/v8/include/cppgc/internal/api-constants.h +3 -3
- data/vendor/v8/include/cppgc/internal/caged-heap-local-data.h +2 -1
- data/vendor/v8/include/cppgc/internal/compiler-specific.h +2 -2
- data/vendor/v8/include/cppgc/internal/gc-info.h +44 -13
- data/vendor/v8/include/cppgc/internal/name-trait.h +111 -0
- data/vendor/v8/include/cppgc/internal/persistent-node.h +57 -1
- data/vendor/v8/include/cppgc/internal/pointer-policies.h +69 -28
- data/vendor/v8/include/cppgc/internal/prefinalizer-handler.h +1 -1
- data/vendor/v8/include/cppgc/internal/write-barrier.h +353 -35
- data/vendor/v8/include/cppgc/liveness-broker.h +7 -1
- data/vendor/v8/include/cppgc/macros.h +2 -0
- data/vendor/v8/include/cppgc/member.h +85 -25
- data/vendor/v8/include/cppgc/name-provider.h +65 -0
- data/vendor/v8/include/cppgc/object-size-trait.h +58 -0
- data/vendor/v8/include/cppgc/persistent.h +33 -9
- data/vendor/v8/include/cppgc/platform.h +48 -25
- data/vendor/v8/include/cppgc/prefinalizer.h +1 -1
- data/vendor/v8/include/cppgc/process-heap-statistics.h +36 -0
- data/vendor/v8/include/cppgc/sentinel-pointer.h +32 -0
- data/vendor/v8/include/cppgc/source-location.h +2 -1
- data/vendor/v8/include/cppgc/testing.h +99 -0
- data/vendor/v8/include/cppgc/trace-trait.h +8 -3
- data/vendor/v8/include/cppgc/type-traits.h +157 -19
- data/vendor/v8/include/cppgc/visitor.h +187 -23
- data/vendor/v8/include/libplatform/libplatform.h +11 -0
- data/vendor/v8/include/libplatform/v8-tracing.h +2 -0
- data/vendor/v8/include/v8-cppgc.h +258 -159
- data/vendor/v8/include/v8-fast-api-calls.h +562 -159
- data/vendor/v8/include/v8-inspector.h +23 -2
- data/vendor/v8/include/v8-internal.h +99 -27
- data/vendor/v8/include/v8-metrics.h +77 -8
- data/vendor/v8/include/v8-platform.h +47 -22
- data/vendor/v8/include/v8-profiler.h +75 -11
- data/vendor/v8/include/v8-unwinder-state.h +30 -0
- data/vendor/v8/include/v8-util.h +1 -1
- data/vendor/v8/include/v8-version.h +4 -4
- data/vendor/v8/include/v8.h +1192 -642
- data/vendor/v8/include/v8config.h +40 -9
- metadata +17 -5
- data/vendor/v8/include/cppgc/internal/process-heap.h +0 -34
data/vendor/v8/include/v8.h
CHANGED
@@ -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
|
-
|
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
|
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
|
92
|
-
|
93
|
-
class
|
94
|
-
|
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
|
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
|
115
|
-
class
|
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
|
-
|
127
|
-
|
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
|
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
|
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
|
-
|
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;
|
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
|
-
|
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
|
-
|
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) {
|
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) {
|
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 {
|
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); }
|
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
|
-
|
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
|
847
|
-
*
|
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<
|
849
|
+
* Construct a Local<Value> from this handle.
|
859
850
|
*/
|
860
|
-
Local<
|
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
|
-
|
886
|
-
|
887
|
-
|
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(
|
912
|
-
reinterpret_cast<std::atomic<
|
913
|
-
|
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
|
920
|
-
return reinterpret_cast<std::atomic<const
|
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
|
949
|
+
* An empty BasicTracedReference without storage cell.
|
929
950
|
*/
|
930
|
-
|
951
|
+
BasicTracedReference() = default;
|
931
952
|
|
932
|
-
V8_INLINE static
|
933
|
-
|
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
|
-
*
|
972
|
+
* BasicTracedReference.
|
952
973
|
*/
|
953
974
|
template <typename T>
|
954
|
-
class TracedGlobal : public
|
975
|
+
class TracedGlobal : public BasicTracedReference<T> {
|
955
976
|
public:
|
956
|
-
using
|
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() :
|
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) :
|
996
|
+
TracedGlobal(Isolate* isolate, Local<S> that) : BasicTracedReference<T>() {
|
976
997
|
this->val_ = this->New(isolate, that.val_, &this->val_,
|
977
|
-
|
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
|
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
|
1103
|
+
class TracedReference : public BasicTracedReference<T> {
|
1083
1104
|
public:
|
1084
|
-
using
|
1105
|
+
using BasicTracedReference<T>::Reset;
|
1085
1106
|
|
1086
1107
|
/**
|
1087
1108
|
* An empty TracedReference without storage cell.
|
1088
1109
|
*/
|
1089
|
-
TracedReference() :
|
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) :
|
1119
|
+
TracedReference(Isolate* isolate, Local<S> that) : BasicTracedReference<T>() {
|
1099
1120
|
this->val_ = this->New(isolate, that.val_, &this->val_,
|
1100
|
-
|
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
|
-
|
1402
|
-
|
1403
|
-
|
1404
|
-
|
1443
|
+
#if defined(_MSC_VER) && _MSC_VER >= 1910 /* Disable on VS2015 */
|
1444
|
+
V8_DEPRECATE_SOON("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_DEPRECATE_SOON("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_DEPRECATE_SOON("Use getter with primitvie C++ types.")
|
1414
1478
|
V8_INLINE Local<Integer> ResourceLineOffset() const;
|
1479
|
+
V8_DEPRECATE_SOON("Use getter with primitvie C++ types.")
|
1415
1480
|
V8_INLINE Local<Integer> ResourceColumnOffset() const;
|
1481
|
+
V8_DEPRECATE_SOON("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
|
-
|
1424
|
-
|
1493
|
+
int resource_line_offset_;
|
1494
|
+
int resource_column_offset_;
|
1425
1495
|
ScriptOriginOptions options_;
|
1426
|
-
|
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_DEPRECATE_SOON("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_DEPRECATE_SOON(
|
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_DEPRECATE_SOON(
|
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
|
-
|
1539
|
-
|
1540
|
-
|
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_DEPRECATE_SOON(
|
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
|
1556
|
-
*
|
1557
|
-
*
|
1558
|
-
*
|
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
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
1735
|
-
|
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
|
-
|
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::
|
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()
|
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::
|
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::
|
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(
|
3169
|
+
V8_INLINE static Name* Cast(Data* data);
|
2976
3170
|
|
2977
3171
|
private:
|
2978
|
-
static void CheckCast(
|
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 {
|
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
|
-
|
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::
|
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::
|
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
|
-
|
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(
|
3692
|
+
V8_INLINE static Symbol* Cast(Data* data);
|
3444
3693
|
|
3445
3694
|
private:
|
3446
3695
|
Symbol();
|
3447
|
-
static void CheckCast(
|
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::
|
3745
|
+
V8_INLINE static Number* Cast(v8::Data* data);
|
3746
|
+
|
3497
3747
|
private:
|
3498
3748
|
Number();
|
3499
|
-
static void CheckCast(v8::
|
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::
|
3761
|
+
V8_INLINE static Integer* Cast(v8::Data* data);
|
3762
|
+
|
3512
3763
|
private:
|
3513
3764
|
Integer();
|
3514
|
-
static void CheckCast(v8::
|
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::
|
3775
|
+
V8_INLINE static Int32* Cast(v8::Data* data);
|
3525
3776
|
|
3526
3777
|
private:
|
3527
3778
|
Int32();
|
3528
|
-
static void CheckCast(v8::
|
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::
|
3789
|
+
V8_INLINE static Uint32* Cast(v8::Data* data);
|
3539
3790
|
|
3540
3791
|
private:
|
3541
3792
|
Uint32();
|
3542
|
-
static void CheckCast(v8::
|
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::
|
3844
|
+
V8_INLINE static BigInt* Cast(v8::Data* data);
|
3594
3845
|
|
3595
3846
|
private:
|
3596
3847
|
BigInt();
|
3597
|
-
static void CheckCast(v8::
|
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
|
-
|
3620
|
-
Local<String> property,
|
3621
|
-
|
3622
|
-
|
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
|
4188
|
+
/** Same as above, but works for BasicTracedReference. */
|
3945
4189
|
V8_INLINE static int InternalFieldCount(
|
3946
|
-
const
|
3947
|
-
return object
|
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
|
3972
|
-
return object
|
4215
|
+
const BasicTracedReference<Object>& object, int index) {
|
4216
|
+
return object->GetAlignedPointerFromInternalField(index);
|
3973
4217
|
}
|
3974
4218
|
|
3975
4219
|
/**
|
@@ -4067,12 +4311,18 @@ class V8_EXPORT Object : public Value {
|
|
4067
4311
|
/**
|
4068
4312
|
* Returns the context in which the object was created.
|
4069
4313
|
*/
|
4314
|
+
V8_DEPRECATE_SOON("Use MaybeLocal<Context> GetCreationContext()")
|
4070
4315
|
Local<Context> CreationContext();
|
4316
|
+
MaybeLocal<Context> GetCreationContext();
|
4071
4317
|
|
4072
4318
|
/** Same as above, but works for Persistents */
|
4073
|
-
|
4319
|
+
V8_DEPRECATE_SOON(
|
4320
|
+
"Use MaybeLocal<Context> GetCreationContext(const "
|
4321
|
+
"PersistentBase<Object>& object)")
|
4322
|
+
static Local<Context> CreationContext(const PersistentBase<Object>& object);
|
4323
|
+
V8_INLINE static MaybeLocal<Context> GetCreationContext(
|
4074
4324
|
const PersistentBase<Object>& object) {
|
4075
|
-
return object.val_->
|
4325
|
+
return object.val_->GetCreationContext();
|
4076
4326
|
}
|
4077
4327
|
|
4078
4328
|
/**
|
@@ -4152,6 +4402,16 @@ class V8_EXPORT Object : public Value {
|
|
4152
4402
|
|
4153
4403
|
V8_INLINE static Object* Cast(Value* obj);
|
4154
4404
|
|
4405
|
+
/**
|
4406
|
+
* Support for TC39 "dynamic code brand checks" proposal.
|
4407
|
+
*
|
4408
|
+
* This API allows to query whether an object was constructed from a
|
4409
|
+
* "code like" ObjectTemplate.
|
4410
|
+
*
|
4411
|
+
* See also: v8::ObjectTemplate::SetCodeLike
|
4412
|
+
*/
|
4413
|
+
bool IsCodeLike(Isolate* isolate);
|
4414
|
+
|
4155
4415
|
private:
|
4156
4416
|
Object();
|
4157
4417
|
static void CheckCast(Value* obj);
|
@@ -4180,6 +4440,7 @@ class V8_EXPORT Array : public Object {
|
|
4180
4440
|
static Local<Array> New(Isolate* isolate, Local<Value>* elements,
|
4181
4441
|
size_t length);
|
4182
4442
|
V8_INLINE static Array* Cast(Value* obj);
|
4443
|
+
|
4183
4444
|
private:
|
4184
4445
|
Array();
|
4185
4446
|
static void CheckCast(Value* obj);
|
@@ -4265,7 +4526,7 @@ class ReturnValue {
|
|
4265
4526
|
template <typename S>
|
4266
4527
|
V8_INLINE void Set(const Global<S>& handle);
|
4267
4528
|
template <typename S>
|
4268
|
-
V8_INLINE void Set(const
|
4529
|
+
V8_INLINE void Set(const BasicTracedReference<S>& handle);
|
4269
4530
|
template <typename S>
|
4270
4531
|
V8_INLINE void Set(const Local<S> handle);
|
4271
4532
|
// Fast primitive setters
|
@@ -4474,8 +4735,7 @@ class PropertyCallbackInfo {
|
|
4474
4735
|
internal::Address* args_;
|
4475
4736
|
};
|
4476
4737
|
|
4477
|
-
|
4478
|
-
typedef void (*FunctionCallback)(const FunctionCallbackInfo<Value>& info);
|
4738
|
+
using FunctionCallback = void (*)(const FunctionCallbackInfo<Value>& info);
|
4479
4739
|
|
4480
4740
|
enum class ConstructorBehavior { kThrow, kAllow };
|
4481
4741
|
|
@@ -4536,6 +4796,11 @@ class V8_EXPORT Function : public Object {
|
|
4536
4796
|
* User-defined name assigned to the "displayName" property of this function.
|
4537
4797
|
* Used to facilitate debugging and profiling of JavaScript code.
|
4538
4798
|
*/
|
4799
|
+
V8_DEPRECATED(
|
4800
|
+
"Use v8::Object::Get() instead to look up \"displayName\". "
|
4801
|
+
"V8 and DevTools no longer use \"displayName\" in stack "
|
4802
|
+
"traces, but the standard \"name\" property. "
|
4803
|
+
"See http://crbug.com/1177685.")
|
4539
4804
|
Local<Value> GetDisplayName() const;
|
4540
4805
|
|
4541
4806
|
/**
|
@@ -4560,6 +4825,15 @@ class V8_EXPORT Function : public Object {
|
|
4560
4825
|
*/
|
4561
4826
|
Local<Value> GetBoundFunction() const;
|
4562
4827
|
|
4828
|
+
/**
|
4829
|
+
* Calls builtin Function.prototype.toString on this function.
|
4830
|
+
* This is different from Value::ToString() that may call a user-defined
|
4831
|
+
* toString() function, and different than Object::ObjectProtoToString() which
|
4832
|
+
* always serializes "[object Function]".
|
4833
|
+
*/
|
4834
|
+
V8_WARN_UNUSED_RESULT MaybeLocal<String> FunctionProtoToString(
|
4835
|
+
Local<Context> context);
|
4836
|
+
|
4563
4837
|
ScriptOrigin GetScriptOrigin() const;
|
4564
4838
|
V8_INLINE static Function* Cast(Value* obj);
|
4565
4839
|
static const int kLineOffsetNotFound;
|
@@ -4653,6 +4927,12 @@ class V8_EXPORT Promise : public Object {
|
|
4653
4927
|
*/
|
4654
4928
|
void MarkAsHandled();
|
4655
4929
|
|
4930
|
+
/**
|
4931
|
+
* Marks this promise as silent to prevent pausing the debugger when the
|
4932
|
+
* promise is rejected.
|
4933
|
+
*/
|
4934
|
+
void MarkAsSilent();
|
4935
|
+
|
4656
4936
|
V8_INLINE static Promise* Cast(Value* obj);
|
4657
4937
|
|
4658
4938
|
static const int kEmbedderFieldCount = V8_PROMISE_INTERNAL_FIELD_COUNT;
|
@@ -4827,6 +5107,22 @@ class V8_EXPORT CompiledWasmModule {
|
|
4827
5107
|
const std::string source_url_;
|
4828
5108
|
};
|
4829
5109
|
|
5110
|
+
// An instance of WebAssembly.Memory.
|
5111
|
+
class V8_EXPORT WasmMemoryObject : public Object {
|
5112
|
+
public:
|
5113
|
+
WasmMemoryObject() = delete;
|
5114
|
+
|
5115
|
+
/**
|
5116
|
+
* Returns underlying ArrayBuffer.
|
5117
|
+
*/
|
5118
|
+
Local<ArrayBuffer> Buffer();
|
5119
|
+
|
5120
|
+
V8_INLINE static WasmMemoryObject* Cast(Value* obj);
|
5121
|
+
|
5122
|
+
private:
|
5123
|
+
static void CheckCast(Value* object);
|
5124
|
+
};
|
5125
|
+
|
4830
5126
|
// An instance of WebAssembly.Module.
|
4831
5127
|
class V8_EXPORT WasmModuleObject : public Object {
|
4832
5128
|
public:
|
@@ -5090,7 +5386,7 @@ class V8_EXPORT ArrayBuffer : public Object {
|
|
5090
5386
|
* Note that it is unsafe to call back into V8 from any of the allocator
|
5091
5387
|
* functions.
|
5092
5388
|
*/
|
5093
|
-
class V8_EXPORT Allocator {
|
5389
|
+
class V8_EXPORT Allocator {
|
5094
5390
|
public:
|
5095
5391
|
virtual ~Allocator() = default;
|
5096
5392
|
|
@@ -5215,7 +5511,7 @@ class V8_EXPORT ArrayBuffer : public Object {
|
|
5215
5511
|
* |Allocator::Free| once all ArrayBuffers referencing it are collected by
|
5216
5512
|
* the garbage collector.
|
5217
5513
|
*/
|
5218
|
-
|
5514
|
+
V8_DEPRECATED(
|
5219
5515
|
"Use the version that takes a BackingStore. "
|
5220
5516
|
"See http://crbug.com/v8/9908.")
|
5221
5517
|
static Local<ArrayBuffer> New(
|
@@ -5264,7 +5560,7 @@ class V8_EXPORT ArrayBuffer : public Object {
|
|
5264
5560
|
* Returns true if ArrayBuffer is externalized, that is, does not
|
5265
5561
|
* own its memory block.
|
5266
5562
|
*/
|
5267
|
-
|
5563
|
+
V8_DEPRECATED(
|
5268
5564
|
"With v8::BackingStore externalized ArrayBuffers are "
|
5269
5565
|
"the same as ordinary ArrayBuffers. See http://crbug.com/v8/9908.")
|
5270
5566
|
bool IsExternal() const;
|
@@ -5292,8 +5588,7 @@ class V8_EXPORT ArrayBuffer : public Object {
|
|
5292
5588
|
* deleter, which will call ArrayBuffer::Allocator::Free if the buffer
|
5293
5589
|
* was allocated with ArrayBuffer::Allocator::Allocate.
|
5294
5590
|
*/
|
5295
|
-
|
5296
|
-
"Use GetBackingStore or Detach. See http://crbug.com/v8/9908.")
|
5591
|
+
V8_DEPRECATED("Use GetBackingStore or Detach. See http://crbug.com/v8/9908.")
|
5297
5592
|
Contents Externalize();
|
5298
5593
|
|
5299
5594
|
/**
|
@@ -5303,7 +5598,7 @@ class V8_EXPORT ArrayBuffer : public Object {
|
|
5303
5598
|
* With the new lifetime management of backing stores there is no need for
|
5304
5599
|
* externalizing, so this function exists only to make the transition easier.
|
5305
5600
|
*/
|
5306
|
-
|
5601
|
+
V8_DEPRECATED("This will be removed together with IsExternal.")
|
5307
5602
|
void Externalize(const std::shared_ptr<BackingStore>& backing_store);
|
5308
5603
|
|
5309
5604
|
/**
|
@@ -5314,7 +5609,7 @@ class V8_EXPORT ArrayBuffer : public Object {
|
|
5314
5609
|
* The embedder should make sure to hold a strong reference to the
|
5315
5610
|
* ArrayBuffer while accessing this pointer.
|
5316
5611
|
*/
|
5317
|
-
|
5612
|
+
V8_DEPRECATED("Use GetBackingStore. See http://crbug.com/v8/9908.")
|
5318
5613
|
Contents GetContents();
|
5319
5614
|
|
5320
5615
|
/**
|
@@ -5698,7 +5993,7 @@ class V8_EXPORT SharedArrayBuffer : public Object {
|
|
5698
5993
|
* specified. The memory block will not be reclaimed when a created
|
5699
5994
|
* SharedArrayBuffer is garbage-collected.
|
5700
5995
|
*/
|
5701
|
-
|
5996
|
+
V8_DEPRECATED(
|
5702
5997
|
"Use the version that takes a BackingStore. "
|
5703
5998
|
"See http://crbug.com/v8/9908.")
|
5704
5999
|
static Local<SharedArrayBuffer> New(
|
@@ -5758,7 +6053,7 @@ class V8_EXPORT SharedArrayBuffer : public Object {
|
|
5758
6053
|
* Returns true if SharedArrayBuffer is externalized, that is, does not
|
5759
6054
|
* own its memory block.
|
5760
6055
|
*/
|
5761
|
-
|
6056
|
+
V8_DEPRECATED(
|
5762
6057
|
"With v8::BackingStore externalized SharedArrayBuffers are the same "
|
5763
6058
|
"as ordinary SharedArrayBuffers. See http://crbug.com/v8/9908.")
|
5764
6059
|
bool IsExternal() const;
|
@@ -5775,8 +6070,7 @@ class V8_EXPORT SharedArrayBuffer : public Object {
|
|
5775
6070
|
* v8::Isolate::CreateParams::array_buffer_allocator.
|
5776
6071
|
*
|
5777
6072
|
*/
|
5778
|
-
|
5779
|
-
"Use GetBackingStore or Detach. See http://crbug.com/v8/9908.")
|
6073
|
+
V8_DEPRECATED("Use GetBackingStore or Detach. See http://crbug.com/v8/9908.")
|
5780
6074
|
Contents Externalize();
|
5781
6075
|
|
5782
6076
|
/**
|
@@ -5786,7 +6080,7 @@ class V8_EXPORT SharedArrayBuffer : public Object {
|
|
5786
6080
|
* With the new lifetime management of backing stores there is no need for
|
5787
6081
|
* externalizing, so this function exists only to make the transition easier.
|
5788
6082
|
*/
|
5789
|
-
|
6083
|
+
V8_DEPRECATED("This will be removed together with IsExternal.")
|
5790
6084
|
void Externalize(const std::shared_ptr<BackingStore>& backing_store);
|
5791
6085
|
|
5792
6086
|
/**
|
@@ -5801,7 +6095,7 @@ class V8_EXPORT SharedArrayBuffer : public Object {
|
|
5801
6095
|
* by the allocator specified in
|
5802
6096
|
* v8::Isolate::CreateParams::array_buffer_allocator.
|
5803
6097
|
*/
|
5804
|
-
|
6098
|
+
V8_DEPRECATED("Use GetBackingStore. See http://crbug.com/v8/9908.")
|
5805
6099
|
Contents GetContents();
|
5806
6100
|
|
5807
6101
|
/**
|
@@ -5932,6 +6226,10 @@ class V8_EXPORT RegExp : public Object {
|
|
5932
6226
|
/**
|
5933
6227
|
* Regular expression flag bits. They can be or'ed to enable a set
|
5934
6228
|
* of flags.
|
6229
|
+
* The kLinear value ('l') is experimental and can only be used with
|
6230
|
+
* --enable-experimental-regexp-engine. RegExps with kLinear flag are
|
6231
|
+
* guaranteed to be executed in asymptotic linear time wrt. the length of
|
6232
|
+
* the subject string.
|
5935
6233
|
*/
|
5936
6234
|
enum Flags {
|
5937
6235
|
kNone = 0,
|
@@ -5941,9 +6239,11 @@ class V8_EXPORT RegExp : public Object {
|
|
5941
6239
|
kSticky = 1 << 3,
|
5942
6240
|
kUnicode = 1 << 4,
|
5943
6241
|
kDotAll = 1 << 5,
|
6242
|
+
kLinear = 1 << 6,
|
6243
|
+
kHasIndices = 1 << 7,
|
5944
6244
|
};
|
5945
6245
|
|
5946
|
-
static constexpr int kFlagCount =
|
6246
|
+
static constexpr int kFlagCount = 8;
|
5947
6247
|
|
5948
6248
|
/**
|
5949
6249
|
* Creates a regular expression from the given pattern string and
|
@@ -6085,7 +6385,6 @@ class V8_EXPORT Template : public Data {
|
|
6085
6385
|
void SetNativeDataProperty(
|
6086
6386
|
Local<String> name, AccessorGetterCallback getter,
|
6087
6387
|
AccessorSetterCallback setter = nullptr,
|
6088
|
-
// TODO(dcarney): gcc can't handle Local below
|
6089
6388
|
Local<Value> data = Local<Value>(), PropertyAttribute attribute = None,
|
6090
6389
|
Local<AccessorSignature> signature = Local<AccessorSignature>(),
|
6091
6390
|
AccessControl settings = DEFAULT,
|
@@ -6094,7 +6393,6 @@ class V8_EXPORT Template : public Data {
|
|
6094
6393
|
void SetNativeDataProperty(
|
6095
6394
|
Local<Name> name, AccessorNameGetterCallback getter,
|
6096
6395
|
AccessorNameSetterCallback setter = nullptr,
|
6097
|
-
// TODO(dcarney): gcc can't handle Local below
|
6098
6396
|
Local<Value> data = Local<Value>(), PropertyAttribute attribute = None,
|
6099
6397
|
Local<AccessorSignature> signature = Local<AccessorSignature>(),
|
6100
6398
|
AccessControl settings = DEFAULT,
|
@@ -6164,8 +6462,8 @@ class V8_EXPORT Template : public Data {
|
|
6164
6462
|
*
|
6165
6463
|
* See also `ObjectTemplate::SetHandler`.
|
6166
6464
|
*/
|
6167
|
-
|
6168
|
-
Local<Name> property, const PropertyCallbackInfo<Value>& info);
|
6465
|
+
using GenericNamedPropertyGetterCallback =
|
6466
|
+
void (*)(Local<Name> property, const PropertyCallbackInfo<Value>& info);
|
6169
6467
|
|
6170
6468
|
/**
|
6171
6469
|
* Interceptor for set requests on an object.
|
@@ -6188,9 +6486,9 @@ typedef void (*GenericNamedPropertyGetterCallback)(
|
|
6188
6486
|
* See also
|
6189
6487
|
* `ObjectTemplate::SetHandler.`
|
6190
6488
|
*/
|
6191
|
-
|
6192
|
-
Local<Name> property, Local<Value> value,
|
6193
|
-
|
6489
|
+
using GenericNamedPropertySetterCallback =
|
6490
|
+
void (*)(Local<Name> property, Local<Value> value,
|
6491
|
+
const PropertyCallbackInfo<Value>& info);
|
6194
6492
|
|
6195
6493
|
/**
|
6196
6494
|
* Intercepts all requests that query the attributes of the
|
@@ -6213,8 +6511,8 @@ typedef void (*GenericNamedPropertySetterCallback)(
|
|
6213
6511
|
* See also
|
6214
6512
|
* `ObjectTemplate::SetHandler.`
|
6215
6513
|
*/
|
6216
|
-
|
6217
|
-
Local<Name> property, const PropertyCallbackInfo<Integer>& info);
|
6514
|
+
using GenericNamedPropertyQueryCallback =
|
6515
|
+
void (*)(Local<Name> property, const PropertyCallbackInfo<Integer>& info);
|
6218
6516
|
|
6219
6517
|
/**
|
6220
6518
|
* Interceptor for delete requests on an object.
|
@@ -6237,8 +6535,8 @@ typedef void (*GenericNamedPropertyQueryCallback)(
|
|
6237
6535
|
*
|
6238
6536
|
* See also `ObjectTemplate::SetHandler.`
|
6239
6537
|
*/
|
6240
|
-
|
6241
|
-
Local<Name> property, const PropertyCallbackInfo<Boolean>& info);
|
6538
|
+
using GenericNamedPropertyDeleterCallback =
|
6539
|
+
void (*)(Local<Name> property, const PropertyCallbackInfo<Boolean>& info);
|
6242
6540
|
|
6243
6541
|
/**
|
6244
6542
|
* Returns an array containing the names of the properties the named
|
@@ -6246,8 +6544,8 @@ typedef void (*GenericNamedPropertyDeleterCallback)(
|
|
6246
6544
|
*
|
6247
6545
|
* Note: The values in the array must be of type v8::Name.
|
6248
6546
|
*/
|
6249
|
-
|
6250
|
-
const PropertyCallbackInfo<Array>& info);
|
6547
|
+
using GenericNamedPropertyEnumeratorCallback =
|
6548
|
+
void (*)(const PropertyCallbackInfo<Array>& info);
|
6251
6549
|
|
6252
6550
|
/**
|
6253
6551
|
* Interceptor for defineProperty requests on an object.
|
@@ -6269,9 +6567,9 @@ typedef void (*GenericNamedPropertyEnumeratorCallback)(
|
|
6269
6567
|
*
|
6270
6568
|
* See also `ObjectTemplate::SetHandler`.
|
6271
6569
|
*/
|
6272
|
-
|
6273
|
-
Local<Name> property, const PropertyDescriptor& desc,
|
6274
|
-
|
6570
|
+
using GenericNamedPropertyDefinerCallback =
|
6571
|
+
void (*)(Local<Name> property, const PropertyDescriptor& desc,
|
6572
|
+
const PropertyCallbackInfo<Value>& info);
|
6275
6573
|
|
6276
6574
|
/**
|
6277
6575
|
* Interceptor for getOwnPropertyDescriptor requests on an object.
|
@@ -6292,37 +6590,33 @@ typedef void (*GenericNamedPropertyDefinerCallback)(
|
|
6292
6590
|
*
|
6293
6591
|
* See also `ObjectTemplate::SetHandler`.
|
6294
6592
|
*/
|
6295
|
-
|
6296
|
-
Local<Name> property, const PropertyCallbackInfo<Value>& info);
|
6593
|
+
using GenericNamedPropertyDescriptorCallback =
|
6594
|
+
void (*)(Local<Name> property, const PropertyCallbackInfo<Value>& info);
|
6297
6595
|
|
6298
6596
|
/**
|
6299
6597
|
* See `v8::GenericNamedPropertyGetterCallback`.
|
6300
6598
|
*/
|
6301
|
-
|
6302
|
-
uint32_t index,
|
6303
|
-
const PropertyCallbackInfo<Value>& info);
|
6599
|
+
using IndexedPropertyGetterCallback =
|
6600
|
+
void (*)(uint32_t index, const PropertyCallbackInfo<Value>& info);
|
6304
6601
|
|
6305
6602
|
/**
|
6306
6603
|
* See `v8::GenericNamedPropertySetterCallback`.
|
6307
6604
|
*/
|
6308
|
-
|
6309
|
-
uint32_t index,
|
6310
|
-
|
6311
|
-
const PropertyCallbackInfo<Value>& info);
|
6605
|
+
using IndexedPropertySetterCallback =
|
6606
|
+
void (*)(uint32_t index, Local<Value> value,
|
6607
|
+
const PropertyCallbackInfo<Value>& info);
|
6312
6608
|
|
6313
6609
|
/**
|
6314
6610
|
* See `v8::GenericNamedPropertyQueryCallback`.
|
6315
6611
|
*/
|
6316
|
-
|
6317
|
-
uint32_t index,
|
6318
|
-
const PropertyCallbackInfo<Integer>& info);
|
6612
|
+
using IndexedPropertyQueryCallback =
|
6613
|
+
void (*)(uint32_t index, const PropertyCallbackInfo<Integer>& info);
|
6319
6614
|
|
6320
6615
|
/**
|
6321
6616
|
* See `v8::GenericNamedPropertyDeleterCallback`.
|
6322
6617
|
*/
|
6323
|
-
|
6324
|
-
uint32_t index,
|
6325
|
-
const PropertyCallbackInfo<Boolean>& info);
|
6618
|
+
using IndexedPropertyDeleterCallback =
|
6619
|
+
void (*)(uint32_t index, const PropertyCallbackInfo<Boolean>& info);
|
6326
6620
|
|
6327
6621
|
/**
|
6328
6622
|
* Returns an array containing the indices of the properties the indexed
|
@@ -6330,21 +6624,21 @@ typedef void (*IndexedPropertyDeleterCallback)(
|
|
6330
6624
|
*
|
6331
6625
|
* Note: The values in the array must be uint32_t.
|
6332
6626
|
*/
|
6333
|
-
|
6334
|
-
const PropertyCallbackInfo<Array>& info);
|
6627
|
+
using IndexedPropertyEnumeratorCallback =
|
6628
|
+
void (*)(const PropertyCallbackInfo<Array>& info);
|
6335
6629
|
|
6336
6630
|
/**
|
6337
6631
|
* See `v8::GenericNamedPropertyDefinerCallback`.
|
6338
6632
|
*/
|
6339
|
-
|
6340
|
-
uint32_t index, const PropertyDescriptor& desc,
|
6341
|
-
|
6633
|
+
using IndexedPropertyDefinerCallback =
|
6634
|
+
void (*)(uint32_t index, const PropertyDescriptor& desc,
|
6635
|
+
const PropertyCallbackInfo<Value>& info);
|
6342
6636
|
|
6343
6637
|
/**
|
6344
6638
|
* See `v8::GenericNamedPropertyDescriptorCallback`.
|
6345
6639
|
*/
|
6346
|
-
|
6347
|
-
uint32_t index, const PropertyCallbackInfo<Value>& info);
|
6640
|
+
using IndexedPropertyDescriptorCallback =
|
6641
|
+
void (*)(uint32_t index, const PropertyCallbackInfo<Value>& info);
|
6348
6642
|
|
6349
6643
|
/**
|
6350
6644
|
* Access type specification.
|
@@ -6362,9 +6656,9 @@ enum AccessType {
|
|
6362
6656
|
* Returns true if the given context should be allowed to access the given
|
6363
6657
|
* object.
|
6364
6658
|
*/
|
6365
|
-
|
6366
|
-
|
6367
|
-
|
6659
|
+
using AccessCheckCallback = bool (*)(Local<Context> accessing_context,
|
6660
|
+
Local<Object> accessed_object,
|
6661
|
+
Local<Value> data);
|
6368
6662
|
|
6369
6663
|
/**
|
6370
6664
|
* A FunctionTemplate is used to create functions at runtime. There
|
@@ -6484,6 +6778,15 @@ class V8_EXPORT FunctionTemplate : public Template {
|
|
6484
6778
|
SideEffectType side_effect_type = SideEffectType::kHasSideEffect,
|
6485
6779
|
const CFunction* c_function = nullptr);
|
6486
6780
|
|
6781
|
+
/** Creates a function template for multiple overloaded fast API calls.*/
|
6782
|
+
static Local<FunctionTemplate> NewWithCFunctionOverloads(
|
6783
|
+
Isolate* isolate, FunctionCallback callback = nullptr,
|
6784
|
+
Local<Value> data = Local<Value>(),
|
6785
|
+
Local<Signature> signature = Local<Signature>(), int length = 0,
|
6786
|
+
ConstructorBehavior behavior = ConstructorBehavior::kAllow,
|
6787
|
+
SideEffectType side_effect_type = SideEffectType::kHasSideEffect,
|
6788
|
+
const MemorySpan<const CFunction>& c_function_overloads = {});
|
6789
|
+
|
6487
6790
|
/**
|
6488
6791
|
* Creates a function template backed/cached by a private property.
|
6489
6792
|
*/
|
@@ -6517,6 +6820,17 @@ class V8_EXPORT FunctionTemplate : public Template {
|
|
6517
6820
|
SideEffectType side_effect_type = SideEffectType::kHasSideEffect,
|
6518
6821
|
const CFunction* c_function = nullptr);
|
6519
6822
|
|
6823
|
+
/**
|
6824
|
+
* Set the call-handler callback for a FunctionTemplate. This
|
6825
|
+
* callback is called whenever the function created from this
|
6826
|
+
* FunctionTemplate is called. The 'c_function' represents a fast
|
6827
|
+
* API call, see the comment above the class declaration.
|
6828
|
+
*/
|
6829
|
+
void SetCallHandlerV8_92(
|
6830
|
+
FunctionCallback callback, Local<Value> data = Local<Value>(),
|
6831
|
+
SideEffectType side_effect_type = SideEffectType::kHasSideEffect,
|
6832
|
+
const MemorySpan<const CFunction>& c_function_overloads = {});
|
6833
|
+
|
6520
6834
|
/** Set the predefined length property for the FunctionTemplate. */
|
6521
6835
|
void SetLength(int length);
|
6522
6836
|
|
@@ -6576,6 +6890,15 @@ class V8_EXPORT FunctionTemplate : public Template {
|
|
6576
6890
|
*/
|
6577
6891
|
bool HasInstance(Local<Value> object);
|
6578
6892
|
|
6893
|
+
/**
|
6894
|
+
* Returns true if the given value is an API object that was constructed by an
|
6895
|
+
* instance of this function template (without checking for inheriting
|
6896
|
+
* function templates).
|
6897
|
+
*
|
6898
|
+
* This is an experimental feature and may still change significantly.
|
6899
|
+
*/
|
6900
|
+
bool IsLeafTemplateForApiObject(v8::Local<v8::Value> value) const;
|
6901
|
+
|
6579
6902
|
V8_INLINE static FunctionTemplate* Cast(Data* data);
|
6580
6903
|
|
6581
6904
|
private:
|
@@ -6940,6 +7263,18 @@ class V8_EXPORT ObjectTemplate : public Template {
|
|
6940
7263
|
*/
|
6941
7264
|
void SetImmutableProto();
|
6942
7265
|
|
7266
|
+
/**
|
7267
|
+
* Support for TC39 "dynamic code brand checks" proposal.
|
7268
|
+
*
|
7269
|
+
* This API allows to mark (& query) objects as "code like", which causes
|
7270
|
+
* them to be treated like Strings in the context of eval and function
|
7271
|
+
* constructor.
|
7272
|
+
*
|
7273
|
+
* Reference: https://github.com/tc39/proposal-dynamic-code-brand-checks
|
7274
|
+
*/
|
7275
|
+
void SetCodeLike();
|
7276
|
+
bool IsCodeLike();
|
7277
|
+
|
6943
7278
|
V8_INLINE static ObjectTemplate* Cast(Data* data);
|
6944
7279
|
|
6945
7280
|
private:
|
@@ -6997,7 +7332,7 @@ class V8_EXPORT AccessorSignature : public Data {
|
|
6997
7332
|
/**
|
6998
7333
|
* Ignore
|
6999
7334
|
*/
|
7000
|
-
class V8_EXPORT Extension {
|
7335
|
+
class V8_EXPORT Extension {
|
7001
7336
|
public:
|
7002
7337
|
// Note that the strings passed into this constructor must live as long
|
7003
7338
|
// as the Extension itself.
|
@@ -7099,6 +7434,11 @@ class V8_EXPORT ResourceConstraints {
|
|
7099
7434
|
/**
|
7100
7435
|
* The amount of virtual memory reserved for generated code. This is relevant
|
7101
7436
|
* for 64-bit architectures that rely on code range for calls in code.
|
7437
|
+
*
|
7438
|
+
* When V8_COMPRESS_POINTERS_IN_SHARED_CAGE is defined, there is a shared
|
7439
|
+
* process-wide code range that is lazily initialized. This value is used to
|
7440
|
+
* configure that shared code range when the first Isolate is
|
7441
|
+
* created. Subsequent Isolates ignore this value.
|
7102
7442
|
*/
|
7103
7443
|
size_t code_range_size_in_bytes() const { return code_range_size_; }
|
7104
7444
|
void set_code_range_size_in_bytes(size_t limit) { code_range_size_ = limit; }
|
@@ -7143,36 +7483,11 @@ class V8_EXPORT ResourceConstraints {
|
|
7143
7483
|
initial_young_generation_size_ = initial_size;
|
7144
7484
|
}
|
7145
7485
|
|
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
7486
|
private:
|
7171
7487
|
static constexpr size_t kMB = 1048576u;
|
7172
7488
|
size_t code_range_size_ = 0;
|
7173
7489
|
size_t max_old_generation_size_ = 0;
|
7174
7490
|
size_t max_young_generation_size_ = 0;
|
7175
|
-
size_t max_zone_pool_size_ = 0;
|
7176
7491
|
size_t initial_old_generation_size_ = 0;
|
7177
7492
|
size_t initial_young_generation_size_ = 0;
|
7178
7493
|
uint32_t* stack_limit_ = nullptr;
|
@@ -7181,19 +7496,18 @@ class V8_EXPORT ResourceConstraints {
|
|
7181
7496
|
|
7182
7497
|
// --- Exceptions ---
|
7183
7498
|
|
7499
|
+
using FatalErrorCallback = void (*)(const char* location, const char* message);
|
7184
7500
|
|
7185
|
-
|
7186
|
-
|
7187
|
-
typedef void (*OOMErrorCallback)(const char* location, bool is_heap_oom);
|
7501
|
+
using OOMErrorCallback = void (*)(const char* location, bool is_heap_oom);
|
7188
7502
|
|
7189
|
-
|
7190
|
-
|
7503
|
+
using DcheckErrorCallback = void (*)(const char* file, int line,
|
7504
|
+
const char* message);
|
7191
7505
|
|
7192
|
-
|
7506
|
+
using MessageCallback = void (*)(Local<Message> message, Local<Value> data);
|
7193
7507
|
|
7194
7508
|
// --- Tracing ---
|
7195
7509
|
|
7196
|
-
|
7510
|
+
using LogEventCallback = void (*)(const char* name, int event);
|
7197
7511
|
|
7198
7512
|
/**
|
7199
7513
|
* Create new error objects by calling the corresponding error object
|
@@ -7227,14 +7541,12 @@ class V8_EXPORT Exception {
|
|
7227
7541
|
|
7228
7542
|
// --- Counters Callbacks ---
|
7229
7543
|
|
7230
|
-
|
7544
|
+
using CounterLookupCallback = int* (*)(const char* name);
|
7231
7545
|
|
7232
|
-
|
7233
|
-
|
7234
|
-
int max,
|
7235
|
-
size_t buckets);
|
7546
|
+
using CreateHistogramCallback = void* (*)(const char* name, int min, int max,
|
7547
|
+
size_t buckets);
|
7236
7548
|
|
7237
|
-
|
7549
|
+
using AddHistogramSampleCallback = void (*)(void* histogram, int sample);
|
7238
7550
|
|
7239
7551
|
// --- Crashkeys Callback ---
|
7240
7552
|
enum class CrashKeyId {
|
@@ -7245,11 +7557,11 @@ enum class CrashKeyId {
|
|
7245
7557
|
kDumpType,
|
7246
7558
|
};
|
7247
7559
|
|
7248
|
-
|
7560
|
+
using AddCrashKeyCallback = void (*)(CrashKeyId id, const std::string& value);
|
7249
7561
|
|
7250
7562
|
// --- Enter/Leave Script Callback ---
|
7251
|
-
|
7252
|
-
|
7563
|
+
using BeforeCallEnteredCallback = void (*)(Isolate*);
|
7564
|
+
using CallCompletedCallback = void (*)(Isolate*);
|
7253
7565
|
|
7254
7566
|
/**
|
7255
7567
|
* HostImportModuleDynamicallyCallback is called when we require the
|
@@ -7262,7 +7574,38 @@ typedef void (*CallCompletedCallback)(Isolate*);
|
|
7262
7574
|
* The specifier is the name of the module that should be imported.
|
7263
7575
|
*
|
7264
7576
|
* The embedder must compile, instantiate, evaluate the Module, and
|
7265
|
-
* obtain
|
7577
|
+
* obtain its namespace object.
|
7578
|
+
*
|
7579
|
+
* The Promise returned from this function is forwarded to userland
|
7580
|
+
* JavaScript. The embedder must resolve this promise with the module
|
7581
|
+
* namespace object. In case of an exception, the embedder must reject
|
7582
|
+
* this promise with the exception. If the promise creation itself
|
7583
|
+
* fails (e.g. due to stack overflow), the embedder must propagate
|
7584
|
+
* that exception by returning an empty MaybeLocal.
|
7585
|
+
*/
|
7586
|
+
using HostImportModuleDynamicallyCallback =
|
7587
|
+
MaybeLocal<Promise> (*)(Local<Context> context,
|
7588
|
+
Local<ScriptOrModule> referrer,
|
7589
|
+
Local<String> specifier);
|
7590
|
+
|
7591
|
+
/**
|
7592
|
+
* HostImportModuleDynamicallyWithImportAssertionsCallback is called when we
|
7593
|
+
* require the embedder to load a module. This is used as part of the dynamic
|
7594
|
+
* import syntax.
|
7595
|
+
*
|
7596
|
+
* The referrer contains metadata about the script/module that calls
|
7597
|
+
* import.
|
7598
|
+
*
|
7599
|
+
* The specifier is the name of the module that should be imported.
|
7600
|
+
*
|
7601
|
+
* The import_assertions are import assertions for this request in the form:
|
7602
|
+
* [key1, value1, key2, value2, ...] where the keys and values are of type
|
7603
|
+
* v8::String. Note, unlike the FixedArray passed to ResolveModuleCallback and
|
7604
|
+
* returned from ModuleRequest::GetImportAssertions(), this array does not
|
7605
|
+
* contain the source Locations of the assertions.
|
7606
|
+
*
|
7607
|
+
* The embedder must compile, instantiate, evaluate the Module, and
|
7608
|
+
* obtain its namespace object.
|
7266
7609
|
*
|
7267
7610
|
* The Promise returned from this function is forwarded to userland
|
7268
7611
|
* JavaScript. The embedder must resolve this promise with the module
|
@@ -7271,9 +7614,11 @@ typedef void (*CallCompletedCallback)(Isolate*);
|
|
7271
7614
|
* fails (e.g. due to stack overflow), the embedder must propagate
|
7272
7615
|
* that exception by returning an empty MaybeLocal.
|
7273
7616
|
*/
|
7274
|
-
|
7275
|
-
|
7276
|
-
|
7617
|
+
using HostImportModuleDynamicallyWithImportAssertionsCallback =
|
7618
|
+
MaybeLocal<Promise> (*)(Local<Context> context,
|
7619
|
+
Local<ScriptOrModule> referrer,
|
7620
|
+
Local<String> specifier,
|
7621
|
+
Local<FixedArray> import_assertions);
|
7277
7622
|
|
7278
7623
|
/**
|
7279
7624
|
* HostInitializeImportMetaObjectCallback is called the first time import.meta
|
@@ -7285,9 +7630,9 @@ typedef MaybeLocal<Promise> (*HostImportModuleDynamicallyCallback)(
|
|
7285
7630
|
* The embedder should use v8::Object::CreateDataProperty to add properties on
|
7286
7631
|
* the meta object.
|
7287
7632
|
*/
|
7288
|
-
|
7289
|
-
|
7290
|
-
|
7633
|
+
using HostInitializeImportMetaObjectCallback = void (*)(Local<Context> context,
|
7634
|
+
Local<Module> module,
|
7635
|
+
Local<Object> meta);
|
7291
7636
|
|
7292
7637
|
/**
|
7293
7638
|
* PrepareStackTraceCallback is called when the stack property of an error is
|
@@ -7296,9 +7641,9 @@ typedef void (*HostInitializeImportMetaObjectCallback)(Local<Context> context,
|
|
7296
7641
|
* |sites| is an array of call sites, specified in
|
7297
7642
|
* https://v8.dev/docs/stack-trace-api
|
7298
7643
|
*/
|
7299
|
-
|
7300
|
-
|
7301
|
-
|
7644
|
+
using PrepareStackTraceCallback = MaybeLocal<Value> (*)(Local<Context> context,
|
7645
|
+
Local<Value> error,
|
7646
|
+
Local<Array> sites);
|
7302
7647
|
|
7303
7648
|
/**
|
7304
7649
|
* PromiseHook with type kInit is called when a new promise is
|
@@ -7318,8 +7663,8 @@ typedef MaybeLocal<Value> (*PrepareStackTraceCallback)(Local<Context> context,
|
|
7318
7663
|
*/
|
7319
7664
|
enum class PromiseHookType { kInit, kResolve, kBefore, kAfter };
|
7320
7665
|
|
7321
|
-
|
7322
|
-
|
7666
|
+
using PromiseHook = void (*)(PromiseHookType type, Local<Promise> promise,
|
7667
|
+
Local<Value> parent);
|
7323
7668
|
|
7324
7669
|
// --- Promise Reject Callback ---
|
7325
7670
|
enum PromiseRejectEvent {
|
@@ -7345,12 +7690,11 @@ class PromiseRejectMessage {
|
|
7345
7690
|
Local<Value> value_;
|
7346
7691
|
};
|
7347
7692
|
|
7348
|
-
|
7693
|
+
using PromiseRejectCallback = void (*)(PromiseRejectMessage message);
|
7349
7694
|
|
7350
7695
|
// --- Microtasks Callbacks ---
|
7351
|
-
|
7352
|
-
|
7353
|
-
typedef void (*MicrotaskCallback)(void* data);
|
7696
|
+
using MicrotasksCompletedCallbackWithData = void (*)(Isolate*, void*);
|
7697
|
+
using MicrotaskCallback = void (*)(void* data);
|
7354
7698
|
|
7355
7699
|
/**
|
7356
7700
|
* Policy for running microtasks:
|
@@ -7454,7 +7798,7 @@ class V8_EXPORT MicrotaskQueue {
|
|
7454
7798
|
* kDoNotRunMicrotasks should be used to annotate calls not intended to trigger
|
7455
7799
|
* microtasks.
|
7456
7800
|
*/
|
7457
|
-
class V8_EXPORT MicrotasksScope {
|
7801
|
+
class V8_EXPORT V8_NODISCARD MicrotasksScope {
|
7458
7802
|
public:
|
7459
7803
|
enum Type { kRunMicrotasks, kDoNotRunMicrotasks };
|
7460
7804
|
|
@@ -7487,11 +7831,9 @@ class V8_EXPORT MicrotasksScope {
|
|
7487
7831
|
bool run_;
|
7488
7832
|
};
|
7489
7833
|
|
7490
|
-
|
7491
7834
|
// --- Failed Access Check Callback ---
|
7492
|
-
|
7493
|
-
|
7494
|
-
Local<Value> data);
|
7835
|
+
using FailedAccessCheckCallback = void (*)(Local<Object> target,
|
7836
|
+
AccessType type, Local<Value> data);
|
7495
7837
|
|
7496
7838
|
// --- AllowCodeGenerationFromStrings callbacks ---
|
7497
7839
|
|
@@ -7499,8 +7841,8 @@ typedef void (*FailedAccessCheckCallback)(Local<Object> target,
|
|
7499
7841
|
* Callback to check if code generation from strings is allowed. See
|
7500
7842
|
* Context::AllowCodeGenerationFromStrings.
|
7501
7843
|
*/
|
7502
|
-
|
7503
|
-
|
7844
|
+
using AllowCodeGenerationFromStringsCallback = bool (*)(Local<Context> context,
|
7845
|
+
Local<String> source);
|
7504
7846
|
|
7505
7847
|
struct ModifyCodeGenerationFromStringsResult {
|
7506
7848
|
// If true, proceed with the codegen algorithm. Otherwise, block it.
|
@@ -7513,34 +7855,42 @@ struct ModifyCodeGenerationFromStringsResult {
|
|
7513
7855
|
|
7514
7856
|
/**
|
7515
7857
|
* Callback to check if codegen is allowed from a source object, and convert
|
7516
|
-
* the source to string if necessary.See
|
7858
|
+
* the source to string if necessary. See: ModifyCodeGenerationFromStrings.
|
7517
7859
|
*/
|
7518
|
-
|
7519
|
-
*
|
7860
|
+
using ModifyCodeGenerationFromStringsCallback =
|
7861
|
+
ModifyCodeGenerationFromStringsResult (*)(Local<Context> context,
|
7520
7862
|
Local<Value> source);
|
7863
|
+
using ModifyCodeGenerationFromStringsCallback2 =
|
7864
|
+
ModifyCodeGenerationFromStringsResult (*)(Local<Context> context,
|
7865
|
+
Local<Value> source,
|
7866
|
+
bool is_code_like);
|
7521
7867
|
|
7522
7868
|
// --- WebAssembly compilation callbacks ---
|
7523
|
-
|
7869
|
+
using ExtensionCallback = bool (*)(const FunctionCallbackInfo<Value>&);
|
7524
7870
|
|
7525
|
-
|
7526
|
-
|
7871
|
+
using AllowWasmCodeGenerationCallback = bool (*)(Local<Context> context,
|
7872
|
+
Local<String> source);
|
7527
7873
|
|
7528
7874
|
// --- Callback for APIs defined on v8-supported objects, but implemented
|
7529
7875
|
// by the embedder. Example: WebAssembly.{compile|instantiate}Streaming ---
|
7530
|
-
|
7876
|
+
using ApiImplementationCallback = void (*)(const FunctionCallbackInfo<Value>&);
|
7531
7877
|
|
7532
7878
|
// --- Callback for WebAssembly.compileStreaming ---
|
7533
|
-
|
7534
|
-
|
7535
|
-
// --- Callback for checking if WebAssembly threads are enabled ---
|
7536
|
-
typedef bool (*WasmThreadsEnabledCallback)(Local<Context> context);
|
7879
|
+
using WasmStreamingCallback = void (*)(const FunctionCallbackInfo<Value>&);
|
7537
7880
|
|
7538
7881
|
// --- Callback for loading source map file for Wasm profiling support
|
7539
|
-
|
7540
|
-
|
7882
|
+
using WasmLoadSourceMapCallback = Local<String> (*)(Isolate* isolate,
|
7883
|
+
const char* name);
|
7541
7884
|
|
7542
7885
|
// --- Callback for checking if WebAssembly Simd is enabled ---
|
7543
|
-
|
7886
|
+
using WasmSimdEnabledCallback = bool (*)(Local<Context> context);
|
7887
|
+
|
7888
|
+
// --- Callback for checking if WebAssembly exceptions are enabled ---
|
7889
|
+
using WasmExceptionsEnabledCallback = bool (*)(Local<Context> context);
|
7890
|
+
|
7891
|
+
// --- Callback for checking if the SharedArrayBuffer constructor is enabled ---
|
7892
|
+
using SharedArrayBufferConstructorEnabledCallback =
|
7893
|
+
bool (*)(Local<Context> context);
|
7544
7894
|
|
7545
7895
|
// --- Garbage Collection Callbacks ---
|
7546
7896
|
|
@@ -7584,9 +7934,9 @@ enum GCCallbackFlags {
|
|
7584
7934
|
kGCCallbackScheduleIdleGarbageCollection = 1 << 6,
|
7585
7935
|
};
|
7586
7936
|
|
7587
|
-
|
7937
|
+
using GCCallback = void (*)(GCType type, GCCallbackFlags flags);
|
7588
7938
|
|
7589
|
-
|
7939
|
+
using InterruptCallback = void (*)(Isolate* isolate, void* data);
|
7590
7940
|
|
7591
7941
|
/**
|
7592
7942
|
* This callback is invoked when the heap size is close to the heap limit and
|
@@ -7595,8 +7945,8 @@ typedef void (*InterruptCallback)(Isolate* isolate, void* data);
|
|
7595
7945
|
* than the current_heap_limit. The initial heap limit is the limit that was
|
7596
7946
|
* set after heap setup.
|
7597
7947
|
*/
|
7598
|
-
|
7599
|
-
|
7948
|
+
using NearHeapLimitCallback = size_t (*)(void* data, size_t current_heap_limit,
|
7949
|
+
size_t initial_heap_limit);
|
7600
7950
|
|
7601
7951
|
/**
|
7602
7952
|
* Collection of shared per-process V8 memory information.
|
@@ -7850,30 +8200,29 @@ enum JitCodeEventOptions {
|
|
7850
8200
|
*
|
7851
8201
|
* \param event code add, move or removal event.
|
7852
8202
|
*/
|
7853
|
-
|
8203
|
+
using JitCodeEventHandler = void (*)(const JitCodeEvent* event);
|
7854
8204
|
|
7855
8205
|
/**
|
7856
8206
|
* Callback function passed to SetUnhandledExceptionCallback.
|
7857
8207
|
*/
|
7858
8208
|
#if defined(V8_OS_WIN)
|
7859
|
-
|
7860
|
-
_EXCEPTION_POINTERS* exception_pointers);
|
8209
|
+
using UnhandledExceptionCallback =
|
8210
|
+
int (*)(_EXCEPTION_POINTERS* exception_pointers);
|
7861
8211
|
#endif
|
7862
8212
|
|
7863
8213
|
/**
|
7864
8214
|
* Interface for iterating through all external resources in the heap.
|
7865
8215
|
*/
|
7866
|
-
class V8_EXPORT ExternalResourceVisitor {
|
8216
|
+
class V8_EXPORT ExternalResourceVisitor {
|
7867
8217
|
public:
|
7868
8218
|
virtual ~ExternalResourceVisitor() = default;
|
7869
8219
|
virtual void VisitExternalString(Local<String> string) {}
|
7870
8220
|
};
|
7871
8221
|
|
7872
|
-
|
7873
8222
|
/**
|
7874
8223
|
* Interface for iterating through all the persistent handles in the heap.
|
7875
8224
|
*/
|
7876
|
-
class V8_EXPORT PersistentHandleVisitor {
|
8225
|
+
class V8_EXPORT PersistentHandleVisitor {
|
7877
8226
|
public:
|
7878
8227
|
virtual ~PersistentHandleVisitor() = default;
|
7879
8228
|
virtual void VisitPersistentHandle(Persistent<Value>* value,
|
@@ -7890,6 +8239,45 @@ class V8_EXPORT PersistentHandleVisitor { // NOLINT
|
|
7890
8239
|
*/
|
7891
8240
|
enum class MemoryPressureLevel { kNone, kModerate, kCritical };
|
7892
8241
|
|
8242
|
+
/**
|
8243
|
+
* Handler for embedder roots on non-unified heap garbage collections.
|
8244
|
+
*/
|
8245
|
+
class V8_EXPORT EmbedderRootsHandler {
|
8246
|
+
public:
|
8247
|
+
virtual ~EmbedderRootsHandler() = default;
|
8248
|
+
|
8249
|
+
/**
|
8250
|
+
* Returns true if the TracedGlobal handle should be considered as root for
|
8251
|
+
* the currently running non-tracing garbage collection and false otherwise.
|
8252
|
+
* The default implementation will keep all TracedGlobal references as roots.
|
8253
|
+
*
|
8254
|
+
* If this returns false, then V8 may decide that the object referred to by
|
8255
|
+
* such a handle is reclaimed. In that case:
|
8256
|
+
* - No action is required if handles are used with destructors, i.e., by just
|
8257
|
+
* using |TracedGlobal|.
|
8258
|
+
* - When run without destructors, i.e., by using |TracedReference|, V8 calls
|
8259
|
+
* |ResetRoot|.
|
8260
|
+
*
|
8261
|
+
* Note that the |handle| is different from the handle that the embedder holds
|
8262
|
+
* for retaining the object. The embedder may use |WrapperClassId()| to
|
8263
|
+
* distinguish cases where it wants handles to be treated as roots from not
|
8264
|
+
* being treated as roots.
|
8265
|
+
*/
|
8266
|
+
virtual bool IsRoot(const v8::TracedReference<v8::Value>& handle) = 0;
|
8267
|
+
virtual bool IsRoot(const v8::TracedGlobal<v8::Value>& handle) = 0;
|
8268
|
+
|
8269
|
+
/**
|
8270
|
+
* Used in combination with |IsRoot|. Called by V8 when an
|
8271
|
+
* object that is backed by a handle is reclaimed by a non-tracing garbage
|
8272
|
+
* collection. It is up to the embedder to reset the original handle.
|
8273
|
+
*
|
8274
|
+
* Note that the |handle| is different from the handle that the embedder holds
|
8275
|
+
* for retaining the object. It is up to the embedder to find the original
|
8276
|
+
* handle via the object or class id.
|
8277
|
+
*/
|
8278
|
+
virtual void ResetRoot(const v8::TracedReference<v8::Value>& handle) = 0;
|
8279
|
+
};
|
8280
|
+
|
7893
8281
|
/**
|
7894
8282
|
* Interface for tracing through the embedder heap. During a V8 garbage
|
7895
8283
|
* collection, V8 collects hidden fields of all potential wrappers, and at the
|
@@ -7952,6 +8340,9 @@ class V8_EXPORT EmbedderHeapTracer {
|
|
7952
8340
|
/**
|
7953
8341
|
* Called by the embedder to notify V8 of an empty execution stack.
|
7954
8342
|
*/
|
8343
|
+
V8_DEPRECATE_SOON(
|
8344
|
+
"This call only optimized internal caches which V8 is able to figure out "
|
8345
|
+
"on its own now.")
|
7955
8346
|
void NotifyEmptyEmbedderStack();
|
7956
8347
|
|
7957
8348
|
/**
|
@@ -7963,7 +8354,7 @@ class V8_EXPORT EmbedderHeapTracer {
|
|
7963
8354
|
virtual void RegisterV8References(
|
7964
8355
|
const std::vector<std::pair<void*, void*> >& embedder_fields) = 0;
|
7965
8356
|
|
7966
|
-
void RegisterEmbedderReference(const
|
8357
|
+
void RegisterEmbedderReference(const BasicTracedReference<v8::Data>& ref);
|
7967
8358
|
|
7968
8359
|
/**
|
7969
8360
|
* Called at the beginning of a GC cycle.
|
@@ -8015,34 +8406,14 @@ class V8_EXPORT EmbedderHeapTracer {
|
|
8015
8406
|
void FinalizeTracing();
|
8016
8407
|
|
8017
8408
|
/**
|
8018
|
-
*
|
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.
|
8409
|
+
* See documentation on EmbedderRootsHandler.
|
8033
8410
|
*/
|
8034
8411
|
virtual bool IsRootForNonTracingGC(
|
8035
8412
|
const v8::TracedReference<v8::Value>& handle);
|
8036
8413
|
virtual bool IsRootForNonTracingGC(const v8::TracedGlobal<v8::Value>& handle);
|
8037
8414
|
|
8038
8415
|
/**
|
8039
|
-
*
|
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.
|
8416
|
+
* See documentation on EmbedderRootsHandler.
|
8046
8417
|
*/
|
8047
8418
|
virtual void ResetHandleInNonTracingGC(
|
8048
8419
|
const v8::TracedReference<v8::Value>& handle);
|
@@ -8084,8 +8455,8 @@ class V8_EXPORT EmbedderHeapTracer {
|
|
8084
8455
|
* serialized verbatim.
|
8085
8456
|
*/
|
8086
8457
|
struct SerializeInternalFieldsCallback {
|
8087
|
-
|
8088
|
-
|
8458
|
+
using CallbackFunction = StartupData (*)(Local<Object> holder, int index,
|
8459
|
+
void* data);
|
8089
8460
|
SerializeInternalFieldsCallback(CallbackFunction function = nullptr,
|
8090
8461
|
void* data_arg = nullptr)
|
8091
8462
|
: callback(function), data(data_arg) {}
|
@@ -8094,15 +8465,15 @@ struct SerializeInternalFieldsCallback {
|
|
8094
8465
|
};
|
8095
8466
|
// Note that these fields are called "internal fields" in the API and called
|
8096
8467
|
// "embedder fields" within V8.
|
8097
|
-
|
8468
|
+
using SerializeEmbedderFieldsCallback = SerializeInternalFieldsCallback;
|
8098
8469
|
|
8099
8470
|
/**
|
8100
8471
|
* Callback and supporting data used to implement embedder logic to deserialize
|
8101
8472
|
* internal fields.
|
8102
8473
|
*/
|
8103
8474
|
struct DeserializeInternalFieldsCallback {
|
8104
|
-
|
8105
|
-
|
8475
|
+
using CallbackFunction = void (*)(Local<Object> holder, int index,
|
8476
|
+
StartupData payload, void* data);
|
8106
8477
|
DeserializeInternalFieldsCallback(CallbackFunction function = nullptr,
|
8107
8478
|
void* data_arg = nullptr)
|
8108
8479
|
: callback(function), data(data_arg) {}
|
@@ -8110,7 +8481,7 @@ struct DeserializeInternalFieldsCallback {
|
|
8110
8481
|
void* data);
|
8111
8482
|
void* data;
|
8112
8483
|
};
|
8113
|
-
|
8484
|
+
using DeserializeEmbedderFieldsCallback = DeserializeInternalFieldsCallback;
|
8114
8485
|
|
8115
8486
|
/**
|
8116
8487
|
* Controls how the default MeasureMemoryDelegate reports the result of
|
@@ -8186,26 +8557,15 @@ class V8_EXPORT Isolate {
|
|
8186
8557
|
/**
|
8187
8558
|
* Initial configuration parameters for a new Isolate.
|
8188
8559
|
*/
|
8189
|
-
struct CreateParams {
|
8190
|
-
CreateParams()
|
8191
|
-
|
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) {}
|
8560
|
+
struct V8_EXPORT CreateParams {
|
8561
|
+
CreateParams();
|
8562
|
+
~CreateParams();
|
8203
8563
|
|
8204
8564
|
/**
|
8205
8565
|
* Allows the host application to provide the address of a function that is
|
8206
8566
|
* notified each time code is added, moved or removed.
|
8207
8567
|
*/
|
8208
|
-
JitCodeEventHandler code_event_handler;
|
8568
|
+
JitCodeEventHandler code_event_handler = nullptr;
|
8209
8569
|
|
8210
8570
|
/**
|
8211
8571
|
* ResourceConstraints to use for the new Isolate.
|
@@ -8215,14 +8575,13 @@ class V8_EXPORT Isolate {
|
|
8215
8575
|
/**
|
8216
8576
|
* Explicitly specify a startup snapshot blob. The embedder owns the blob.
|
8217
8577
|
*/
|
8218
|
-
StartupData* snapshot_blob;
|
8219
|
-
|
8578
|
+
StartupData* snapshot_blob = nullptr;
|
8220
8579
|
|
8221
8580
|
/**
|
8222
8581
|
* Enables the host application to provide a mechanism for recording
|
8223
8582
|
* statistics counters.
|
8224
8583
|
*/
|
8225
|
-
CounterLookupCallback counter_lookup_callback;
|
8584
|
+
CounterLookupCallback counter_lookup_callback = nullptr;
|
8226
8585
|
|
8227
8586
|
/**
|
8228
8587
|
* Enables the host application to provide a mechanism for recording
|
@@ -8230,8 +8589,8 @@ class V8_EXPORT Isolate {
|
|
8230
8589
|
* histogram which will later be passed to the AddHistogramSample
|
8231
8590
|
* function.
|
8232
8591
|
*/
|
8233
|
-
CreateHistogramCallback create_histogram_callback;
|
8234
|
-
AddHistogramSampleCallback add_histogram_sample_callback;
|
8592
|
+
CreateHistogramCallback create_histogram_callback = nullptr;
|
8593
|
+
AddHistogramSampleCallback add_histogram_sample_callback = nullptr;
|
8235
8594
|
|
8236
8595
|
/**
|
8237
8596
|
* The ArrayBuffer::Allocator to use for allocating and freeing the backing
|
@@ -8242,7 +8601,7 @@ class V8_EXPORT Isolate {
|
|
8242
8601
|
* to the allocator, in order to facilitate lifetime
|
8243
8602
|
* management for the allocator instance.
|
8244
8603
|
*/
|
8245
|
-
ArrayBuffer::Allocator* array_buffer_allocator;
|
8604
|
+
ArrayBuffer::Allocator* array_buffer_allocator = nullptr;
|
8246
8605
|
std::shared_ptr<ArrayBuffer::Allocator> array_buffer_allocator_shared;
|
8247
8606
|
|
8248
8607
|
/**
|
@@ -8251,34 +8610,38 @@ class V8_EXPORT Isolate {
|
|
8251
8610
|
* deserialization. This array and its content must stay valid for the
|
8252
8611
|
* entire lifetime of the isolate.
|
8253
8612
|
*/
|
8254
|
-
const intptr_t* external_references;
|
8613
|
+
const intptr_t* external_references = nullptr;
|
8255
8614
|
|
8256
8615
|
/**
|
8257
8616
|
* Whether calling Atomics.wait (a function that may block) is allowed in
|
8258
8617
|
* this isolate. This can also be configured via SetAllowAtomicsWait.
|
8259
8618
|
*/
|
8260
|
-
bool allow_atomics_wait;
|
8619
|
+
bool allow_atomics_wait = true;
|
8261
8620
|
|
8262
8621
|
/**
|
8263
8622
|
* Termination is postponed when there is no active SafeForTerminationScope.
|
8264
8623
|
*/
|
8265
|
-
bool only_terminate_in_safe_scope;
|
8624
|
+
bool only_terminate_in_safe_scope = false;
|
8266
8625
|
|
8267
8626
|
/**
|
8268
8627
|
* The following parameters describe the offsets for addressing type info
|
8269
8628
|
* for wrapped API objects and are used by the fast C API
|
8270
8629
|
* (for details see v8-fast-api-calls.h).
|
8271
8630
|
*/
|
8272
|
-
int embedder_wrapper_type_index;
|
8273
|
-
int embedder_wrapper_object_index;
|
8274
|
-
};
|
8631
|
+
int embedder_wrapper_type_index = -1;
|
8632
|
+
int embedder_wrapper_object_index = -1;
|
8275
8633
|
|
8634
|
+
V8_DEPRECATED(
|
8635
|
+
"Setting this has no effect. Embedders should ignore import assertions "
|
8636
|
+
"that they do not use.")
|
8637
|
+
std::vector<std::string> supported_import_assertions;
|
8638
|
+
};
|
8276
8639
|
|
8277
8640
|
/**
|
8278
8641
|
* Stack-allocated class which sets the isolate for all operations
|
8279
8642
|
* executed within a local scope.
|
8280
8643
|
*/
|
8281
|
-
class V8_EXPORT Scope {
|
8644
|
+
class V8_EXPORT V8_NODISCARD Scope {
|
8282
8645
|
public:
|
8283
8646
|
explicit Scope(Isolate* isolate) : isolate_(isolate) {
|
8284
8647
|
isolate->Enter();
|
@@ -8294,11 +8657,10 @@ class V8_EXPORT Isolate {
|
|
8294
8657
|
Isolate* const isolate_;
|
8295
8658
|
};
|
8296
8659
|
|
8297
|
-
|
8298
8660
|
/**
|
8299
8661
|
* Assert that no Javascript code is invoked.
|
8300
8662
|
*/
|
8301
|
-
class V8_EXPORT DisallowJavascriptExecutionScope {
|
8663
|
+
class V8_EXPORT V8_NODISCARD DisallowJavascriptExecutionScope {
|
8302
8664
|
public:
|
8303
8665
|
enum OnFailure { CRASH_ON_FAILURE, THROW_ON_FAILURE, DUMP_ON_FAILURE };
|
8304
8666
|
|
@@ -8313,14 +8675,17 @@ class V8_EXPORT Isolate {
|
|
8313
8675
|
|
8314
8676
|
private:
|
8315
8677
|
OnFailure on_failure_;
|
8316
|
-
|
8317
|
-
};
|
8678
|
+
Isolate* isolate_;
|
8318
8679
|
|
8680
|
+
bool was_execution_allowed_assert_;
|
8681
|
+
bool was_execution_allowed_throws_;
|
8682
|
+
bool was_execution_allowed_dump_;
|
8683
|
+
};
|
8319
8684
|
|
8320
8685
|
/**
|
8321
8686
|
* Introduce exception to DisallowJavascriptExecutionScope.
|
8322
8687
|
*/
|
8323
|
-
class V8_EXPORT AllowJavascriptExecutionScope {
|
8688
|
+
class V8_EXPORT V8_NODISCARD AllowJavascriptExecutionScope {
|
8324
8689
|
public:
|
8325
8690
|
explicit AllowJavascriptExecutionScope(Isolate* isolate);
|
8326
8691
|
~AllowJavascriptExecutionScope();
|
@@ -8332,16 +8697,17 @@ class V8_EXPORT Isolate {
|
|
8332
8697
|
const AllowJavascriptExecutionScope&) = delete;
|
8333
8698
|
|
8334
8699
|
private:
|
8335
|
-
|
8336
|
-
|
8337
|
-
|
8700
|
+
Isolate* isolate_;
|
8701
|
+
bool was_execution_allowed_assert_;
|
8702
|
+
bool was_execution_allowed_throws_;
|
8703
|
+
bool was_execution_allowed_dump_;
|
8338
8704
|
};
|
8339
8705
|
|
8340
8706
|
/**
|
8341
8707
|
* Do not run microtasks while this scope is active, even if microtasks are
|
8342
8708
|
* automatically executed otherwise.
|
8343
8709
|
*/
|
8344
|
-
class V8_EXPORT SuppressMicrotaskExecutionScope {
|
8710
|
+
class V8_EXPORT V8_NODISCARD SuppressMicrotaskExecutionScope {
|
8345
8711
|
public:
|
8346
8712
|
explicit SuppressMicrotaskExecutionScope(
|
8347
8713
|
Isolate* isolate, MicrotaskQueue* microtask_queue = nullptr);
|
@@ -8365,7 +8731,7 @@ class V8_EXPORT Isolate {
|
|
8365
8731
|
* This scope allows terminations inside direct V8 API calls and forbid them
|
8366
8732
|
* inside any recursive API calls without explicit SafeForTerminationScope.
|
8367
8733
|
*/
|
8368
|
-
class V8_EXPORT SafeForTerminationScope {
|
8734
|
+
class V8_EXPORT V8_NODISCARD SafeForTerminationScope {
|
8369
8735
|
public:
|
8370
8736
|
explicit SafeForTerminationScope(v8::Isolate* isolate);
|
8371
8737
|
~SafeForTerminationScope();
|
@@ -8424,8 +8790,8 @@ class V8_EXPORT Isolate {
|
|
8424
8790
|
kArrayInstanceProtoModified = 27,
|
8425
8791
|
kArrayInstanceConstructorModified = 28,
|
8426
8792
|
kLegacyFunctionDeclaration = 29,
|
8427
|
-
kRegExpPrototypeSourceGetter = 30,
|
8428
|
-
kRegExpPrototypeOldFlagGetter = 31,
|
8793
|
+
kRegExpPrototypeSourceGetter = 30, // Unused.
|
8794
|
+
kRegExpPrototypeOldFlagGetter = 31, // Unused.
|
8429
8795
|
kDecimalWithLeadingZeroInStrictMode = 32,
|
8430
8796
|
kLegacyDateParser = 33,
|
8431
8797
|
kDefineGetterOrSetterWouldThrow = 34,
|
@@ -8465,7 +8831,7 @@ class V8_EXPORT Isolate {
|
|
8465
8831
|
kDateToLocaleTimeString = 68,
|
8466
8832
|
kAttemptOverrideReadOnlyOnPrototypeSloppy = 69,
|
8467
8833
|
kAttemptOverrideReadOnlyOnPrototypeStrict = 70,
|
8468
|
-
kOptimizedFunctionWithOneShotBytecode = 71,
|
8834
|
+
kOptimizedFunctionWithOneShotBytecode = 71, // Unused.
|
8469
8835
|
kRegExpMatchIsTrueishOnNonJSRegExp = 72,
|
8470
8836
|
kRegExpMatchIsFalseishOnJSRegExp = 73,
|
8471
8837
|
kDateGetTimezoneOffset = 74, // Unused.
|
@@ -8503,8 +8869,10 @@ class V8_EXPORT Isolate {
|
|
8503
8869
|
kWasmSimdOpcodes = 106,
|
8504
8870
|
kVarRedeclaredCatchBinding = 107,
|
8505
8871
|
kWasmRefTypes = 108,
|
8506
|
-
kWasmBulkMemory = 109,
|
8872
|
+
kWasmBulkMemory = 109, // Unused.
|
8507
8873
|
kWasmMultiValue = 110,
|
8874
|
+
kWasmExceptionHandling = 111,
|
8875
|
+
kInvalidatedMegaDOMProtector = 112,
|
8508
8876
|
|
8509
8877
|
// If you add new values here, you'll also need to update Chromium's:
|
8510
8878
|
// web_feature.mojom, use_counter_callback.cc, and enums.xml. V8 changes to
|
@@ -8522,8 +8890,8 @@ class V8_EXPORT Isolate {
|
|
8522
8890
|
kMessageWarning,
|
8523
8891
|
};
|
8524
8892
|
|
8525
|
-
|
8526
|
-
|
8893
|
+
using UseCounterCallback = void (*)(Isolate* isolate,
|
8894
|
+
UseCounterFeature feature);
|
8527
8895
|
|
8528
8896
|
/**
|
8529
8897
|
* Allocates a new isolate but does not initialize it. Does not change the
|
@@ -8565,6 +8933,14 @@ class V8_EXPORT Isolate {
|
|
8565
8933
|
*/
|
8566
8934
|
static Isolate* GetCurrent();
|
8567
8935
|
|
8936
|
+
/**
|
8937
|
+
* Returns the entered isolate for the current thread or NULL in
|
8938
|
+
* case there is no current isolate.
|
8939
|
+
*
|
8940
|
+
* No checks are performed by this method.
|
8941
|
+
*/
|
8942
|
+
static Isolate* TryGetCurrent();
|
8943
|
+
|
8568
8944
|
/**
|
8569
8945
|
* Clears the set of objects held strongly by the heap. This set of
|
8570
8946
|
* objects are originally built when a WeakRef is created or
|
@@ -8589,7 +8965,7 @@ class V8_EXPORT Isolate {
|
|
8589
8965
|
* - the custom callback set returns true.
|
8590
8966
|
* Otherwise, the custom callback will not be called and V8 will not abort.
|
8591
8967
|
*/
|
8592
|
-
|
8968
|
+
using AbortOnUncaughtExceptionCallback = bool (*)(Isolate*);
|
8593
8969
|
void SetAbortOnUncaughtExceptionCallback(
|
8594
8970
|
AbortOnUncaughtExceptionCallback callback);
|
8595
8971
|
|
@@ -8597,9 +8973,19 @@ class V8_EXPORT Isolate {
|
|
8597
8973
|
* This specifies the callback called by the upcoming dynamic
|
8598
8974
|
* import() language feature to load modules.
|
8599
8975
|
*/
|
8976
|
+
V8_DEPRECATE_SOON(
|
8977
|
+
"Use the version of SetHostImportModuleDynamicallyCallback that takes a "
|
8978
|
+
"HostImportModuleDynamicallyWithImportAssertionsCallback instead")
|
8600
8979
|
void SetHostImportModuleDynamicallyCallback(
|
8601
8980
|
HostImportModuleDynamicallyCallback callback);
|
8602
8981
|
|
8982
|
+
/**
|
8983
|
+
* This specifies the callback called by the upcoming dynamic
|
8984
|
+
* import() language feature to load modules.
|
8985
|
+
*/
|
8986
|
+
void SetHostImportModuleDynamicallyCallback(
|
8987
|
+
HostImportModuleDynamicallyWithImportAssertionsCallback callback);
|
8988
|
+
|
8603
8989
|
/**
|
8604
8990
|
* This specifies the callback called by the upcoming import.meta
|
8605
8991
|
* language feature to retrieve host-defined meta data for a module.
|
@@ -8621,6 +9007,13 @@ class V8_EXPORT Isolate {
|
|
8621
9007
|
*/
|
8622
9008
|
void MemoryPressureNotification(MemoryPressureLevel level);
|
8623
9009
|
|
9010
|
+
/**
|
9011
|
+
* Drop non-essential caches. Should only be called from testing code.
|
9012
|
+
* The method can potentially block for a long time and does not necessarily
|
9013
|
+
* trigger GC.
|
9014
|
+
*/
|
9015
|
+
void ClearCachesForTesting();
|
9016
|
+
|
8624
9017
|
/**
|
8625
9018
|
* Methods below this point require holding a lock (using Locker) in
|
8626
9019
|
* a multi-threaded environment.
|
@@ -8753,7 +9146,7 @@ class V8_EXPORT Isolate {
|
|
8753
9146
|
std::unique_ptr<MeasureMemoryDelegate> delegate,
|
8754
9147
|
MeasureMemoryExecution execution = MeasureMemoryExecution::kDefault);
|
8755
9148
|
|
8756
|
-
|
9149
|
+
V8_DEPRECATED("Use the version with a delegate")
|
8757
9150
|
MaybeLocal<Promise> MeasureMemory(Local<Context> context,
|
8758
9151
|
MeasureMemoryMode mode);
|
8759
9152
|
|
@@ -8816,10 +9209,6 @@ class V8_EXPORT Isolate {
|
|
8816
9209
|
*/
|
8817
9210
|
Local<Context> GetCurrentContext();
|
8818
9211
|
|
8819
|
-
/** Returns the last context entered through V8's C++ API. */
|
8820
|
-
V8_DEPRECATED("Use GetEnteredOrMicrotaskContext().")
|
8821
|
-
Local<Context> GetEnteredContext();
|
8822
|
-
|
8823
9212
|
/**
|
8824
9213
|
* Returns either the last context entered through V8's C++ API, or the
|
8825
9214
|
* context of the currently running microtask while processing microtasks.
|
@@ -8834,6 +9223,17 @@ class V8_EXPORT Isolate {
|
|
8834
9223
|
*/
|
8835
9224
|
Local<Context> GetIncumbentContext();
|
8836
9225
|
|
9226
|
+
/**
|
9227
|
+
* Schedules a v8::Exception::Error with the given message.
|
9228
|
+
* See ThrowException for more details. Templatized to provide compile-time
|
9229
|
+
* errors in case of too long strings (see v8::String::NewFromUtf8Literal).
|
9230
|
+
*/
|
9231
|
+
template <int N>
|
9232
|
+
Local<Value> ThrowError(const char (&message)[N]) {
|
9233
|
+
return ThrowError(String::NewFromUtf8Literal(this, message));
|
9234
|
+
}
|
9235
|
+
Local<Value> ThrowError(Local<String> message);
|
9236
|
+
|
8837
9237
|
/**
|
8838
9238
|
* Schedules an exception to be thrown when returning to JavaScript. When an
|
8839
9239
|
* exception has been scheduled it is illegal to invoke any JavaScript
|
@@ -8842,10 +9242,10 @@ class V8_EXPORT Isolate {
|
|
8842
9242
|
*/
|
8843
9243
|
Local<Value> ThrowException(Local<Value> exception);
|
8844
9244
|
|
8845
|
-
|
8846
|
-
|
8847
|
-
|
8848
|
-
|
9245
|
+
using GCCallback = void (*)(Isolate* isolate, GCType type,
|
9246
|
+
GCCallbackFlags flags);
|
9247
|
+
using GCCallbackWithData = void (*)(Isolate* isolate, GCType type,
|
9248
|
+
GCCallbackFlags flags, void* data);
|
8849
9249
|
|
8850
9250
|
/**
|
8851
9251
|
* Enables the host application to receive a notification before a
|
@@ -8878,6 +9278,42 @@ class V8_EXPORT Isolate {
|
|
8878
9278
|
*/
|
8879
9279
|
EmbedderHeapTracer* GetEmbedderHeapTracer();
|
8880
9280
|
|
9281
|
+
/**
|
9282
|
+
* Sets an embedder roots handle that V8 should consider when performing
|
9283
|
+
* non-unified heap garbage collections.
|
9284
|
+
*
|
9285
|
+
* Using only EmbedderHeapTracer automatically sets up a default handler.
|
9286
|
+
* The intended use case is for setting a custom handler after invoking
|
9287
|
+
* `AttachCppHeap()`.
|
9288
|
+
*
|
9289
|
+
* V8 does not take ownership of the handler.
|
9290
|
+
*/
|
9291
|
+
void SetEmbedderRootsHandler(EmbedderRootsHandler* handler);
|
9292
|
+
|
9293
|
+
/**
|
9294
|
+
* Attaches a managed C++ heap as an extension to the JavaScript heap. The
|
9295
|
+
* embedder maintains ownership of the CppHeap. At most one C++ heap can be
|
9296
|
+
* attached to V8.
|
9297
|
+
*
|
9298
|
+
* This is an experimental feature and may still change significantly.
|
9299
|
+
*/
|
9300
|
+
void AttachCppHeap(CppHeap*);
|
9301
|
+
|
9302
|
+
/**
|
9303
|
+
* Detaches a managed C++ heap if one was attached using `AttachCppHeap()`.
|
9304
|
+
*
|
9305
|
+
* This is an experimental feature and may still change significantly.
|
9306
|
+
*/
|
9307
|
+
void DetachCppHeap();
|
9308
|
+
|
9309
|
+
/**
|
9310
|
+
* This is an experimental feature and may still change significantly.
|
9311
|
+
|
9312
|
+
* \returns the C++ heap managed by V8. Only available if such a heap has been
|
9313
|
+
* attached using `AttachCppHeap()`.
|
9314
|
+
*/
|
9315
|
+
CppHeap* GetCppHeap() const;
|
9316
|
+
|
8881
9317
|
/**
|
8882
9318
|
* Use for |AtomicsWaitCallback| to indicate the type of event it receives.
|
8883
9319
|
*/
|
@@ -8942,12 +9378,12 @@ class V8_EXPORT Isolate {
|
|
8942
9378
|
* This callback may schedule exceptions, *unless* |event| is equal to
|
8943
9379
|
* |kTerminatedExecution|.
|
8944
9380
|
*/
|
8945
|
-
|
8946
|
-
|
8947
|
-
|
8948
|
-
|
8949
|
-
|
8950
|
-
|
9381
|
+
using AtomicsWaitCallback = void (*)(AtomicsWaitEvent event,
|
9382
|
+
Local<SharedArrayBuffer> array_buffer,
|
9383
|
+
size_t offset_in_bytes, int64_t value,
|
9384
|
+
double timeout_in_ms,
|
9385
|
+
AtomicsWaitWakeHandle* stop_handle,
|
9386
|
+
void* data);
|
8951
9387
|
|
8952
9388
|
/**
|
8953
9389
|
* Set a new |AtomicsWaitCallback|. This overrides an earlier
|
@@ -8979,7 +9415,7 @@ class V8_EXPORT Isolate {
|
|
8979
9415
|
void* data = nullptr);
|
8980
9416
|
void RemoveGCEpilogueCallback(GCCallback callback);
|
8981
9417
|
|
8982
|
-
|
9418
|
+
using GetExternallyAllocatedMemoryInBytesCallback = size_t (*)();
|
8983
9419
|
|
8984
9420
|
/**
|
8985
9421
|
* Set the callback that tells V8 how much memory is currently allocated
|
@@ -9098,12 +9534,6 @@ class V8_EXPORT Isolate {
|
|
9098
9534
|
*/
|
9099
9535
|
void SetPromiseRejectCallback(PromiseRejectCallback callback);
|
9100
9536
|
|
9101
|
-
/**
|
9102
|
-
* An alias for PerformMicrotaskCheckpoint.
|
9103
|
-
*/
|
9104
|
-
V8_DEPRECATE_SOON("Use PerformMicrotaskCheckpoint.")
|
9105
|
-
void RunMicrotasks() { PerformMicrotaskCheckpoint(); }
|
9106
|
-
|
9107
9537
|
/**
|
9108
9538
|
* Runs the default MicrotaskQueue until it gets empty and perform other
|
9109
9539
|
* microtask checkpoint steps, such as calling ClearKeptObjects. Asserts that
|
@@ -9145,16 +9575,12 @@ class V8_EXPORT Isolate {
|
|
9145
9575
|
* Executing scripts inside the callback will not re-trigger microtasks and
|
9146
9576
|
* the callback.
|
9147
9577
|
*/
|
9148
|
-
V8_DEPRECATE_SOON("Use *WithData version.")
|
9149
|
-
void AddMicrotasksCompletedCallback(MicrotasksCompletedCallback callback);
|
9150
9578
|
void AddMicrotasksCompletedCallback(
|
9151
9579
|
MicrotasksCompletedCallbackWithData callback, void* data = nullptr);
|
9152
9580
|
|
9153
9581
|
/**
|
9154
9582
|
* Removes callback that was installed by AddMicrotasksCompletedCallback.
|
9155
9583
|
*/
|
9156
|
-
V8_DEPRECATE_SOON("Use *WithData version.")
|
9157
|
-
void RemoveMicrotasksCompletedCallback(MicrotasksCompletedCallback callback);
|
9158
9584
|
void RemoveMicrotasksCompletedCallback(
|
9159
9585
|
MicrotasksCompletedCallbackWithData callback, void* data = nullptr);
|
9160
9586
|
|
@@ -9263,6 +9689,11 @@ class V8_EXPORT Isolate {
|
|
9263
9689
|
*/
|
9264
9690
|
void SetRAILMode(RAILMode rail_mode);
|
9265
9691
|
|
9692
|
+
/**
|
9693
|
+
* Update load start time of the RAIL mode
|
9694
|
+
*/
|
9695
|
+
void UpdateLoadStartTime();
|
9696
|
+
|
9266
9697
|
/**
|
9267
9698
|
* Optional notification to tell V8 the current isolate is used for debugging
|
9268
9699
|
* and requires higher heap limit.
|
@@ -9334,11 +9765,10 @@ class V8_EXPORT Isolate {
|
|
9334
9765
|
void GetCodeRange(void** start, size_t* length_in_bytes);
|
9335
9766
|
|
9336
9767
|
/**
|
9337
|
-
*
|
9768
|
+
* As GetCodeRange, but for embedded builtins (these live in a distinct
|
9769
|
+
* memory region from other V8 Code objects).
|
9338
9770
|
*/
|
9339
|
-
|
9340
|
-
V8_DEPRECATED("Use entry_stubs + code_pages version.")
|
9341
|
-
UnwindState GetUnwindState();
|
9771
|
+
void GetEmbeddedCodeRange(const void** start, size_t* length_in_bytes);
|
9342
9772
|
|
9343
9773
|
/**
|
9344
9774
|
* Returns the JSEntryStubs necessary for use with the Unwinder API.
|
@@ -9398,12 +9828,14 @@ class V8_EXPORT Isolate {
|
|
9398
9828
|
* strings should be allowed.
|
9399
9829
|
*/
|
9400
9830
|
V8_DEPRECATED(
|
9401
|
-
"Use Isolate::SetModifyCodeGenerationFromStringsCallback
|
9402
|
-
"See
|
9403
|
-
|
9404
|
-
|
9831
|
+
"Use Isolate::SetModifyCodeGenerationFromStringsCallback with "
|
9832
|
+
"ModifyCodeGenerationFromStringsCallback2 instead. See "
|
9833
|
+
"http://crbug.com/1096017 and TC39 Dynamic Code Brand Checks proposal "
|
9834
|
+
"at https://github.com/tc39/proposal-dynamic-code-brand-checks.")
|
9405
9835
|
void SetModifyCodeGenerationFromStringsCallback(
|
9406
9836
|
ModifyCodeGenerationFromStringsCallback callback);
|
9837
|
+
void SetModifyCodeGenerationFromStringsCallback(
|
9838
|
+
ModifyCodeGenerationFromStringsCallback2 callback);
|
9407
9839
|
|
9408
9840
|
/**
|
9409
9841
|
* Set the callback to invoke to check if wasm code generation should
|
@@ -9421,12 +9853,22 @@ class V8_EXPORT Isolate {
|
|
9421
9853
|
|
9422
9854
|
void SetWasmStreamingCallback(WasmStreamingCallback callback);
|
9423
9855
|
|
9424
|
-
void SetWasmThreadsEnabledCallback(WasmThreadsEnabledCallback callback);
|
9425
|
-
|
9426
9856
|
void SetWasmLoadSourceMapCallback(WasmLoadSourceMapCallback callback);
|
9427
9857
|
|
9428
9858
|
void SetWasmSimdEnabledCallback(WasmSimdEnabledCallback callback);
|
9429
9859
|
|
9860
|
+
void SetWasmExceptionsEnabledCallback(WasmExceptionsEnabledCallback callback);
|
9861
|
+
|
9862
|
+
void SetSharedArrayBufferConstructorEnabledCallback(
|
9863
|
+
SharedArrayBufferConstructorEnabledCallback callback);
|
9864
|
+
|
9865
|
+
/**
|
9866
|
+
* This function can be called by the embedder to signal V8 that the dynamic
|
9867
|
+
* enabling of features has finished. V8 can now set up dynamically added
|
9868
|
+
* features.
|
9869
|
+
*/
|
9870
|
+
void InstallConditionalFeatures(Local<Context> context);
|
9871
|
+
|
9430
9872
|
/**
|
9431
9873
|
* Check if V8 is dead and therefore unusable. This is the case after
|
9432
9874
|
* fatal errors such as out-of-memory situations.
|
@@ -9589,7 +10031,7 @@ class V8_EXPORT StartupData {
|
|
9589
10031
|
* EntropySource is used as a callback function when v8 needs a source
|
9590
10032
|
* of entropy.
|
9591
10033
|
*/
|
9592
|
-
|
10034
|
+
using EntropySource = bool (*)(unsigned char* buffer, size_t length);
|
9593
10035
|
|
9594
10036
|
/**
|
9595
10037
|
* ReturnAddressLocationResolver is used as a callback function when v8 is
|
@@ -9604,9 +10046,8 @@ typedef bool (*EntropySource)(unsigned char* buffer, size_t length);
|
|
9604
10046
|
*
|
9605
10047
|
* \note The resolver function must not cause garbage collection.
|
9606
10048
|
*/
|
9607
|
-
|
9608
|
-
uintptr_t return_addr_location);
|
9609
|
-
|
10049
|
+
using ReturnAddressLocationResolver =
|
10050
|
+
uintptr_t (*)(uintptr_t return_addr_location);
|
9610
10051
|
|
9611
10052
|
/**
|
9612
10053
|
* Container class for static utility functions.
|
@@ -9760,7 +10201,7 @@ class V8_EXPORT V8 {
|
|
9760
10201
|
* \param context The third argument passed to the Linux signal handler, which
|
9761
10202
|
* points to a ucontext_t structure.
|
9762
10203
|
*/
|
9763
|
-
|
10204
|
+
V8_DEPRECATED("Use TryHandleWebAssemblyTrapPosix")
|
9764
10205
|
static bool TryHandleSignal(int signal_number, void* info, void* context);
|
9765
10206
|
#endif // V8_OS_POSIX
|
9766
10207
|
|
@@ -9791,6 +10232,15 @@ class V8_EXPORT V8 {
|
|
9791
10232
|
*/
|
9792
10233
|
static void GetSharedMemoryStatistics(SharedMemoryStatistics* statistics);
|
9793
10234
|
|
10235
|
+
/**
|
10236
|
+
* Notifies V8 that the process is cross-origin-isolated, which enables
|
10237
|
+
* defining the SharedArrayBuffer function on the global object of Contexts.
|
10238
|
+
*/
|
10239
|
+
V8_DEPRECATED(
|
10240
|
+
"Use the command line argument --enable-sharedarraybuffer-per-context "
|
10241
|
+
"together with SetSharedArrayBufferConstructorEnabledCallback")
|
10242
|
+
static void SetIsCrossOriginIsolated();
|
10243
|
+
|
9794
10244
|
private:
|
9795
10245
|
V8();
|
9796
10246
|
|
@@ -9840,6 +10290,8 @@ class V8_EXPORT V8 {
|
|
9840
10290
|
static void ToLocalEmpty();
|
9841
10291
|
static void InternalFieldOutOfBounds(int index);
|
9842
10292
|
template <class T>
|
10293
|
+
friend class BasicTracedReference;
|
10294
|
+
template <class T>
|
9843
10295
|
friend class Global;
|
9844
10296
|
template <class T> friend class Local;
|
9845
10297
|
template <class T>
|
@@ -9847,9 +10299,8 @@ class V8_EXPORT V8 {
|
|
9847
10299
|
template <class T>
|
9848
10300
|
friend class Maybe;
|
9849
10301
|
template <class T>
|
9850
|
-
friend class TracedReferenceBase;
|
9851
|
-
template <class T>
|
9852
10302
|
friend class TracedGlobal;
|
10303
|
+
friend class TracedReferenceBase;
|
9853
10304
|
template <class T>
|
9854
10305
|
friend class TracedReference;
|
9855
10306
|
template <class T>
|
@@ -10269,7 +10720,7 @@ class V8_EXPORT ExtensionConfiguration {
|
|
10269
10720
|
* A sandboxed execution context with its own set of built-in objects
|
10270
10721
|
* and functions.
|
10271
10722
|
*/
|
10272
|
-
class V8_EXPORT Context {
|
10723
|
+
class V8_EXPORT Context : public Data {
|
10273
10724
|
public:
|
10274
10725
|
/**
|
10275
10726
|
* Returns the global proxy object.
|
@@ -10484,8 +10935,8 @@ class V8_EXPORT Context {
|
|
10484
10935
|
* context, call the specified callback, and throw an exception.
|
10485
10936
|
* To unset abort, pass nullptr as callback.
|
10486
10937
|
*/
|
10487
|
-
|
10488
|
-
|
10938
|
+
using AbortScriptExecutionCallback = void (*)(Isolate* isolate,
|
10939
|
+
Local<Context> context);
|
10489
10940
|
void SetAbortScriptExecution(AbortScriptExecutionCallback callback);
|
10490
10941
|
|
10491
10942
|
/**
|
@@ -10500,11 +10951,23 @@ class V8_EXPORT Context {
|
|
10500
10951
|
*/
|
10501
10952
|
void SetContinuationPreservedEmbedderData(Local<Value> context);
|
10502
10953
|
|
10954
|
+
/**
|
10955
|
+
* Set or clear hooks to be invoked for promise lifecycle operations.
|
10956
|
+
* To clear a hook, set it to an empty v8::Function. Each function will
|
10957
|
+
* receive the observed promise as the first argument. If a chaining
|
10958
|
+
* operation is used on a promise, the init will additionally receive
|
10959
|
+
* the parent promise as the second argument.
|
10960
|
+
*/
|
10961
|
+
void SetPromiseHooks(Local<Function> init_hook,
|
10962
|
+
Local<Function> before_hook,
|
10963
|
+
Local<Function> after_hook,
|
10964
|
+
Local<Function> resolve_hook);
|
10965
|
+
|
10503
10966
|
/**
|
10504
10967
|
* Stack-allocated class which sets the execution context for all
|
10505
10968
|
* operations executed within a local scope.
|
10506
10969
|
*/
|
10507
|
-
class Scope {
|
10970
|
+
class V8_NODISCARD Scope {
|
10508
10971
|
public:
|
10509
10972
|
explicit V8_INLINE Scope(Local<Context> context) : context_(context) {
|
10510
10973
|
context_->Enter();
|
@@ -10520,7 +10983,7 @@ class V8_EXPORT Context {
|
|
10520
10983
|
* stack.
|
10521
10984
|
* https://html.spec.whatwg.org/multipage/webappapis.html#backup-incumbent-settings-object-stack
|
10522
10985
|
*/
|
10523
|
-
class V8_EXPORT BackupIncumbentScope final {
|
10986
|
+
class V8_EXPORT V8_NODISCARD BackupIncumbentScope final {
|
10524
10987
|
public:
|
10525
10988
|
/**
|
10526
10989
|
* |backup_incumbent_context| is pushed onto the backup incumbent settings
|
@@ -10546,18 +11009,21 @@ class V8_EXPORT Context {
|
|
10546
11009
|
const BackupIncumbentScope* prev_ = nullptr;
|
10547
11010
|
};
|
10548
11011
|
|
11012
|
+
V8_INLINE static Context* Cast(Data* data);
|
11013
|
+
|
10549
11014
|
private:
|
10550
11015
|
friend class Value;
|
10551
11016
|
friend class Script;
|
10552
11017
|
friend class Object;
|
10553
11018
|
friend class Function;
|
10554
11019
|
|
11020
|
+
static void CheckCast(Data* obj);
|
11021
|
+
|
10555
11022
|
internal::Address* GetDataFromSnapshotOnce(size_t index);
|
10556
11023
|
Local<Value> SlowGetEmbedderData(int index);
|
10557
11024
|
void* SlowGetAlignedPointerFromEmbedderData(int index);
|
10558
11025
|
};
|
10559
11026
|
|
10560
|
-
|
10561
11027
|
/**
|
10562
11028
|
* Multiple threads in V8 are allowed, but only one thread at a time is allowed
|
10563
11029
|
* to use any given V8 isolate, see the comments in the Isolate class. The
|
@@ -10700,12 +11166,14 @@ class V8_EXPORT Unwinder {
|
|
10700
11166
|
*
|
10701
11167
|
* The unwinder also needs the virtual memory range of all possible V8 code
|
10702
11168
|
* objects. There are two ranges required - the heap code range and the range
|
10703
|
-
* for code embedded in the binary.
|
10704
|
-
*
|
10705
|
-
*
|
10706
|
-
* |unwind_state| can be used for multiple calls.
|
11169
|
+
* for code embedded in the binary.
|
11170
|
+
*
|
11171
|
+
* Available on x64, ARM64 and ARM32.
|
10707
11172
|
*
|
10708
|
-
* \param
|
11173
|
+
* \param code_pages A list of all of the ranges in which V8 has allocated
|
11174
|
+
* executable code. The caller should obtain this list by calling
|
11175
|
+
* Isolate::CopyCodePages() during the same interrupt/thread suspension that
|
11176
|
+
* captures the stack.
|
10709
11177
|
* \param register_state The current registers. This is an in-out param that
|
10710
11178
|
* will be overwritten with the register values after unwinding, on success.
|
10711
11179
|
* \param stack_base The resulting stack pointer and frame pointer values are
|
@@ -10716,20 +11184,6 @@ class V8_EXPORT Unwinder {
|
|
10716
11184
|
*
|
10717
11185
|
* \return True on success.
|
10718
11186
|
*/
|
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
11187
|
static bool TryUnwindV8Frames(const JSEntryStubs& entry_stubs,
|
10734
11188
|
size_t code_pages_length,
|
10735
11189
|
const MemoryRange* code_pages,
|
@@ -10737,20 +11191,13 @@ class V8_EXPORT Unwinder {
|
|
10737
11191
|
const void* stack_base);
|
10738
11192
|
|
10739
11193
|
/**
|
10740
|
-
* Whether the PC is within the V8 code range represented by
|
10741
|
-
* embedded_code_range in |unwind_state|.
|
11194
|
+
* Whether the PC is within the V8 code range represented by code_pages.
|
10742
11195
|
*
|
10743
11196
|
* If this returns false, then calling UnwindV8Frames() with the same PC
|
10744
11197
|
* and unwind_state will always fail. If it returns true, then unwinding may
|
10745
11198
|
* (but not necessarily) be successful.
|
10746
|
-
|
10747
|
-
|
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.
|
11199
|
+
*
|
11200
|
+
* Available on x64, ARM64 and ARM32
|
10754
11201
|
*/
|
10755
11202
|
static bool PCIsInV8(size_t code_pages_length, const MemoryRange* code_pages,
|
10756
11203
|
void* pc);
|
@@ -10769,8 +11216,8 @@ Local<T> Local<T>::New(Isolate* isolate, const PersistentBase<T>& that) {
|
|
10769
11216
|
}
|
10770
11217
|
|
10771
11218
|
template <class T>
|
10772
|
-
Local<T> Local<T>::New(Isolate* isolate, const
|
10773
|
-
return New(isolate, that
|
11219
|
+
Local<T> Local<T>::New(Isolate* isolate, const BasicTracedReference<T>& that) {
|
11220
|
+
return New(isolate, *that);
|
10774
11221
|
}
|
10775
11222
|
|
10776
11223
|
template <class T>
|
@@ -10840,7 +11287,7 @@ void Persistent<T, M>::Copy(const Persistent<S, M2>& that) {
|
|
10840
11287
|
|
10841
11288
|
template <class T>
|
10842
11289
|
bool PersistentBase<T>::IsWeak() const {
|
10843
|
-
|
11290
|
+
using I = internal::Internals;
|
10844
11291
|
if (this->IsEmpty()) return false;
|
10845
11292
|
return I::GetNodeState(reinterpret_cast<internal::Address*>(this->val_)) ==
|
10846
11293
|
I::kNodeStateIsWeakValue;
|
@@ -10881,7 +11328,7 @@ template <typename P>
|
|
10881
11328
|
V8_INLINE void PersistentBase<T>::SetWeak(
|
10882
11329
|
P* parameter, typename WeakCallbackInfo<P>::Callback callback,
|
10883
11330
|
WeakCallbackType type) {
|
10884
|
-
|
11331
|
+
using Callback = WeakCallbackInfo<void>::Callback;
|
10885
11332
|
#if (__GNUC__ >= 8) && !defined(__clang__)
|
10886
11333
|
#pragma GCC diagnostic push
|
10887
11334
|
#pragma GCC diagnostic ignored "-Wcast-function-type"
|
@@ -10913,7 +11360,7 @@ void PersistentBase<T>::AnnotateStrongRetainer(const char* label) {
|
|
10913
11360
|
|
10914
11361
|
template <class T>
|
10915
11362
|
void PersistentBase<T>::SetWrapperClassId(uint16_t class_id) {
|
10916
|
-
|
11363
|
+
using I = internal::Internals;
|
10917
11364
|
if (this->IsEmpty()) return;
|
10918
11365
|
internal::Address* obj = reinterpret_cast<internal::Address*>(this->val_);
|
10919
11366
|
uint8_t* addr = reinterpret_cast<uint8_t*>(obj) + I::kNodeClassIdOffset;
|
@@ -10923,7 +11370,7 @@ void PersistentBase<T>::SetWrapperClassId(uint16_t class_id) {
|
|
10923
11370
|
|
10924
11371
|
template <class T>
|
10925
11372
|
uint16_t PersistentBase<T>::WrapperClassId() const {
|
10926
|
-
|
11373
|
+
using I = internal::Internals;
|
10927
11374
|
if (this->IsEmpty()) return 0;
|
10928
11375
|
internal::Address* obj = reinterpret_cast<internal::Address*>(this->val_);
|
10929
11376
|
uint8_t* addr = reinterpret_cast<uint8_t*>(obj) + I::kNodeClassIdOffset;
|
@@ -10957,23 +11404,69 @@ Global<T>& Global<T>::operator=(Global<S>&& rhs) {
|
|
10957
11404
|
}
|
10958
11405
|
|
10959
11406
|
template <class T>
|
10960
|
-
|
10961
|
-
|
11407
|
+
internal::Address* BasicTracedReference<T>::New(
|
11408
|
+
Isolate* isolate, T* that, void* slot, DestructionMode destruction_mode) {
|
10962
11409
|
if (that == nullptr) return nullptr;
|
10963
11410
|
internal::Address* p = reinterpret_cast<internal::Address*>(that);
|
10964
|
-
return
|
11411
|
+
return V8::GlobalizeTracedReference(
|
10965
11412
|
reinterpret_cast<internal::Isolate*>(isolate), p,
|
10966
11413
|
reinterpret_cast<internal::Address*>(slot),
|
10967
|
-
destruction_mode == kWithDestructor)
|
11414
|
+
destruction_mode == kWithDestructor);
|
10968
11415
|
}
|
10969
11416
|
|
10970
|
-
|
10971
|
-
void TracedReferenceBase<T>::Reset() {
|
11417
|
+
void TracedReferenceBase::Reset() {
|
10972
11418
|
if (IsEmpty()) return;
|
10973
11419
|
V8::DisposeTracedGlobal(reinterpret_cast<internal::Address*>(val_));
|
10974
11420
|
SetSlotThreadSafe(nullptr);
|
10975
11421
|
}
|
10976
11422
|
|
11423
|
+
v8::Local<v8::Value> TracedReferenceBase::Get(v8::Isolate* isolate) const {
|
11424
|
+
if (IsEmpty()) return Local<Value>();
|
11425
|
+
return Local<Value>::New(isolate, reinterpret_cast<Value*>(val_));
|
11426
|
+
}
|
11427
|
+
|
11428
|
+
V8_INLINE bool operator==(const TracedReferenceBase& lhs,
|
11429
|
+
const TracedReferenceBase& rhs) {
|
11430
|
+
v8::internal::Address* a = reinterpret_cast<v8::internal::Address*>(lhs.val_);
|
11431
|
+
v8::internal::Address* b = reinterpret_cast<v8::internal::Address*>(rhs.val_);
|
11432
|
+
if (a == nullptr) return b == nullptr;
|
11433
|
+
if (b == nullptr) return false;
|
11434
|
+
return *a == *b;
|
11435
|
+
}
|
11436
|
+
|
11437
|
+
template <typename U>
|
11438
|
+
V8_INLINE bool operator==(const TracedReferenceBase& lhs,
|
11439
|
+
const v8::Local<U>& rhs) {
|
11440
|
+
v8::internal::Address* a = reinterpret_cast<v8::internal::Address*>(lhs.val_);
|
11441
|
+
v8::internal::Address* b = reinterpret_cast<v8::internal::Address*>(*rhs);
|
11442
|
+
if (a == nullptr) return b == nullptr;
|
11443
|
+
if (b == nullptr) return false;
|
11444
|
+
return *a == *b;
|
11445
|
+
}
|
11446
|
+
|
11447
|
+
template <typename U>
|
11448
|
+
V8_INLINE bool operator==(const v8::Local<U>& lhs,
|
11449
|
+
const TracedReferenceBase& rhs) {
|
11450
|
+
return rhs == lhs;
|
11451
|
+
}
|
11452
|
+
|
11453
|
+
V8_INLINE bool operator!=(const TracedReferenceBase& lhs,
|
11454
|
+
const TracedReferenceBase& rhs) {
|
11455
|
+
return !(lhs == rhs);
|
11456
|
+
}
|
11457
|
+
|
11458
|
+
template <typename U>
|
11459
|
+
V8_INLINE bool operator!=(const TracedReferenceBase& lhs,
|
11460
|
+
const v8::Local<U>& rhs) {
|
11461
|
+
return !(lhs == rhs);
|
11462
|
+
}
|
11463
|
+
|
11464
|
+
template <typename U>
|
11465
|
+
V8_INLINE bool operator!=(const v8::Local<U>& lhs,
|
11466
|
+
const TracedReferenceBase& rhs) {
|
11467
|
+
return !(rhs == lhs);
|
11468
|
+
}
|
11469
|
+
|
10977
11470
|
template <class T>
|
10978
11471
|
template <class S>
|
10979
11472
|
void TracedGlobal<T>::Reset(Isolate* isolate, const Local<S>& other) {
|
@@ -10981,7 +11474,7 @@ void TracedGlobal<T>::Reset(Isolate* isolate, const Local<S>& other) {
|
|
10981
11474
|
Reset();
|
10982
11475
|
if (other.IsEmpty()) return;
|
10983
11476
|
this->val_ = this->New(isolate, other.val_, &this->val_,
|
10984
|
-
|
11477
|
+
BasicTracedReference<T>::kWithDestructor);
|
10985
11478
|
}
|
10986
11479
|
|
10987
11480
|
template <class T>
|
@@ -11031,7 +11524,7 @@ void TracedReference<T>::Reset(Isolate* isolate, const Local<S>& other) {
|
|
11031
11524
|
if (other.IsEmpty()) return;
|
11032
11525
|
this->SetSlotThreadSafe(
|
11033
11526
|
this->New(isolate, other.val_, &this->val_,
|
11034
|
-
|
11527
|
+
BasicTracedReference<T>::kWithoutDestructor));
|
11035
11528
|
}
|
11036
11529
|
|
11037
11530
|
template <class T>
|
@@ -11074,18 +11567,16 @@ TracedReference<T>& TracedReference<T>::operator=(const TracedReference& rhs) {
|
|
11074
11567
|
return *this;
|
11075
11568
|
}
|
11076
11569
|
|
11077
|
-
|
11078
|
-
|
11079
|
-
typedef internal::Internals I;
|
11570
|
+
void TracedReferenceBase::SetWrapperClassId(uint16_t class_id) {
|
11571
|
+
using I = internal::Internals;
|
11080
11572
|
if (IsEmpty()) return;
|
11081
11573
|
internal::Address* obj = reinterpret_cast<internal::Address*>(val_);
|
11082
11574
|
uint8_t* addr = reinterpret_cast<uint8_t*>(obj) + I::kNodeClassIdOffset;
|
11083
11575
|
*reinterpret_cast<uint16_t*>(addr) = class_id;
|
11084
11576
|
}
|
11085
11577
|
|
11086
|
-
|
11087
|
-
|
11088
|
-
typedef internal::Internals I;
|
11578
|
+
uint16_t TracedReferenceBase::WrapperClassId() const {
|
11579
|
+
using I = internal::Internals;
|
11089
11580
|
if (IsEmpty()) return 0;
|
11090
11581
|
internal::Address* obj = reinterpret_cast<internal::Address*>(val_);
|
11091
11582
|
uint8_t* addr = reinterpret_cast<uint8_t*>(obj) + I::kNodeClassIdOffset;
|
@@ -11115,7 +11606,7 @@ void ReturnValue<T>::Set(const Global<S>& handle) {
|
|
11115
11606
|
|
11116
11607
|
template <typename T>
|
11117
11608
|
template <typename S>
|
11118
|
-
void ReturnValue<T>::Set(const
|
11609
|
+
void ReturnValue<T>::Set(const BasicTracedReference<S>& handle) {
|
11119
11610
|
static_assert(std::is_base_of<T, S>::value, "type check");
|
11120
11611
|
if (V8_UNLIKELY(handle.IsEmpty())) {
|
11121
11612
|
*value_ = GetDefaultValue();
|
@@ -11145,7 +11636,7 @@ void ReturnValue<T>::Set(double i) {
|
|
11145
11636
|
template<typename T>
|
11146
11637
|
void ReturnValue<T>::Set(int32_t i) {
|
11147
11638
|
static_assert(std::is_base_of<T, Integer>::value, "type check");
|
11148
|
-
|
11639
|
+
using I = internal::Internals;
|
11149
11640
|
if (V8_LIKELY(I::IsValidSmi(i))) {
|
11150
11641
|
*value_ = I::IntToSmi(i);
|
11151
11642
|
return;
|
@@ -11168,7 +11659,7 @@ void ReturnValue<T>::Set(uint32_t i) {
|
|
11168
11659
|
template<typename T>
|
11169
11660
|
void ReturnValue<T>::Set(bool value) {
|
11170
11661
|
static_assert(std::is_base_of<T, Boolean>::value, "type check");
|
11171
|
-
|
11662
|
+
using I = internal::Internals;
|
11172
11663
|
int root_index;
|
11173
11664
|
if (value) {
|
11174
11665
|
root_index = I::kTrueValueRootIndex;
|
@@ -11181,21 +11672,21 @@ void ReturnValue<T>::Set(bool value) {
|
|
11181
11672
|
template<typename T>
|
11182
11673
|
void ReturnValue<T>::SetNull() {
|
11183
11674
|
static_assert(std::is_base_of<T, Primitive>::value, "type check");
|
11184
|
-
|
11675
|
+
using I = internal::Internals;
|
11185
11676
|
*value_ = *I::GetRoot(GetIsolate(), I::kNullValueRootIndex);
|
11186
11677
|
}
|
11187
11678
|
|
11188
11679
|
template<typename T>
|
11189
11680
|
void ReturnValue<T>::SetUndefined() {
|
11190
11681
|
static_assert(std::is_base_of<T, Primitive>::value, "type check");
|
11191
|
-
|
11682
|
+
using I = internal::Internals;
|
11192
11683
|
*value_ = *I::GetRoot(GetIsolate(), I::kUndefinedValueRootIndex);
|
11193
11684
|
}
|
11194
11685
|
|
11195
11686
|
template<typename T>
|
11196
11687
|
void ReturnValue<T>::SetEmptyString() {
|
11197
11688
|
static_assert(std::is_base_of<T, String>::value, "type check");
|
11198
|
-
|
11689
|
+
using I = internal::Internals;
|
11199
11690
|
*value_ = *I::GetRoot(GetIsolate(), I::kEmptyStringRootIndex);
|
11200
11691
|
}
|
11201
11692
|
|
@@ -11207,7 +11698,7 @@ Isolate* ReturnValue<T>::GetIsolate() const {
|
|
11207
11698
|
|
11208
11699
|
template <typename T>
|
11209
11700
|
Local<Value> ReturnValue<T>::Get() const {
|
11210
|
-
|
11701
|
+
using I = internal::Internals;
|
11211
11702
|
if (*value_ == *I::GetRoot(GetIsolate(), I::kTheHoleValueRootIndex))
|
11212
11703
|
return Local<Value>(*Undefined(GetIsolate()));
|
11213
11704
|
return Local<Value>::New(GetIsolate(), reinterpret_cast<Value*>(value_));
|
@@ -11235,22 +11726,14 @@ template<typename T>
|
|
11235
11726
|
Local<Value> FunctionCallbackInfo<T>::operator[](int i) const {
|
11236
11727
|
// values_ points to the first argument (not the receiver).
|
11237
11728
|
if (i < 0 || length_ <= i) return Local<Value>(*Undefined(GetIsolate()));
|
11238
|
-
#ifdef V8_REVERSE_JSARGS
|
11239
11729
|
return Local<Value>(reinterpret_cast<Value*>(values_ + i));
|
11240
|
-
#else
|
11241
|
-
return Local<Value>(reinterpret_cast<Value*>(values_ - i));
|
11242
|
-
#endif
|
11243
11730
|
}
|
11244
11731
|
|
11245
11732
|
|
11246
11733
|
template<typename T>
|
11247
11734
|
Local<Object> FunctionCallbackInfo<T>::This() const {
|
11248
11735
|
// values_ points to the first argument (not the receiver).
|
11249
|
-
#ifdef V8_REVERSE_JSARGS
|
11250
11736
|
return Local<Object>(reinterpret_cast<Object*>(values_ - 1));
|
11251
|
-
#else
|
11252
|
-
return Local<Object>(reinterpret_cast<Object*>(values_ + 1));
|
11253
|
-
#endif
|
11254
11737
|
}
|
11255
11738
|
|
11256
11739
|
|
@@ -11295,23 +11778,48 @@ int FunctionCallbackInfo<T>::Length() const {
|
|
11295
11778
|
return length_;
|
11296
11779
|
}
|
11297
11780
|
|
11298
|
-
ScriptOrigin::ScriptOrigin(
|
11299
|
-
|
11300
|
-
|
11301
|
-
|
11302
|
-
|
11303
|
-
|
11304
|
-
|
11305
|
-
|
11781
|
+
ScriptOrigin::ScriptOrigin(
|
11782
|
+
Local<Value> resource_name, Local<Integer> line_offset,
|
11783
|
+
Local<Integer> column_offset, Local<Boolean> is_shared_cross_origin,
|
11784
|
+
Local<Integer> script_id, Local<Value> source_map_url,
|
11785
|
+
Local<Boolean> is_opaque, Local<Boolean> is_wasm, Local<Boolean> is_module,
|
11786
|
+
Local<PrimitiveArray> host_defined_options)
|
11787
|
+
: ScriptOrigin(
|
11788
|
+
Isolate::GetCurrent(), resource_name,
|
11789
|
+
line_offset.IsEmpty() ? 0 : static_cast<int>(line_offset->Value()),
|
11790
|
+
column_offset.IsEmpty() ? 0
|
11791
|
+
: static_cast<int>(column_offset->Value()),
|
11792
|
+
!is_shared_cross_origin.IsEmpty() && is_shared_cross_origin->IsTrue(),
|
11793
|
+
static_cast<int>(script_id.IsEmpty() ? -1 : script_id->Value()),
|
11794
|
+
source_map_url, !is_opaque.IsEmpty() && is_opaque->IsTrue(),
|
11795
|
+
!is_wasm.IsEmpty() && is_wasm->IsTrue(),
|
11796
|
+
!is_module.IsEmpty() && is_module->IsTrue(), host_defined_options) {}
|
11797
|
+
|
11798
|
+
ScriptOrigin::ScriptOrigin(Local<Value> resource_name, int line_offset,
|
11799
|
+
int column_offset, bool is_shared_cross_origin,
|
11800
|
+
int script_id, Local<Value> source_map_url,
|
11801
|
+
bool is_opaque, bool is_wasm, bool is_module,
|
11802
|
+
Local<PrimitiveArray> host_defined_options)
|
11803
|
+
: isolate_(Isolate::GetCurrent()),
|
11804
|
+
resource_name_(resource_name),
|
11805
|
+
resource_line_offset_(line_offset),
|
11806
|
+
resource_column_offset_(column_offset),
|
11807
|
+
options_(is_shared_cross_origin, is_opaque, is_wasm, is_module),
|
11808
|
+
script_id_(script_id),
|
11809
|
+
source_map_url_(source_map_url),
|
11810
|
+
host_defined_options_(host_defined_options) {}
|
11811
|
+
|
11812
|
+
ScriptOrigin::ScriptOrigin(Isolate* isolate, Local<Value> resource_name,
|
11813
|
+
int line_offset, int column_offset,
|
11814
|
+
bool is_shared_cross_origin, int script_id,
|
11815
|
+
Local<Value> source_map_url, bool is_opaque,
|
11816
|
+
bool is_wasm, bool is_module,
|
11306
11817
|
Local<PrimitiveArray> host_defined_options)
|
11307
|
-
:
|
11308
|
-
|
11309
|
-
|
11310
|
-
|
11311
|
-
|
11312
|
-
!resource_is_opaque.IsEmpty() && resource_is_opaque->IsTrue(),
|
11313
|
-
!is_wasm.IsEmpty() && is_wasm->IsTrue(),
|
11314
|
-
!is_module.IsEmpty() && is_module->IsTrue()),
|
11818
|
+
: isolate_(isolate),
|
11819
|
+
resource_name_(resource_name),
|
11820
|
+
resource_line_offset_(line_offset),
|
11821
|
+
resource_column_offset_(column_offset),
|
11822
|
+
options_(is_shared_cross_origin, is_opaque, is_wasm, is_module),
|
11315
11823
|
script_id_(script_id),
|
11316
11824
|
source_map_url_(source_map_url),
|
11317
11825
|
host_defined_options_(host_defined_options) {}
|
@@ -11323,17 +11831,22 @@ Local<PrimitiveArray> ScriptOrigin::HostDefinedOptions() const {
|
|
11323
11831
|
}
|
11324
11832
|
|
11325
11833
|
Local<Integer> ScriptOrigin::ResourceLineOffset() const {
|
11326
|
-
return resource_line_offset_;
|
11834
|
+
return v8::Integer::New(isolate_, resource_line_offset_);
|
11327
11835
|
}
|
11328
11836
|
|
11329
|
-
|
11330
11837
|
Local<Integer> ScriptOrigin::ResourceColumnOffset() const {
|
11331
|
-
return resource_column_offset_;
|
11838
|
+
return v8::Integer::New(isolate_, resource_column_offset_);
|
11332
11839
|
}
|
11333
11840
|
|
11841
|
+
Local<Integer> ScriptOrigin::ScriptID() const {
|
11842
|
+
return v8::Integer::New(isolate_, script_id_);
|
11843
|
+
}
|
11844
|
+
|
11845
|
+
int ScriptOrigin::LineOffset() const { return resource_line_offset_; }
|
11334
11846
|
|
11335
|
-
|
11847
|
+
int ScriptOrigin::ColumnOffset() const { return resource_column_offset_; }
|
11336
11848
|
|
11849
|
+
int ScriptOrigin::ScriptId() const { return script_id_; }
|
11337
11850
|
|
11338
11851
|
Local<Value> ScriptOrigin::SourceMapUrl() const { return source_map_url_; }
|
11339
11852
|
|
@@ -11341,8 +11854,8 @@ ScriptCompiler::Source::Source(Local<String> string, const ScriptOrigin& origin,
|
|
11341
11854
|
CachedData* data)
|
11342
11855
|
: source_string(string),
|
11343
11856
|
resource_name(origin.ResourceName()),
|
11344
|
-
resource_line_offset(origin.
|
11345
|
-
resource_column_offset(origin.
|
11857
|
+
resource_line_offset(origin.LineOffset()),
|
11858
|
+
resource_column_offset(origin.ColumnOffset()),
|
11346
11859
|
resource_options(origin.Options()),
|
11347
11860
|
source_map_url(origin.SourceMapUrl()),
|
11348
11861
|
host_defined_options(origin.HostDefinedOptions()),
|
@@ -11407,8 +11920,8 @@ AccessorSignature* AccessorSignature::Cast(Data* data) {
|
|
11407
11920
|
|
11408
11921
|
Local<Value> Object::GetInternalField(int index) {
|
11409
11922
|
#ifndef V8_ENABLE_CHECKS
|
11410
|
-
|
11411
|
-
|
11923
|
+
using A = internal::Address;
|
11924
|
+
using I = internal::Internals;
|
11412
11925
|
A obj = *reinterpret_cast<A*>(this);
|
11413
11926
|
// Fast path: If the object is a plain JSObject, which is the common case, we
|
11414
11927
|
// know where to find the internal fields and can return the value directly.
|
@@ -11435,8 +11948,8 @@ Local<Value> Object::GetInternalField(int index) {
|
|
11435
11948
|
|
11436
11949
|
void* Object::GetAlignedPointerFromInternalField(int index) {
|
11437
11950
|
#ifndef V8_ENABLE_CHECKS
|
11438
|
-
|
11439
|
-
|
11951
|
+
using A = internal::Address;
|
11952
|
+
using I = internal::Internals;
|
11440
11953
|
A obj = *reinterpret_cast<A*>(this);
|
11441
11954
|
// Fast path: If the object is a plain JSObject, which is the common case, we
|
11442
11955
|
// know where to find the internal fields and can return the value directly.
|
@@ -11445,25 +11958,28 @@ void* Object::GetAlignedPointerFromInternalField(int index) {
|
|
11445
11958
|
instance_type == I::kJSApiObjectType ||
|
11446
11959
|
instance_type == I::kJSSpecialApiObjectType)) {
|
11447
11960
|
int offset = I::kJSObjectHeaderSize + (I::kEmbedderDataSlotSize * index);
|
11961
|
+
#ifdef V8_HEAP_SANDBOX
|
11962
|
+
offset += I::kEmbedderDataSlotRawPayloadOffset;
|
11963
|
+
#endif
|
11448
11964
|
internal::Isolate* isolate = I::GetIsolateForHeapSandbox(obj);
|
11449
|
-
A value = I::ReadExternalPointerField(
|
11965
|
+
A value = I::ReadExternalPointerField(
|
11966
|
+
isolate, obj, offset, internal::kEmbedderDataSlotPayloadTag);
|
11450
11967
|
return reinterpret_cast<void*>(value);
|
11451
11968
|
}
|
11452
11969
|
#endif
|
11453
11970
|
return SlowGetAlignedPointerFromInternalField(index);
|
11454
11971
|
}
|
11455
11972
|
|
11456
|
-
String* String::Cast(v8::
|
11973
|
+
String* String::Cast(v8::Data* data) {
|
11457
11974
|
#ifdef V8_ENABLE_CHECKS
|
11458
|
-
CheckCast(
|
11975
|
+
CheckCast(data);
|
11459
11976
|
#endif
|
11460
|
-
return static_cast<String*>(
|
11977
|
+
return static_cast<String*>(data);
|
11461
11978
|
}
|
11462
11979
|
|
11463
|
-
|
11464
11980
|
Local<String> String::Empty(Isolate* isolate) {
|
11465
|
-
|
11466
|
-
|
11981
|
+
using S = internal::Address;
|
11982
|
+
using I = internal::Internals;
|
11467
11983
|
I::CheckInitialized(isolate);
|
11468
11984
|
S* slot = I::GetRoot(isolate, I::kEmptyStringRootIndex);
|
11469
11985
|
return Local<String>(reinterpret_cast<String*>(slot));
|
@@ -11471,15 +11987,16 @@ Local<String> String::Empty(Isolate* isolate) {
|
|
11471
11987
|
|
11472
11988
|
|
11473
11989
|
String::ExternalStringResource* String::GetExternalStringResource() const {
|
11474
|
-
|
11475
|
-
|
11990
|
+
using A = internal::Address;
|
11991
|
+
using I = internal::Internals;
|
11476
11992
|
A obj = *reinterpret_cast<const A*>(this);
|
11477
11993
|
|
11478
11994
|
ExternalStringResource* result;
|
11479
11995
|
if (I::IsExternalTwoByteString(I::GetInstanceType(obj))) {
|
11480
11996
|
internal::Isolate* isolate = I::GetIsolateForHeapSandbox(obj);
|
11481
11997
|
A value =
|
11482
|
-
I::ReadExternalPointerField(isolate, obj, I::kStringResourceOffset
|
11998
|
+
I::ReadExternalPointerField(isolate, obj, I::kStringResourceOffset,
|
11999
|
+
internal::kExternalStringResourceTag);
|
11483
12000
|
result = reinterpret_cast<String::ExternalStringResource*>(value);
|
11484
12001
|
} else {
|
11485
12002
|
result = GetExternalStringResourceSlow();
|
@@ -11493,8 +12010,8 @@ String::ExternalStringResource* String::GetExternalStringResource() const {
|
|
11493
12010
|
|
11494
12011
|
String::ExternalStringResourceBase* String::GetExternalStringResourceBase(
|
11495
12012
|
String::Encoding* encoding_out) const {
|
11496
|
-
|
11497
|
-
|
12013
|
+
using A = internal::Address;
|
12014
|
+
using I = internal::Internals;
|
11498
12015
|
A obj = *reinterpret_cast<const A*>(this);
|
11499
12016
|
int type = I::GetInstanceType(obj) & I::kFullStringRepresentationMask;
|
11500
12017
|
*encoding_out = static_cast<Encoding>(type & I::kStringEncodingMask);
|
@@ -11503,7 +12020,8 @@ String::ExternalStringResourceBase* String::GetExternalStringResourceBase(
|
|
11503
12020
|
type == I::kExternalTwoByteRepresentationTag) {
|
11504
12021
|
internal::Isolate* isolate = I::GetIsolateForHeapSandbox(obj);
|
11505
12022
|
A value =
|
11506
|
-
I::ReadExternalPointerField(isolate, obj, I::kStringResourceOffset
|
12023
|
+
I::ReadExternalPointerField(isolate, obj, I::kStringResourceOffset,
|
12024
|
+
internal::kExternalStringResourceTag);
|
11507
12025
|
resource = reinterpret_cast<ExternalStringResourceBase*>(value);
|
11508
12026
|
} else {
|
11509
12027
|
resource = GetExternalStringResourceBaseSlow(encoding_out);
|
@@ -11524,8 +12042,8 @@ bool Value::IsUndefined() const {
|
|
11524
12042
|
}
|
11525
12043
|
|
11526
12044
|
bool Value::QuickIsUndefined() const {
|
11527
|
-
|
11528
|
-
|
12045
|
+
using A = internal::Address;
|
12046
|
+
using I = internal::Internals;
|
11529
12047
|
A obj = *reinterpret_cast<const A*>(this);
|
11530
12048
|
if (!I::HasHeapObjectTag(obj)) return false;
|
11531
12049
|
if (I::GetInstanceType(obj) != I::kOddballType) return false;
|
@@ -11542,8 +12060,8 @@ bool Value::IsNull() const {
|
|
11542
12060
|
}
|
11543
12061
|
|
11544
12062
|
bool Value::QuickIsNull() const {
|
11545
|
-
|
11546
|
-
|
12063
|
+
using A = internal::Address;
|
12064
|
+
using I = internal::Internals;
|
11547
12065
|
A obj = *reinterpret_cast<const A*>(this);
|
11548
12066
|
if (!I::HasHeapObjectTag(obj)) return false;
|
11549
12067
|
if (I::GetInstanceType(obj) != I::kOddballType) return false;
|
@@ -11559,8 +12077,8 @@ bool Value::IsNullOrUndefined() const {
|
|
11559
12077
|
}
|
11560
12078
|
|
11561
12079
|
bool Value::QuickIsNullOrUndefined() const {
|
11562
|
-
|
11563
|
-
|
12080
|
+
using A = internal::Address;
|
12081
|
+
using I = internal::Internals;
|
11564
12082
|
A obj = *reinterpret_cast<const A*>(this);
|
11565
12083
|
if (!I::HasHeapObjectTag(obj)) return false;
|
11566
12084
|
if (I::GetInstanceType(obj) != I::kOddballType) return false;
|
@@ -11577,8 +12095,8 @@ bool Value::IsString() const {
|
|
11577
12095
|
}
|
11578
12096
|
|
11579
12097
|
bool Value::QuickIsString() const {
|
11580
|
-
|
11581
|
-
|
12098
|
+
using A = internal::Address;
|
12099
|
+
using I = internal::Internals;
|
11582
12100
|
A obj = *reinterpret_cast<const A*>(this);
|
11583
12101
|
if (!I::HasHeapObjectTag(obj)) return false;
|
11584
12102
|
return (I::GetInstanceType(obj) < I::kFirstNonstringType);
|
@@ -11589,30 +12107,34 @@ template <class T> Value* Value::Cast(T* value) {
|
|
11589
12107
|
return static_cast<Value*>(value);
|
11590
12108
|
}
|
11591
12109
|
|
11592
|
-
|
11593
|
-
|
12110
|
+
template <>
|
12111
|
+
V8_INLINE Value* Value::Cast(Data* value) {
|
11594
12112
|
#ifdef V8_ENABLE_CHECKS
|
11595
12113
|
CheckCast(value);
|
11596
12114
|
#endif
|
11597
|
-
return static_cast<
|
12115
|
+
return static_cast<Value*>(value);
|
11598
12116
|
}
|
11599
12117
|
|
11600
|
-
|
11601
|
-
Name* Name::Cast(v8::Value* value) {
|
12118
|
+
Boolean* Boolean::Cast(v8::Data* data) {
|
11602
12119
|
#ifdef V8_ENABLE_CHECKS
|
11603
|
-
CheckCast(
|
12120
|
+
CheckCast(data);
|
11604
12121
|
#endif
|
11605
|
-
return static_cast<
|
12122
|
+
return static_cast<Boolean*>(data);
|
11606
12123
|
}
|
11607
12124
|
|
11608
|
-
|
11609
|
-
Symbol* Symbol::Cast(v8::Value* value) {
|
12125
|
+
Name* Name::Cast(v8::Data* data) {
|
11610
12126
|
#ifdef V8_ENABLE_CHECKS
|
11611
|
-
CheckCast(
|
12127
|
+
CheckCast(data);
|
11612
12128
|
#endif
|
11613
|
-
return static_cast<
|
12129
|
+
return static_cast<Name*>(data);
|
11614
12130
|
}
|
11615
12131
|
|
12132
|
+
Symbol* Symbol::Cast(v8::Data* data) {
|
12133
|
+
#ifdef V8_ENABLE_CHECKS
|
12134
|
+
CheckCast(data);
|
12135
|
+
#endif
|
12136
|
+
return static_cast<Symbol*>(data);
|
12137
|
+
}
|
11616
12138
|
|
11617
12139
|
Private* Private::Cast(Data* data) {
|
11618
12140
|
#ifdef V8_ENABLE_CHECKS
|
@@ -11621,43 +12143,60 @@ Private* Private::Cast(Data* data) {
|
|
11621
12143
|
return reinterpret_cast<Private*>(data);
|
11622
12144
|
}
|
11623
12145
|
|
11624
|
-
|
11625
|
-
Number* Number::Cast(v8::Value* value) {
|
12146
|
+
ModuleRequest* ModuleRequest::Cast(Data* data) {
|
11626
12147
|
#ifdef V8_ENABLE_CHECKS
|
11627
|
-
CheckCast(
|
12148
|
+
CheckCast(data);
|
11628
12149
|
#endif
|
11629
|
-
return
|
12150
|
+
return reinterpret_cast<ModuleRequest*>(data);
|
11630
12151
|
}
|
11631
12152
|
|
12153
|
+
Module* Module::Cast(Data* data) {
|
12154
|
+
#ifdef V8_ENABLE_CHECKS
|
12155
|
+
CheckCast(data);
|
12156
|
+
#endif
|
12157
|
+
return reinterpret_cast<Module*>(data);
|
12158
|
+
}
|
11632
12159
|
|
11633
|
-
|
12160
|
+
Number* Number::Cast(v8::Data* data) {
|
11634
12161
|
#ifdef V8_ENABLE_CHECKS
|
11635
|
-
CheckCast(
|
12162
|
+
CheckCast(data);
|
11636
12163
|
#endif
|
11637
|
-
return static_cast<
|
12164
|
+
return static_cast<Number*>(data);
|
11638
12165
|
}
|
11639
12166
|
|
12167
|
+
Integer* Integer::Cast(v8::Data* data) {
|
12168
|
+
#ifdef V8_ENABLE_CHECKS
|
12169
|
+
CheckCast(data);
|
12170
|
+
#endif
|
12171
|
+
return static_cast<Integer*>(data);
|
12172
|
+
}
|
11640
12173
|
|
11641
|
-
Int32* Int32::Cast(v8::
|
12174
|
+
Int32* Int32::Cast(v8::Data* data) {
|
11642
12175
|
#ifdef V8_ENABLE_CHECKS
|
11643
|
-
CheckCast(
|
12176
|
+
CheckCast(data);
|
11644
12177
|
#endif
|
11645
|
-
return static_cast<Int32*>(
|
12178
|
+
return static_cast<Int32*>(data);
|
11646
12179
|
}
|
11647
12180
|
|
12181
|
+
Uint32* Uint32::Cast(v8::Data* data) {
|
12182
|
+
#ifdef V8_ENABLE_CHECKS
|
12183
|
+
CheckCast(data);
|
12184
|
+
#endif
|
12185
|
+
return static_cast<Uint32*>(data);
|
12186
|
+
}
|
11648
12187
|
|
11649
|
-
|
12188
|
+
BigInt* BigInt::Cast(v8::Data* data) {
|
11650
12189
|
#ifdef V8_ENABLE_CHECKS
|
11651
|
-
CheckCast(
|
12190
|
+
CheckCast(data);
|
11652
12191
|
#endif
|
11653
|
-
return static_cast<
|
12192
|
+
return static_cast<BigInt*>(data);
|
11654
12193
|
}
|
11655
12194
|
|
11656
|
-
|
12195
|
+
Context* Context::Cast(v8::Data* data) {
|
11657
12196
|
#ifdef V8_ENABLE_CHECKS
|
11658
|
-
CheckCast(
|
12197
|
+
CheckCast(data);
|
11659
12198
|
#endif
|
11660
|
-
return static_cast<
|
12199
|
+
return static_cast<Context*>(data);
|
11661
12200
|
}
|
11662
12201
|
|
11663
12202
|
Date* Date::Cast(v8::Value* value) {
|
@@ -11761,6 +12300,13 @@ Proxy* Proxy::Cast(v8::Value* value) {
|
|
11761
12300
|
return static_cast<Proxy*>(value);
|
11762
12301
|
}
|
11763
12302
|
|
12303
|
+
WasmMemoryObject* WasmMemoryObject::Cast(v8::Value* value) {
|
12304
|
+
#ifdef V8_ENABLE_CHECKS
|
12305
|
+
CheckCast(value);
|
12306
|
+
#endif
|
12307
|
+
return static_cast<WasmMemoryObject*>(value);
|
12308
|
+
}
|
12309
|
+
|
11764
12310
|
WasmModuleObject* WasmModuleObject::Cast(v8::Value* value) {
|
11765
12311
|
#ifdef V8_ENABLE_CHECKS
|
11766
12312
|
CheckCast(value);
|
@@ -11948,7 +12494,7 @@ ReturnValue<T> PropertyCallbackInfo<T>::GetReturnValue() const {
|
|
11948
12494
|
|
11949
12495
|
template <typename T>
|
11950
12496
|
bool PropertyCallbackInfo<T>::ShouldThrowOnError() const {
|
11951
|
-
|
12497
|
+
using I = internal::Internals;
|
11952
12498
|
if (args_[kShouldThrowOnErrorIndex] !=
|
11953
12499
|
I::IntToSmi(I::kInferShouldThrowMode)) {
|
11954
12500
|
return args_[kShouldThrowOnErrorIndex] != I::IntToSmi(I::kDontThrow);
|
@@ -11958,8 +12504,8 @@ bool PropertyCallbackInfo<T>::ShouldThrowOnError() const {
|
|
11958
12504
|
}
|
11959
12505
|
|
11960
12506
|
Local<Primitive> Undefined(Isolate* isolate) {
|
11961
|
-
|
11962
|
-
|
12507
|
+
using S = internal::Address;
|
12508
|
+
using I = internal::Internals;
|
11963
12509
|
I::CheckInitialized(isolate);
|
11964
12510
|
S* slot = I::GetRoot(isolate, I::kUndefinedValueRootIndex);
|
11965
12511
|
return Local<Primitive>(reinterpret_cast<Primitive*>(slot));
|
@@ -11967,8 +12513,8 @@ Local<Primitive> Undefined(Isolate* isolate) {
|
|
11967
12513
|
|
11968
12514
|
|
11969
12515
|
Local<Primitive> Null(Isolate* isolate) {
|
11970
|
-
|
11971
|
-
|
12516
|
+
using S = internal::Address;
|
12517
|
+
using I = internal::Internals;
|
11972
12518
|
I::CheckInitialized(isolate);
|
11973
12519
|
S* slot = I::GetRoot(isolate, I::kNullValueRootIndex);
|
11974
12520
|
return Local<Primitive>(reinterpret_cast<Primitive*>(slot));
|
@@ -11976,8 +12522,8 @@ Local<Primitive> Null(Isolate* isolate) {
|
|
11976
12522
|
|
11977
12523
|
|
11978
12524
|
Local<Boolean> True(Isolate* isolate) {
|
11979
|
-
|
11980
|
-
|
12525
|
+
using S = internal::Address;
|
12526
|
+
using I = internal::Internals;
|
11981
12527
|
I::CheckInitialized(isolate);
|
11982
12528
|
S* slot = I::GetRoot(isolate, I::kTrueValueRootIndex);
|
11983
12529
|
return Local<Boolean>(reinterpret_cast<Boolean*>(slot));
|
@@ -11985,8 +12531,8 @@ Local<Boolean> True(Isolate* isolate) {
|
|
11985
12531
|
|
11986
12532
|
|
11987
12533
|
Local<Boolean> False(Isolate* isolate) {
|
11988
|
-
|
11989
|
-
|
12534
|
+
using S = internal::Address;
|
12535
|
+
using I = internal::Internals;
|
11990
12536
|
I::CheckInitialized(isolate);
|
11991
12537
|
S* slot = I::GetRoot(isolate, I::kFalseValueRootIndex);
|
11992
12538
|
return Local<Boolean>(reinterpret_cast<Boolean*>(slot));
|
@@ -11994,19 +12540,19 @@ Local<Boolean> False(Isolate* isolate) {
|
|
11994
12540
|
|
11995
12541
|
|
11996
12542
|
void Isolate::SetData(uint32_t slot, void* data) {
|
11997
|
-
|
12543
|
+
using I = internal::Internals;
|
11998
12544
|
I::SetEmbedderData(this, slot, data);
|
11999
12545
|
}
|
12000
12546
|
|
12001
12547
|
|
12002
12548
|
void* Isolate::GetData(uint32_t slot) {
|
12003
|
-
|
12549
|
+
using I = internal::Internals;
|
12004
12550
|
return I::GetEmbedderData(this, slot);
|
12005
12551
|
}
|
12006
12552
|
|
12007
12553
|
|
12008
12554
|
uint32_t Isolate::GetNumberOfDataSlots() {
|
12009
|
-
|
12555
|
+
using I = internal::Internals;
|
12010
12556
|
return I::kNumIsolateDataSlots;
|
12011
12557
|
}
|
12012
12558
|
|
@@ -12019,8 +12565,8 @@ MaybeLocal<T> Isolate::GetDataFromSnapshotOnce(size_t index) {
|
|
12019
12565
|
|
12020
12566
|
Local<Value> Context::GetEmbedderData(int index) {
|
12021
12567
|
#ifndef V8_ENABLE_CHECKS
|
12022
|
-
|
12023
|
-
|
12568
|
+
using A = internal::Address;
|
12569
|
+
using I = internal::Internals;
|
12024
12570
|
A ctx = *reinterpret_cast<const A*>(this);
|
12025
12571
|
A embedder_data =
|
12026
12572
|
I::ReadTaggedPointerField(ctx, I::kNativeContextEmbedderDataOffset);
|
@@ -12045,16 +12591,20 @@ Local<Value> Context::GetEmbedderData(int index) {
|
|
12045
12591
|
|
12046
12592
|
void* Context::GetAlignedPointerFromEmbedderData(int index) {
|
12047
12593
|
#ifndef V8_ENABLE_CHECKS
|
12048
|
-
|
12049
|
-
|
12594
|
+
using A = internal::Address;
|
12595
|
+
using I = internal::Internals;
|
12050
12596
|
A ctx = *reinterpret_cast<const A*>(this);
|
12051
12597
|
A embedder_data =
|
12052
12598
|
I::ReadTaggedPointerField(ctx, I::kNativeContextEmbedderDataOffset);
|
12053
12599
|
int value_offset =
|
12054
12600
|
I::kEmbedderDataArrayHeaderSize + (I::kEmbedderDataSlotSize * index);
|
12601
|
+
#ifdef V8_HEAP_SANDBOX
|
12602
|
+
value_offset += I::kEmbedderDataSlotRawPayloadOffset;
|
12603
|
+
#endif
|
12055
12604
|
internal::Isolate* isolate = I::GetIsolateForHeapSandbox(ctx);
|
12056
12605
|
return reinterpret_cast<void*>(
|
12057
|
-
I::ReadExternalPointerField(isolate, embedder_data, value_offset
|
12606
|
+
I::ReadExternalPointerField(isolate, embedder_data, value_offset,
|
12607
|
+
internal::kEmbedderDataSlotPayloadTag));
|
12058
12608
|
#else
|
12059
12609
|
return SlowGetAlignedPointerFromEmbedderData(index);
|
12060
12610
|
#endif
|