libv8 7.3.492.27.1-universal-darwin-17 → 8.4.255.0-universal-darwin-17
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/libv8/version.rb +1 -1
- data/vendor/v8/include/cppgc/allocation.h +124 -0
- data/vendor/v8/include/cppgc/garbage-collected.h +192 -0
- data/vendor/v8/include/cppgc/heap.h +50 -0
- data/vendor/v8/include/cppgc/internal/accessors.h +26 -0
- data/vendor/v8/include/cppgc/internal/api-constants.h +44 -0
- data/vendor/v8/include/cppgc/internal/compiler-specific.h +26 -0
- data/vendor/v8/include/cppgc/internal/finalizer-trait.h +90 -0
- data/vendor/v8/include/cppgc/internal/gc-info.h +43 -0
- data/vendor/v8/include/cppgc/internal/logging.h +50 -0
- data/vendor/v8/include/cppgc/internal/persistent-node.h +109 -0
- data/vendor/v8/include/cppgc/internal/pointer-policies.h +133 -0
- data/vendor/v8/include/cppgc/internal/prefinalizer-handler.h +31 -0
- data/vendor/v8/include/cppgc/liveness-broker.h +50 -0
- data/vendor/v8/include/cppgc/macros.h +26 -0
- data/vendor/v8/include/cppgc/member.h +206 -0
- data/vendor/v8/include/cppgc/persistent.h +304 -0
- data/vendor/v8/include/cppgc/platform.h +31 -0
- data/vendor/v8/include/cppgc/prefinalizer.h +54 -0
- data/vendor/v8/include/cppgc/source-location.h +59 -0
- data/vendor/v8/include/cppgc/trace-trait.h +67 -0
- data/vendor/v8/include/cppgc/type-traits.h +109 -0
- data/vendor/v8/include/cppgc/visitor.h +137 -0
- data/vendor/v8/include/libplatform/libplatform.h +13 -19
- data/vendor/v8/include/libplatform/v8-tracing.h +50 -15
- data/vendor/v8/include/v8-fast-api-calls.h +412 -0
- data/vendor/v8/include/v8-inspector-protocol.h +4 -4
- data/vendor/v8/include/v8-inspector.h +60 -29
- data/vendor/v8/include/v8-internal.h +98 -82
- data/vendor/v8/include/v8-platform.h +181 -42
- data/vendor/v8/include/v8-profiler.h +162 -224
- data/vendor/v8/include/v8-util.h +1 -13
- data/vendor/v8/include/v8-version-string.h +1 -1
- data/vendor/v8/include/v8-version.h +4 -4
- data/vendor/v8/include/v8-wasm-trap-handler-posix.h +1 -1
- data/vendor/v8/include/v8-wasm-trap-handler-win.h +1 -1
- data/vendor/v8/include/v8.h +1990 -611
- data/vendor/v8/include/v8config.h +129 -48
- data/vendor/v8/out.gn/libv8/obj/libv8_libbase.a +0 -0
- data/vendor/v8/out.gn/libv8/obj/libv8_libplatform.a +0 -0
- data/vendor/v8/out.gn/libv8/obj/libv8_monolith.a +0 -0
- data/vendor/v8/out.gn/libv8/obj/third_party/icu/libicui18n.a +0 -0
- data/vendor/v8/out.gn/libv8/obj/third_party/icu/libicuuc.a +0 -0
- data/vendor/v8/out.gn/libv8/obj/third_party/zlib/google/libcompression_utils_portable.a +0 -0
- data/vendor/v8/out.gn/libv8/obj/third_party/zlib/libchrome_zlib.a +0 -0
- metadata +34 -8
- data/vendor/v8/include/v8-testing.h +0 -48
data/vendor/v8/include/v8-util.h
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
#ifndef V8_UTIL_H_
|
6
6
|
#define V8_UTIL_H_
|
7
7
|
|
8
|
-
#include "v8.h" // NOLINT(build/
|
8
|
+
#include "v8.h" // NOLINT(build/include_directory)
|
9
9
|
#include <assert.h>
|
10
10
|
#include <map>
|
11
11
|
#include <vector>
|
@@ -194,17 +194,6 @@ class PersistentValueMapBase {
|
|
194
194
|
return SetReturnValueFromVal(&returnValue, Traits::Get(&impl_, key));
|
195
195
|
}
|
196
196
|
|
197
|
-
/**
|
198
|
-
* Call V8::RegisterExternallyReferencedObject with the map value for given
|
199
|
-
* key.
|
200
|
-
*/
|
201
|
-
void RegisterExternallyReferencedObject(K& key) {
|
202
|
-
assert(Contains(key));
|
203
|
-
V8::RegisterExternallyReferencedObject(
|
204
|
-
reinterpret_cast<internal::Address*>(FromVal(Traits::Get(&impl_, key))),
|
205
|
-
reinterpret_cast<internal::Isolate*>(GetIsolate()));
|
206
|
-
}
|
207
|
-
|
208
197
|
/**
|
209
198
|
* Return value for key and remove it from the map.
|
210
199
|
*/
|
@@ -355,7 +344,6 @@ class PersistentValueMapBase {
|
|
355
344
|
const char* label_;
|
356
345
|
};
|
357
346
|
|
358
|
-
|
359
347
|
template <typename K, typename V, typename Traits>
|
360
348
|
class PersistentValueMap : public PersistentValueMapBase<K, V, Traits> {
|
361
349
|
public:
|
@@ -5,7 +5,7 @@
|
|
5
5
|
#ifndef V8_VERSION_STRING_H_
|
6
6
|
#define V8_VERSION_STRING_H_
|
7
7
|
|
8
|
-
#include "v8-version.h" // NOLINT(build/
|
8
|
+
#include "v8-version.h" // NOLINT(build/include_directory)
|
9
9
|
|
10
10
|
// This is here rather than v8-version.h to keep that file simple and
|
11
11
|
// machine-processable.
|
@@ -8,10 +8,10 @@
|
|
8
8
|
// These macros define the version number for the current version.
|
9
9
|
// NOTE these macros are used by some of the tool scripts and the build
|
10
10
|
// system so their names cannot be changed without changing the scripts.
|
11
|
-
#define V8_MAJOR_VERSION
|
12
|
-
#define V8_MINOR_VERSION
|
13
|
-
#define V8_BUILD_NUMBER
|
14
|
-
#define V8_PATCH_LEVEL
|
11
|
+
#define V8_MAJOR_VERSION 8
|
12
|
+
#define V8_MINOR_VERSION 4
|
13
|
+
#define V8_BUILD_NUMBER 255
|
14
|
+
#define V8_PATCH_LEVEL 0
|
15
15
|
|
16
16
|
// Use 1 for candidates and 0 otherwise.
|
17
17
|
// (Boolean macro values are not supported by all preprocessors.)
|
data/vendor/v8/include/v8.h
CHANGED
@@ -9,7 +9,7 @@
|
|
9
9
|
* This set of documents provides reference material generated from the
|
10
10
|
* V8 header file, include/v8.h.
|
11
11
|
*
|
12
|
-
* For other documentation see
|
12
|
+
* For other documentation see https://v8.dev/.
|
13
13
|
*/
|
14
14
|
|
15
15
|
#ifndef INCLUDE_V8_H_
|
@@ -19,12 +19,14 @@
|
|
19
19
|
#include <stdint.h>
|
20
20
|
#include <stdio.h>
|
21
21
|
#include <memory>
|
22
|
+
#include <string>
|
23
|
+
#include <type_traits>
|
22
24
|
#include <utility>
|
23
25
|
#include <vector>
|
24
26
|
|
25
|
-
#include "v8-internal.h" // NOLINT(build/
|
26
|
-
#include "v8-version.h" // NOLINT(build/
|
27
|
-
#include "v8config.h" // NOLINT(build/
|
27
|
+
#include "v8-internal.h" // NOLINT(build/include_directory)
|
28
|
+
#include "v8-version.h" // NOLINT(build/include_directory)
|
29
|
+
#include "v8config.h" // NOLINT(build/include_directory)
|
28
30
|
|
29
31
|
// We reserve the V8_* prefix for macros defined in V8 public API and
|
30
32
|
// assume there are no name conflicts with the embedder's code.
|
@@ -54,6 +56,7 @@ class Integer;
|
|
54
56
|
class Isolate;
|
55
57
|
template <class T>
|
56
58
|
class Maybe;
|
59
|
+
class MicrotaskQueue;
|
57
60
|
class Name;
|
58
61
|
class Number;
|
59
62
|
class NumberObject;
|
@@ -92,6 +95,12 @@ template
|
|
92
95
|
class Persistent;
|
93
96
|
template <class T>
|
94
97
|
class Global;
|
98
|
+
template <class T>
|
99
|
+
class TracedGlobal;
|
100
|
+
template <class T>
|
101
|
+
class TracedReference;
|
102
|
+
template <class T>
|
103
|
+
class TracedReferenceBase;
|
95
104
|
template<class K, class V, class T> class PersistentValueMap;
|
96
105
|
template <class K, class V, class T>
|
97
106
|
class PersistentValueMapBase;
|
@@ -111,19 +120,23 @@ class EscapableHandleScope;
|
|
111
120
|
template<typename T> class ReturnValue;
|
112
121
|
|
113
122
|
namespace internal {
|
123
|
+
enum class ArgumentsType;
|
124
|
+
template <ArgumentsType>
|
114
125
|
class Arguments;
|
115
126
|
class DeferredHandles;
|
116
127
|
class Heap;
|
117
128
|
class HeapObject;
|
129
|
+
class ExternalString;
|
118
130
|
class Isolate;
|
119
131
|
class LocalEmbedderHeapTracer;
|
120
|
-
class
|
132
|
+
class MicrotaskQueue;
|
121
133
|
struct ScriptStreamingData;
|
122
134
|
template<typename T> class CustomArguments;
|
123
135
|
class PropertyCallbackArguments;
|
124
136
|
class FunctionCallbackArguments;
|
125
137
|
class GlobalHandles;
|
126
138
|
class ScopedExternalStringLock;
|
139
|
+
class ThreadLocalTop;
|
127
140
|
|
128
141
|
namespace wasm {
|
129
142
|
class NativeModule;
|
@@ -138,11 +151,6 @@ class ConsoleCallArguments;
|
|
138
151
|
|
139
152
|
// --- Handles ---
|
140
153
|
|
141
|
-
#define TYPE_CHECK(T, S) \
|
142
|
-
while (false) { \
|
143
|
-
*(static_cast<T* volatile*>(0)) = static_cast<S*>(0); \
|
144
|
-
}
|
145
|
-
|
146
154
|
/**
|
147
155
|
* An object reference managed by the v8 garbage collector.
|
148
156
|
*
|
@@ -186,7 +194,7 @@ class Local {
|
|
186
194
|
* handles. For example, converting from a Local<String> to a
|
187
195
|
* Local<Number>.
|
188
196
|
*/
|
189
|
-
|
197
|
+
static_assert(std::is_base_of<T, S>::value, "type check");
|
190
198
|
}
|
191
199
|
|
192
200
|
/**
|
@@ -205,9 +213,13 @@ class Local {
|
|
205
213
|
|
206
214
|
/**
|
207
215
|
* Checks whether two handles are the same.
|
208
|
-
* Returns true if both are empty, or if the objects
|
209
|
-
*
|
210
|
-
*
|
216
|
+
* Returns true if both are empty, or if the objects to which they refer
|
217
|
+
* are identical.
|
218
|
+
*
|
219
|
+
* If both handles refer to JS objects, this is the same as strict equality.
|
220
|
+
* For primitives, such as numbers or strings, a `false` return value does not
|
221
|
+
* indicate that the values aren't equal in the JavaScript sense.
|
222
|
+
* Use `Value::StrictEquals()` to check primitives for equality.
|
211
223
|
*/
|
212
224
|
template <class S>
|
213
225
|
V8_INLINE bool operator==(const Local<S>& that) const {
|
@@ -231,7 +243,11 @@ class Local {
|
|
231
243
|
* Checks whether two handles are different.
|
232
244
|
* Returns true if only one of the handles is empty, or if
|
233
245
|
* the objects to which they refer are different.
|
234
|
-
*
|
246
|
+
*
|
247
|
+
* If both handles refer to JS objects, this is the same as strict
|
248
|
+
* non-equality. For primitives, such as numbers or strings, a `true` return
|
249
|
+
* value does not indicate that the values aren't equal in the JavaScript
|
250
|
+
* sense. Use `Value::StrictEquals()` to check primitives for equality.
|
235
251
|
*/
|
236
252
|
template <class S>
|
237
253
|
V8_INLINE bool operator!=(const Local<S>& that) const {
|
@@ -275,6 +291,8 @@ class Local {
|
|
275
291
|
V8_INLINE static Local<T> New(Isolate* isolate, Local<T> that);
|
276
292
|
V8_INLINE static Local<T> New(Isolate* isolate,
|
277
293
|
const PersistentBase<T>& that);
|
294
|
+
V8_INLINE static Local<T> New(Isolate* isolate,
|
295
|
+
const TracedReferenceBase<T>& that);
|
278
296
|
|
279
297
|
private:
|
280
298
|
friend class Utils;
|
@@ -303,6 +321,14 @@ class Local {
|
|
303
321
|
template<class F1, class F2> friend class PersistentValueVector;
|
304
322
|
template <class F>
|
305
323
|
friend class ReturnValue;
|
324
|
+
template <class F>
|
325
|
+
friend class Traced;
|
326
|
+
template <class F>
|
327
|
+
friend class TracedGlobal;
|
328
|
+
template <class F>
|
329
|
+
friend class TracedReferenceBase;
|
330
|
+
template <class F>
|
331
|
+
friend class TracedReference;
|
306
332
|
|
307
333
|
explicit V8_INLINE Local(T* that) : val_(that) {}
|
308
334
|
V8_INLINE static Local<T> New(Isolate* isolate, T* that);
|
@@ -334,7 +360,7 @@ class MaybeLocal {
|
|
334
360
|
template <class S>
|
335
361
|
V8_INLINE MaybeLocal(Local<S> that)
|
336
362
|
: val_(reinterpret_cast<T*>(*that)) {
|
337
|
-
|
363
|
+
static_assert(std::is_base_of<T, S>::value, "type check");
|
338
364
|
}
|
339
365
|
|
340
366
|
V8_INLINE bool IsEmpty() const { return val_ == nullptr; }
|
@@ -503,11 +529,16 @@ template
|
|
503
529
|
}
|
504
530
|
|
505
531
|
/**
|
506
|
-
*
|
507
|
-
*
|
508
|
-
*
|
509
|
-
*
|
510
|
-
*
|
532
|
+
* Install a finalization callback on this object.
|
533
|
+
* NOTE: There is no guarantee as to *when* or even *if* the callback is
|
534
|
+
* invoked. The invocation is performed solely on a best effort basis.
|
535
|
+
* As always, GC-based finalization should *not* be relied upon for any
|
536
|
+
* critical form of resource management!
|
537
|
+
*
|
538
|
+
* The callback is supposed to reset the handle. No further V8 API may be
|
539
|
+
* called in this callback. In case additional work involving V8 needs to be
|
540
|
+
* done, a second callback can be scheduled using
|
541
|
+
* WeakCallbackInfo<void>::SetSecondPassCallback.
|
511
542
|
*/
|
512
543
|
template <typename P>
|
513
544
|
V8_INLINE void SetWeak(P* parameter,
|
@@ -537,47 +568,11 @@ template
|
|
537
568
|
*/
|
538
569
|
V8_INLINE void AnnotateStrongRetainer(const char* label);
|
539
570
|
|
540
|
-
/**
|
541
|
-
* Allows the embedder to tell the v8 garbage collector that a certain object
|
542
|
-
* is alive. Only allowed when the embedder is asked to trace its heap by
|
543
|
-
* EmbedderHeapTracer.
|
544
|
-
*/
|
545
|
-
V8_INLINE void RegisterExternalReference(Isolate* isolate) const;
|
546
|
-
|
547
|
-
/**
|
548
|
-
* Marks the reference to this object independent. Garbage collector is free
|
549
|
-
* to ignore any object groups containing this object. Weak callback for an
|
550
|
-
* independent handle should not assume that it will be preceded by a global
|
551
|
-
* GC prologue callback or followed by a global GC epilogue callback.
|
552
|
-
*/
|
553
|
-
V8_DEPRECATE_SOON(
|
554
|
-
"Objects are always considered independent. "
|
555
|
-
"Use MarkActive to avoid collecting otherwise dead weak handles.",
|
556
|
-
V8_INLINE void MarkIndependent());
|
557
|
-
|
558
|
-
/**
|
559
|
-
* Marks the reference to this object as active. The scavenge garbage
|
560
|
-
* collection should not reclaim the objects marked as active, even if the
|
561
|
-
* object held by the handle is otherwise unreachable.
|
562
|
-
*
|
563
|
-
* This bit is cleared after the each garbage collection pass.
|
564
|
-
*/
|
565
|
-
V8_INLINE void MarkActive();
|
566
|
-
|
567
|
-
V8_DEPRECATE_SOON("See MarkIndependent.",
|
568
|
-
V8_INLINE bool IsIndependent() const);
|
569
|
-
|
570
|
-
/** Checks if the handle holds the only reference to an object. */
|
571
|
-
V8_DEPRECATE_SOON(
|
572
|
-
"Garbage collection internal state should not be relied on.",
|
573
|
-
V8_INLINE bool IsNearDeath() const);
|
574
|
-
|
575
571
|
/** Returns true if the handle's reference is weak. */
|
576
572
|
V8_INLINE bool IsWeak() const;
|
577
573
|
|
578
574
|
/**
|
579
|
-
* Assigns a wrapper class ID to the handle.
|
580
|
-
* description in v8-profiler.h for details.
|
575
|
+
* Assigns a wrapper class ID to the handle.
|
581
576
|
*/
|
582
577
|
V8_INLINE void SetWrapperClassId(uint16_t class_id);
|
583
578
|
|
@@ -625,11 +620,8 @@ class NonCopyablePersistentTraits {
|
|
625
620
|
template<class S, class M>
|
626
621
|
V8_INLINE static void Copy(const Persistent<S, M>& source,
|
627
622
|
NonCopyablePersistent* dest) {
|
628
|
-
|
629
|
-
|
630
|
-
// TODO(dcarney): come up with a good compile error here.
|
631
|
-
template<class O> V8_INLINE static void Uncompilable() {
|
632
|
-
TYPE_CHECK(O, Primitive);
|
623
|
+
static_assert(sizeof(S) < 0,
|
624
|
+
"NonCopyablePersistentTraits::Copy is not instantiable");
|
633
625
|
}
|
634
626
|
};
|
635
627
|
|
@@ -672,7 +664,7 @@ template
|
|
672
664
|
template <class S>
|
673
665
|
V8_INLINE Persistent(Isolate* isolate, Local<S> that)
|
674
666
|
: PersistentBase<T>(PersistentBase<T>::New(isolate, *that)) {
|
675
|
-
|
667
|
+
static_assert(std::is_base_of<T, S>::value, "type check");
|
676
668
|
}
|
677
669
|
/**
|
678
670
|
* Construct a Persistent from a Persistent.
|
@@ -682,7 +674,7 @@ template
|
|
682
674
|
template <class S, class M2>
|
683
675
|
V8_INLINE Persistent(Isolate* isolate, const Persistent<S, M2>& that)
|
684
676
|
: PersistentBase<T>(PersistentBase<T>::New(isolate, *that)) {
|
685
|
-
|
677
|
+
static_assert(std::is_base_of<T, S>::value, "type check");
|
686
678
|
}
|
687
679
|
/**
|
688
680
|
* The copy constructors and assignment operator create a Persistent
|
@@ -758,6 +750,7 @@ class Global : public PersistentBase
|
|
758
750
|
* A Global with no storage cell.
|
759
751
|
*/
|
760
752
|
V8_INLINE Global() : PersistentBase<T>(nullptr) {}
|
753
|
+
|
761
754
|
/**
|
762
755
|
* Construct a Global from a Local.
|
763
756
|
* When the Local is non-empty, a new storage cell is created
|
@@ -766,8 +759,9 @@ class Global : public PersistentBase
|
|
766
759
|
template <class S>
|
767
760
|
V8_INLINE Global(Isolate* isolate, Local<S> that)
|
768
761
|
: PersistentBase<T>(PersistentBase<T>::New(isolate, *that)) {
|
769
|
-
|
762
|
+
static_assert(std::is_base_of<T, S>::value, "type check");
|
770
763
|
}
|
764
|
+
|
771
765
|
/**
|
772
766
|
* Construct a Global from a PersistentBase.
|
773
767
|
* When the Persistent is non-empty, a new storage cell is created
|
@@ -776,28 +770,22 @@ class Global : public PersistentBase
|
|
776
770
|
template <class S>
|
777
771
|
V8_INLINE Global(Isolate* isolate, const PersistentBase<S>& that)
|
778
772
|
: PersistentBase<T>(PersistentBase<T>::New(isolate, that.val_)) {
|
779
|
-
|
773
|
+
static_assert(std::is_base_of<T, S>::value, "type check");
|
780
774
|
}
|
775
|
+
|
781
776
|
/**
|
782
777
|
* Move constructor.
|
783
778
|
*/
|
784
|
-
V8_INLINE Global(Global&& other)
|
785
|
-
|
786
|
-
}
|
779
|
+
V8_INLINE Global(Global&& other);
|
780
|
+
|
787
781
|
V8_INLINE ~Global() { this->Reset(); }
|
782
|
+
|
788
783
|
/**
|
789
784
|
* Move via assignment.
|
790
785
|
*/
|
791
786
|
template <class S>
|
792
|
-
V8_INLINE Global& operator=(Global<S>&& rhs)
|
793
|
-
|
794
|
-
if (this != &rhs) {
|
795
|
-
this->Reset();
|
796
|
-
this->val_ = rhs.val_;
|
797
|
-
rhs.val_ = nullptr;
|
798
|
-
}
|
799
|
-
return *this;
|
800
|
-
}
|
787
|
+
V8_INLINE Global& operator=(Global<S>&& rhs);
|
788
|
+
|
801
789
|
/**
|
802
790
|
* Pass allows returning uniques from functions, etc.
|
803
791
|
*/
|
@@ -822,6 +810,345 @@ class Global : public PersistentBase
|
|
822
810
|
template <class T>
|
823
811
|
using UniquePersistent = Global<T>;
|
824
812
|
|
813
|
+
/**
|
814
|
+
* Deprecated. Use |TracedReference<T>| instead.
|
815
|
+
*/
|
816
|
+
template <typename T>
|
817
|
+
struct TracedGlobalTrait {};
|
818
|
+
|
819
|
+
/**
|
820
|
+
* A traced handle with copy and move semantics. The handle is to be used
|
821
|
+
* together with |v8::EmbedderHeapTracer| and specifies edges from the embedder
|
822
|
+
* into V8's heap.
|
823
|
+
*
|
824
|
+
* The exact semantics are:
|
825
|
+
* - Tracing garbage collections use |v8::EmbedderHeapTracer|.
|
826
|
+
* - Non-tracing garbage collections refer to
|
827
|
+
* |v8::EmbedderHeapTracer::IsRootForNonTracingGC()| whether the handle should
|
828
|
+
* be treated as root or not.
|
829
|
+
*
|
830
|
+
* Note that the base class cannot be instantiated itself. Choose from
|
831
|
+
* - TracedGlobal
|
832
|
+
* - TracedReference
|
833
|
+
*/
|
834
|
+
template <typename T>
|
835
|
+
class TracedReferenceBase {
|
836
|
+
public:
|
837
|
+
/**
|
838
|
+
* Returns true if this TracedReferenceBase is empty, i.e., has not been
|
839
|
+
* assigned an object.
|
840
|
+
*/
|
841
|
+
bool IsEmpty() const { return val_ == nullptr; }
|
842
|
+
|
843
|
+
/**
|
844
|
+
* If non-empty, destroy the underlying storage cell. |IsEmpty| will return
|
845
|
+
* true after this call.
|
846
|
+
*/
|
847
|
+
V8_INLINE void Reset();
|
848
|
+
|
849
|
+
/**
|
850
|
+
* Construct a Local<T> from this handle.
|
851
|
+
*/
|
852
|
+
Local<T> Get(Isolate* isolate) const { return Local<T>::New(isolate, *this); }
|
853
|
+
|
854
|
+
template <class S>
|
855
|
+
V8_INLINE bool operator==(const TracedReferenceBase<S>& that) const {
|
856
|
+
internal::Address* a = reinterpret_cast<internal::Address*>(val_);
|
857
|
+
internal::Address* b = reinterpret_cast<internal::Address*>(that.val_);
|
858
|
+
if (a == nullptr) return b == nullptr;
|
859
|
+
if (b == nullptr) return false;
|
860
|
+
return *a == *b;
|
861
|
+
}
|
862
|
+
|
863
|
+
template <class S>
|
864
|
+
V8_INLINE bool operator==(const Local<S>& that) const {
|
865
|
+
internal::Address* a = reinterpret_cast<internal::Address*>(val_);
|
866
|
+
internal::Address* b = reinterpret_cast<internal::Address*>(that.val_);
|
867
|
+
if (a == nullptr) return b == nullptr;
|
868
|
+
if (b == nullptr) return false;
|
869
|
+
return *a == *b;
|
870
|
+
}
|
871
|
+
|
872
|
+
template <class S>
|
873
|
+
V8_INLINE bool operator!=(const TracedReferenceBase<S>& that) const {
|
874
|
+
return !operator==(that);
|
875
|
+
}
|
876
|
+
|
877
|
+
template <class S>
|
878
|
+
V8_INLINE bool operator!=(const Local<S>& that) const {
|
879
|
+
return !operator==(that);
|
880
|
+
}
|
881
|
+
|
882
|
+
/**
|
883
|
+
* Assigns a wrapper class ID to the handle.
|
884
|
+
*/
|
885
|
+
V8_INLINE void SetWrapperClassId(uint16_t class_id);
|
886
|
+
|
887
|
+
/**
|
888
|
+
* Returns the class ID previously assigned to this handle or 0 if no class ID
|
889
|
+
* was previously assigned.
|
890
|
+
*/
|
891
|
+
V8_INLINE uint16_t WrapperClassId() const;
|
892
|
+
|
893
|
+
template <class S>
|
894
|
+
V8_INLINE TracedReferenceBase<S>& As() const {
|
895
|
+
return reinterpret_cast<TracedReferenceBase<S>&>(
|
896
|
+
const_cast<TracedReferenceBase<T>&>(*this));
|
897
|
+
}
|
898
|
+
|
899
|
+
private:
|
900
|
+
enum DestructionMode { kWithDestructor, kWithoutDestructor };
|
901
|
+
|
902
|
+
/**
|
903
|
+
* An empty TracedReferenceBase without storage cell.
|
904
|
+
*/
|
905
|
+
TracedReferenceBase() = default;
|
906
|
+
|
907
|
+
V8_INLINE static T* New(Isolate* isolate, T* that, void* slot,
|
908
|
+
DestructionMode destruction_mode);
|
909
|
+
|
910
|
+
T* val_ = nullptr;
|
911
|
+
|
912
|
+
friend class EmbedderHeapTracer;
|
913
|
+
template <typename F>
|
914
|
+
friend class Local;
|
915
|
+
friend class Object;
|
916
|
+
template <typename F>
|
917
|
+
friend class TracedGlobal;
|
918
|
+
template <typename F>
|
919
|
+
friend class TracedReference;
|
920
|
+
template <typename F>
|
921
|
+
friend class ReturnValue;
|
922
|
+
};
|
923
|
+
|
924
|
+
/**
|
925
|
+
* A traced handle with destructor that clears the handle. For more details see
|
926
|
+
* TracedReferenceBase.
|
927
|
+
*/
|
928
|
+
template <typename T>
|
929
|
+
class TracedGlobal : public TracedReferenceBase<T> {
|
930
|
+
public:
|
931
|
+
using TracedReferenceBase<T>::Reset;
|
932
|
+
|
933
|
+
/**
|
934
|
+
* Destructor resetting the handle.
|
935
|
+
*/
|
936
|
+
~TracedGlobal() { this->Reset(); }
|
937
|
+
|
938
|
+
/**
|
939
|
+
* An empty TracedGlobal without storage cell.
|
940
|
+
*/
|
941
|
+
TracedGlobal() : TracedReferenceBase<T>() {}
|
942
|
+
|
943
|
+
/**
|
944
|
+
* Construct a TracedGlobal from a Local.
|
945
|
+
*
|
946
|
+
* When the Local is non-empty, a new storage cell is created
|
947
|
+
* pointing to the same object.
|
948
|
+
*/
|
949
|
+
template <class S>
|
950
|
+
TracedGlobal(Isolate* isolate, Local<S> that) : TracedReferenceBase<T>() {
|
951
|
+
this->val_ = this->New(isolate, that.val_, &this->val_,
|
952
|
+
TracedReferenceBase<T>::kWithDestructor);
|
953
|
+
static_assert(std::is_base_of<T, S>::value, "type check");
|
954
|
+
}
|
955
|
+
|
956
|
+
/**
|
957
|
+
* Move constructor initializing TracedGlobal from an existing one.
|
958
|
+
*/
|
959
|
+
V8_INLINE TracedGlobal(TracedGlobal&& other) {
|
960
|
+
// Forward to operator=.
|
961
|
+
*this = std::move(other);
|
962
|
+
}
|
963
|
+
|
964
|
+
/**
|
965
|
+
* Move constructor initializing TracedGlobal from an existing one.
|
966
|
+
*/
|
967
|
+
template <typename S>
|
968
|
+
V8_INLINE TracedGlobal(TracedGlobal<S>&& other) {
|
969
|
+
// Forward to operator=.
|
970
|
+
*this = std::move(other);
|
971
|
+
}
|
972
|
+
|
973
|
+
/**
|
974
|
+
* Copy constructor initializing TracedGlobal from an existing one.
|
975
|
+
*/
|
976
|
+
V8_INLINE TracedGlobal(const TracedGlobal& other) {
|
977
|
+
// Forward to operator=;
|
978
|
+
*this = other;
|
979
|
+
}
|
980
|
+
|
981
|
+
/**
|
982
|
+
* Copy constructor initializing TracedGlobal from an existing one.
|
983
|
+
*/
|
984
|
+
template <typename S>
|
985
|
+
V8_INLINE TracedGlobal(const TracedGlobal<S>& other) {
|
986
|
+
// Forward to operator=;
|
987
|
+
*this = other;
|
988
|
+
}
|
989
|
+
|
990
|
+
/**
|
991
|
+
* Move assignment operator initializing TracedGlobal from an existing one.
|
992
|
+
*/
|
993
|
+
V8_INLINE TracedGlobal& operator=(TracedGlobal&& rhs);
|
994
|
+
|
995
|
+
/**
|
996
|
+
* Move assignment operator initializing TracedGlobal from an existing one.
|
997
|
+
*/
|
998
|
+
template <class S>
|
999
|
+
V8_INLINE TracedGlobal& operator=(TracedGlobal<S>&& rhs);
|
1000
|
+
|
1001
|
+
/**
|
1002
|
+
* Copy assignment operator initializing TracedGlobal from an existing one.
|
1003
|
+
*
|
1004
|
+
* Note: Prohibited when |other| has a finalization callback set through
|
1005
|
+
* |SetFinalizationCallback|.
|
1006
|
+
*/
|
1007
|
+
V8_INLINE TracedGlobal& operator=(const TracedGlobal& rhs);
|
1008
|
+
|
1009
|
+
/**
|
1010
|
+
* Copy assignment operator initializing TracedGlobal from an existing one.
|
1011
|
+
*
|
1012
|
+
* Note: Prohibited when |other| has a finalization callback set through
|
1013
|
+
* |SetFinalizationCallback|.
|
1014
|
+
*/
|
1015
|
+
template <class S>
|
1016
|
+
V8_INLINE TracedGlobal& operator=(const TracedGlobal<S>& rhs);
|
1017
|
+
|
1018
|
+
/**
|
1019
|
+
* If non-empty, destroy the underlying storage cell and create a new one with
|
1020
|
+
* the contents of other if other is non empty
|
1021
|
+
*/
|
1022
|
+
template <class S>
|
1023
|
+
V8_INLINE void Reset(Isolate* isolate, const Local<S>& other);
|
1024
|
+
|
1025
|
+
template <class S>
|
1026
|
+
V8_INLINE TracedGlobal<S>& As() const {
|
1027
|
+
return reinterpret_cast<TracedGlobal<S>&>(
|
1028
|
+
const_cast<TracedGlobal<T>&>(*this));
|
1029
|
+
}
|
1030
|
+
|
1031
|
+
/**
|
1032
|
+
* Adds a finalization callback to the handle. The type of this callback is
|
1033
|
+
* similar to WeakCallbackType::kInternalFields, i.e., it will pass the
|
1034
|
+
* parameter and the first two internal fields of the object.
|
1035
|
+
*
|
1036
|
+
* The callback is then supposed to reset the handle in the callback. No
|
1037
|
+
* further V8 API may be called in this callback. In case additional work
|
1038
|
+
* involving V8 needs to be done, a second callback can be scheduled using
|
1039
|
+
* WeakCallbackInfo<void>::SetSecondPassCallback.
|
1040
|
+
*/
|
1041
|
+
V8_INLINE void SetFinalizationCallback(
|
1042
|
+
void* parameter, WeakCallbackInfo<void>::Callback callback);
|
1043
|
+
};
|
1044
|
+
|
1045
|
+
/**
|
1046
|
+
* A traced handle without destructor that clears the handle. The embedder needs
|
1047
|
+
* to ensure that the handle is not accessed once the V8 object has been
|
1048
|
+
* reclaimed. This can happen when the handle is not passed through the
|
1049
|
+
* EmbedderHeapTracer. For more details see TracedReferenceBase.
|
1050
|
+
*
|
1051
|
+
* The reference assumes the embedder has precise knowledge about references at
|
1052
|
+
* all times. In case V8 needs to separately handle on-stack references, the
|
1053
|
+
* embedder is required to set the stack start through
|
1054
|
+
* |EmbedderHeapTracer::SetStackStart|.
|
1055
|
+
*/
|
1056
|
+
template <typename T>
|
1057
|
+
class TracedReference : public TracedReferenceBase<T> {
|
1058
|
+
public:
|
1059
|
+
using TracedReferenceBase<T>::Reset;
|
1060
|
+
|
1061
|
+
/**
|
1062
|
+
* An empty TracedReference without storage cell.
|
1063
|
+
*/
|
1064
|
+
TracedReference() : TracedReferenceBase<T>() {}
|
1065
|
+
|
1066
|
+
/**
|
1067
|
+
* Construct a TracedReference from a Local.
|
1068
|
+
*
|
1069
|
+
* When the Local is non-empty, a new storage cell is created
|
1070
|
+
* pointing to the same object.
|
1071
|
+
*/
|
1072
|
+
template <class S>
|
1073
|
+
TracedReference(Isolate* isolate, Local<S> that) : TracedReferenceBase<T>() {
|
1074
|
+
this->val_ = this->New(isolate, that.val_, &this->val_,
|
1075
|
+
TracedReferenceBase<T>::kWithoutDestructor);
|
1076
|
+
static_assert(std::is_base_of<T, S>::value, "type check");
|
1077
|
+
}
|
1078
|
+
|
1079
|
+
/**
|
1080
|
+
* Move constructor initializing TracedReference from an
|
1081
|
+
* existing one.
|
1082
|
+
*/
|
1083
|
+
V8_INLINE TracedReference(TracedReference&& other) {
|
1084
|
+
// Forward to operator=.
|
1085
|
+
*this = std::move(other);
|
1086
|
+
}
|
1087
|
+
|
1088
|
+
/**
|
1089
|
+
* Move constructor initializing TracedReference from an
|
1090
|
+
* existing one.
|
1091
|
+
*/
|
1092
|
+
template <typename S>
|
1093
|
+
V8_INLINE TracedReference(TracedReference<S>&& other) {
|
1094
|
+
// Forward to operator=.
|
1095
|
+
*this = std::move(other);
|
1096
|
+
}
|
1097
|
+
|
1098
|
+
/**
|
1099
|
+
* Copy constructor initializing TracedReference from an
|
1100
|
+
* existing one.
|
1101
|
+
*/
|
1102
|
+
V8_INLINE TracedReference(const TracedReference& other) {
|
1103
|
+
// Forward to operator=;
|
1104
|
+
*this = other;
|
1105
|
+
}
|
1106
|
+
|
1107
|
+
/**
|
1108
|
+
* Copy constructor initializing TracedReference from an
|
1109
|
+
* existing one.
|
1110
|
+
*/
|
1111
|
+
template <typename S>
|
1112
|
+
V8_INLINE TracedReference(const TracedReference<S>& other) {
|
1113
|
+
// Forward to operator=;
|
1114
|
+
*this = other;
|
1115
|
+
}
|
1116
|
+
|
1117
|
+
/**
|
1118
|
+
* Move assignment operator initializing TracedGlobal from an existing one.
|
1119
|
+
*/
|
1120
|
+
V8_INLINE TracedReference& operator=(TracedReference&& rhs);
|
1121
|
+
|
1122
|
+
/**
|
1123
|
+
* Move assignment operator initializing TracedGlobal from an existing one.
|
1124
|
+
*/
|
1125
|
+
template <class S>
|
1126
|
+
V8_INLINE TracedReference& operator=(TracedReference<S>&& rhs);
|
1127
|
+
|
1128
|
+
/**
|
1129
|
+
* Copy assignment operator initializing TracedGlobal from an existing one.
|
1130
|
+
*/
|
1131
|
+
V8_INLINE TracedReference& operator=(const TracedReference& rhs);
|
1132
|
+
|
1133
|
+
/**
|
1134
|
+
* Copy assignment operator initializing TracedGlobal from an existing one.
|
1135
|
+
*/
|
1136
|
+
template <class S>
|
1137
|
+
V8_INLINE TracedReference& operator=(const TracedReference<S>& rhs);
|
1138
|
+
|
1139
|
+
/**
|
1140
|
+
* If non-empty, destroy the underlying storage cell and create a new one with
|
1141
|
+
* the contents of other if other is non empty
|
1142
|
+
*/
|
1143
|
+
template <class S>
|
1144
|
+
V8_INLINE void Reset(Isolate* isolate, const Local<S>& other);
|
1145
|
+
|
1146
|
+
template <class S>
|
1147
|
+
V8_INLINE TracedReference<S>& As() const {
|
1148
|
+
return reinterpret_cast<TracedReference<S>&>(
|
1149
|
+
const_cast<TracedReference<T>&>(*this));
|
1150
|
+
}
|
1151
|
+
};
|
825
1152
|
|
826
1153
|
/**
|
827
1154
|
* A stack-allocated class that governs a number of local handles.
|
@@ -954,9 +1281,8 @@ class V8_EXPORT SealHandleScope {
|
|
954
1281
|
|
955
1282
|
// --- Special objects ---
|
956
1283
|
|
957
|
-
|
958
1284
|
/**
|
959
|
-
* The superclass of
|
1285
|
+
* The superclass of objects that can reside on V8's heap.
|
960
1286
|
*/
|
961
1287
|
class V8_EXPORT Data {
|
962
1288
|
private:
|
@@ -1103,7 +1429,7 @@ class V8_EXPORT UnboundScript {
|
|
1103
1429
|
/**
|
1104
1430
|
* A compiled JavaScript module, not yet tied to a Context.
|
1105
1431
|
*/
|
1106
|
-
class V8_EXPORT UnboundModuleScript {
|
1432
|
+
class V8_EXPORT UnboundModuleScript : public Data {
|
1107
1433
|
// Only used as a container for code caching.
|
1108
1434
|
};
|
1109
1435
|
|
@@ -1126,7 +1452,7 @@ class V8_EXPORT Location {
|
|
1126
1452
|
/**
|
1127
1453
|
* A compiled JavaScript module.
|
1128
1454
|
*/
|
1129
|
-
class V8_EXPORT Module {
|
1455
|
+
class V8_EXPORT Module : public Data {
|
1130
1456
|
public:
|
1131
1457
|
/**
|
1132
1458
|
* The different states a module can be in.
|
@@ -1214,6 +1540,45 @@ class V8_EXPORT Module {
|
|
1214
1540
|
* kEvaluated or kErrored.
|
1215
1541
|
*/
|
1216
1542
|
Local<UnboundModuleScript> GetUnboundModuleScript();
|
1543
|
+
|
1544
|
+
/*
|
1545
|
+
* Callback defined in the embedder. This is responsible for setting
|
1546
|
+
* the module's exported values with calls to SetSyntheticModuleExport().
|
1547
|
+
* The callback must return a Value to indicate success (where no
|
1548
|
+
* exception was thrown) and return an empy MaybeLocal to indicate falure
|
1549
|
+
* (where an exception was thrown).
|
1550
|
+
*/
|
1551
|
+
typedef MaybeLocal<Value> (*SyntheticModuleEvaluationSteps)(
|
1552
|
+
Local<Context> context, Local<Module> module);
|
1553
|
+
|
1554
|
+
/**
|
1555
|
+
* Creates a new SyntheticModule with the specified export names, where
|
1556
|
+
* evaluation_steps will be executed upon module evaluation.
|
1557
|
+
* export_names must not contain duplicates.
|
1558
|
+
* module_name is used solely for logging/debugging and doesn't affect module
|
1559
|
+
* behavior.
|
1560
|
+
*/
|
1561
|
+
static Local<Module> CreateSyntheticModule(
|
1562
|
+
Isolate* isolate, Local<String> module_name,
|
1563
|
+
const std::vector<Local<String>>& export_names,
|
1564
|
+
SyntheticModuleEvaluationSteps evaluation_steps);
|
1565
|
+
|
1566
|
+
/**
|
1567
|
+
* Set this module's exported value for the name export_name to the specified
|
1568
|
+
* export_value. This method must be called only on Modules created via
|
1569
|
+
* CreateSyntheticModule. An error will be thrown if export_name is not one
|
1570
|
+
* of the export_names that were passed in that CreateSyntheticModule call.
|
1571
|
+
* Returns Just(true) on success, Nothing<bool>() if an error was thrown.
|
1572
|
+
*/
|
1573
|
+
V8_WARN_UNUSED_RESULT Maybe<bool> SetSyntheticModuleExport(
|
1574
|
+
Isolate* isolate, Local<String> export_name, Local<Value> export_value);
|
1575
|
+
V8_DEPRECATE_SOON(
|
1576
|
+
"Use the preceding SetSyntheticModuleExport with an Isolate parameter, "
|
1577
|
+
"instead of the one that follows. The former will throw a runtime "
|
1578
|
+
"error if called for an export that doesn't exist (as per spec); "
|
1579
|
+
"the latter will crash with a failed CHECK().")
|
1580
|
+
void SetSyntheticModuleExport(Local<String> export_name,
|
1581
|
+
Local<Value> export_value);
|
1217
1582
|
};
|
1218
1583
|
|
1219
1584
|
/**
|
@@ -1387,7 +1752,12 @@ class V8_EXPORT ScriptCompiler {
|
|
1387
1752
|
public:
|
1388
1753
|
enum Encoding { ONE_BYTE, TWO_BYTE, UTF8 };
|
1389
1754
|
|
1755
|
+
V8_DEPRECATE_SOON(
|
1756
|
+
"This class takes ownership of source_stream, so use the constructor "
|
1757
|
+
"taking a unique_ptr to make these semantics clearer")
|
1390
1758
|
StreamedSource(ExternalSourceStream* source_stream, Encoding encoding);
|
1759
|
+
StreamedSource(std::unique_ptr<ExternalSourceStream> source_stream,
|
1760
|
+
Encoding encoding);
|
1391
1761
|
~StreamedSource();
|
1392
1762
|
|
1393
1763
|
internal::ScriptStreamingData* impl() const { return impl_.get(); }
|
@@ -1551,7 +1921,8 @@ class V8_EXPORT ScriptCompiler {
|
|
1551
1921
|
Local<String> arguments[], size_t context_extension_count,
|
1552
1922
|
Local<Object> context_extensions[],
|
1553
1923
|
CompileOptions options = kNoCompileOptions,
|
1554
|
-
NoCacheReason no_cache_reason = kNoCacheNoReason
|
1924
|
+
NoCacheReason no_cache_reason = kNoCacheNoReason,
|
1925
|
+
Local<ScriptOrModule>* script_or_module_out = nullptr);
|
1555
1926
|
|
1556
1927
|
/**
|
1557
1928
|
* Creates and returns code cache for the specified unbound_script.
|
@@ -1634,6 +2005,12 @@ class V8_EXPORT Message {
|
|
1634
2005
|
*/
|
1635
2006
|
int GetEndPosition() const;
|
1636
2007
|
|
2008
|
+
/**
|
2009
|
+
* Returns the Wasm function index where the error occurred. Returns -1 if
|
2010
|
+
* message is not from a Wasm script.
|
2011
|
+
*/
|
2012
|
+
int GetWasmFunctionIndex() const;
|
2013
|
+
|
1637
2014
|
/**
|
1638
2015
|
* Returns the error level of the message.
|
1639
2016
|
*/
|
@@ -1666,6 +2043,7 @@ class V8_EXPORT Message {
|
|
1666
2043
|
static const int kNoLineNumberInfo = 0;
|
1667
2044
|
static const int kNoColumnInfo = 0;
|
1668
2045
|
static const int kNoScriptIdInfo = 0;
|
2046
|
+
static const int kNoWasmFunctionIndexInfo = -1;
|
1669
2047
|
};
|
1670
2048
|
|
1671
2049
|
|
@@ -1783,6 +2161,11 @@ class V8_EXPORT StackFrame {
|
|
1783
2161
|
* Returns whether or not the associated functions is defined in wasm.
|
1784
2162
|
*/
|
1785
2163
|
bool IsWasm() const;
|
2164
|
+
|
2165
|
+
/**
|
2166
|
+
* Returns whether or not the associated function is defined by the user.
|
2167
|
+
*/
|
2168
|
+
bool IsUserJavaScript() const;
|
1786
2169
|
};
|
1787
2170
|
|
1788
2171
|
|
@@ -1795,16 +2178,18 @@ enum StateTag {
|
|
1795
2178
|
COMPILER,
|
1796
2179
|
OTHER,
|
1797
2180
|
EXTERNAL,
|
2181
|
+
ATOMICS_WAIT,
|
1798
2182
|
IDLE
|
1799
2183
|
};
|
1800
2184
|
|
1801
2185
|
// A RegisterState represents the current state of registers used
|
1802
2186
|
// by the sampling profiler API.
|
1803
2187
|
struct RegisterState {
|
1804
|
-
RegisterState() : pc(nullptr), sp(nullptr), fp(nullptr) {}
|
2188
|
+
RegisterState() : pc(nullptr), sp(nullptr), fp(nullptr), lr(nullptr) {}
|
1805
2189
|
void* pc; // Instruction pointer.
|
1806
2190
|
void* sp; // Stack pointer.
|
1807
2191
|
void* fp; // Frame pointer.
|
2192
|
+
void* lr; // Link register (or nullptr on platforms without a link register).
|
1808
2193
|
};
|
1809
2194
|
|
1810
2195
|
// The output structure filled up by GetStackSample API function.
|
@@ -1813,6 +2198,7 @@ struct SampleInfo {
|
|
1813
2198
|
StateTag vm_state; // Current VM state.
|
1814
2199
|
void* external_callback_entry; // External callback address if VM is
|
1815
2200
|
// executing an external callback.
|
2201
|
+
void* top_context; // Incumbent native context address.
|
1816
2202
|
};
|
1817
2203
|
|
1818
2204
|
struct MemoryRange {
|
@@ -1828,6 +2214,14 @@ struct UnwindState {
|
|
1828
2214
|
MemoryRange code_range;
|
1829
2215
|
MemoryRange embedded_code_range;
|
1830
2216
|
JSEntryStub js_entry_stub;
|
2217
|
+
JSEntryStub js_construct_entry_stub;
|
2218
|
+
JSEntryStub js_run_microtasks_entry_stub;
|
2219
|
+
};
|
2220
|
+
|
2221
|
+
struct JSEntryStubs {
|
2222
|
+
JSEntryStub js_entry_stub;
|
2223
|
+
JSEntryStub js_construct_entry_stub;
|
2224
|
+
JSEntryStub js_run_microtasks_entry_stub;
|
1831
2225
|
};
|
1832
2226
|
|
1833
2227
|
/**
|
@@ -1861,10 +2255,6 @@ class V8_EXPORT JSON {
|
|
1861
2255
|
/**
|
1862
2256
|
* Value serialization compatible with the HTML structured clone algorithm.
|
1863
2257
|
* The format is backward-compatible (i.e. safe to store to disk).
|
1864
|
-
*
|
1865
|
-
* WARNING: This API is under development, and changes (including incompatible
|
1866
|
-
* changes to the API or wire format) may occur without notice until this
|
1867
|
-
* warning is removed.
|
1868
2258
|
*/
|
1869
2259
|
class V8_EXPORT ValueSerializer {
|
1870
2260
|
public:
|
@@ -1974,10 +2364,10 @@ class V8_EXPORT ValueSerializer {
|
|
1974
2364
|
void WriteDouble(double value);
|
1975
2365
|
void WriteRawBytes(const void* source, size_t length);
|
1976
2366
|
|
1977
|
-
private:
|
1978
2367
|
ValueSerializer(const ValueSerializer&) = delete;
|
1979
2368
|
void operator=(const ValueSerializer&) = delete;
|
1980
2369
|
|
2370
|
+
private:
|
1981
2371
|
struct PrivateData;
|
1982
2372
|
PrivateData* private_;
|
1983
2373
|
};
|
@@ -1985,10 +2375,6 @@ class V8_EXPORT ValueSerializer {
|
|
1985
2375
|
/**
|
1986
2376
|
* Deserializes values from data written with ValueSerializer, or a compatible
|
1987
2377
|
* implementation.
|
1988
|
-
*
|
1989
|
-
* WARNING: This API is under development, and changes (including incompatible
|
1990
|
-
* changes to the API or wire format) may occur without notice until this
|
1991
|
-
* warning is removed.
|
1992
2378
|
*/
|
1993
2379
|
class V8_EXPORT ValueDeserializer {
|
1994
2380
|
public:
|
@@ -2058,11 +2444,6 @@ class V8_EXPORT ValueDeserializer {
|
|
2058
2444
|
*/
|
2059
2445
|
void SetSupportsLegacyWireFormat(bool supports_legacy_wire_format);
|
2060
2446
|
|
2061
|
-
/**
|
2062
|
-
* Expect inline wasm in the data stream (rather than in-memory transfer)
|
2063
|
-
*/
|
2064
|
-
void SetExpectInlineWasm(bool allow_inline_wasm);
|
2065
|
-
|
2066
2447
|
/**
|
2067
2448
|
* Reads the underlying wire format version. Likely mostly to be useful to
|
2068
2449
|
* legacy code reading old wire format versions. Must be called after
|
@@ -2080,10 +2461,10 @@ class V8_EXPORT ValueDeserializer {
|
|
2080
2461
|
V8_WARN_UNUSED_RESULT bool ReadDouble(double* value);
|
2081
2462
|
V8_WARN_UNUSED_RESULT bool ReadRawBytes(size_t length, const void** data);
|
2082
2463
|
|
2083
|
-
private:
|
2084
2464
|
ValueDeserializer(const ValueDeserializer&) = delete;
|
2085
2465
|
void operator=(const ValueDeserializer&) = delete;
|
2086
2466
|
|
2467
|
+
private:
|
2087
2468
|
struct PrivateData;
|
2088
2469
|
PrivateData* private_;
|
2089
2470
|
};
|
@@ -2100,12 +2481,16 @@ class V8_EXPORT Value : public Data {
|
|
2100
2481
|
/**
|
2101
2482
|
* Returns true if this value is the undefined value. See ECMA-262
|
2102
2483
|
* 4.3.10.
|
2484
|
+
*
|
2485
|
+
* This is equivalent to `value === undefined` in JS.
|
2103
2486
|
*/
|
2104
2487
|
V8_INLINE bool IsUndefined() const;
|
2105
2488
|
|
2106
2489
|
/**
|
2107
2490
|
* Returns true if this value is the null value. See ECMA-262
|
2108
2491
|
* 4.3.11.
|
2492
|
+
*
|
2493
|
+
* This is equivalent to `value === null` in JS.
|
2109
2494
|
*/
|
2110
2495
|
V8_INLINE bool IsNull() const;
|
2111
2496
|
|
@@ -2113,37 +2498,56 @@ class V8_EXPORT Value : public Data {
|
|
2113
2498
|
* Returns true if this value is either the null or the undefined value.
|
2114
2499
|
* See ECMA-262
|
2115
2500
|
* 4.3.11. and 4.3.12
|
2501
|
+
*
|
2502
|
+
* This is equivalent to `value == null` in JS.
|
2116
2503
|
*/
|
2117
2504
|
V8_INLINE bool IsNullOrUndefined() const;
|
2118
2505
|
|
2119
2506
|
/**
|
2120
|
-
|
2121
|
-
|
2507
|
+
* Returns true if this value is true.
|
2508
|
+
*
|
2509
|
+
* This is not the same as `BooleanValue()`. The latter performs a
|
2510
|
+
* conversion to boolean, i.e. the result of `Boolean(value)` in JS, whereas
|
2511
|
+
* this checks `value === true`.
|
2512
|
+
*/
|
2122
2513
|
bool IsTrue() const;
|
2123
2514
|
|
2124
2515
|
/**
|
2125
2516
|
* Returns true if this value is false.
|
2517
|
+
*
|
2518
|
+
* This is not the same as `!BooleanValue()`. The latter performs a
|
2519
|
+
* conversion to boolean, i.e. the result of `!Boolean(value)` in JS, whereas
|
2520
|
+
* this checks `value === false`.
|
2126
2521
|
*/
|
2127
2522
|
bool IsFalse() const;
|
2128
2523
|
|
2129
2524
|
/**
|
2130
2525
|
* Returns true if this value is a symbol or a string.
|
2526
|
+
*
|
2527
|
+
* This is equivalent to
|
2528
|
+
* `typeof value === 'string' || typeof value === 'symbol'` in JS.
|
2131
2529
|
*/
|
2132
2530
|
bool IsName() const;
|
2133
2531
|
|
2134
2532
|
/**
|
2135
2533
|
* Returns true if this value is an instance of the String type.
|
2136
2534
|
* See ECMA-262 8.4.
|
2535
|
+
*
|
2536
|
+
* This is equivalent to `typeof value === 'string'` in JS.
|
2137
2537
|
*/
|
2138
2538
|
V8_INLINE bool IsString() const;
|
2139
2539
|
|
2140
2540
|
/**
|
2141
2541
|
* Returns true if this value is a symbol.
|
2542
|
+
*
|
2543
|
+
* This is equivalent to `typeof value === 'symbol'` in JS.
|
2142
2544
|
*/
|
2143
2545
|
bool IsSymbol() const;
|
2144
2546
|
|
2145
2547
|
/**
|
2146
2548
|
* Returns true if this value is a function.
|
2549
|
+
*
|
2550
|
+
* This is equivalent to `typeof value === 'function'` in JS.
|
2147
2551
|
*/
|
2148
2552
|
bool IsFunction() const;
|
2149
2553
|
|
@@ -2160,21 +2564,27 @@ class V8_EXPORT Value : public Data {
|
|
2160
2564
|
|
2161
2565
|
/**
|
2162
2566
|
* Returns true if this value is a bigint.
|
2567
|
+
*
|
2568
|
+
* This is equivalent to `typeof value === 'bigint'` in JS.
|
2163
2569
|
*/
|
2164
2570
|
bool IsBigInt() const;
|
2165
2571
|
|
2166
2572
|
/**
|
2167
2573
|
* Returns true if this value is boolean.
|
2574
|
+
*
|
2575
|
+
* This is equivalent to `typeof value === 'boolean'` in JS.
|
2168
2576
|
*/
|
2169
2577
|
bool IsBoolean() const;
|
2170
2578
|
|
2171
2579
|
/**
|
2172
2580
|
* Returns true if this value is a number.
|
2581
|
+
*
|
2582
|
+
* This is equivalent to `typeof value === 'number'` in JS.
|
2173
2583
|
*/
|
2174
2584
|
bool IsNumber() const;
|
2175
2585
|
|
2176
2586
|
/**
|
2177
|
-
* Returns true if this value is
|
2587
|
+
* Returns true if this value is an `External` object.
|
2178
2588
|
*/
|
2179
2589
|
bool IsExternal() const;
|
2180
2590
|
|
@@ -2360,7 +2770,6 @@ class V8_EXPORT Value : public Data {
|
|
2360
2770
|
|
2361
2771
|
/**
|
2362
2772
|
* Returns true if this value is a SharedArrayBuffer.
|
2363
|
-
* This is an experimental feature.
|
2364
2773
|
*/
|
2365
2774
|
bool IsSharedArrayBuffer() const;
|
2366
2775
|
|
@@ -2369,43 +2778,68 @@ class V8_EXPORT Value : public Data {
|
|
2369
2778
|
*/
|
2370
2779
|
bool IsProxy() const;
|
2371
2780
|
|
2372
|
-
|
2781
|
+
/**
|
2782
|
+
* Returns true if this value is a WasmModuleObject.
|
2783
|
+
*/
|
2784
|
+
bool IsWasmModuleObject() const;
|
2373
2785
|
|
2374
2786
|
/**
|
2375
2787
|
* Returns true if the value is a Module Namespace Object.
|
2376
2788
|
*/
|
2377
2789
|
bool IsModuleNamespaceObject() const;
|
2378
2790
|
|
2791
|
+
/**
|
2792
|
+
* Perform the equivalent of `BigInt(value)` in JS.
|
2793
|
+
*/
|
2379
2794
|
V8_WARN_UNUSED_RESULT MaybeLocal<BigInt> ToBigInt(
|
2380
2795
|
Local<Context> context) const;
|
2381
|
-
|
2382
|
-
|
2383
|
-
|
2796
|
+
/**
|
2797
|
+
* Perform the equivalent of `Number(value)` in JS.
|
2798
|
+
*/
|
2384
2799
|
V8_WARN_UNUSED_RESULT MaybeLocal<Number> ToNumber(
|
2385
2800
|
Local<Context> context) const;
|
2801
|
+
/**
|
2802
|
+
* Perform the equivalent of `String(value)` in JS.
|
2803
|
+
*/
|
2386
2804
|
V8_WARN_UNUSED_RESULT MaybeLocal<String> ToString(
|
2387
2805
|
Local<Context> context) const;
|
2806
|
+
/**
|
2807
|
+
* Provide a string representation of this value usable for debugging.
|
2808
|
+
* This operation has no observable side effects and will succeed
|
2809
|
+
* unless e.g. execution is being terminated.
|
2810
|
+
*/
|
2388
2811
|
V8_WARN_UNUSED_RESULT MaybeLocal<String> ToDetailString(
|
2389
2812
|
Local<Context> context) const;
|
2813
|
+
/**
|
2814
|
+
* Perform the equivalent of `Object(value)` in JS.
|
2815
|
+
*/
|
2390
2816
|
V8_WARN_UNUSED_RESULT MaybeLocal<Object> ToObject(
|
2391
2817
|
Local<Context> context) const;
|
2818
|
+
/**
|
2819
|
+
* Perform the equivalent of `Number(value)` in JS and convert the result
|
2820
|
+
* to an integer. Negative values are rounded up, positive values are rounded
|
2821
|
+
* down. NaN is converted to 0. Infinite values yield undefined results.
|
2822
|
+
*/
|
2392
2823
|
V8_WARN_UNUSED_RESULT MaybeLocal<Integer> ToInteger(
|
2393
2824
|
Local<Context> context) const;
|
2825
|
+
/**
|
2826
|
+
* Perform the equivalent of `Number(value)` in JS and convert the result
|
2827
|
+
* to an unsigned 32-bit integer by performing the steps in
|
2828
|
+
* https://tc39.es/ecma262/#sec-touint32.
|
2829
|
+
*/
|
2394
2830
|
V8_WARN_UNUSED_RESULT MaybeLocal<Uint32> ToUint32(
|
2395
2831
|
Local<Context> context) const;
|
2832
|
+
/**
|
2833
|
+
* Perform the equivalent of `Number(value)` in JS and convert the result
|
2834
|
+
* to a signed 32-bit integer by performing the steps in
|
2835
|
+
* https://tc39.es/ecma262/#sec-toint32.
|
2836
|
+
*/
|
2396
2837
|
V8_WARN_UNUSED_RESULT MaybeLocal<Int32> ToInt32(Local<Context> context) const;
|
2397
2838
|
|
2839
|
+
/**
|
2840
|
+
* Perform the equivalent of `Boolean(value)` in JS. This can never fail.
|
2841
|
+
*/
|
2398
2842
|
Local<Boolean> ToBoolean(Isolate* isolate) const;
|
2399
|
-
V8_DEPRECATE_SOON("Use maybe version",
|
2400
|
-
Local<Number> ToNumber(Isolate* isolate) const);
|
2401
|
-
V8_DEPRECATE_SOON("Use maybe version",
|
2402
|
-
Local<String> ToString(Isolate* isolate) const);
|
2403
|
-
V8_DEPRECATE_SOON("Use maybe version",
|
2404
|
-
Local<Object> ToObject(Isolate* isolate) const);
|
2405
|
-
V8_DEPRECATE_SOON("Use maybe version",
|
2406
|
-
Local<Integer> ToInteger(Isolate* isolate) const);
|
2407
|
-
V8_DEPRECATE_SOON("Use maybe version",
|
2408
|
-
Local<Int32> ToInt32(Isolate* isolate) const);
|
2409
2843
|
|
2410
2844
|
/**
|
2411
2845
|
* Attempts to convert a string to an array index.
|
@@ -2414,16 +2848,18 @@ class V8_EXPORT Value : public Data {
|
|
2414
2848
|
V8_WARN_UNUSED_RESULT MaybeLocal<Uint32> ToArrayIndex(
|
2415
2849
|
Local<Context> context) const;
|
2416
2850
|
|
2851
|
+
/** Returns the equivalent of `ToBoolean()->Value()`. */
|
2417
2852
|
bool BooleanValue(Isolate* isolate) const;
|
2418
2853
|
|
2419
|
-
|
2420
|
-
V8_WARN_UNUSED_RESULT Maybe<bool> BooleanValue(
|
2421
|
-
Local<Context> context) const);
|
2854
|
+
/** Returns the equivalent of `ToNumber()->Value()`. */
|
2422
2855
|
V8_WARN_UNUSED_RESULT Maybe<double> NumberValue(Local<Context> context) const;
|
2856
|
+
/** Returns the equivalent of `ToInteger()->Value()`. */
|
2423
2857
|
V8_WARN_UNUSED_RESULT Maybe<int64_t> IntegerValue(
|
2424
2858
|
Local<Context> context) const;
|
2859
|
+
/** Returns the equivalent of `ToUint32()->Value()`. */
|
2425
2860
|
V8_WARN_UNUSED_RESULT Maybe<uint32_t> Uint32Value(
|
2426
2861
|
Local<Context> context) const;
|
2862
|
+
/** Returns the equivalent of `ToInt32()->Value()`. */
|
2427
2863
|
V8_WARN_UNUSED_RESULT Maybe<int32_t> Int32Value(Local<Context> context) const;
|
2428
2864
|
|
2429
2865
|
/** JS == */
|
@@ -2515,9 +2951,8 @@ enum class NewStringType {
|
|
2515
2951
|
*/
|
2516
2952
|
class V8_EXPORT String : public Name {
|
2517
2953
|
public:
|
2518
|
-
static constexpr int kMaxLength =
|
2519
|
-
|
2520
|
-
: internal::kSmiMaxValue / 2 - 24;
|
2954
|
+
static constexpr int kMaxLength =
|
2955
|
+
internal::kApiSystemPointerSize == 4 ? (1 << 28) - 16 : (1 << 29) - 24;
|
2521
2956
|
|
2522
2957
|
enum Encoding {
|
2523
2958
|
UNKNOWN_ENCODING = 0x1,
|
@@ -2615,10 +3050,6 @@ class V8_EXPORT String : public Name {
|
|
2615
3050
|
public:
|
2616
3051
|
virtual ~ExternalStringResourceBase() = default;
|
2617
3052
|
|
2618
|
-
V8_DEPRECATED("Use IsCacheable().", virtual bool IsCompressible() const) {
|
2619
|
-
return false;
|
2620
|
-
}
|
2621
|
-
|
2622
3053
|
/**
|
2623
3054
|
* If a string is cacheable, the value returned by
|
2624
3055
|
* ExternalStringResource::data() may be cached, otherwise it is not
|
@@ -2626,6 +3057,10 @@ class V8_EXPORT String : public Name {
|
|
2626
3057
|
*/
|
2627
3058
|
virtual bool IsCacheable() const { return true; }
|
2628
3059
|
|
3060
|
+
// Disallow copying and assigning.
|
3061
|
+
ExternalStringResourceBase(const ExternalStringResourceBase&) = delete;
|
3062
|
+
void operator=(const ExternalStringResourceBase&) = delete;
|
3063
|
+
|
2629
3064
|
protected:
|
2630
3065
|
ExternalStringResourceBase() = default;
|
2631
3066
|
|
@@ -2655,12 +3090,8 @@ class V8_EXPORT String : public Name {
|
|
2655
3090
|
*/
|
2656
3091
|
virtual void Unlock() const {}
|
2657
3092
|
|
2658
|
-
// Disallow copying and assigning.
|
2659
|
-
ExternalStringResourceBase(const ExternalStringResourceBase&) = delete;
|
2660
|
-
void operator=(const ExternalStringResourceBase&) = delete;
|
2661
|
-
|
2662
3093
|
private:
|
2663
|
-
friend class internal::
|
3094
|
+
friend class internal::ExternalString;
|
2664
3095
|
friend class v8::String;
|
2665
3096
|
friend class internal::ScopedExternalStringLock;
|
2666
3097
|
};
|
@@ -2742,43 +3173,40 @@ class V8_EXPORT String : public Name {
|
|
2742
3173
|
|
2743
3174
|
V8_INLINE static String* Cast(v8::Value* obj);
|
2744
3175
|
|
2745
|
-
|
2746
|
-
|
2747
|
-
|
2748
|
-
|
2749
|
-
|
2750
|
-
|
2751
|
-
|
2752
|
-
|
2753
|
-
|
2754
|
-
|
2755
|
-
|
2756
|
-
|
3176
|
+
/**
|
3177
|
+
* Allocates a new string from a UTF-8 literal. This is equivalent to calling
|
3178
|
+
* String::NewFromUtf(isolate, "...").ToLocalChecked(), but without the check
|
3179
|
+
* overhead.
|
3180
|
+
*
|
3181
|
+
* When called on a string literal containing '\0', the inferred length is the
|
3182
|
+
* length of the input array minus 1 (for the final '\0') and not the value
|
3183
|
+
* returned by strlen.
|
3184
|
+
**/
|
3185
|
+
template <int N>
|
3186
|
+
static V8_WARN_UNUSED_RESULT Local<String> NewFromUtf8Literal(
|
3187
|
+
Isolate* isolate, const char (&literal)[N],
|
3188
|
+
NewStringType type = NewStringType::kNormal) {
|
3189
|
+
static_assert(N <= kMaxLength, "String is too long");
|
3190
|
+
return NewFromUtf8Literal(isolate, literal, type, N - 1);
|
3191
|
+
}
|
2757
3192
|
|
2758
3193
|
/** Allocates a new string from UTF-8 data. Only returns an empty value when
|
2759
3194
|
* length > kMaxLength. **/
|
2760
3195
|
static V8_WARN_UNUSED_RESULT MaybeLocal<String> NewFromUtf8(
|
2761
|
-
Isolate* isolate, const char* data,
|
2762
|
-
int length = -1);
|
3196
|
+
Isolate* isolate, const char* data,
|
3197
|
+
NewStringType type = NewStringType::kNormal, int length = -1);
|
2763
3198
|
|
2764
3199
|
/** Allocates a new string from Latin-1 data. Only returns an empty value
|
2765
3200
|
* when length > kMaxLength. **/
|
2766
3201
|
static V8_WARN_UNUSED_RESULT MaybeLocal<String> NewFromOneByte(
|
2767
|
-
Isolate* isolate, const uint8_t* data,
|
2768
|
-
int length = -1);
|
2769
|
-
|
2770
|
-
/** Allocates a new string from UTF-16 data.*/
|
2771
|
-
static V8_DEPRECATE_SOON(
|
2772
|
-
"Use maybe version",
|
2773
|
-
Local<String> NewFromTwoByte(Isolate* isolate, const uint16_t* data,
|
2774
|
-
NewStringType type = kNormalString,
|
2775
|
-
int length = -1));
|
3202
|
+
Isolate* isolate, const uint8_t* data,
|
3203
|
+
NewStringType type = NewStringType::kNormal, int length = -1);
|
2776
3204
|
|
2777
3205
|
/** Allocates a new string from UTF-16 data. Only returns an empty value when
|
2778
3206
|
* length > kMaxLength. **/
|
2779
3207
|
static V8_WARN_UNUSED_RESULT MaybeLocal<String> NewFromTwoByte(
|
2780
|
-
Isolate* isolate, const uint16_t* data,
|
2781
|
-
int length = -1);
|
3208
|
+
Isolate* isolate, const uint16_t* data,
|
3209
|
+
NewStringType type = NewStringType::kNormal, int length = -1);
|
2782
3210
|
|
2783
3211
|
/**
|
2784
3212
|
* Creates a new string by concatenating the left and the right strings
|
@@ -2817,10 +3245,6 @@ class V8_EXPORT String : public Name {
|
|
2817
3245
|
* should the underlying buffer be deallocated or modified except through the
|
2818
3246
|
* destructor of the external string resource.
|
2819
3247
|
*/
|
2820
|
-
static V8_DEPRECATE_SOON(
|
2821
|
-
"Use maybe version",
|
2822
|
-
Local<String> NewExternal(Isolate* isolate,
|
2823
|
-
ExternalOneByteStringResource* resource));
|
2824
3248
|
static V8_WARN_UNUSED_RESULT MaybeLocal<String> NewExternalOneByte(
|
2825
3249
|
Isolate* isolate, ExternalOneByteStringResource* resource);
|
2826
3250
|
|
@@ -2900,9 +3324,20 @@ class V8_EXPORT String : public Name {
|
|
2900
3324
|
ExternalStringResourceBase* GetExternalStringResourceBaseSlow(
|
2901
3325
|
String::Encoding* encoding_out) const;
|
2902
3326
|
|
3327
|
+
static Local<v8::String> NewFromUtf8Literal(Isolate* isolate,
|
3328
|
+
const char* literal,
|
3329
|
+
NewStringType type, int length);
|
3330
|
+
|
2903
3331
|
static void CheckCast(v8::Value* obj);
|
2904
3332
|
};
|
2905
3333
|
|
3334
|
+
// Zero-length string specialization (templated string size includes
|
3335
|
+
// terminator).
|
3336
|
+
template <>
|
3337
|
+
inline V8_WARN_UNUSED_RESULT Local<String> String::NewFromUtf8Literal(
|
3338
|
+
Isolate* isolate, const char (&literal)[1], NewStringType type) {
|
3339
|
+
return String::Empty(isolate);
|
3340
|
+
}
|
2906
3341
|
|
2907
3342
|
/**
|
2908
3343
|
* A JavaScript symbol (ECMA-262 edition 6)
|
@@ -2910,30 +3345,35 @@ class V8_EXPORT String : public Name {
|
|
2910
3345
|
class V8_EXPORT Symbol : public Name {
|
2911
3346
|
public:
|
2912
3347
|
/**
|
2913
|
-
* Returns the
|
3348
|
+
* Returns the description string of the symbol, or undefined if none.
|
2914
3349
|
*/
|
2915
|
-
Local<Value>
|
3350
|
+
Local<Value> Description() const;
|
3351
|
+
|
3352
|
+
V8_DEPRECATE_SOON("Use Symbol::Description()")
|
3353
|
+
Local<Value> Name() const { return Description(); }
|
2916
3354
|
|
2917
3355
|
/**
|
2918
|
-
* Create a symbol. If
|
3356
|
+
* Create a symbol. If description is not empty, it will be used as the
|
3357
|
+
* description.
|
2919
3358
|
*/
|
2920
3359
|
static Local<Symbol> New(Isolate* isolate,
|
2921
|
-
Local<String>
|
3360
|
+
Local<String> description = Local<String>());
|
2922
3361
|
|
2923
3362
|
/**
|
2924
3363
|
* Access global symbol registry.
|
2925
3364
|
* Note that symbols created this way are never collected, so
|
2926
3365
|
* they should only be used for statically fixed properties.
|
2927
|
-
* Also, there is only one global name space for the
|
3366
|
+
* Also, there is only one global name space for the descriptions used as
|
3367
|
+
* keys.
|
2928
3368
|
* To minimize the potential for clashes, use qualified names as keys.
|
2929
3369
|
*/
|
2930
|
-
static Local<Symbol> For(Isolate
|
3370
|
+
static Local<Symbol> For(Isolate* isolate, Local<String> description);
|
2931
3371
|
|
2932
3372
|
/**
|
2933
3373
|
* Retrieve a global symbol. Similar to |For|, but using a separate
|
2934
3374
|
* registry that is not accessible by (and cannot clash with) JavaScript code.
|
2935
3375
|
*/
|
2936
|
-
static Local<Symbol> ForApi(Isolate
|
3376
|
+
static Local<Symbol> ForApi(Isolate* isolate, Local<String> description);
|
2937
3377
|
|
2938
3378
|
// Well-known symbols
|
2939
3379
|
static Local<Symbol> GetAsyncIterator(Isolate* isolate);
|
@@ -3205,7 +3645,7 @@ enum class IndexFilter { kIncludeIndices, kSkipIndices };
|
|
3205
3645
|
* kConvertToString will convert integer indices to strings.
|
3206
3646
|
* kKeepNumbers will return numbers for integer indices.
|
3207
3647
|
*/
|
3208
|
-
enum class KeyConversionMode { kConvertToString, kKeepNumbers };
|
3648
|
+
enum class KeyConversionMode { kConvertToString, kKeepNumbers, kNoNumbers };
|
3209
3649
|
|
3210
3650
|
/**
|
3211
3651
|
* Integrity level for objects.
|
@@ -3217,8 +3657,6 @@ enum class IntegrityLevel { kFrozen, kSealed };
|
|
3217
3657
|
*/
|
3218
3658
|
class V8_EXPORT Object : public Value {
|
3219
3659
|
public:
|
3220
|
-
V8_DEPRECATE_SOON("Use maybe version",
|
3221
|
-
bool Set(Local<Value> key, Local<Value> value));
|
3222
3660
|
/**
|
3223
3661
|
* Set only return Just(true) or Empty(), so if it should never fail, use
|
3224
3662
|
* result.Check().
|
@@ -3226,8 +3664,6 @@ class V8_EXPORT Object : public Value {
|
|
3226
3664
|
V8_WARN_UNUSED_RESULT Maybe<bool> Set(Local<Context> context,
|
3227
3665
|
Local<Value> key, Local<Value> value);
|
3228
3666
|
|
3229
|
-
V8_DEPRECATE_SOON("Use maybe version",
|
3230
|
-
bool Set(uint32_t index, Local<Value> value));
|
3231
3667
|
V8_WARN_UNUSED_RESULT Maybe<bool> Set(Local<Context> context, uint32_t index,
|
3232
3668
|
Local<Value> value);
|
3233
3669
|
|
@@ -3269,13 +3705,12 @@ class V8_EXPORT Object : public Value {
|
|
3269
3705
|
//
|
3270
3706
|
// Returns true on success.
|
3271
3707
|
V8_WARN_UNUSED_RESULT Maybe<bool> DefineProperty(
|
3272
|
-
Local<Context> context, Local<Name> key,
|
3708
|
+
Local<Context> context, Local<Name> key,
|
3709
|
+
PropertyDescriptor& descriptor); // NOLINT(runtime/references)
|
3273
3710
|
|
3274
|
-
V8_DEPRECATE_SOON("Use maybe version", Local<Value> Get(Local<Value> key));
|
3275
3711
|
V8_WARN_UNUSED_RESULT MaybeLocal<Value> Get(Local<Context> context,
|
3276
3712
|
Local<Value> key);
|
3277
3713
|
|
3278
|
-
V8_DEPRECATE_SOON("Use maybe version", Local<Value> Get(uint32_t index));
|
3279
3714
|
V8_WARN_UNUSED_RESULT MaybeLocal<Value> Get(Local<Context> context,
|
3280
3715
|
uint32_t index);
|
3281
3716
|
|
@@ -3381,7 +3816,6 @@ class V8_EXPORT Object : public Value {
|
|
3381
3816
|
* array returned by this method contains the same values as would
|
3382
3817
|
* be enumerated by a for-in statement over this object.
|
3383
3818
|
*/
|
3384
|
-
V8_DEPRECATED("Use maybe version", Local<Array> GetPropertyNames());
|
3385
3819
|
V8_WARN_UNUSED_RESULT MaybeLocal<Array> GetPropertyNames(
|
3386
3820
|
Local<Context> context);
|
3387
3821
|
V8_WARN_UNUSED_RESULT MaybeLocal<Array> GetPropertyNames(
|
@@ -3394,7 +3828,6 @@ class V8_EXPORT Object : public Value {
|
|
3394
3828
|
* the returned array doesn't contain the names of properties from
|
3395
3829
|
* prototype objects.
|
3396
3830
|
*/
|
3397
|
-
V8_DEPRECATED("Use maybe version", Local<Array> GetOwnPropertyNames());
|
3398
3831
|
V8_WARN_UNUSED_RESULT MaybeLocal<Array> GetOwnPropertyNames(
|
3399
3832
|
Local<Context> context);
|
3400
3833
|
|
@@ -3450,12 +3883,18 @@ class V8_EXPORT Object : public Value {
|
|
3450
3883
|
/** Gets the number of internal fields for this Object. */
|
3451
3884
|
int InternalFieldCount();
|
3452
3885
|
|
3453
|
-
/** Same as above, but works for
|
3886
|
+
/** Same as above, but works for PersistentBase. */
|
3454
3887
|
V8_INLINE static int InternalFieldCount(
|
3455
3888
|
const PersistentBase<Object>& object) {
|
3456
3889
|
return object.val_->InternalFieldCount();
|
3457
3890
|
}
|
3458
3891
|
|
3892
|
+
/** Same as above, but works for TracedReferenceBase. */
|
3893
|
+
V8_INLINE static int InternalFieldCount(
|
3894
|
+
const TracedReferenceBase<Object>& object) {
|
3895
|
+
return object.val_->InternalFieldCount();
|
3896
|
+
}
|
3897
|
+
|
3459
3898
|
/** Gets the value from an internal field. */
|
3460
3899
|
V8_INLINE Local<Value> GetInternalField(int index);
|
3461
3900
|
|
@@ -3469,12 +3908,18 @@ class V8_EXPORT Object : public Value {
|
|
3469
3908
|
*/
|
3470
3909
|
V8_INLINE void* GetAlignedPointerFromInternalField(int index);
|
3471
3910
|
|
3472
|
-
/** Same as above, but works for
|
3911
|
+
/** Same as above, but works for PersistentBase. */
|
3473
3912
|
V8_INLINE static void* GetAlignedPointerFromInternalField(
|
3474
3913
|
const PersistentBase<Object>& object, int index) {
|
3475
3914
|
return object.val_->GetAlignedPointerFromInternalField(index);
|
3476
3915
|
}
|
3477
3916
|
|
3917
|
+
/** Same as above, but works for TracedGlobal. */
|
3918
|
+
V8_INLINE static void* GetAlignedPointerFromInternalField(
|
3919
|
+
const TracedReferenceBase<Object>& object, int index) {
|
3920
|
+
return object.val_->GetAlignedPointerFromInternalField(index);
|
3921
|
+
}
|
3922
|
+
|
3478
3923
|
/**
|
3479
3924
|
* Sets a 2-byte-aligned native pointer in an internal field. To retrieve such
|
3480
3925
|
* a field, GetAlignedPointerFromInternalField must be used, everything else
|
@@ -3493,8 +3938,6 @@ class V8_EXPORT Object : public Value {
|
|
3493
3938
|
Local<Name> key);
|
3494
3939
|
V8_WARN_UNUSED_RESULT Maybe<bool> HasOwnProperty(Local<Context> context,
|
3495
3940
|
uint32_t index);
|
3496
|
-
V8_DEPRECATED("Use maybe version",
|
3497
|
-
bool HasRealNamedProperty(Local<String> key));
|
3498
3941
|
/**
|
3499
3942
|
* Use HasRealNamedProperty() if you want to check if an object has an own
|
3500
3943
|
* property without causing side effects, i.e., without calling interceptors.
|
@@ -3510,12 +3953,8 @@ class V8_EXPORT Object : public Value {
|
|
3510
3953
|
*/
|
3511
3954
|
V8_WARN_UNUSED_RESULT Maybe<bool> HasRealNamedProperty(Local<Context> context,
|
3512
3955
|
Local<Name> key);
|
3513
|
-
V8_DEPRECATED("Use maybe version",
|
3514
|
-
bool HasRealIndexedProperty(uint32_t index));
|
3515
3956
|
V8_WARN_UNUSED_RESULT Maybe<bool> HasRealIndexedProperty(
|
3516
3957
|
Local<Context> context, uint32_t index);
|
3517
|
-
V8_DEPRECATED("Use maybe version",
|
3518
|
-
bool HasRealNamedCallbackProperty(Local<String> key));
|
3519
3958
|
V8_WARN_UNUSED_RESULT Maybe<bool> HasRealNamedCallbackProperty(
|
3520
3959
|
Local<Context> context, Local<Name> key);
|
3521
3960
|
|
@@ -3596,6 +4035,22 @@ class V8_EXPORT Object : public Value {
|
|
3596
4035
|
*/
|
3597
4036
|
bool IsConstructor();
|
3598
4037
|
|
4038
|
+
/**
|
4039
|
+
* True if this object can carry information relevant to the embedder in its
|
4040
|
+
* embedder fields, false otherwise. This is generally true for objects
|
4041
|
+
* constructed through function templates but also holds for other types where
|
4042
|
+
* V8 automatically adds internal fields at compile time, such as e.g.
|
4043
|
+
* v8::ArrayBuffer.
|
4044
|
+
*/
|
4045
|
+
bool IsApiWrapper();
|
4046
|
+
|
4047
|
+
/**
|
4048
|
+
* True if this object was created from an object template which was marked
|
4049
|
+
* as undetectable. See v8::ObjectTemplate::MarkAsUndetectable for more
|
4050
|
+
* information.
|
4051
|
+
*/
|
4052
|
+
bool IsUndetectable();
|
4053
|
+
|
3599
4054
|
/**
|
3600
4055
|
* Call an Object as a function if a callback is set by the
|
3601
4056
|
* ObjectTemplate::SetCallAsFunctionHandler method.
|
@@ -3752,15 +4207,14 @@ class ReturnValue {
|
|
3752
4207
|
public:
|
3753
4208
|
template <class S> V8_INLINE ReturnValue(const ReturnValue<S>& that)
|
3754
4209
|
: value_(that.value_) {
|
3755
|
-
|
4210
|
+
static_assert(std::is_base_of<T, S>::value, "type check");
|
3756
4211
|
}
|
3757
4212
|
// Local setters
|
3758
4213
|
template <typename S>
|
3759
|
-
V8_INLINE V8_DEPRECATED("Use Global<> instead",
|
3760
|
-
void Set(const Persistent<S>& handle));
|
3761
|
-
template <typename S>
|
3762
4214
|
V8_INLINE void Set(const Global<S>& handle);
|
3763
4215
|
template <typename S>
|
4216
|
+
V8_INLINE void Set(const TracedReferenceBase<S>& handle);
|
4217
|
+
template <typename S>
|
3764
4218
|
V8_INLINE void Set(const Local<S> handle);
|
3765
4219
|
// Fast primitive setters
|
3766
4220
|
V8_INLINE void Set(bool value);
|
@@ -3807,7 +4261,10 @@ class FunctionCallbackInfo {
|
|
3807
4261
|
public:
|
3808
4262
|
/** The number of available arguments. */
|
3809
4263
|
V8_INLINE int Length() const;
|
3810
|
-
/**
|
4264
|
+
/**
|
4265
|
+
* Accessor for the available arguments. Returns `undefined` if the index
|
4266
|
+
* is out of bounds.
|
4267
|
+
*/
|
3811
4268
|
V8_INLINE Local<Value> operator[](int i) const;
|
3812
4269
|
/** Returns the receiver. This corresponds to the "this" value. */
|
3813
4270
|
V8_INLINE Local<Object> This() const;
|
@@ -3984,11 +4441,6 @@ class V8_EXPORT Function : public Object {
|
|
3984
4441
|
Local<Value> data = Local<Value>(), int length = 0,
|
3985
4442
|
ConstructorBehavior behavior = ConstructorBehavior::kAllow,
|
3986
4443
|
SideEffectType side_effect_type = SideEffectType::kHasSideEffect);
|
3987
|
-
static V8_DEPRECATED("Use maybe version",
|
3988
|
-
Local<Function> New(Isolate* isolate,
|
3989
|
-
FunctionCallback callback,
|
3990
|
-
Local<Value> data = Local<Value>(),
|
3991
|
-
int length = 0));
|
3992
4444
|
|
3993
4445
|
V8_WARN_UNUSED_RESULT MaybeLocal<Object> NewInstance(
|
3994
4446
|
Local<Context> context, int argc, Local<Value> argv[]) const;
|
@@ -4007,9 +4459,6 @@ class V8_EXPORT Function : public Object {
|
|
4007
4459
|
Local<Context> context, int argc, Local<Value> argv[],
|
4008
4460
|
SideEffectType side_effect_type = SideEffectType::kHasSideEffect) const;
|
4009
4461
|
|
4010
|
-
V8_DEPRECATED("Use maybe version",
|
4011
|
-
Local<Value> Call(Local<Value> recv, int argc,
|
4012
|
-
Local<Value> argv[]));
|
4013
4462
|
V8_WARN_UNUSED_RESULT MaybeLocal<Value> Call(Local<Context> context,
|
4014
4463
|
Local<Value> recv, int argc,
|
4015
4464
|
Local<Value> argv[]);
|
@@ -4194,14 +4643,6 @@ class V8_EXPORT PropertyDescriptor {
|
|
4194
4643
|
// GenericDescriptor
|
4195
4644
|
PropertyDescriptor();
|
4196
4645
|
|
4197
|
-
// DataDescriptor (implicit / DEPRECATED)
|
4198
|
-
// Templatized such that the explicit constructor is chosen first.
|
4199
|
-
// TODO(clemensh): Remove after 7.3 branch.
|
4200
|
-
template <std::nullptr_t = nullptr>
|
4201
|
-
V8_DEPRECATED(
|
4202
|
-
"Use explicit constructor",
|
4203
|
-
PropertyDescriptor(Local<Value> value)); // NOLINT(runtime/explicit)
|
4204
|
-
|
4205
4646
|
// DataDescriptor
|
4206
4647
|
explicit PropertyDescriptor(Local<Value> value);
|
4207
4648
|
|
@@ -4242,11 +4683,6 @@ class V8_EXPORT PropertyDescriptor {
|
|
4242
4683
|
PrivateData* private_;
|
4243
4684
|
};
|
4244
4685
|
|
4245
|
-
// TODO(clemensh): Remove after 7.3 branch.
|
4246
|
-
template <std::nullptr_t>
|
4247
|
-
PropertyDescriptor::PropertyDescriptor(Local<Value> value)
|
4248
|
-
: PropertyDescriptor(value) {}
|
4249
|
-
|
4250
4686
|
/**
|
4251
4687
|
* An instance of the built-in Proxy constructor (ECMA-262, 6th Edition,
|
4252
4688
|
* 26.2.1).
|
@@ -4336,74 +4772,14 @@ class V8_EXPORT CompiledWasmModule {
|
|
4336
4772
|
// An instance of WebAssembly.Module.
|
4337
4773
|
class V8_EXPORT WasmModuleObject : public Object {
|
4338
4774
|
public:
|
4339
|
-
|
4340
|
-
V8_DEPRECATED("Use OwnedBuffer", typedef)
|
4341
|
-
std::pair<std::unique_ptr<const uint8_t[]>, size_t> SerializedModule;
|
4342
|
-
|
4343
|
-
/**
|
4344
|
-
* A unowned reference to a byte buffer.
|
4345
|
-
* TODO(clemensh): Remove after 7.3 branch.
|
4346
|
-
*/
|
4347
|
-
V8_DEPRECATED("Use MemorySpan<const uint8_t>", struct) BufferReference {
|
4348
|
-
const uint8_t* start;
|
4349
|
-
size_t size;
|
4350
|
-
BufferReference(const uint8_t* start, size_t size)
|
4351
|
-
: start(start), size(size) {}
|
4352
|
-
|
4353
|
-
// Implicit conversion to and from MemorySpan<const uint8_t>.
|
4354
|
-
BufferReference(MemorySpan<const uint8_t> span) // NOLINT(runtime/explicit)
|
4355
|
-
: start(span.data()), size(span.size()) {}
|
4356
|
-
operator MemorySpan<const uint8_t>() const {
|
4357
|
-
return MemorySpan<const uint8_t>{start, size};
|
4358
|
-
}
|
4359
|
-
};
|
4360
|
-
|
4361
|
-
/**
|
4362
|
-
* An opaque, native heap object for transferring wasm modules. It
|
4363
|
-
* supports move semantics, and does not support copy semantics.
|
4364
|
-
* TODO(wasm): Merge this with CompiledWasmModule once code sharing is always
|
4365
|
-
* enabled.
|
4366
|
-
*/
|
4367
|
-
class TransferrableModule final {
|
4368
|
-
public:
|
4369
|
-
TransferrableModule(TransferrableModule&& src) = default;
|
4370
|
-
TransferrableModule(const TransferrableModule& src) = delete;
|
4371
|
-
|
4372
|
-
TransferrableModule& operator=(TransferrableModule&& src) = default;
|
4373
|
-
TransferrableModule& operator=(const TransferrableModule& src) = delete;
|
4374
|
-
|
4375
|
-
private:
|
4376
|
-
typedef std::shared_ptr<internal::wasm::NativeModule> SharedModule;
|
4377
|
-
friend class WasmModuleObject;
|
4378
|
-
explicit TransferrableModule(SharedModule shared_module)
|
4379
|
-
: shared_module_(std::move(shared_module)) {}
|
4380
|
-
TransferrableModule(OwnedBuffer serialized, OwnedBuffer bytes)
|
4381
|
-
: serialized_(std::move(serialized)), wire_bytes_(std::move(bytes)) {}
|
4382
|
-
|
4383
|
-
SharedModule shared_module_;
|
4384
|
-
OwnedBuffer serialized_ = {nullptr, 0};
|
4385
|
-
OwnedBuffer wire_bytes_ = {nullptr, 0};
|
4386
|
-
};
|
4387
|
-
|
4388
|
-
/**
|
4389
|
-
* Get an in-memory, non-persistable, and context-independent (meaning,
|
4390
|
-
* suitable for transfer to another Isolate and Context) representation
|
4391
|
-
* of this wasm compiled module.
|
4392
|
-
*/
|
4393
|
-
TransferrableModule GetTransferrableModule();
|
4775
|
+
WasmModuleObject() = delete;
|
4394
4776
|
|
4395
4777
|
/**
|
4396
4778
|
* Efficiently re-create a WasmModuleObject, without recompiling, from
|
4397
|
-
* a
|
4398
|
-
*/
|
4399
|
-
static MaybeLocal<WasmModuleObject> FromTransferrableModule(
|
4400
|
-
Isolate* isolate, const TransferrableModule&);
|
4401
|
-
|
4402
|
-
/**
|
4403
|
-
* Get the wasm-encoded bytes that were used to compile this module.
|
4779
|
+
* a CompiledWasmModule.
|
4404
4780
|
*/
|
4405
|
-
|
4406
|
-
|
4781
|
+
static MaybeLocal<WasmModuleObject> FromCompiledModule(
|
4782
|
+
Isolate* isolate, const CompiledWasmModule&);
|
4407
4783
|
|
4408
4784
|
/**
|
4409
4785
|
* Get the compiled module for this module object. The compiled module can be
|
@@ -4411,40 +4787,12 @@ class V8_EXPORT WasmModuleObject : public Object {
|
|
4411
4787
|
*/
|
4412
4788
|
CompiledWasmModule GetCompiledModule();
|
4413
4789
|
|
4414
|
-
/**
|
4415
|
-
* Serialize the compiled module. The serialized data does not include the
|
4416
|
-
* uncompiled bytes.
|
4417
|
-
*/
|
4418
|
-
V8_DEPRECATED("Use CompiledWasmModule::Serialize()",
|
4419
|
-
SerializedModule Serialize());
|
4420
|
-
|
4421
|
-
/**
|
4422
|
-
* If possible, deserialize the module, otherwise compile it from the provided
|
4423
|
-
* uncompiled bytes.
|
4424
|
-
*/
|
4425
|
-
static MaybeLocal<WasmModuleObject> DeserializeOrCompile(
|
4426
|
-
Isolate* isolate, MemorySpan<const uint8_t> serialized_module,
|
4427
|
-
MemorySpan<const uint8_t> wire_bytes);
|
4428
4790
|
V8_INLINE static WasmModuleObject* Cast(Value* obj);
|
4429
4791
|
|
4430
4792
|
private:
|
4431
|
-
static MaybeLocal<WasmModuleObject> Deserialize(
|
4432
|
-
Isolate* isolate, MemorySpan<const uint8_t> serialized_module,
|
4433
|
-
MemorySpan<const uint8_t> wire_bytes);
|
4434
|
-
static MaybeLocal<WasmModuleObject> Compile(Isolate* isolate,
|
4435
|
-
const uint8_t* start,
|
4436
|
-
size_t length);
|
4437
|
-
static MemorySpan<const uint8_t> AsReference(const OwnedBuffer& buff) {
|
4438
|
-
return {buff.buffer.get(), buff.size};
|
4439
|
-
}
|
4440
|
-
|
4441
|
-
WasmModuleObject();
|
4442
4793
|
static void CheckCast(Value* obj);
|
4443
4794
|
};
|
4444
4795
|
|
4445
|
-
V8_DEPRECATED("Use WasmModuleObject",
|
4446
|
-
typedef WasmModuleObject WasmCompiledModule);
|
4447
|
-
|
4448
4796
|
/**
|
4449
4797
|
* The V8 interface for WebAssembly streaming compilation. When streaming
|
4450
4798
|
* compilation is initiated, V8 passes a {WasmStreaming} object to the embedder
|
@@ -4507,6 +4855,12 @@ class V8_EXPORT WasmStreaming final {
|
|
4507
4855
|
*/
|
4508
4856
|
void SetClient(std::shared_ptr<Client> client);
|
4509
4857
|
|
4858
|
+
/*
|
4859
|
+
* Sets the UTF-8 encoded source URL for the {Script} object. This must be
|
4860
|
+
* called before {Finish}.
|
4861
|
+
*/
|
4862
|
+
void SetUrl(const char* url, size_t length);
|
4863
|
+
|
4510
4864
|
/**
|
4511
4865
|
* Unpacks a {WasmStreaming} object wrapped in a {Managed} for the embedder.
|
4512
4866
|
* Since the embedder is on the other side of the API, it cannot unpack the
|
@@ -4571,8 +4925,85 @@ class V8_EXPORT WasmModuleObjectBuilderStreaming final {
|
|
4571
4925
|
#endif
|
4572
4926
|
|
4573
4927
|
|
4574
|
-
enum class ArrayBufferCreationMode { kInternalized, kExternalized };
|
4928
|
+
enum class ArrayBufferCreationMode { kInternalized, kExternalized };
|
4929
|
+
|
4930
|
+
/**
|
4931
|
+
* A wrapper around the backing store (i.e. the raw memory) of an array buffer.
|
4932
|
+
* See a document linked in http://crbug.com/v8/9908 for more information.
|
4933
|
+
*
|
4934
|
+
* The allocation and destruction of backing stores is generally managed by
|
4935
|
+
* V8. Clients should always use standard C++ memory ownership types (i.e.
|
4936
|
+
* std::unique_ptr and std::shared_ptr) to manage lifetimes of backing stores
|
4937
|
+
* properly, since V8 internal objects may alias backing stores.
|
4938
|
+
*
|
4939
|
+
* This object does not keep the underlying |ArrayBuffer::Allocator| alive by
|
4940
|
+
* default. Use Isolate::CreateParams::array_buffer_allocator_shared when
|
4941
|
+
* creating the Isolate to make it hold a reference to the allocator itself.
|
4942
|
+
*/
|
4943
|
+
class V8_EXPORT BackingStore : public v8::internal::BackingStoreBase {
|
4944
|
+
public:
|
4945
|
+
~BackingStore();
|
4946
|
+
|
4947
|
+
/**
|
4948
|
+
* Return a pointer to the beginning of the memory block for this backing
|
4949
|
+
* store. The pointer is only valid as long as this backing store object
|
4950
|
+
* lives.
|
4951
|
+
*/
|
4952
|
+
void* Data() const;
|
4953
|
+
|
4954
|
+
/**
|
4955
|
+
* The length (in bytes) of this backing store.
|
4956
|
+
*/
|
4957
|
+
size_t ByteLength() const;
|
4958
|
+
|
4959
|
+
/**
|
4960
|
+
* Indicates whether the backing store was created for an ArrayBuffer or
|
4961
|
+
* a SharedArrayBuffer.
|
4962
|
+
*/
|
4963
|
+
bool IsShared() const;
|
4964
|
+
|
4965
|
+
/**
|
4966
|
+
* Wrapper around ArrayBuffer::Allocator::Reallocate that preserves IsShared.
|
4967
|
+
* Assumes that the backing_store was allocated by the ArrayBuffer allocator
|
4968
|
+
* of the given isolate.
|
4969
|
+
*/
|
4970
|
+
static std::unique_ptr<BackingStore> Reallocate(
|
4971
|
+
v8::Isolate* isolate, std::unique_ptr<BackingStore> backing_store,
|
4972
|
+
size_t byte_length);
|
4973
|
+
|
4974
|
+
/**
|
4975
|
+
* This callback is used only if the memory block for a BackingStore cannot be
|
4976
|
+
* allocated with an ArrayBuffer::Allocator. In such cases the destructor of
|
4977
|
+
* the BackingStore invokes the callback to free the memory block.
|
4978
|
+
*/
|
4979
|
+
using DeleterCallback = void (*)(void* data, size_t length,
|
4980
|
+
void* deleter_data);
|
4981
|
+
|
4982
|
+
/**
|
4983
|
+
* If the memory block of a BackingStore is static or is managed manually,
|
4984
|
+
* then this empty deleter along with nullptr deleter_data can be passed to
|
4985
|
+
* ArrayBuffer::NewBackingStore to indicate that.
|
4986
|
+
*
|
4987
|
+
* The manually managed case should be used with caution and only when it
|
4988
|
+
* is guaranteed that the memory block freeing happens after detaching its
|
4989
|
+
* ArrayBuffer.
|
4990
|
+
*/
|
4991
|
+
static void EmptyDeleter(void* data, size_t length, void* deleter_data);
|
4992
|
+
|
4993
|
+
private:
|
4994
|
+
/**
|
4995
|
+
* See [Shared]ArrayBuffer::GetBackingStore and
|
4996
|
+
* [Shared]ArrayBuffer::NewBackingStore.
|
4997
|
+
*/
|
4998
|
+
BackingStore();
|
4999
|
+
};
|
5000
|
+
|
5001
|
+
#if !defined(V8_IMMINENT_DEPRECATION_WARNINGS)
|
5002
|
+
// Use v8::BackingStore::DeleterCallback instead.
|
5003
|
+
using BackingStoreDeleterCallback = void (*)(void* data, size_t length,
|
5004
|
+
void* deleter_data);
|
4575
5005
|
|
5006
|
+
#endif
|
4576
5007
|
|
4577
5008
|
/**
|
4578
5009
|
* An instance of the built-in ArrayBuffer constructor (ES6 draft 15.13.5).
|
@@ -4599,13 +5030,13 @@ class V8_EXPORT ArrayBuffer : public Object {
|
|
4599
5030
|
virtual ~Allocator() = default;
|
4600
5031
|
|
4601
5032
|
/**
|
4602
|
-
* Allocate |length| bytes. Return
|
5033
|
+
* Allocate |length| bytes. Return nullptr if allocation is not successful.
|
4603
5034
|
* Memory should be initialized to zeroes.
|
4604
5035
|
*/
|
4605
5036
|
virtual void* Allocate(size_t length) = 0;
|
4606
5037
|
|
4607
5038
|
/**
|
4608
|
-
* Allocate |length| bytes. Return
|
5039
|
+
* Allocate |length| bytes. Return nullptr if allocation is not successful.
|
4609
5040
|
* Memory does not have to be initialized.
|
4610
5041
|
*/
|
4611
5042
|
virtual void* AllocateUninitialized(size_t length) = 0;
|
@@ -4616,6 +5047,20 @@ class V8_EXPORT ArrayBuffer : public Object {
|
|
4616
5047
|
*/
|
4617
5048
|
virtual void Free(void* data, size_t length) = 0;
|
4618
5049
|
|
5050
|
+
/**
|
5051
|
+
* Reallocate the memory block of size |old_length| to a memory block of
|
5052
|
+
* size |new_length| by expanding, contracting, or copying the existing
|
5053
|
+
* memory block. If |new_length| > |old_length|, then the new part of
|
5054
|
+
* the memory must be initialized to zeros. Return nullptr if reallocation
|
5055
|
+
* is not successful.
|
5056
|
+
*
|
5057
|
+
* The caller guarantees that the memory block was previously allocated
|
5058
|
+
* using Allocate or AllocateUninitialized.
|
5059
|
+
*
|
5060
|
+
* The default implementation allocates a new block and copies data.
|
5061
|
+
*/
|
5062
|
+
virtual void* Reallocate(void* data, size_t old_length, size_t new_length);
|
5063
|
+
|
4619
5064
|
/**
|
4620
5065
|
* ArrayBuffer allocation mode. kNormal is a malloc/free style allocation,
|
4621
5066
|
* while kReservation is for larger allocations with the ability to set
|
@@ -4705,14 +5150,58 @@ class V8_EXPORT ArrayBuffer : public Object {
|
|
4705
5150
|
* |Allocator::Free| once all ArrayBuffers referencing it are collected by
|
4706
5151
|
* the garbage collector.
|
4707
5152
|
*/
|
5153
|
+
V8_DEPRECATE_SOON(
|
5154
|
+
"Use the version that takes a BackingStore. "
|
5155
|
+
"See http://crbug.com/v8/9908.")
|
4708
5156
|
static Local<ArrayBuffer> New(
|
4709
5157
|
Isolate* isolate, void* data, size_t byte_length,
|
4710
5158
|
ArrayBufferCreationMode mode = ArrayBufferCreationMode::kExternalized);
|
4711
5159
|
|
5160
|
+
/**
|
5161
|
+
* Create a new ArrayBuffer with an existing backing store.
|
5162
|
+
* The created array keeps a reference to the backing store until the array
|
5163
|
+
* is garbage collected. Note that the IsExternal bit does not affect this
|
5164
|
+
* reference from the array to the backing store.
|
5165
|
+
*
|
5166
|
+
* In future IsExternal bit will be removed. Until then the bit is set as
|
5167
|
+
* follows. If the backing store does not own the underlying buffer, then
|
5168
|
+
* the array is created in externalized state. Otherwise, the array is created
|
5169
|
+
* in internalized state. In the latter case the array can be transitioned
|
5170
|
+
* to the externalized state using Externalize(backing_store).
|
5171
|
+
*/
|
5172
|
+
static Local<ArrayBuffer> New(Isolate* isolate,
|
5173
|
+
std::shared_ptr<BackingStore> backing_store);
|
5174
|
+
|
5175
|
+
/**
|
5176
|
+
* Returns a new standalone BackingStore that is allocated using the array
|
5177
|
+
* buffer allocator of the isolate. The result can be later passed to
|
5178
|
+
* ArrayBuffer::New.
|
5179
|
+
*
|
5180
|
+
* If the allocator returns nullptr, then the function may cause GCs in the
|
5181
|
+
* given isolate and re-try the allocation. If GCs do not help, then the
|
5182
|
+
* function will crash with an out-of-memory error.
|
5183
|
+
*/
|
5184
|
+
static std::unique_ptr<BackingStore> NewBackingStore(Isolate* isolate,
|
5185
|
+
size_t byte_length);
|
5186
|
+
/**
|
5187
|
+
* Returns a new standalone BackingStore that takes over the ownership of
|
5188
|
+
* the given buffer. The destructor of the BackingStore invokes the given
|
5189
|
+
* deleter callback.
|
5190
|
+
*
|
5191
|
+
* The result can be later passed to ArrayBuffer::New. The raw pointer
|
5192
|
+
* to the buffer must not be passed again to any V8 API function.
|
5193
|
+
*/
|
5194
|
+
static std::unique_ptr<BackingStore> NewBackingStore(
|
5195
|
+
void* data, size_t byte_length, v8::BackingStore::DeleterCallback deleter,
|
5196
|
+
void* deleter_data);
|
5197
|
+
|
4712
5198
|
/**
|
4713
5199
|
* Returns true if ArrayBuffer is externalized, that is, does not
|
4714
5200
|
* own its memory block.
|
4715
5201
|
*/
|
5202
|
+
V8_DEPRECATE_SOON(
|
5203
|
+
"With v8::BackingStore externalized ArrayBuffers are "
|
5204
|
+
"the same as ordinary ArrayBuffers. See http://crbug.com/v8/9908.")
|
4716
5205
|
bool IsExternal() const;
|
4717
5206
|
|
4718
5207
|
/**
|
@@ -4720,12 +5209,6 @@ class V8_EXPORT ArrayBuffer : public Object {
|
|
4720
5209
|
*/
|
4721
5210
|
bool IsDetachable() const;
|
4722
5211
|
|
4723
|
-
// TODO(913887): fix the use of 'neuter' in the API.
|
4724
|
-
V8_DEPRECATE_SOON("Use IsDetachable() instead.",
|
4725
|
-
inline bool IsNeuterable() const) {
|
4726
|
-
return IsDetachable();
|
4727
|
-
}
|
4728
|
-
|
4729
5212
|
/**
|
4730
5213
|
* Detaches this ArrayBuffer and all its views (typed arrays).
|
4731
5214
|
* Detaching sets the byte length of the buffer and all typed arrays to zero,
|
@@ -4734,9 +5217,6 @@ class V8_EXPORT ArrayBuffer : public Object {
|
|
4734
5217
|
*/
|
4735
5218
|
void Detach();
|
4736
5219
|
|
4737
|
-
// TODO(913887): fix the use of 'neuter' in the API.
|
4738
|
-
V8_DEPRECATE_SOON("Use Detach() instead.", inline void Neuter()) { Detach(); }
|
4739
|
-
|
4740
5220
|
/**
|
4741
5221
|
* Make this ArrayBuffer external. The pointer to underlying memory block
|
4742
5222
|
* and byte length are returned as |Contents| structure. After ArrayBuffer
|
@@ -4745,10 +5225,22 @@ class V8_EXPORT ArrayBuffer : public Object {
|
|
4745
5225
|
*
|
4746
5226
|
* The Data pointer of ArrayBuffer::Contents must be freed using the provided
|
4747
5227
|
* deleter, which will call ArrayBuffer::Allocator::Free if the buffer
|
4748
|
-
* was allocated with
|
5228
|
+
* was allocated with ArrayBuffer::Allocator::Allocate.
|
4749
5229
|
*/
|
5230
|
+
V8_DEPRECATE_SOON(
|
5231
|
+
"Use GetBackingStore or Detach. See http://crbug.com/v8/9908.")
|
4750
5232
|
Contents Externalize();
|
4751
5233
|
|
5234
|
+
/**
|
5235
|
+
* Marks this ArrayBuffer external given a witness that the embedder
|
5236
|
+
* has fetched the backing store using the new GetBackingStore() function.
|
5237
|
+
*
|
5238
|
+
* With the new lifetime management of backing stores there is no need for
|
5239
|
+
* externalizing, so this function exists only to make the transition easier.
|
5240
|
+
*/
|
5241
|
+
V8_DEPRECATE_SOON("This will be removed together with IsExternal.")
|
5242
|
+
void Externalize(const std::shared_ptr<BackingStore>& backing_store);
|
5243
|
+
|
4752
5244
|
/**
|
4753
5245
|
* Get a pointer to the ArrayBuffer's underlying memory block without
|
4754
5246
|
* externalizing it. If the ArrayBuffer is not externalized, this pointer
|
@@ -4757,8 +5249,19 @@ class V8_EXPORT ArrayBuffer : public Object {
|
|
4757
5249
|
* The embedder should make sure to hold a strong reference to the
|
4758
5250
|
* ArrayBuffer while accessing this pointer.
|
4759
5251
|
*/
|
5252
|
+
V8_DEPRECATE_SOON("Use GetBackingStore. See http://crbug.com/v8/9908.")
|
4760
5253
|
Contents GetContents();
|
4761
5254
|
|
5255
|
+
/**
|
5256
|
+
* Get a shared pointer to the backing store of this array buffer. This
|
5257
|
+
* pointer coordinates the lifetime management of the internal storage
|
5258
|
+
* with any live ArrayBuffers on the heap, even across isolates. The embedder
|
5259
|
+
* should not attempt to manage lifetime of the storage through other means.
|
5260
|
+
*
|
5261
|
+
* This function replaces both Externalize() and GetContents().
|
5262
|
+
*/
|
5263
|
+
std::shared_ptr<BackingStore> GetBackingStore();
|
5264
|
+
|
4762
5265
|
V8_INLINE static ArrayBuffer* Cast(Value* obj);
|
4763
5266
|
|
4764
5267
|
static const int kInternalFieldCount = V8_ARRAY_BUFFER_INTERNAL_FIELD_COUNT;
|
@@ -4767,6 +5270,7 @@ class V8_EXPORT ArrayBuffer : public Object {
|
|
4767
5270
|
private:
|
4768
5271
|
ArrayBuffer();
|
4769
5272
|
static void CheckCast(Value* obj);
|
5273
|
+
Contents GetContents(bool externalize);
|
4770
5274
|
};
|
4771
5275
|
|
4772
5276
|
|
@@ -4834,7 +5338,9 @@ class V8_EXPORT TypedArray : public ArrayBufferView {
|
|
4834
5338
|
/*
|
4835
5339
|
* The largest typed array size that can be constructed using New.
|
4836
5340
|
*/
|
4837
|
-
static constexpr size_t kMaxLength = internal::
|
5341
|
+
static constexpr size_t kMaxLength = internal::kApiSystemPointerSize == 4
|
5342
|
+
? internal::kSmiMaxValue
|
5343
|
+
: 0xFFFFFFFF;
|
4838
5344
|
|
4839
5345
|
/**
|
4840
5346
|
* Number of elements in this typed array
|
@@ -5053,7 +5559,6 @@ class V8_EXPORT DataView : public ArrayBufferView {
|
|
5053
5559
|
|
5054
5560
|
/**
|
5055
5561
|
* An instance of the built-in SharedArrayBuffer constructor.
|
5056
|
-
* This API is experimental and may change significantly.
|
5057
5562
|
*/
|
5058
5563
|
class V8_EXPORT SharedArrayBuffer : public Object {
|
5059
5564
|
public:
|
@@ -5065,8 +5570,6 @@ class V8_EXPORT SharedArrayBuffer : public Object {
|
|
5065
5570
|
* The Data pointer of ArrayBuffer::Contents must be freed using the provided
|
5066
5571
|
* deleter, which will call ArrayBuffer::Allocator::Free if the buffer
|
5067
5572
|
* was allocated with ArraryBuffer::Allocator::Allocate.
|
5068
|
-
*
|
5069
|
-
* This API is experimental and may change significantly.
|
5070
5573
|
*/
|
5071
5574
|
class V8_EXPORT Contents { // NOLINT
|
5072
5575
|
public:
|
@@ -5129,14 +5632,69 @@ class V8_EXPORT SharedArrayBuffer : public Object {
|
|
5129
5632
|
* specified. The memory block will not be reclaimed when a created
|
5130
5633
|
* SharedArrayBuffer is garbage-collected.
|
5131
5634
|
*/
|
5635
|
+
V8_DEPRECATE_SOON(
|
5636
|
+
"Use the version that takes a BackingStore. "
|
5637
|
+
"See http://crbug.com/v8/9908.")
|
5132
5638
|
static Local<SharedArrayBuffer> New(
|
5133
5639
|
Isolate* isolate, void* data, size_t byte_length,
|
5134
5640
|
ArrayBufferCreationMode mode = ArrayBufferCreationMode::kExternalized);
|
5135
5641
|
|
5642
|
+
/**
|
5643
|
+
* Create a new SharedArrayBuffer with an existing backing store.
|
5644
|
+
* The created array keeps a reference to the backing store until the array
|
5645
|
+
* is garbage collected. Note that the IsExternal bit does not affect this
|
5646
|
+
* reference from the array to the backing store.
|
5647
|
+
*
|
5648
|
+
* In future IsExternal bit will be removed. Until then the bit is set as
|
5649
|
+
* follows. If the backing store does not own the underlying buffer, then
|
5650
|
+
* the array is created in externalized state. Otherwise, the array is created
|
5651
|
+
* in internalized state. In the latter case the array can be transitioned
|
5652
|
+
* to the externalized state using Externalize(backing_store).
|
5653
|
+
*/
|
5654
|
+
static Local<SharedArrayBuffer> New(
|
5655
|
+
Isolate* isolate, std::shared_ptr<BackingStore> backing_store);
|
5656
|
+
|
5657
|
+
/**
|
5658
|
+
* Returns a new standalone BackingStore that is allocated using the array
|
5659
|
+
* buffer allocator of the isolate. The result can be later passed to
|
5660
|
+
* SharedArrayBuffer::New.
|
5661
|
+
*
|
5662
|
+
* If the allocator returns nullptr, then the function may cause GCs in the
|
5663
|
+
* given isolate and re-try the allocation. If GCs do not help, then the
|
5664
|
+
* function will crash with an out-of-memory error.
|
5665
|
+
*/
|
5666
|
+
static std::unique_ptr<BackingStore> NewBackingStore(Isolate* isolate,
|
5667
|
+
size_t byte_length);
|
5668
|
+
/**
|
5669
|
+
* Returns a new standalone BackingStore that takes over the ownership of
|
5670
|
+
* the given buffer. The destructor of the BackingStore invokes the given
|
5671
|
+
* deleter callback.
|
5672
|
+
*
|
5673
|
+
* The result can be later passed to SharedArrayBuffer::New. The raw pointer
|
5674
|
+
* to the buffer must not be passed again to any V8 functions.
|
5675
|
+
*/
|
5676
|
+
static std::unique_ptr<BackingStore> NewBackingStore(
|
5677
|
+
void* data, size_t byte_length, v8::BackingStore::DeleterCallback deleter,
|
5678
|
+
void* deleter_data);
|
5679
|
+
|
5680
|
+
/**
|
5681
|
+
* Create a new SharedArrayBuffer over an existing memory block. Propagate
|
5682
|
+
* flags to indicate whether the underlying buffer can be grown.
|
5683
|
+
*/
|
5684
|
+
V8_DEPRECATED(
|
5685
|
+
"Use the version that takes a BackingStore. "
|
5686
|
+
"See http://crbug.com/v8/9908.")
|
5687
|
+
static Local<SharedArrayBuffer> New(
|
5688
|
+
Isolate* isolate, const SharedArrayBuffer::Contents&,
|
5689
|
+
ArrayBufferCreationMode mode = ArrayBufferCreationMode::kExternalized);
|
5690
|
+
|
5136
5691
|
/**
|
5137
5692
|
* Returns true if SharedArrayBuffer is externalized, that is, does not
|
5138
5693
|
* own its memory block.
|
5139
5694
|
*/
|
5695
|
+
V8_DEPRECATE_SOON(
|
5696
|
+
"With v8::BackingStore externalized SharedArrayBuffers are the same "
|
5697
|
+
"as ordinary SharedArrayBuffers. See http://crbug.com/v8/9908.")
|
5140
5698
|
bool IsExternal() const;
|
5141
5699
|
|
5142
5700
|
/**
|
@@ -5151,8 +5709,20 @@ class V8_EXPORT SharedArrayBuffer : public Object {
|
|
5151
5709
|
* v8::Isolate::CreateParams::array_buffer_allocator.
|
5152
5710
|
*
|
5153
5711
|
*/
|
5712
|
+
V8_DEPRECATE_SOON(
|
5713
|
+
"Use GetBackingStore or Detach. See http://crbug.com/v8/9908.")
|
5154
5714
|
Contents Externalize();
|
5155
5715
|
|
5716
|
+
/**
|
5717
|
+
* Marks this SharedArrayBuffer external given a witness that the embedder
|
5718
|
+
* has fetched the backing store using the new GetBackingStore() function.
|
5719
|
+
*
|
5720
|
+
* With the new lifetime management of backing stores there is no need for
|
5721
|
+
* externalizing, so this function exists only to make the transition easier.
|
5722
|
+
*/
|
5723
|
+
V8_DEPRECATE_SOON("This will be removed together with IsExternal.")
|
5724
|
+
void Externalize(const std::shared_ptr<BackingStore>& backing_store);
|
5725
|
+
|
5156
5726
|
/**
|
5157
5727
|
* Get a pointer to the ArrayBuffer's underlying memory block without
|
5158
5728
|
* externalizing it. If the ArrayBuffer is not externalized, this pointer
|
@@ -5165,8 +5735,19 @@ class V8_EXPORT SharedArrayBuffer : public Object {
|
|
5165
5735
|
* by the allocator specified in
|
5166
5736
|
* v8::Isolate::CreateParams::array_buffer_allocator.
|
5167
5737
|
*/
|
5738
|
+
V8_DEPRECATE_SOON("Use GetBackingStore. See http://crbug.com/v8/9908.")
|
5168
5739
|
Contents GetContents();
|
5169
5740
|
|
5741
|
+
/**
|
5742
|
+
* Get a shared pointer to the backing store of this array buffer. This
|
5743
|
+
* pointer coordinates the lifetime management of the internal storage
|
5744
|
+
* with any live ArrayBuffers on the heap, even across isolates. The embedder
|
5745
|
+
* should not attempt to manage lifetime of the storage through other means.
|
5746
|
+
*
|
5747
|
+
* This function replaces both Externalize() and GetContents().
|
5748
|
+
*/
|
5749
|
+
std::shared_ptr<BackingStore> GetBackingStore();
|
5750
|
+
|
5170
5751
|
V8_INLINE static SharedArrayBuffer* Cast(Value* obj);
|
5171
5752
|
|
5172
5753
|
static const int kInternalFieldCount = V8_ARRAY_BUFFER_INTERNAL_FIELD_COUNT;
|
@@ -5174,6 +5755,7 @@ class V8_EXPORT SharedArrayBuffer : public Object {
|
|
5174
5755
|
private:
|
5175
5756
|
SharedArrayBuffer();
|
5176
5757
|
static void CheckCast(Value* obj);
|
5758
|
+
Contents GetContents(bool externalize);
|
5177
5759
|
};
|
5178
5760
|
|
5179
5761
|
|
@@ -5193,20 +5775,6 @@ class V8_EXPORT Date : public Object {
|
|
5193
5775
|
|
5194
5776
|
V8_INLINE static Date* Cast(Value* obj);
|
5195
5777
|
|
5196
|
-
/**
|
5197
|
-
* Notification that the embedder has changed the time zone,
|
5198
|
-
* daylight savings time, or other date / time configuration
|
5199
|
-
* parameters. V8 keeps a cache of various values used for
|
5200
|
-
* date / time computation. This notification will reset
|
5201
|
-
* those cached values for the current context so that date /
|
5202
|
-
* time configuration changes would be reflected in the Date
|
5203
|
-
* object.
|
5204
|
-
*
|
5205
|
-
* This API should not be called more than needed as it will
|
5206
|
-
* negatively impact the performance of date operations.
|
5207
|
-
*/
|
5208
|
-
static void DateTimeConfigurationChangeNotification(Isolate* isolate);
|
5209
|
-
|
5210
5778
|
private:
|
5211
5779
|
static void CheckCast(Value* obj);
|
5212
5780
|
};
|
@@ -5309,6 +5877,8 @@ class V8_EXPORT RegExp : public Object {
|
|
5309
5877
|
kDotAll = 1 << 5,
|
5310
5878
|
};
|
5311
5879
|
|
5880
|
+
static constexpr int kFlagCount = 6;
|
5881
|
+
|
5312
5882
|
/**
|
5313
5883
|
* Creates a regular expression from the given pattern string and
|
5314
5884
|
* the flags bit field. May throw a JavaScript exception as
|
@@ -5323,6 +5893,29 @@ class V8_EXPORT RegExp : public Object {
|
|
5323
5893
|
Local<String> pattern,
|
5324
5894
|
Flags flags);
|
5325
5895
|
|
5896
|
+
/**
|
5897
|
+
* Like New, but additionally specifies a backtrack limit. If the number of
|
5898
|
+
* backtracks done in one Exec call hits the limit, a match failure is
|
5899
|
+
* immediately returned.
|
5900
|
+
*/
|
5901
|
+
static V8_WARN_UNUSED_RESULT MaybeLocal<RegExp> NewWithBacktrackLimit(
|
5902
|
+
Local<Context> context, Local<String> pattern, Flags flags,
|
5903
|
+
uint32_t backtrack_limit);
|
5904
|
+
|
5905
|
+
/**
|
5906
|
+
* Executes the current RegExp instance on the given subject string.
|
5907
|
+
* Equivalent to RegExp.prototype.exec as described in
|
5908
|
+
*
|
5909
|
+
* https://tc39.es/ecma262/#sec-regexp.prototype.exec
|
5910
|
+
*
|
5911
|
+
* On success, an Array containing the matched strings is returned. On
|
5912
|
+
* failure, returns Null.
|
5913
|
+
*
|
5914
|
+
* Note: modifies global context state, accessible e.g. through RegExp.input.
|
5915
|
+
*/
|
5916
|
+
V8_WARN_UNUSED_RESULT MaybeLocal<Object> Exec(Local<Context> context,
|
5917
|
+
Local<String> subject);
|
5918
|
+
|
5326
5919
|
/**
|
5327
5920
|
* Returns the value of the source property: a string representing
|
5328
5921
|
* the regular expression.
|
@@ -5340,7 +5933,6 @@ class V8_EXPORT RegExp : public Object {
|
|
5340
5933
|
static void CheckCast(Value* obj);
|
5341
5934
|
};
|
5342
5935
|
|
5343
|
-
|
5344
5936
|
/**
|
5345
5937
|
* A JavaScript value that wraps a C++ void*. This type of value is mainly used
|
5346
5938
|
* to associate C++ data structures with JavaScript objects.
|
@@ -5354,13 +5946,14 @@ class V8_EXPORT External : public Value {
|
|
5354
5946
|
static void CheckCast(v8::Value* obj);
|
5355
5947
|
};
|
5356
5948
|
|
5357
|
-
#define V8_INTRINSICS_LIST(F)
|
5358
|
-
F(ArrayProto_entries, array_entries_iterator)
|
5359
|
-
F(ArrayProto_forEach, array_for_each_iterator)
|
5360
|
-
F(ArrayProto_keys, array_keys_iterator)
|
5361
|
-
F(ArrayProto_values, array_values_iterator)
|
5362
|
-
F(ErrorPrototype, initial_error_prototype)
|
5363
|
-
F(IteratorPrototype, initial_iterator_prototype)
|
5949
|
+
#define V8_INTRINSICS_LIST(F) \
|
5950
|
+
F(ArrayProto_entries, array_entries_iterator) \
|
5951
|
+
F(ArrayProto_forEach, array_for_each_iterator) \
|
5952
|
+
F(ArrayProto_keys, array_keys_iterator) \
|
5953
|
+
F(ArrayProto_values, array_values_iterator) \
|
5954
|
+
F(ErrorPrototype, initial_error_prototype) \
|
5955
|
+
F(IteratorPrototype, initial_iterator_prototype) \
|
5956
|
+
F(ObjProto_valueOf, object_value_of_function)
|
5364
5957
|
|
5365
5958
|
enum Intrinsic {
|
5366
5959
|
#define V8_DECL_INTRINSIC(name, iname) k##name,
|
@@ -5706,6 +6299,7 @@ typedef bool (*AccessCheckCallback)(Local
|
|
5706
6299
|
Local<Object> accessed_object,
|
5707
6300
|
Local<Value> data);
|
5708
6301
|
|
6302
|
+
class CFunction;
|
5709
6303
|
/**
|
5710
6304
|
* A FunctionTemplate is used to create functions at runtime. There
|
5711
6305
|
* can only be one function created from a FunctionTemplate in a
|
@@ -5741,11 +6335,12 @@ typedef bool (*AccessCheckCallback)(Local
|
|
5741
6335
|
* proto_t->Set(isolate, "proto_const", v8::Number::New(isolate, 2));
|
5742
6336
|
*
|
5743
6337
|
* v8::Local<v8::ObjectTemplate> instance_t = t->InstanceTemplate();
|
5744
|
-
* instance_t->SetAccessor(
|
5745
|
-
|
6338
|
+
* instance_t->SetAccessor(
|
6339
|
+
String::NewFromUtf8Literal(isolate, "instance_accessor"),
|
6340
|
+
* InstanceAccessorCallback);
|
5746
6341
|
* instance_t->SetHandler(
|
5747
6342
|
* NamedPropertyHandlerConfiguration(PropertyHandlerCallback));
|
5748
|
-
* instance_t->Set(String::
|
6343
|
+
* instance_t->Set(String::NewFromUtf8Literal(isolate, "instance_property"),
|
5749
6344
|
* Number::New(isolate, 3));
|
5750
6345
|
*
|
5751
6346
|
* v8::Local<v8::Function> function = t->GetFunction();
|
@@ -5805,6 +6400,12 @@ typedef bool (*AccessCheckCallback)(Local
|
|
5805
6400
|
* child_instance.instance_accessor calls 'InstanceAccessorCallback'
|
5806
6401
|
* child_instance.instance_property == 3;
|
5807
6402
|
* \endcode
|
6403
|
+
*
|
6404
|
+
* The additional 'c_function' parameter refers to a fast API call, which
|
6405
|
+
* must not trigger GC or JavaScript execution, or call into V8 in other
|
6406
|
+
* ways. For more information how to define them, see
|
6407
|
+
* include/v8-fast-api-calls.h. Please note that this feature is still
|
6408
|
+
* experimental.
|
5808
6409
|
*/
|
5809
6410
|
class V8_EXPORT FunctionTemplate : public Template {
|
5810
6411
|
public:
|
@@ -5814,11 +6415,8 @@ class V8_EXPORT FunctionTemplate : public Template {
|
|
5814
6415
|
Local<Value> data = Local<Value>(),
|
5815
6416
|
Local<Signature> signature = Local<Signature>(), int length = 0,
|
5816
6417
|
ConstructorBehavior behavior = ConstructorBehavior::kAllow,
|
5817
|
-
SideEffectType side_effect_type = SideEffectType::kHasSideEffect
|
5818
|
-
|
5819
|
-
/** Get a template included in the snapshot by index. */
|
5820
|
-
static MaybeLocal<FunctionTemplate> FromSnapshot(Isolate* isolate,
|
5821
|
-
size_t index);
|
6418
|
+
SideEffectType side_effect_type = SideEffectType::kHasSideEffect,
|
6419
|
+
const CFunction* c_function = nullptr);
|
5822
6420
|
|
5823
6421
|
/**
|
5824
6422
|
* Creates a function template backed/cached by a private property.
|
@@ -5830,7 +6428,6 @@ class V8_EXPORT FunctionTemplate : public Template {
|
|
5830
6428
|
SideEffectType side_effect_type = SideEffectType::kHasSideEffect);
|
5831
6429
|
|
5832
6430
|
/** Returns the unique function instance in the current execution context.*/
|
5833
|
-
V8_DEPRECATED("Use maybe version", Local<Function> GetFunction());
|
5834
6431
|
V8_WARN_UNUSED_RESULT MaybeLocal<Function> GetFunction(
|
5835
6432
|
Local<Context> context);
|
5836
6433
|
|
@@ -5846,11 +6443,13 @@ class V8_EXPORT FunctionTemplate : public Template {
|
|
5846
6443
|
/**
|
5847
6444
|
* Set the call-handler callback for a FunctionTemplate. This
|
5848
6445
|
* callback is called whenever the function created from this
|
5849
|
-
* FunctionTemplate is called.
|
6446
|
+
* FunctionTemplate is called. The 'c_function' represents a fast
|
6447
|
+
* API call, see the comment above the class declaration.
|
5850
6448
|
*/
|
5851
6449
|
void SetCallHandler(
|
5852
6450
|
FunctionCallback callback, Local<Value> data = Local<Value>(),
|
5853
|
-
SideEffectType side_effect_type = SideEffectType::kHasSideEffect
|
6451
|
+
SideEffectType side_effect_type = SideEffectType::kHasSideEffect,
|
6452
|
+
const CFunction* c_function = nullptr);
|
5854
6453
|
|
5855
6454
|
/** Set the predefined length property for the FunctionTemplate. */
|
5856
6455
|
void SetLength(int length);
|
@@ -5893,20 +6492,6 @@ class V8_EXPORT FunctionTemplate : public Template {
|
|
5893
6492
|
*/
|
5894
6493
|
void SetAcceptAnyReceiver(bool value);
|
5895
6494
|
|
5896
|
-
/**
|
5897
|
-
* Determines whether the __proto__ accessor ignores instances of
|
5898
|
-
* the function template. If instances of the function template are
|
5899
|
-
* ignored, __proto__ skips all instances and instead returns the
|
5900
|
-
* next object in the prototype chain.
|
5901
|
-
*
|
5902
|
-
* Call with a value of true to make the __proto__ accessor ignore
|
5903
|
-
* instances of the function template. Call with a value of false
|
5904
|
-
* to make the __proto__ accessor not ignore instances of the
|
5905
|
-
* function template. By default, instances of a function template
|
5906
|
-
* are not ignored.
|
5907
|
-
*/
|
5908
|
-
void SetHiddenPrototype(bool value);
|
5909
|
-
|
5910
6495
|
/**
|
5911
6496
|
* Sets the ReadOnly flag in the attributes of the 'prototype' property
|
5912
6497
|
* of functions created from this FunctionTemplate to true.
|
@@ -6122,12 +6707,7 @@ class V8_EXPORT ObjectTemplate : public Template {
|
|
6122
6707
|
Isolate* isolate,
|
6123
6708
|
Local<FunctionTemplate> constructor = Local<FunctionTemplate>());
|
6124
6709
|
|
6125
|
-
/** Get a template included in the snapshot by index. */
|
6126
|
-
static MaybeLocal<ObjectTemplate> FromSnapshot(Isolate* isolate,
|
6127
|
-
size_t index);
|
6128
|
-
|
6129
6710
|
/** Creates a new instance of this template.*/
|
6130
|
-
V8_DEPRECATED("Use maybe version", Local<Object> NewInstance());
|
6131
6711
|
V8_WARN_UNUSED_RESULT MaybeLocal<Object> NewInstance(Local<Context> context);
|
6132
6712
|
|
6133
6713
|
/**
|
@@ -6347,20 +6927,6 @@ class V8_EXPORT AccessorSignature : public Data {
|
|
6347
6927
|
|
6348
6928
|
|
6349
6929
|
// --- Extensions ---
|
6350
|
-
V8_DEPRECATED("Implementation detail", class)
|
6351
|
-
V8_EXPORT ExternalOneByteStringResourceImpl
|
6352
|
-
: public String::ExternalOneByteStringResource {
|
6353
|
-
public:
|
6354
|
-
ExternalOneByteStringResourceImpl() : data_(nullptr), length_(0) {}
|
6355
|
-
ExternalOneByteStringResourceImpl(const char* data, size_t length)
|
6356
|
-
: data_(data), length_(length) {}
|
6357
|
-
const char* data() const override { return data_; }
|
6358
|
-
size_t length() const override { return length_; }
|
6359
|
-
|
6360
|
-
private:
|
6361
|
-
const char* data_;
|
6362
|
-
size_t length_;
|
6363
|
-
};
|
6364
6930
|
|
6365
6931
|
/**
|
6366
6932
|
* Ignore
|
@@ -6382,8 +6948,8 @@ class V8_EXPORT Extension { // NOLINT
|
|
6382
6948
|
const String::ExternalOneByteStringResource* source() const {
|
6383
6949
|
return source_;
|
6384
6950
|
}
|
6385
|
-
int dependency_count() { return dep_count_; }
|
6386
|
-
const char** dependencies() { return deps_; }
|
6951
|
+
int dependency_count() const { return dep_count_; }
|
6952
|
+
const char** dependencies() const { return deps_; }
|
6387
6953
|
void set_auto_enable(bool value) { auto_enable_ = value; }
|
6388
6954
|
bool auto_enable() { return auto_enable_; }
|
6389
6955
|
|
@@ -6400,9 +6966,7 @@ class V8_EXPORT Extension { // NOLINT
|
|
6400
6966
|
bool auto_enable_;
|
6401
6967
|
};
|
6402
6968
|
|
6403
|
-
|
6404
|
-
void V8_EXPORT RegisterExtension(Extension* extension);
|
6405
|
-
|
6969
|
+
void V8_EXPORT RegisterExtension(std::unique_ptr<Extension>);
|
6406
6970
|
|
6407
6971
|
// --- Statics ---
|
6408
6972
|
|
@@ -6427,7 +6991,26 @@ V8_INLINE Local
|
|
6427
6991
|
*/
|
6428
6992
|
class V8_EXPORT ResourceConstraints {
|
6429
6993
|
public:
|
6430
|
-
|
6994
|
+
/**
|
6995
|
+
* Configures the constraints with reasonable default values based on the
|
6996
|
+
* provided heap size limit. The heap size includes both the young and
|
6997
|
+
* the old generation.
|
6998
|
+
*
|
6999
|
+
* \param initial_heap_size_in_bytes The initial heap size or zero.
|
7000
|
+
* By default V8 starts with a small heap and dynamically grows it to
|
7001
|
+
* match the set of live objects. This may lead to ineffective
|
7002
|
+
* garbage collections at startup if the live set is large.
|
7003
|
+
* Setting the initial heap size avoids such garbage collections.
|
7004
|
+
* Note that this does not affect young generation garbage collections.
|
7005
|
+
*
|
7006
|
+
* \param maximum_heap_size_in_bytes The hard limit for the heap size.
|
7007
|
+
* When the heap size approaches this limit, V8 will perform series of
|
7008
|
+
* garbage collections and invoke the NearHeapLimitCallback. If the garbage
|
7009
|
+
* collections do not help and the callback does not increase the limit,
|
7010
|
+
* then V8 will crash with V8::FatalProcessOutOfMemory.
|
7011
|
+
*/
|
7012
|
+
void ConfigureDefaultsFromHeapSize(size_t initial_heap_size_in_bytes,
|
7013
|
+
size_t maximum_heap_size_in_bytes);
|
6431
7014
|
|
6432
7015
|
/**
|
6433
7016
|
* Configures the constraints with reasonable default values based on the
|
@@ -6441,39 +7024,92 @@ class V8_EXPORT ResourceConstraints {
|
|
6441
7024
|
void ConfigureDefaults(uint64_t physical_memory,
|
6442
7025
|
uint64_t virtual_memory_limit);
|
6443
7026
|
|
6444
|
-
|
6445
|
-
|
6446
|
-
|
7027
|
+
/**
|
7028
|
+
* The address beyond which the VM's stack may not grow.
|
7029
|
+
*/
|
7030
|
+
uint32_t* stack_limit() const { return stack_limit_; }
|
7031
|
+
void set_stack_limit(uint32_t* value) { stack_limit_ = value; }
|
7032
|
+
|
7033
|
+
/**
|
7034
|
+
* The amount of virtual memory reserved for generated code. This is relevant
|
7035
|
+
* for 64-bit architectures that rely on code range for calls in code.
|
7036
|
+
*/
|
7037
|
+
size_t code_range_size_in_bytes() const { return code_range_size_; }
|
7038
|
+
void set_code_range_size_in_bytes(size_t limit) { code_range_size_ = limit; }
|
7039
|
+
|
7040
|
+
/**
|
7041
|
+
* The maximum size of the old generation.
|
7042
|
+
* When the old generation approaches this limit, V8 will perform series of
|
7043
|
+
* garbage collections and invoke the NearHeapLimitCallback.
|
7044
|
+
* If the garbage collections do not help and the callback does not
|
7045
|
+
* increase the limit, then V8 will crash with V8::FatalProcessOutOfMemory.
|
7046
|
+
*/
|
7047
|
+
size_t max_old_generation_size_in_bytes() const {
|
7048
|
+
return max_old_generation_size_;
|
7049
|
+
}
|
7050
|
+
void set_max_old_generation_size_in_bytes(size_t limit) {
|
7051
|
+
max_old_generation_size_ = limit;
|
7052
|
+
}
|
7053
|
+
|
7054
|
+
/**
|
7055
|
+
* The maximum size of the young generation, which consists of two semi-spaces
|
7056
|
+
* and a large object space. This affects frequency of Scavenge garbage
|
7057
|
+
* collections and should be typically much smaller that the old generation.
|
7058
|
+
*/
|
7059
|
+
size_t max_young_generation_size_in_bytes() const {
|
7060
|
+
return max_young_generation_size_;
|
7061
|
+
}
|
7062
|
+
void set_max_young_generation_size_in_bytes(size_t limit) {
|
7063
|
+
max_young_generation_size_ = limit;
|
6447
7064
|
}
|
6448
7065
|
|
6449
|
-
|
6450
|
-
|
6451
|
-
|
7066
|
+
size_t initial_old_generation_size_in_bytes() const {
|
7067
|
+
return initial_old_generation_size_;
|
7068
|
+
}
|
7069
|
+
void set_initial_old_generation_size_in_bytes(size_t initial_size) {
|
7070
|
+
initial_old_generation_size_ = initial_size;
|
6452
7071
|
}
|
6453
7072
|
|
6454
|
-
size_t
|
6455
|
-
|
6456
|
-
max_old_space_size_ = limit_in_mb;
|
7073
|
+
size_t initial_young_generation_size_in_bytes() const {
|
7074
|
+
return initial_young_generation_size_;
|
6457
7075
|
}
|
6458
|
-
|
6459
|
-
|
6460
|
-
|
6461
|
-
|
7076
|
+
void set_initial_young_generation_size_in_bytes(size_t initial_size) {
|
7077
|
+
initial_young_generation_size_ = initial_size;
|
7078
|
+
}
|
7079
|
+
|
7080
|
+
/**
|
7081
|
+
* Deprecated functions. Do not use in new code.
|
7082
|
+
*/
|
7083
|
+
V8_DEPRECATE_SOON("Use code_range_size_in_bytes.")
|
7084
|
+
size_t code_range_size() const { return code_range_size_ / kMB; }
|
7085
|
+
V8_DEPRECATE_SOON("Use set_code_range_size_in_bytes.")
|
6462
7086
|
void set_code_range_size(size_t limit_in_mb) {
|
6463
|
-
code_range_size_ = limit_in_mb;
|
7087
|
+
code_range_size_ = limit_in_mb * kMB;
|
6464
7088
|
}
|
7089
|
+
V8_DEPRECATE_SOON("Use max_young_generation_size_in_bytes.")
|
7090
|
+
size_t max_semi_space_size_in_kb() const;
|
7091
|
+
V8_DEPRECATE_SOON("Use set_max_young_generation_size_in_bytes.")
|
7092
|
+
void set_max_semi_space_size_in_kb(size_t limit_in_kb);
|
7093
|
+
V8_DEPRECATE_SOON("Use max_old_generation_size_in_bytes.")
|
7094
|
+
size_t max_old_space_size() const { return max_old_generation_size_ / kMB; }
|
7095
|
+
V8_DEPRECATE_SOON("Use set_max_old_generation_size_in_bytes.")
|
7096
|
+
void set_max_old_space_size(size_t limit_in_mb) {
|
7097
|
+
max_old_generation_size_ = limit_in_mb * kMB;
|
7098
|
+
}
|
7099
|
+
V8_DEPRECATE_SOON("Zone does not pool memory any more.")
|
6465
7100
|
size_t max_zone_pool_size() const { return max_zone_pool_size_; }
|
7101
|
+
V8_DEPRECATE_SOON("Zone does not pool memory any more.")
|
6466
7102
|
void set_max_zone_pool_size(size_t bytes) { max_zone_pool_size_ = bytes; }
|
6467
7103
|
|
6468
7104
|
private:
|
6469
|
-
|
6470
|
-
size_t
|
6471
|
-
|
6472
|
-
|
6473
|
-
size_t
|
6474
|
-
|
6475
|
-
size_t
|
6476
|
-
|
7105
|
+
static constexpr size_t kMB = 1048576u;
|
7106
|
+
size_t code_range_size_ = 0;
|
7107
|
+
size_t max_old_generation_size_ = 0;
|
7108
|
+
size_t max_young_generation_size_ = 0;
|
7109
|
+
size_t max_zone_pool_size_ = 0;
|
7110
|
+
size_t initial_old_generation_size_ = 0;
|
7111
|
+
size_t initial_young_generation_size_ = 0;
|
7112
|
+
uint32_t* stack_limit_ = nullptr;
|
6477
7113
|
};
|
6478
7114
|
|
6479
7115
|
|
@@ -6503,6 +7139,9 @@ class V8_EXPORT Exception {
|
|
6503
7139
|
static Local<Value> ReferenceError(Local<String> message);
|
6504
7140
|
static Local<Value> SyntaxError(Local<String> message);
|
6505
7141
|
static Local<Value> TypeError(Local<String> message);
|
7142
|
+
static Local<Value> WasmCompileError(Local<String> message);
|
7143
|
+
static Local<Value> WasmLinkError(Local<String> message);
|
7144
|
+
static Local<Value> WasmRuntimeError(Local<String> message);
|
6506
7145
|
static Local<Value> Error(Local<String> message);
|
6507
7146
|
|
6508
7147
|
/**
|
@@ -6531,6 +7170,17 @@ typedef void* (*CreateHistogramCallback)(const char* name,
|
|
6531
7170
|
|
6532
7171
|
typedef void (*AddHistogramSampleCallback)(void* histogram, int sample);
|
6533
7172
|
|
7173
|
+
// --- Crashkeys Callback ---
|
7174
|
+
enum class CrashKeyId {
|
7175
|
+
kIsolateAddress,
|
7176
|
+
kReadonlySpaceFirstPageAddress,
|
7177
|
+
kMapSpaceFirstPageAddress,
|
7178
|
+
kCodeSpaceFirstPageAddress,
|
7179
|
+
kDumpType,
|
7180
|
+
};
|
7181
|
+
|
7182
|
+
typedef void (*AddCrashKeyCallback)(CrashKeyId id, const std::string& value);
|
7183
|
+
|
6534
7184
|
// --- Enter/Leave Script Callback ---
|
6535
7185
|
typedef void (*BeforeCallEnteredCallback)(Isolate*);
|
6536
7186
|
typedef void (*CallCompletedCallback)(Isolate*);
|
@@ -6578,7 +7228,7 @@ typedef void (*HostInitializeImportMetaObjectCallback)(Local
|
|
6578
7228
|
* first accessed. The return value will be used as the stack value. If this
|
6579
7229
|
* callback is registed, the |Error.prepareStackTrace| API will be disabled.
|
6580
7230
|
* |sites| is an array of call sites, specified in
|
6581
|
-
* https://
|
7231
|
+
* https://v8.dev/docs/stack-trace-api
|
6582
7232
|
*/
|
6583
7233
|
typedef MaybeLocal<Value> (*PrepareStackTraceCallback)(Local<Context> context,
|
6584
7234
|
Local<Value> error,
|
@@ -6616,11 +7266,8 @@ enum PromiseRejectEvent {
|
|
6616
7266
|
class PromiseRejectMessage {
|
6617
7267
|
public:
|
6618
7268
|
PromiseRejectMessage(Local<Promise> promise, PromiseRejectEvent event,
|
6619
|
-
Local<Value> value
|
6620
|
-
: promise_(promise),
|
6621
|
-
event_(event),
|
6622
|
-
value_(value),
|
6623
|
-
stack_trace_(stack_trace) {}
|
7269
|
+
Local<Value> value)
|
7270
|
+
: promise_(promise), event_(event), value_(value) {}
|
6624
7271
|
|
6625
7272
|
V8_INLINE Local<Promise> GetPromise() const { return promise_; }
|
6626
7273
|
V8_INLINE PromiseRejectEvent GetEvent() const { return event_; }
|
@@ -6630,28 +7277,111 @@ class PromiseRejectMessage {
|
|
6630
7277
|
Local<Promise> promise_;
|
6631
7278
|
PromiseRejectEvent event_;
|
6632
7279
|
Local<Value> value_;
|
6633
|
-
Local<StackTrace> stack_trace_;
|
6634
7280
|
};
|
6635
7281
|
|
6636
7282
|
typedef void (*PromiseRejectCallback)(PromiseRejectMessage message);
|
6637
7283
|
|
6638
7284
|
// --- Microtasks Callbacks ---
|
7285
|
+
V8_DEPRECATE_SOON("Use *WithData version.")
|
6639
7286
|
typedef void (*MicrotasksCompletedCallback)(Isolate*);
|
7287
|
+
typedef void (*MicrotasksCompletedCallbackWithData)(Isolate*, void*);
|
6640
7288
|
typedef void (*MicrotaskCallback)(void* data);
|
6641
7289
|
|
6642
|
-
|
6643
7290
|
/**
|
6644
7291
|
* Policy for running microtasks:
|
6645
|
-
* - explicit: microtasks are invoked with
|
7292
|
+
* - explicit: microtasks are invoked with the
|
7293
|
+
* Isolate::PerformMicrotaskCheckpoint() method;
|
6646
7294
|
* - scoped: microtasks invocation is controlled by MicrotasksScope objects;
|
6647
7295
|
* - auto: microtasks are invoked when the script call depth decrements
|
6648
7296
|
* to zero.
|
6649
7297
|
*/
|
6650
7298
|
enum class MicrotasksPolicy { kExplicit, kScoped, kAuto };
|
6651
7299
|
|
7300
|
+
/**
|
7301
|
+
* Represents the microtask queue, where microtasks are stored and processed.
|
7302
|
+
* https://html.spec.whatwg.org/multipage/webappapis.html#microtask-queue
|
7303
|
+
* https://html.spec.whatwg.org/multipage/webappapis.html#enqueuejob(queuename,-job,-arguments)
|
7304
|
+
* https://html.spec.whatwg.org/multipage/webappapis.html#perform-a-microtask-checkpoint
|
7305
|
+
*
|
7306
|
+
* A MicrotaskQueue instance may be associated to multiple Contexts by passing
|
7307
|
+
* it to Context::New(), and they can be detached by Context::DetachGlobal().
|
7308
|
+
* The embedder must keep the MicrotaskQueue instance alive until all associated
|
7309
|
+
* Contexts are gone or detached.
|
7310
|
+
*
|
7311
|
+
* Use the same instance of MicrotaskQueue for all Contexts that may access each
|
7312
|
+
* other synchronously. E.g. for Web embedding, use the same instance for all
|
7313
|
+
* origins that share the same URL scheme and eTLD+1.
|
7314
|
+
*/
|
7315
|
+
class V8_EXPORT MicrotaskQueue {
|
7316
|
+
public:
|
7317
|
+
/**
|
7318
|
+
* Creates an empty MicrotaskQueue instance.
|
7319
|
+
*/
|
7320
|
+
static std::unique_ptr<MicrotaskQueue> New(
|
7321
|
+
Isolate* isolate, MicrotasksPolicy policy = MicrotasksPolicy::kAuto);
|
7322
|
+
|
7323
|
+
virtual ~MicrotaskQueue() = default;
|
7324
|
+
|
7325
|
+
/**
|
7326
|
+
* Enqueues the callback to the queue.
|
7327
|
+
*/
|
7328
|
+
virtual void EnqueueMicrotask(Isolate* isolate,
|
7329
|
+
Local<Function> microtask) = 0;
|
7330
|
+
|
7331
|
+
/**
|
7332
|
+
* Enqueues the callback to the queue.
|
7333
|
+
*/
|
7334
|
+
virtual void EnqueueMicrotask(v8::Isolate* isolate,
|
7335
|
+
MicrotaskCallback callback,
|
7336
|
+
void* data = nullptr) = 0;
|
7337
|
+
|
7338
|
+
/**
|
7339
|
+
* Adds a callback to notify the embedder after microtasks were run. The
|
7340
|
+
* callback is triggered by explicit RunMicrotasks call or automatic
|
7341
|
+
* microtasks execution (see Isolate::SetMicrotasksPolicy).
|
7342
|
+
*
|
7343
|
+
* Callback will trigger even if microtasks were attempted to run,
|
7344
|
+
* but the microtasks queue was empty and no single microtask was actually
|
7345
|
+
* executed.
|
7346
|
+
*
|
7347
|
+
* Executing scripts inside the callback will not re-trigger microtasks and
|
7348
|
+
* the callback.
|
7349
|
+
*/
|
7350
|
+
virtual void AddMicrotasksCompletedCallback(
|
7351
|
+
MicrotasksCompletedCallbackWithData callback, void* data = nullptr) = 0;
|
7352
|
+
|
7353
|
+
/**
|
7354
|
+
* Removes callback that was installed by AddMicrotasksCompletedCallback.
|
7355
|
+
*/
|
7356
|
+
virtual void RemoveMicrotasksCompletedCallback(
|
7357
|
+
MicrotasksCompletedCallbackWithData callback, void* data = nullptr) = 0;
|
7358
|
+
|
7359
|
+
/**
|
7360
|
+
* Runs microtasks if no microtask is running on this MicrotaskQueue instance.
|
7361
|
+
*/
|
7362
|
+
virtual void PerformCheckpoint(Isolate* isolate) = 0;
|
7363
|
+
|
7364
|
+
/**
|
7365
|
+
* Returns true if a microtask is running on this MicrotaskQueue instance.
|
7366
|
+
*/
|
7367
|
+
virtual bool IsRunningMicrotasks() const = 0;
|
7368
|
+
|
7369
|
+
/**
|
7370
|
+
* Returns the current depth of nested MicrotasksScope that has
|
7371
|
+
* kRunMicrotasks.
|
7372
|
+
*/
|
7373
|
+
virtual int GetMicrotasksScopeDepth() const = 0;
|
7374
|
+
|
7375
|
+
MicrotaskQueue(const MicrotaskQueue&) = delete;
|
7376
|
+
MicrotaskQueue& operator=(const MicrotaskQueue&) = delete;
|
7377
|
+
|
7378
|
+
private:
|
7379
|
+
friend class internal::MicrotaskQueue;
|
7380
|
+
MicrotaskQueue() = default;
|
7381
|
+
};
|
6652
7382
|
|
6653
7383
|
/**
|
6654
|
-
* This scope is used to control microtasks when
|
7384
|
+
* This scope is used to control microtasks when MicrotasksPolicy::kScoped
|
6655
7385
|
* is used on Isolate. In this mode every non-primitive call to V8 should be
|
6656
7386
|
* done inside some MicrotasksScope.
|
6657
7387
|
* Microtasks are executed when topmost MicrotasksScope marked as kRunMicrotasks
|
@@ -6664,6 +7394,7 @@ class V8_EXPORT MicrotasksScope {
|
|
6664
7394
|
enum Type { kRunMicrotasks, kDoNotRunMicrotasks };
|
6665
7395
|
|
6666
7396
|
MicrotasksScope(Isolate* isolate, Type type);
|
7397
|
+
MicrotasksScope(Isolate* isolate, MicrotaskQueue* microtask_queue, Type type);
|
6667
7398
|
~MicrotasksScope();
|
6668
7399
|
|
6669
7400
|
/**
|
@@ -6687,6 +7418,7 @@ class V8_EXPORT MicrotasksScope {
|
|
6687
7418
|
|
6688
7419
|
private:
|
6689
7420
|
internal::Isolate* const isolate_;
|
7421
|
+
internal::MicrotaskQueue* const microtask_queue_;
|
6690
7422
|
bool run_;
|
6691
7423
|
};
|
6692
7424
|
|
@@ -6705,6 +7437,23 @@ typedef void (*FailedAccessCheckCallback)(Local
|
|
6705
7437
|
typedef bool (*AllowCodeGenerationFromStringsCallback)(Local<Context> context,
|
6706
7438
|
Local<String> source);
|
6707
7439
|
|
7440
|
+
struct ModifyCodeGenerationFromStringsResult {
|
7441
|
+
// If true, proceed with the codegen algorithm. Otherwise, block it.
|
7442
|
+
bool codegen_allowed = false;
|
7443
|
+
// Overwrite the original source with this string, if present.
|
7444
|
+
// Use the original source if empty.
|
7445
|
+
// This field is considered only if codegen_allowed is true.
|
7446
|
+
MaybeLocal<String> modified_source;
|
7447
|
+
};
|
7448
|
+
|
7449
|
+
/**
|
7450
|
+
* Callback to check if codegen is allowed from a source object, and convert
|
7451
|
+
* the source to string if necessary.See ModifyCodeGenerationFromStrings.
|
7452
|
+
*/
|
7453
|
+
typedef ModifyCodeGenerationFromStringsResult (
|
7454
|
+
*ModifyCodeGenerationFromStringsCallback)(Local<Context> context,
|
7455
|
+
Local<Value> source);
|
7456
|
+
|
6708
7457
|
// --- WebAssembly compilation callbacks ---
|
6709
7458
|
typedef bool (*ExtensionCallback)(const FunctionCallbackInfo<Value>&);
|
6710
7459
|
|
@@ -6721,6 +7470,10 @@ typedef void (*WasmStreamingCallback)(const FunctionCallbackInfo
|
|
6721
7470
|
// --- Callback for checking if WebAssembly threads are enabled ---
|
6722
7471
|
typedef bool (*WasmThreadsEnabledCallback)(Local<Context> context);
|
6723
7472
|
|
7473
|
+
// --- Callback for loading source map file for Wasm profiling support
|
7474
|
+
typedef Local<String> (*WasmLoadSourceMapCallback)(Isolate* isolate,
|
7475
|
+
const char* name);
|
7476
|
+
|
6724
7477
|
// --- Garbage Collection Callbacks ---
|
6725
7478
|
|
6726
7479
|
/**
|
@@ -6777,10 +7530,33 @@ typedef void (*InterruptCallback)(Isolate* isolate, void* data);
|
|
6777
7530
|
typedef size_t (*NearHeapLimitCallback)(void* data, size_t current_heap_limit,
|
6778
7531
|
size_t initial_heap_limit);
|
6779
7532
|
|
7533
|
+
/**
|
7534
|
+
* Collection of shared per-process V8 memory information.
|
7535
|
+
*
|
7536
|
+
* Instances of this class can be passed to
|
7537
|
+
* v8::V8::GetSharedMemoryStatistics to get shared memory statistics from V8.
|
7538
|
+
*/
|
7539
|
+
class V8_EXPORT SharedMemoryStatistics {
|
7540
|
+
public:
|
7541
|
+
SharedMemoryStatistics();
|
7542
|
+
size_t read_only_space_size() { return read_only_space_size_; }
|
7543
|
+
size_t read_only_space_used_size() { return read_only_space_used_size_; }
|
7544
|
+
size_t read_only_space_physical_size() {
|
7545
|
+
return read_only_space_physical_size_;
|
7546
|
+
}
|
7547
|
+
|
7548
|
+
private:
|
7549
|
+
size_t read_only_space_size_;
|
7550
|
+
size_t read_only_space_used_size_;
|
7551
|
+
size_t read_only_space_physical_size_;
|
7552
|
+
|
7553
|
+
friend class V8;
|
7554
|
+
};
|
7555
|
+
|
6780
7556
|
/**
|
6781
7557
|
* Collection of V8 heap information.
|
6782
7558
|
*
|
6783
|
-
* Instances of this class can be passed to v8::
|
7559
|
+
* Instances of this class can be passed to v8::Isolate::GetHeapStatistics to
|
6784
7560
|
* get heap statistics from V8.
|
6785
7561
|
*/
|
6786
7562
|
class V8_EXPORT HeapStatistics {
|
@@ -6790,6 +7566,8 @@ class V8_EXPORT HeapStatistics {
|
|
6790
7566
|
size_t total_heap_size_executable() { return total_heap_size_executable_; }
|
6791
7567
|
size_t total_physical_size() { return total_physical_size_; }
|
6792
7568
|
size_t total_available_size() { return total_available_size_; }
|
7569
|
+
size_t total_global_handles_size() { return total_global_handles_size_; }
|
7570
|
+
size_t used_global_handles_size() { return used_global_handles_size_; }
|
6793
7571
|
size_t used_heap_size() { return used_heap_size_; }
|
6794
7572
|
size_t heap_size_limit() { return heap_size_limit_; }
|
6795
7573
|
size_t malloced_memory() { return malloced_memory_; }
|
@@ -6817,6 +7595,8 @@ class V8_EXPORT HeapStatistics {
|
|
6817
7595
|
bool does_zap_garbage_;
|
6818
7596
|
size_t number_of_native_contexts_;
|
6819
7597
|
size_t number_of_detached_contexts_;
|
7598
|
+
size_t total_global_handles_size_;
|
7599
|
+
size_t used_global_handles_size_;
|
6820
7600
|
|
6821
7601
|
friend class V8;
|
6822
7602
|
friend class Isolate;
|
@@ -6875,8 +7655,6 @@ class V8_EXPORT HeapCodeStatistics {
|
|
6875
7655
|
friend class Isolate;
|
6876
7656
|
};
|
6877
7657
|
|
6878
|
-
class RetainedObjectInfo;
|
6879
|
-
|
6880
7658
|
/**
|
6881
7659
|
* A JIT code event is issued each time code is added, moved or removed.
|
6882
7660
|
*
|
@@ -6938,6 +7716,20 @@ struct JitCodeEvent {
|
|
6938
7716
|
PositionType position_type;
|
6939
7717
|
};
|
6940
7718
|
|
7719
|
+
struct wasm_source_info_t {
|
7720
|
+
// Source file name.
|
7721
|
+
const char* filename;
|
7722
|
+
// Length of filename.
|
7723
|
+
size_t filename_size;
|
7724
|
+
// Line number table, which maps offsets of JITted code to line numbers of
|
7725
|
+
// source file.
|
7726
|
+
const line_info_t* line_number_table;
|
7727
|
+
// Number of entries in the line number table.
|
7728
|
+
size_t line_number_table_size;
|
7729
|
+
};
|
7730
|
+
|
7731
|
+
wasm_source_info_t* wasm_source_info;
|
7732
|
+
|
6941
7733
|
union {
|
6942
7734
|
// Only valid for CODE_ADDED.
|
6943
7735
|
struct name_t name;
|
@@ -6957,7 +7749,7 @@ struct JitCodeEvent {
|
|
6957
7749
|
* See documentation https://developers.google.com/web/tools/chrome-devtools/
|
6958
7750
|
* profile/evaluate-performance/rail
|
6959
7751
|
*/
|
6960
|
-
enum RAILMode {
|
7752
|
+
enum RAILMode : unsigned {
|
6961
7753
|
// Response performance mode: In this mode very low virtual machine latency
|
6962
7754
|
// is provided. V8 will try to avoid JavaScript execution interruptions.
|
6963
7755
|
// Throughput may be throttled.
|
@@ -6991,6 +7783,13 @@ enum JitCodeEventOptions {
|
|
6991
7783
|
*/
|
6992
7784
|
typedef void (*JitCodeEventHandler)(const JitCodeEvent* event);
|
6993
7785
|
|
7786
|
+
/**
|
7787
|
+
* Callback function passed to SetUnhandledExceptionCallback.
|
7788
|
+
*/
|
7789
|
+
#if defined(V8_OS_WIN)
|
7790
|
+
typedef int (*UnhandledExceptionCallback)(
|
7791
|
+
_EXCEPTION_POINTERS* exception_pointers);
|
7792
|
+
#endif
|
6994
7793
|
|
6995
7794
|
/**
|
6996
7795
|
* Interface for iterating through all external resources in the heap.
|
@@ -7031,6 +7830,11 @@ enum class MemoryPressureLevel { kNone, kModerate, kCritical };
|
|
7031
7830
|
*/
|
7032
7831
|
class V8_EXPORT EmbedderHeapTracer {
|
7033
7832
|
public:
|
7833
|
+
enum TraceFlags : uint64_t {
|
7834
|
+
kNoFlags = 0,
|
7835
|
+
kReduceMemory = 1 << 0,
|
7836
|
+
};
|
7837
|
+
|
7034
7838
|
// Indicator for the stack state of the embedder.
|
7035
7839
|
enum EmbedderStackState {
|
7036
7840
|
kUnknown,
|
@@ -7038,8 +7842,53 @@ class V8_EXPORT EmbedderHeapTracer {
|
|
7038
7842
|
kEmpty,
|
7039
7843
|
};
|
7040
7844
|
|
7845
|
+
/**
|
7846
|
+
* Interface for iterating through TracedGlobal handles.
|
7847
|
+
*/
|
7848
|
+
class V8_EXPORT TracedGlobalHandleVisitor {
|
7849
|
+
public:
|
7850
|
+
virtual ~TracedGlobalHandleVisitor() = default;
|
7851
|
+
virtual void VisitTracedGlobalHandle(const TracedGlobal<Value>& handle) {}
|
7852
|
+
virtual void VisitTracedReference(const TracedReference<Value>& handle) {}
|
7853
|
+
};
|
7854
|
+
|
7855
|
+
/**
|
7856
|
+
* Summary of a garbage collection cycle. See |TraceEpilogue| on how the
|
7857
|
+
* summary is reported.
|
7858
|
+
*/
|
7859
|
+
struct TraceSummary {
|
7860
|
+
/**
|
7861
|
+
* Time spent managing the retained memory in milliseconds. This can e.g.
|
7862
|
+
* include the time tracing through objects in the embedder.
|
7863
|
+
*/
|
7864
|
+
double time = 0.0;
|
7865
|
+
|
7866
|
+
/**
|
7867
|
+
* Memory retained by the embedder through the |EmbedderHeapTracer|
|
7868
|
+
* mechanism in bytes.
|
7869
|
+
*/
|
7870
|
+
size_t allocated_size = 0;
|
7871
|
+
};
|
7872
|
+
|
7041
7873
|
virtual ~EmbedderHeapTracer() = default;
|
7042
7874
|
|
7875
|
+
/**
|
7876
|
+
* Iterates all TracedGlobal handles created for the v8::Isolate the tracer is
|
7877
|
+
* attached to.
|
7878
|
+
*/
|
7879
|
+
void IterateTracedGlobalHandles(TracedGlobalHandleVisitor* visitor);
|
7880
|
+
|
7881
|
+
/**
|
7882
|
+
* Called by the embedder to set the start of the stack which is e.g. used by
|
7883
|
+
* V8 to determine whether handles are used from stack or heap.
|
7884
|
+
*/
|
7885
|
+
void SetStackStart(void* stack_start);
|
7886
|
+
|
7887
|
+
/**
|
7888
|
+
* Called by the embedder to notify V8 of an empty execution stack.
|
7889
|
+
*/
|
7890
|
+
void NotifyEmptyEmbedderStack();
|
7891
|
+
|
7043
7892
|
/**
|
7044
7893
|
* Called by v8 to register internal fields of found wrappers.
|
7045
7894
|
*
|
@@ -7049,10 +7898,12 @@ class V8_EXPORT EmbedderHeapTracer {
|
|
7049
7898
|
virtual void RegisterV8References(
|
7050
7899
|
const std::vector<std::pair<void*, void*> >& embedder_fields) = 0;
|
7051
7900
|
|
7901
|
+
void RegisterEmbedderReference(const TracedReferenceBase<v8::Data>& ref);
|
7902
|
+
|
7052
7903
|
/**
|
7053
7904
|
* Called at the beginning of a GC cycle.
|
7054
7905
|
*/
|
7055
|
-
virtual void TracePrologue()
|
7906
|
+
virtual void TracePrologue(TraceFlags flags) {}
|
7056
7907
|
|
7057
7908
|
/**
|
7058
7909
|
* Called to advance tracing in the embedder.
|
@@ -7075,9 +7926,11 @@ class V8_EXPORT EmbedderHeapTracer {
|
|
7075
7926
|
/**
|
7076
7927
|
* Called at the end of a GC cycle.
|
7077
7928
|
*
|
7078
|
-
* Note that allocation is *not* allowed within |TraceEpilogue|.
|
7929
|
+
* Note that allocation is *not* allowed within |TraceEpilogue|. Can be
|
7930
|
+
* overriden to fill a |TraceSummary| that is used by V8 to schedule future
|
7931
|
+
* garbage collections.
|
7079
7932
|
*/
|
7080
|
-
virtual void TraceEpilogue()
|
7933
|
+
virtual void TraceEpilogue(TraceSummary* trace_summary) {}
|
7081
7934
|
|
7082
7935
|
/**
|
7083
7936
|
* Called upon entering the final marking pause. No more incremental marking
|
@@ -7085,15 +7938,6 @@ class V8_EXPORT EmbedderHeapTracer {
|
|
7085
7938
|
*/
|
7086
7939
|
virtual void EnterFinalPause(EmbedderStackState stack_state) = 0;
|
7087
7940
|
|
7088
|
-
/**
|
7089
|
-
* Called when tracing is aborted.
|
7090
|
-
*
|
7091
|
-
* The embedder is expected to throw away all intermediate data and reset to
|
7092
|
-
* the initial state.
|
7093
|
-
*/
|
7094
|
-
V8_DEPRECATED("Obsolete as V8 will not abort tracing anymore.",
|
7095
|
-
virtual void AbortTracing()) {}
|
7096
|
-
|
7097
7941
|
/*
|
7098
7942
|
* Called by the embedder to request immediate finalization of the currently
|
7099
7943
|
* running tracing phase that has been started with TracePrologue and not
|
@@ -7105,6 +7949,39 @@ class V8_EXPORT EmbedderHeapTracer {
|
|
7105
7949
|
*/
|
7106
7950
|
void FinalizeTracing();
|
7107
7951
|
|
7952
|
+
/**
|
7953
|
+
* Returns true if the TracedGlobal handle should be considered as root for
|
7954
|
+
* the currently running non-tracing garbage collection and false otherwise.
|
7955
|
+
* The default implementation will keep all TracedGlobal references as roots.
|
7956
|
+
*
|
7957
|
+
* If this returns false, then V8 may decide that the object referred to by
|
7958
|
+
* such a handle is reclaimed. In that case:
|
7959
|
+
* - No action is required if handles are used with destructors, i.e., by just
|
7960
|
+
* using |TracedGlobal|.
|
7961
|
+
* - When run without destructors, i.e., by using
|
7962
|
+
* |TracedReference|, V8 calls |ResetHandleInNonTracingGC|.
|
7963
|
+
*
|
7964
|
+
* Note that the |handle| is different from the handle that the embedder holds
|
7965
|
+
* for retaining the object. The embedder may use |WrapperClassId()| to
|
7966
|
+
* distinguish cases where it wants handles to be treated as roots from not
|
7967
|
+
* being treated as roots.
|
7968
|
+
*/
|
7969
|
+
virtual bool IsRootForNonTracingGC(
|
7970
|
+
const v8::TracedReference<v8::Value>& handle);
|
7971
|
+
virtual bool IsRootForNonTracingGC(const v8::TracedGlobal<v8::Value>& handle);
|
7972
|
+
|
7973
|
+
/**
|
7974
|
+
* Used in combination with |IsRootForNonTracingGC|. Called by V8 when an
|
7975
|
+
* object that is backed by a handle is reclaimed by a non-tracing garbage
|
7976
|
+
* collection. It is up to the embedder to reset the original handle.
|
7977
|
+
*
|
7978
|
+
* Note that the |handle| is different from the handle that the embedder holds
|
7979
|
+
* for retaining the object. It is up to the embedder to find the original
|
7980
|
+
* handle via the object or class id.
|
7981
|
+
*/
|
7982
|
+
virtual void ResetHandleInNonTracingGC(
|
7983
|
+
const v8::TracedReference<v8::Value>& handle);
|
7984
|
+
|
7108
7985
|
/*
|
7109
7986
|
* Called by the embedder to immediately perform a full garbage collection.
|
7110
7987
|
*
|
@@ -7112,6 +7989,15 @@ class V8_EXPORT EmbedderHeapTracer {
|
|
7112
7989
|
*/
|
7113
7990
|
void GarbageCollectionForTesting(EmbedderStackState stack_state);
|
7114
7991
|
|
7992
|
+
/*
|
7993
|
+
* Called by the embedder to signal newly allocated or freed memory. Not bound
|
7994
|
+
* to tracing phases. Embedders should trade off when increments are reported
|
7995
|
+
* as V8 may consult global heuristics on whether to trigger garbage
|
7996
|
+
* collection on this change.
|
7997
|
+
*/
|
7998
|
+
void IncreaseAllocatedSize(size_t bytes);
|
7999
|
+
void DecreaseAllocatedSize(size_t bytes);
|
8000
|
+
|
7115
8001
|
/*
|
7116
8002
|
* Returns the v8::Isolate this tracer is attached too and |nullptr| if it
|
7117
8003
|
* is not attached to any v8::Isolate.
|
@@ -7159,7 +8045,67 @@ struct DeserializeInternalFieldsCallback {
|
|
7159
8045
|
void* data);
|
7160
8046
|
void* data;
|
7161
8047
|
};
|
7162
|
-
typedef DeserializeInternalFieldsCallback DeserializeEmbedderFieldsCallback;
|
8048
|
+
typedef DeserializeInternalFieldsCallback DeserializeEmbedderFieldsCallback;
|
8049
|
+
|
8050
|
+
/**
|
8051
|
+
* Controls how the default MeasureMemoryDelegate reports the result of
|
8052
|
+
* the memory measurement to JS. With kSummary only the total size is reported.
|
8053
|
+
* With kDetailed the result includes the size of each native context.
|
8054
|
+
*/
|
8055
|
+
enum class MeasureMemoryMode { kSummary, kDetailed };
|
8056
|
+
|
8057
|
+
/**
|
8058
|
+
* Controls how promptly a memory measurement request is executed.
|
8059
|
+
* By default the measurement is folded with the next scheduled GC which may
|
8060
|
+
* happen after a while. The kEager starts increment GC right away and
|
8061
|
+
* is useful for testing.
|
8062
|
+
*/
|
8063
|
+
enum class MeasureMemoryExecution { kDefault, kEager };
|
8064
|
+
|
8065
|
+
/**
|
8066
|
+
* The delegate is used in Isolate::MeasureMemory API.
|
8067
|
+
*
|
8068
|
+
* It specifies the contexts that need to be measured and gets called when
|
8069
|
+
* the measurement is completed to report the results.
|
8070
|
+
*/
|
8071
|
+
class V8_EXPORT MeasureMemoryDelegate {
|
8072
|
+
public:
|
8073
|
+
virtual ~MeasureMemoryDelegate() = default;
|
8074
|
+
|
8075
|
+
/**
|
8076
|
+
* Returns true if the size of the given context needs to be measured.
|
8077
|
+
*/
|
8078
|
+
virtual bool ShouldMeasure(Local<Context> context) = 0;
|
8079
|
+
|
8080
|
+
/**
|
8081
|
+
* This function is called when memory measurement finishes.
|
8082
|
+
*
|
8083
|
+
* \param context_sizes_in_bytes a vector of (context, size) pairs that
|
8084
|
+
* includes each context for which ShouldMeasure returned true and that
|
8085
|
+
* was not garbage collected while the memory measurement was in progress.
|
8086
|
+
*
|
8087
|
+
* \param unattributed_size_in_bytes total size of objects that were not
|
8088
|
+
* attributed to any context (i.e. are likely shared objects).
|
8089
|
+
*/
|
8090
|
+
virtual void MeasurementComplete(
|
8091
|
+
const std::vector<std::pair<Local<Context>, size_t>>&
|
8092
|
+
context_sizes_in_bytes,
|
8093
|
+
size_t unattributed_size_in_bytes) = 0;
|
8094
|
+
|
8095
|
+
/**
|
8096
|
+
* Returns a default delegate that resolves the given promise when
|
8097
|
+
* the memory measurement completes.
|
8098
|
+
*
|
8099
|
+
* \param isolate the current isolate
|
8100
|
+
* \param context the current context
|
8101
|
+
* \param promise_resolver the promise resolver that is given the
|
8102
|
+
* result of the memory measurement.
|
8103
|
+
* \param mode the detail level of the result.
|
8104
|
+
*/
|
8105
|
+
static std::unique_ptr<MeasureMemoryDelegate> Default(
|
8106
|
+
Isolate* isolate, Local<Context> context,
|
8107
|
+
Local<Promise::Resolver> promise_resolver, MeasureMemoryMode mode);
|
8108
|
+
};
|
7163
8109
|
|
7164
8110
|
/**
|
7165
8111
|
* Isolate represents an isolated instance of the V8 engine. V8 isolates have
|
@@ -7182,9 +8128,12 @@ class V8_EXPORT Isolate {
|
|
7182
8128
|
create_histogram_callback(nullptr),
|
7183
8129
|
add_histogram_sample_callback(nullptr),
|
7184
8130
|
array_buffer_allocator(nullptr),
|
8131
|
+
array_buffer_allocator_shared(),
|
7185
8132
|
external_references(nullptr),
|
7186
8133
|
allow_atomics_wait(true),
|
7187
|
-
only_terminate_in_safe_scope(false)
|
8134
|
+
only_terminate_in_safe_scope(false),
|
8135
|
+
embedder_wrapper_type_index(-1),
|
8136
|
+
embedder_wrapper_object_index(-1) {}
|
7188
8137
|
|
7189
8138
|
/**
|
7190
8139
|
* Allows the host application to provide the address of a function that is
|
@@ -7221,8 +8170,14 @@ class V8_EXPORT Isolate {
|
|
7221
8170
|
/**
|
7222
8171
|
* The ArrayBuffer::Allocator to use for allocating and freeing the backing
|
7223
8172
|
* store of ArrayBuffers.
|
8173
|
+
*
|
8174
|
+
* If the shared_ptr version is used, the Isolate instance and every
|
8175
|
+
* |BackingStore| allocated using this allocator hold a std::shared_ptr
|
8176
|
+
* to the allocator, in order to facilitate lifetime
|
8177
|
+
* management for the allocator instance.
|
7224
8178
|
*/
|
7225
8179
|
ArrayBuffer::Allocator* array_buffer_allocator;
|
8180
|
+
std::shared_ptr<ArrayBuffer::Allocator> array_buffer_allocator_shared;
|
7226
8181
|
|
7227
8182
|
/**
|
7228
8183
|
* Specifies an optional nullptr-terminated array of raw addresses in the
|
@@ -7242,6 +8197,14 @@ class V8_EXPORT Isolate {
|
|
7242
8197
|
* Termination is postponed when there is no active SafeForTerminationScope.
|
7243
8198
|
*/
|
7244
8199
|
bool only_terminate_in_safe_scope;
|
8200
|
+
|
8201
|
+
/**
|
8202
|
+
* The following parameters describe the offsets for addressing type info
|
8203
|
+
* for wrapped API objects and are used by the fast C API
|
8204
|
+
* (for details see v8-fast-api-calls.h).
|
8205
|
+
*/
|
8206
|
+
int embedder_wrapper_type_index;
|
8207
|
+
int embedder_wrapper_object_index;
|
7245
8208
|
};
|
7246
8209
|
|
7247
8210
|
|
@@ -7314,7 +8277,8 @@ class V8_EXPORT Isolate {
|
|
7314
8277
|
*/
|
7315
8278
|
class V8_EXPORT SuppressMicrotaskExecutionScope {
|
7316
8279
|
public:
|
7317
|
-
explicit SuppressMicrotaskExecutionScope(
|
8280
|
+
explicit SuppressMicrotaskExecutionScope(
|
8281
|
+
Isolate* isolate, MicrotaskQueue* microtask_queue = nullptr);
|
7318
8282
|
~SuppressMicrotaskExecutionScope();
|
7319
8283
|
|
7320
8284
|
// Prevent copying of Scope objects.
|
@@ -7325,6 +8289,10 @@ class V8_EXPORT Isolate {
|
|
7325
8289
|
|
7326
8290
|
private:
|
7327
8291
|
internal::Isolate* const isolate_;
|
8292
|
+
internal::MicrotaskQueue* const microtask_queue_;
|
8293
|
+
internal::Address previous_stack_height_;
|
8294
|
+
|
8295
|
+
friend class internal::ThreadLocalTop;
|
7328
8296
|
};
|
7329
8297
|
|
7330
8298
|
/**
|
@@ -7434,10 +8402,41 @@ class V8_EXPORT Isolate {
|
|
7434
8402
|
kOptimizedFunctionWithOneShotBytecode = 71,
|
7435
8403
|
kRegExpMatchIsTrueishOnNonJSRegExp = 72,
|
7436
8404
|
kRegExpMatchIsFalseishOnJSRegExp = 73,
|
7437
|
-
kDateGetTimezoneOffset = 74,
|
8405
|
+
kDateGetTimezoneOffset = 74, // Unused.
|
8406
|
+
kStringNormalize = 75,
|
8407
|
+
kCallSiteAPIGetFunctionSloppyCall = 76,
|
8408
|
+
kCallSiteAPIGetThisSloppyCall = 77,
|
8409
|
+
kRegExpMatchAllWithNonGlobalRegExp = 78,
|
8410
|
+
kRegExpExecCalledOnSlowRegExp = 79,
|
8411
|
+
kRegExpReplaceCalledOnSlowRegExp = 80,
|
8412
|
+
kDisplayNames = 81,
|
8413
|
+
kSharedArrayBufferConstructed = 82,
|
8414
|
+
kArrayPrototypeHasElements = 83,
|
8415
|
+
kObjectPrototypeHasElements = 84,
|
8416
|
+
kNumberFormatStyleUnit = 85,
|
8417
|
+
kDateTimeFormatRange = 86,
|
8418
|
+
kDateTimeFormatDateTimeStyle = 87,
|
8419
|
+
kBreakIteratorTypeWord = 88,
|
8420
|
+
kBreakIteratorTypeLine = 89,
|
8421
|
+
kInvalidatedArrayBufferDetachingProtector = 90,
|
8422
|
+
kInvalidatedArrayConstructorProtector = 91,
|
8423
|
+
kInvalidatedArrayIteratorLookupChainProtector = 92,
|
8424
|
+
kInvalidatedArraySpeciesLookupChainProtector = 93,
|
8425
|
+
kInvalidatedIsConcatSpreadableLookupChainProtector = 94,
|
8426
|
+
kInvalidatedMapIteratorLookupChainProtector = 95,
|
8427
|
+
kInvalidatedNoElementsProtector = 96,
|
8428
|
+
kInvalidatedPromiseHookProtector = 97,
|
8429
|
+
kInvalidatedPromiseResolveLookupChainProtector = 98,
|
8430
|
+
kInvalidatedPromiseSpeciesLookupChainProtector = 99,
|
8431
|
+
kInvalidatedPromiseThenLookupChainProtector = 100,
|
8432
|
+
kInvalidatedRegExpSpeciesLookupChainProtector = 101,
|
8433
|
+
kInvalidatedSetIteratorLookupChainProtector = 102,
|
8434
|
+
kInvalidatedStringIteratorLookupChainProtector = 103,
|
8435
|
+
kInvalidatedStringLengthOverflowLookupChainProtector = 104,
|
8436
|
+
kInvalidatedTypedArraySpeciesLookupChainProtector = 105,
|
7438
8437
|
|
7439
8438
|
// If you add new values here, you'll also need to update Chromium's:
|
7440
|
-
// web_feature.mojom,
|
8439
|
+
// web_feature.mojom, use_counter_callback.cc, and enums.xml. V8 changes to
|
7441
8440
|
// this list need to be landed first, then changes on the Chromium side.
|
7442
8441
|
kUseCounterFeatureCount // This enum value must be last.
|
7443
8442
|
};
|
@@ -7495,6 +8494,21 @@ class V8_EXPORT Isolate {
|
|
7495
8494
|
*/
|
7496
8495
|
static Isolate* GetCurrent();
|
7497
8496
|
|
8497
|
+
/**
|
8498
|
+
* Clears the set of objects held strongly by the heap. This set of
|
8499
|
+
* objects are originally built when a WeakRef is created or
|
8500
|
+
* successfully dereferenced.
|
8501
|
+
*
|
8502
|
+
* This is invoked automatically after microtasks are run. See
|
8503
|
+
* MicrotasksPolicy for when microtasks are run.
|
8504
|
+
*
|
8505
|
+
* This needs to be manually invoked only if the embedder is manually running
|
8506
|
+
* microtasks via a custom MicrotaskQueue class's PerformCheckpoint. In that
|
8507
|
+
* case, it is the embedder's responsibility to make this call at a time which
|
8508
|
+
* does not interrupt synchronous ECMAScript code execution.
|
8509
|
+
*/
|
8510
|
+
void ClearKeptObjects();
|
8511
|
+
|
7498
8512
|
/**
|
7499
8513
|
* Custom callback used by embedders to help V8 determine if it should abort
|
7500
8514
|
* when it throws and no internal handler is predicted to catch the
|
@@ -7652,6 +8666,26 @@ class V8_EXPORT Isolate {
|
|
7652
8666
|
*/
|
7653
8667
|
bool GetHeapCodeAndMetadataStatistics(HeapCodeStatistics* object_statistics);
|
7654
8668
|
|
8669
|
+
/**
|
8670
|
+
* This API is experimental and may change significantly.
|
8671
|
+
*
|
8672
|
+
* Enqueues a memory measurement request and invokes the delegate with the
|
8673
|
+
* results.
|
8674
|
+
*
|
8675
|
+
* \param delegate the delegate that defines which contexts to measure and
|
8676
|
+
* reports the results.
|
8677
|
+
*
|
8678
|
+
* \param execution promptness executing the memory measurement.
|
8679
|
+
* The kEager value is expected to be used only in tests.
|
8680
|
+
*/
|
8681
|
+
bool MeasureMemory(
|
8682
|
+
std::unique_ptr<MeasureMemoryDelegate> delegate,
|
8683
|
+
MeasureMemoryExecution execution = MeasureMemoryExecution::kDefault);
|
8684
|
+
|
8685
|
+
V8_DEPRECATE_SOON("Use the version with a delegate")
|
8686
|
+
MaybeLocal<Promise> MeasureMemory(Local<Context> context,
|
8687
|
+
MeasureMemoryMode mode);
|
8688
|
+
|
7655
8689
|
/**
|
7656
8690
|
* Get a call stack sample from the isolate.
|
7657
8691
|
* \param state Execution state.
|
@@ -7700,6 +8734,9 @@ class V8_EXPORT Isolate {
|
|
7700
8734
|
*/
|
7701
8735
|
void SetIdle(bool is_idle);
|
7702
8736
|
|
8737
|
+
/** Returns the ArrayBuffer::Allocator used in this isolate. */
|
8738
|
+
ArrayBuffer::Allocator* GetArrayBufferAllocator();
|
8739
|
+
|
7703
8740
|
/** Returns true if this isolate has a current context. */
|
7704
8741
|
bool InContext();
|
7705
8742
|
|
@@ -7710,8 +8747,8 @@ class V8_EXPORT Isolate {
|
|
7710
8747
|
Local<Context> GetCurrentContext();
|
7711
8748
|
|
7712
8749
|
/** Returns the last context entered through V8's C++ API. */
|
7713
|
-
V8_DEPRECATED("Use GetEnteredOrMicrotaskContext()."
|
7714
|
-
|
8750
|
+
V8_DEPRECATED("Use GetEnteredOrMicrotaskContext().")
|
8751
|
+
Local<Context> GetEnteredContext();
|
7715
8752
|
|
7716
8753
|
/**
|
7717
8754
|
* Returns either the last context entered through V8's C++ API, or the
|
@@ -7985,18 +9022,26 @@ class V8_EXPORT Isolate {
|
|
7985
9022
|
void SetPromiseRejectCallback(PromiseRejectCallback callback);
|
7986
9023
|
|
7987
9024
|
/**
|
7988
|
-
*
|
7989
|
-
|
9025
|
+
* An alias for PerformMicrotaskCheckpoint.
|
9026
|
+
*/
|
9027
|
+
V8_DEPRECATE_SOON("Use PerformMicrotaskCheckpoint.")
|
9028
|
+
void RunMicrotasks() { PerformMicrotaskCheckpoint(); }
|
9029
|
+
|
9030
|
+
/**
|
9031
|
+
* Runs the default MicrotaskQueue until it gets empty and perform other
|
9032
|
+
* microtask checkpoint steps, such as calling ClearKeptObjects. Asserts that
|
9033
|
+
* the MicrotasksPolicy is not kScoped. Any exceptions thrown by microtask
|
9034
|
+
* callbacks are swallowed.
|
7990
9035
|
*/
|
7991
|
-
void
|
9036
|
+
void PerformMicrotaskCheckpoint();
|
7992
9037
|
|
7993
9038
|
/**
|
7994
|
-
* Enqueues the callback to the
|
9039
|
+
* Enqueues the callback to the default MicrotaskQueue
|
7995
9040
|
*/
|
7996
9041
|
void EnqueueMicrotask(Local<Function> microtask);
|
7997
9042
|
|
7998
9043
|
/**
|
7999
|
-
* Enqueues the callback to the
|
9044
|
+
* Enqueues the callback to the default MicrotaskQueue
|
8000
9045
|
*/
|
8001
9046
|
void EnqueueMicrotask(MicrotaskCallback callback, void* data = nullptr);
|
8002
9047
|
|
@@ -8012,22 +9057,29 @@ class V8_EXPORT Isolate {
|
|
8012
9057
|
|
8013
9058
|
/**
|
8014
9059
|
* Adds a callback to notify the host application after
|
8015
|
-
* microtasks were run. The callback is
|
8016
|
-
* call or automatic microtasks execution
|
9060
|
+
* microtasks were run on the default MicrotaskQueue. The callback is
|
9061
|
+
* triggered by explicit RunMicrotasks call or automatic microtasks execution
|
9062
|
+
* (see SetMicrotaskPolicy).
|
8017
9063
|
*
|
8018
9064
|
* Callback will trigger even if microtasks were attempted to run,
|
8019
9065
|
* but the microtasks queue was empty and no single microtask was actually
|
8020
9066
|
* executed.
|
8021
9067
|
*
|
8022
|
-
* Executing
|
9068
|
+
* Executing scripts inside the callback will not re-trigger microtasks and
|
8023
9069
|
* the callback.
|
8024
9070
|
*/
|
9071
|
+
V8_DEPRECATE_SOON("Use *WithData version.")
|
8025
9072
|
void AddMicrotasksCompletedCallback(MicrotasksCompletedCallback callback);
|
9073
|
+
void AddMicrotasksCompletedCallback(
|
9074
|
+
MicrotasksCompletedCallbackWithData callback, void* data = nullptr);
|
8026
9075
|
|
8027
9076
|
/**
|
8028
9077
|
* Removes callback that was installed by AddMicrotasksCompletedCallback.
|
8029
9078
|
*/
|
9079
|
+
V8_DEPRECATE_SOON("Use *WithData version.")
|
8030
9080
|
void RemoveMicrotasksCompletedCallback(MicrotasksCompletedCallback callback);
|
9081
|
+
void RemoveMicrotasksCompletedCallback(
|
9082
|
+
MicrotasksCompletedCallbackWithData callback, void* data = nullptr);
|
8031
9083
|
|
8032
9084
|
/**
|
8033
9085
|
* Sets a callback for counting the number of times a feature of V8 is used.
|
@@ -8049,6 +9101,13 @@ class V8_EXPORT Isolate {
|
|
8049
9101
|
void SetCreateHistogramFunction(CreateHistogramCallback);
|
8050
9102
|
void SetAddHistogramSampleFunction(AddHistogramSampleCallback);
|
8051
9103
|
|
9104
|
+
/**
|
9105
|
+
* Enables the host application to provide a mechanism for recording a
|
9106
|
+
* predefined set of data as crash keys to be used in postmortem debugging in
|
9107
|
+
* case of a crash.
|
9108
|
+
*/
|
9109
|
+
void SetAddCrashKeyCallback(AddCrashKeyCallback);
|
9110
|
+
|
8052
9111
|
/**
|
8053
9112
|
* Optional notification that the embedder is idle.
|
8054
9113
|
* V8 uses the notification to perform garbage collection.
|
@@ -8072,10 +9131,10 @@ class V8_EXPORT Isolate {
|
|
8072
9131
|
void LowMemoryNotification();
|
8073
9132
|
|
8074
9133
|
/**
|
8075
|
-
* Optional notification that a context has been disposed. V8 uses
|
8076
|
-
*
|
8077
|
-
* of context disposals - including this one
|
8078
|
-
* V8 had a chance to clean up.
|
9134
|
+
* Optional notification that a context has been disposed. V8 uses these
|
9135
|
+
* notifications to guide the GC heuristic and cancel FinalizationRegistry
|
9136
|
+
* cleanup tasks. Returns the number of context disposals - including this one
|
9137
|
+
* - since the last time V8 had a chance to clean up.
|
8079
9138
|
*
|
8080
9139
|
* The optional parameter |dependant_context| specifies whether the disposed
|
8081
9140
|
* context was depending on state from other contexts or not.
|
@@ -8171,13 +9230,13 @@ class V8_EXPORT Isolate {
|
|
8171
9230
|
/**
|
8172
9231
|
* Returns a memory range that can potentially contain jitted code. Code for
|
8173
9232
|
* V8's 'builtins' will not be in this range if embedded builtins is enabled.
|
8174
|
-
* Instead, see GetEmbeddedCodeRange.
|
8175
9233
|
*
|
8176
9234
|
* On Win64, embedders are advised to install function table callbacks for
|
8177
9235
|
* these ranges, as default SEH won't be able to unwind through jitted code.
|
8178
|
-
*
|
8179
9236
|
* The first page of the code range is reserved for the embedder and is
|
8180
|
-
* committed, writable, and executable
|
9237
|
+
* committed, writable, and executable, to be used to store unwind data, as
|
9238
|
+
* documented in
|
9239
|
+
* https://docs.microsoft.com/en-us/cpp/build/exception-handling-x64.
|
8181
9240
|
*
|
8182
9241
|
* Might be empty on other platforms.
|
8183
9242
|
*
|
@@ -8188,8 +9247,32 @@ class V8_EXPORT Isolate {
|
|
8188
9247
|
/**
|
8189
9248
|
* Returns the UnwindState necessary for use with the Unwinder API.
|
8190
9249
|
*/
|
9250
|
+
// TODO(petermarshall): Remove this API.
|
9251
|
+
V8_DEPRECATED("Use entry_stubs + code_pages version.")
|
8191
9252
|
UnwindState GetUnwindState();
|
8192
9253
|
|
9254
|
+
/**
|
9255
|
+
* Returns the JSEntryStubs necessary for use with the Unwinder API.
|
9256
|
+
*/
|
9257
|
+
JSEntryStubs GetJSEntryStubs();
|
9258
|
+
|
9259
|
+
static constexpr size_t kMinCodePagesBufferSize = 32;
|
9260
|
+
|
9261
|
+
/**
|
9262
|
+
* Copies the code heap pages currently in use by V8 into |code_pages_out|.
|
9263
|
+
* |code_pages_out| must have at least kMinCodePagesBufferSize capacity and
|
9264
|
+
* must be empty.
|
9265
|
+
*
|
9266
|
+
* Signal-safe, does not allocate, does not access the V8 heap.
|
9267
|
+
* No code on the stack can rely on pages that might be missing.
|
9268
|
+
*
|
9269
|
+
* Returns the number of pages available to be copied, which might be greater
|
9270
|
+
* than |capacity|. In this case, only |capacity| pages will be copied into
|
9271
|
+
* |code_pages_out|. The caller should provide a bigger buffer on the next
|
9272
|
+
* call in order to get all available code pages, but this is not required.
|
9273
|
+
*/
|
9274
|
+
size_t CopyCodePages(size_t capacity, MemoryRange* code_pages_out);
|
9275
|
+
|
8193
9276
|
/** Set the callback to invoke in case of fatal errors. */
|
8194
9277
|
void SetFatalErrorHandler(FatalErrorCallback that);
|
8195
9278
|
|
@@ -8225,8 +9308,13 @@ class V8_EXPORT Isolate {
|
|
8225
9308
|
* Set the callback to invoke to check if code generation from
|
8226
9309
|
* strings should be allowed.
|
8227
9310
|
*/
|
9311
|
+
V8_DEPRECATED(
|
9312
|
+
"Use Isolate::SetModifyCodeGenerationFromStringsCallback instead. "
|
9313
|
+
"See http://crbug.com/v8/10096.")
|
8228
9314
|
void SetAllowCodeGenerationFromStringsCallback(
|
8229
9315
|
AllowCodeGenerationFromStringsCallback callback);
|
9316
|
+
void SetModifyCodeGenerationFromStringsCallback(
|
9317
|
+
ModifyCodeGenerationFromStringsCallback callback);
|
8230
9318
|
|
8231
9319
|
/**
|
8232
9320
|
* Set the callback to invoke to check if wasm code generation should
|
@@ -8242,14 +9330,12 @@ class V8_EXPORT Isolate {
|
|
8242
9330
|
void SetWasmModuleCallback(ExtensionCallback callback);
|
8243
9331
|
void SetWasmInstanceCallback(ExtensionCallback callback);
|
8244
9332
|
|
8245
|
-
V8_DEPRECATED(
|
8246
|
-
"The callback set in SetWasmStreamingCallback is used now",
|
8247
|
-
void SetWasmCompileStreamingCallback(ApiImplementationCallback callback));
|
8248
|
-
|
8249
9333
|
void SetWasmStreamingCallback(WasmStreamingCallback callback);
|
8250
9334
|
|
8251
9335
|
void SetWasmThreadsEnabledCallback(WasmThreadsEnabledCallback callback);
|
8252
9336
|
|
9337
|
+
void SetWasmLoadSourceMapCallback(WasmLoadSourceMapCallback callback);
|
9338
|
+
|
8253
9339
|
/**
|
8254
9340
|
* Check if V8 is dead and therefore unusable. This is the case after
|
8255
9341
|
* fatal errors such as out-of-memory situations.
|
@@ -8312,17 +9398,6 @@ class V8_EXPORT Isolate {
|
|
8312
9398
|
*/
|
8313
9399
|
void VisitHandlesWithClassIds(PersistentHandleVisitor* visitor);
|
8314
9400
|
|
8315
|
-
/**
|
8316
|
-
* Iterates through all the persistent handles in the current isolate's heap
|
8317
|
-
* that have class_ids and are candidates to be marked as partially dependent
|
8318
|
-
* handles. This will visit handles to young objects created since the last
|
8319
|
-
* garbage collection but is free to visit an arbitrary superset of these
|
8320
|
-
* objects.
|
8321
|
-
*/
|
8322
|
-
V8_DEPRECATE_SOON(
|
8323
|
-
"Use VisitHandlesWithClassIds",
|
8324
|
-
void VisitHandlesForPartialDependence(PersistentHandleVisitor* visitor));
|
8325
|
-
|
8326
9401
|
/**
|
8327
9402
|
* Iterates through all the persistent handles in the current isolate's heap
|
8328
9403
|
* that have class_ids and are weak to be marked as inactive if there is no
|
@@ -8343,6 +9418,45 @@ class V8_EXPORT Isolate {
|
|
8343
9418
|
*/
|
8344
9419
|
void SetAllowAtomicsWait(bool allow);
|
8345
9420
|
|
9421
|
+
/**
|
9422
|
+
* Time zone redetection indicator for
|
9423
|
+
* DateTimeConfigurationChangeNotification.
|
9424
|
+
*
|
9425
|
+
* kSkip indicates V8 that the notification should not trigger redetecting
|
9426
|
+
* host time zone. kRedetect indicates V8 that host time zone should be
|
9427
|
+
* redetected, and used to set the default time zone.
|
9428
|
+
*
|
9429
|
+
* The host time zone detection may require file system access or similar
|
9430
|
+
* operations unlikely to be available inside a sandbox. If v8 is run inside a
|
9431
|
+
* sandbox, the host time zone has to be detected outside the sandbox before
|
9432
|
+
* calling DateTimeConfigurationChangeNotification function.
|
9433
|
+
*/
|
9434
|
+
enum class TimeZoneDetection { kSkip, kRedetect };
|
9435
|
+
|
9436
|
+
/**
|
9437
|
+
* Notification that the embedder has changed the time zone, daylight savings
|
9438
|
+
* time or other date / time configuration parameters. V8 keeps a cache of
|
9439
|
+
* various values used for date / time computation. This notification will
|
9440
|
+
* reset those cached values for the current context so that date / time
|
9441
|
+
* configuration changes would be reflected.
|
9442
|
+
*
|
9443
|
+
* This API should not be called more than needed as it will negatively impact
|
9444
|
+
* the performance of date operations.
|
9445
|
+
*/
|
9446
|
+
void DateTimeConfigurationChangeNotification(
|
9447
|
+
TimeZoneDetection time_zone_detection = TimeZoneDetection::kSkip);
|
9448
|
+
|
9449
|
+
/**
|
9450
|
+
* Notification that the embedder has changed the locale. V8 keeps a cache of
|
9451
|
+
* various values used for locale computation. This notification will reset
|
9452
|
+
* those cached values for the current context so that locale configuration
|
9453
|
+
* changes would be reflected.
|
9454
|
+
*
|
9455
|
+
* This API should not be called more than needed as it will negatively impact
|
9456
|
+
* the performance of locale operations.
|
9457
|
+
*/
|
9458
|
+
void LocaleConfigurationChangeNotification();
|
9459
|
+
|
8346
9460
|
Isolate() = delete;
|
8347
9461
|
~Isolate() = delete;
|
8348
9462
|
Isolate(const Isolate&) = delete;
|
@@ -8360,11 +9474,17 @@ class V8_EXPORT Isolate {
|
|
8360
9474
|
|
8361
9475
|
internal::Address* GetDataFromSnapshotOnce(size_t index);
|
8362
9476
|
void ReportExternalAllocationLimitReached();
|
8363
|
-
void CheckMemoryPressure();
|
8364
9477
|
};
|
8365
9478
|
|
8366
9479
|
class V8_EXPORT StartupData {
|
8367
9480
|
public:
|
9481
|
+
/**
|
9482
|
+
* Whether the data created can be rehashed and and the hash seed can be
|
9483
|
+
* recomputed when deserialized.
|
9484
|
+
* Only valid for StartupData returned by SnapshotCreator::CreateBlob().
|
9485
|
+
*/
|
9486
|
+
bool CanBeRehashed() const;
|
9487
|
+
|
8368
9488
|
const char* data;
|
8369
9489
|
int raw_size;
|
8370
9490
|
};
|
@@ -8413,7 +9533,6 @@ class V8_EXPORT V8 {
|
|
8413
9533
|
* handled entirely on the embedders' side.
|
8414
9534
|
* - The call will abort if the data is invalid.
|
8415
9535
|
*/
|
8416
|
-
static void SetNativesDataBlob(StartupData* startup_blob);
|
8417
9536
|
static void SetSnapshotDataBlob(StartupData* startup_blob);
|
8418
9537
|
|
8419
9538
|
/** Set the callback to invoke in case of Dcheck failures. */
|
@@ -8423,7 +9542,8 @@ class V8_EXPORT V8 {
|
|
8423
9542
|
/**
|
8424
9543
|
* Sets V8 flags from a string.
|
8425
9544
|
*/
|
8426
|
-
static void SetFlagsFromString(const char* str
|
9545
|
+
static void SetFlagsFromString(const char* str);
|
9546
|
+
static void SetFlagsFromString(const char* str, size_t length);
|
8427
9547
|
|
8428
9548
|
/**
|
8429
9549
|
* Sets V8 flags from the command line.
|
@@ -8439,7 +9559,12 @@ class V8_EXPORT V8 {
|
|
8439
9559
|
* Initializes V8. This function needs to be called before the first Isolate
|
8440
9560
|
* is created. It always returns true.
|
8441
9561
|
*/
|
8442
|
-
static bool Initialize()
|
9562
|
+
V8_INLINE static bool Initialize() {
|
9563
|
+
const int kBuildConfiguration =
|
9564
|
+
(internal::PointerCompressionIsEnabled() ? kPointerCompression : 0) |
|
9565
|
+
(internal::SmiValuesAre31Bits() ? k31BitSmis : 0);
|
9566
|
+
return Initialize(kBuildConfiguration);
|
9567
|
+
}
|
8443
9568
|
|
8444
9569
|
/**
|
8445
9570
|
* Allows the host application to provide a callback which can be used
|
@@ -8497,17 +9622,16 @@ class V8_EXPORT V8 {
|
|
8497
9622
|
* V8 needs to be given those external files during startup. There are
|
8498
9623
|
* three ways to do this:
|
8499
9624
|
* - InitializeExternalStartupData(const char*)
|
8500
|
-
* This will look in the given directory for
|
8501
|
-
*
|
8502
|
-
*
|
8503
|
-
*
|
8504
|
-
*
|
8505
|
-
* This will read the blobs from the given data structures and will
|
9625
|
+
* This will look in the given directory for the file "snapshot_blob.bin".
|
9626
|
+
* - InitializeExternalStartupDataFromFile(const char*)
|
9627
|
+
* As above, but will directly use the given file name.
|
9628
|
+
* - Call SetSnapshotDataBlob.
|
9629
|
+
* This will read the blobs from the given data structure and will
|
8506
9630
|
* not perform any file IO.
|
8507
9631
|
*/
|
8508
9632
|
static void InitializeExternalStartupData(const char* directory_path);
|
8509
|
-
static void
|
8510
|
-
|
9633
|
+
static void InitializeExternalStartupDataFromFile(const char* snapshot_blob);
|
9634
|
+
|
8511
9635
|
/**
|
8512
9636
|
* Sets the v8::Platform to use. This should be invoked before V8 is
|
8513
9637
|
* initialized.
|
@@ -8540,18 +9664,10 @@ class V8_EXPORT V8 {
|
|
8540
9664
|
* \param context The third argument passed to the Linux signal handler, which
|
8541
9665
|
* points to a ucontext_t structure.
|
8542
9666
|
*/
|
8543
|
-
V8_DEPRECATE_SOON("Use TryHandleWebAssemblyTrapPosix"
|
8544
|
-
|
8545
|
-
void* context));
|
9667
|
+
V8_DEPRECATE_SOON("Use TryHandleWebAssemblyTrapPosix")
|
9668
|
+
static bool TryHandleSignal(int signal_number, void* info, void* context);
|
8546
9669
|
#endif // V8_OS_POSIX
|
8547
9670
|
|
8548
|
-
/**
|
8549
|
-
* Enable the default signal handler rather than using one provided by the
|
8550
|
-
* embedder.
|
8551
|
-
*/
|
8552
|
-
V8_DEPRECATED("Use EnableWebAssemblyTrapHandler",
|
8553
|
-
static bool RegisterDefaultSignalHandler());
|
8554
|
-
|
8555
9671
|
/**
|
8556
9672
|
* Activate trap-based bounds checking for WebAssembly.
|
8557
9673
|
*
|
@@ -8560,37 +9676,86 @@ class V8_EXPORT V8 {
|
|
8560
9676
|
*/
|
8561
9677
|
static bool EnableWebAssemblyTrapHandler(bool use_v8_signal_handler);
|
8562
9678
|
|
9679
|
+
#if defined(V8_OS_WIN)
|
9680
|
+
/**
|
9681
|
+
* On Win64, by default V8 does not emit unwinding data for jitted code,
|
9682
|
+
* which means the OS cannot walk the stack frames and the system Structured
|
9683
|
+
* Exception Handling (SEH) cannot unwind through V8-generated code:
|
9684
|
+
* https://code.google.com/p/v8/issues/detail?id=3598.
|
9685
|
+
*
|
9686
|
+
* This function allows embedders to register a custom exception handler for
|
9687
|
+
* exceptions in V8-generated code.
|
9688
|
+
*/
|
9689
|
+
static void SetUnhandledExceptionCallback(
|
9690
|
+
UnhandledExceptionCallback unhandled_exception_callback);
|
9691
|
+
#endif
|
9692
|
+
|
9693
|
+
/**
|
9694
|
+
* Get statistics about the shared memory usage.
|
9695
|
+
*/
|
9696
|
+
static void GetSharedMemoryStatistics(SharedMemoryStatistics* statistics);
|
9697
|
+
|
8563
9698
|
private:
|
8564
9699
|
V8();
|
8565
9700
|
|
9701
|
+
enum BuildConfigurationFeatures {
|
9702
|
+
kPointerCompression = 1 << 0,
|
9703
|
+
k31BitSmis = 1 << 1,
|
9704
|
+
};
|
9705
|
+
|
9706
|
+
/**
|
9707
|
+
* Checks that the embedder build configuration is compatible with
|
9708
|
+
* the V8 binary and if so initializes V8.
|
9709
|
+
*/
|
9710
|
+
static bool Initialize(int build_config);
|
9711
|
+
|
8566
9712
|
static internal::Address* GlobalizeReference(internal::Isolate* isolate,
|
8567
9713
|
internal::Address* handle);
|
8568
|
-
static internal::Address*
|
9714
|
+
static internal::Address* GlobalizeTracedReference(internal::Isolate* isolate,
|
9715
|
+
internal::Address* handle,
|
9716
|
+
internal::Address* slot,
|
9717
|
+
bool has_destructor);
|
9718
|
+
static void MoveGlobalReference(internal::Address** from,
|
9719
|
+
internal::Address** to);
|
9720
|
+
static void MoveTracedGlobalReference(internal::Address** from,
|
9721
|
+
internal::Address** to);
|
9722
|
+
static void CopyTracedGlobalReference(const internal::Address* const* from,
|
9723
|
+
internal::Address** to);
|
9724
|
+
static internal::Address* CopyGlobalReference(internal::Address* from);
|
8569
9725
|
static void DisposeGlobal(internal::Address* global_handle);
|
9726
|
+
static void DisposeTracedGlobal(internal::Address* global_handle);
|
8570
9727
|
static void MakeWeak(internal::Address* location, void* data,
|
8571
9728
|
WeakCallbackInfo<void>::Callback weak_callback,
|
8572
9729
|
WeakCallbackType type);
|
8573
9730
|
static void MakeWeak(internal::Address** location_addr);
|
8574
9731
|
static void* ClearWeak(internal::Address* location);
|
9732
|
+
static void SetFinalizationCallbackTraced(
|
9733
|
+
internal::Address* location, void* parameter,
|
9734
|
+
WeakCallbackInfo<void>::Callback callback);
|
8575
9735
|
static void AnnotateStrongRetainer(internal::Address* location,
|
8576
9736
|
const char* label);
|
8577
9737
|
static Value* Eternalize(Isolate* isolate, Value* handle);
|
8578
9738
|
|
8579
|
-
static void RegisterExternallyReferencedObject(internal::Address* location,
|
8580
|
-
internal::Isolate* isolate);
|
8581
|
-
|
8582
9739
|
template <class K, class V, class T>
|
8583
9740
|
friend class PersistentValueMapBase;
|
8584
9741
|
|
8585
9742
|
static void FromJustIsNothing();
|
8586
9743
|
static void ToLocalEmpty();
|
8587
9744
|
static void InternalFieldOutOfBounds(int index);
|
9745
|
+
template <class T>
|
9746
|
+
friend class Global;
|
8588
9747
|
template <class T> friend class Local;
|
8589
9748
|
template <class T>
|
8590
9749
|
friend class MaybeLocal;
|
8591
9750
|
template <class T>
|
8592
9751
|
friend class Maybe;
|
8593
9752
|
template <class T>
|
9753
|
+
friend class TracedReferenceBase;
|
9754
|
+
template <class T>
|
9755
|
+
friend class TracedGlobal;
|
9756
|
+
template <class T>
|
9757
|
+
friend class TracedReference;
|
9758
|
+
template <class T>
|
8594
9759
|
friend class WeakCallbackInfo;
|
8595
9760
|
template <class T> friend class Eternal;
|
8596
9761
|
template <class T> friend class PersistentBase;
|
@@ -8600,6 +9765,11 @@ class V8_EXPORT V8 {
|
|
8600
9765
|
|
8601
9766
|
/**
|
8602
9767
|
* Helper class to create a snapshot data blob.
|
9768
|
+
*
|
9769
|
+
* The Isolate used by a SnapshotCreator is owned by it, and will be entered
|
9770
|
+
* and exited by the constructor and destructor, respectively; The destructor
|
9771
|
+
* will also destroy the Isolate. Experimental language features, including
|
9772
|
+
* those available by default, are not available while creating a snapshot.
|
8603
9773
|
*/
|
8604
9774
|
class V8_EXPORT SnapshotCreator {
|
8605
9775
|
public:
|
@@ -8628,6 +9798,10 @@ class V8_EXPORT SnapshotCreator {
|
|
8628
9798
|
SnapshotCreator(const intptr_t* external_references = nullptr,
|
8629
9799
|
StartupData* existing_blob = nullptr);
|
8630
9800
|
|
9801
|
+
/**
|
9802
|
+
* Destroy the snapshot creator, and exit and dispose of the Isolate
|
9803
|
+
* associated with it.
|
9804
|
+
*/
|
8631
9805
|
~SnapshotCreator();
|
8632
9806
|
|
8633
9807
|
/**
|
@@ -8658,12 +9832,6 @@ class V8_EXPORT SnapshotCreator {
|
|
8658
9832
|
SerializeInternalFieldsCallback callback =
|
8659
9833
|
SerializeInternalFieldsCallback());
|
8660
9834
|
|
8661
|
-
/**
|
8662
|
-
* Add a template to be included in the snapshot blob.
|
8663
|
-
* \returns the index of the template in the snapshot blob.
|
8664
|
-
*/
|
8665
|
-
size_t AddTemplate(Local<Template> template_obj);
|
8666
|
-
|
8667
9835
|
/**
|
8668
9836
|
* Attach arbitrary V8::Data to the context snapshot, which can be retrieved
|
8669
9837
|
* via Context::GetDataFromSnapshot after deserialization. This data does not
|
@@ -8884,9 +10052,17 @@ class V8_EXPORT TryCatch {
|
|
8884
10052
|
Local<Value> Exception() const;
|
8885
10053
|
|
8886
10054
|
/**
|
8887
|
-
* Returns the .stack property of
|
10055
|
+
* Returns the .stack property of an object. If no .stack
|
8888
10056
|
* property is present an empty handle is returned.
|
8889
10057
|
*/
|
10058
|
+
V8_WARN_UNUSED_RESULT static MaybeLocal<Value> StackTrace(
|
10059
|
+
Local<Context> context, Local<Value> exception);
|
10060
|
+
|
10061
|
+
/**
|
10062
|
+
* Returns the .stack property of the thrown object. If no .stack property is
|
10063
|
+
* present or if this try/catch block has not caught an exception, an empty
|
10064
|
+
* handle is returned.
|
10065
|
+
*/
|
8890
10066
|
V8_WARN_UNUSED_RESULT MaybeLocal<Value> StackTrace(
|
8891
10067
|
Local<Context> context) const;
|
8892
10068
|
|
@@ -9046,7 +10222,8 @@ class V8_EXPORT Context {
|
|
9046
10222
|
MaybeLocal<ObjectTemplate> global_template = MaybeLocal<ObjectTemplate>(),
|
9047
10223
|
MaybeLocal<Value> global_object = MaybeLocal<Value>(),
|
9048
10224
|
DeserializeInternalFieldsCallback internal_fields_deserializer =
|
9049
|
-
DeserializeInternalFieldsCallback()
|
10225
|
+
DeserializeInternalFieldsCallback(),
|
10226
|
+
MicrotaskQueue* microtask_queue = nullptr);
|
9050
10227
|
|
9051
10228
|
/**
|
9052
10229
|
* Create a new context from a (non-default) context snapshot. There
|
@@ -9066,13 +10243,13 @@ class V8_EXPORT Context {
|
|
9066
10243
|
*
|
9067
10244
|
* \param global_object See v8::Context::New.
|
9068
10245
|
*/
|
9069
|
-
|
9070
10246
|
static MaybeLocal<Context> FromSnapshot(
|
9071
10247
|
Isolate* isolate, size_t context_snapshot_index,
|
9072
10248
|
DeserializeInternalFieldsCallback embedder_fields_deserializer =
|
9073
10249
|
DeserializeInternalFieldsCallback(),
|
9074
10250
|
ExtensionConfiguration* extensions = nullptr,
|
9075
|
-
MaybeLocal<Value> global_object = MaybeLocal<Value>()
|
10251
|
+
MaybeLocal<Value> global_object = MaybeLocal<Value>(),
|
10252
|
+
MicrotaskQueue* microtask_queue = nullptr);
|
9076
10253
|
|
9077
10254
|
/**
|
9078
10255
|
* Returns an global object that isn't backed by an actual context.
|
@@ -9207,6 +10384,27 @@ class V8_EXPORT Context {
|
|
9207
10384
|
template <class T>
|
9208
10385
|
V8_INLINE MaybeLocal<T> GetDataFromSnapshotOnce(size_t index);
|
9209
10386
|
|
10387
|
+
/**
|
10388
|
+
* If callback is set, abort any attempt to execute JavaScript in this
|
10389
|
+
* context, call the specified callback, and throw an exception.
|
10390
|
+
* To unset abort, pass nullptr as callback.
|
10391
|
+
*/
|
10392
|
+
typedef void (*AbortScriptExecutionCallback)(Isolate* isolate,
|
10393
|
+
Local<Context> context);
|
10394
|
+
void SetAbortScriptExecution(AbortScriptExecutionCallback callback);
|
10395
|
+
|
10396
|
+
/**
|
10397
|
+
* Returns the value that was set or restored by
|
10398
|
+
* SetContinuationPreservedEmbedderData(), if any.
|
10399
|
+
*/
|
10400
|
+
Local<Value> GetContinuationPreservedEmbedderData() const;
|
10401
|
+
|
10402
|
+
/**
|
10403
|
+
* Sets a value that will be stored on continuations and reset while the
|
10404
|
+
* continuation runs.
|
10405
|
+
*/
|
10406
|
+
void SetContinuationPreservedEmbedderData(Local<Value> context);
|
10407
|
+
|
9210
10408
|
/**
|
9211
10409
|
* Stack-allocated class which sets the execution context for all
|
9212
10410
|
* operations executed within a local scope.
|
@@ -9391,7 +10589,7 @@ class V8_EXPORT Locker {
|
|
9391
10589
|
/**
|
9392
10590
|
* Various helpers for skipping over V8 frames in a given stack.
|
9393
10591
|
*
|
9394
|
-
* The unwinder API is only supported on the x64
|
10592
|
+
* The unwinder API is only supported on the x64, ARM64 and ARM32 architectures.
|
9395
10593
|
*/
|
9396
10594
|
class V8_EXPORT Unwinder {
|
9397
10595
|
public:
|
@@ -9423,10 +10621,26 @@ class V8_EXPORT Unwinder {
|
|
9423
10621
|
*
|
9424
10622
|
* \return True on success.
|
9425
10623
|
*/
|
10624
|
+
// TODO(petermarshall): Remove this API
|
10625
|
+
V8_DEPRECATED("Use entry_stubs + code_pages version.")
|
9426
10626
|
static bool TryUnwindV8Frames(const UnwindState& unwind_state,
|
9427
10627
|
RegisterState* register_state,
|
9428
10628
|
const void* stack_base);
|
9429
10629
|
|
10630
|
+
/**
|
10631
|
+
* The same as above, but is available on x64, ARM64 and ARM32.
|
10632
|
+
*
|
10633
|
+
* \param code_pages A list of all of the ranges in which V8 has allocated
|
10634
|
+
* executable code. The caller should obtain this list by calling
|
10635
|
+
* Isolate::CopyCodePages() during the same interrupt/thread suspension that
|
10636
|
+
* captures the stack.
|
10637
|
+
*/
|
10638
|
+
static bool TryUnwindV8Frames(const JSEntryStubs& entry_stubs,
|
10639
|
+
size_t code_pages_length,
|
10640
|
+
const MemoryRange* code_pages,
|
10641
|
+
RegisterState* register_state,
|
10642
|
+
const void* stack_base);
|
10643
|
+
|
9430
10644
|
/**
|
9431
10645
|
* Whether the PC is within the V8 code range represented by code_range or
|
9432
10646
|
* embedded_code_range in |unwind_state|.
|
@@ -9435,7 +10649,16 @@ class V8_EXPORT Unwinder {
|
|
9435
10649
|
* and unwind_state will always fail. If it returns true, then unwinding may
|
9436
10650
|
* (but not necessarily) be successful.
|
9437
10651
|
*/
|
10652
|
+
// TODO(petermarshall): Remove this API
|
10653
|
+
V8_DEPRECATED("Use code_pages version.")
|
9438
10654
|
static bool PCIsInV8(const UnwindState& unwind_state, void* pc);
|
10655
|
+
|
10656
|
+
/**
|
10657
|
+
* The same as above, but is available on x64, ARM64 and ARM32. See the
|
10658
|
+
* comment on TryUnwindV8Frames.
|
10659
|
+
*/
|
10660
|
+
static bool PCIsInV8(size_t code_pages_length, const MemoryRange* code_pages,
|
10661
|
+
void* pc);
|
9439
10662
|
};
|
9440
10663
|
|
9441
10664
|
// --- Implementation ---
|
@@ -9450,6 +10673,10 @@ Local
|
|
9450
10673
|
return New(isolate, that.val_);
|
9451
10674
|
}
|
9452
10675
|
|
10676
|
+
template <class T>
|
10677
|
+
Local<T> Local<T>::New(Isolate* isolate, const TracedReferenceBase<T>& that) {
|
10678
|
+
return New(isolate, that.val_);
|
10679
|
+
}
|
9453
10680
|
|
9454
10681
|
template <class T>
|
9455
10682
|
Local<T> Local<T>::New(Isolate* isolate, T* that) {
|
@@ -9464,7 +10691,7 @@ Local
|
|
9464
10691
|
template<class T>
|
9465
10692
|
template<class S>
|
9466
10693
|
void Eternal<T>::Set(Isolate* isolate, Local<S> handle) {
|
9467
|
-
|
10694
|
+
static_assert(std::is_base_of<T, S>::value, "type check");
|
9468
10695
|
val_ = reinterpret_cast<T*>(
|
9469
10696
|
V8::Eternalize(isolate, reinterpret_cast<Value*>(*handle)));
|
9470
10697
|
}
|
@@ -9508,33 +10735,14 @@ T* PersistentBase
|
|
9508
10735
|
template <class T, class M>
|
9509
10736
|
template <class S, class M2>
|
9510
10737
|
void Persistent<T, M>::Copy(const Persistent<S, M2>& that) {
|
9511
|
-
|
10738
|
+
static_assert(std::is_base_of<T, S>::value, "type check");
|
9512
10739
|
this->Reset();
|
9513
10740
|
if (that.IsEmpty()) return;
|
9514
10741
|
internal::Address* p = reinterpret_cast<internal::Address*>(that.val_);
|
9515
|
-
this->val_ = reinterpret_cast<T*>(V8::
|
10742
|
+
this->val_ = reinterpret_cast<T*>(V8::CopyGlobalReference(p));
|
9516
10743
|
M::Copy(that, this);
|
9517
10744
|
}
|
9518
10745
|
|
9519
|
-
template <class T>
|
9520
|
-
bool PersistentBase<T>::IsIndependent() const {
|
9521
|
-
typedef internal::Internals I;
|
9522
|
-
if (this->IsEmpty()) return false;
|
9523
|
-
return I::GetNodeFlag(reinterpret_cast<internal::Address*>(this->val_),
|
9524
|
-
I::kNodeIsIndependentShift);
|
9525
|
-
}
|
9526
|
-
|
9527
|
-
template <class T>
|
9528
|
-
bool PersistentBase<T>::IsNearDeath() const {
|
9529
|
-
typedef internal::Internals I;
|
9530
|
-
if (this->IsEmpty()) return false;
|
9531
|
-
uint8_t node_state =
|
9532
|
-
I::GetNodeState(reinterpret_cast<internal::Address*>(this->val_));
|
9533
|
-
return node_state == I::kNodeStateIsNearDeathValue ||
|
9534
|
-
node_state == I::kNodeStateIsPendingValue;
|
9535
|
-
}
|
9536
|
-
|
9537
|
-
|
9538
10746
|
template <class T>
|
9539
10747
|
bool PersistentBase<T>::IsWeak() const {
|
9540
10748
|
typedef internal::Internals I;
|
@@ -9555,7 +10763,7 @@ void PersistentBase
|
|
9555
10763
|
template <class T>
|
9556
10764
|
template <class S>
|
9557
10765
|
void PersistentBase<T>::Reset(Isolate* isolate, const Local<S>& other) {
|
9558
|
-
|
10766
|
+
static_assert(std::is_base_of<T, S>::value, "type check");
|
9559
10767
|
Reset();
|
9560
10768
|
if (other.IsEmpty()) return;
|
9561
10769
|
this->val_ = New(isolate, other.val_);
|
@@ -9566,7 +10774,7 @@ template
|
|
9566
10774
|
template <class S>
|
9567
10775
|
void PersistentBase<T>::Reset(Isolate* isolate,
|
9568
10776
|
const PersistentBase<S>& other) {
|
9569
|
-
|
10777
|
+
static_assert(std::is_base_of<T, S>::value, "type check");
|
9570
10778
|
Reset();
|
9571
10779
|
if (other.IsEmpty()) return;
|
9572
10780
|
this->val_ = New(isolate, other.val_);
|
@@ -9602,56 +10810,199 @@ void PersistentBase
|
|
9602
10810
|
}
|
9603
10811
|
|
9604
10812
|
template <class T>
|
9605
|
-
void PersistentBase<T>::
|
9606
|
-
|
9607
|
-
|
9608
|
-
|
9609
|
-
|
10813
|
+
void PersistentBase<T>::SetWrapperClassId(uint16_t class_id) {
|
10814
|
+
typedef internal::Internals I;
|
10815
|
+
if (this->IsEmpty()) return;
|
10816
|
+
internal::Address* obj = reinterpret_cast<internal::Address*>(this->val_);
|
10817
|
+
uint8_t* addr = reinterpret_cast<uint8_t*>(obj) + I::kNodeClassIdOffset;
|
10818
|
+
*reinterpret_cast<uint16_t*>(addr) = class_id;
|
9610
10819
|
}
|
9611
10820
|
|
10821
|
+
|
9612
10822
|
template <class T>
|
9613
|
-
|
10823
|
+
uint16_t PersistentBase<T>::WrapperClassId() const {
|
9614
10824
|
typedef internal::Internals I;
|
9615
|
-
if (this->IsEmpty()) return;
|
9616
|
-
|
9617
|
-
|
10825
|
+
if (this->IsEmpty()) return 0;
|
10826
|
+
internal::Address* obj = reinterpret_cast<internal::Address*>(this->val_);
|
10827
|
+
uint8_t* addr = reinterpret_cast<uint8_t*>(obj) + I::kNodeClassIdOffset;
|
10828
|
+
return *reinterpret_cast<uint16_t*>(addr);
|
9618
10829
|
}
|
9619
10830
|
|
9620
10831
|
template <class T>
|
9621
|
-
|
9622
|
-
|
9623
|
-
|
9624
|
-
|
9625
|
-
|
10832
|
+
Global<T>::Global(Global&& other) : PersistentBase<T>(other.val_) {
|
10833
|
+
if (other.val_ != nullptr) {
|
10834
|
+
V8::MoveGlobalReference(reinterpret_cast<internal::Address**>(&other.val_),
|
10835
|
+
reinterpret_cast<internal::Address**>(&this->val_));
|
10836
|
+
other.val_ = nullptr;
|
10837
|
+
}
|
10838
|
+
}
|
10839
|
+
|
10840
|
+
template <class T>
|
10841
|
+
template <class S>
|
10842
|
+
Global<T>& Global<T>::operator=(Global<S>&& rhs) {
|
10843
|
+
static_assert(std::is_base_of<T, S>::value, "type check");
|
10844
|
+
if (this != &rhs) {
|
10845
|
+
this->Reset();
|
10846
|
+
if (rhs.val_ != nullptr) {
|
10847
|
+
this->val_ = rhs.val_;
|
10848
|
+
V8::MoveGlobalReference(
|
10849
|
+
reinterpret_cast<internal::Address**>(&rhs.val_),
|
10850
|
+
reinterpret_cast<internal::Address**>(&this->val_));
|
10851
|
+
rhs.val_ = nullptr;
|
10852
|
+
}
|
10853
|
+
}
|
10854
|
+
return *this;
|
9626
10855
|
}
|
9627
10856
|
|
10857
|
+
template <class T>
|
10858
|
+
T* TracedReferenceBase<T>::New(Isolate* isolate, T* that, void* slot,
|
10859
|
+
DestructionMode destruction_mode) {
|
10860
|
+
if (that == nullptr) return nullptr;
|
10861
|
+
internal::Address* p = reinterpret_cast<internal::Address*>(that);
|
10862
|
+
return reinterpret_cast<T*>(V8::GlobalizeTracedReference(
|
10863
|
+
reinterpret_cast<internal::Isolate*>(isolate), p,
|
10864
|
+
reinterpret_cast<internal::Address*>(slot),
|
10865
|
+
destruction_mode == kWithDestructor));
|
10866
|
+
}
|
9628
10867
|
|
9629
10868
|
template <class T>
|
9630
|
-
void
|
10869
|
+
void TracedReferenceBase<T>::Reset() {
|
10870
|
+
if (IsEmpty()) return;
|
10871
|
+
V8::DisposeTracedGlobal(reinterpret_cast<internal::Address*>(val_));
|
10872
|
+
val_ = nullptr;
|
10873
|
+
}
|
10874
|
+
|
10875
|
+
template <class T>
|
10876
|
+
template <class S>
|
10877
|
+
void TracedGlobal<T>::Reset(Isolate* isolate, const Local<S>& other) {
|
10878
|
+
static_assert(std::is_base_of<T, S>::value, "type check");
|
10879
|
+
Reset();
|
10880
|
+
if (other.IsEmpty()) return;
|
10881
|
+
this->val_ = this->New(isolate, other.val_, &this->val_,
|
10882
|
+
TracedReferenceBase<T>::kWithDestructor);
|
10883
|
+
}
|
10884
|
+
|
10885
|
+
template <class T>
|
10886
|
+
template <class S>
|
10887
|
+
TracedGlobal<T>& TracedGlobal<T>::operator=(TracedGlobal<S>&& rhs) {
|
10888
|
+
static_assert(std::is_base_of<T, S>::value, "type check");
|
10889
|
+
*this = std::move(rhs.template As<T>());
|
10890
|
+
return *this;
|
10891
|
+
}
|
10892
|
+
|
10893
|
+
template <class T>
|
10894
|
+
template <class S>
|
10895
|
+
TracedGlobal<T>& TracedGlobal<T>::operator=(const TracedGlobal<S>& rhs) {
|
10896
|
+
static_assert(std::is_base_of<T, S>::value, "type check");
|
10897
|
+
*this = rhs.template As<T>();
|
10898
|
+
return *this;
|
10899
|
+
}
|
10900
|
+
|
10901
|
+
template <class T>
|
10902
|
+
TracedGlobal<T>& TracedGlobal<T>::operator=(TracedGlobal&& rhs) {
|
10903
|
+
if (this != &rhs) {
|
10904
|
+
V8::MoveTracedGlobalReference(
|
10905
|
+
reinterpret_cast<internal::Address**>(&rhs.val_),
|
10906
|
+
reinterpret_cast<internal::Address**>(&this->val_));
|
10907
|
+
}
|
10908
|
+
return *this;
|
10909
|
+
}
|
10910
|
+
|
10911
|
+
template <class T>
|
10912
|
+
TracedGlobal<T>& TracedGlobal<T>::operator=(const TracedGlobal& rhs) {
|
10913
|
+
if (this != &rhs) {
|
10914
|
+
this->Reset();
|
10915
|
+
if (rhs.val_ != nullptr) {
|
10916
|
+
V8::CopyTracedGlobalReference(
|
10917
|
+
reinterpret_cast<const internal::Address* const*>(&rhs.val_),
|
10918
|
+
reinterpret_cast<internal::Address**>(&this->val_));
|
10919
|
+
}
|
10920
|
+
}
|
10921
|
+
return *this;
|
10922
|
+
}
|
10923
|
+
|
10924
|
+
template <class T>
|
10925
|
+
template <class S>
|
10926
|
+
void TracedReference<T>::Reset(Isolate* isolate, const Local<S>& other) {
|
10927
|
+
static_assert(std::is_base_of<T, S>::value, "type check");
|
10928
|
+
Reset();
|
10929
|
+
if (other.IsEmpty()) return;
|
10930
|
+
this->val_ = this->New(isolate, other.val_, &this->val_,
|
10931
|
+
TracedReferenceBase<T>::kWithoutDestructor);
|
10932
|
+
}
|
10933
|
+
|
10934
|
+
template <class T>
|
10935
|
+
template <class S>
|
10936
|
+
TracedReference<T>& TracedReference<T>::operator=(TracedReference<S>&& rhs) {
|
10937
|
+
static_assert(std::is_base_of<T, S>::value, "type check");
|
10938
|
+
*this = std::move(rhs.template As<T>());
|
10939
|
+
return *this;
|
10940
|
+
}
|
10941
|
+
|
10942
|
+
template <class T>
|
10943
|
+
template <class S>
|
10944
|
+
TracedReference<T>& TracedReference<T>::operator=(
|
10945
|
+
const TracedReference<S>& rhs) {
|
10946
|
+
static_assert(std::is_base_of<T, S>::value, "type check");
|
10947
|
+
*this = rhs.template As<T>();
|
10948
|
+
return *this;
|
10949
|
+
}
|
10950
|
+
|
10951
|
+
template <class T>
|
10952
|
+
TracedReference<T>& TracedReference<T>::operator=(TracedReference&& rhs) {
|
10953
|
+
if (this != &rhs) {
|
10954
|
+
V8::MoveTracedGlobalReference(
|
10955
|
+
reinterpret_cast<internal::Address**>(&rhs.val_),
|
10956
|
+
reinterpret_cast<internal::Address**>(&this->val_));
|
10957
|
+
}
|
10958
|
+
return *this;
|
10959
|
+
}
|
10960
|
+
|
10961
|
+
template <class T>
|
10962
|
+
TracedReference<T>& TracedReference<T>::operator=(const TracedReference& rhs) {
|
10963
|
+
if (this != &rhs) {
|
10964
|
+
this->Reset();
|
10965
|
+
if (rhs.val_ != nullptr) {
|
10966
|
+
V8::CopyTracedGlobalReference(
|
10967
|
+
reinterpret_cast<const internal::Address* const*>(&rhs.val_),
|
10968
|
+
reinterpret_cast<internal::Address**>(&this->val_));
|
10969
|
+
}
|
10970
|
+
}
|
10971
|
+
return *this;
|
10972
|
+
}
|
10973
|
+
|
10974
|
+
template <class T>
|
10975
|
+
void TracedReferenceBase<T>::SetWrapperClassId(uint16_t class_id) {
|
9631
10976
|
typedef internal::Internals I;
|
9632
|
-
if (
|
9633
|
-
internal::Address* obj = reinterpret_cast<internal::Address*>(
|
10977
|
+
if (IsEmpty()) return;
|
10978
|
+
internal::Address* obj = reinterpret_cast<internal::Address*>(val_);
|
9634
10979
|
uint8_t* addr = reinterpret_cast<uint8_t*>(obj) + I::kNodeClassIdOffset;
|
9635
10980
|
*reinterpret_cast<uint16_t*>(addr) = class_id;
|
9636
10981
|
}
|
9637
10982
|
|
9638
|
-
|
9639
10983
|
template <class T>
|
9640
|
-
uint16_t
|
10984
|
+
uint16_t TracedReferenceBase<T>::WrapperClassId() const {
|
9641
10985
|
typedef internal::Internals I;
|
9642
|
-
if (
|
9643
|
-
internal::Address* obj = reinterpret_cast<internal::Address*>(
|
10986
|
+
if (IsEmpty()) return 0;
|
10987
|
+
internal::Address* obj = reinterpret_cast<internal::Address*>(val_);
|
9644
10988
|
uint8_t* addr = reinterpret_cast<uint8_t*>(obj) + I::kNodeClassIdOffset;
|
9645
10989
|
return *reinterpret_cast<uint16_t*>(addr);
|
9646
10990
|
}
|
9647
10991
|
|
10992
|
+
template <class T>
|
10993
|
+
void TracedGlobal<T>::SetFinalizationCallback(
|
10994
|
+
void* parameter, typename WeakCallbackInfo<void>::Callback callback) {
|
10995
|
+
V8::SetFinalizationCallbackTraced(
|
10996
|
+
reinterpret_cast<internal::Address*>(this->val_), parameter, callback);
|
10997
|
+
}
|
10998
|
+
|
9648
10999
|
template <typename T>
|
9649
11000
|
ReturnValue<T>::ReturnValue(internal::Address* slot) : value_(slot) {}
|
9650
11001
|
|
9651
|
-
template<typename T>
|
9652
|
-
template<typename S>
|
9653
|
-
void ReturnValue<T>::Set(const
|
9654
|
-
|
11002
|
+
template <typename T>
|
11003
|
+
template <typename S>
|
11004
|
+
void ReturnValue<T>::Set(const Global<S>& handle) {
|
11005
|
+
static_assert(std::is_base_of<T, S>::value, "type check");
|
9655
11006
|
if (V8_UNLIKELY(handle.IsEmpty())) {
|
9656
11007
|
*value_ = GetDefaultValue();
|
9657
11008
|
} else {
|
@@ -9661,19 +11012,20 @@ void ReturnValue
|
|
9661
11012
|
|
9662
11013
|
template <typename T>
|
9663
11014
|
template <typename S>
|
9664
|
-
void ReturnValue<T>::Set(const
|
9665
|
-
|
11015
|
+
void ReturnValue<T>::Set(const TracedReferenceBase<S>& handle) {
|
11016
|
+
static_assert(std::is_base_of<T, S>::value, "type check");
|
9666
11017
|
if (V8_UNLIKELY(handle.IsEmpty())) {
|
9667
11018
|
*value_ = GetDefaultValue();
|
9668
11019
|
} else {
|
9669
|
-
*value_ = *reinterpret_cast<internal::Address*>(
|
11020
|
+
*value_ = *reinterpret_cast<internal::Address*>(handle.val_);
|
9670
11021
|
}
|
9671
11022
|
}
|
9672
11023
|
|
9673
11024
|
template <typename T>
|
9674
11025
|
template <typename S>
|
9675
11026
|
void ReturnValue<T>::Set(const Local<S> handle) {
|
9676
|
-
|
11027
|
+
static_assert(std::is_void<T>::value || std::is_base_of<T, S>::value,
|
11028
|
+
"type check");
|
9677
11029
|
if (V8_UNLIKELY(handle.IsEmpty())) {
|
9678
11030
|
*value_ = GetDefaultValue();
|
9679
11031
|
} else {
|
@@ -9683,13 +11035,13 @@ void ReturnValue
|
|
9683
11035
|
|
9684
11036
|
template<typename T>
|
9685
11037
|
void ReturnValue<T>::Set(double i) {
|
9686
|
-
|
11038
|
+
static_assert(std::is_base_of<T, Number>::value, "type check");
|
9687
11039
|
Set(Number::New(GetIsolate(), i));
|
9688
11040
|
}
|
9689
11041
|
|
9690
11042
|
template<typename T>
|
9691
11043
|
void ReturnValue<T>::Set(int32_t i) {
|
9692
|
-
|
11044
|
+
static_assert(std::is_base_of<T, Integer>::value, "type check");
|
9693
11045
|
typedef internal::Internals I;
|
9694
11046
|
if (V8_LIKELY(I::IsValidSmi(i))) {
|
9695
11047
|
*value_ = I::IntToSmi(i);
|
@@ -9700,7 +11052,7 @@ void ReturnValue
|
|
9700
11052
|
|
9701
11053
|
template<typename T>
|
9702
11054
|
void ReturnValue<T>::Set(uint32_t i) {
|
9703
|
-
|
11055
|
+
static_assert(std::is_base_of<T, Integer>::value, "type check");
|
9704
11056
|
// Can't simply use INT32_MAX here for whatever reason.
|
9705
11057
|
bool fits_into_int32_t = (i & (1U << 31)) == 0;
|
9706
11058
|
if (V8_LIKELY(fits_into_int32_t)) {
|
@@ -9712,7 +11064,7 @@ void ReturnValue
|
|
9712
11064
|
|
9713
11065
|
template<typename T>
|
9714
11066
|
void ReturnValue<T>::Set(bool value) {
|
9715
|
-
|
11067
|
+
static_assert(std::is_base_of<T, Boolean>::value, "type check");
|
9716
11068
|
typedef internal::Internals I;
|
9717
11069
|
int root_index;
|
9718
11070
|
if (value) {
|
@@ -9725,21 +11077,21 @@ void ReturnValue
|
|
9725
11077
|
|
9726
11078
|
template<typename T>
|
9727
11079
|
void ReturnValue<T>::SetNull() {
|
9728
|
-
|
11080
|
+
static_assert(std::is_base_of<T, Primitive>::value, "type check");
|
9729
11081
|
typedef internal::Internals I;
|
9730
11082
|
*value_ = *I::GetRoot(GetIsolate(), I::kNullValueRootIndex);
|
9731
11083
|
}
|
9732
11084
|
|
9733
11085
|
template<typename T>
|
9734
11086
|
void ReturnValue<T>::SetUndefined() {
|
9735
|
-
|
11087
|
+
static_assert(std::is_base_of<T, Primitive>::value, "type check");
|
9736
11088
|
typedef internal::Internals I;
|
9737
11089
|
*value_ = *I::GetRoot(GetIsolate(), I::kUndefinedValueRootIndex);
|
9738
11090
|
}
|
9739
11091
|
|
9740
11092
|
template<typename T>
|
9741
11093
|
void ReturnValue<T>::SetEmptyString() {
|
9742
|
-
|
11094
|
+
static_assert(std::is_base_of<T, String>::value, "type check");
|
9743
11095
|
typedef internal::Internals I;
|
9744
11096
|
*value_ = *I::GetRoot(GetIsolate(), I::kEmptyStringRootIndex);
|
9745
11097
|
}
|
@@ -9761,8 +11113,7 @@ Local
|
|
9761
11113
|
template <typename T>
|
9762
11114
|
template <typename S>
|
9763
11115
|
void ReturnValue<T>::Set(S* whatever) {
|
9764
|
-
|
9765
|
-
TYPE_CHECK(S*, Primitive);
|
11116
|
+
static_assert(sizeof(S) < 0, "incompilable to prevent inadvertent misuse");
|
9766
11117
|
}
|
9767
11118
|
|
9768
11119
|
template <typename T>
|
@@ -9779,14 +11130,24 @@ FunctionCallbackInfo
|
|
9779
11130
|
|
9780
11131
|
template<typename T>
|
9781
11132
|
Local<Value> FunctionCallbackInfo<T>::operator[](int i) const {
|
11133
|
+
// values_ points to the first argument (not the receiver).
|
9782
11134
|
if (i < 0 || length_ <= i) return Local<Value>(*Undefined(GetIsolate()));
|
11135
|
+
#ifdef V8_REVERSE_JSARGS
|
11136
|
+
return Local<Value>(reinterpret_cast<Value*>(values_ + i));
|
11137
|
+
#else
|
9783
11138
|
return Local<Value>(reinterpret_cast<Value*>(values_ - i));
|
11139
|
+
#endif
|
9784
11140
|
}
|
9785
11141
|
|
9786
11142
|
|
9787
11143
|
template<typename T>
|
9788
11144
|
Local<Object> FunctionCallbackInfo<T>::This() const {
|
11145
|
+
// values_ points to the first argument (not the receiver).
|
11146
|
+
#ifdef V8_REVERSE_JSARGS
|
11147
|
+
return Local<Object>(reinterpret_cast<Object*>(values_ - 1));
|
11148
|
+
#else
|
9789
11149
|
return Local<Object>(reinterpret_cast<Object*>(values_ + 1));
|
11150
|
+
#endif
|
9790
11151
|
}
|
9791
11152
|
|
9792
11153
|
|
@@ -9942,7 +11303,7 @@ AccessorSignature* AccessorSignature::Cast(Data* data) {
|
|
9942
11303
|
}
|
9943
11304
|
|
9944
11305
|
Local<Value> Object::GetInternalField(int index) {
|
9945
|
-
#
|
11306
|
+
#ifndef V8_ENABLE_CHECKS
|
9946
11307
|
typedef internal::Address A;
|
9947
11308
|
typedef internal::Internals I;
|
9948
11309
|
A obj = *reinterpret_cast<A*>(this);
|
@@ -9952,9 +11313,13 @@ Local
|
|
9952
11313
|
if (instance_type == I::kJSObjectType ||
|
9953
11314
|
instance_type == I::kJSApiObjectType ||
|
9954
11315
|
instance_type == I::kJSSpecialApiObjectType) {
|
9955
|
-
int offset = I::
|
9956
|
-
|
9957
|
-
|
11316
|
+
int offset = I::kJSObjectHeaderSize + (I::kEmbedderDataSlotSize * index);
|
11317
|
+
A value = I::ReadRawField<A>(obj, offset);
|
11318
|
+
#ifdef V8_COMPRESS_POINTERS
|
11319
|
+
// We read the full pointer value and then decompress it in order to avoid
|
11320
|
+
// dealing with potential endiannes issues.
|
11321
|
+
value = I::DecompressTaggedAnyField(obj, static_cast<uint32_t>(value));
|
11322
|
+
#endif
|
9958
11323
|
internal::Isolate* isolate =
|
9959
11324
|
internal::IsolateFromNeverReadOnlySpaceObject(obj);
|
9960
11325
|
A* result = HandleScope::CreateHandle(isolate, value);
|
@@ -9966,7 +11331,7 @@ Local
|
|
9966
11331
|
|
9967
11332
|
|
9968
11333
|
void* Object::GetAlignedPointerFromInternalField(int index) {
|
9969
|
-
#
|
11334
|
+
#ifndef V8_ENABLE_CHECKS
|
9970
11335
|
typedef internal::Address A;
|
9971
11336
|
typedef internal::Internals I;
|
9972
11337
|
A obj = *reinterpret_cast<A*>(this);
|
@@ -9976,8 +11341,7 @@ void* Object::GetAlignedPointerFromInternalField(int index) {
|
|
9976
11341
|
if (V8_LIKELY(instance_type == I::kJSObjectType ||
|
9977
11342
|
instance_type == I::kJSApiObjectType ||
|
9978
11343
|
instance_type == I::kJSSpecialApiObjectType)) {
|
9979
|
-
int offset = I::
|
9980
|
-
(I::kEmbedderDataSlotSize * index);
|
11344
|
+
int offset = I::kJSObjectHeaderSize + (I::kEmbedderDataSlotSize * index);
|
9981
11345
|
return I::ReadRawField<void*>(obj, offset);
|
9982
11346
|
}
|
9983
11347
|
#endif
|
@@ -10476,10 +11840,14 @@ ReturnValue
|
|
10476
11840
|
template <typename T>
|
10477
11841
|
bool PropertyCallbackInfo<T>::ShouldThrowOnError() const {
|
10478
11842
|
typedef internal::Internals I;
|
10479
|
-
|
11843
|
+
if (args_[kShouldThrowOnErrorIndex] !=
|
11844
|
+
I::IntToSmi(I::kInferShouldThrowMode)) {
|
11845
|
+
return args_[kShouldThrowOnErrorIndex] != I::IntToSmi(I::kDontThrow);
|
11846
|
+
}
|
11847
|
+
return v8::internal::ShouldThrowOnError(
|
11848
|
+
reinterpret_cast<v8::internal::Isolate*>(GetIsolate()));
|
10480
11849
|
}
|
10481
11850
|
|
10482
|
-
|
10483
11851
|
Local<Primitive> Undefined(Isolate* isolate) {
|
10484
11852
|
typedef internal::Address S;
|
10485
11853
|
typedef internal::Internals I;
|
@@ -10543,44 +11911,53 @@ MaybeLocal
|
|
10543
11911
|
int64_t Isolate::AdjustAmountOfExternalAllocatedMemory(
|
10544
11912
|
int64_t change_in_bytes) {
|
10545
11913
|
typedef internal::Internals I;
|
10546
|
-
constexpr int64_t kMemoryReducerActivationLimit = 32 * 1024 * 1024;
|
10547
11914
|
int64_t* external_memory = reinterpret_cast<int64_t*>(
|
10548
11915
|
reinterpret_cast<uint8_t*>(this) + I::kExternalMemoryOffset);
|
10549
11916
|
int64_t* external_memory_limit = reinterpret_cast<int64_t*>(
|
10550
11917
|
reinterpret_cast<uint8_t*>(this) + I::kExternalMemoryLimitOffset);
|
10551
|
-
int64_t*
|
11918
|
+
int64_t* external_memory_low_since_mc =
|
10552
11919
|
reinterpret_cast<int64_t*>(reinterpret_cast<uint8_t*>(this) +
|
10553
|
-
I::
|
11920
|
+
I::kExternalMemoryLowSinceMarkCompactOffset);
|
10554
11921
|
|
10555
|
-
|
11922
|
+
// Embedders are weird: we see both over- and underflows here. Perform the
|
11923
|
+
// addition with unsigned types to avoid undefined behavior.
|
11924
|
+
const int64_t amount =
|
11925
|
+
static_cast<int64_t>(static_cast<uint64_t>(change_in_bytes) +
|
11926
|
+
static_cast<uint64_t>(*external_memory));
|
10556
11927
|
*external_memory = amount;
|
10557
11928
|
|
10558
|
-
|
10559
|
-
|
10560
|
-
|
10561
|
-
// external memory increased.
|
10562
|
-
if (allocation_diff_since_last_mc > kMemoryReducerActivationLimit) {
|
10563
|
-
CheckMemoryPressure();
|
11929
|
+
if (amount < *external_memory_low_since_mc) {
|
11930
|
+
*external_memory_low_since_mc = amount;
|
11931
|
+
*external_memory_limit = amount + I::kExternalAllocationSoftLimit;
|
10564
11932
|
}
|
10565
11933
|
|
10566
|
-
if (change_in_bytes
|
10567
|
-
|
10568
|
-
|
10569
|
-
*external_memory_limit = lower_limit;
|
10570
|
-
} else if (change_in_bytes > 0 && amount > *external_memory_limit) {
|
11934
|
+
if (change_in_bytes <= 0) return *external_memory;
|
11935
|
+
|
11936
|
+
if (amount > *external_memory_limit) {
|
10571
11937
|
ReportExternalAllocationLimitReached();
|
10572
11938
|
}
|
10573
11939
|
return *external_memory;
|
10574
11940
|
}
|
10575
11941
|
|
10576
11942
|
Local<Value> Context::GetEmbedderData(int index) {
|
10577
|
-
#
|
11943
|
+
#ifndef V8_ENABLE_CHECKS
|
10578
11944
|
typedef internal::Address A;
|
10579
11945
|
typedef internal::Internals I;
|
11946
|
+
A ctx = *reinterpret_cast<const A*>(this);
|
11947
|
+
A embedder_data =
|
11948
|
+
I::ReadTaggedPointerField(ctx, I::kNativeContextEmbedderDataOffset);
|
11949
|
+
int value_offset =
|
11950
|
+
I::kEmbedderDataArrayHeaderSize + (I::kEmbedderDataSlotSize * index);
|
11951
|
+
A value = I::ReadRawField<A>(embedder_data, value_offset);
|
11952
|
+
#ifdef V8_COMPRESS_POINTERS
|
11953
|
+
// We read the full pointer value and then decompress it in order to avoid
|
11954
|
+
// dealing with potential endiannes issues.
|
11955
|
+
value =
|
11956
|
+
I::DecompressTaggedAnyField(embedder_data, static_cast<uint32_t>(value));
|
11957
|
+
#endif
|
10580
11958
|
internal::Isolate* isolate = internal::IsolateFromNeverReadOnlySpaceObject(
|
10581
11959
|
*reinterpret_cast<A*>(this));
|
10582
|
-
A* result =
|
10583
|
-
HandleScope::CreateHandle(isolate, I::ReadEmbedderData<A>(this, index));
|
11960
|
+
A* result = HandleScope::CreateHandle(isolate, value);
|
10584
11961
|
return Local<Value>(reinterpret_cast<Value*>(result));
|
10585
11962
|
#else
|
10586
11963
|
return SlowGetEmbedderData(index);
|
@@ -10589,9 +11966,15 @@ Local
|
|
10589
11966
|
|
10590
11967
|
|
10591
11968
|
void* Context::GetAlignedPointerFromEmbedderData(int index) {
|
10592
|
-
#
|
11969
|
+
#ifndef V8_ENABLE_CHECKS
|
11970
|
+
typedef internal::Address A;
|
10593
11971
|
typedef internal::Internals I;
|
10594
|
-
|
11972
|
+
A ctx = *reinterpret_cast<const A*>(this);
|
11973
|
+
A embedder_data =
|
11974
|
+
I::ReadTaggedPointerField(ctx, I::kNativeContextEmbedderDataOffset);
|
11975
|
+
int value_offset =
|
11976
|
+
I::kEmbedderDataArrayHeaderSize + (I::kEmbedderDataSlotSize * index);
|
11977
|
+
return I::ReadRawField<void*>(embedder_data, value_offset);
|
10595
11978
|
#else
|
10596
11979
|
return SlowGetAlignedPointerFromEmbedderData(index);
|
10597
11980
|
#endif
|
@@ -10632,8 +12015,4 @@ size_t SnapshotCreator::AddData(Local
|
|
10632
12015
|
|
10633
12016
|
} // namespace v8
|
10634
12017
|
|
10635
|
-
|
10636
|
-
#undef TYPE_CHECK
|
10637
|
-
|
10638
|
-
|
10639
12018
|
#endif // INCLUDE_V8_H_
|