libv8 6.7.288.46.1-universal-darwin-18 → 7.3.492.27.1-universal-darwin-18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/libv8/version.rb +1 -1
- data/vendor/v8/include/libplatform/libplatform.h +1 -6
- data/vendor/v8/include/libplatform/v8-tracing.h +7 -5
- data/vendor/v8/include/v8-inspector.h +14 -7
- data/vendor/v8/include/v8-internal.h +373 -0
- data/vendor/v8/include/v8-platform.h +66 -101
- data/vendor/v8/include/v8-profiler.h +157 -31
- data/vendor/v8/include/v8-util.h +27 -13
- data/vendor/v8/include/v8-version.h +4 -4
- data/vendor/v8/include/v8-wasm-trap-handler-posix.h +31 -0
- data/vendor/v8/include/v8-wasm-trap-handler-win.h +28 -0
- data/vendor/v8/include/v8.h +1192 -967
- data/vendor/v8/include/v8config.h +33 -72
- 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
- metadata +6 -4
data/vendor/v8/include/v8-util.h
CHANGED
@@ -25,13 +25,11 @@ enum PersistentContainerCallbackType {
|
|
25
25
|
kNotWeak,
|
26
26
|
// These correspond to v8::WeakCallbackType
|
27
27
|
kWeakWithParameter,
|
28
|
-
kWeakWithInternalFields
|
29
|
-
kWeak = kWeakWithParameter // For backwards compatibility. Deprecate.
|
28
|
+
kWeakWithInternalFields
|
30
29
|
};
|
31
30
|
|
32
|
-
|
33
31
|
/**
|
34
|
-
* A default trait
|
32
|
+
* A default trait implementation for PersistentValueMap which uses std::map
|
35
33
|
* as a backing map.
|
36
34
|
*
|
37
35
|
* Users will have to implement their own weak callbacks & dispose traits.
|
@@ -94,11 +92,11 @@ class DefaultPersistentValueMapTraits : public StdMapTraits<K, V> {
|
|
94
92
|
|
95
93
|
static WeakCallbackDataType* WeakCallbackParameter(
|
96
94
|
MapType* map, const K& key, Local<V> value) {
|
97
|
-
return
|
95
|
+
return nullptr;
|
98
96
|
}
|
99
97
|
static MapType* MapFromWeakCallbackInfo(
|
100
98
|
const WeakCallbackInfo<WeakCallbackDataType>& data) {
|
101
|
-
return
|
99
|
+
return nullptr;
|
102
100
|
}
|
103
101
|
static K KeyFromWeakCallbackInfo(
|
104
102
|
const WeakCallbackInfo<WeakCallbackDataType>& data) {
|
@@ -203,7 +201,7 @@ class PersistentValueMapBase {
|
|
203
201
|
void RegisterExternallyReferencedObject(K& key) {
|
204
202
|
assert(Contains(key));
|
205
203
|
V8::RegisterExternallyReferencedObject(
|
206
|
-
reinterpret_cast<internal::
|
204
|
+
reinterpret_cast<internal::Address*>(FromVal(Traits::Get(&impl_, key))),
|
207
205
|
reinterpret_cast<internal::Isolate*>(GetIsolate()));
|
208
206
|
}
|
209
207
|
|
@@ -289,7 +287,10 @@ class PersistentValueMapBase {
|
|
289
287
|
}
|
290
288
|
|
291
289
|
protected:
|
292
|
-
explicit PersistentValueMapBase(Isolate* isolate)
|
290
|
+
explicit PersistentValueMapBase(Isolate* isolate)
|
291
|
+
: isolate_(isolate), label_(nullptr) {}
|
292
|
+
PersistentValueMapBase(Isolate* isolate, const char* label)
|
293
|
+
: isolate_(isolate), label_(label) {}
|
293
294
|
|
294
295
|
~PersistentValueMapBase() { Clear(); }
|
295
296
|
|
@@ -302,7 +303,7 @@ class PersistentValueMapBase {
|
|
302
303
|
|
303
304
|
static PersistentContainerValue ClearAndLeak(Global<V>* persistent) {
|
304
305
|
V* v = persistent->val_;
|
305
|
-
persistent->val_ =
|
306
|
+
persistent->val_ = nullptr;
|
306
307
|
return reinterpret_cast<PersistentContainerValue>(v);
|
307
308
|
}
|
308
309
|
|
@@ -331,6 +332,10 @@ class PersistentValueMapBase {
|
|
331
332
|
p.Reset();
|
332
333
|
}
|
333
334
|
|
335
|
+
void AnnotateStrongRetainer(Global<V>* persistent) {
|
336
|
+
persistent->AnnotateStrongRetainer(label_);
|
337
|
+
}
|
338
|
+
|
334
339
|
private:
|
335
340
|
PersistentValueMapBase(PersistentValueMapBase&);
|
336
341
|
void operator=(PersistentValueMapBase&);
|
@@ -340,13 +345,14 @@ class PersistentValueMapBase {
|
|
340
345
|
bool hasValue = value != kPersistentContainerNotFound;
|
341
346
|
if (hasValue) {
|
342
347
|
returnValue->SetInternal(
|
343
|
-
*reinterpret_cast<internal::
|
348
|
+
*reinterpret_cast<internal::Address*>(FromVal(value)));
|
344
349
|
}
|
345
350
|
return hasValue;
|
346
351
|
}
|
347
352
|
|
348
353
|
Isolate* isolate_;
|
349
354
|
typename Traits::Impl impl_;
|
355
|
+
const char* label_;
|
350
356
|
};
|
351
357
|
|
352
358
|
|
@@ -355,6 +361,8 @@ class PersistentValueMap : public PersistentValueMapBase<K, V, Traits> {
|
|
355
361
|
public:
|
356
362
|
explicit PersistentValueMap(Isolate* isolate)
|
357
363
|
: PersistentValueMapBase<K, V, Traits>(isolate) {}
|
364
|
+
PersistentValueMap(Isolate* isolate, const char* label)
|
365
|
+
: PersistentValueMapBase<K, V, Traits>(isolate, label) {}
|
358
366
|
|
359
367
|
typedef
|
360
368
|
typename PersistentValueMapBase<K, V, Traits>::PersistentValueReference
|
@@ -382,7 +390,9 @@ class PersistentValueMap : public PersistentValueMapBase<K, V, Traits> {
|
|
382
390
|
* by the Traits class.
|
383
391
|
*/
|
384
392
|
Global<V> SetUnique(const K& key, Global<V>* persistent) {
|
385
|
-
if (Traits::kCallbackType
|
393
|
+
if (Traits::kCallbackType == kNotWeak) {
|
394
|
+
this->AnnotateStrongRetainer(persistent);
|
395
|
+
} else {
|
386
396
|
WeakCallbackType callback_type =
|
387
397
|
Traits::kCallbackType == kWeakWithInternalFields
|
388
398
|
? WeakCallbackType::kInternalFields
|
@@ -427,6 +437,8 @@ class GlobalValueMap : public PersistentValueMapBase<K, V, Traits> {
|
|
427
437
|
public:
|
428
438
|
explicit GlobalValueMap(Isolate* isolate)
|
429
439
|
: PersistentValueMapBase<K, V, Traits>(isolate) {}
|
440
|
+
GlobalValueMap(Isolate* isolate, const char* label)
|
441
|
+
: PersistentValueMapBase<K, V, Traits>(isolate, label) {}
|
430
442
|
|
431
443
|
typedef
|
432
444
|
typename PersistentValueMapBase<K, V, Traits>::PersistentValueReference
|
@@ -454,7 +466,9 @@ class GlobalValueMap : public PersistentValueMapBase<K, V, Traits> {
|
|
454
466
|
* by the Traits class.
|
455
467
|
*/
|
456
468
|
Global<V> SetUnique(const K& key, Global<V>* persistent) {
|
457
|
-
if (Traits::kCallbackType
|
469
|
+
if (Traits::kCallbackType == kNotWeak) {
|
470
|
+
this->AnnotateStrongRetainer(persistent);
|
471
|
+
} else {
|
458
472
|
WeakCallbackType callback_type =
|
459
473
|
Traits::kCallbackType == kWeakWithInternalFields
|
460
474
|
? WeakCallbackType::kInternalFields
|
@@ -633,7 +647,7 @@ class PersistentValueVector {
|
|
633
647
|
private:
|
634
648
|
static PersistentContainerValue ClearAndLeak(Global<V>* persistent) {
|
635
649
|
V* v = persistent->val_;
|
636
|
-
persistent->val_ =
|
650
|
+
persistent->val_ = nullptr;
|
637
651
|
return reinterpret_cast<PersistentContainerValue>(v);
|
638
652
|
}
|
639
653
|
|
@@ -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 7
|
12
|
+
#define V8_MINOR_VERSION 3
|
13
|
+
#define V8_BUILD_NUMBER 492
|
14
|
+
#define V8_PATCH_LEVEL 27
|
15
15
|
|
16
16
|
// Use 1 for candidates and 0 otherwise.
|
17
17
|
// (Boolean macro values are not supported by all preprocessors.)
|
@@ -0,0 +1,31 @@
|
|
1
|
+
// Copyright 2018 the V8 project authors. All rights reserved.
|
2
|
+
// Use of this source code is governed by a BSD-style license that can be
|
3
|
+
// found in the LICENSE file.
|
4
|
+
|
5
|
+
#ifndef V8_WASM_TRAP_HANDLER_POSIX_H_
|
6
|
+
#define V8_WASM_TRAP_HANDLER_POSIX_H_
|
7
|
+
|
8
|
+
#include <signal.h>
|
9
|
+
|
10
|
+
#include "v8config.h" // NOLINT(build/include)
|
11
|
+
|
12
|
+
namespace v8 {
|
13
|
+
/**
|
14
|
+
* This function determines whether a memory access violation has been an
|
15
|
+
* out-of-bounds memory access in WebAssembly. If so, it will modify the context
|
16
|
+
* parameter and add a return address where the execution can continue after the
|
17
|
+
* signal handling, and return true. Otherwise, false will be returned.
|
18
|
+
*
|
19
|
+
* The parameters to this function correspond to those passed to a Posix signal
|
20
|
+
* handler. Use this function only on Linux and Mac.
|
21
|
+
*
|
22
|
+
* \param sig_code The signal code, e.g. SIGSEGV.
|
23
|
+
* \param info A pointer to the siginfo_t struct provided to the signal handler.
|
24
|
+
* \param context A pointer to a ucontext_t struct provided to the signal
|
25
|
+
* handler.
|
26
|
+
*/
|
27
|
+
V8_EXPORT bool TryHandleWebAssemblyTrapPosix(int sig_code, siginfo_t* info,
|
28
|
+
void* context);
|
29
|
+
|
30
|
+
} // namespace v8
|
31
|
+
#endif // V8_WASM_TRAP_HANDLER_POSIX_H_
|
@@ -0,0 +1,28 @@
|
|
1
|
+
// Copyright 2018 the V8 project authors. All rights reserved.
|
2
|
+
// Use of this source code is governed by a BSD-style license that can be
|
3
|
+
// found in the LICENSE file.
|
4
|
+
|
5
|
+
#ifndef V8_WASM_TRAP_HANDLER_WIN_H_
|
6
|
+
#define V8_WASM_TRAP_HANDLER_WIN_H_
|
7
|
+
|
8
|
+
#include <windows.h>
|
9
|
+
|
10
|
+
#include "v8config.h" // NOLINT(build/include)
|
11
|
+
|
12
|
+
namespace v8 {
|
13
|
+
/**
|
14
|
+
* This function determines whether a memory access violation has been an
|
15
|
+
* out-of-bounds memory access in WebAssembly. If so, it will modify the
|
16
|
+
* exception parameter and add a return address where the execution can continue
|
17
|
+
* after the exception handling, and return true. Otherwise the return value
|
18
|
+
* will be false.
|
19
|
+
*
|
20
|
+
* The parameter to this function corresponds to the one passed to a Windows
|
21
|
+
* vectored exception handler. Use this function only on Windows.
|
22
|
+
*
|
23
|
+
* \param exception An EXCEPTION_POINTERS* as provided to the exception handler.
|
24
|
+
*/
|
25
|
+
V8_EXPORT bool TryHandleWebAssemblyTrapWindows(EXCEPTION_POINTERS* exception);
|
26
|
+
|
27
|
+
} // namespace v8
|
28
|
+
#endif // V8_WASM_TRAP_HANDLER_WIN_H_
|
data/vendor/v8/include/v8.h
CHANGED
@@ -22,42 +22,13 @@
|
|
22
22
|
#include <utility>
|
23
23
|
#include <vector>
|
24
24
|
|
25
|
-
#include "v8-
|
26
|
-
#include "
|
25
|
+
#include "v8-internal.h" // NOLINT(build/include)
|
26
|
+
#include "v8-version.h" // NOLINT(build/include)
|
27
|
+
#include "v8config.h" // NOLINT(build/include)
|
27
28
|
|
28
29
|
// We reserve the V8_* prefix for macros defined in V8 public API and
|
29
30
|
// assume there are no name conflicts with the embedder's code.
|
30
31
|
|
31
|
-
#ifdef V8_OS_WIN
|
32
|
-
|
33
|
-
// Setup for Windows DLL export/import. When building the V8 DLL the
|
34
|
-
// BUILDING_V8_SHARED needs to be defined. When building a program which uses
|
35
|
-
// the V8 DLL USING_V8_SHARED needs to be defined. When either building the V8
|
36
|
-
// static library or building a program which uses the V8 static library neither
|
37
|
-
// BUILDING_V8_SHARED nor USING_V8_SHARED should be defined.
|
38
|
-
#ifdef BUILDING_V8_SHARED
|
39
|
-
# define V8_EXPORT __declspec(dllexport)
|
40
|
-
#elif USING_V8_SHARED
|
41
|
-
# define V8_EXPORT __declspec(dllimport)
|
42
|
-
#else
|
43
|
-
# define V8_EXPORT
|
44
|
-
#endif // BUILDING_V8_SHARED
|
45
|
-
|
46
|
-
#else // V8_OS_WIN
|
47
|
-
|
48
|
-
// Setup for Linux shared library export.
|
49
|
-
#if V8_HAS_ATTRIBUTE_VISIBILITY
|
50
|
-
# ifdef BUILDING_V8_SHARED
|
51
|
-
# define V8_EXPORT __attribute__ ((visibility("default")))
|
52
|
-
# else
|
53
|
-
# define V8_EXPORT
|
54
|
-
# endif
|
55
|
-
#else
|
56
|
-
# define V8_EXPORT
|
57
|
-
#endif
|
58
|
-
|
59
|
-
#endif // V8_OS_WIN
|
60
|
-
|
61
32
|
/**
|
62
33
|
* The v8 JavaScript engine.
|
63
34
|
*/
|
@@ -71,7 +42,6 @@ class BigIntObject;
|
|
71
42
|
class Boolean;
|
72
43
|
class BooleanObject;
|
73
44
|
class Context;
|
74
|
-
class CpuProfiler;
|
75
45
|
class Data;
|
76
46
|
class Date;
|
77
47
|
class External;
|
@@ -111,7 +81,7 @@ class Private;
|
|
111
81
|
class Uint32;
|
112
82
|
class Utils;
|
113
83
|
class Value;
|
114
|
-
class
|
84
|
+
class WasmModuleObject;
|
115
85
|
template <class T> class Local;
|
116
86
|
template <class T>
|
117
87
|
class MaybeLocal;
|
@@ -146,16 +116,20 @@ class DeferredHandles;
|
|
146
116
|
class Heap;
|
147
117
|
class HeapObject;
|
148
118
|
class Isolate;
|
149
|
-
class
|
119
|
+
class LocalEmbedderHeapTracer;
|
120
|
+
class NeverReadOnlySpaceObject;
|
150
121
|
struct ScriptStreamingData;
|
151
122
|
template<typename T> class CustomArguments;
|
152
123
|
class PropertyCallbackArguments;
|
153
124
|
class FunctionCallbackArguments;
|
154
125
|
class GlobalHandles;
|
126
|
+
class ScopedExternalStringLock;
|
155
127
|
|
156
128
|
namespace wasm {
|
129
|
+
class NativeModule;
|
157
130
|
class StreamingDecoder;
|
158
131
|
} // namespace wasm
|
132
|
+
|
159
133
|
} // namespace internal
|
160
134
|
|
161
135
|
namespace debug {
|
@@ -203,7 +177,7 @@ class ConsoleCallArguments;
|
|
203
177
|
template <class T>
|
204
178
|
class Local {
|
205
179
|
public:
|
206
|
-
V8_INLINE Local() : val_(
|
180
|
+
V8_INLINE Local() : val_(nullptr) {}
|
207
181
|
template <class S>
|
208
182
|
V8_INLINE Local(Local<S> that)
|
209
183
|
: val_(reinterpret_cast<T*>(*that)) {
|
@@ -218,12 +192,12 @@ class Local {
|
|
218
192
|
/**
|
219
193
|
* Returns true if the handle is empty.
|
220
194
|
*/
|
221
|
-
V8_INLINE bool IsEmpty() const { return val_ ==
|
195
|
+
V8_INLINE bool IsEmpty() const { return val_ == nullptr; }
|
222
196
|
|
223
197
|
/**
|
224
198
|
* Sets the handle to be empty. IsEmpty() will then return true.
|
225
199
|
*/
|
226
|
-
V8_INLINE void Clear() { val_ =
|
200
|
+
V8_INLINE void Clear() { val_ = nullptr; }
|
227
201
|
|
228
202
|
V8_INLINE T* operator->() const { return val_; }
|
229
203
|
|
@@ -237,19 +211,19 @@ class Local {
|
|
237
211
|
*/
|
238
212
|
template <class S>
|
239
213
|
V8_INLINE bool operator==(const Local<S>& that) const {
|
240
|
-
internal::
|
241
|
-
internal::
|
242
|
-
if (a ==
|
243
|
-
if (b ==
|
214
|
+
internal::Address* a = reinterpret_cast<internal::Address*>(this->val_);
|
215
|
+
internal::Address* b = reinterpret_cast<internal::Address*>(that.val_);
|
216
|
+
if (a == nullptr) return b == nullptr;
|
217
|
+
if (b == nullptr) return false;
|
244
218
|
return *a == *b;
|
245
219
|
}
|
246
220
|
|
247
221
|
template <class S> V8_INLINE bool operator==(
|
248
222
|
const PersistentBase<S>& that) const {
|
249
|
-
internal::
|
250
|
-
internal::
|
251
|
-
if (a ==
|
252
|
-
if (b ==
|
223
|
+
internal::Address* a = reinterpret_cast<internal::Address*>(this->val_);
|
224
|
+
internal::Address* b = reinterpret_cast<internal::Address*>(that.val_);
|
225
|
+
if (a == nullptr) return b == nullptr;
|
226
|
+
if (b == nullptr) return false;
|
253
227
|
return *a == *b;
|
254
228
|
}
|
255
229
|
|
@@ -493,7 +467,7 @@ template <class T> class PersistentBase {
|
|
493
467
|
template <class S>
|
494
468
|
V8_INLINE void Reset(Isolate* isolate, const PersistentBase<S>& other);
|
495
469
|
|
496
|
-
V8_INLINE bool IsEmpty() const { return val_ ==
|
470
|
+
V8_INLINE bool IsEmpty() const { return val_ == nullptr; }
|
497
471
|
V8_INLINE void Empty() { val_ = 0; }
|
498
472
|
|
499
473
|
V8_INLINE Local<T> Get(Isolate* isolate) const {
|
@@ -502,19 +476,19 @@ template <class T> class PersistentBase {
|
|
502
476
|
|
503
477
|
template <class S>
|
504
478
|
V8_INLINE bool operator==(const PersistentBase<S>& that) const {
|
505
|
-
internal::
|
506
|
-
internal::
|
507
|
-
if (a ==
|
508
|
-
if (b ==
|
479
|
+
internal::Address* a = reinterpret_cast<internal::Address*>(this->val_);
|
480
|
+
internal::Address* b = reinterpret_cast<internal::Address*>(that.val_);
|
481
|
+
if (a == nullptr) return b == nullptr;
|
482
|
+
if (b == nullptr) return false;
|
509
483
|
return *a == *b;
|
510
484
|
}
|
511
485
|
|
512
486
|
template <class S>
|
513
487
|
V8_INLINE bool operator==(const Local<S>& that) const {
|
514
|
-
internal::
|
515
|
-
internal::
|
516
|
-
if (a ==
|
517
|
-
if (b ==
|
488
|
+
internal::Address* a = reinterpret_cast<internal::Address*>(this->val_);
|
489
|
+
internal::Address* b = reinterpret_cast<internal::Address*>(that.val_);
|
490
|
+
if (a == nullptr) return b == nullptr;
|
491
|
+
if (b == nullptr) return false;
|
518
492
|
return *a == *b;
|
519
493
|
}
|
520
494
|
|
@@ -594,7 +568,9 @@ template <class T> class PersistentBase {
|
|
594
568
|
V8_INLINE bool IsIndependent() const);
|
595
569
|
|
596
570
|
/** Checks if the handle holds the only reference to an object. */
|
597
|
-
|
571
|
+
V8_DEPRECATE_SOON(
|
572
|
+
"Garbage collection internal state should not be relied on.",
|
573
|
+
V8_INLINE bool IsNearDeath() const);
|
598
574
|
|
599
575
|
/** Returns true if the handle's reference is weak. */
|
600
576
|
V8_INLINE bool IsWeak() const;
|
@@ -687,7 +663,7 @@ template <class T, class M> class Persistent : public PersistentBase<T> {
|
|
687
663
|
/**
|
688
664
|
* A Persistent with no storage cell.
|
689
665
|
*/
|
690
|
-
V8_INLINE Persistent() : PersistentBase<T>(
|
666
|
+
V8_INLINE Persistent() : PersistentBase<T>(nullptr) {}
|
691
667
|
/**
|
692
668
|
* Construct a Persistent from a Local.
|
693
669
|
* When the Local is non-empty, a new storage cell is created
|
@@ -714,14 +690,14 @@ template <class T, class M> class Persistent : public PersistentBase<T> {
|
|
714
690
|
* traits class is called, allowing the setting of flags based on the
|
715
691
|
* copied Persistent.
|
716
692
|
*/
|
717
|
-
V8_INLINE Persistent(const Persistent& that) : PersistentBase<T>(
|
693
|
+
V8_INLINE Persistent(const Persistent& that) : PersistentBase<T>(nullptr) {
|
718
694
|
Copy(that);
|
719
695
|
}
|
720
696
|
template <class S, class M2>
|
721
697
|
V8_INLINE Persistent(const Persistent<S, M2>& that) : PersistentBase<T>(0) {
|
722
698
|
Copy(that);
|
723
699
|
}
|
724
|
-
V8_INLINE Persistent& operator=(const Persistent& that) {
|
700
|
+
V8_INLINE Persistent& operator=(const Persistent& that) {
|
725
701
|
Copy(that);
|
726
702
|
return *this;
|
727
703
|
}
|
@@ -805,7 +781,7 @@ class Global : public PersistentBase<T> {
|
|
805
781
|
/**
|
806
782
|
* Move constructor.
|
807
783
|
*/
|
808
|
-
V8_INLINE Global(Global&& other) : PersistentBase<T>(other.val_) {
|
784
|
+
V8_INLINE Global(Global&& other) : PersistentBase<T>(other.val_) {
|
809
785
|
other.val_ = nullptr;
|
810
786
|
}
|
811
787
|
V8_INLINE ~Global() { this->Reset(); }
|
@@ -880,12 +856,12 @@ class V8_EXPORT HandleScope {
|
|
880
856
|
void operator=(const HandleScope&) = delete;
|
881
857
|
|
882
858
|
protected:
|
883
|
-
V8_INLINE HandleScope()
|
859
|
+
V8_INLINE HandleScope() = default;
|
884
860
|
|
885
861
|
void Initialize(Isolate* isolate);
|
886
862
|
|
887
|
-
static internal::
|
888
|
-
internal::
|
863
|
+
static internal::Address* CreateHandle(internal::Isolate* isolate,
|
864
|
+
internal::Address value);
|
889
865
|
|
890
866
|
private:
|
891
867
|
// Declaring operator new and delete as deleted is not spec compliant.
|
@@ -895,19 +871,15 @@ class V8_EXPORT HandleScope {
|
|
895
871
|
void operator delete(void*, size_t);
|
896
872
|
void operator delete[](void*, size_t);
|
897
873
|
|
898
|
-
// Uses heap_object to obtain the current Isolate.
|
899
|
-
static internal::Object** CreateHandle(internal::HeapObject* heap_object,
|
900
|
-
internal::Object* value);
|
901
|
-
|
902
874
|
internal::Isolate* isolate_;
|
903
|
-
internal::
|
904
|
-
internal::
|
875
|
+
internal::Address* prev_next_;
|
876
|
+
internal::Address* prev_limit_;
|
905
877
|
|
906
878
|
// Local::New uses CreateHandle with an Isolate* parameter.
|
907
879
|
template<class F> friend class Local;
|
908
880
|
|
909
881
|
// Object::GetInternalField and Context::GetEmbedderData use CreateHandle with
|
910
|
-
// a HeapObject
|
882
|
+
// a HeapObject in their shortcuts.
|
911
883
|
friend class Object;
|
912
884
|
friend class Context;
|
913
885
|
};
|
@@ -920,7 +892,7 @@ class V8_EXPORT HandleScope {
|
|
920
892
|
class V8_EXPORT EscapableHandleScope : public HandleScope {
|
921
893
|
public:
|
922
894
|
explicit EscapableHandleScope(Isolate* isolate);
|
923
|
-
V8_INLINE ~EscapableHandleScope()
|
895
|
+
V8_INLINE ~EscapableHandleScope() = default;
|
924
896
|
|
925
897
|
/**
|
926
898
|
* Pushes the value into the previous scope and returns a handle to it.
|
@@ -928,11 +900,16 @@ class V8_EXPORT EscapableHandleScope : public HandleScope {
|
|
928
900
|
*/
|
929
901
|
template <class T>
|
930
902
|
V8_INLINE Local<T> Escape(Local<T> value) {
|
931
|
-
internal::
|
932
|
-
Escape(reinterpret_cast<internal::
|
903
|
+
internal::Address* slot =
|
904
|
+
Escape(reinterpret_cast<internal::Address*>(*value));
|
933
905
|
return Local<T>(reinterpret_cast<T*>(slot));
|
934
906
|
}
|
935
907
|
|
908
|
+
template <class T>
|
909
|
+
V8_INLINE MaybeLocal<T> EscapeMaybe(MaybeLocal<T> value) {
|
910
|
+
return Escape(value.FromMaybe(Local<T>()));
|
911
|
+
}
|
912
|
+
|
936
913
|
EscapableHandleScope(const EscapableHandleScope&) = delete;
|
937
914
|
void operator=(const EscapableHandleScope&) = delete;
|
938
915
|
|
@@ -944,8 +921,8 @@ class V8_EXPORT EscapableHandleScope : public HandleScope {
|
|
944
921
|
void operator delete(void*, size_t);
|
945
922
|
void operator delete[](void*, size_t);
|
946
923
|
|
947
|
-
internal::
|
948
|
-
internal::
|
924
|
+
internal::Address* Escape(internal::Address* escape_value);
|
925
|
+
internal::Address* escape_slot_;
|
949
926
|
};
|
950
927
|
|
951
928
|
/**
|
@@ -970,7 +947,7 @@ class V8_EXPORT SealHandleScope {
|
|
970
947
|
void operator delete[](void*, size_t);
|
971
948
|
|
972
949
|
internal::Isolate* const isolate_;
|
973
|
-
internal::
|
950
|
+
internal::Address* prev_limit_;
|
974
951
|
int prev_sealed_level_;
|
975
952
|
};
|
976
953
|
|
@@ -1019,8 +996,8 @@ class V8_EXPORT PrimitiveArray {
|
|
1019
996
|
public:
|
1020
997
|
static Local<PrimitiveArray> New(Isolate* isolate, int length);
|
1021
998
|
int Length() const;
|
1022
|
-
void Set(int index, Local<Primitive> item);
|
1023
|
-
Local<Primitive> Get(int index);
|
999
|
+
void Set(Isolate* isolate, int index, Local<Primitive> item);
|
1000
|
+
Local<Primitive> Get(Isolate* isolate, int index);
|
1024
1001
|
};
|
1025
1002
|
|
1026
1003
|
/**
|
@@ -1123,6 +1100,13 @@ class V8_EXPORT UnboundScript {
|
|
1123
1100
|
static const int kNoScriptId = 0;
|
1124
1101
|
};
|
1125
1102
|
|
1103
|
+
/**
|
1104
|
+
* A compiled JavaScript module, not yet tied to a Context.
|
1105
|
+
*/
|
1106
|
+
class V8_EXPORT UnboundModuleScript {
|
1107
|
+
// Only used as a container for code caching.
|
1108
|
+
};
|
1109
|
+
|
1126
1110
|
/**
|
1127
1111
|
* A location in JavaScript source.
|
1128
1112
|
*/
|
@@ -1222,6 +1206,14 @@ class V8_EXPORT Module {
|
|
1222
1206
|
* The module's status must be at least kInstantiated.
|
1223
1207
|
*/
|
1224
1208
|
Local<Value> GetModuleNamespace();
|
1209
|
+
|
1210
|
+
/**
|
1211
|
+
* Returns the corresponding context-unbound module script.
|
1212
|
+
*
|
1213
|
+
* The module must be unevaluated, i.e. its status must not be kEvaluating,
|
1214
|
+
* kEvaluated or kErrored.
|
1215
|
+
*/
|
1216
|
+
Local<UnboundModuleScript> GetUnboundModuleScript();
|
1225
1217
|
};
|
1226
1218
|
|
1227
1219
|
/**
|
@@ -1233,23 +1225,15 @@ class V8_EXPORT Script {
|
|
1233
1225
|
/**
|
1234
1226
|
* A shorthand for ScriptCompiler::Compile().
|
1235
1227
|
*/
|
1236
|
-
static V8_DEPRECATED("Use maybe version",
|
1237
|
-
Local<Script> Compile(Local<String> source,
|
1238
|
-
ScriptOrigin* origin = nullptr));
|
1239
1228
|
static V8_WARN_UNUSED_RESULT MaybeLocal<Script> Compile(
|
1240
1229
|
Local<Context> context, Local<String> source,
|
1241
1230
|
ScriptOrigin* origin = nullptr);
|
1242
1231
|
|
1243
|
-
static Local<Script> V8_DEPRECATED("Use maybe version",
|
1244
|
-
Compile(Local<String> source,
|
1245
|
-
Local<String> file_name));
|
1246
|
-
|
1247
1232
|
/**
|
1248
1233
|
* Runs the script returning the resulting value. It will be run in the
|
1249
1234
|
* context in which it was created (ScriptCompiler::CompileBound or
|
1250
1235
|
* UnboundScript::BindToCurrentContext()).
|
1251
1236
|
*/
|
1252
|
-
V8_DEPRECATED("Use maybe version", Local<Value> Run());
|
1253
1237
|
V8_WARN_UNUSED_RESULT MaybeLocal<Value> Run(Local<Context> context);
|
1254
1238
|
|
1255
1239
|
/**
|
@@ -1278,7 +1262,7 @@ class V8_EXPORT ScriptCompiler {
|
|
1278
1262
|
};
|
1279
1263
|
|
1280
1264
|
CachedData()
|
1281
|
-
: data(
|
1265
|
+
: data(nullptr),
|
1282
1266
|
length(0),
|
1283
1267
|
rejected(false),
|
1284
1268
|
buffer_policy(BufferNotOwned) {}
|
@@ -1309,9 +1293,9 @@ class V8_EXPORT ScriptCompiler {
|
|
1309
1293
|
public:
|
1310
1294
|
// Source takes ownership of CachedData.
|
1311
1295
|
V8_INLINE Source(Local<String> source_string, const ScriptOrigin& origin,
|
1312
|
-
|
1296
|
+
CachedData* cached_data = nullptr);
|
1313
1297
|
V8_INLINE Source(Local<String> source_string,
|
1314
|
-
CachedData* cached_data =
|
1298
|
+
CachedData* cached_data = nullptr);
|
1315
1299
|
V8_INLINE ~Source();
|
1316
1300
|
|
1317
1301
|
// Ownership of the CachedData or its buffers is *not* transferred to the
|
@@ -1350,7 +1334,7 @@ class V8_EXPORT ScriptCompiler {
|
|
1350
1334
|
*/
|
1351
1335
|
class V8_EXPORT ExternalSourceStream {
|
1352
1336
|
public:
|
1353
|
-
virtual ~ExternalSourceStream()
|
1337
|
+
virtual ~ExternalSourceStream() = default;
|
1354
1338
|
|
1355
1339
|
/**
|
1356
1340
|
* V8 calls this to request the next chunk of data from the embedder. This
|
@@ -1364,6 +1348,10 @@ class V8_EXPORT ScriptCompiler {
|
|
1364
1348
|
* more than two data chunks. The embedder can avoid this problem by always
|
1365
1349
|
* returning at least 2 bytes of data.
|
1366
1350
|
*
|
1351
|
+
* When streaming UTF-16 data, V8 does not handle characters split between
|
1352
|
+
* two data chunks. The embedder has to make sure that chunks have an even
|
1353
|
+
* length.
|
1354
|
+
*
|
1367
1355
|
* If the embedder wants to cancel the streaming, they should make the next
|
1368
1356
|
* GetMoreData call return 0. V8 will interpret it as end of data (and most
|
1369
1357
|
* probably, parsing will fail). The streaming task will return as soon as
|
@@ -1389,12 +1377,11 @@ class V8_EXPORT ScriptCompiler {
|
|
1389
1377
|
virtual void ResetToBookmark();
|
1390
1378
|
};
|
1391
1379
|
|
1392
|
-
|
1393
1380
|
/**
|
1394
1381
|
* Source code which can be streamed into V8 in pieces. It will be parsed
|
1395
|
-
* while streaming
|
1396
|
-
*
|
1397
|
-
*
|
1382
|
+
* while streaming and compiled after parsing has completed. StreamedSource
|
1383
|
+
* must be kept alive while the streaming task is run (see ScriptStreamingTask
|
1384
|
+
* below).
|
1398
1385
|
*/
|
1399
1386
|
class V8_EXPORT StreamedSource {
|
1400
1387
|
public:
|
@@ -1403,37 +1390,35 @@ class V8_EXPORT ScriptCompiler {
|
|
1403
1390
|
StreamedSource(ExternalSourceStream* source_stream, Encoding encoding);
|
1404
1391
|
~StreamedSource();
|
1405
1392
|
|
1406
|
-
|
1407
|
-
// caller. The CachedData object is alive as long as the StreamedSource
|
1408
|
-
// object is alive.
|
1409
|
-
const CachedData* GetCachedData() const;
|
1410
|
-
|
1411
|
-
internal::ScriptStreamingData* impl() const { return impl_; }
|
1393
|
+
internal::ScriptStreamingData* impl() const { return impl_.get(); }
|
1412
1394
|
|
1413
1395
|
// Prevent copying.
|
1414
1396
|
StreamedSource(const StreamedSource&) = delete;
|
1415
1397
|
StreamedSource& operator=(const StreamedSource&) = delete;
|
1416
1398
|
|
1417
1399
|
private:
|
1418
|
-
internal::ScriptStreamingData
|
1400
|
+
std::unique_ptr<internal::ScriptStreamingData> impl_;
|
1419
1401
|
};
|
1420
1402
|
|
1421
1403
|
/**
|
1422
1404
|
* A streaming task which the embedder must run on a background thread to
|
1423
1405
|
* stream scripts into V8. Returned by ScriptCompiler::StartStreamingScript.
|
1424
1406
|
*/
|
1425
|
-
class ScriptStreamingTask {
|
1407
|
+
class V8_EXPORT ScriptStreamingTask final {
|
1426
1408
|
public:
|
1427
|
-
|
1428
|
-
|
1409
|
+
void Run();
|
1410
|
+
|
1411
|
+
private:
|
1412
|
+
friend class ScriptCompiler;
|
1413
|
+
|
1414
|
+
explicit ScriptStreamingTask(internal::ScriptStreamingData* data)
|
1415
|
+
: data_(data) {}
|
1416
|
+
|
1417
|
+
internal::ScriptStreamingData* data_;
|
1429
1418
|
};
|
1430
1419
|
|
1431
1420
|
enum CompileOptions {
|
1432
1421
|
kNoCompileOptions = 0,
|
1433
|
-
kProduceParserCache,
|
1434
|
-
kConsumeParserCache,
|
1435
|
-
kProduceCodeCache,
|
1436
|
-
kProduceFullCodeCache,
|
1437
1422
|
kConsumeCodeCache,
|
1438
1423
|
kEagerCompile
|
1439
1424
|
};
|
@@ -1547,7 +1532,9 @@ class V8_EXPORT ScriptCompiler {
|
|
1547
1532
|
* ECMAScript specification.
|
1548
1533
|
*/
|
1549
1534
|
static V8_WARN_UNUSED_RESULT MaybeLocal<Module> CompileModule(
|
1550
|
-
Isolate* isolate, Source* source
|
1535
|
+
Isolate* isolate, Source* source,
|
1536
|
+
CompileOptions options = kNoCompileOptions,
|
1537
|
+
NoCacheReason no_cache_reason = kNoCacheNoReason);
|
1551
1538
|
|
1552
1539
|
/**
|
1553
1540
|
* Compile a function for a given context. This is equivalent to running
|
@@ -1559,13 +1546,6 @@ class V8_EXPORT ScriptCompiler {
|
|
1559
1546
|
* It is possible to specify multiple context extensions (obj in the above
|
1560
1547
|
* example).
|
1561
1548
|
*/
|
1562
|
-
static V8_DEPRECATED("Use maybe version",
|
1563
|
-
Local<Function> CompileFunctionInContext(
|
1564
|
-
Isolate* isolate, Source* source,
|
1565
|
-
Local<Context> context, size_t arguments_count,
|
1566
|
-
Local<String> arguments[],
|
1567
|
-
size_t context_extension_count,
|
1568
|
-
Local<Object> context_extensions[]));
|
1569
1549
|
static V8_WARN_UNUSED_RESULT MaybeLocal<Function> CompileFunctionInContext(
|
1570
1550
|
Local<Context> context, Source* source, size_t arguments_count,
|
1571
1551
|
Local<String> arguments[], size_t context_extension_count,
|
@@ -1578,8 +1558,15 @@ class V8_EXPORT ScriptCompiler {
|
|
1578
1558
|
* This will return nullptr if the script cannot be serialized. The
|
1579
1559
|
* CachedData returned by this function should be owned by the caller.
|
1580
1560
|
*/
|
1581
|
-
static CachedData* CreateCodeCache(Local<UnboundScript> unbound_script
|
1582
|
-
|
1561
|
+
static CachedData* CreateCodeCache(Local<UnboundScript> unbound_script);
|
1562
|
+
|
1563
|
+
/**
|
1564
|
+
* Creates and returns code cache for the specified unbound_module_script.
|
1565
|
+
* This will return nullptr if the script cannot be serialized. The
|
1566
|
+
* CachedData returned by this function should be owned by the caller.
|
1567
|
+
*/
|
1568
|
+
static CachedData* CreateCodeCache(
|
1569
|
+
Local<UnboundModuleScript> unbound_module_script);
|
1583
1570
|
|
1584
1571
|
/**
|
1585
1572
|
* Creates and returns code cache for the specified function that was
|
@@ -1587,8 +1574,7 @@ class V8_EXPORT ScriptCompiler {
|
|
1587
1574
|
* This will return nullptr if the script cannot be serialized. The
|
1588
1575
|
* CachedData returned by this function should be owned by the caller.
|
1589
1576
|
*/
|
1590
|
-
static CachedData* CreateCodeCacheForFunction(Local<Function> function
|
1591
|
-
Local<String> source);
|
1577
|
+
static CachedData* CreateCodeCacheForFunction(Local<Function> function);
|
1592
1578
|
|
1593
1579
|
private:
|
1594
1580
|
static V8_WARN_UNUSED_RESULT MaybeLocal<UnboundScript> CompileUnboundInternal(
|
@@ -1604,7 +1590,11 @@ class V8_EXPORT Message {
|
|
1604
1590
|
public:
|
1605
1591
|
Local<String> Get() const;
|
1606
1592
|
|
1607
|
-
|
1593
|
+
/**
|
1594
|
+
* Return the isolate to which the Message belongs.
|
1595
|
+
*/
|
1596
|
+
Isolate* GetIsolate() const;
|
1597
|
+
|
1608
1598
|
V8_WARN_UNUSED_RESULT MaybeLocal<String> GetSourceLine(
|
1609
1599
|
Local<Context> context) const;
|
1610
1600
|
|
@@ -1630,7 +1620,6 @@ class V8_EXPORT Message {
|
|
1630
1620
|
/**
|
1631
1621
|
* Returns the number, 1-based, of the line where the error occurred.
|
1632
1622
|
*/
|
1633
|
-
V8_DEPRECATED("Use maybe version", int GetLineNumber() const);
|
1634
1623
|
V8_WARN_UNUSED_RESULT Maybe<int> GetLineNumber(Local<Context> context) const;
|
1635
1624
|
|
1636
1625
|
/**
|
@@ -1710,7 +1699,7 @@ class V8_EXPORT StackTrace {
|
|
1710
1699
|
/**
|
1711
1700
|
* Returns a StackFrame at a particular index.
|
1712
1701
|
*/
|
1713
|
-
Local<StackFrame> GetFrame(uint32_t index) const;
|
1702
|
+
Local<StackFrame> GetFrame(Isolate* isolate, uint32_t index) const;
|
1714
1703
|
|
1715
1704
|
/**
|
1716
1705
|
* Returns the number of StackFrames.
|
@@ -1826,6 +1815,21 @@ struct SampleInfo {
|
|
1826
1815
|
// executing an external callback.
|
1827
1816
|
};
|
1828
1817
|
|
1818
|
+
struct MemoryRange {
|
1819
|
+
const void* start = nullptr;
|
1820
|
+
size_t length_in_bytes = 0;
|
1821
|
+
};
|
1822
|
+
|
1823
|
+
struct JSEntryStub {
|
1824
|
+
MemoryRange code;
|
1825
|
+
};
|
1826
|
+
|
1827
|
+
struct UnwindState {
|
1828
|
+
MemoryRange code_range;
|
1829
|
+
MemoryRange embedded_code_range;
|
1830
|
+
JSEntryStub js_entry_stub;
|
1831
|
+
};
|
1832
|
+
|
1829
1833
|
/**
|
1830
1834
|
* A JSON Parser and Stringifier.
|
1831
1835
|
*/
|
@@ -1835,12 +1839,10 @@ class V8_EXPORT JSON {
|
|
1835
1839
|
* Tries to parse the string |json_string| and returns it as value if
|
1836
1840
|
* successful.
|
1837
1841
|
*
|
1842
|
+
* \param the context in which to parse and create the value.
|
1838
1843
|
* \param json_string The string to parse.
|
1839
1844
|
* \return The corresponding value if successfully parsed.
|
1840
1845
|
*/
|
1841
|
-
static V8_DEPRECATE_SOON("Use the maybe version taking context",
|
1842
|
-
MaybeLocal<Value> Parse(Isolate* isolate,
|
1843
|
-
Local<String> json_string));
|
1844
1846
|
static V8_WARN_UNUSED_RESULT MaybeLocal<Value> Parse(
|
1845
1847
|
Local<Context> context, Local<String> json_string);
|
1846
1848
|
|
@@ -1868,7 +1870,7 @@ class V8_EXPORT ValueSerializer {
|
|
1868
1870
|
public:
|
1869
1871
|
class V8_EXPORT Delegate {
|
1870
1872
|
public:
|
1871
|
-
virtual ~Delegate()
|
1873
|
+
virtual ~Delegate() = default;
|
1872
1874
|
|
1873
1875
|
/**
|
1874
1876
|
* Handles the case where a DataCloneError would be thrown in the structured
|
@@ -1898,7 +1900,7 @@ class V8_EXPORT ValueSerializer {
|
|
1898
1900
|
Isolate* isolate, Local<SharedArrayBuffer> shared_array_buffer);
|
1899
1901
|
|
1900
1902
|
virtual Maybe<uint32_t> GetWasmModuleTransferId(
|
1901
|
-
Isolate* isolate, Local<
|
1903
|
+
Isolate* isolate, Local<WasmModuleObject> module);
|
1902
1904
|
/**
|
1903
1905
|
* Allocates memory for the buffer of at least the size provided. The actual
|
1904
1906
|
* size (which may be greater or equal) is written to |actual_size|. If no
|
@@ -1907,12 +1909,16 @@ class V8_EXPORT ValueSerializer {
|
|
1907
1909
|
* If the memory cannot be allocated, nullptr should be returned.
|
1908
1910
|
* |actual_size| will be ignored. It is assumed that |old_buffer| is still
|
1909
1911
|
* valid in this case and has not been modified.
|
1912
|
+
*
|
1913
|
+
* The default implementation uses the stdlib's `realloc()` function.
|
1910
1914
|
*/
|
1911
1915
|
virtual void* ReallocateBufferMemory(void* old_buffer, size_t size,
|
1912
1916
|
size_t* actual_size);
|
1913
1917
|
|
1914
1918
|
/**
|
1915
1919
|
* Frees a buffer allocated with |ReallocateBufferMemory|.
|
1920
|
+
*
|
1921
|
+
* The default implementation uses the stdlib's `free()` function.
|
1916
1922
|
*/
|
1917
1923
|
virtual void FreeBufferMemory(void* buffer);
|
1918
1924
|
};
|
@@ -1932,17 +1938,11 @@ class V8_EXPORT ValueSerializer {
|
|
1932
1938
|
V8_WARN_UNUSED_RESULT Maybe<bool> WriteValue(Local<Context> context,
|
1933
1939
|
Local<Value> value);
|
1934
1940
|
|
1935
|
-
/**
|
1936
|
-
* Returns the stored data. This serializer should not be used once the buffer
|
1937
|
-
* is released. The contents are undefined if a previous write has failed.
|
1938
|
-
*/
|
1939
|
-
V8_DEPRECATE_SOON("Use Release()", std::vector<uint8_t> ReleaseBuffer());
|
1940
|
-
|
1941
1941
|
/**
|
1942
1942
|
* Returns the stored data (allocated using the delegate's
|
1943
|
-
*
|
1944
|
-
* the buffer is released. The contents are undefined if a previous write
|
1945
|
-
* failed.
|
1943
|
+
* ReallocateBufferMemory) and its size. This serializer should not be used
|
1944
|
+
* once the buffer is released. The contents are undefined if a previous write
|
1945
|
+
* has failed. Ownership of the buffer is transferred to the caller.
|
1946
1946
|
*/
|
1947
1947
|
V8_WARN_UNUSED_RESULT std::pair<uint8_t*, size_t> Release();
|
1948
1948
|
|
@@ -1954,13 +1954,6 @@ class V8_EXPORT ValueSerializer {
|
|
1954
1954
|
void TransferArrayBuffer(uint32_t transfer_id,
|
1955
1955
|
Local<ArrayBuffer> array_buffer);
|
1956
1956
|
|
1957
|
-
/**
|
1958
|
-
* Similar to TransferArrayBuffer, but for SharedArrayBuffer.
|
1959
|
-
*/
|
1960
|
-
V8_DEPRECATE_SOON("Use Delegate::GetSharedArrayBufferId",
|
1961
|
-
void TransferSharedArrayBuffer(
|
1962
|
-
uint32_t transfer_id,
|
1963
|
-
Local<SharedArrayBuffer> shared_array_buffer));
|
1964
1957
|
|
1965
1958
|
/**
|
1966
1959
|
* Indicate whether to treat ArrayBufferView objects as host objects,
|
@@ -2001,7 +1994,7 @@ class V8_EXPORT ValueDeserializer {
|
|
2001
1994
|
public:
|
2002
1995
|
class V8_EXPORT Delegate {
|
2003
1996
|
public:
|
2004
|
-
virtual ~Delegate()
|
1997
|
+
virtual ~Delegate() = default;
|
2005
1998
|
|
2006
1999
|
/**
|
2007
2000
|
* The embedder overrides this method to read some kind of host object, if
|
@@ -2011,10 +2004,10 @@ class V8_EXPORT ValueDeserializer {
|
|
2011
2004
|
virtual MaybeLocal<Object> ReadHostObject(Isolate* isolate);
|
2012
2005
|
|
2013
2006
|
/**
|
2014
|
-
* Get a
|
2007
|
+
* Get a WasmModuleObject given a transfer_id previously provided
|
2015
2008
|
* by ValueSerializer::GetWasmModuleTransferId
|
2016
2009
|
*/
|
2017
|
-
virtual MaybeLocal<
|
2010
|
+
virtual MaybeLocal<WasmModuleObject> GetWasmModuleFromId(
|
2018
2011
|
Isolate* isolate, uint32_t transfer_id);
|
2019
2012
|
|
2020
2013
|
/**
|
@@ -2378,10 +2371,16 @@ class V8_EXPORT Value : public Data {
|
|
2378
2371
|
|
2379
2372
|
bool IsWebAssemblyCompiledModule() const;
|
2380
2373
|
|
2374
|
+
/**
|
2375
|
+
* Returns true if the value is a Module Namespace Object.
|
2376
|
+
*/
|
2377
|
+
bool IsModuleNamespaceObject() const;
|
2378
|
+
|
2381
2379
|
V8_WARN_UNUSED_RESULT MaybeLocal<BigInt> ToBigInt(
|
2382
2380
|
Local<Context> context) const;
|
2383
|
-
|
2384
|
-
|
2381
|
+
V8_DEPRECATE_SOON("ToBoolean can never throw. Use Local version.",
|
2382
|
+
V8_WARN_UNUSED_RESULT MaybeLocal<Boolean> ToBoolean(
|
2383
|
+
Local<Context> context) const);
|
2385
2384
|
V8_WARN_UNUSED_RESULT MaybeLocal<Number> ToNumber(
|
2386
2385
|
Local<Context> context) const;
|
2387
2386
|
V8_WARN_UNUSED_RESULT MaybeLocal<String> ToString(
|
@@ -2396,8 +2395,7 @@ class V8_EXPORT Value : public Data {
|
|
2396
2395
|
Local<Context> context) const;
|
2397
2396
|
V8_WARN_UNUSED_RESULT MaybeLocal<Int32> ToInt32(Local<Context> context) const;
|
2398
2397
|
|
2399
|
-
|
2400
|
-
Local<Boolean> ToBoolean(Isolate* isolate) const);
|
2398
|
+
Local<Boolean> ToBoolean(Isolate* isolate) const;
|
2401
2399
|
V8_DEPRECATE_SOON("Use maybe version",
|
2402
2400
|
Local<Number> ToNumber(Isolate* isolate) const);
|
2403
2401
|
V8_DEPRECATE_SOON("Use maybe version",
|
@@ -2409,13 +2407,6 @@ class V8_EXPORT Value : public Data {
|
|
2409
2407
|
V8_DEPRECATE_SOON("Use maybe version",
|
2410
2408
|
Local<Int32> ToInt32(Isolate* isolate) const);
|
2411
2409
|
|
2412
|
-
inline V8_DEPRECATE_SOON("Use maybe version",
|
2413
|
-
Local<Boolean> ToBoolean() const);
|
2414
|
-
inline V8_DEPRECATE_SOON("Use maybe version", Local<String> ToString() const);
|
2415
|
-
inline V8_DEPRECATE_SOON("Use maybe version", Local<Object> ToObject() const);
|
2416
|
-
inline V8_DEPRECATE_SOON("Use maybe version",
|
2417
|
-
Local<Integer> ToInteger() const);
|
2418
|
-
|
2419
2410
|
/**
|
2420
2411
|
* Attempts to convert a string to an array index.
|
2421
2412
|
* Returns an empty handle if the conversion fails.
|
@@ -2423,7 +2414,11 @@ class V8_EXPORT Value : public Data {
|
|
2423
2414
|
V8_WARN_UNUSED_RESULT MaybeLocal<Uint32> ToArrayIndex(
|
2424
2415
|
Local<Context> context) const;
|
2425
2416
|
|
2426
|
-
|
2417
|
+
bool BooleanValue(Isolate* isolate) const;
|
2418
|
+
|
2419
|
+
V8_DEPRECATE_SOON("BooleanValue can never throw. Use Isolate version.",
|
2420
|
+
V8_WARN_UNUSED_RESULT Maybe<bool> BooleanValue(
|
2421
|
+
Local<Context> context) const);
|
2427
2422
|
V8_WARN_UNUSED_RESULT Maybe<double> NumberValue(Local<Context> context) const;
|
2428
2423
|
V8_WARN_UNUSED_RESULT Maybe<int64_t> IntegerValue(
|
2429
2424
|
Local<Context> context) const;
|
@@ -2431,14 +2426,7 @@ class V8_EXPORT Value : public Data {
|
|
2431
2426
|
Local<Context> context) const;
|
2432
2427
|
V8_WARN_UNUSED_RESULT Maybe<int32_t> Int32Value(Local<Context> context) const;
|
2433
2428
|
|
2434
|
-
V8_DEPRECATE_SOON("Use maybe version", bool BooleanValue() const);
|
2435
|
-
V8_DEPRECATE_SOON("Use maybe version", double NumberValue() const);
|
2436
|
-
V8_DEPRECATE_SOON("Use maybe version", int64_t IntegerValue() const);
|
2437
|
-
V8_DEPRECATE_SOON("Use maybe version", uint32_t Uint32Value() const);
|
2438
|
-
V8_DEPRECATE_SOON("Use maybe version", int32_t Int32Value() const);
|
2439
|
-
|
2440
2429
|
/** JS == */
|
2441
|
-
V8_DEPRECATE_SOON("Use maybe version", bool Equals(Local<Value> that) const);
|
2442
2430
|
V8_WARN_UNUSED_RESULT Maybe<bool> Equals(Local<Context> context,
|
2443
2431
|
Local<Value> that) const;
|
2444
2432
|
bool StrictEquals(Local<Value> that) const;
|
@@ -2527,8 +2515,9 @@ enum class NewStringType {
|
|
2527
2515
|
*/
|
2528
2516
|
class V8_EXPORT String : public Name {
|
2529
2517
|
public:
|
2530
|
-
static constexpr int kMaxLength =
|
2531
|
-
|
2518
|
+
static constexpr int kMaxLength = internal::kApiTaggedSize == 4
|
2519
|
+
? (1 << 28) - 16
|
2520
|
+
: internal::kSmiMaxValue / 2 - 24;
|
2532
2521
|
|
2533
2522
|
enum Encoding {
|
2534
2523
|
UNKNOWN_ENCODING = 0x1,
|
@@ -2544,7 +2533,7 @@ class V8_EXPORT String : public Name {
|
|
2544
2533
|
* Returns the number of bytes in the UTF-8 encoded
|
2545
2534
|
* representation of this string.
|
2546
2535
|
*/
|
2547
|
-
int Utf8Length() const;
|
2536
|
+
int Utf8Length(Isolate* isolate) const;
|
2548
2537
|
|
2549
2538
|
/**
|
2550
2539
|
* Returns whether this string is known to contain only one byte data,
|
@@ -2598,20 +2587,14 @@ class V8_EXPORT String : public Name {
|
|
2598
2587
|
};
|
2599
2588
|
|
2600
2589
|
// 16-bit character codes.
|
2601
|
-
int Write(uint16_t* buffer,
|
2602
|
-
int start = 0,
|
2603
|
-
int length = -1,
|
2590
|
+
int Write(Isolate* isolate, uint16_t* buffer, int start = 0, int length = -1,
|
2604
2591
|
int options = NO_OPTIONS) const;
|
2605
2592
|
// One byte characters.
|
2606
|
-
int WriteOneByte(uint8_t* buffer,
|
2607
|
-
int
|
2608
|
-
int length = -1,
|
2609
|
-
int options = NO_OPTIONS) const;
|
2593
|
+
int WriteOneByte(Isolate* isolate, uint8_t* buffer, int start = 0,
|
2594
|
+
int length = -1, int options = NO_OPTIONS) const;
|
2610
2595
|
// UTF-8 encoded characters.
|
2611
|
-
int WriteUtf8(char* buffer,
|
2612
|
-
int
|
2613
|
-
int* nchars_ref = NULL,
|
2614
|
-
int options = NO_OPTIONS) const;
|
2596
|
+
int WriteUtf8(Isolate* isolate, char* buffer, int length = -1,
|
2597
|
+
int* nchars_ref = nullptr, int options = NO_OPTIONS) const;
|
2615
2598
|
|
2616
2599
|
/**
|
2617
2600
|
* A zero length string.
|
@@ -2630,12 +2613,21 @@ class V8_EXPORT String : public Name {
|
|
2630
2613
|
|
2631
2614
|
class V8_EXPORT ExternalStringResourceBase { // NOLINT
|
2632
2615
|
public:
|
2633
|
-
virtual ~ExternalStringResourceBase()
|
2616
|
+
virtual ~ExternalStringResourceBase() = default;
|
2634
2617
|
|
2635
|
-
virtual bool IsCompressible() const {
|
2618
|
+
V8_DEPRECATED("Use IsCacheable().", virtual bool IsCompressible() const) {
|
2619
|
+
return false;
|
2620
|
+
}
|
2621
|
+
|
2622
|
+
/**
|
2623
|
+
* If a string is cacheable, the value returned by
|
2624
|
+
* ExternalStringResource::data() may be cached, otherwise it is not
|
2625
|
+
* expected to be stable beyond the current top-level task.
|
2626
|
+
*/
|
2627
|
+
virtual bool IsCacheable() const { return true; }
|
2636
2628
|
|
2637
2629
|
protected:
|
2638
|
-
ExternalStringResourceBase()
|
2630
|
+
ExternalStringResourceBase() = default;
|
2639
2631
|
|
2640
2632
|
/**
|
2641
2633
|
* Internally V8 will call this Dispose method when the external string
|
@@ -2645,6 +2637,24 @@ class V8_EXPORT String : public Name {
|
|
2645
2637
|
*/
|
2646
2638
|
virtual void Dispose() { delete this; }
|
2647
2639
|
|
2640
|
+
/**
|
2641
|
+
* For a non-cacheable string, the value returned by
|
2642
|
+
* |ExternalStringResource::data()| has to be stable between |Lock()| and
|
2643
|
+
* |Unlock()|, that is the string must behave as is |IsCacheable()| returned
|
2644
|
+
* true.
|
2645
|
+
*
|
2646
|
+
* These two functions must be thread-safe, and can be called from anywhere.
|
2647
|
+
* They also must handle lock depth, in the sense that each can be called
|
2648
|
+
* several times, from different threads, and unlocking should only happen
|
2649
|
+
* when the balance of Lock() and Unlock() calls is 0.
|
2650
|
+
*/
|
2651
|
+
virtual void Lock() const {}
|
2652
|
+
|
2653
|
+
/**
|
2654
|
+
* Unlocks the string.
|
2655
|
+
*/
|
2656
|
+
virtual void Unlock() const {}
|
2657
|
+
|
2648
2658
|
// Disallow copying and assigning.
|
2649
2659
|
ExternalStringResourceBase(const ExternalStringResourceBase&) = delete;
|
2650
2660
|
void operator=(const ExternalStringResourceBase&) = delete;
|
@@ -2652,6 +2662,7 @@ class V8_EXPORT String : public Name {
|
|
2652
2662
|
private:
|
2653
2663
|
friend class internal::Heap;
|
2654
2664
|
friend class v8::String;
|
2665
|
+
friend class internal::ScopedExternalStringLock;
|
2655
2666
|
};
|
2656
2667
|
|
2657
2668
|
/**
|
@@ -2667,7 +2678,7 @@ class V8_EXPORT String : public Name {
|
|
2667
2678
|
* Override the destructor to manage the life cycle of the underlying
|
2668
2679
|
* buffer.
|
2669
2680
|
*/
|
2670
|
-
|
2681
|
+
~ExternalStringResource() override = default;
|
2671
2682
|
|
2672
2683
|
/**
|
2673
2684
|
* The string data from the underlying buffer.
|
@@ -2680,7 +2691,7 @@ class V8_EXPORT String : public Name {
|
|
2680
2691
|
virtual size_t length() const = 0;
|
2681
2692
|
|
2682
2693
|
protected:
|
2683
|
-
ExternalStringResource()
|
2694
|
+
ExternalStringResource() = default;
|
2684
2695
|
};
|
2685
2696
|
|
2686
2697
|
/**
|
@@ -2700,13 +2711,13 @@ class V8_EXPORT String : public Name {
|
|
2700
2711
|
* Override the destructor to manage the life cycle of the underlying
|
2701
2712
|
* buffer.
|
2702
2713
|
*/
|
2703
|
-
|
2714
|
+
~ExternalOneByteStringResource() override = default;
|
2704
2715
|
/** The string data from the underlying buffer.*/
|
2705
2716
|
virtual const char* data() const = 0;
|
2706
2717
|
/** The number of Latin-1 characters in the string.*/
|
2707
2718
|
virtual size_t length() const = 0;
|
2708
2719
|
protected:
|
2709
|
-
ExternalOneByteStringResource()
|
2720
|
+
ExternalOneByteStringResource() = default;
|
2710
2721
|
};
|
2711
2722
|
|
2712
2723
|
/**
|
@@ -2738,7 +2749,7 @@ class V8_EXPORT String : public Name {
|
|
2738
2749
|
};
|
2739
2750
|
|
2740
2751
|
/** Allocates a new string from UTF-8 data.*/
|
2741
|
-
static
|
2752
|
+
static V8_DEPRECATED(
|
2742
2753
|
"Use maybe version",
|
2743
2754
|
Local<String> NewFromUtf8(Isolate* isolate, const char* data,
|
2744
2755
|
NewStringType type = kNormalString,
|
@@ -2773,7 +2784,8 @@ class V8_EXPORT String : public Name {
|
|
2773
2784
|
* Creates a new string by concatenating the left and the right strings
|
2774
2785
|
* passed in as parameters.
|
2775
2786
|
*/
|
2776
|
-
static Local<String> Concat(
|
2787
|
+
static Local<String> Concat(Isolate* isolate, Local<String> left,
|
2788
|
+
Local<String> right);
|
2777
2789
|
|
2778
2790
|
/**
|
2779
2791
|
* Creates a new external string using the data defined in the given
|
@@ -2828,6 +2840,11 @@ class V8_EXPORT String : public Name {
|
|
2828
2840
|
*/
|
2829
2841
|
bool CanMakeExternal();
|
2830
2842
|
|
2843
|
+
/**
|
2844
|
+
* Returns true if the strings values are equal. Same as JS ==/===.
|
2845
|
+
*/
|
2846
|
+
bool StringEquals(Local<String> str);
|
2847
|
+
|
2831
2848
|
/**
|
2832
2849
|
* Converts an object to a UTF-8-encoded character array. Useful if
|
2833
2850
|
* you want to print the object. If conversion to a string fails
|
@@ -2837,8 +2854,6 @@ class V8_EXPORT String : public Name {
|
|
2837
2854
|
*/
|
2838
2855
|
class V8_EXPORT Utf8Value {
|
2839
2856
|
public:
|
2840
|
-
V8_DEPRECATED("Use Isolate version",
|
2841
|
-
explicit Utf8Value(Local<v8::Value> obj));
|
2842
2857
|
Utf8Value(Isolate* isolate, Local<v8::Value> obj);
|
2843
2858
|
~Utf8Value();
|
2844
2859
|
char* operator*() { return str_; }
|
@@ -2862,7 +2877,6 @@ class V8_EXPORT String : public Name {
|
|
2862
2877
|
*/
|
2863
2878
|
class V8_EXPORT Value {
|
2864
2879
|
public:
|
2865
|
-
V8_DEPRECATED("Use Isolate version", explicit Value(Local<v8::Value> obj));
|
2866
2880
|
Value(Isolate* isolate, Local<v8::Value> obj);
|
2867
2881
|
~Value();
|
2868
2882
|
uint16_t* operator*() { return str_; }
|
@@ -2882,6 +2896,10 @@ class V8_EXPORT String : public Name {
|
|
2882
2896
|
void VerifyExternalStringResourceBase(ExternalStringResourceBase* v,
|
2883
2897
|
Encoding encoding) const;
|
2884
2898
|
void VerifyExternalStringResource(ExternalStringResource* val) const;
|
2899
|
+
ExternalStringResource* GetExternalStringResourceSlow() const;
|
2900
|
+
ExternalStringResourceBase* GetExternalStringResourceBaseSlow(
|
2901
|
+
String::Encoding* encoding_out) const;
|
2902
|
+
|
2885
2903
|
static void CheckCast(v8::Value* obj);
|
2886
2904
|
};
|
2887
2905
|
|
@@ -2918,6 +2936,7 @@ class V8_EXPORT Symbol : public Name {
|
|
2918
2936
|
static Local<Symbol> ForApi(Isolate *isolate, Local<String> name);
|
2919
2937
|
|
2920
2938
|
// Well-known symbols
|
2939
|
+
static Local<Symbol> GetAsyncIterator(Isolate* isolate);
|
2921
2940
|
static Local<Symbol> GetHasInstance(Isolate* isolate);
|
2922
2941
|
static Local<Symbol> GetIsConcatSpreadable(Isolate* isolate);
|
2923
2942
|
static Local<Symbol> GetIterator(Isolate* isolate);
|
@@ -3037,6 +3056,48 @@ class V8_EXPORT Uint32 : public Integer {
|
|
3037
3056
|
class V8_EXPORT BigInt : public Primitive {
|
3038
3057
|
public:
|
3039
3058
|
static Local<BigInt> New(Isolate* isolate, int64_t value);
|
3059
|
+
static Local<BigInt> NewFromUnsigned(Isolate* isolate, uint64_t value);
|
3060
|
+
/**
|
3061
|
+
* Creates a new BigInt object using a specified sign bit and a
|
3062
|
+
* specified list of digits/words.
|
3063
|
+
* The resulting number is calculated as:
|
3064
|
+
*
|
3065
|
+
* (-1)^sign_bit * (words[0] * (2^64)^0 + words[1] * (2^64)^1 + ...)
|
3066
|
+
*/
|
3067
|
+
static MaybeLocal<BigInt> NewFromWords(Local<Context> context, int sign_bit,
|
3068
|
+
int word_count, const uint64_t* words);
|
3069
|
+
|
3070
|
+
/**
|
3071
|
+
* Returns the value of this BigInt as an unsigned 64-bit integer.
|
3072
|
+
* If `lossless` is provided, it will reflect whether the return value was
|
3073
|
+
* truncated or wrapped around. In particular, it is set to `false` if this
|
3074
|
+
* BigInt is negative.
|
3075
|
+
*/
|
3076
|
+
uint64_t Uint64Value(bool* lossless = nullptr) const;
|
3077
|
+
|
3078
|
+
/**
|
3079
|
+
* Returns the value of this BigInt as a signed 64-bit integer.
|
3080
|
+
* If `lossless` is provided, it will reflect whether this BigInt was
|
3081
|
+
* truncated or not.
|
3082
|
+
*/
|
3083
|
+
int64_t Int64Value(bool* lossless = nullptr) const;
|
3084
|
+
|
3085
|
+
/**
|
3086
|
+
* Returns the number of 64-bit words needed to store the result of
|
3087
|
+
* ToWordsArray().
|
3088
|
+
*/
|
3089
|
+
int WordCount() const;
|
3090
|
+
|
3091
|
+
/**
|
3092
|
+
* Writes the contents of this BigInt to a specified memory location.
|
3093
|
+
* `sign_bit` must be provided and will be set to 1 if this BigInt is
|
3094
|
+
* negative.
|
3095
|
+
* `*word_count` has to be initialized to the length of the `words` array.
|
3096
|
+
* Upon return, it will be set to the actual number of words that would
|
3097
|
+
* be needed to store this BigInt (i.e. the return value of `WordCount()`).
|
3098
|
+
*/
|
3099
|
+
void ToWordsArray(int* sign_bit, int* word_count, uint64_t* words) const;
|
3100
|
+
|
3040
3101
|
V8_INLINE static BigInt* Cast(v8::Value* obj);
|
3041
3102
|
|
3042
3103
|
private:
|
@@ -3113,10 +3174,17 @@ enum PropertyFilter {
|
|
3113
3174
|
* Options for marking whether callbacks may trigger JS-observable side effects.
|
3114
3175
|
* Side-effect-free callbacks are whitelisted during debug evaluation with
|
3115
3176
|
* throwOnSideEffect. It applies when calling a Function, FunctionTemplate,
|
3116
|
-
* or an Accessor
|
3177
|
+
* or an Accessor callback. For Interceptors, please see
|
3117
3178
|
* PropertyHandlerFlags's kHasNoSideEffect.
|
3179
|
+
* Callbacks that only cause side effects to the receiver are whitelisted if
|
3180
|
+
* invoked on receiver objects that are created within the same debug-evaluate
|
3181
|
+
* call, as these objects are temporary and the side effect does not escape.
|
3118
3182
|
*/
|
3119
|
-
enum class SideEffectType {
|
3183
|
+
enum class SideEffectType {
|
3184
|
+
kHasSideEffect,
|
3185
|
+
kHasNoSideEffect,
|
3186
|
+
kHasSideEffectToReceiver
|
3187
|
+
};
|
3120
3188
|
|
3121
3189
|
/**
|
3122
3190
|
* Keys/Properties filter enums:
|
@@ -3151,6 +3219,10 @@ class V8_EXPORT Object : public Value {
|
|
3151
3219
|
public:
|
3152
3220
|
V8_DEPRECATE_SOON("Use maybe version",
|
3153
3221
|
bool Set(Local<Value> key, Local<Value> value));
|
3222
|
+
/**
|
3223
|
+
* Set only return Just(true) or Empty(), so if it should never fail, use
|
3224
|
+
* result.Check().
|
3225
|
+
*/
|
3154
3226
|
V8_WARN_UNUSED_RESULT Maybe<bool> Set(Local<Context> context,
|
3155
3227
|
Local<Value> key, Local<Value> value);
|
3156
3228
|
|
@@ -3221,7 +3293,6 @@ class V8_EXPORT Object : public Value {
|
|
3221
3293
|
V8_WARN_UNUSED_RESULT MaybeLocal<Value> GetOwnPropertyDescriptor(
|
3222
3294
|
Local<Context> context, Local<Name> key);
|
3223
3295
|
|
3224
|
-
V8_DEPRECATE_SOON("Use maybe version", bool Has(Local<Value> key));
|
3225
3296
|
/**
|
3226
3297
|
* Object::Has() calls the abstract operation HasProperty(O, P) described
|
3227
3298
|
* in ECMA-262, 7.3.10. Has() returns
|
@@ -3240,7 +3311,6 @@ class V8_EXPORT Object : public Value {
|
|
3240
3311
|
V8_WARN_UNUSED_RESULT Maybe<bool> Has(Local<Context> context,
|
3241
3312
|
Local<Value> key);
|
3242
3313
|
|
3243
|
-
V8_DEPRECATE_SOON("Use maybe version", bool Delete(Local<Value> key));
|
3244
3314
|
V8_WARN_UNUSED_RESULT Maybe<bool> Delete(Local<Context> context,
|
3245
3315
|
Local<Value> key);
|
3246
3316
|
|
@@ -3254,10 +3324,12 @@ class V8_EXPORT Object : public Value {
|
|
3254
3324
|
*/
|
3255
3325
|
V8_WARN_UNUSED_RESULT Maybe<bool> SetAccessor(
|
3256
3326
|
Local<Context> context, Local<Name> name,
|
3257
|
-
AccessorNameGetterCallback getter,
|
3327
|
+
AccessorNameGetterCallback getter,
|
3328
|
+
AccessorNameSetterCallback setter = nullptr,
|
3258
3329
|
MaybeLocal<Value> data = MaybeLocal<Value>(),
|
3259
3330
|
AccessControl settings = DEFAULT, PropertyAttribute attribute = None,
|
3260
|
-
SideEffectType getter_side_effect_type = SideEffectType::kHasSideEffect
|
3331
|
+
SideEffectType getter_side_effect_type = SideEffectType::kHasSideEffect,
|
3332
|
+
SideEffectType setter_side_effect_type = SideEffectType::kHasSideEffect);
|
3261
3333
|
|
3262
3334
|
void SetAccessorProperty(Local<Name> name, Local<Function> getter,
|
3263
3335
|
Local<Function> setter = Local<Function>(),
|
@@ -3273,7 +3345,8 @@ class V8_EXPORT Object : public Value {
|
|
3273
3345
|
AccessorNameGetterCallback getter,
|
3274
3346
|
AccessorNameSetterCallback setter = nullptr,
|
3275
3347
|
Local<Value> data = Local<Value>(), PropertyAttribute attributes = None,
|
3276
|
-
SideEffectType getter_side_effect_type = SideEffectType::kHasSideEffect
|
3348
|
+
SideEffectType getter_side_effect_type = SideEffectType::kHasSideEffect,
|
3349
|
+
SideEffectType setter_side_effect_type = SideEffectType::kHasSideEffect);
|
3277
3350
|
|
3278
3351
|
/**
|
3279
3352
|
* Attempts to create a property with the given name which behaves like a data
|
@@ -3287,7 +3360,8 @@ class V8_EXPORT Object : public Value {
|
|
3287
3360
|
Local<Context> context, Local<Name> name,
|
3288
3361
|
AccessorNameGetterCallback getter, Local<Value> data = Local<Value>(),
|
3289
3362
|
PropertyAttribute attributes = None,
|
3290
|
-
SideEffectType getter_side_effect_type = SideEffectType::kHasSideEffect
|
3363
|
+
SideEffectType getter_side_effect_type = SideEffectType::kHasSideEffect,
|
3364
|
+
SideEffectType setter_side_effect_type = SideEffectType::kHasSideEffect);
|
3291
3365
|
|
3292
3366
|
/**
|
3293
3367
|
* Functionality for private properties.
|
@@ -3307,7 +3381,7 @@ class V8_EXPORT Object : public Value {
|
|
3307
3381
|
* array returned by this method contains the same values as would
|
3308
3382
|
* be enumerated by a for-in statement over this object.
|
3309
3383
|
*/
|
3310
|
-
|
3384
|
+
V8_DEPRECATED("Use maybe version", Local<Array> GetPropertyNames());
|
3311
3385
|
V8_WARN_UNUSED_RESULT MaybeLocal<Array> GetPropertyNames(
|
3312
3386
|
Local<Context> context);
|
3313
3387
|
V8_WARN_UNUSED_RESULT MaybeLocal<Array> GetPropertyNames(
|
@@ -3320,7 +3394,7 @@ class V8_EXPORT Object : public Value {
|
|
3320
3394
|
* the returned array doesn't contain the names of properties from
|
3321
3395
|
* prototype objects.
|
3322
3396
|
*/
|
3323
|
-
|
3397
|
+
V8_DEPRECATED("Use maybe version", Local<Array> GetOwnPropertyNames());
|
3324
3398
|
V8_WARN_UNUSED_RESULT MaybeLocal<Array> GetOwnPropertyNames(
|
3325
3399
|
Local<Context> context);
|
3326
3400
|
|
@@ -3419,8 +3493,8 @@ class V8_EXPORT Object : public Value {
|
|
3419
3493
|
Local<Name> key);
|
3420
3494
|
V8_WARN_UNUSED_RESULT Maybe<bool> HasOwnProperty(Local<Context> context,
|
3421
3495
|
uint32_t index);
|
3422
|
-
|
3423
|
-
|
3496
|
+
V8_DEPRECATED("Use maybe version",
|
3497
|
+
bool HasRealNamedProperty(Local<String> key));
|
3424
3498
|
/**
|
3425
3499
|
* Use HasRealNamedProperty() if you want to check if an object has an own
|
3426
3500
|
* property without causing side effects, i.e., without calling interceptors.
|
@@ -3436,12 +3510,12 @@ class V8_EXPORT Object : public Value {
|
|
3436
3510
|
*/
|
3437
3511
|
V8_WARN_UNUSED_RESULT Maybe<bool> HasRealNamedProperty(Local<Context> context,
|
3438
3512
|
Local<Name> key);
|
3439
|
-
|
3440
|
-
|
3513
|
+
V8_DEPRECATED("Use maybe version",
|
3514
|
+
bool HasRealIndexedProperty(uint32_t index));
|
3441
3515
|
V8_WARN_UNUSED_RESULT Maybe<bool> HasRealIndexedProperty(
|
3442
3516
|
Local<Context> context, uint32_t index);
|
3443
|
-
|
3444
|
-
|
3517
|
+
V8_DEPRECATED("Use maybe version",
|
3518
|
+
bool HasRealNamedCallbackProperty(Local<String> key));
|
3445
3519
|
V8_WARN_UNUSED_RESULT Maybe<bool> HasRealNamedCallbackProperty(
|
3446
3520
|
Local<Context> context, Local<Name> key);
|
3447
3521
|
|
@@ -3544,8 +3618,31 @@ class V8_EXPORT Object : public Value {
|
|
3544
3618
|
*/
|
3545
3619
|
Isolate* GetIsolate();
|
3546
3620
|
|
3621
|
+
/**
|
3622
|
+
* If this object is a Set, Map, WeakSet or WeakMap, this returns a
|
3623
|
+
* representation of the elements of this object as an array.
|
3624
|
+
* If this object is a SetIterator or MapIterator, this returns all
|
3625
|
+
* elements of the underlying collection, starting at the iterator's current
|
3626
|
+
* position.
|
3627
|
+
* For other types, this will return an empty MaybeLocal<Array> (without
|
3628
|
+
* scheduling an exception).
|
3629
|
+
*/
|
3630
|
+
MaybeLocal<Array> PreviewEntries(bool* is_key_value);
|
3631
|
+
|
3547
3632
|
static Local<Object> New(Isolate* isolate);
|
3548
3633
|
|
3634
|
+
/**
|
3635
|
+
* Creates a JavaScript object with the given properties, and
|
3636
|
+
* a the given prototype_or_null (which can be any JavaScript
|
3637
|
+
* value, and if it's null, the newly created object won't have
|
3638
|
+
* a prototype at all). This is similar to Object.create().
|
3639
|
+
* All properties will be created as enumerable, configurable
|
3640
|
+
* and writable properties.
|
3641
|
+
*/
|
3642
|
+
static Local<Object> New(Isolate* isolate, Local<Value> prototype_or_null,
|
3643
|
+
Local<Name>* names, Local<Value>* values,
|
3644
|
+
size_t length);
|
3645
|
+
|
3549
3646
|
V8_INLINE static Object* Cast(Value* obj);
|
3550
3647
|
|
3551
3648
|
private:
|
@@ -3569,6 +3666,12 @@ class V8_EXPORT Array : public Object {
|
|
3569
3666
|
*/
|
3570
3667
|
static Local<Array> New(Isolate* isolate, int length = 0);
|
3571
3668
|
|
3669
|
+
/**
|
3670
|
+
* Creates a JavaScript array out of a Local<Value> array in C++
|
3671
|
+
* with a known length.
|
3672
|
+
*/
|
3673
|
+
static Local<Array> New(Isolate* isolate, Local<Value>* elements,
|
3674
|
+
size_t length);
|
3572
3675
|
V8_INLINE static Array* Cast(Value* obj);
|
3573
3676
|
private:
|
3574
3677
|
Array();
|
@@ -3653,8 +3756,8 @@ class ReturnValue {
|
|
3653
3756
|
}
|
3654
3757
|
// Local setters
|
3655
3758
|
template <typename S>
|
3656
|
-
V8_INLINE
|
3657
|
-
|
3759
|
+
V8_INLINE V8_DEPRECATED("Use Global<> instead",
|
3760
|
+
void Set(const Persistent<S>& handle));
|
3658
3761
|
template <typename S>
|
3659
3762
|
V8_INLINE void Set(const Global<S>& handle);
|
3660
3763
|
template <typename S>
|
@@ -3686,10 +3789,10 @@ class ReturnValue {
|
|
3686
3789
|
template<class F> friend class PropertyCallbackInfo;
|
3687
3790
|
template <class F, class G, class H>
|
3688
3791
|
friend class PersistentValueMapBase;
|
3689
|
-
V8_INLINE void SetInternal(internal::
|
3690
|
-
V8_INLINE internal::
|
3691
|
-
V8_INLINE explicit ReturnValue(internal::
|
3692
|
-
internal::
|
3792
|
+
V8_INLINE void SetInternal(internal::Address value) { *value_ = value; }
|
3793
|
+
V8_INLINE internal::Address GetDefaultValue();
|
3794
|
+
V8_INLINE explicit ReturnValue(internal::Address* slot);
|
3795
|
+
internal::Address* value_;
|
3693
3796
|
};
|
3694
3797
|
|
3695
3798
|
|
@@ -3743,10 +3846,10 @@ class FunctionCallbackInfo {
|
|
3743
3846
|
static const int kDataIndex = 4;
|
3744
3847
|
static const int kNewTargetIndex = 5;
|
3745
3848
|
|
3746
|
-
V8_INLINE FunctionCallbackInfo(internal::
|
3747
|
-
internal::
|
3748
|
-
internal::
|
3749
|
-
internal::
|
3849
|
+
V8_INLINE FunctionCallbackInfo(internal::Address* implicit_args,
|
3850
|
+
internal::Address* values, int length);
|
3851
|
+
internal::Address* implicit_args_;
|
3852
|
+
internal::Address* values_;
|
3750
3853
|
int length_;
|
3751
3854
|
};
|
3752
3855
|
|
@@ -3858,8 +3961,8 @@ class PropertyCallbackInfo {
|
|
3858
3961
|
static const int kDataIndex = 5;
|
3859
3962
|
static const int kThisIndex = 6;
|
3860
3963
|
|
3861
|
-
V8_INLINE PropertyCallbackInfo(internal::
|
3862
|
-
internal::
|
3964
|
+
V8_INLINE PropertyCallbackInfo(internal::Address* args) : args_(args) {}
|
3965
|
+
internal::Address* args_;
|
3863
3966
|
};
|
3864
3967
|
|
3865
3968
|
|
@@ -3881,10 +3984,11 @@ class V8_EXPORT Function : public Object {
|
|
3881
3984
|
Local<Value> data = Local<Value>(), int length = 0,
|
3882
3985
|
ConstructorBehavior behavior = ConstructorBehavior::kAllow,
|
3883
3986
|
SideEffectType side_effect_type = SideEffectType::kHasSideEffect);
|
3884
|
-
static
|
3885
|
-
|
3886
|
-
|
3887
|
-
|
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));
|
3888
3992
|
|
3889
3993
|
V8_WARN_UNUSED_RESULT MaybeLocal<Object> NewInstance(
|
3890
3994
|
Local<Context> context, int argc, Local<Value> argv[]) const;
|
@@ -3894,9 +3998,18 @@ class V8_EXPORT Function : public Object {
|
|
3894
3998
|
return NewInstance(context, 0, nullptr);
|
3895
3999
|
}
|
3896
4000
|
|
3897
|
-
|
3898
|
-
|
3899
|
-
|
4001
|
+
/**
|
4002
|
+
* When side effect checks are enabled, passing kHasNoSideEffect allows the
|
4003
|
+
* constructor to be invoked without throwing. Calls made within the
|
4004
|
+
* constructor are still checked.
|
4005
|
+
*/
|
4006
|
+
V8_WARN_UNUSED_RESULT MaybeLocal<Object> NewInstanceWithSideEffectType(
|
4007
|
+
Local<Context> context, int argc, Local<Value> argv[],
|
4008
|
+
SideEffectType side_effect_type = SideEffectType::kHasSideEffect) const;
|
4009
|
+
|
4010
|
+
V8_DEPRECATED("Use maybe version",
|
4011
|
+
Local<Value> Call(Local<Value> recv, int argc,
|
4012
|
+
Local<Value> argv[]));
|
3900
4013
|
V8_WARN_UNUSED_RESULT MaybeLocal<Value> Call(Local<Context> context,
|
3901
4014
|
Local<Value> recv, int argc,
|
3902
4015
|
Local<Value> argv[]);
|
@@ -3976,8 +4089,6 @@ class V8_EXPORT Promise : public Object {
|
|
3976
4089
|
/**
|
3977
4090
|
* Create a new resolver, along with an associated promise in pending state.
|
3978
4091
|
*/
|
3979
|
-
static V8_DEPRECATED("Use maybe version",
|
3980
|
-
Local<Resolver> New(Isolate* isolate));
|
3981
4092
|
static V8_WARN_UNUSED_RESULT MaybeLocal<Resolver> New(
|
3982
4093
|
Local<Context> context);
|
3983
4094
|
|
@@ -3990,11 +4101,9 @@ class V8_EXPORT Promise : public Object {
|
|
3990
4101
|
* Resolve/reject the associated promise with a given value.
|
3991
4102
|
* Ignored if the promise is no longer pending.
|
3992
4103
|
*/
|
3993
|
-
V8_DEPRECATED("Use maybe version", void Resolve(Local<Value> value));
|
3994
4104
|
V8_WARN_UNUSED_RESULT Maybe<bool> Resolve(Local<Context> context,
|
3995
4105
|
Local<Value> value);
|
3996
4106
|
|
3997
|
-
V8_DEPRECATED("Use maybe version", void Reject(Local<Value> value));
|
3998
4107
|
V8_WARN_UNUSED_RESULT Maybe<bool> Reject(Local<Context> context,
|
3999
4108
|
Local<Value> value);
|
4000
4109
|
|
@@ -4017,6 +4126,10 @@ class V8_EXPORT Promise : public Object {
|
|
4017
4126
|
V8_WARN_UNUSED_RESULT MaybeLocal<Promise> Then(Local<Context> context,
|
4018
4127
|
Local<Function> handler);
|
4019
4128
|
|
4129
|
+
V8_WARN_UNUSED_RESULT MaybeLocal<Promise> Then(Local<Context> context,
|
4130
|
+
Local<Function> on_fulfilled,
|
4131
|
+
Local<Function> on_rejected);
|
4132
|
+
|
4020
4133
|
/**
|
4021
4134
|
* Returns true if the promise has at least one derived promise, and
|
4022
4135
|
* therefore resolve/reject handlers (including default handler).
|
@@ -4034,6 +4147,11 @@ class V8_EXPORT Promise : public Object {
|
|
4034
4147
|
*/
|
4035
4148
|
PromiseState State();
|
4036
4149
|
|
4150
|
+
/**
|
4151
|
+
* Marks this promise as handled to avoid reporting unhandled rejections.
|
4152
|
+
*/
|
4153
|
+
void MarkAsHandled();
|
4154
|
+
|
4037
4155
|
V8_INLINE static Promise* Cast(Value* obj);
|
4038
4156
|
|
4039
4157
|
static const int kEmbedderFieldCount = V8_PROMISE_INTERNAL_FIELD_COUNT;
|
@@ -4076,8 +4194,16 @@ class V8_EXPORT PropertyDescriptor {
|
|
4076
4194
|
// GenericDescriptor
|
4077
4195
|
PropertyDescriptor();
|
4078
4196
|
|
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
|
+
|
4079
4205
|
// DataDescriptor
|
4080
|
-
PropertyDescriptor(Local<Value> value);
|
4206
|
+
explicit PropertyDescriptor(Local<Value> value);
|
4081
4207
|
|
4082
4208
|
// DataDescriptor with writable property
|
4083
4209
|
PropertyDescriptor(Local<Value> value, bool writable);
|
@@ -4116,6 +4242,11 @@ class V8_EXPORT PropertyDescriptor {
|
|
4116
4242
|
PrivateData* private_;
|
4117
4243
|
};
|
4118
4244
|
|
4245
|
+
// TODO(clemensh): Remove after 7.3 branch.
|
4246
|
+
template <std::nullptr_t>
|
4247
|
+
PropertyDescriptor::PropertyDescriptor(Local<Value> value)
|
4248
|
+
: PropertyDescriptor(value) {}
|
4249
|
+
|
4119
4250
|
/**
|
4120
4251
|
* An instance of the built-in Proxy constructor (ECMA-262, 6th Edition,
|
4121
4252
|
* 26.2.1).
|
@@ -4141,19 +4272,97 @@ class V8_EXPORT Proxy : public Object {
|
|
4141
4272
|
static void CheckCast(Value* obj);
|
4142
4273
|
};
|
4143
4274
|
|
4144
|
-
|
4145
|
-
|
4146
|
-
|
4275
|
+
/**
|
4276
|
+
* Points to an unowned continous buffer holding a known number of elements.
|
4277
|
+
*
|
4278
|
+
* This is similar to std::span (under consideration for C++20), but does not
|
4279
|
+
* require advanced C++ support. In the (far) future, this may be replaced with
|
4280
|
+
* or aliased to std::span.
|
4281
|
+
*
|
4282
|
+
* To facilitate future migration, this class exposes a subset of the interface
|
4283
|
+
* implemented by std::span.
|
4284
|
+
*/
|
4285
|
+
template <typename T>
|
4286
|
+
class V8_EXPORT MemorySpan {
|
4287
|
+
public:
|
4288
|
+
/** The default constructor creates an empty span. */
|
4289
|
+
constexpr MemorySpan() = default;
|
4290
|
+
|
4291
|
+
constexpr MemorySpan(T* data, size_t size) : data_(data), size_(size) {}
|
4292
|
+
|
4293
|
+
/** Returns a pointer to the beginning of the buffer. */
|
4294
|
+
constexpr T* data() const { return data_; }
|
4295
|
+
/** Returns the number of elements that the buffer holds. */
|
4296
|
+
constexpr size_t size() const { return size_; }
|
4297
|
+
|
4298
|
+
private:
|
4299
|
+
T* data_ = nullptr;
|
4300
|
+
size_t size_ = 0;
|
4301
|
+
};
|
4302
|
+
|
4303
|
+
/**
|
4304
|
+
* An owned byte buffer with associated size.
|
4305
|
+
*/
|
4306
|
+
struct OwnedBuffer {
|
4307
|
+
std::unique_ptr<const uint8_t[]> buffer;
|
4308
|
+
size_t size = 0;
|
4309
|
+
OwnedBuffer(std::unique_ptr<const uint8_t[]> buffer, size_t size)
|
4310
|
+
: buffer(std::move(buffer)), size(size) {}
|
4311
|
+
OwnedBuffer() = default;
|
4312
|
+
};
|
4313
|
+
|
4314
|
+
// Wrapper around a compiled WebAssembly module, which is potentially shared by
|
4315
|
+
// different WasmModuleObjects.
|
4316
|
+
class V8_EXPORT CompiledWasmModule {
|
4317
|
+
public:
|
4318
|
+
/**
|
4319
|
+
* Serialize the compiled module. The serialized data does not include the
|
4320
|
+
* wire bytes.
|
4321
|
+
*/
|
4322
|
+
OwnedBuffer Serialize();
|
4323
|
+
|
4324
|
+
/**
|
4325
|
+
* Get the (wasm-encoded) wire bytes that were used to compile this module.
|
4326
|
+
*/
|
4327
|
+
MemorySpan<const uint8_t> GetWireBytesRef();
|
4328
|
+
|
4329
|
+
private:
|
4330
|
+
explicit CompiledWasmModule(std::shared_ptr<internal::wasm::NativeModule>);
|
4331
|
+
friend class Utils;
|
4332
|
+
|
4333
|
+
const std::shared_ptr<internal::wasm::NativeModule> native_module_;
|
4334
|
+
};
|
4335
|
+
|
4336
|
+
// An instance of WebAssembly.Module.
|
4337
|
+
class V8_EXPORT WasmModuleObject : public Object {
|
4147
4338
|
public:
|
4148
|
-
|
4339
|
+
// TODO(clemensh): Remove after 7.3 branch.
|
4340
|
+
V8_DEPRECATED("Use OwnedBuffer", typedef)
|
4341
|
+
std::pair<std::unique_ptr<const uint8_t[]>, size_t> SerializedModule;
|
4342
|
+
|
4149
4343
|
/**
|
4150
|
-
* A
|
4344
|
+
* A unowned reference to a byte buffer.
|
4345
|
+
* TODO(clemensh): Remove after 7.3 branch.
|
4151
4346
|
*/
|
4152
|
-
|
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
|
+
};
|
4153
4360
|
|
4154
4361
|
/**
|
4155
4362
|
* An opaque, native heap object for transferring wasm modules. It
|
4156
4363
|
* supports move semantics, and does not support copy semantics.
|
4364
|
+
* TODO(wasm): Merge this with CompiledWasmModule once code sharing is always
|
4365
|
+
* enabled.
|
4157
4366
|
*/
|
4158
4367
|
class TransferrableModule final {
|
4159
4368
|
public:
|
@@ -4164,13 +4373,16 @@ class V8_EXPORT WasmCompiledModule : public Object {
|
|
4164
4373
|
TransferrableModule& operator=(const TransferrableModule& src) = delete;
|
4165
4374
|
|
4166
4375
|
private:
|
4167
|
-
typedef std::
|
4168
|
-
friend class
|
4169
|
-
TransferrableModule(
|
4170
|
-
:
|
4171
|
-
|
4172
|
-
|
4173
|
-
|
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};
|
4174
4386
|
};
|
4175
4387
|
|
4176
4388
|
/**
|
@@ -4181,48 +4393,132 @@ class V8_EXPORT WasmCompiledModule : public Object {
|
|
4181
4393
|
TransferrableModule GetTransferrableModule();
|
4182
4394
|
|
4183
4395
|
/**
|
4184
|
-
* Efficiently re-create a
|
4396
|
+
* Efficiently re-create a WasmModuleObject, without recompiling, from
|
4185
4397
|
* a TransferrableModule.
|
4186
4398
|
*/
|
4187
|
-
static MaybeLocal<
|
4399
|
+
static MaybeLocal<WasmModuleObject> FromTransferrableModule(
|
4188
4400
|
Isolate* isolate, const TransferrableModule&);
|
4189
4401
|
|
4190
4402
|
/**
|
4191
4403
|
* Get the wasm-encoded bytes that were used to compile this module.
|
4192
4404
|
*/
|
4193
|
-
|
4405
|
+
V8_DEPRECATED("Use CompiledWasmModule::GetWireBytesRef()",
|
4406
|
+
BufferReference GetWasmWireBytesRef());
|
4407
|
+
|
4408
|
+
/**
|
4409
|
+
* Get the compiled module for this module object. The compiled module can be
|
4410
|
+
* shared by several module objects.
|
4411
|
+
*/
|
4412
|
+
CompiledWasmModule GetCompiledModule();
|
4194
4413
|
|
4195
4414
|
/**
|
4196
4415
|
* Serialize the compiled module. The serialized data does not include the
|
4197
4416
|
* uncompiled bytes.
|
4198
4417
|
*/
|
4199
|
-
|
4418
|
+
V8_DEPRECATED("Use CompiledWasmModule::Serialize()",
|
4419
|
+
SerializedModule Serialize());
|
4200
4420
|
|
4201
4421
|
/**
|
4202
4422
|
* If possible, deserialize the module, otherwise compile it from the provided
|
4203
4423
|
* uncompiled bytes.
|
4204
4424
|
*/
|
4205
|
-
static MaybeLocal<
|
4206
|
-
Isolate* isolate, const
|
4207
|
-
const
|
4208
|
-
V8_INLINE static
|
4425
|
+
static MaybeLocal<WasmModuleObject> DeserializeOrCompile(
|
4426
|
+
Isolate* isolate, MemorySpan<const uint8_t> serialized_module,
|
4427
|
+
MemorySpan<const uint8_t> wire_bytes);
|
4428
|
+
V8_INLINE static WasmModuleObject* Cast(Value* obj);
|
4209
4429
|
|
4210
4430
|
private:
|
4211
|
-
static MaybeLocal<
|
4212
|
-
Isolate* isolate, const
|
4213
|
-
const
|
4214
|
-
static MaybeLocal<
|
4215
|
-
|
4216
|
-
|
4217
|
-
static
|
4218
|
-
|
4219
|
-
return {buff.first.get(), buff.second};
|
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};
|
4220
4439
|
}
|
4221
4440
|
|
4222
|
-
|
4441
|
+
WasmModuleObject();
|
4223
4442
|
static void CheckCast(Value* obj);
|
4224
4443
|
};
|
4225
4444
|
|
4445
|
+
V8_DEPRECATED("Use WasmModuleObject",
|
4446
|
+
typedef WasmModuleObject WasmCompiledModule);
|
4447
|
+
|
4448
|
+
/**
|
4449
|
+
* The V8 interface for WebAssembly streaming compilation. When streaming
|
4450
|
+
* compilation is initiated, V8 passes a {WasmStreaming} object to the embedder
|
4451
|
+
* such that the embedder can pass the input bytes for streaming compilation to
|
4452
|
+
* V8.
|
4453
|
+
*/
|
4454
|
+
class V8_EXPORT WasmStreaming final {
|
4455
|
+
public:
|
4456
|
+
class WasmStreamingImpl;
|
4457
|
+
|
4458
|
+
/**
|
4459
|
+
* Client to receive streaming event notifications.
|
4460
|
+
*/
|
4461
|
+
class Client {
|
4462
|
+
public:
|
4463
|
+
virtual ~Client() = default;
|
4464
|
+
/**
|
4465
|
+
* Passes the fully compiled module to the client. This can be used to
|
4466
|
+
* implement code caching.
|
4467
|
+
*/
|
4468
|
+
virtual void OnModuleCompiled(CompiledWasmModule compiled_module) = 0;
|
4469
|
+
};
|
4470
|
+
|
4471
|
+
explicit WasmStreaming(std::unique_ptr<WasmStreamingImpl> impl);
|
4472
|
+
|
4473
|
+
~WasmStreaming();
|
4474
|
+
|
4475
|
+
/**
|
4476
|
+
* Pass a new chunk of bytes to WebAssembly streaming compilation.
|
4477
|
+
* The buffer passed into {OnBytesReceived} is owned by the caller.
|
4478
|
+
*/
|
4479
|
+
void OnBytesReceived(const uint8_t* bytes, size_t size);
|
4480
|
+
|
4481
|
+
/**
|
4482
|
+
* {Finish} should be called after all received bytes where passed to
|
4483
|
+
* {OnBytesReceived} to tell V8 that there will be no more bytes. {Finish}
|
4484
|
+
* does not have to be called after {Abort} has been called already.
|
4485
|
+
*/
|
4486
|
+
void Finish();
|
4487
|
+
|
4488
|
+
/**
|
4489
|
+
* Abort streaming compilation. If {exception} has a value, then the promise
|
4490
|
+
* associated with streaming compilation is rejected with that value. If
|
4491
|
+
* {exception} does not have value, the promise does not get rejected.
|
4492
|
+
*/
|
4493
|
+
void Abort(MaybeLocal<Value> exception);
|
4494
|
+
|
4495
|
+
/**
|
4496
|
+
* Passes previously compiled module bytes. This must be called before
|
4497
|
+
* {OnBytesReceived}, {Finish}, or {Abort}. Returns true if the module bytes
|
4498
|
+
* can be used, false otherwise. The buffer passed via {bytes} and {size}
|
4499
|
+
* is owned by the caller. If {SetCompiledModuleBytes} returns true, the
|
4500
|
+
* buffer must remain valid until either {Finish} or {Abort} completes.
|
4501
|
+
*/
|
4502
|
+
bool SetCompiledModuleBytes(const uint8_t* bytes, size_t size);
|
4503
|
+
|
4504
|
+
/**
|
4505
|
+
* Sets the client object that will receive streaming event notifications.
|
4506
|
+
* This must be called before {OnBytesReceived}, {Finish}, or {Abort}.
|
4507
|
+
*/
|
4508
|
+
void SetClient(std::shared_ptr<Client> client);
|
4509
|
+
|
4510
|
+
/**
|
4511
|
+
* Unpacks a {WasmStreaming} object wrapped in a {Managed} for the embedder.
|
4512
|
+
* Since the embedder is on the other side of the API, it cannot unpack the
|
4513
|
+
* {Managed} itself.
|
4514
|
+
*/
|
4515
|
+
static std::shared_ptr<WasmStreaming> Unpack(Isolate* isolate,
|
4516
|
+
Local<Value> value);
|
4517
|
+
|
4518
|
+
private:
|
4519
|
+
std::unique_ptr<WasmStreamingImpl> impl_;
|
4520
|
+
};
|
4521
|
+
|
4226
4522
|
// TODO(mtrofin): when streaming compilation is done, we can rename this
|
4227
4523
|
// to simply WasmModuleObjectBuilder
|
4228
4524
|
class V8_EXPORT WasmModuleObjectBuilderStreaming final {
|
@@ -4241,11 +4537,9 @@ class V8_EXPORT WasmModuleObjectBuilderStreaming final {
|
|
4241
4537
|
void Abort(MaybeLocal<Value> exception);
|
4242
4538
|
Local<Promise> GetPromise();
|
4243
4539
|
|
4244
|
-
~WasmModuleObjectBuilderStreaming();
|
4540
|
+
~WasmModuleObjectBuilderStreaming() = default;
|
4245
4541
|
|
4246
4542
|
private:
|
4247
|
-
typedef std::pair<std::unique_ptr<const uint8_t[]>, size_t> Buffer;
|
4248
|
-
|
4249
4543
|
WasmModuleObjectBuilderStreaming(const WasmModuleObjectBuilderStreaming&) =
|
4250
4544
|
delete;
|
4251
4545
|
WasmModuleObjectBuilderStreaming(WasmModuleObjectBuilderStreaming&&) =
|
@@ -4268,8 +4562,6 @@ class V8_EXPORT WasmModuleObjectBuilderStreaming final {
|
|
4268
4562
|
#else
|
4269
4563
|
Persistent<Promise> promise_;
|
4270
4564
|
#endif
|
4271
|
-
std::vector<Buffer> received_buffers_;
|
4272
|
-
size_t total_size_ = 0;
|
4273
4565
|
std::shared_ptr<internal::wasm::StreamingDecoder> streaming_decoder_;
|
4274
4566
|
};
|
4275
4567
|
|
@@ -4304,7 +4596,7 @@ class V8_EXPORT ArrayBuffer : public Object {
|
|
4304
4596
|
*/
|
4305
4597
|
class V8_EXPORT Allocator { // NOLINT
|
4306
4598
|
public:
|
4307
|
-
virtual ~Allocator()
|
4599
|
+
virtual ~Allocator() = default;
|
4308
4600
|
|
4309
4601
|
/**
|
4310
4602
|
* Allocate |length| bytes. Return NULL if allocation is not successful.
|
@@ -4345,17 +4637,22 @@ class V8_EXPORT ArrayBuffer : public Object {
|
|
4345
4637
|
* returns an instance of this class, populated, with a pointer to data
|
4346
4638
|
* and byte length.
|
4347
4639
|
*
|
4348
|
-
* The Data pointer of ArrayBuffer::Contents
|
4349
|
-
* Allocator::
|
4640
|
+
* The Data pointer of ArrayBuffer::Contents must be freed using the provided
|
4641
|
+
* deleter, which will call ArrayBuffer::Allocator::Free if the buffer
|
4642
|
+
* was allocated with ArraryBuffer::Allocator::Allocate.
|
4350
4643
|
*/
|
4351
4644
|
class V8_EXPORT Contents { // NOLINT
|
4352
4645
|
public:
|
4646
|
+
using DeleterCallback = void (*)(void* buffer, size_t length, void* info);
|
4647
|
+
|
4353
4648
|
Contents()
|
4354
4649
|
: data_(nullptr),
|
4355
4650
|
byte_length_(0),
|
4356
4651
|
allocation_base_(nullptr),
|
4357
4652
|
allocation_length_(0),
|
4358
|
-
allocation_mode_(Allocator::AllocationMode::kNormal)
|
4653
|
+
allocation_mode_(Allocator::AllocationMode::kNormal),
|
4654
|
+
deleter_(nullptr),
|
4655
|
+
deleter_data_(nullptr) {}
|
4359
4656
|
|
4360
4657
|
void* AllocationBase() const { return allocation_base_; }
|
4361
4658
|
size_t AllocationLength() const { return allocation_length_; }
|
@@ -4365,13 +4662,22 @@ class V8_EXPORT ArrayBuffer : public Object {
|
|
4365
4662
|
|
4366
4663
|
void* Data() const { return data_; }
|
4367
4664
|
size_t ByteLength() const { return byte_length_; }
|
4665
|
+
DeleterCallback Deleter() const { return deleter_; }
|
4666
|
+
void* DeleterData() const { return deleter_data_; }
|
4368
4667
|
|
4369
4668
|
private:
|
4669
|
+
Contents(void* data, size_t byte_length, void* allocation_base,
|
4670
|
+
size_t allocation_length,
|
4671
|
+
Allocator::AllocationMode allocation_mode, DeleterCallback deleter,
|
4672
|
+
void* deleter_data);
|
4673
|
+
|
4370
4674
|
void* data_;
|
4371
4675
|
size_t byte_length_;
|
4372
4676
|
void* allocation_base_;
|
4373
4677
|
size_t allocation_length_;
|
4374
4678
|
Allocator::AllocationMode allocation_mode_;
|
4679
|
+
DeleterCallback deleter_;
|
4680
|
+
void* deleter_data_;
|
4375
4681
|
|
4376
4682
|
friend class ArrayBuffer;
|
4377
4683
|
};
|
@@ -4410,17 +4716,26 @@ class V8_EXPORT ArrayBuffer : public Object {
|
|
4410
4716
|
bool IsExternal() const;
|
4411
4717
|
|
4412
4718
|
/**
|
4413
|
-
* Returns true if this ArrayBuffer may be
|
4719
|
+
* Returns true if this ArrayBuffer may be detached.
|
4414
4720
|
*/
|
4415
|
-
bool
|
4721
|
+
bool IsDetachable() const;
|
4722
|
+
|
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
|
+
}
|
4416
4728
|
|
4417
4729
|
/**
|
4418
|
-
*
|
4419
|
-
*
|
4730
|
+
* Detaches this ArrayBuffer and all its views (typed arrays).
|
4731
|
+
* Detaching sets the byte length of the buffer and all typed arrays to zero,
|
4420
4732
|
* preventing JavaScript from ever accessing underlying backing store.
|
4421
|
-
* ArrayBuffer should have been externalized and must be
|
4733
|
+
* ArrayBuffer should have been externalized and must be detachable.
|
4422
4734
|
*/
|
4423
|
-
void
|
4735
|
+
void Detach();
|
4736
|
+
|
4737
|
+
// TODO(913887): fix the use of 'neuter' in the API.
|
4738
|
+
V8_DEPRECATE_SOON("Use Detach() instead.", inline void Neuter()) { Detach(); }
|
4424
4739
|
|
4425
4740
|
/**
|
4426
4741
|
* Make this ArrayBuffer external. The pointer to underlying memory block
|
@@ -4428,8 +4743,9 @@ class V8_EXPORT ArrayBuffer : public Object {
|
|
4428
4743
|
* had been externalized, it does no longer own the memory block. The caller
|
4429
4744
|
* should take steps to free memory when it is no longer needed.
|
4430
4745
|
*
|
4431
|
-
* The
|
4432
|
-
*
|
4746
|
+
* The Data pointer of ArrayBuffer::Contents must be freed using the provided
|
4747
|
+
* deleter, which will call ArrayBuffer::Allocator::Free if the buffer
|
4748
|
+
* was allocated with ArraryBuffer::Allocator::Allocate.
|
4433
4749
|
*/
|
4434
4750
|
Contents Externalize();
|
4435
4751
|
|
@@ -4440,8 +4756,6 @@ class V8_EXPORT ArrayBuffer : public Object {
|
|
4440
4756
|
*
|
4441
4757
|
* The embedder should make sure to hold a strong reference to the
|
4442
4758
|
* ArrayBuffer while accessing this pointer.
|
4443
|
-
*
|
4444
|
-
* The memory block is guaranteed to be allocated with |Allocator::Allocate|.
|
4445
4759
|
*/
|
4446
4760
|
Contents GetContents();
|
4447
4761
|
|
@@ -4520,8 +4834,7 @@ class V8_EXPORT TypedArray : public ArrayBufferView {
|
|
4520
4834
|
/*
|
4521
4835
|
* The largest typed array size that can be constructed using New.
|
4522
4836
|
*/
|
4523
|
-
static constexpr size_t kMaxLength =
|
4524
|
-
sizeof(void*) == 4 ? (1u << 30) - 1 : (1u << 31) - 1;
|
4837
|
+
static constexpr size_t kMaxLength = internal::kSmiMaxValue;
|
4525
4838
|
|
4526
4839
|
/**
|
4527
4840
|
* Number of elements in this typed array
|
@@ -4749,41 +5062,54 @@ class V8_EXPORT SharedArrayBuffer : public Object {
|
|
4749
5062
|
* |SharedArrayBuffer| returns an instance of this class, populated, with a
|
4750
5063
|
* pointer to data and byte length.
|
4751
5064
|
*
|
4752
|
-
* The Data pointer of
|
4753
|
-
*
|
4754
|
-
*
|
5065
|
+
* The Data pointer of ArrayBuffer::Contents must be freed using the provided
|
5066
|
+
* deleter, which will call ArrayBuffer::Allocator::Free if the buffer
|
5067
|
+
* was allocated with ArraryBuffer::Allocator::Allocate.
|
4755
5068
|
*
|
4756
5069
|
* This API is experimental and may change significantly.
|
4757
5070
|
*/
|
4758
5071
|
class V8_EXPORT Contents { // NOLINT
|
4759
5072
|
public:
|
5073
|
+
using Allocator = v8::ArrayBuffer::Allocator;
|
5074
|
+
using DeleterCallback = void (*)(void* buffer, size_t length, void* info);
|
5075
|
+
|
4760
5076
|
Contents()
|
4761
5077
|
: data_(nullptr),
|
4762
5078
|
byte_length_(0),
|
4763
5079
|
allocation_base_(nullptr),
|
4764
5080
|
allocation_length_(0),
|
4765
|
-
allocation_mode_(
|
5081
|
+
allocation_mode_(Allocator::AllocationMode::kNormal),
|
5082
|
+
deleter_(nullptr),
|
5083
|
+
deleter_data_(nullptr) {}
|
4766
5084
|
|
4767
5085
|
void* AllocationBase() const { return allocation_base_; }
|
4768
5086
|
size_t AllocationLength() const { return allocation_length_; }
|
4769
|
-
|
5087
|
+
Allocator::AllocationMode AllocationMode() const {
|
4770
5088
|
return allocation_mode_;
|
4771
5089
|
}
|
4772
5090
|
|
4773
5091
|
void* Data() const { return data_; }
|
4774
5092
|
size_t ByteLength() const { return byte_length_; }
|
5093
|
+
DeleterCallback Deleter() const { return deleter_; }
|
5094
|
+
void* DeleterData() const { return deleter_data_; }
|
4775
5095
|
|
4776
5096
|
private:
|
5097
|
+
Contents(void* data, size_t byte_length, void* allocation_base,
|
5098
|
+
size_t allocation_length,
|
5099
|
+
Allocator::AllocationMode allocation_mode, DeleterCallback deleter,
|
5100
|
+
void* deleter_data);
|
5101
|
+
|
4777
5102
|
void* data_;
|
4778
5103
|
size_t byte_length_;
|
4779
5104
|
void* allocation_base_;
|
4780
5105
|
size_t allocation_length_;
|
4781
|
-
|
5106
|
+
Allocator::AllocationMode allocation_mode_;
|
5107
|
+
DeleterCallback deleter_;
|
5108
|
+
void* deleter_data_;
|
4782
5109
|
|
4783
5110
|
friend class SharedArrayBuffer;
|
4784
5111
|
};
|
4785
5112
|
|
4786
|
-
|
4787
5113
|
/**
|
4788
5114
|
* Data length in bytes.
|
4789
5115
|
*/
|
@@ -4856,8 +5182,6 @@ class V8_EXPORT SharedArrayBuffer : public Object {
|
|
4856
5182
|
*/
|
4857
5183
|
class V8_EXPORT Date : public Object {
|
4858
5184
|
public:
|
4859
|
-
static V8_DEPRECATE_SOON("Use maybe version.",
|
4860
|
-
Local<Value> New(Isolate* isolate, double time));
|
4861
5185
|
static V8_WARN_UNUSED_RESULT MaybeLocal<Value> New(Local<Context> context,
|
4862
5186
|
double time);
|
4863
5187
|
|
@@ -4939,7 +5263,7 @@ class V8_EXPORT BooleanObject : public Object {
|
|
4939
5263
|
*/
|
4940
5264
|
class V8_EXPORT StringObject : public Object {
|
4941
5265
|
public:
|
4942
|
-
static Local<Value> New(Local<String> value);
|
5266
|
+
static Local<Value> New(Isolate* isolate, Local<String> value);
|
4943
5267
|
|
4944
5268
|
Local<String> ValueOf() const;
|
4945
5269
|
|
@@ -4995,8 +5319,6 @@ class V8_EXPORT RegExp : public Object {
|
|
4995
5319
|
* static_cast<RegExp::Flags>(kGlobal | kMultiline))
|
4996
5320
|
* is equivalent to evaluating "/foo/gm".
|
4997
5321
|
*/
|
4998
|
-
static V8_DEPRECATED("Use maybe version",
|
4999
|
-
Local<RegExp> New(Local<String> pattern, Flags flags));
|
5000
5322
|
static V8_WARN_UNUSED_RESULT MaybeLocal<RegExp> New(Local<Context> context,
|
5001
5323
|
Local<String> pattern,
|
5002
5324
|
Flags flags);
|
@@ -5102,26 +5424,32 @@ class V8_EXPORT Template : public Data {
|
|
5102
5424
|
*/
|
5103
5425
|
void SetNativeDataProperty(
|
5104
5426
|
Local<String> name, AccessorGetterCallback getter,
|
5105
|
-
AccessorSetterCallback setter =
|
5427
|
+
AccessorSetterCallback setter = nullptr,
|
5106
5428
|
// TODO(dcarney): gcc can't handle Local below
|
5107
5429
|
Local<Value> data = Local<Value>(), PropertyAttribute attribute = None,
|
5108
5430
|
Local<AccessorSignature> signature = Local<AccessorSignature>(),
|
5109
|
-
AccessControl settings = DEFAULT
|
5431
|
+
AccessControl settings = DEFAULT,
|
5432
|
+
SideEffectType getter_side_effect_type = SideEffectType::kHasSideEffect,
|
5433
|
+
SideEffectType setter_side_effect_type = SideEffectType::kHasSideEffect);
|
5110
5434
|
void SetNativeDataProperty(
|
5111
5435
|
Local<Name> name, AccessorNameGetterCallback getter,
|
5112
|
-
AccessorNameSetterCallback setter =
|
5436
|
+
AccessorNameSetterCallback setter = nullptr,
|
5113
5437
|
// TODO(dcarney): gcc can't handle Local below
|
5114
5438
|
Local<Value> data = Local<Value>(), PropertyAttribute attribute = None,
|
5115
5439
|
Local<AccessorSignature> signature = Local<AccessorSignature>(),
|
5116
|
-
AccessControl settings = DEFAULT
|
5440
|
+
AccessControl settings = DEFAULT,
|
5441
|
+
SideEffectType getter_side_effect_type = SideEffectType::kHasSideEffect,
|
5442
|
+
SideEffectType setter_side_effect_type = SideEffectType::kHasSideEffect);
|
5117
5443
|
|
5118
5444
|
/**
|
5119
5445
|
* Like SetNativeDataProperty, but V8 will replace the native data property
|
5120
5446
|
* with a real data property on first access.
|
5121
5447
|
*/
|
5122
|
-
void SetLazyDataProperty(
|
5123
|
-
|
5124
|
-
|
5448
|
+
void SetLazyDataProperty(
|
5449
|
+
Local<Name> name, AccessorNameGetterCallback getter,
|
5450
|
+
Local<Value> data = Local<Value>(), PropertyAttribute attribute = None,
|
5451
|
+
SideEffectType getter_side_effect_type = SideEffectType::kHasSideEffect,
|
5452
|
+
SideEffectType setter_side_effect_type = SideEffectType::kHasSideEffect);
|
5125
5453
|
|
5126
5454
|
/**
|
5127
5455
|
* During template instantiation, sets the value with the intrinsic property
|
@@ -5137,60 +5465,11 @@ class V8_EXPORT Template : public Data {
|
|
5137
5465
|
friend class FunctionTemplate;
|
5138
5466
|
};
|
5139
5467
|
|
5468
|
+
// TODO(dcarney): Replace GenericNamedPropertyFooCallback with just
|
5469
|
+
// NamedPropertyFooCallback.
|
5140
5470
|
|
5141
5471
|
/**
|
5142
|
-
*
|
5143
|
-
* See ObjectTemplate::SetNamedPropertyHandler.
|
5144
|
-
*/
|
5145
|
-
typedef void (*NamedPropertyGetterCallback)(
|
5146
|
-
Local<String> property,
|
5147
|
-
const PropertyCallbackInfo<Value>& info);
|
5148
|
-
|
5149
|
-
|
5150
|
-
/**
|
5151
|
-
* Returns the value if the setter intercepts the request.
|
5152
|
-
* Otherwise, returns an empty handle.
|
5153
|
-
*/
|
5154
|
-
typedef void (*NamedPropertySetterCallback)(
|
5155
|
-
Local<String> property,
|
5156
|
-
Local<Value> value,
|
5157
|
-
const PropertyCallbackInfo<Value>& info);
|
5158
|
-
|
5159
|
-
|
5160
|
-
/**
|
5161
|
-
* Returns a non-empty handle if the interceptor intercepts the request.
|
5162
|
-
* The result is an integer encoding property attributes (like v8::None,
|
5163
|
-
* v8::DontEnum, etc.)
|
5164
|
-
*/
|
5165
|
-
typedef void (*NamedPropertyQueryCallback)(
|
5166
|
-
Local<String> property,
|
5167
|
-
const PropertyCallbackInfo<Integer>& info);
|
5168
|
-
|
5169
|
-
|
5170
|
-
/**
|
5171
|
-
* Returns a non-empty handle if the deleter intercepts the request.
|
5172
|
-
* The return value is true if the property could be deleted and false
|
5173
|
-
* otherwise.
|
5174
|
-
*/
|
5175
|
-
typedef void (*NamedPropertyDeleterCallback)(
|
5176
|
-
Local<String> property,
|
5177
|
-
const PropertyCallbackInfo<Boolean>& info);
|
5178
|
-
|
5179
|
-
/**
|
5180
|
-
* Returns an array containing the names of the properties the named
|
5181
|
-
* property getter intercepts.
|
5182
|
-
*
|
5183
|
-
* Note: The values in the array must be of type v8::Name.
|
5184
|
-
*/
|
5185
|
-
typedef void (*NamedPropertyEnumeratorCallback)(
|
5186
|
-
const PropertyCallbackInfo<Array>& info);
|
5187
|
-
|
5188
|
-
|
5189
|
-
// TODO(dcarney): Deprecate and remove previous typedefs, and replace
|
5190
|
-
// GenericNamedPropertyFooCallback with just NamedPropertyFooCallback.
|
5191
|
-
|
5192
|
-
/**
|
5193
|
-
* Interceptor for get requests on an object.
|
5472
|
+
* Interceptor for get requests on an object.
|
5194
5473
|
*
|
5195
5474
|
* Use `info.GetReturnValue().Set()` to set the return value of the
|
5196
5475
|
* intercepted get request.
|
@@ -5531,7 +5810,7 @@ class V8_EXPORT FunctionTemplate : public Template {
|
|
5531
5810
|
public:
|
5532
5811
|
/** Creates a function template.*/
|
5533
5812
|
static Local<FunctionTemplate> New(
|
5534
|
-
Isolate* isolate, FunctionCallback callback =
|
5813
|
+
Isolate* isolate, FunctionCallback callback = nullptr,
|
5535
5814
|
Local<Value> data = Local<Value>(),
|
5536
5815
|
Local<Signature> signature = Local<Signature>(), int length = 0,
|
5537
5816
|
ConstructorBehavior behavior = ConstructorBehavior::kAllow,
|
@@ -5551,7 +5830,7 @@ class V8_EXPORT FunctionTemplate : public Template {
|
|
5551
5830
|
SideEffectType side_effect_type = SideEffectType::kHasSideEffect);
|
5552
5831
|
|
5553
5832
|
/** Returns the unique function instance in the current execution context.*/
|
5554
|
-
|
5833
|
+
V8_DEPRECATED("Use maybe version", Local<Function> GetFunction());
|
5555
5834
|
V8_WARN_UNUSED_RESULT MaybeLocal<Function> GetFunction(
|
5556
5835
|
Local<Context> context);
|
5557
5836
|
|
@@ -5690,13 +5969,33 @@ enum class PropertyHandlerFlags {
|
|
5690
5969
|
};
|
5691
5970
|
|
5692
5971
|
struct NamedPropertyHandlerConfiguration {
|
5972
|
+
NamedPropertyHandlerConfiguration(
|
5973
|
+
GenericNamedPropertyGetterCallback getter,
|
5974
|
+
GenericNamedPropertySetterCallback setter,
|
5975
|
+
GenericNamedPropertyQueryCallback query,
|
5976
|
+
GenericNamedPropertyDeleterCallback deleter,
|
5977
|
+
GenericNamedPropertyEnumeratorCallback enumerator,
|
5978
|
+
GenericNamedPropertyDefinerCallback definer,
|
5979
|
+
GenericNamedPropertyDescriptorCallback descriptor,
|
5980
|
+
Local<Value> data = Local<Value>(),
|
5981
|
+
PropertyHandlerFlags flags = PropertyHandlerFlags::kNone)
|
5982
|
+
: getter(getter),
|
5983
|
+
setter(setter),
|
5984
|
+
query(query),
|
5985
|
+
deleter(deleter),
|
5986
|
+
enumerator(enumerator),
|
5987
|
+
definer(definer),
|
5988
|
+
descriptor(descriptor),
|
5989
|
+
data(data),
|
5990
|
+
flags(flags) {}
|
5991
|
+
|
5693
5992
|
NamedPropertyHandlerConfiguration(
|
5694
5993
|
/** Note: getter is required */
|
5695
|
-
GenericNamedPropertyGetterCallback getter =
|
5696
|
-
GenericNamedPropertySetterCallback setter =
|
5697
|
-
GenericNamedPropertyQueryCallback query =
|
5698
|
-
GenericNamedPropertyDeleterCallback deleter =
|
5699
|
-
GenericNamedPropertyEnumeratorCallback enumerator =
|
5994
|
+
GenericNamedPropertyGetterCallback getter = nullptr,
|
5995
|
+
GenericNamedPropertySetterCallback setter = nullptr,
|
5996
|
+
GenericNamedPropertyQueryCallback query = nullptr,
|
5997
|
+
GenericNamedPropertyDeleterCallback deleter = nullptr,
|
5998
|
+
GenericNamedPropertyEnumeratorCallback enumerator = nullptr,
|
5700
5999
|
Local<Value> data = Local<Value>(),
|
5701
6000
|
PropertyHandlerFlags flags = PropertyHandlerFlags::kNone)
|
5702
6001
|
: getter(getter),
|
@@ -5704,8 +6003,8 @@ struct NamedPropertyHandlerConfiguration {
|
|
5704
6003
|
query(query),
|
5705
6004
|
deleter(deleter),
|
5706
6005
|
enumerator(enumerator),
|
5707
|
-
definer(
|
5708
|
-
descriptor(
|
6006
|
+
definer(nullptr),
|
6007
|
+
descriptor(nullptr),
|
5709
6008
|
data(data),
|
5710
6009
|
flags(flags) {}
|
5711
6010
|
|
@@ -5720,7 +6019,7 @@ struct NamedPropertyHandlerConfiguration {
|
|
5720
6019
|
PropertyHandlerFlags flags = PropertyHandlerFlags::kNone)
|
5721
6020
|
: getter(getter),
|
5722
6021
|
setter(setter),
|
5723
|
-
query(
|
6022
|
+
query(nullptr),
|
5724
6023
|
deleter(deleter),
|
5725
6024
|
enumerator(enumerator),
|
5726
6025
|
definer(definer),
|
@@ -5741,13 +6040,32 @@ struct NamedPropertyHandlerConfiguration {
|
|
5741
6040
|
|
5742
6041
|
|
5743
6042
|
struct IndexedPropertyHandlerConfiguration {
|
6043
|
+
IndexedPropertyHandlerConfiguration(
|
6044
|
+
IndexedPropertyGetterCallback getter,
|
6045
|
+
IndexedPropertySetterCallback setter, IndexedPropertyQueryCallback query,
|
6046
|
+
IndexedPropertyDeleterCallback deleter,
|
6047
|
+
IndexedPropertyEnumeratorCallback enumerator,
|
6048
|
+
IndexedPropertyDefinerCallback definer,
|
6049
|
+
IndexedPropertyDescriptorCallback descriptor,
|
6050
|
+
Local<Value> data = Local<Value>(),
|
6051
|
+
PropertyHandlerFlags flags = PropertyHandlerFlags::kNone)
|
6052
|
+
: getter(getter),
|
6053
|
+
setter(setter),
|
6054
|
+
query(query),
|
6055
|
+
deleter(deleter),
|
6056
|
+
enumerator(enumerator),
|
6057
|
+
definer(definer),
|
6058
|
+
descriptor(descriptor),
|
6059
|
+
data(data),
|
6060
|
+
flags(flags) {}
|
6061
|
+
|
5744
6062
|
IndexedPropertyHandlerConfiguration(
|
5745
6063
|
/** Note: getter is required */
|
5746
|
-
IndexedPropertyGetterCallback getter =
|
5747
|
-
IndexedPropertySetterCallback setter =
|
5748
|
-
IndexedPropertyQueryCallback query =
|
5749
|
-
IndexedPropertyDeleterCallback deleter =
|
5750
|
-
IndexedPropertyEnumeratorCallback enumerator =
|
6064
|
+
IndexedPropertyGetterCallback getter = nullptr,
|
6065
|
+
IndexedPropertySetterCallback setter = nullptr,
|
6066
|
+
IndexedPropertyQueryCallback query = nullptr,
|
6067
|
+
IndexedPropertyDeleterCallback deleter = nullptr,
|
6068
|
+
IndexedPropertyEnumeratorCallback enumerator = nullptr,
|
5751
6069
|
Local<Value> data = Local<Value>(),
|
5752
6070
|
PropertyHandlerFlags flags = PropertyHandlerFlags::kNone)
|
5753
6071
|
: getter(getter),
|
@@ -5755,8 +6073,8 @@ struct IndexedPropertyHandlerConfiguration {
|
|
5755
6073
|
query(query),
|
5756
6074
|
deleter(deleter),
|
5757
6075
|
enumerator(enumerator),
|
5758
|
-
definer(
|
5759
|
-
descriptor(
|
6076
|
+
definer(nullptr),
|
6077
|
+
descriptor(nullptr),
|
5760
6078
|
data(data),
|
5761
6079
|
flags(flags) {}
|
5762
6080
|
|
@@ -5771,7 +6089,7 @@ struct IndexedPropertyHandlerConfiguration {
|
|
5771
6089
|
PropertyHandlerFlags flags = PropertyHandlerFlags::kNone)
|
5772
6090
|
: getter(getter),
|
5773
6091
|
setter(setter),
|
5774
|
-
query(
|
6092
|
+
query(nullptr),
|
5775
6093
|
deleter(deleter),
|
5776
6094
|
enumerator(enumerator),
|
5777
6095
|
definer(definer),
|
@@ -5809,7 +6127,7 @@ class V8_EXPORT ObjectTemplate : public Template {
|
|
5809
6127
|
size_t index);
|
5810
6128
|
|
5811
6129
|
/** Creates a new instance of this template.*/
|
5812
|
-
|
6130
|
+
V8_DEPRECATED("Use maybe version", Local<Object> NewInstance());
|
5813
6131
|
V8_WARN_UNUSED_RESULT MaybeLocal<Object> NewInstance(Local<Context> context);
|
5814
6132
|
|
5815
6133
|
/**
|
@@ -5843,47 +6161,20 @@ class V8_EXPORT ObjectTemplate : public Template {
|
|
5843
6161
|
*/
|
5844
6162
|
void SetAccessor(
|
5845
6163
|
Local<String> name, AccessorGetterCallback getter,
|
5846
|
-
AccessorSetterCallback setter =
|
5847
|
-
|
5848
|
-
|
6164
|
+
AccessorSetterCallback setter = nullptr,
|
6165
|
+
Local<Value> data = Local<Value>(), AccessControl settings = DEFAULT,
|
6166
|
+
PropertyAttribute attribute = None,
|
6167
|
+
Local<AccessorSignature> signature = Local<AccessorSignature>(),
|
6168
|
+
SideEffectType getter_side_effect_type = SideEffectType::kHasSideEffect,
|
6169
|
+
SideEffectType setter_side_effect_type = SideEffectType::kHasSideEffect);
|
5849
6170
|
void SetAccessor(
|
5850
6171
|
Local<Name> name, AccessorNameGetterCallback getter,
|
5851
|
-
AccessorNameSetterCallback setter =
|
5852
|
-
|
5853
|
-
|
5854
|
-
|
5855
|
-
|
5856
|
-
|
5857
|
-
*
|
5858
|
-
* Whenever a property whose name is a string is accessed on objects created
|
5859
|
-
* from this object template, the provided callback is invoked instead of
|
5860
|
-
* accessing the property directly on the JavaScript object.
|
5861
|
-
*
|
5862
|
-
* SetNamedPropertyHandler() is different from SetHandler(), in
|
5863
|
-
* that the latter can intercept symbol-named properties as well as
|
5864
|
-
* string-named properties when called with a
|
5865
|
-
* NamedPropertyHandlerConfiguration. New code should use SetHandler().
|
5866
|
-
*
|
5867
|
-
* \param getter The callback to invoke when getting a property.
|
5868
|
-
* \param setter The callback to invoke when setting a property.
|
5869
|
-
* \param query The callback to invoke to check if a property is present,
|
5870
|
-
* and if present, get its attributes.
|
5871
|
-
* \param deleter The callback to invoke when deleting a property.
|
5872
|
-
* \param enumerator The callback to invoke to enumerate all the named
|
5873
|
-
* properties of an object.
|
5874
|
-
* \param data A piece of data that will be passed to the callbacks
|
5875
|
-
* whenever they are invoked.
|
5876
|
-
*/
|
5877
|
-
V8_DEPRECATED(
|
5878
|
-
"Use SetHandler(const NamedPropertyHandlerConfiguration) "
|
5879
|
-
"with the kOnlyInterceptStrings flag set.",
|
5880
|
-
void SetNamedPropertyHandler(
|
5881
|
-
NamedPropertyGetterCallback getter,
|
5882
|
-
NamedPropertySetterCallback setter = 0,
|
5883
|
-
NamedPropertyQueryCallback query = 0,
|
5884
|
-
NamedPropertyDeleterCallback deleter = 0,
|
5885
|
-
NamedPropertyEnumeratorCallback enumerator = 0,
|
5886
|
-
Local<Value> data = Local<Value>()));
|
6172
|
+
AccessorNameSetterCallback setter = nullptr,
|
6173
|
+
Local<Value> data = Local<Value>(), AccessControl settings = DEFAULT,
|
6174
|
+
PropertyAttribute attribute = None,
|
6175
|
+
Local<AccessorSignature> signature = Local<AccessorSignature>(),
|
6176
|
+
SideEffectType getter_side_effect_type = SideEffectType::kHasSideEffect,
|
6177
|
+
SideEffectType setter_side_effect_type = SideEffectType::kHasSideEffect);
|
5887
6178
|
|
5888
6179
|
/**
|
5889
6180
|
* Sets a named property handler on the object template.
|
@@ -5917,10 +6208,10 @@ class V8_EXPORT ObjectTemplate : public Template {
|
|
5917
6208
|
// TODO(dcarney): deprecate
|
5918
6209
|
void SetIndexedPropertyHandler(
|
5919
6210
|
IndexedPropertyGetterCallback getter,
|
5920
|
-
IndexedPropertySetterCallback setter =
|
5921
|
-
IndexedPropertyQueryCallback query =
|
5922
|
-
IndexedPropertyDeleterCallback deleter =
|
5923
|
-
IndexedPropertyEnumeratorCallback enumerator =
|
6211
|
+
IndexedPropertySetterCallback setter = nullptr,
|
6212
|
+
IndexedPropertyQueryCallback query = nullptr,
|
6213
|
+
IndexedPropertyDeleterCallback deleter = nullptr,
|
6214
|
+
IndexedPropertyEnumeratorCallback enumerator = nullptr,
|
5924
6215
|
Local<Value> data = Local<Value>()) {
|
5925
6216
|
SetHandler(IndexedPropertyHandlerConfiguration(getter, setter, query,
|
5926
6217
|
deleter, enumerator, data));
|
@@ -6056,15 +6347,15 @@ class V8_EXPORT AccessorSignature : public Data {
|
|
6056
6347
|
|
6057
6348
|
|
6058
6349
|
// --- Extensions ---
|
6059
|
-
|
6060
|
-
|
6350
|
+
V8_DEPRECATED("Implementation detail", class)
|
6351
|
+
V8_EXPORT ExternalOneByteStringResourceImpl
|
6061
6352
|
: public String::ExternalOneByteStringResource {
|
6062
6353
|
public:
|
6063
|
-
ExternalOneByteStringResourceImpl() : data_(
|
6354
|
+
ExternalOneByteStringResourceImpl() : data_(nullptr), length_(0) {}
|
6064
6355
|
ExternalOneByteStringResourceImpl(const char* data, size_t length)
|
6065
6356
|
: data_(data), length_(length) {}
|
6066
|
-
const char* data() const { return data_; }
|
6067
|
-
size_t length() const { return length_; }
|
6357
|
+
const char* data() const override { return data_; }
|
6358
|
+
size_t length() const override { return length_; }
|
6068
6359
|
|
6069
6360
|
private:
|
6070
6361
|
const char* data_;
|
@@ -6078,12 +6369,9 @@ class V8_EXPORT Extension { // NOLINT
|
|
6078
6369
|
public:
|
6079
6370
|
// Note that the strings passed into this constructor must live as long
|
6080
6371
|
// as the Extension itself.
|
6081
|
-
Extension(const char* name,
|
6082
|
-
const char
|
6083
|
-
|
6084
|
-
const char** deps = 0,
|
6085
|
-
int source_length = -1);
|
6086
|
-
virtual ~Extension() { }
|
6372
|
+
Extension(const char* name, const char* source = nullptr, int dep_count = 0,
|
6373
|
+
const char** deps = nullptr, int source_length = -1);
|
6374
|
+
virtual ~Extension() { delete source_; }
|
6087
6375
|
virtual Local<FunctionTemplate> GetNativeFunctionTemplate(
|
6088
6376
|
Isolate* isolate, Local<String> name) {
|
6089
6377
|
return Local<FunctionTemplate>();
|
@@ -6092,7 +6380,8 @@ class V8_EXPORT Extension { // NOLINT
|
|
6092
6380
|
const char* name() const { return name_; }
|
6093
6381
|
size_t source_length() const { return source_length_; }
|
6094
6382
|
const String::ExternalOneByteStringResource* source() const {
|
6095
|
-
return
|
6383
|
+
return source_;
|
6384
|
+
}
|
6096
6385
|
int dependency_count() { return dep_count_; }
|
6097
6386
|
const char** dependencies() { return deps_; }
|
6098
6387
|
void set_auto_enable(bool value) { auto_enable_ = value; }
|
@@ -6105,7 +6394,7 @@ class V8_EXPORT Extension { // NOLINT
|
|
6105
6394
|
private:
|
6106
6395
|
const char* name_;
|
6107
6396
|
size_t source_length_; // expected to initialize before source_
|
6108
|
-
|
6397
|
+
String::ExternalOneByteStringResource* source_;
|
6109
6398
|
int dep_count_;
|
6110
6399
|
const char** deps_;
|
6111
6400
|
bool auto_enable_;
|
@@ -6152,18 +6441,6 @@ class V8_EXPORT ResourceConstraints {
|
|
6152
6441
|
void ConfigureDefaults(uint64_t physical_memory,
|
6153
6442
|
uint64_t virtual_memory_limit);
|
6154
6443
|
|
6155
|
-
// Returns the max semi-space size in MB.
|
6156
|
-
V8_DEPRECATE_SOON("Use max_semi_space_size_in_kb()",
|
6157
|
-
size_t max_semi_space_size()) {
|
6158
|
-
return max_semi_space_size_in_kb_ / 1024;
|
6159
|
-
}
|
6160
|
-
|
6161
|
-
// Sets the max semi-space size in MB.
|
6162
|
-
V8_DEPRECATE_SOON("Use set_max_semi_space_size_in_kb(size_t limit_in_kb)",
|
6163
|
-
void set_max_semi_space_size(size_t limit_in_mb)) {
|
6164
|
-
max_semi_space_size_in_kb_ = limit_in_mb * 1024;
|
6165
|
-
}
|
6166
|
-
|
6167
6444
|
// Returns the max semi-space size in KB.
|
6168
6445
|
size_t max_semi_space_size_in_kb() const {
|
6169
6446
|
return max_semi_space_size_in_kb_;
|
@@ -6178,14 +6455,6 @@ class V8_EXPORT ResourceConstraints {
|
|
6178
6455
|
void set_max_old_space_size(size_t limit_in_mb) {
|
6179
6456
|
max_old_space_size_ = limit_in_mb;
|
6180
6457
|
}
|
6181
|
-
V8_DEPRECATE_SOON("max_executable_size_ is subsumed by max_old_space_size_",
|
6182
|
-
size_t max_executable_size() const) {
|
6183
|
-
return max_executable_size_;
|
6184
|
-
}
|
6185
|
-
V8_DEPRECATE_SOON("max_executable_size_ is subsumed by max_old_space_size_",
|
6186
|
-
void set_max_executable_size(size_t limit_in_mb)) {
|
6187
|
-
max_executable_size_ = limit_in_mb;
|
6188
|
-
}
|
6189
6458
|
uint32_t* stack_limit() const { return stack_limit_; }
|
6190
6459
|
// Sets an address beyond which the VM's stack may not grow.
|
6191
6460
|
void set_stack_limit(uint32_t* value) { stack_limit_ = value; }
|
@@ -6202,7 +6471,6 @@ class V8_EXPORT ResourceConstraints {
|
|
6202
6471
|
|
6203
6472
|
// The remaining limits are in MB
|
6204
6473
|
size_t max_old_space_size_;
|
6205
|
-
size_t max_executable_size_;
|
6206
6474
|
uint32_t* stack_limit_;
|
6207
6475
|
size_t code_range_size_;
|
6208
6476
|
size_t max_zone_pool_size_;
|
@@ -6266,7 +6534,6 @@ typedef void (*AddHistogramSampleCallback)(void* histogram, int sample);
|
|
6266
6534
|
// --- Enter/Leave Script Callback ---
|
6267
6535
|
typedef void (*BeforeCallEnteredCallback)(Isolate*);
|
6268
6536
|
typedef void (*CallCompletedCallback)(Isolate*);
|
6269
|
-
typedef void (*DeprecatedCallCompletedCallback)();
|
6270
6537
|
|
6271
6538
|
/**
|
6272
6539
|
* HostImportModuleDynamicallyCallback is called when we require the
|
@@ -6306,6 +6573,17 @@ typedef void (*HostInitializeImportMetaObjectCallback)(Local<Context> context,
|
|
6306
6573
|
Local<Module> module,
|
6307
6574
|
Local<Object> meta);
|
6308
6575
|
|
6576
|
+
/**
|
6577
|
+
* PrepareStackTraceCallback is called when the stack property of an error is
|
6578
|
+
* first accessed. The return value will be used as the stack value. If this
|
6579
|
+
* callback is registed, the |Error.prepareStackTrace| API will be disabled.
|
6580
|
+
* |sites| is an array of call sites, specified in
|
6581
|
+
* https://github.com/v8/v8/wiki/Stack-Trace-API
|
6582
|
+
*/
|
6583
|
+
typedef MaybeLocal<Value> (*PrepareStackTraceCallback)(Local<Context> context,
|
6584
|
+
Local<Value> error,
|
6585
|
+
Local<Array> sites);
|
6586
|
+
|
6309
6587
|
/**
|
6310
6588
|
* PromiseHook with type kInit is called when a new promise is
|
6311
6589
|
* created. When a new promise is created as part of the chain in the
|
@@ -6330,7 +6608,9 @@ typedef void (*PromiseHook)(PromiseHookType type, Local<Promise> promise,
|
|
6330
6608
|
// --- Promise Reject Callback ---
|
6331
6609
|
enum PromiseRejectEvent {
|
6332
6610
|
kPromiseRejectWithNoHandler = 0,
|
6333
|
-
kPromiseHandlerAddedAfterReject = 1
|
6611
|
+
kPromiseHandlerAddedAfterReject = 1,
|
6612
|
+
kPromiseRejectAfterResolved = 2,
|
6613
|
+
kPromiseResolveAfterResolved = 3,
|
6334
6614
|
};
|
6335
6615
|
|
6336
6616
|
class PromiseRejectMessage {
|
@@ -6435,6 +6715,12 @@ typedef bool (*AllowWasmCodeGenerationCallback)(Local<Context> context,
|
|
6435
6715
|
// by the embedder. Example: WebAssembly.{compile|instantiate}Streaming ---
|
6436
6716
|
typedef void (*ApiImplementationCallback)(const FunctionCallbackInfo<Value>&);
|
6437
6717
|
|
6718
|
+
// --- Callback for WebAssembly.compileStreaming ---
|
6719
|
+
typedef void (*WasmStreamingCallback)(const FunctionCallbackInfo<Value>&);
|
6720
|
+
|
6721
|
+
// --- Callback for checking if WebAssembly threads are enabled ---
|
6722
|
+
typedef bool (*WasmThreadsEnabledCallback)(Local<Context> context);
|
6723
|
+
|
6438
6724
|
// --- Garbage Collection Callbacks ---
|
6439
6725
|
|
6440
6726
|
/**
|
@@ -6507,6 +6793,7 @@ class V8_EXPORT HeapStatistics {
|
|
6507
6793
|
size_t used_heap_size() { return used_heap_size_; }
|
6508
6794
|
size_t heap_size_limit() { return heap_size_limit_; }
|
6509
6795
|
size_t malloced_memory() { return malloced_memory_; }
|
6796
|
+
size_t external_memory() { return external_memory_; }
|
6510
6797
|
size_t peak_malloced_memory() { return peak_malloced_memory_; }
|
6511
6798
|
size_t number_of_native_contexts() { return number_of_native_contexts_; }
|
6512
6799
|
size_t number_of_detached_contexts() { return number_of_detached_contexts_; }
|
@@ -6525,6 +6812,7 @@ class V8_EXPORT HeapStatistics {
|
|
6525
6812
|
size_t used_heap_size_;
|
6526
6813
|
size_t heap_size_limit_;
|
6527
6814
|
size_t malloced_memory_;
|
6815
|
+
size_t external_memory_;
|
6528
6816
|
size_t peak_malloced_memory_;
|
6529
6817
|
bool does_zap_garbage_;
|
6530
6818
|
size_t number_of_native_contexts_;
|
@@ -6577,31 +6865,18 @@ class V8_EXPORT HeapCodeStatistics {
|
|
6577
6865
|
HeapCodeStatistics();
|
6578
6866
|
size_t code_and_metadata_size() { return code_and_metadata_size_; }
|
6579
6867
|
size_t bytecode_and_metadata_size() { return bytecode_and_metadata_size_; }
|
6868
|
+
size_t external_script_source_size() { return external_script_source_size_; }
|
6580
6869
|
|
6581
6870
|
private:
|
6582
6871
|
size_t code_and_metadata_size_;
|
6583
6872
|
size_t bytecode_and_metadata_size_;
|
6873
|
+
size_t external_script_source_size_;
|
6584
6874
|
|
6585
6875
|
friend class Isolate;
|
6586
6876
|
};
|
6587
6877
|
|
6588
6878
|
class RetainedObjectInfo;
|
6589
6879
|
|
6590
|
-
|
6591
|
-
/**
|
6592
|
-
* FunctionEntryHook is the type of the profile entry hook called at entry to
|
6593
|
-
* any generated function when function-level profiling is enabled.
|
6594
|
-
*
|
6595
|
-
* \param function the address of the function that's being entered.
|
6596
|
-
* \param return_addr_location points to a location on stack where the machine
|
6597
|
-
* return address resides. This can be used to identify the caller of
|
6598
|
-
* \p function, and/or modified to divert execution when \p function exits.
|
6599
|
-
*
|
6600
|
-
* \note the entry hook must not cause garbage collection.
|
6601
|
-
*/
|
6602
|
-
typedef void (*FunctionEntryHook)(uintptr_t function,
|
6603
|
-
uintptr_t return_addr_location);
|
6604
|
-
|
6605
6880
|
/**
|
6606
6881
|
* A JIT code event is issued each time code is added, moved or removed.
|
6607
6882
|
*
|
@@ -6673,6 +6948,8 @@ struct JitCodeEvent {
|
|
6673
6948
|
// New location of instructions. Only valid for CODE_MOVED.
|
6674
6949
|
void* new_code_start;
|
6675
6950
|
};
|
6951
|
+
|
6952
|
+
Isolate* isolate;
|
6676
6953
|
};
|
6677
6954
|
|
6678
6955
|
/**
|
@@ -6720,7 +6997,7 @@ typedef void (*JitCodeEventHandler)(const JitCodeEvent* event);
|
|
6720
6997
|
*/
|
6721
6998
|
class V8_EXPORT ExternalResourceVisitor { // NOLINT
|
6722
6999
|
public:
|
6723
|
-
virtual ~ExternalResourceVisitor()
|
7000
|
+
virtual ~ExternalResourceVisitor() = default;
|
6724
7001
|
virtual void VisitExternalString(Local<String> string) {}
|
6725
7002
|
};
|
6726
7003
|
|
@@ -6730,7 +7007,7 @@ class V8_EXPORT ExternalResourceVisitor { // NOLINT
|
|
6730
7007
|
*/
|
6731
7008
|
class V8_EXPORT PersistentHandleVisitor { // NOLINT
|
6732
7009
|
public:
|
6733
|
-
virtual ~PersistentHandleVisitor()
|
7010
|
+
virtual ~PersistentHandleVisitor() = default;
|
6734
7011
|
virtual void VisitPersistentHandle(Persistent<Value>* value,
|
6735
7012
|
uint16_t class_id) {}
|
6736
7013
|
};
|
@@ -6746,27 +7023,23 @@ class V8_EXPORT PersistentHandleVisitor { // NOLINT
|
|
6746
7023
|
enum class MemoryPressureLevel { kNone, kModerate, kCritical };
|
6747
7024
|
|
6748
7025
|
/**
|
6749
|
-
* Interface for tracing through the embedder heap. During a
|
6750
|
-
* collection,
|
7026
|
+
* Interface for tracing through the embedder heap. During a V8 garbage
|
7027
|
+
* collection, V8 collects hidden fields of all potential wrappers, and at the
|
6751
7028
|
* end of its marking phase iterates the collection and asks the embedder to
|
6752
7029
|
* trace through its heap and use reporter to report each JavaScript object
|
6753
7030
|
* reachable from any of the given wrappers.
|
6754
|
-
*
|
6755
|
-
* Before the first call to the TraceWrappersFrom function TracePrologue will be
|
6756
|
-
* called. When the garbage collection cycle is finished, TraceEpilogue will be
|
6757
|
-
* called.
|
6758
7031
|
*/
|
6759
7032
|
class V8_EXPORT EmbedderHeapTracer {
|
6760
7033
|
public:
|
6761
|
-
|
6762
|
-
|
6763
|
-
|
6764
|
-
|
6765
|
-
|
6766
|
-
|
6767
|
-
ForceCompletionAction force_completion;
|
7034
|
+
// Indicator for the stack state of the embedder.
|
7035
|
+
enum EmbedderStackState {
|
7036
|
+
kUnknown,
|
7037
|
+
kNonEmpty,
|
7038
|
+
kEmpty,
|
6768
7039
|
};
|
6769
7040
|
|
7041
|
+
virtual ~EmbedderHeapTracer() = default;
|
7042
|
+
|
6770
7043
|
/**
|
6771
7044
|
* Called by v8 to register internal fields of found wrappers.
|
6772
7045
|
*
|
@@ -6782,17 +7055,22 @@ class V8_EXPORT EmbedderHeapTracer {
|
|
6782
7055
|
virtual void TracePrologue() = 0;
|
6783
7056
|
|
6784
7057
|
/**
|
6785
|
-
* Called to
|
7058
|
+
* Called to advance tracing in the embedder.
|
6786
7059
|
*
|
6787
7060
|
* The embedder is expected to trace its heap starting from wrappers reported
|
6788
7061
|
* by RegisterV8References method, and report back all reachable wrappers.
|
6789
7062
|
* Furthermore, the embedder is expected to stop tracing by the given
|
6790
|
-
* deadline.
|
7063
|
+
* deadline. A deadline of infinity means that tracing should be finished.
|
6791
7064
|
*
|
6792
|
-
* Returns true if
|
7065
|
+
* Returns |true| if tracing is done, and false otherwise.
|
7066
|
+
*/
|
7067
|
+
virtual bool AdvanceTracing(double deadline_in_ms) = 0;
|
7068
|
+
|
7069
|
+
/*
|
7070
|
+
* Returns true if there no more tracing work to be done (see AdvanceTracing)
|
7071
|
+
* and false otherwise.
|
6793
7072
|
*/
|
6794
|
-
virtual bool
|
6795
|
-
AdvanceTracingActions actions) = 0;
|
7073
|
+
virtual bool IsTracingDone() = 0;
|
6796
7074
|
|
6797
7075
|
/**
|
6798
7076
|
* Called at the end of a GC cycle.
|
@@ -6805,7 +7083,7 @@ class V8_EXPORT EmbedderHeapTracer {
|
|
6805
7083
|
* Called upon entering the final marking pause. No more incremental marking
|
6806
7084
|
* steps will follow this call.
|
6807
7085
|
*/
|
6808
|
-
virtual void EnterFinalPause() = 0;
|
7086
|
+
virtual void EnterFinalPause(EmbedderStackState stack_state) = 0;
|
6809
7087
|
|
6810
7088
|
/**
|
6811
7089
|
* Called when tracing is aborted.
|
@@ -6813,20 +7091,46 @@ class V8_EXPORT EmbedderHeapTracer {
|
|
6813
7091
|
* The embedder is expected to throw away all intermediate data and reset to
|
6814
7092
|
* the initial state.
|
6815
7093
|
*/
|
6816
|
-
|
7094
|
+
V8_DEPRECATED("Obsolete as V8 will not abort tracing anymore.",
|
7095
|
+
virtual void AbortTracing()) {}
|
6817
7096
|
|
6818
|
-
|
6819
|
-
*
|
7097
|
+
/*
|
7098
|
+
* Called by the embedder to request immediate finalization of the currently
|
7099
|
+
* running tracing phase that has been started with TracePrologue and not
|
7100
|
+
* yet finished with TraceEpilogue.
|
7101
|
+
*
|
7102
|
+
* Will be a noop when currently not in tracing.
|
7103
|
+
*
|
7104
|
+
* This is an experimental feature.
|
7105
|
+
*/
|
7106
|
+
void FinalizeTracing();
|
7107
|
+
|
7108
|
+
/*
|
7109
|
+
* Called by the embedder to immediately perform a full garbage collection.
|
7110
|
+
*
|
7111
|
+
* Should only be used in testing code.
|
6820
7112
|
*/
|
6821
|
-
|
7113
|
+
void GarbageCollectionForTesting(EmbedderStackState stack_state);
|
7114
|
+
|
7115
|
+
/*
|
7116
|
+
* Returns the v8::Isolate this tracer is attached too and |nullptr| if it
|
7117
|
+
* is not attached to any v8::Isolate.
|
7118
|
+
*/
|
7119
|
+
v8::Isolate* isolate() const { return isolate_; }
|
6822
7120
|
|
6823
7121
|
protected:
|
6824
|
-
|
7122
|
+
v8::Isolate* isolate_ = nullptr;
|
7123
|
+
|
7124
|
+
friend class internal::LocalEmbedderHeapTracer;
|
6825
7125
|
};
|
6826
7126
|
|
6827
7127
|
/**
|
6828
7128
|
* Callback and supporting data used in SnapshotCreator to implement embedder
|
6829
7129
|
* logic to serialize internal fields.
|
7130
|
+
* Internal fields that directly reference V8 objects are serialized without
|
7131
|
+
* calling this callback. Internal fields that contain aligned pointers are
|
7132
|
+
* serialized by this callback if it returns non-zero result. Otherwise it is
|
7133
|
+
* serialized verbatim.
|
6830
7134
|
*/
|
6831
7135
|
struct SerializeInternalFieldsCallback {
|
6832
7136
|
typedef StartupData (*CallbackFunction)(Local<Object> holder, int index,
|
@@ -6872,25 +7176,15 @@ class V8_EXPORT Isolate {
|
|
6872
7176
|
*/
|
6873
7177
|
struct CreateParams {
|
6874
7178
|
CreateParams()
|
6875
|
-
:
|
6876
|
-
code_event_handler(nullptr),
|
7179
|
+
: code_event_handler(nullptr),
|
6877
7180
|
snapshot_blob(nullptr),
|
6878
7181
|
counter_lookup_callback(nullptr),
|
6879
7182
|
create_histogram_callback(nullptr),
|
6880
7183
|
add_histogram_sample_callback(nullptr),
|
6881
7184
|
array_buffer_allocator(nullptr),
|
6882
7185
|
external_references(nullptr),
|
6883
|
-
allow_atomics_wait(true)
|
6884
|
-
|
6885
|
-
/**
|
6886
|
-
* The optional entry_hook allows the host application to provide the
|
6887
|
-
* address of a function that's invoked on entry to every V8-generated
|
6888
|
-
* function. Note that entry_hook is invoked at the very start of each
|
6889
|
-
* generated function.
|
6890
|
-
* An entry_hook can only be provided in no-snapshot builds; in snapshot
|
6891
|
-
* builds it must be nullptr.
|
6892
|
-
*/
|
6893
|
-
FunctionEntryHook entry_hook;
|
7186
|
+
allow_atomics_wait(true),
|
7187
|
+
only_terminate_in_safe_scope(false) {}
|
6894
7188
|
|
6895
7189
|
/**
|
6896
7190
|
* Allows the host application to provide the address of a function that is
|
@@ -6943,6 +7237,11 @@ class V8_EXPORT Isolate {
|
|
6943
7237
|
* this isolate. This can also be configured via SetAllowAtomicsWait.
|
6944
7238
|
*/
|
6945
7239
|
bool allow_atomics_wait;
|
7240
|
+
|
7241
|
+
/**
|
7242
|
+
* Termination is postponed when there is no active SafeForTerminationScope.
|
7243
|
+
*/
|
7244
|
+
bool only_terminate_in_safe_scope;
|
6946
7245
|
};
|
6947
7246
|
|
6948
7247
|
|
@@ -6972,7 +7271,7 @@ class V8_EXPORT Isolate {
|
|
6972
7271
|
*/
|
6973
7272
|
class V8_EXPORT DisallowJavascriptExecutionScope {
|
6974
7273
|
public:
|
6975
|
-
enum OnFailure { CRASH_ON_FAILURE, THROW_ON_FAILURE };
|
7274
|
+
enum OnFailure { CRASH_ON_FAILURE, THROW_ON_FAILURE, DUMP_ON_FAILURE };
|
6976
7275
|
|
6977
7276
|
DisallowJavascriptExecutionScope(Isolate* isolate, OnFailure on_failure);
|
6978
7277
|
~DisallowJavascriptExecutionScope();
|
@@ -6984,7 +7283,7 @@ class V8_EXPORT Isolate {
|
|
6984
7283
|
const DisallowJavascriptExecutionScope&) = delete;
|
6985
7284
|
|
6986
7285
|
private:
|
6987
|
-
|
7286
|
+
OnFailure on_failure_;
|
6988
7287
|
void* internal_;
|
6989
7288
|
};
|
6990
7289
|
|
@@ -7006,6 +7305,7 @@ class V8_EXPORT Isolate {
|
|
7006
7305
|
private:
|
7007
7306
|
void* internal_throws_;
|
7008
7307
|
void* internal_assert_;
|
7308
|
+
void* internal_dump_;
|
7009
7309
|
};
|
7010
7310
|
|
7011
7311
|
/**
|
@@ -7027,6 +7327,24 @@ class V8_EXPORT Isolate {
|
|
7027
7327
|
internal::Isolate* const isolate_;
|
7028
7328
|
};
|
7029
7329
|
|
7330
|
+
/**
|
7331
|
+
* This scope allows terminations inside direct V8 API calls and forbid them
|
7332
|
+
* inside any recursice API calls without explicit SafeForTerminationScope.
|
7333
|
+
*/
|
7334
|
+
class V8_EXPORT SafeForTerminationScope {
|
7335
|
+
public:
|
7336
|
+
explicit SafeForTerminationScope(v8::Isolate* isolate);
|
7337
|
+
~SafeForTerminationScope();
|
7338
|
+
|
7339
|
+
// Prevent copying of Scope objects.
|
7340
|
+
SafeForTerminationScope(const SafeForTerminationScope&) = delete;
|
7341
|
+
SafeForTerminationScope& operator=(const SafeForTerminationScope&) = delete;
|
7342
|
+
|
7343
|
+
private:
|
7344
|
+
internal::Isolate* isolate_;
|
7345
|
+
bool prev_value_;
|
7346
|
+
};
|
7347
|
+
|
7030
7348
|
/**
|
7031
7349
|
* Types of garbage collections that can be requested via
|
7032
7350
|
* RequestGarbageCollectionForTesting.
|
@@ -7090,6 +7408,33 @@ class V8_EXPORT Isolate {
|
|
7090
7408
|
kErrorStackTraceLimit = 45,
|
7091
7409
|
kWebAssemblyInstantiation = 46,
|
7092
7410
|
kDeoptimizerDisableSpeculation = 47,
|
7411
|
+
kArrayPrototypeSortJSArrayModifiedPrototype = 48,
|
7412
|
+
kFunctionTokenOffsetTooLongForToString = 49,
|
7413
|
+
kWasmSharedMemory = 50,
|
7414
|
+
kWasmThreadOpcodes = 51,
|
7415
|
+
kAtomicsNotify = 52,
|
7416
|
+
kAtomicsWake = 53,
|
7417
|
+
kCollator = 54,
|
7418
|
+
kNumberFormat = 55,
|
7419
|
+
kDateTimeFormat = 56,
|
7420
|
+
kPluralRules = 57,
|
7421
|
+
kRelativeTimeFormat = 58,
|
7422
|
+
kLocale = 59,
|
7423
|
+
kListFormat = 60,
|
7424
|
+
kSegmenter = 61,
|
7425
|
+
kStringLocaleCompare = 62,
|
7426
|
+
kStringToLocaleUpperCase = 63,
|
7427
|
+
kStringToLocaleLowerCase = 64,
|
7428
|
+
kNumberToLocaleString = 65,
|
7429
|
+
kDateToLocaleString = 66,
|
7430
|
+
kDateToLocaleDateString = 67,
|
7431
|
+
kDateToLocaleTimeString = 68,
|
7432
|
+
kAttemptOverrideReadOnlyOnPrototypeSloppy = 69,
|
7433
|
+
kAttemptOverrideReadOnlyOnPrototypeStrict = 70,
|
7434
|
+
kOptimizedFunctionWithOneShotBytecode = 71,
|
7435
|
+
kRegExpMatchIsTrueishOnNonJSRegExp = 72,
|
7436
|
+
kRegExpMatchIsFalseishOnJSRegExp = 73,
|
7437
|
+
kDateGetTimezoneOffset = 74,
|
7093
7438
|
|
7094
7439
|
// If you add new values here, you'll also need to update Chromium's:
|
7095
7440
|
// web_feature.mojom, UseCounterCallback.cpp, and enums.xml. V8 changes to
|
@@ -7110,6 +7455,26 @@ class V8_EXPORT Isolate {
|
|
7110
7455
|
typedef void (*UseCounterCallback)(Isolate* isolate,
|
7111
7456
|
UseCounterFeature feature);
|
7112
7457
|
|
7458
|
+
/**
|
7459
|
+
* Allocates a new isolate but does not initialize it. Does not change the
|
7460
|
+
* currently entered isolate.
|
7461
|
+
*
|
7462
|
+
* Only Isolate::GetData() and Isolate::SetData(), which access the
|
7463
|
+
* embedder-controlled parts of the isolate, are allowed to be called on the
|
7464
|
+
* uninitialized isolate. To initialize the isolate, call
|
7465
|
+
* Isolate::Initialize().
|
7466
|
+
*
|
7467
|
+
* When an isolate is no longer used its resources should be freed
|
7468
|
+
* by calling Dispose(). Using the delete operator is not allowed.
|
7469
|
+
*
|
7470
|
+
* V8::Initialize() must have run prior to this.
|
7471
|
+
*/
|
7472
|
+
static Isolate* Allocate();
|
7473
|
+
|
7474
|
+
/**
|
7475
|
+
* Initialize an Isolate previously allocated by Isolate::Allocate().
|
7476
|
+
*/
|
7477
|
+
static void Initialize(Isolate* isolate, const CreateParams& params);
|
7113
7478
|
|
7114
7479
|
/**
|
7115
7480
|
* Creates a new isolate. Does not change the currently entered
|
@@ -7157,6 +7522,12 @@ class V8_EXPORT Isolate {
|
|
7157
7522
|
void SetHostInitializeImportMetaObjectCallback(
|
7158
7523
|
HostInitializeImportMetaObjectCallback callback);
|
7159
7524
|
|
7525
|
+
/**
|
7526
|
+
* This specifies the callback called when the stack property of Error
|
7527
|
+
* is accessed.
|
7528
|
+
*/
|
7529
|
+
void SetPrepareStackTraceCallback(PrepareStackTraceCallback callback);
|
7530
|
+
|
7160
7531
|
/**
|
7161
7532
|
* Optional notification that the system is running low on memory.
|
7162
7533
|
* V8 uses these notifications to guide heuristics.
|
@@ -7325,15 +7696,7 @@ class V8_EXPORT Isolate {
|
|
7325
7696
|
HeapProfiler* GetHeapProfiler();
|
7326
7697
|
|
7327
7698
|
/**
|
7328
|
-
*
|
7329
|
-
* is initialized. It is the embedder's responsibility to stop all CPU
|
7330
|
-
* profiling activities if it has started any.
|
7331
|
-
*/
|
7332
|
-
V8_DEPRECATED("CpuProfiler should be created with CpuProfiler::New call.",
|
7333
|
-
CpuProfiler* GetCpuProfiler());
|
7334
|
-
|
7335
|
-
/**
|
7336
|
-
* Tells the CPU profiler whether the embedder is idle.
|
7699
|
+
* Tells the VM whether the embedder is idle or not.
|
7337
7700
|
*/
|
7338
7701
|
void SetIdle(bool is_idle);
|
7339
7702
|
|
@@ -7346,18 +7709,9 @@ class V8_EXPORT Isolate {
|
|
7346
7709
|
*/
|
7347
7710
|
Local<Context> GetCurrentContext();
|
7348
7711
|
|
7349
|
-
/**
|
7350
|
-
* Returns the context of the calling JavaScript code. That is the
|
7351
|
-
* context of the top-most JavaScript frame. If there are no
|
7352
|
-
* JavaScript frames an empty handle is returned.
|
7353
|
-
*/
|
7354
|
-
V8_DEPRECATED(
|
7355
|
-
"Calling context concept is not compatible with tail calls, and will be "
|
7356
|
-
"removed.",
|
7357
|
-
Local<Context> GetCallingContext());
|
7358
|
-
|
7359
7712
|
/** Returns the last context entered through V8's C++ API. */
|
7360
|
-
|
7713
|
+
V8_DEPRECATED("Use GetEnteredOrMicrotaskContext().",
|
7714
|
+
Local<Context> GetEnteredContext());
|
7361
7715
|
|
7362
7716
|
/**
|
7363
7717
|
* Returns either the last context entered through V8's C++ API, or the
|
@@ -7412,6 +7766,90 @@ class V8_EXPORT Isolate {
|
|
7412
7766
|
*/
|
7413
7767
|
void SetEmbedderHeapTracer(EmbedderHeapTracer* tracer);
|
7414
7768
|
|
7769
|
+
/*
|
7770
|
+
* Gets the currently active heap tracer for the isolate.
|
7771
|
+
*/
|
7772
|
+
EmbedderHeapTracer* GetEmbedderHeapTracer();
|
7773
|
+
|
7774
|
+
/**
|
7775
|
+
* Use for |AtomicsWaitCallback| to indicate the type of event it receives.
|
7776
|
+
*/
|
7777
|
+
enum class AtomicsWaitEvent {
|
7778
|
+
/** Indicates that this call is happening before waiting. */
|
7779
|
+
kStartWait,
|
7780
|
+
/** `Atomics.wait()` finished because of an `Atomics.wake()` call. */
|
7781
|
+
kWokenUp,
|
7782
|
+
/** `Atomics.wait()` finished because it timed out. */
|
7783
|
+
kTimedOut,
|
7784
|
+
/** `Atomics.wait()` was interrupted through |TerminateExecution()|. */
|
7785
|
+
kTerminatedExecution,
|
7786
|
+
/** `Atomics.wait()` was stopped through |AtomicsWaitWakeHandle|. */
|
7787
|
+
kAPIStopped,
|
7788
|
+
/** `Atomics.wait()` did not wait, as the initial condition was not met. */
|
7789
|
+
kNotEqual
|
7790
|
+
};
|
7791
|
+
|
7792
|
+
/**
|
7793
|
+
* Passed to |AtomicsWaitCallback| as a means of stopping an ongoing
|
7794
|
+
* `Atomics.wait` call.
|
7795
|
+
*/
|
7796
|
+
class V8_EXPORT AtomicsWaitWakeHandle {
|
7797
|
+
public:
|
7798
|
+
/**
|
7799
|
+
* Stop this `Atomics.wait()` call and call the |AtomicsWaitCallback|
|
7800
|
+
* with |kAPIStopped|.
|
7801
|
+
*
|
7802
|
+
* This function may be called from another thread. The caller has to ensure
|
7803
|
+
* through proper synchronization that it is not called after
|
7804
|
+
* the finishing |AtomicsWaitCallback|.
|
7805
|
+
*
|
7806
|
+
* Note that the ECMAScript specification does not plan for the possibility
|
7807
|
+
* of wakeups that are neither coming from a timeout or an `Atomics.wake()`
|
7808
|
+
* call, so this may invalidate assumptions made by existing code.
|
7809
|
+
* The embedder may accordingly wish to schedule an exception in the
|
7810
|
+
* finishing |AtomicsWaitCallback|.
|
7811
|
+
*/
|
7812
|
+
void Wake();
|
7813
|
+
};
|
7814
|
+
|
7815
|
+
/**
|
7816
|
+
* Embedder callback for `Atomics.wait()` that can be added through
|
7817
|
+
* |SetAtomicsWaitCallback|.
|
7818
|
+
*
|
7819
|
+
* This will be called just before starting to wait with the |event| value
|
7820
|
+
* |kStartWait| and after finishing waiting with one of the other
|
7821
|
+
* values of |AtomicsWaitEvent| inside of an `Atomics.wait()` call.
|
7822
|
+
*
|
7823
|
+
* |array_buffer| will refer to the underlying SharedArrayBuffer,
|
7824
|
+
* |offset_in_bytes| to the location of the waited-on memory address inside
|
7825
|
+
* the SharedArrayBuffer.
|
7826
|
+
*
|
7827
|
+
* |value| and |timeout_in_ms| will be the values passed to
|
7828
|
+
* the `Atomics.wait()` call. If no timeout was used, |timeout_in_ms|
|
7829
|
+
* will be `INFINITY`.
|
7830
|
+
*
|
7831
|
+
* In the |kStartWait| callback, |stop_handle| will be an object that
|
7832
|
+
* is only valid until the corresponding finishing callback and that
|
7833
|
+
* can be used to stop the wait process while it is happening.
|
7834
|
+
*
|
7835
|
+
* This callback may schedule exceptions, *unless* |event| is equal to
|
7836
|
+
* |kTerminatedExecution|.
|
7837
|
+
*/
|
7838
|
+
typedef void (*AtomicsWaitCallback)(AtomicsWaitEvent event,
|
7839
|
+
Local<SharedArrayBuffer> array_buffer,
|
7840
|
+
size_t offset_in_bytes, int64_t value,
|
7841
|
+
double timeout_in_ms,
|
7842
|
+
AtomicsWaitWakeHandle* stop_handle,
|
7843
|
+
void* data);
|
7844
|
+
|
7845
|
+
/**
|
7846
|
+
* Set a new |AtomicsWaitCallback|. This overrides an earlier
|
7847
|
+
* |AtomicsWaitCallback|, if there was any. If |callback| is nullptr,
|
7848
|
+
* this unsets the callback. |data| will be passed to the callback
|
7849
|
+
* as its last parameter.
|
7850
|
+
*/
|
7851
|
+
void SetAtomicsWaitCallback(AtomicsWaitCallback callback, void* data);
|
7852
|
+
|
7415
7853
|
/**
|
7416
7854
|
* Enables the host application to receive a notification after a
|
7417
7855
|
* garbage collection. Allocations are allowed in the callback function,
|
@@ -7528,17 +7966,11 @@ class V8_EXPORT Isolate {
|
|
7528
7966
|
* further callbacks.
|
7529
7967
|
*/
|
7530
7968
|
void AddCallCompletedCallback(CallCompletedCallback callback);
|
7531
|
-
V8_DEPRECATED(
|
7532
|
-
"Use callback with parameter",
|
7533
|
-
void AddCallCompletedCallback(DeprecatedCallCompletedCallback callback));
|
7534
7969
|
|
7535
7970
|
/**
|
7536
7971
|
* Removes callback that was installed by AddCallCompletedCallback.
|
7537
7972
|
*/
|
7538
7973
|
void RemoveCallCompletedCallback(CallCompletedCallback callback);
|
7539
|
-
V8_DEPRECATED("Use callback with parameter",
|
7540
|
-
void RemoveCallCompletedCallback(
|
7541
|
-
DeprecatedCallCompletedCallback callback));
|
7542
7974
|
|
7543
7975
|
/**
|
7544
7976
|
* Set the PromiseHook callback for various promise lifecycle
|
@@ -7572,14 +8004,11 @@ class V8_EXPORT Isolate {
|
|
7572
8004
|
* Controls how Microtasks are invoked. See MicrotasksPolicy for details.
|
7573
8005
|
*/
|
7574
8006
|
void SetMicrotasksPolicy(MicrotasksPolicy policy);
|
7575
|
-
V8_DEPRECATED("Use SetMicrotasksPolicy",
|
7576
|
-
void SetAutorunMicrotasks(bool autorun));
|
7577
8007
|
|
7578
8008
|
/**
|
7579
8009
|
* Returns the policy controlling how Microtasks are invoked.
|
7580
8010
|
*/
|
7581
8011
|
MicrotasksPolicy GetMicrotasksPolicy() const;
|
7582
|
-
V8_DEPRECATED("Use GetMicrotasksPolicy", bool WillAutorunMicrotasks() const);
|
7583
8012
|
|
7584
8013
|
/**
|
7585
8014
|
* Adds a callback to notify the host application after
|
@@ -7665,6 +8094,18 @@ class V8_EXPORT Isolate {
|
|
7665
8094
|
*/
|
7666
8095
|
void IsolateInBackgroundNotification();
|
7667
8096
|
|
8097
|
+
/**
|
8098
|
+
* Optional notification which will enable the memory savings mode.
|
8099
|
+
* V8 uses this notification to guide heuristics which may result in a
|
8100
|
+
* smaller memory footprint at the cost of reduced runtime performance.
|
8101
|
+
*/
|
8102
|
+
void EnableMemorySavingsMode();
|
8103
|
+
|
8104
|
+
/**
|
8105
|
+
* Optional notification which will disable the memory savings mode.
|
8106
|
+
*/
|
8107
|
+
void DisableMemorySavingsMode();
|
8108
|
+
|
7668
8109
|
/**
|
7669
8110
|
* Optional notification to tell V8 the current performance requirements
|
7670
8111
|
* of the embedder based on RAIL.
|
@@ -7728,7 +8169,9 @@ class V8_EXPORT Isolate {
|
|
7728
8169
|
void SetStackLimit(uintptr_t stack_limit);
|
7729
8170
|
|
7730
8171
|
/**
|
7731
|
-
* Returns a memory range that can potentially contain jitted code.
|
8172
|
+
* Returns a memory range that can potentially contain jitted code. Code for
|
8173
|
+
* V8's 'builtins' will not be in this range if embedded builtins is enabled.
|
8174
|
+
* Instead, see GetEmbeddedCodeRange.
|
7732
8175
|
*
|
7733
8176
|
* On Win64, embedders are advised to install function table callbacks for
|
7734
8177
|
* these ranges, as default SEH won't be able to unwind through jitted code.
|
@@ -7742,6 +8185,11 @@ class V8_EXPORT Isolate {
|
|
7742
8185
|
*/
|
7743
8186
|
void GetCodeRange(void** start, size_t* length_in_bytes);
|
7744
8187
|
|
8188
|
+
/**
|
8189
|
+
* Returns the UnwindState necessary for use with the Unwinder API.
|
8190
|
+
*/
|
8191
|
+
UnwindState GetUnwindState();
|
8192
|
+
|
7745
8193
|
/** Set the callback to invoke in case of fatal errors. */
|
7746
8194
|
void SetFatalErrorHandler(FatalErrorCallback that);
|
7747
8195
|
|
@@ -7765,6 +8213,14 @@ class V8_EXPORT Isolate {
|
|
7765
8213
|
void RemoveNearHeapLimitCallback(NearHeapLimitCallback callback,
|
7766
8214
|
size_t heap_limit);
|
7767
8215
|
|
8216
|
+
/**
|
8217
|
+
* If the heap limit was changed by the NearHeapLimitCallback, then the
|
8218
|
+
* initial heap limit will be restored once the heap size falls below the
|
8219
|
+
* given threshold percentage of the initial heap limit.
|
8220
|
+
* The threshold percentage is a number in (0.0, 1.0) range.
|
8221
|
+
*/
|
8222
|
+
void AutomaticallyRestoreInitialHeapLimit(double threshold_percent = 0.5);
|
8223
|
+
|
7768
8224
|
/**
|
7769
8225
|
* Set the callback to invoke to check if code generation from
|
7770
8226
|
* strings should be allowed.
|
@@ -7786,7 +8242,13 @@ class V8_EXPORT Isolate {
|
|
7786
8242
|
void SetWasmModuleCallback(ExtensionCallback callback);
|
7787
8243
|
void SetWasmInstanceCallback(ExtensionCallback callback);
|
7788
8244
|
|
7789
|
-
|
8245
|
+
V8_DEPRECATED(
|
8246
|
+
"The callback set in SetWasmStreamingCallback is used now",
|
8247
|
+
void SetWasmCompileStreamingCallback(ApiImplementationCallback callback));
|
8248
|
+
|
8249
|
+
void SetWasmStreamingCallback(WasmStreamingCallback callback);
|
8250
|
+
|
8251
|
+
void SetWasmThreadsEnabledCallback(WasmThreadsEnabledCallback callback);
|
7790
8252
|
|
7791
8253
|
/**
|
7792
8254
|
* Check if V8 is dead and therefore unusable. This is the case after
|
@@ -7857,7 +8319,9 @@ class V8_EXPORT Isolate {
|
|
7857
8319
|
* garbage collection but is free to visit an arbitrary superset of these
|
7858
8320
|
* objects.
|
7859
8321
|
*/
|
7860
|
-
|
8322
|
+
V8_DEPRECATE_SOON(
|
8323
|
+
"Use VisitHandlesWithClassIds",
|
8324
|
+
void VisitHandlesForPartialDependence(PersistentHandleVisitor* visitor));
|
7861
8325
|
|
7862
8326
|
/**
|
7863
8327
|
* Iterates through all the persistent handles in the current isolate's heap
|
@@ -7894,7 +8358,7 @@ class V8_EXPORT Isolate {
|
|
7894
8358
|
template <class K, class V, class Traits>
|
7895
8359
|
friend class PersistentValueMapBase;
|
7896
8360
|
|
7897
|
-
internal::
|
8361
|
+
internal::Address* GetDataFromSnapshotOnce(size_t index);
|
7898
8362
|
void ReportExternalAllocationLimitReached();
|
7899
8363
|
void CheckMemoryPressure();
|
7900
8364
|
};
|
@@ -7952,25 +8416,6 @@ class V8_EXPORT V8 {
|
|
7952
8416
|
static void SetNativesDataBlob(StartupData* startup_blob);
|
7953
8417
|
static void SetSnapshotDataBlob(StartupData* startup_blob);
|
7954
8418
|
|
7955
|
-
/**
|
7956
|
-
* Bootstrap an isolate and a context from scratch to create a startup
|
7957
|
-
* snapshot. Include the side-effects of running the optional script.
|
7958
|
-
* Returns { NULL, 0 } on failure.
|
7959
|
-
* The caller acquires ownership of the data array in the return value.
|
7960
|
-
*/
|
7961
|
-
static StartupData CreateSnapshotDataBlob(const char* embedded_source = NULL);
|
7962
|
-
|
7963
|
-
/**
|
7964
|
-
* Bootstrap an isolate and a context from the cold startup blob, run the
|
7965
|
-
* warm-up script to trigger code compilation. The side effects are then
|
7966
|
-
* discarded. The resulting startup snapshot will include compiled code.
|
7967
|
-
* Returns { NULL, 0 } on failure.
|
7968
|
-
* The caller acquires ownership of the data array in the return value.
|
7969
|
-
* The argument startup blob is untouched.
|
7970
|
-
*/
|
7971
|
-
static StartupData WarmUpSnapshotDataBlob(StartupData cold_startup_blob,
|
7972
|
-
const char* warmup_source);
|
7973
|
-
|
7974
8419
|
/** Set the callback to invoke in case of Dcheck failures. */
|
7975
8420
|
static void SetDcheckErrorHandler(DcheckErrorCallback that);
|
7976
8421
|
|
@@ -8095,15 +8540,17 @@ class V8_EXPORT V8 {
|
|
8095
8540
|
* \param context The third argument passed to the Linux signal handler, which
|
8096
8541
|
* points to a ucontext_t structure.
|
8097
8542
|
*/
|
8098
|
-
|
8543
|
+
V8_DEPRECATE_SOON("Use TryHandleWebAssemblyTrapPosix",
|
8544
|
+
static bool TryHandleSignal(int signal_number, void* info,
|
8545
|
+
void* context));
|
8099
8546
|
#endif // V8_OS_POSIX
|
8100
8547
|
|
8101
8548
|
/**
|
8102
8549
|
* Enable the default signal handler rather than using one provided by the
|
8103
8550
|
* embedder.
|
8104
8551
|
*/
|
8105
|
-
|
8106
|
-
|
8552
|
+
V8_DEPRECATED("Use EnableWebAssemblyTrapHandler",
|
8553
|
+
static bool RegisterDefaultSignalHandler());
|
8107
8554
|
|
8108
8555
|
/**
|
8109
8556
|
* Activate trap-based bounds checking for WebAssembly.
|
@@ -8116,26 +8563,20 @@ class V8_EXPORT V8 {
|
|
8116
8563
|
private:
|
8117
8564
|
V8();
|
8118
8565
|
|
8119
|
-
static internal::
|
8120
|
-
internal::
|
8121
|
-
static internal::
|
8122
|
-
static void DisposeGlobal(internal::
|
8123
|
-
static void MakeWeak(internal::
|
8566
|
+
static internal::Address* GlobalizeReference(internal::Isolate* isolate,
|
8567
|
+
internal::Address* handle);
|
8568
|
+
static internal::Address* CopyPersistent(internal::Address* handle);
|
8569
|
+
static void DisposeGlobal(internal::Address* global_handle);
|
8570
|
+
static void MakeWeak(internal::Address* location, void* data,
|
8124
8571
|
WeakCallbackInfo<void>::Callback weak_callback,
|
8125
8572
|
WeakCallbackType type);
|
8126
|
-
static void MakeWeak(internal::
|
8127
|
-
|
8128
|
-
|
8129
|
-
// Must be 1 or -1.
|
8130
|
-
int internal_field_index2,
|
8131
|
-
WeakCallbackInfo<void>::Callback weak_callback);
|
8132
|
-
static void MakeWeak(internal::Object*** location_addr);
|
8133
|
-
static void* ClearWeak(internal::Object** location);
|
8134
|
-
static void AnnotateStrongRetainer(internal::Object** location,
|
8573
|
+
static void MakeWeak(internal::Address** location_addr);
|
8574
|
+
static void* ClearWeak(internal::Address* location);
|
8575
|
+
static void AnnotateStrongRetainer(internal::Address* location,
|
8135
8576
|
const char* label);
|
8136
8577
|
static Value* Eternalize(Isolate* isolate, Value* handle);
|
8137
8578
|
|
8138
|
-
static void RegisterExternallyReferencedObject(internal::
|
8579
|
+
static void RegisterExternallyReferencedObject(internal::Address* location,
|
8139
8580
|
internal::Isolate* isolate);
|
8140
8581
|
|
8141
8582
|
template <class K, class V, class T>
|
@@ -8164,6 +8605,18 @@ class V8_EXPORT SnapshotCreator {
|
|
8164
8605
|
public:
|
8165
8606
|
enum class FunctionCodeHandling { kClear, kKeep };
|
8166
8607
|
|
8608
|
+
/**
|
8609
|
+
* Initialize and enter an isolate, and set it up for serialization.
|
8610
|
+
* The isolate is either created from scratch or from an existing snapshot.
|
8611
|
+
* The caller keeps ownership of the argument snapshot.
|
8612
|
+
* \param existing_blob existing snapshot from which to create this one.
|
8613
|
+
* \param external_references a null-terminated array of external references
|
8614
|
+
* that must be equivalent to CreateParams::external_references.
|
8615
|
+
*/
|
8616
|
+
SnapshotCreator(Isolate* isolate,
|
8617
|
+
const intptr_t* external_references = nullptr,
|
8618
|
+
StartupData* existing_blob = nullptr);
|
8619
|
+
|
8167
8620
|
/**
|
8168
8621
|
* Create and enter an isolate, and set it up for serialization.
|
8169
8622
|
* The isolate is either created from scratch or from an existing snapshot.
|
@@ -8244,8 +8697,8 @@ class V8_EXPORT SnapshotCreator {
|
|
8244
8697
|
void operator=(const SnapshotCreator&) = delete;
|
8245
8698
|
|
8246
8699
|
private:
|
8247
|
-
size_t AddData(Local<Context> context, internal::
|
8248
|
-
size_t AddData(internal::
|
8700
|
+
size_t AddData(Local<Context> context, internal::Address object);
|
8701
|
+
size_t AddData(internal::Address object);
|
8249
8702
|
|
8250
8703
|
void* data_;
|
8251
8704
|
};
|
@@ -8271,6 +8724,14 @@ class Maybe {
|
|
8271
8724
|
*/
|
8272
8725
|
V8_INLINE T ToChecked() const { return FromJust(); }
|
8273
8726
|
|
8727
|
+
/**
|
8728
|
+
* Short-hand for ToChecked(), which doesn't return a value. To be used, where
|
8729
|
+
* the actual value of the Maybe is not needed like Object::Set.
|
8730
|
+
*/
|
8731
|
+
V8_INLINE void Check() const {
|
8732
|
+
if (V8_UNLIKELY(!IsJust())) V8::FromJustIsNothing();
|
8733
|
+
}
|
8734
|
+
|
8274
8735
|
/**
|
8275
8736
|
* Converts this Maybe<> to a value of type T. If this Maybe<> is
|
8276
8737
|
* nothing (empty), |false| is returned and |out| is left untouched.
|
@@ -8426,7 +8887,6 @@ class V8_EXPORT TryCatch {
|
|
8426
8887
|
* Returns the .stack property of the thrown object. If no .stack
|
8427
8888
|
* property is present an empty handle is returned.
|
8428
8889
|
*/
|
8429
|
-
V8_DEPRECATED("Use maybe version.", Local<Value> StackTrace() const);
|
8430
8890
|
V8_WARN_UNUSED_RESULT MaybeLocal<Value> StackTrace(
|
8431
8891
|
Local<Context> context) const;
|
8432
8892
|
|
@@ -8485,7 +8945,7 @@ class V8_EXPORT TryCatch {
|
|
8485
8945
|
* of the C++ try catch handler itself.
|
8486
8946
|
*/
|
8487
8947
|
static void* JSStackComparableAddress(TryCatch* handler) {
|
8488
|
-
if (handler ==
|
8948
|
+
if (handler == nullptr) return nullptr;
|
8489
8949
|
return handler->js_stack_comparable_address_;
|
8490
8950
|
}
|
8491
8951
|
|
@@ -8525,7 +8985,7 @@ class V8_EXPORT TryCatch {
|
|
8525
8985
|
*/
|
8526
8986
|
class V8_EXPORT ExtensionConfiguration {
|
8527
8987
|
public:
|
8528
|
-
ExtensionConfiguration() : name_count_(0), names_(
|
8988
|
+
ExtensionConfiguration() : name_count_(0), names_(nullptr) {}
|
8529
8989
|
ExtensionConfiguration(int name_count, const char* names[])
|
8530
8990
|
: name_count_(name_count), names_(names) { }
|
8531
8991
|
|
@@ -8582,7 +9042,7 @@ class V8_EXPORT Context {
|
|
8582
9042
|
* and only object identify will remain.
|
8583
9043
|
*/
|
8584
9044
|
static Local<Context> New(
|
8585
|
-
Isolate* isolate, ExtensionConfiguration* extensions =
|
9045
|
+
Isolate* isolate, ExtensionConfiguration* extensions = nullptr,
|
8586
9046
|
MaybeLocal<ObjectTemplate> global_template = MaybeLocal<ObjectTemplate>(),
|
8587
9047
|
MaybeLocal<Value> global_object = MaybeLocal<Value>(),
|
8588
9048
|
DeserializeInternalFieldsCallback internal_fields_deserializer =
|
@@ -8767,7 +9227,7 @@ class V8_EXPORT Context {
|
|
8767
9227
|
* stack.
|
8768
9228
|
* https://html.spec.whatwg.org/multipage/webappapis.html#backup-incumbent-settings-object-stack
|
8769
9229
|
*/
|
8770
|
-
class V8_EXPORT BackupIncumbentScope {
|
9230
|
+
class V8_EXPORT BackupIncumbentScope final {
|
8771
9231
|
public:
|
8772
9232
|
/**
|
8773
9233
|
* |backup_incumbent_context| is pushed onto the backup incumbent settings
|
@@ -8776,10 +9236,20 @@ class V8_EXPORT Context {
|
|
8776
9236
|
explicit BackupIncumbentScope(Local<Context> backup_incumbent_context);
|
8777
9237
|
~BackupIncumbentScope();
|
8778
9238
|
|
9239
|
+
/**
|
9240
|
+
* Returns address that is comparable with JS stack address. Note that JS
|
9241
|
+
* stack may be allocated separately from the native stack. See also
|
9242
|
+
* |TryCatch::JSStackComparableAddress| for details.
|
9243
|
+
*/
|
9244
|
+
uintptr_t JSStackComparableAddress() const {
|
9245
|
+
return js_stack_comparable_address_;
|
9246
|
+
}
|
9247
|
+
|
8779
9248
|
private:
|
8780
9249
|
friend class internal::Isolate;
|
8781
9250
|
|
8782
9251
|
Local<Context> backup_incumbent_context_;
|
9252
|
+
uintptr_t js_stack_comparable_address_ = 0;
|
8783
9253
|
const BackupIncumbentScope* prev_ = nullptr;
|
8784
9254
|
};
|
8785
9255
|
|
@@ -8789,7 +9259,7 @@ class V8_EXPORT Context {
|
|
8789
9259
|
friend class Object;
|
8790
9260
|
friend class Function;
|
8791
9261
|
|
8792
|
-
internal::
|
9262
|
+
internal::Address* GetDataFromSnapshotOnce(size_t index);
|
8793
9263
|
Local<Value> SlowGetEmbedderData(int index);
|
8794
9264
|
void* SlowGetAlignedPointerFromEmbedderData(int index);
|
8795
9265
|
};
|
@@ -8918,282 +9388,57 @@ class V8_EXPORT Locker {
|
|
8918
9388
|
internal::Isolate* isolate_;
|
8919
9389
|
};
|
8920
9390
|
|
8921
|
-
|
8922
|
-
// --- Implementation ---
|
8923
|
-
|
8924
|
-
|
8925
|
-
namespace internal {
|
8926
|
-
|
8927
|
-
const int kApiPointerSize = sizeof(void*); // NOLINT
|
8928
|
-
const int kApiIntSize = sizeof(int); // NOLINT
|
8929
|
-
const int kApiInt64Size = sizeof(int64_t); // NOLINT
|
8930
|
-
|
8931
|
-
// Tag information for HeapObject.
|
8932
|
-
const int kHeapObjectTag = 1;
|
8933
|
-
const int kWeakHeapObjectTag = 3;
|
8934
|
-
const int kHeapObjectTagSize = 2;
|
8935
|
-
const intptr_t kHeapObjectTagMask = (1 << kHeapObjectTagSize) - 1;
|
8936
|
-
|
8937
|
-
// Tag information for Smi.
|
8938
|
-
const int kSmiTag = 0;
|
8939
|
-
const int kSmiTagSize = 1;
|
8940
|
-
const intptr_t kSmiTagMask = (1 << kSmiTagSize) - 1;
|
8941
|
-
|
8942
|
-
template <size_t ptr_size> struct SmiTagging;
|
8943
|
-
|
8944
|
-
template<int kSmiShiftSize>
|
8945
|
-
V8_INLINE internal::Object* IntToSmi(int value) {
|
8946
|
-
int smi_shift_bits = kSmiTagSize + kSmiShiftSize;
|
8947
|
-
uintptr_t tagged_value =
|
8948
|
-
(static_cast<uintptr_t>(value) << smi_shift_bits) | kSmiTag;
|
8949
|
-
return reinterpret_cast<internal::Object*>(tagged_value);
|
8950
|
-
}
|
8951
|
-
|
8952
|
-
// Smi constants for 32-bit systems.
|
8953
|
-
template <> struct SmiTagging<4> {
|
8954
|
-
enum { kSmiShiftSize = 0, kSmiValueSize = 31 };
|
8955
|
-
static int SmiShiftSize() { return kSmiShiftSize; }
|
8956
|
-
static int SmiValueSize() { return kSmiValueSize; }
|
8957
|
-
V8_INLINE static int SmiToInt(const internal::Object* value) {
|
8958
|
-
int shift_bits = kSmiTagSize + kSmiShiftSize;
|
8959
|
-
// Throw away top 32 bits and shift down (requires >> to be sign extending).
|
8960
|
-
return static_cast<int>(reinterpret_cast<intptr_t>(value)) >> shift_bits;
|
8961
|
-
}
|
8962
|
-
V8_INLINE static internal::Object* IntToSmi(int value) {
|
8963
|
-
return internal::IntToSmi<kSmiShiftSize>(value);
|
8964
|
-
}
|
8965
|
-
V8_INLINE static bool IsValidSmi(intptr_t value) {
|
8966
|
-
// To be representable as an tagged small integer, the two
|
8967
|
-
// most-significant bits of 'value' must be either 00 or 11 due to
|
8968
|
-
// sign-extension. To check this we add 01 to the two
|
8969
|
-
// most-significant bits, and check if the most-significant bit is 0
|
8970
|
-
//
|
8971
|
-
// CAUTION: The original code below:
|
8972
|
-
// bool result = ((value + 0x40000000) & 0x80000000) == 0;
|
8973
|
-
// may lead to incorrect results according to the C language spec, and
|
8974
|
-
// in fact doesn't work correctly with gcc4.1.1 in some cases: The
|
8975
|
-
// compiler may produce undefined results in case of signed integer
|
8976
|
-
// overflow. The computation must be done w/ unsigned ints.
|
8977
|
-
return static_cast<uintptr_t>(value + 0x40000000U) < 0x80000000U;
|
8978
|
-
}
|
8979
|
-
};
|
8980
|
-
|
8981
|
-
// Smi constants for 64-bit systems.
|
8982
|
-
template <> struct SmiTagging<8> {
|
8983
|
-
enum { kSmiShiftSize = 31, kSmiValueSize = 32 };
|
8984
|
-
static int SmiShiftSize() { return kSmiShiftSize; }
|
8985
|
-
static int SmiValueSize() { return kSmiValueSize; }
|
8986
|
-
V8_INLINE static int SmiToInt(const internal::Object* value) {
|
8987
|
-
int shift_bits = kSmiTagSize + kSmiShiftSize;
|
8988
|
-
// Shift down and throw away top 32 bits.
|
8989
|
-
return static_cast<int>(reinterpret_cast<intptr_t>(value) >> shift_bits);
|
8990
|
-
}
|
8991
|
-
V8_INLINE static internal::Object* IntToSmi(int value) {
|
8992
|
-
return internal::IntToSmi<kSmiShiftSize>(value);
|
8993
|
-
}
|
8994
|
-
V8_INLINE static bool IsValidSmi(intptr_t value) {
|
8995
|
-
// To be representable as a long smi, the value must be a 32-bit integer.
|
8996
|
-
return (value == static_cast<int32_t>(value));
|
8997
|
-
}
|
8998
|
-
};
|
8999
|
-
|
9000
|
-
typedef SmiTagging<kApiPointerSize> PlatformSmiTagging;
|
9001
|
-
const int kSmiShiftSize = PlatformSmiTagging::kSmiShiftSize;
|
9002
|
-
const int kSmiValueSize = PlatformSmiTagging::kSmiValueSize;
|
9003
|
-
V8_INLINE static bool SmiValuesAre31Bits() { return kSmiValueSize == 31; }
|
9004
|
-
V8_INLINE static bool SmiValuesAre32Bits() { return kSmiValueSize == 32; }
|
9005
|
-
|
9006
9391
|
/**
|
9007
|
-
*
|
9008
|
-
*
|
9009
|
-
*
|
9392
|
+
* Various helpers for skipping over V8 frames in a given stack.
|
9393
|
+
*
|
9394
|
+
* The unwinder API is only supported on the x64 architecture.
|
9010
9395
|
*/
|
9011
|
-
class
|
9396
|
+
class V8_EXPORT Unwinder {
|
9012
9397
|
public:
|
9013
|
-
|
9014
|
-
|
9015
|
-
|
9016
|
-
|
9017
|
-
|
9018
|
-
|
9019
|
-
|
9020
|
-
|
9021
|
-
|
9022
|
-
|
9023
|
-
|
9024
|
-
|
9025
|
-
|
9026
|
-
|
9027
|
-
|
9028
|
-
|
9029
|
-
|
9030
|
-
|
9031
|
-
|
9032
|
-
|
9033
|
-
|
9034
|
-
|
9035
|
-
|
9036
|
-
|
9037
|
-
|
9038
|
-
|
9039
|
-
|
9040
|
-
|
9041
|
-
static const
|
9042
|
-
|
9043
|
-
|
9044
|
-
static const int kEmptyStringRootIndex = 9;
|
9045
|
-
|
9046
|
-
static const int kNodeClassIdOffset = 1 * kApiPointerSize;
|
9047
|
-
static const int kNodeFlagsOffset = 1 * kApiPointerSize + 3;
|
9048
|
-
static const int kNodeStateMask = 0x7;
|
9049
|
-
static const int kNodeStateIsWeakValue = 2;
|
9050
|
-
static const int kNodeStateIsPendingValue = 3;
|
9051
|
-
static const int kNodeStateIsNearDeathValue = 4;
|
9052
|
-
static const int kNodeIsIndependentShift = 3;
|
9053
|
-
static const int kNodeIsActiveShift = 4;
|
9054
|
-
|
9055
|
-
static const int kFirstNonstringType = 0x80;
|
9056
|
-
static const int kOddballType = 0x83;
|
9057
|
-
static const int kForeignType = 0x87;
|
9058
|
-
static const int kJSSpecialApiObjectType = 0x410;
|
9059
|
-
static const int kJSApiObjectType = 0x420;
|
9060
|
-
static const int kJSObjectType = 0x421;
|
9061
|
-
|
9062
|
-
static const int kUndefinedOddballKind = 5;
|
9063
|
-
static const int kNullOddballKind = 3;
|
9064
|
-
|
9065
|
-
static const uint32_t kNumIsolateDataSlots = 4;
|
9066
|
-
|
9067
|
-
V8_EXPORT static void CheckInitializedImpl(v8::Isolate* isolate);
|
9068
|
-
V8_INLINE static void CheckInitialized(v8::Isolate* isolate) {
|
9069
|
-
#ifdef V8_ENABLE_CHECKS
|
9070
|
-
CheckInitializedImpl(isolate);
|
9071
|
-
#endif
|
9072
|
-
}
|
9073
|
-
|
9074
|
-
V8_INLINE static bool HasHeapObjectTag(const internal::Object* value) {
|
9075
|
-
return ((reinterpret_cast<intptr_t>(value) & kHeapObjectTagMask) ==
|
9076
|
-
kHeapObjectTag);
|
9077
|
-
}
|
9078
|
-
|
9079
|
-
V8_INLINE static int SmiValue(const internal::Object* value) {
|
9080
|
-
return PlatformSmiTagging::SmiToInt(value);
|
9081
|
-
}
|
9082
|
-
|
9083
|
-
V8_INLINE static internal::Object* IntToSmi(int value) {
|
9084
|
-
return PlatformSmiTagging::IntToSmi(value);
|
9085
|
-
}
|
9086
|
-
|
9087
|
-
V8_INLINE static bool IsValidSmi(intptr_t value) {
|
9088
|
-
return PlatformSmiTagging::IsValidSmi(value);
|
9089
|
-
}
|
9090
|
-
|
9091
|
-
V8_INLINE static int GetInstanceType(const internal::Object* obj) {
|
9092
|
-
typedef internal::Object O;
|
9093
|
-
O* map = ReadField<O*>(obj, kHeapObjectMapOffset);
|
9094
|
-
return ReadField<uint16_t>(map, kMapInstanceTypeOffset);
|
9095
|
-
}
|
9096
|
-
|
9097
|
-
V8_INLINE static int GetOddballKind(const internal::Object* obj) {
|
9098
|
-
typedef internal::Object O;
|
9099
|
-
return SmiValue(ReadField<O*>(obj, kOddballKindOffset));
|
9100
|
-
}
|
9101
|
-
|
9102
|
-
V8_INLINE static bool IsExternalTwoByteString(int instance_type) {
|
9103
|
-
int representation = (instance_type & kFullStringRepresentationMask);
|
9104
|
-
return representation == kExternalTwoByteRepresentationTag;
|
9105
|
-
}
|
9106
|
-
|
9107
|
-
V8_INLINE static uint8_t GetNodeFlag(internal::Object** obj, int shift) {
|
9108
|
-
uint8_t* addr = reinterpret_cast<uint8_t*>(obj) + kNodeFlagsOffset;
|
9109
|
-
return *addr & static_cast<uint8_t>(1U << shift);
|
9110
|
-
}
|
9111
|
-
|
9112
|
-
V8_INLINE static void UpdateNodeFlag(internal::Object** obj,
|
9113
|
-
bool value, int shift) {
|
9114
|
-
uint8_t* addr = reinterpret_cast<uint8_t*>(obj) + kNodeFlagsOffset;
|
9115
|
-
uint8_t mask = static_cast<uint8_t>(1U << shift);
|
9116
|
-
*addr = static_cast<uint8_t>((*addr & ~mask) | (value << shift));
|
9117
|
-
}
|
9118
|
-
|
9119
|
-
V8_INLINE static uint8_t GetNodeState(internal::Object** obj) {
|
9120
|
-
uint8_t* addr = reinterpret_cast<uint8_t*>(obj) + kNodeFlagsOffset;
|
9121
|
-
return *addr & kNodeStateMask;
|
9122
|
-
}
|
9123
|
-
|
9124
|
-
V8_INLINE static void UpdateNodeState(internal::Object** obj,
|
9125
|
-
uint8_t value) {
|
9126
|
-
uint8_t* addr = reinterpret_cast<uint8_t*>(obj) + kNodeFlagsOffset;
|
9127
|
-
*addr = static_cast<uint8_t>((*addr & ~kNodeStateMask) | value);
|
9128
|
-
}
|
9129
|
-
|
9130
|
-
V8_INLINE static void SetEmbedderData(v8::Isolate* isolate,
|
9131
|
-
uint32_t slot,
|
9132
|
-
void* data) {
|
9133
|
-
uint8_t* addr = reinterpret_cast<uint8_t*>(isolate) +
|
9134
|
-
kIsolateEmbedderDataOffset + slot * kApiPointerSize;
|
9135
|
-
*reinterpret_cast<void**>(addr) = data;
|
9136
|
-
}
|
9137
|
-
|
9138
|
-
V8_INLINE static void* GetEmbedderData(const v8::Isolate* isolate,
|
9139
|
-
uint32_t slot) {
|
9140
|
-
const uint8_t* addr = reinterpret_cast<const uint8_t*>(isolate) +
|
9141
|
-
kIsolateEmbedderDataOffset + slot * kApiPointerSize;
|
9142
|
-
return *reinterpret_cast<void* const*>(addr);
|
9143
|
-
}
|
9144
|
-
|
9145
|
-
V8_INLINE static internal::Object** GetRoot(v8::Isolate* isolate,
|
9146
|
-
int index) {
|
9147
|
-
uint8_t* addr = reinterpret_cast<uint8_t*>(isolate) + kIsolateRootsOffset;
|
9148
|
-
return reinterpret_cast<internal::Object**>(addr + index * kApiPointerSize);
|
9149
|
-
}
|
9150
|
-
|
9151
|
-
template <typename T>
|
9152
|
-
V8_INLINE static T ReadField(const internal::Object* ptr, int offset) {
|
9153
|
-
const uint8_t* addr =
|
9154
|
-
reinterpret_cast<const uint8_t*>(ptr) + offset - kHeapObjectTag;
|
9155
|
-
return *reinterpret_cast<const T*>(addr);
|
9156
|
-
}
|
9157
|
-
|
9158
|
-
template <typename T>
|
9159
|
-
V8_INLINE static T ReadEmbedderData(const v8::Context* context, int index) {
|
9160
|
-
typedef internal::Object O;
|
9161
|
-
typedef internal::Internals I;
|
9162
|
-
O* ctx = *reinterpret_cast<O* const*>(context);
|
9163
|
-
int embedder_data_offset = I::kContextHeaderSize +
|
9164
|
-
(internal::kApiPointerSize * I::kContextEmbedderDataIndex);
|
9165
|
-
O* embedder_data = I::ReadField<O*>(ctx, embedder_data_offset);
|
9166
|
-
int value_offset =
|
9167
|
-
I::kFixedArrayHeaderSize + (internal::kApiPointerSize * index);
|
9168
|
-
return I::ReadField<T>(embedder_data, value_offset);
|
9169
|
-
}
|
9170
|
-
};
|
9398
|
+
/**
|
9399
|
+
* Attempt to unwind the stack to the most recent C++ frame. This function is
|
9400
|
+
* signal-safe and does not access any V8 state and thus doesn't require an
|
9401
|
+
* Isolate.
|
9402
|
+
*
|
9403
|
+
* The unwinder needs to know the location of the JS Entry Stub (a piece of
|
9404
|
+
* code that is run when C++ code calls into generated JS code). This is used
|
9405
|
+
* for edge cases where the current frame is being constructed or torn down
|
9406
|
+
* when the stack sample occurs.
|
9407
|
+
*
|
9408
|
+
* The unwinder also needs the virtual memory range of all possible V8 code
|
9409
|
+
* objects. There are two ranges required - the heap code range and the range
|
9410
|
+
* for code embedded in the binary. The V8 API provides all required inputs
|
9411
|
+
* via an UnwindState object through the Isolate::GetUnwindState() API. These
|
9412
|
+
* values will not change after Isolate initialization, so the same
|
9413
|
+
* |unwind_state| can be used for multiple calls.
|
9414
|
+
*
|
9415
|
+
* \param unwind_state Input state for the Isolate that the stack comes from.
|
9416
|
+
* \param register_state The current registers. This is an in-out param that
|
9417
|
+
* will be overwritten with the register values after unwinding, on success.
|
9418
|
+
* \param stack_base The resulting stack pointer and frame pointer values are
|
9419
|
+
* bounds-checked against the stack_base and the original stack pointer value
|
9420
|
+
* to ensure that they are valid locations in the given stack. If these values
|
9421
|
+
* or any intermediate frame pointer values used during unwinding are ever out
|
9422
|
+
* of these bounds, unwinding will fail.
|
9423
|
+
*
|
9424
|
+
* \return True on success.
|
9425
|
+
*/
|
9426
|
+
static bool TryUnwindV8Frames(const UnwindState& unwind_state,
|
9427
|
+
RegisterState* register_state,
|
9428
|
+
const void* stack_base);
|
9171
9429
|
|
9172
|
-
|
9173
|
-
|
9174
|
-
|
9175
|
-
|
9176
|
-
|
9177
|
-
|
9430
|
+
/**
|
9431
|
+
* Whether the PC is within the V8 code range represented by code_range or
|
9432
|
+
* embedded_code_range in |unwind_state|.
|
9433
|
+
*
|
9434
|
+
* If this returns false, then calling UnwindV8Frames() with the same PC
|
9435
|
+
* and unwind_state will always fail. If it returns true, then unwinding may
|
9436
|
+
* (but not necessarily) be successful.
|
9437
|
+
*/
|
9438
|
+
static bool PCIsInV8(const UnwindState& unwind_state, void* pc);
|
9178
9439
|
};
|
9179
9440
|
|
9180
|
-
|
9181
|
-
template <class T>
|
9182
|
-
void CastCheck<true>::Perform(T* data) {
|
9183
|
-
T::Cast(data);
|
9184
|
-
}
|
9185
|
-
|
9186
|
-
template <>
|
9187
|
-
template <class T>
|
9188
|
-
void CastCheck<false>::Perform(T* data) {}
|
9189
|
-
|
9190
|
-
template <class T>
|
9191
|
-
V8_INLINE void PerformCastCheck(T* data) {
|
9192
|
-
CastCheck<std::is_base_of<Data, T>::value>::Perform(data);
|
9193
|
-
}
|
9194
|
-
|
9195
|
-
} // namespace internal
|
9196
|
-
|
9441
|
+
// --- Implementation ---
|
9197
9442
|
|
9198
9443
|
template <class T>
|
9199
9444
|
Local<T> Local<T>::New(Isolate* isolate, Local<T> that) {
|
@@ -9208,9 +9453,9 @@ Local<T> Local<T>::New(Isolate* isolate, const PersistentBase<T>& that) {
|
|
9208
9453
|
|
9209
9454
|
template <class T>
|
9210
9455
|
Local<T> Local<T>::New(Isolate* isolate, T* that) {
|
9211
|
-
if (that ==
|
9456
|
+
if (that == nullptr) return Local<T>();
|
9212
9457
|
T* that_ptr = that;
|
9213
|
-
internal::
|
9458
|
+
internal::Address* p = reinterpret_cast<internal::Address*>(that_ptr);
|
9214
9459
|
return Local<T>(reinterpret_cast<T*>(HandleScope::CreateHandle(
|
9215
9460
|
reinterpret_cast<internal::Isolate*>(isolate), *p)));
|
9216
9461
|
}
|
@@ -9252,8 +9497,8 @@ void* WeakCallbackInfo<T>::GetInternalField(int index) const {
|
|
9252
9497
|
|
9253
9498
|
template <class T>
|
9254
9499
|
T* PersistentBase<T>::New(Isolate* isolate, T* that) {
|
9255
|
-
if (that ==
|
9256
|
-
internal::
|
9500
|
+
if (that == nullptr) return nullptr;
|
9501
|
+
internal::Address* p = reinterpret_cast<internal::Address*>(that);
|
9257
9502
|
return reinterpret_cast<T*>(
|
9258
9503
|
V8::GlobalizeReference(reinterpret_cast<internal::Isolate*>(isolate),
|
9259
9504
|
p));
|
@@ -9266,7 +9511,7 @@ void Persistent<T, M>::Copy(const Persistent<S, M2>& that) {
|
|
9266
9511
|
TYPE_CHECK(T, S);
|
9267
9512
|
this->Reset();
|
9268
9513
|
if (that.IsEmpty()) return;
|
9269
|
-
internal::
|
9514
|
+
internal::Address* p = reinterpret_cast<internal::Address*>(that.val_);
|
9270
9515
|
this->val_ = reinterpret_cast<T*>(V8::CopyPersistent(p));
|
9271
9516
|
M::Copy(that, this);
|
9272
9517
|
}
|
@@ -9275,7 +9520,7 @@ template <class T>
|
|
9275
9520
|
bool PersistentBase<T>::IsIndependent() const {
|
9276
9521
|
typedef internal::Internals I;
|
9277
9522
|
if (this->IsEmpty()) return false;
|
9278
|
-
return I::GetNodeFlag(reinterpret_cast<internal::
|
9523
|
+
return I::GetNodeFlag(reinterpret_cast<internal::Address*>(this->val_),
|
9279
9524
|
I::kNodeIsIndependentShift);
|
9280
9525
|
}
|
9281
9526
|
|
@@ -9284,7 +9529,7 @@ bool PersistentBase<T>::IsNearDeath() const {
|
|
9284
9529
|
typedef internal::Internals I;
|
9285
9530
|
if (this->IsEmpty()) return false;
|
9286
9531
|
uint8_t node_state =
|
9287
|
-
I::GetNodeState(reinterpret_cast<internal::
|
9532
|
+
I::GetNodeState(reinterpret_cast<internal::Address*>(this->val_));
|
9288
9533
|
return node_state == I::kNodeStateIsNearDeathValue ||
|
9289
9534
|
node_state == I::kNodeStateIsPendingValue;
|
9290
9535
|
}
|
@@ -9294,16 +9539,16 @@ template <class T>
|
|
9294
9539
|
bool PersistentBase<T>::IsWeak() const {
|
9295
9540
|
typedef internal::Internals I;
|
9296
9541
|
if (this->IsEmpty()) return false;
|
9297
|
-
return I::GetNodeState(reinterpret_cast<internal::
|
9298
|
-
|
9542
|
+
return I::GetNodeState(reinterpret_cast<internal::Address*>(this->val_)) ==
|
9543
|
+
I::kNodeStateIsWeakValue;
|
9299
9544
|
}
|
9300
9545
|
|
9301
9546
|
|
9302
9547
|
template <class T>
|
9303
9548
|
void PersistentBase<T>::Reset() {
|
9304
9549
|
if (this->IsEmpty()) return;
|
9305
|
-
V8::DisposeGlobal(reinterpret_cast<internal::
|
9306
|
-
val_ =
|
9550
|
+
V8::DisposeGlobal(reinterpret_cast<internal::Address*>(this->val_));
|
9551
|
+
val_ = nullptr;
|
9307
9552
|
}
|
9308
9553
|
|
9309
9554
|
|
@@ -9334,25 +9579,25 @@ V8_INLINE void PersistentBase<T>::SetWeak(
|
|
9334
9579
|
P* parameter, typename WeakCallbackInfo<P>::Callback callback,
|
9335
9580
|
WeakCallbackType type) {
|
9336
9581
|
typedef typename WeakCallbackInfo<void>::Callback Callback;
|
9337
|
-
V8::MakeWeak(reinterpret_cast<internal::
|
9582
|
+
V8::MakeWeak(reinterpret_cast<internal::Address*>(this->val_), parameter,
|
9338
9583
|
reinterpret_cast<Callback>(callback), type);
|
9339
9584
|
}
|
9340
9585
|
|
9341
9586
|
template <class T>
|
9342
9587
|
void PersistentBase<T>::SetWeak() {
|
9343
|
-
V8::MakeWeak(reinterpret_cast<internal::
|
9588
|
+
V8::MakeWeak(reinterpret_cast<internal::Address**>(&this->val_));
|
9344
9589
|
}
|
9345
9590
|
|
9346
9591
|
template <class T>
|
9347
9592
|
template <typename P>
|
9348
9593
|
P* PersistentBase<T>::ClearWeak() {
|
9349
9594
|
return reinterpret_cast<P*>(
|
9350
|
-
|
9595
|
+
V8::ClearWeak(reinterpret_cast<internal::Address*>(this->val_)));
|
9351
9596
|
}
|
9352
9597
|
|
9353
9598
|
template <class T>
|
9354
9599
|
void PersistentBase<T>::AnnotateStrongRetainer(const char* label) {
|
9355
|
-
V8::AnnotateStrongRetainer(reinterpret_cast<internal::
|
9600
|
+
V8::AnnotateStrongRetainer(reinterpret_cast<internal::Address*>(this->val_),
|
9356
9601
|
label);
|
9357
9602
|
}
|
9358
9603
|
|
@@ -9360,7 +9605,7 @@ template <class T>
|
|
9360
9605
|
void PersistentBase<T>::RegisterExternalReference(Isolate* isolate) const {
|
9361
9606
|
if (IsEmpty()) return;
|
9362
9607
|
V8::RegisterExternallyReferencedObject(
|
9363
|
-
reinterpret_cast<internal::
|
9608
|
+
reinterpret_cast<internal::Address*>(this->val_),
|
9364
9609
|
reinterpret_cast<internal::Isolate*>(isolate));
|
9365
9610
|
}
|
9366
9611
|
|
@@ -9368,7 +9613,7 @@ template <class T>
|
|
9368
9613
|
void PersistentBase<T>::MarkIndependent() {
|
9369
9614
|
typedef internal::Internals I;
|
9370
9615
|
if (this->IsEmpty()) return;
|
9371
|
-
I::UpdateNodeFlag(reinterpret_cast<internal::
|
9616
|
+
I::UpdateNodeFlag(reinterpret_cast<internal::Address*>(this->val_), true,
|
9372
9617
|
I::kNodeIsIndependentShift);
|
9373
9618
|
}
|
9374
9619
|
|
@@ -9376,7 +9621,7 @@ template <class T>
|
|
9376
9621
|
void PersistentBase<T>::MarkActive() {
|
9377
9622
|
typedef internal::Internals I;
|
9378
9623
|
if (this->IsEmpty()) return;
|
9379
|
-
I::UpdateNodeFlag(reinterpret_cast<internal::
|
9624
|
+
I::UpdateNodeFlag(reinterpret_cast<internal::Address*>(this->val_), true,
|
9380
9625
|
I::kNodeIsActiveShift);
|
9381
9626
|
}
|
9382
9627
|
|
@@ -9385,7 +9630,7 @@ template <class T>
|
|
9385
9630
|
void PersistentBase<T>::SetWrapperClassId(uint16_t class_id) {
|
9386
9631
|
typedef internal::Internals I;
|
9387
9632
|
if (this->IsEmpty()) return;
|
9388
|
-
internal::
|
9633
|
+
internal::Address* obj = reinterpret_cast<internal::Address*>(this->val_);
|
9389
9634
|
uint8_t* addr = reinterpret_cast<uint8_t*>(obj) + I::kNodeClassIdOffset;
|
9390
9635
|
*reinterpret_cast<uint16_t*>(addr) = class_id;
|
9391
9636
|
}
|
@@ -9395,14 +9640,13 @@ template <class T>
|
|
9395
9640
|
uint16_t PersistentBase<T>::WrapperClassId() const {
|
9396
9641
|
typedef internal::Internals I;
|
9397
9642
|
if (this->IsEmpty()) return 0;
|
9398
|
-
internal::
|
9643
|
+
internal::Address* obj = reinterpret_cast<internal::Address*>(this->val_);
|
9399
9644
|
uint8_t* addr = reinterpret_cast<uint8_t*>(obj) + I::kNodeClassIdOffset;
|
9400
9645
|
return *reinterpret_cast<uint16_t*>(addr);
|
9401
9646
|
}
|
9402
9647
|
|
9403
|
-
|
9404
|
-
|
9405
|
-
ReturnValue<T>::ReturnValue(internal::Object** slot) : value_(slot) {}
|
9648
|
+
template <typename T>
|
9649
|
+
ReturnValue<T>::ReturnValue(internal::Address* slot) : value_(slot) {}
|
9406
9650
|
|
9407
9651
|
template<typename T>
|
9408
9652
|
template<typename S>
|
@@ -9411,7 +9655,7 @@ void ReturnValue<T>::Set(const Persistent<S>& handle) {
|
|
9411
9655
|
if (V8_UNLIKELY(handle.IsEmpty())) {
|
9412
9656
|
*value_ = GetDefaultValue();
|
9413
9657
|
} else {
|
9414
|
-
*value_ = *reinterpret_cast<internal::
|
9658
|
+
*value_ = *reinterpret_cast<internal::Address*>(*handle);
|
9415
9659
|
}
|
9416
9660
|
}
|
9417
9661
|
|
@@ -9422,7 +9666,7 @@ void ReturnValue<T>::Set(const Global<S>& handle) {
|
|
9422
9666
|
if (V8_UNLIKELY(handle.IsEmpty())) {
|
9423
9667
|
*value_ = GetDefaultValue();
|
9424
9668
|
} else {
|
9425
|
-
*value_ = *reinterpret_cast<internal::
|
9669
|
+
*value_ = *reinterpret_cast<internal::Address*>(*handle);
|
9426
9670
|
}
|
9427
9671
|
}
|
9428
9672
|
|
@@ -9433,7 +9677,7 @@ void ReturnValue<T>::Set(const Local<S> handle) {
|
|
9433
9677
|
if (V8_UNLIKELY(handle.IsEmpty())) {
|
9434
9678
|
*value_ = GetDefaultValue();
|
9435
9679
|
} else {
|
9436
|
-
*value_ = *reinterpret_cast<internal::
|
9680
|
+
*value_ = *reinterpret_cast<internal::Address*>(*handle);
|
9437
9681
|
}
|
9438
9682
|
}
|
9439
9683
|
|
@@ -9521,15 +9765,15 @@ void ReturnValue<T>::Set(S* whatever) {
|
|
9521
9765
|
TYPE_CHECK(S*, Primitive);
|
9522
9766
|
}
|
9523
9767
|
|
9524
|
-
template<typename T>
|
9525
|
-
internal::
|
9768
|
+
template <typename T>
|
9769
|
+
internal::Address ReturnValue<T>::GetDefaultValue() {
|
9526
9770
|
// Default value is always the pointer below value_ on the stack.
|
9527
9771
|
return value_[-1];
|
9528
9772
|
}
|
9529
9773
|
|
9530
9774
|
template <typename T>
|
9531
|
-
FunctionCallbackInfo<T>::FunctionCallbackInfo(internal::
|
9532
|
-
internal::
|
9775
|
+
FunctionCallbackInfo<T>::FunctionCallbackInfo(internal::Address* implicit_args,
|
9776
|
+
internal::Address* values,
|
9533
9777
|
int length)
|
9534
9778
|
: implicit_args_(implicit_args), values_(values), length_(length) {}
|
9535
9779
|
|
@@ -9698,20 +9942,22 @@ AccessorSignature* AccessorSignature::Cast(Data* data) {
|
|
9698
9942
|
}
|
9699
9943
|
|
9700
9944
|
Local<Value> Object::GetInternalField(int index) {
|
9701
|
-
#
|
9702
|
-
typedef internal::
|
9703
|
-
typedef internal::HeapObject HO;
|
9945
|
+
#if !defined(V8_ENABLE_CHECKS) && !defined(V8_COMPRESS_POINTERS)
|
9946
|
+
typedef internal::Address A;
|
9704
9947
|
typedef internal::Internals I;
|
9705
|
-
|
9948
|
+
A obj = *reinterpret_cast<A*>(this);
|
9706
9949
|
// Fast path: If the object is a plain JSObject, which is the common case, we
|
9707
9950
|
// know where to find the internal fields and can return the value directly.
|
9708
9951
|
auto instance_type = I::GetInstanceType(obj);
|
9709
9952
|
if (instance_type == I::kJSObjectType ||
|
9710
9953
|
instance_type == I::kJSApiObjectType ||
|
9711
9954
|
instance_type == I::kJSSpecialApiObjectType) {
|
9712
|
-
int offset = I::
|
9713
|
-
|
9714
|
-
|
9955
|
+
int offset = I::kJSObjectHeaderSizeForEmbedderFields +
|
9956
|
+
(I::kEmbedderDataSlotSize * index);
|
9957
|
+
A value = I::ReadTaggedAnyField(obj, offset);
|
9958
|
+
internal::Isolate* isolate =
|
9959
|
+
internal::IsolateFromNeverReadOnlySpaceObject(obj);
|
9960
|
+
A* result = HandleScope::CreateHandle(isolate, value);
|
9715
9961
|
return Local<Value>(reinterpret_cast<Value*>(result));
|
9716
9962
|
}
|
9717
9963
|
#endif
|
@@ -9720,18 +9966,19 @@ Local<Value> Object::GetInternalField(int index) {
|
|
9720
9966
|
|
9721
9967
|
|
9722
9968
|
void* Object::GetAlignedPointerFromInternalField(int index) {
|
9723
|
-
#
|
9724
|
-
typedef internal::
|
9969
|
+
#if !defined(V8_ENABLE_CHECKS) && !defined(V8_COMPRESS_POINTERS)
|
9970
|
+
typedef internal::Address A;
|
9725
9971
|
typedef internal::Internals I;
|
9726
|
-
|
9972
|
+
A obj = *reinterpret_cast<A*>(this);
|
9727
9973
|
// Fast path: If the object is a plain JSObject, which is the common case, we
|
9728
9974
|
// know where to find the internal fields and can return the value directly.
|
9729
9975
|
auto instance_type = I::GetInstanceType(obj);
|
9730
9976
|
if (V8_LIKELY(instance_type == I::kJSObjectType ||
|
9731
9977
|
instance_type == I::kJSApiObjectType ||
|
9732
9978
|
instance_type == I::kJSSpecialApiObjectType)) {
|
9733
|
-
int offset = I::
|
9734
|
-
|
9979
|
+
int offset = I::kJSObjectHeaderSizeForEmbedderFields +
|
9980
|
+
(I::kEmbedderDataSlotSize * index);
|
9981
|
+
return I::ReadRawField<void*>(obj, offset);
|
9735
9982
|
}
|
9736
9983
|
#endif
|
9737
9984
|
return SlowGetAlignedPointerFromInternalField(index);
|
@@ -9746,7 +9993,7 @@ String* String::Cast(v8::Value* value) {
|
|
9746
9993
|
|
9747
9994
|
|
9748
9995
|
Local<String> String::Empty(Isolate* isolate) {
|
9749
|
-
typedef internal::
|
9996
|
+
typedef internal::Address S;
|
9750
9997
|
typedef internal::Internals I;
|
9751
9998
|
I::CheckInitialized(isolate);
|
9752
9999
|
S* slot = I::GetRoot(isolate, I::kEmptyStringRootIndex);
|
@@ -9755,15 +10002,16 @@ Local<String> String::Empty(Isolate* isolate) {
|
|
9755
10002
|
|
9756
10003
|
|
9757
10004
|
String::ExternalStringResource* String::GetExternalStringResource() const {
|
9758
|
-
typedef internal::
|
10005
|
+
typedef internal::Address A;
|
9759
10006
|
typedef internal::Internals I;
|
9760
|
-
|
9761
|
-
|
10007
|
+
A obj = *reinterpret_cast<const A*>(this);
|
10008
|
+
|
10009
|
+
ExternalStringResource* result;
|
9762
10010
|
if (I::IsExternalTwoByteString(I::GetInstanceType(obj))) {
|
9763
|
-
void* value = I::
|
10011
|
+
void* value = I::ReadRawField<void*>(obj, I::kStringResourceOffset);
|
9764
10012
|
result = reinterpret_cast<String::ExternalStringResource*>(value);
|
9765
10013
|
} else {
|
9766
|
-
result =
|
10014
|
+
result = GetExternalStringResourceSlow();
|
9767
10015
|
}
|
9768
10016
|
#ifdef V8_ENABLE_CHECKS
|
9769
10017
|
VerifyExternalStringResource(result);
|
@@ -9774,19 +10022,21 @@ String::ExternalStringResource* String::GetExternalStringResource() const {
|
|
9774
10022
|
|
9775
10023
|
String::ExternalStringResourceBase* String::GetExternalStringResourceBase(
|
9776
10024
|
String::Encoding* encoding_out) const {
|
9777
|
-
typedef internal::
|
10025
|
+
typedef internal::Address A;
|
9778
10026
|
typedef internal::Internals I;
|
9779
|
-
|
10027
|
+
A obj = *reinterpret_cast<const A*>(this);
|
9780
10028
|
int type = I::GetInstanceType(obj) & I::kFullStringRepresentationMask;
|
9781
10029
|
*encoding_out = static_cast<Encoding>(type & I::kStringEncodingMask);
|
9782
|
-
ExternalStringResourceBase* resource
|
10030
|
+
ExternalStringResourceBase* resource;
|
9783
10031
|
if (type == I::kExternalOneByteRepresentationTag ||
|
9784
10032
|
type == I::kExternalTwoByteRepresentationTag) {
|
9785
|
-
void* value = I::
|
10033
|
+
void* value = I::ReadRawField<void*>(obj, I::kStringResourceOffset);
|
9786
10034
|
resource = static_cast<ExternalStringResourceBase*>(value);
|
10035
|
+
} else {
|
10036
|
+
resource = GetExternalStringResourceBaseSlow(encoding_out);
|
9787
10037
|
}
|
9788
10038
|
#ifdef V8_ENABLE_CHECKS
|
9789
|
-
|
10039
|
+
VerifyExternalStringResourceBase(resource, *encoding_out);
|
9790
10040
|
#endif
|
9791
10041
|
return resource;
|
9792
10042
|
}
|
@@ -9801,9 +10051,9 @@ bool Value::IsUndefined() const {
|
|
9801
10051
|
}
|
9802
10052
|
|
9803
10053
|
bool Value::QuickIsUndefined() const {
|
9804
|
-
typedef internal::
|
10054
|
+
typedef internal::Address A;
|
9805
10055
|
typedef internal::Internals I;
|
9806
|
-
|
10056
|
+
A obj = *reinterpret_cast<const A*>(this);
|
9807
10057
|
if (!I::HasHeapObjectTag(obj)) return false;
|
9808
10058
|
if (I::GetInstanceType(obj) != I::kOddballType) return false;
|
9809
10059
|
return (I::GetOddballKind(obj) == I::kUndefinedOddballKind);
|
@@ -9819,9 +10069,9 @@ bool Value::IsNull() const {
|
|
9819
10069
|
}
|
9820
10070
|
|
9821
10071
|
bool Value::QuickIsNull() const {
|
9822
|
-
typedef internal::
|
10072
|
+
typedef internal::Address A;
|
9823
10073
|
typedef internal::Internals I;
|
9824
|
-
|
10074
|
+
A obj = *reinterpret_cast<const A*>(this);
|
9825
10075
|
if (!I::HasHeapObjectTag(obj)) return false;
|
9826
10076
|
if (I::GetInstanceType(obj) != I::kOddballType) return false;
|
9827
10077
|
return (I::GetOddballKind(obj) == I::kNullOddballKind);
|
@@ -9836,9 +10086,9 @@ bool Value::IsNullOrUndefined() const {
|
|
9836
10086
|
}
|
9837
10087
|
|
9838
10088
|
bool Value::QuickIsNullOrUndefined() const {
|
9839
|
-
typedef internal::
|
10089
|
+
typedef internal::Address A;
|
9840
10090
|
typedef internal::Internals I;
|
9841
|
-
|
10091
|
+
A obj = *reinterpret_cast<const A*>(this);
|
9842
10092
|
if (!I::HasHeapObjectTag(obj)) return false;
|
9843
10093
|
if (I::GetInstanceType(obj) != I::kOddballType) return false;
|
9844
10094
|
int kind = I::GetOddballKind(obj);
|
@@ -9854,9 +10104,9 @@ bool Value::IsString() const {
|
|
9854
10104
|
}
|
9855
10105
|
|
9856
10106
|
bool Value::QuickIsString() const {
|
9857
|
-
typedef internal::
|
10107
|
+
typedef internal::Address A;
|
9858
10108
|
typedef internal::Internals I;
|
9859
|
-
|
10109
|
+
A obj = *reinterpret_cast<const A*>(this);
|
9860
10110
|
if (!I::HasHeapObjectTag(obj)) return false;
|
9861
10111
|
return (I::GetInstanceType(obj) < I::kFirstNonstringType);
|
9862
10112
|
}
|
@@ -9867,30 +10117,6 @@ template <class T> Value* Value::Cast(T* value) {
|
|
9867
10117
|
}
|
9868
10118
|
|
9869
10119
|
|
9870
|
-
Local<Boolean> Value::ToBoolean() const {
|
9871
|
-
return ToBoolean(Isolate::GetCurrent()->GetCurrentContext())
|
9872
|
-
.FromMaybe(Local<Boolean>());
|
9873
|
-
}
|
9874
|
-
|
9875
|
-
|
9876
|
-
Local<String> Value::ToString() const {
|
9877
|
-
return ToString(Isolate::GetCurrent()->GetCurrentContext())
|
9878
|
-
.FromMaybe(Local<String>());
|
9879
|
-
}
|
9880
|
-
|
9881
|
-
|
9882
|
-
Local<Object> Value::ToObject() const {
|
9883
|
-
return ToObject(Isolate::GetCurrent()->GetCurrentContext())
|
9884
|
-
.FromMaybe(Local<Object>());
|
9885
|
-
}
|
9886
|
-
|
9887
|
-
|
9888
|
-
Local<Integer> Value::ToInteger() const {
|
9889
|
-
return ToInteger(Isolate::GetCurrent()->GetCurrentContext())
|
9890
|
-
.FromMaybe(Local<Integer>());
|
9891
|
-
}
|
9892
|
-
|
9893
|
-
|
9894
10120
|
Boolean* Boolean::Cast(v8::Value* value) {
|
9895
10121
|
#ifdef V8_ENABLE_CHECKS
|
9896
10122
|
CheckCast(value);
|
@@ -10062,11 +10288,11 @@ Proxy* Proxy::Cast(v8::Value* value) {
|
|
10062
10288
|
return static_cast<Proxy*>(value);
|
10063
10289
|
}
|
10064
10290
|
|
10065
|
-
|
10291
|
+
WasmModuleObject* WasmModuleObject::Cast(v8::Value* value) {
|
10066
10292
|
#ifdef V8_ENABLE_CHECKS
|
10067
10293
|
CheckCast(value);
|
10068
10294
|
#endif
|
10069
|
-
return static_cast<
|
10295
|
+
return static_cast<WasmModuleObject*>(value);
|
10070
10296
|
}
|
10071
10297
|
|
10072
10298
|
Promise::Resolver* Promise::Resolver::Cast(v8::Value* value) {
|
@@ -10255,7 +10481,7 @@ bool PropertyCallbackInfo<T>::ShouldThrowOnError() const {
|
|
10255
10481
|
|
10256
10482
|
|
10257
10483
|
Local<Primitive> Undefined(Isolate* isolate) {
|
10258
|
-
typedef internal::
|
10484
|
+
typedef internal::Address S;
|
10259
10485
|
typedef internal::Internals I;
|
10260
10486
|
I::CheckInitialized(isolate);
|
10261
10487
|
S* slot = I::GetRoot(isolate, I::kUndefinedValueRootIndex);
|
@@ -10264,7 +10490,7 @@ Local<Primitive> Undefined(Isolate* isolate) {
|
|
10264
10490
|
|
10265
10491
|
|
10266
10492
|
Local<Primitive> Null(Isolate* isolate) {
|
10267
|
-
typedef internal::
|
10493
|
+
typedef internal::Address S;
|
10268
10494
|
typedef internal::Internals I;
|
10269
10495
|
I::CheckInitialized(isolate);
|
10270
10496
|
S* slot = I::GetRoot(isolate, I::kNullValueRootIndex);
|
@@ -10273,7 +10499,7 @@ Local<Primitive> Null(Isolate* isolate) {
|
|
10273
10499
|
|
10274
10500
|
|
10275
10501
|
Local<Boolean> True(Isolate* isolate) {
|
10276
|
-
typedef internal::
|
10502
|
+
typedef internal::Address S;
|
10277
10503
|
typedef internal::Internals I;
|
10278
10504
|
I::CheckInitialized(isolate);
|
10279
10505
|
S* slot = I::GetRoot(isolate, I::kTrueValueRootIndex);
|
@@ -10282,7 +10508,7 @@ Local<Boolean> True(Isolate* isolate) {
|
|
10282
10508
|
|
10283
10509
|
|
10284
10510
|
Local<Boolean> False(Isolate* isolate) {
|
10285
|
-
typedef internal::
|
10511
|
+
typedef internal::Address S;
|
10286
10512
|
typedef internal::Internals I;
|
10287
10513
|
I::CheckInitialized(isolate);
|
10288
10514
|
S* slot = I::GetRoot(isolate, I::kFalseValueRootIndex);
|
@@ -10317,7 +10543,7 @@ MaybeLocal<T> Isolate::GetDataFromSnapshotOnce(size_t index) {
|
|
10317
10543
|
int64_t Isolate::AdjustAmountOfExternalAllocatedMemory(
|
10318
10544
|
int64_t change_in_bytes) {
|
10319
10545
|
typedef internal::Internals I;
|
10320
|
-
|
10546
|
+
constexpr int64_t kMemoryReducerActivationLimit = 32 * 1024 * 1024;
|
10321
10547
|
int64_t* external_memory = reinterpret_cast<int64_t*>(
|
10322
10548
|
reinterpret_cast<uint8_t*>(this) + I::kExternalMemoryOffset);
|
10323
10549
|
int64_t* external_memory_limit = reinterpret_cast<int64_t*>(
|
@@ -10325,37 +10551,36 @@ int64_t Isolate::AdjustAmountOfExternalAllocatedMemory(
|
|
10325
10551
|
int64_t* external_memory_at_last_mc =
|
10326
10552
|
reinterpret_cast<int64_t*>(reinterpret_cast<uint8_t*>(this) +
|
10327
10553
|
I::kExternalMemoryAtLastMarkCompactOffset);
|
10328
|
-
const int64_t amount = *external_memory + change_in_bytes;
|
10329
10554
|
|
10555
|
+
const int64_t amount = *external_memory + change_in_bytes;
|
10330
10556
|
*external_memory = amount;
|
10331
10557
|
|
10332
10558
|
int64_t allocation_diff_since_last_mc =
|
10333
|
-
*
|
10334
|
-
|
10335
|
-
|
10336
|
-
: allocation_diff_since_last_mc;
|
10559
|
+
*external_memory - *external_memory_at_last_mc;
|
10560
|
+
// Only check memory pressure and potentially trigger GC if the amount of
|
10561
|
+
// external memory increased.
|
10337
10562
|
if (allocation_diff_since_last_mc > kMemoryReducerActivationLimit) {
|
10338
10563
|
CheckMemoryPressure();
|
10339
10564
|
}
|
10340
10565
|
|
10341
10566
|
if (change_in_bytes < 0) {
|
10342
|
-
*external_memory_limit
|
10343
|
-
|
10344
|
-
|
10345
|
-
if (change_in_bytes > 0 && amount > *external_memory_limit) {
|
10567
|
+
const int64_t lower_limit = *external_memory_limit + change_in_bytes;
|
10568
|
+
if (lower_limit > I::kExternalAllocationSoftLimit)
|
10569
|
+
*external_memory_limit = lower_limit;
|
10570
|
+
} else if (change_in_bytes > 0 && amount > *external_memory_limit) {
|
10346
10571
|
ReportExternalAllocationLimitReached();
|
10347
10572
|
}
|
10348
10573
|
return *external_memory;
|
10349
10574
|
}
|
10350
10575
|
|
10351
10576
|
Local<Value> Context::GetEmbedderData(int index) {
|
10352
|
-
#
|
10353
|
-
typedef internal::
|
10354
|
-
typedef internal::HeapObject HO;
|
10577
|
+
#if !defined(V8_ENABLE_CHECKS) && !defined(V8_COMPRESS_POINTERS)
|
10578
|
+
typedef internal::Address A;
|
10355
10579
|
typedef internal::Internals I;
|
10356
|
-
|
10357
|
-
|
10358
|
-
|
10580
|
+
internal::Isolate* isolate = internal::IsolateFromNeverReadOnlySpaceObject(
|
10581
|
+
*reinterpret_cast<A*>(this));
|
10582
|
+
A* result =
|
10583
|
+
HandleScope::CreateHandle(isolate, I::ReadEmbedderData<A>(this, index));
|
10359
10584
|
return Local<Value>(reinterpret_cast<Value*>(result));
|
10360
10585
|
#else
|
10361
10586
|
return SlowGetEmbedderData(index);
|
@@ -10364,7 +10589,7 @@ Local<Value> Context::GetEmbedderData(int index) {
|
|
10364
10589
|
|
10365
10590
|
|
10366
10591
|
void* Context::GetAlignedPointerFromEmbedderData(int index) {
|
10367
|
-
#
|
10592
|
+
#if !defined(V8_ENABLE_CHECKS) && !defined(V8_COMPRESS_POINTERS)
|
10368
10593
|
typedef internal::Internals I;
|
10369
10594
|
return I::ReadEmbedderData<void*>(this, index);
|
10370
10595
|
#else
|
@@ -10382,14 +10607,14 @@ MaybeLocal<T> Context::GetDataFromSnapshotOnce(size_t index) {
|
|
10382
10607
|
template <class T>
|
10383
10608
|
size_t SnapshotCreator::AddData(Local<Context> context, Local<T> object) {
|
10384
10609
|
T* object_ptr = *object;
|
10385
|
-
internal::
|
10610
|
+
internal::Address* p = reinterpret_cast<internal::Address*>(object_ptr);
|
10386
10611
|
return AddData(context, *p);
|
10387
10612
|
}
|
10388
10613
|
|
10389
10614
|
template <class T>
|
10390
10615
|
size_t SnapshotCreator::AddData(Local<T> object) {
|
10391
10616
|
T* object_ptr = *object;
|
10392
|
-
internal::
|
10617
|
+
internal::Address* p = reinterpret_cast<internal::Address*>(object_ptr);
|
10393
10618
|
return AddData(*p);
|
10394
10619
|
}
|
10395
10620
|
|