libv8 5.0.71.48.3-arm-linux → 5.3.332.38.1-arm-linux
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ext/libv8/arch.rb +1 -1
- data/ext/libv8/location.rb +12 -9
- data/ext/libv8/paths.rb +2 -2
- data/lib/libv8/version.rb +1 -1
- data/vendor/v8/include/libplatform/libplatform.h +1 -1
- data/vendor/v8/include/v8-debug.h +17 -4
- data/vendor/v8/include/v8-experimental.h +1 -1
- data/vendor/v8/include/v8-platform.h +3 -3
- data/vendor/v8/include/v8-profiler.h +8 -3
- data/vendor/v8/include/v8-util.h +18 -7
- data/vendor/v8/include/v8-version.h +3 -3
- data/vendor/v8/include/v8.h +595 -279
- data/vendor/v8/include/v8config.h +1 -7
- data/vendor/v8/out/arm.release/libv8_base.a +0 -0
- data/vendor/v8/out/arm.release/libv8_libbase.a +0 -0
- data/vendor/v8/out/arm.release/libv8_libplatform.a +0 -0
- data/vendor/v8/out/arm.release/libv8_libsampler.a +0 -0
- data/vendor/v8/out/arm.release/libv8_nosnapshot.a +0 -0
- data/vendor/v8/out/arm.release/libv8_snapshot.a +0 -0
- data/vendor/v8/out/arm.release/obj.target/{tools/gyp → src}/libv8_base.a +0 -0
- data/vendor/v8/out/arm.release/obj.target/src/libv8_libbase.a +0 -0
- data/vendor/v8/out/arm.release/obj.target/src/libv8_libplatform.a +0 -0
- data/vendor/v8/out/arm.release/obj.target/src/libv8_libsampler.a +0 -0
- data/vendor/v8/out/arm.release/obj.target/src/libv8_nosnapshot.a +0 -0
- data/vendor/v8/out/arm.release/obj.target/src/libv8_snapshot.a +0 -0
- metadata +31 -29
- data/vendor/v8/out/arm.release/obj.target/tools/gyp/libv8_libbase.a +0 -0
- data/vendor/v8/out/arm.release/obj.target/tools/gyp/libv8_libplatform.a +0 -0
- data/vendor/v8/out/arm.release/obj.target/tools/gyp/libv8_nosnapshot.a +0 -0
- data/vendor/v8/out/arm.release/obj.target/tools/gyp/libv8_snapshot.a +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c4fd9949049f7b4d0a1d6176a8126973f85a6997
|
4
|
+
data.tar.gz: 26f2a6388a73e15d91dab2c56cf3c720b62003bf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bfa008c9752336cd01168bcf38a818237ccd2d67d389cd21ea952ccb3e3c1891fcbfc0a294e9fb6d7c4ab3b9be134f2e6416d6fe935badf4094f373ff5f005f2
|
7
|
+
data.tar.gz: c49645cddbb93f7f16b6a00ab82d93571276b45d8fd5d9973a69df3ab8f44f3445a01c390c6c8b0b51bacb34fe978ef70b3247ac36766ea6e58df64fbca182e5
|
data/ext/libv8/arch.rb
CHANGED
data/ext/libv8/location.rb
CHANGED
@@ -26,21 +26,24 @@ module Libv8
|
|
26
26
|
verify_installation!
|
27
27
|
return exit_status
|
28
28
|
end
|
29
|
+
|
29
30
|
def configure(context = MkmfContext.new)
|
30
|
-
context.incflags.insert 0, Libv8::Paths.include_paths.map{|p| "-I#{p}"}.join(" ") + " "
|
31
|
+
context.incflags.insert 0, Libv8::Paths.include_paths.map{ |p| "-I#{p}" }.join(" ") + " "
|
31
32
|
context.ldflags.insert 0, Libv8::Paths.object_paths.join(" ") + " "
|
32
33
|
end
|
33
34
|
|
34
35
|
def verify_installation!
|
35
36
|
include_paths = Libv8::Paths.include_paths
|
36
|
-
unless include_paths.detect { |p| Pathname(p).join('
|
37
|
-
fail HeaderNotFound, "Unable to locate '
|
37
|
+
unless include_paths.detect { |p| Pathname(p).join('v8.h').exist? }
|
38
|
+
fail HeaderNotFound, "Unable to locate 'v8.h' in the libv8 header paths: #{include_paths.inspect}"
|
38
39
|
end
|
39
40
|
Libv8::Paths.object_paths.each do |p|
|
40
41
|
fail ArchiveNotFound, p unless File.exist? p
|
41
42
|
end
|
42
43
|
end
|
44
|
+
|
43
45
|
class HeaderNotFound < StandardError; end
|
46
|
+
|
44
47
|
class ArchiveNotFound < StandardError
|
45
48
|
def initialize(filename)
|
46
49
|
super "libv8 did not install properly, expected binary v8 archive '#{filename}'to exist, but it was not found"
|
@@ -59,14 +62,14 @@ module Libv8
|
|
59
62
|
class NotFoundError < StandardError
|
60
63
|
def initialize(*args)
|
61
64
|
super(<<-EOS)
|
62
|
-
By using --with-system-v8, you have chosen to use the version
|
63
|
-
of V8 found on your system and *not* the one that is bundled with
|
64
|
-
the libv8 rubygem.
|
65
|
+
By using --with-system-v8, you have chosen to use the version
|
66
|
+
of V8 found on your system and *not* the one that is bundled with
|
67
|
+
the libv8 rubygem.
|
65
68
|
|
66
|
-
However, your system version of v8 could not be located.
|
69
|
+
However, your system version of v8 could not be located.
|
67
70
|
|
68
|
-
Please make sure your system version of v8 that is compatible
|
69
|
-
with #{Libv8::VERSION} installed. You may need to use the
|
71
|
+
Please make sure your system version of v8 that is compatible
|
72
|
+
with #{Libv8::VERSION} installed. You may need to use the
|
70
73
|
--with-v8-dir option if it is installed in a non-standard location
|
71
74
|
EOS
|
72
75
|
end
|
data/ext/libv8/paths.rb
CHANGED
@@ -7,11 +7,11 @@ module Libv8
|
|
7
7
|
module_function
|
8
8
|
|
9
9
|
def include_paths
|
10
|
-
[Shellwords.escape(vendored_source_path)]
|
10
|
+
[Shellwords.escape(File.join(vendored_source_path, 'include'))]
|
11
11
|
end
|
12
12
|
|
13
13
|
def object_paths
|
14
|
-
[:base, :libplatform, :libbase, :snapshot].map do |name|
|
14
|
+
[:base, :libplatform, :libsampler, :libbase, :snapshot].map do |name|
|
15
15
|
Shellwords.escape libv8_object(name)
|
16
16
|
end
|
17
17
|
end
|
data/lib/libv8/version.rb
CHANGED
@@ -18,13 +18,11 @@ enum DebugEvent {
|
|
18
18
|
Exception = 2,
|
19
19
|
NewFunction = 3,
|
20
20
|
BeforeCompile = 4,
|
21
|
-
AfterCompile
|
21
|
+
AfterCompile = 5,
|
22
22
|
CompileError = 6,
|
23
|
-
|
24
|
-
AsyncTaskEvent = 8,
|
23
|
+
AsyncTaskEvent = 7,
|
25
24
|
};
|
26
25
|
|
27
|
-
|
28
26
|
class V8_EXPORT Debug {
|
29
27
|
public:
|
30
28
|
/**
|
@@ -127,6 +125,8 @@ class V8_EXPORT Debug {
|
|
127
125
|
*/
|
128
126
|
virtual ClientData* GetClientData() const = 0;
|
129
127
|
|
128
|
+
virtual Isolate* GetIsolate() const = 0;
|
129
|
+
|
130
130
|
virtual ~EventDetails() {}
|
131
131
|
};
|
132
132
|
|
@@ -261,6 +261,11 @@ class V8_EXPORT Debug {
|
|
261
261
|
V8_DEPRECATED("Use version with an Isolate",
|
262
262
|
static Local<Context> GetDebugContext());
|
263
263
|
|
264
|
+
/**
|
265
|
+
* While in the debug context, this method returns the top-most non-debug
|
266
|
+
* context, if it exists.
|
267
|
+
*/
|
268
|
+
static MaybeLocal<Context> GetDebuggedContext(Isolate* isolate);
|
264
269
|
|
265
270
|
/**
|
266
271
|
* Enable/disable LiveEdit functionality for the given Isolate
|
@@ -276,6 +281,14 @@ class V8_EXPORT Debug {
|
|
276
281
|
*/
|
277
282
|
static MaybeLocal<Array> GetInternalProperties(Isolate* isolate,
|
278
283
|
Local<Value> value);
|
284
|
+
|
285
|
+
/**
|
286
|
+
* Defines if the ES2015 tail call elimination feature is enabled or not.
|
287
|
+
* The change of this flag triggers deoptimization of all functions that
|
288
|
+
* contain calls at tail position.
|
289
|
+
*/
|
290
|
+
static bool IsTailCallEliminationEnabled(Isolate* isolate);
|
291
|
+
static void SetTailCallEliminationEnabled(Isolate* isolate, bool enabled);
|
279
292
|
};
|
280
293
|
|
281
294
|
|
@@ -152,9 +152,9 @@ class Platform {
|
|
152
152
|
*/
|
153
153
|
virtual uint64_t AddTraceEvent(
|
154
154
|
char phase, const uint8_t* category_enabled_flag, const char* name,
|
155
|
-
uint64_t id, uint64_t bind_id, int32_t num_args,
|
156
|
-
const
|
157
|
-
unsigned int flags) {
|
155
|
+
const char* scope, uint64_t id, uint64_t bind_id, int32_t num_args,
|
156
|
+
const char** arg_names, const uint8_t* arg_types,
|
157
|
+
const uint64_t* arg_values, unsigned int flags) {
|
158
158
|
return 0;
|
159
159
|
}
|
160
160
|
|
@@ -515,6 +515,11 @@ class V8_EXPORT AllocationProfile {
|
|
515
515
|
*/
|
516
516
|
class V8_EXPORT HeapProfiler {
|
517
517
|
public:
|
518
|
+
enum SamplingFlags {
|
519
|
+
kSamplingNoFlags = 0,
|
520
|
+
kSamplingForceGC = 1 << 0,
|
521
|
+
};
|
522
|
+
|
518
523
|
/**
|
519
524
|
* Callback function invoked for obtaining RetainedObjectInfo for
|
520
525
|
* the given JavaScript wrapper object. It is prohibited to enter V8
|
@@ -640,7 +645,8 @@ class V8_EXPORT HeapProfiler {
|
|
640
645
|
* Returns false if a sampling heap profiler is already running.
|
641
646
|
*/
|
642
647
|
bool StartSamplingHeapProfiler(uint64_t sample_interval = 512 * 1024,
|
643
|
-
int stack_depth = 16
|
648
|
+
int stack_depth = 16,
|
649
|
+
SamplingFlags flags = kSamplingNoFlags);
|
644
650
|
|
645
651
|
/**
|
646
652
|
* Stops the sampling heap profile and discards the current profile.
|
@@ -688,7 +694,6 @@ class V8_EXPORT HeapProfiler {
|
|
688
694
|
HeapProfiler& operator=(const HeapProfiler&);
|
689
695
|
};
|
690
696
|
|
691
|
-
|
692
697
|
/**
|
693
698
|
* Interface for providing information about embedder's objects
|
694
699
|
* held by global handles. This information is reported in two ways:
|
@@ -703,7 +708,7 @@ class V8_EXPORT HeapProfiler {
|
|
703
708
|
* were not previously reported via AddObjectGroup.
|
704
709
|
*
|
705
710
|
* Thus, if an embedder wants to provide information about native
|
706
|
-
* objects for heap snapshots,
|
711
|
+
* objects for heap snapshots, it can do it in a GC prologue
|
707
712
|
* handler, and / or by assigning wrapper class ids in the following way:
|
708
713
|
*
|
709
714
|
* 1. Bind a callback to class id by calling SetWrapperClassInfoProvider.
|
data/vendor/v8/include/v8-util.h
CHANGED
@@ -95,12 +95,12 @@ class DefaultPersistentValueMapTraits : public StdMapTraits<K, V> {
|
|
95
95
|
MapType* map, const K& key, Local<V> value) {
|
96
96
|
return NULL;
|
97
97
|
}
|
98
|
-
static MapType*
|
99
|
-
|
98
|
+
static MapType* MapFromWeakCallbackInfo(
|
99
|
+
const WeakCallbackInfo<WeakCallbackDataType>& data) {
|
100
100
|
return NULL;
|
101
101
|
}
|
102
|
-
static K
|
103
|
-
const
|
102
|
+
static K KeyFromWeakCallbackInfo(
|
103
|
+
const WeakCallbackInfo<WeakCallbackDataType>& data) {
|
104
104
|
return K();
|
105
105
|
}
|
106
106
|
static void DisposeCallbackData(WeakCallbackDataType* data) { }
|
@@ -205,6 +205,17 @@ class PersistentValueMapBase {
|
|
205
205
|
reinterpret_cast<internal::Object**>(FromVal(Traits::Get(&impl_, key))));
|
206
206
|
}
|
207
207
|
|
208
|
+
/**
|
209
|
+
* Call V8::RegisterExternallyReferencedObject with the map value for given
|
210
|
+
* key.
|
211
|
+
*/
|
212
|
+
void RegisterExternallyReferencedObject(K& key) {
|
213
|
+
DCHECK(Contains(key));
|
214
|
+
V8::RegisterExternallyReferencedObject(
|
215
|
+
reinterpret_cast<internal::Object**>(FromVal(Traits::Get(&impl_, key))),
|
216
|
+
reinterpret_cast<internal::Isolate*>(GetIsolate()));
|
217
|
+
}
|
218
|
+
|
208
219
|
/**
|
209
220
|
* Return value for key and remove it from the map.
|
210
221
|
*/
|
@@ -402,11 +413,11 @@ class PersistentValueMap : public PersistentValueMapBase<K, V, Traits> {
|
|
402
413
|
|
403
414
|
private:
|
404
415
|
static void WeakCallback(
|
405
|
-
const
|
416
|
+
const WeakCallbackInfo<typename Traits::WeakCallbackDataType>& data) {
|
406
417
|
if (Traits::kCallbackType != kNotWeak) {
|
407
418
|
PersistentValueMap<K, V, Traits>* persistentValueMap =
|
408
|
-
Traits::
|
409
|
-
K key = Traits::
|
419
|
+
Traits::MapFromWeakCallbackInfo(data);
|
420
|
+
K key = Traits::KeyFromWeakCallbackInfo(data);
|
410
421
|
Traits::Dispose(data.GetIsolate(),
|
411
422
|
persistentValueMap->Remove(key).Pass(), key);
|
412
423
|
Traits::DisposeCallbackData(data.GetParameter());
|
@@ -9,9 +9,9 @@
|
|
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
11
|
#define V8_MAJOR_VERSION 5
|
12
|
-
#define V8_MINOR_VERSION
|
13
|
-
#define V8_BUILD_NUMBER
|
14
|
-
#define V8_PATCH_LEVEL
|
12
|
+
#define V8_MINOR_VERSION 3
|
13
|
+
#define V8_BUILD_NUMBER 332
|
14
|
+
#define V8_PATCH_LEVEL 38
|
15
15
|
|
16
16
|
// Use 1 for candidates and 0 otherwise.
|
17
17
|
// (Boolean macro values are not supported by all preprocessors.)
|
data/vendor/v8/include/v8.h
CHANGED
@@ -18,6 +18,8 @@
|
|
18
18
|
#include <stddef.h>
|
19
19
|
#include <stdint.h>
|
20
20
|
#include <stdio.h>
|
21
|
+
#include <utility>
|
22
|
+
#include <vector>
|
21
23
|
|
22
24
|
#include "v8-version.h" // NOLINT(build/include)
|
23
25
|
#include "v8config.h" // NOLINT(build/include)
|
@@ -328,6 +330,8 @@ class Local {
|
|
328
330
|
template <class F1, class F2, class F3>
|
329
331
|
friend class PersistentValueMapBase;
|
330
332
|
template<class F1, class F2> friend class PersistentValueVector;
|
333
|
+
template <class F>
|
334
|
+
friend class ReturnValue;
|
331
335
|
|
332
336
|
explicit V8_INLINE Local(T* that) : val_(that) {}
|
333
337
|
V8_INLINE static Local<T> New(Isolate* isolate, T* that);
|
@@ -453,32 +457,12 @@ class WeakCallbackInfo {
|
|
453
457
|
};
|
454
458
|
|
455
459
|
|
456
|
-
|
457
|
-
|
458
|
-
|
459
|
-
|
460
|
-
|
461
|
-
|
462
|
-
: isolate_(isolate), parameter_(parameter), handle_(handle) {}
|
463
|
-
|
464
|
-
V8_INLINE Isolate* GetIsolate() const { return isolate_; }
|
465
|
-
V8_INLINE P* GetParameter() const { return parameter_; }
|
466
|
-
V8_INLINE Local<T> GetValue() const { return handle_; }
|
467
|
-
|
468
|
-
private:
|
469
|
-
Isolate* isolate_;
|
470
|
-
P* parameter_;
|
471
|
-
Local<T> handle_;
|
472
|
-
};
|
473
|
-
|
474
|
-
|
475
|
-
// TODO(dcarney): delete this with WeakCallbackData
|
476
|
-
template <class T>
|
477
|
-
using PhantomCallbackData = WeakCallbackInfo<T>;
|
478
|
-
|
479
|
-
|
480
|
-
enum class WeakCallbackType { kParameter, kInternalFields };
|
481
|
-
|
460
|
+
// kParameter will pass a void* parameter back to the callback, kInternalFields
|
461
|
+
// will pass the first two internal fields back to the callback, kFinalizer
|
462
|
+
// will pass a void* parameter back, but is invoked before the object is
|
463
|
+
// actually collected, so it can be resurrected. In the last case, it is not
|
464
|
+
// possible to request a second pass callback.
|
465
|
+
enum class WeakCallbackType { kParameter, kInternalFields, kFinalizer };
|
482
466
|
|
483
467
|
/**
|
484
468
|
* An object reference that is independent of any handle scope. Where
|
@@ -557,42 +541,32 @@ template <class T> class PersistentBase {
|
|
557
541
|
* critical form of resource management!
|
558
542
|
*/
|
559
543
|
template <typename P>
|
560
|
-
V8_INLINE V8_DEPRECATED(
|
561
|
-
"use WeakCallbackInfo version",
|
562
|
-
void SetWeak(P* parameter,
|
563
|
-
typename WeakCallbackData<T, P>::Callback callback));
|
564
|
-
|
565
|
-
template <typename S, typename P>
|
566
|
-
V8_INLINE V8_DEPRECATED(
|
567
|
-
"use WeakCallbackInfo version",
|
568
|
-
void SetWeak(P* parameter,
|
569
|
-
typename WeakCallbackData<S, P>::Callback callback));
|
570
|
-
|
571
|
-
// Phantom persistents work like weak persistents, except that the pointer to
|
572
|
-
// the object being collected is not available in the finalization callback.
|
573
|
-
// This enables the garbage collector to collect the object and any objects
|
574
|
-
// it references transitively in one GC cycle. At the moment you can either
|
575
|
-
// specify a parameter for the callback or the location of two internal
|
576
|
-
// fields in the dying object.
|
577
|
-
template <typename P>
|
578
|
-
V8_INLINE V8_DEPRECATED(
|
579
|
-
"use SetWeak",
|
580
|
-
void SetPhantom(P* parameter,
|
581
|
-
typename WeakCallbackInfo<P>::Callback callback,
|
582
|
-
int internal_field_index1 = -1,
|
583
|
-
int internal_field_index2 = -1));
|
584
|
-
|
585
|
-
template <typename P>
|
586
544
|
V8_INLINE void SetWeak(P* parameter,
|
587
545
|
typename WeakCallbackInfo<P>::Callback callback,
|
588
546
|
WeakCallbackType type);
|
589
547
|
|
548
|
+
/**
|
549
|
+
* Turns this handle into a weak phantom handle without finalization callback.
|
550
|
+
* The handle will be reset automatically when the garbage collector detects
|
551
|
+
* that the object is no longer reachable.
|
552
|
+
* A related function Isolate::NumberOfPhantomHandleResetsSinceLastCall
|
553
|
+
* returns how many phantom handles were reset by the garbage collector.
|
554
|
+
*/
|
555
|
+
V8_INLINE void SetWeak();
|
556
|
+
|
590
557
|
template<typename P>
|
591
558
|
V8_INLINE P* ClearWeak();
|
592
559
|
|
593
560
|
// TODO(dcarney): remove this.
|
594
561
|
V8_INLINE void ClearWeak() { ClearWeak<void>(); }
|
595
562
|
|
563
|
+
/**
|
564
|
+
* Allows the embedder to tell the v8 garbage collector that a certain object
|
565
|
+
* is alive. Only allowed when the embedder is asked to trace its heap by
|
566
|
+
* EmbedderHeapTracer.
|
567
|
+
*/
|
568
|
+
V8_INLINE void RegisterExternalReference(Isolate* isolate) const;
|
569
|
+
|
596
570
|
/**
|
597
571
|
* Marks the reference to this object independent. Garbage collector is free
|
598
572
|
* to ignore any object groups containing this object. Weak callback for an
|
@@ -609,7 +583,9 @@ template <class T> class PersistentBase {
|
|
609
583
|
* external dependencies. This mark is automatically cleared after each
|
610
584
|
* garbage collection.
|
611
585
|
*/
|
612
|
-
V8_INLINE
|
586
|
+
V8_INLINE V8_DEPRECATED(
|
587
|
+
"deprecated optimization, do not use partially dependent groups",
|
588
|
+
void MarkPartiallyDependent());
|
613
589
|
|
614
590
|
/**
|
615
591
|
* Marks the reference to this object as active. The scavenge garbage
|
@@ -1637,26 +1613,25 @@ class V8_EXPORT StackFrame {
|
|
1637
1613
|
// A StateTag represents a possible state of the VM.
|
1638
1614
|
enum StateTag { JS, GC, COMPILER, OTHER, EXTERNAL, IDLE };
|
1639
1615
|
|
1640
|
-
|
1641
1616
|
// A RegisterState represents the current state of registers used
|
1642
1617
|
// by the sampling profiler API.
|
1643
1618
|
struct RegisterState {
|
1644
|
-
RegisterState() : pc(
|
1619
|
+
RegisterState() : pc(nullptr), sp(nullptr), fp(nullptr) {}
|
1645
1620
|
void* pc; // Instruction pointer.
|
1646
1621
|
void* sp; // Stack pointer.
|
1647
1622
|
void* fp; // Frame pointer.
|
1648
1623
|
};
|
1649
1624
|
|
1650
|
-
|
1651
1625
|
// The output structure filled up by GetStackSample API function.
|
1652
1626
|
struct SampleInfo {
|
1653
|
-
size_t frames_count;
|
1654
|
-
StateTag vm_state;
|
1627
|
+
size_t frames_count; // Number of frames collected.
|
1628
|
+
StateTag vm_state; // Current VM state.
|
1629
|
+
void* external_callback_entry; // External callback address if VM is
|
1630
|
+
// executing an external callback.
|
1655
1631
|
};
|
1656
1632
|
|
1657
|
-
|
1658
1633
|
/**
|
1659
|
-
* A JSON Parser.
|
1634
|
+
* A JSON Parser and Stringifier.
|
1660
1635
|
*/
|
1661
1636
|
class V8_EXPORT JSON {
|
1662
1637
|
public:
|
@@ -1667,10 +1642,24 @@ class V8_EXPORT JSON {
|
|
1667
1642
|
* \param json_string The string to parse.
|
1668
1643
|
* \return The corresponding value if successfully parsed.
|
1669
1644
|
*/
|
1670
|
-
static V8_DEPRECATED("Use maybe version",
|
1645
|
+
static V8_DEPRECATED("Use the maybe version taking context",
|
1671
1646
|
Local<Value> Parse(Local<String> json_string));
|
1647
|
+
static V8_DEPRECATE_SOON("Use the maybe version taking context",
|
1648
|
+
MaybeLocal<Value> Parse(Isolate* isolate,
|
1649
|
+
Local<String> json_string));
|
1672
1650
|
static V8_WARN_UNUSED_RESULT MaybeLocal<Value> Parse(
|
1673
|
-
|
1651
|
+
Local<Context> context, Local<String> json_string);
|
1652
|
+
|
1653
|
+
/**
|
1654
|
+
* Tries to stringify the JSON-serializable object |json_object| and returns
|
1655
|
+
* it as string if successful.
|
1656
|
+
*
|
1657
|
+
* \param json_object The JSON-serializable object to stringify.
|
1658
|
+
* \return The corresponding string if successfully stringified.
|
1659
|
+
*/
|
1660
|
+
static V8_WARN_UNUSED_RESULT MaybeLocal<String> Stringify(
|
1661
|
+
Local<Context> context, Local<Object> json_object,
|
1662
|
+
Local<String> gap = Local<String>());
|
1674
1663
|
};
|
1675
1664
|
|
1676
1665
|
|
@@ -2039,6 +2028,8 @@ class V8_EXPORT Value : public Data {
|
|
2039
2028
|
|
2040
2029
|
template <class T> V8_INLINE static Value* Cast(T* value);
|
2041
2030
|
|
2031
|
+
Local<String> TypeOf(v8::Isolate*);
|
2032
|
+
|
2042
2033
|
private:
|
2043
2034
|
V8_INLINE bool QuickIsUndefined() const;
|
2044
2035
|
V8_INLINE bool QuickIsNull() const;
|
@@ -2628,6 +2619,37 @@ enum AccessControl {
|
|
2628
2619
|
PROHIBITS_OVERWRITING = 1 << 2
|
2629
2620
|
};
|
2630
2621
|
|
2622
|
+
/**
|
2623
|
+
* Property filter bits. They can be or'ed to build a composite filter.
|
2624
|
+
*/
|
2625
|
+
enum PropertyFilter {
|
2626
|
+
ALL_PROPERTIES = 0,
|
2627
|
+
ONLY_WRITABLE = 1,
|
2628
|
+
ONLY_ENUMERABLE = 2,
|
2629
|
+
ONLY_CONFIGURABLE = 4,
|
2630
|
+
SKIP_STRINGS = 8,
|
2631
|
+
SKIP_SYMBOLS = 16
|
2632
|
+
};
|
2633
|
+
|
2634
|
+
/**
|
2635
|
+
* Keys/Properties filter enums:
|
2636
|
+
*
|
2637
|
+
* KeyCollectionMode limits the range of collected properties. kOwnOnly limits
|
2638
|
+
* the collected properties to the given Object only. kIncludesPrototypes will
|
2639
|
+
* include all keys of the objects's prototype chain as well.
|
2640
|
+
*/
|
2641
|
+
enum class KeyCollectionMode { kOwnOnly, kIncludePrototypes };
|
2642
|
+
|
2643
|
+
/**
|
2644
|
+
* kIncludesIndices allows for integer indices to be collected, while
|
2645
|
+
* kSkipIndices will exclude integer indicies from being collected.
|
2646
|
+
*/
|
2647
|
+
enum class IndexFilter { kIncludeIndices, kSkipIndices };
|
2648
|
+
|
2649
|
+
/**
|
2650
|
+
* Integrity level for objects.
|
2651
|
+
*/
|
2652
|
+
enum class IntegrityLevel { kFrozen, kSealed };
|
2631
2653
|
|
2632
2654
|
/**
|
2633
2655
|
* A JavaScript object (ECMA-262, 4.3.3)
|
@@ -2773,6 +2795,9 @@ class V8_EXPORT Object : public Value {
|
|
2773
2795
|
V8_DEPRECATE_SOON("Use maybe version", Local<Array> GetPropertyNames());
|
2774
2796
|
V8_WARN_UNUSED_RESULT MaybeLocal<Array> GetPropertyNames(
|
2775
2797
|
Local<Context> context);
|
2798
|
+
V8_WARN_UNUSED_RESULT MaybeLocal<Array> GetPropertyNames(
|
2799
|
+
Local<Context> context, KeyCollectionMode mode,
|
2800
|
+
PropertyFilter property_filter, IndexFilter index_filter);
|
2776
2801
|
|
2777
2802
|
/**
|
2778
2803
|
* This function has the same functionality as GetPropertyNames but
|
@@ -2783,6 +2808,15 @@ class V8_EXPORT Object : public Value {
|
|
2783
2808
|
V8_WARN_UNUSED_RESULT MaybeLocal<Array> GetOwnPropertyNames(
|
2784
2809
|
Local<Context> context);
|
2785
2810
|
|
2811
|
+
/**
|
2812
|
+
* Returns an array containing the names of the filtered properties
|
2813
|
+
* of this object, including properties from prototype objects. The
|
2814
|
+
* array returned by this method contains the same values as would
|
2815
|
+
* be enumerated by a for-in statement over this object.
|
2816
|
+
*/
|
2817
|
+
V8_WARN_UNUSED_RESULT MaybeLocal<Array> GetOwnPropertyNames(
|
2818
|
+
Local<Context> context, PropertyFilter filter);
|
2819
|
+
|
2786
2820
|
/**
|
2787
2821
|
* Get the prototype object. This does not skip objects marked to
|
2788
2822
|
* be skipped by __proto__ and it does not consult the security
|
@@ -2819,6 +2853,11 @@ class V8_EXPORT Object : public Value {
|
|
2819
2853
|
*/
|
2820
2854
|
Local<String> GetConstructorName();
|
2821
2855
|
|
2856
|
+
/**
|
2857
|
+
* Sets the integrity level of the object.
|
2858
|
+
*/
|
2859
|
+
Maybe<bool> SetIntegrityLevel(Local<Context> context, IntegrityLevel level);
|
2860
|
+
|
2822
2861
|
/** Gets the number of internal fields for this Object. */
|
2823
2862
|
int InternalFieldCount();
|
2824
2863
|
|
@@ -2858,6 +2897,8 @@ class V8_EXPORT Object : public Value {
|
|
2858
2897
|
V8_DEPRECATED("Use maybe version", bool HasOwnProperty(Local<String> key));
|
2859
2898
|
V8_WARN_UNUSED_RESULT Maybe<bool> HasOwnProperty(Local<Context> context,
|
2860
2899
|
Local<Name> key);
|
2900
|
+
V8_WARN_UNUSED_RESULT Maybe<bool> HasOwnProperty(Local<Context> context,
|
2901
|
+
uint32_t index);
|
2861
2902
|
V8_DEPRECATE_SOON("Use maybe version",
|
2862
2903
|
bool HasRealNamedProperty(Local<String> key));
|
2863
2904
|
V8_WARN_UNUSED_RESULT Maybe<bool> HasRealNamedProperty(Local<Context> context,
|
@@ -2930,13 +2971,6 @@ class V8_EXPORT Object : public Value {
|
|
2930
2971
|
*/
|
2931
2972
|
int GetIdentityHash();
|
2932
2973
|
|
2933
|
-
V8_DEPRECATED("Use v8::Object::SetPrivate instead.",
|
2934
|
-
bool SetHiddenValue(Local<String> key, Local<Value> value));
|
2935
|
-
V8_DEPRECATED("Use v8::Object::GetPrivate instead.",
|
2936
|
-
Local<Value> GetHiddenValue(Local<String> key));
|
2937
|
-
V8_DEPRECATED("Use v8::Object::DeletePrivate instead.",
|
2938
|
-
bool DeleteHiddenValue(Local<String> key));
|
2939
|
-
|
2940
2974
|
/**
|
2941
2975
|
* Clone this object with a fast but shallow copy. Values will point
|
2942
2976
|
* to the same values as the original object.
|
@@ -2956,6 +2990,11 @@ class V8_EXPORT Object : public Value {
|
|
2956
2990
|
*/
|
2957
2991
|
bool IsCallable();
|
2958
2992
|
|
2993
|
+
/**
|
2994
|
+
* True if this object is a constructor.
|
2995
|
+
*/
|
2996
|
+
bool IsConstructor();
|
2997
|
+
|
2959
2998
|
/**
|
2960
2999
|
* Call an Object as a function if a callback is set by the
|
2961
3000
|
* ObjectTemplate::SetCallAsFunctionHandler method.
|
@@ -3118,12 +3157,17 @@ class ReturnValue {
|
|
3118
3157
|
V8_INLINE void SetUndefined();
|
3119
3158
|
V8_INLINE void SetEmptyString();
|
3120
3159
|
// Convenience getter for Isolate
|
3121
|
-
V8_INLINE Isolate* GetIsolate();
|
3160
|
+
V8_INLINE Isolate* GetIsolate() const;
|
3122
3161
|
|
3123
3162
|
// Pointer setter: Uncompilable to prevent inadvertent misuse.
|
3124
3163
|
template <typename S>
|
3125
3164
|
V8_INLINE void Set(S* whatever);
|
3126
3165
|
|
3166
|
+
// Getter. Creates a new Local<> so it comes with a certain performance
|
3167
|
+
// hit. If the ReturnValue was not yet set, this will return the undefined
|
3168
|
+
// value.
|
3169
|
+
V8_INLINE Local<Value> Get() const;
|
3170
|
+
|
3127
3171
|
private:
|
3128
3172
|
template<class F> friend class ReturnValue;
|
3129
3173
|
template<class F> friend class FunctionCallbackInfo;
|
@@ -3152,12 +3196,13 @@ class FunctionCallbackInfo {
|
|
3152
3196
|
Local<Function> Callee() const);
|
3153
3197
|
V8_INLINE Local<Object> This() const;
|
3154
3198
|
V8_INLINE Local<Object> Holder() const;
|
3199
|
+
V8_INLINE Local<Value> NewTarget() const;
|
3155
3200
|
V8_INLINE bool IsConstructCall() const;
|
3156
3201
|
V8_INLINE Local<Value> Data() const;
|
3157
3202
|
V8_INLINE Isolate* GetIsolate() const;
|
3158
3203
|
V8_INLINE ReturnValue<T> GetReturnValue() const;
|
3159
3204
|
// This shouldn't be public, but the arm compiler needs it.
|
3160
|
-
static const int kArgsLength =
|
3205
|
+
static const int kArgsLength = 8;
|
3161
3206
|
|
3162
3207
|
protected:
|
3163
3208
|
friend class internal::FunctionCallbackArguments;
|
@@ -3169,15 +3214,13 @@ class FunctionCallbackInfo {
|
|
3169
3214
|
static const int kDataIndex = 4;
|
3170
3215
|
static const int kCalleeIndex = 5;
|
3171
3216
|
static const int kContextSaveIndex = 6;
|
3217
|
+
static const int kNewTargetIndex = 7;
|
3172
3218
|
|
3173
3219
|
V8_INLINE FunctionCallbackInfo(internal::Object** implicit_args,
|
3174
|
-
|
3175
|
-
int length,
|
3176
|
-
bool is_construct_call);
|
3220
|
+
internal::Object** values, int length);
|
3177
3221
|
internal::Object** implicit_args_;
|
3178
3222
|
internal::Object** values_;
|
3179
3223
|
int length_;
|
3180
|
-
int is_construct_call_;
|
3181
3224
|
};
|
3182
3225
|
|
3183
3226
|
|
@@ -3216,6 +3259,7 @@ class PropertyCallbackInfo {
|
|
3216
3259
|
|
3217
3260
|
typedef void (*FunctionCallback)(const FunctionCallbackInfo<Value>& info);
|
3218
3261
|
|
3262
|
+
enum class ConstructorBehavior { kThrow, kAllow };
|
3219
3263
|
|
3220
3264
|
/**
|
3221
3265
|
* A JavaScript function object (ECMA-262, 15.3).
|
@@ -3226,10 +3270,10 @@ class V8_EXPORT Function : public Object {
|
|
3226
3270
|
* Create a function in the current execution context
|
3227
3271
|
* for a given FunctionCallback.
|
3228
3272
|
*/
|
3229
|
-
static MaybeLocal<Function> New(
|
3230
|
-
|
3231
|
-
|
3232
|
-
|
3273
|
+
static MaybeLocal<Function> New(
|
3274
|
+
Local<Context> context, FunctionCallback callback,
|
3275
|
+
Local<Value> data = Local<Value>(), int length = 0,
|
3276
|
+
ConstructorBehavior behavior = ConstructorBehavior::kAllow);
|
3233
3277
|
static V8_DEPRECATE_SOON(
|
3234
3278
|
"Use maybe version",
|
3235
3279
|
Local<Function> New(Isolate* isolate, FunctionCallback callback,
|
@@ -3431,10 +3475,20 @@ enum class ArrayBufferCreationMode { kInternalized, kExternalized };
|
|
3431
3475
|
class V8_EXPORT ArrayBuffer : public Object {
|
3432
3476
|
public:
|
3433
3477
|
/**
|
3434
|
-
*
|
3478
|
+
* A thread-safe allocator that V8 uses to allocate |ArrayBuffer|'s memory.
|
3435
3479
|
* The allocator is a global V8 setting. It has to be set via
|
3436
3480
|
* Isolate::CreateParams.
|
3437
3481
|
*
|
3482
|
+
* Memory allocated through this allocator by V8 is accounted for as external
|
3483
|
+
* memory by V8. Note that V8 keeps track of the memory for all internalized
|
3484
|
+
* |ArrayBuffer|s. Responsibility for tracking external memory (using
|
3485
|
+
* Isolate::AdjustAmountOfExternalAllocatedMemory) is handed over to the
|
3486
|
+
* embedder upon externalization and taken over upon internalization (creating
|
3487
|
+
* an internalized buffer from an existing buffer).
|
3488
|
+
*
|
3489
|
+
* Note that it is unsafe to call back into V8 from any of the allocator
|
3490
|
+
* functions.
|
3491
|
+
*
|
3438
3492
|
* This API is experimental and may change significantly.
|
3439
3493
|
*/
|
3440
3494
|
class V8_EXPORT Allocator { // NOLINT
|
@@ -4102,7 +4156,11 @@ enum Intrinsic {
|
|
4102
4156
|
*/
|
4103
4157
|
class V8_EXPORT Template : public Data {
|
4104
4158
|
public:
|
4105
|
-
/**
|
4159
|
+
/**
|
4160
|
+
* Adds a property to each instance created by this template.
|
4161
|
+
*
|
4162
|
+
* The property must be defined either as a primitive value, or a template.
|
4163
|
+
*/
|
4106
4164
|
void Set(Local<Name> name, Local<Data> value,
|
4107
4165
|
PropertyAttribute attributes = None);
|
4108
4166
|
V8_INLINE void Set(Isolate* isolate, const char* name, Local<Data> value);
|
@@ -4328,28 +4386,6 @@ enum AccessType {
|
|
4328
4386
|
typedef bool (*AccessCheckCallback)(Local<Context> accessing_context,
|
4329
4387
|
Local<Object> accessed_object,
|
4330
4388
|
Local<Value> data);
|
4331
|
-
typedef bool (*DeprecatedAccessCheckCallback)(Local<Context> accessing_context,
|
4332
|
-
Local<Object> accessed_object);
|
4333
|
-
|
4334
|
-
/**
|
4335
|
-
* Returns true if cross-context access should be allowed to the named
|
4336
|
-
* property with the given key on the host object.
|
4337
|
-
*/
|
4338
|
-
typedef bool (*NamedSecurityCallback)(Local<Object> host,
|
4339
|
-
Local<Value> key,
|
4340
|
-
AccessType type,
|
4341
|
-
Local<Value> data);
|
4342
|
-
|
4343
|
-
|
4344
|
-
/**
|
4345
|
-
* Returns true if cross-context access should be allowed to the indexed
|
4346
|
-
* property with the given index on the host object.
|
4347
|
-
*/
|
4348
|
-
typedef bool (*IndexedSecurityCallback)(Local<Object> host,
|
4349
|
-
uint32_t index,
|
4350
|
-
AccessType type,
|
4351
|
-
Local<Value> data);
|
4352
|
-
|
4353
4389
|
|
4354
4390
|
/**
|
4355
4391
|
* A FunctionTemplate is used to create functions at runtime. There
|
@@ -4452,7 +4488,11 @@ class V8_EXPORT FunctionTemplate : public Template {
|
|
4452
4488
|
static Local<FunctionTemplate> New(
|
4453
4489
|
Isolate* isolate, FunctionCallback callback = 0,
|
4454
4490
|
Local<Value> data = Local<Value>(),
|
4455
|
-
Local<Signature> signature = Local<Signature>(), int length = 0
|
4491
|
+
Local<Signature> signature = Local<Signature>(), int length = 0,
|
4492
|
+
ConstructorBehavior behavior = ConstructorBehavior::kAllow);
|
4493
|
+
|
4494
|
+
/** Get a template included in the snapshot by index. */
|
4495
|
+
static Local<FunctionTemplate> FromSnapshot(Isolate* isolate, size_t index);
|
4456
4496
|
|
4457
4497
|
/**
|
4458
4498
|
* Creates a function template with a fast handler. If a fast handler is set,
|
@@ -4629,6 +4669,9 @@ class V8_EXPORT ObjectTemplate : public Template {
|
|
4629
4669
|
Local<FunctionTemplate> constructor = Local<FunctionTemplate>());
|
4630
4670
|
static V8_DEPRECATED("Use isolate version", Local<ObjectTemplate> New());
|
4631
4671
|
|
4672
|
+
/** Get a template included in the snapshot by index. */
|
4673
|
+
static Local<ObjectTemplate> FromSnapshot(Isolate* isolate, size_t index);
|
4674
|
+
|
4632
4675
|
/** Creates a new instance of this template.*/
|
4633
4676
|
V8_DEPRECATE_SOON("Use maybe version", Local<Object> NewInstance());
|
4634
4677
|
V8_WARN_UNUSED_RESULT MaybeLocal<Object> NewInstance(Local<Context> context);
|
@@ -4759,16 +4802,18 @@ class V8_EXPORT ObjectTemplate : public Template {
|
|
4759
4802
|
*/
|
4760
4803
|
void SetAccessCheckCallback(AccessCheckCallback callback,
|
4761
4804
|
Local<Value> data = Local<Value>());
|
4762
|
-
V8_DEPRECATED(
|
4763
|
-
"Use SetAccessCheckCallback with new AccessCheckCallback signature.",
|
4764
|
-
void SetAccessCheckCallback(DeprecatedAccessCheckCallback callback,
|
4765
|
-
Local<Value> data = Local<Value>()));
|
4766
4805
|
|
4767
|
-
|
4768
|
-
|
4769
|
-
|
4770
|
-
|
4771
|
-
|
4806
|
+
/**
|
4807
|
+
* Like SetAccessCheckCallback but invokes an interceptor on failed access
|
4808
|
+
* checks instead of looking up all-can-read properties. You can only use
|
4809
|
+
* either this method or SetAccessCheckCallback, but not both at the same
|
4810
|
+
* time.
|
4811
|
+
*/
|
4812
|
+
void SetAccessCheckCallbackAndHandler(
|
4813
|
+
AccessCheckCallback callback,
|
4814
|
+
const NamedPropertyHandlerConfiguration& named_handler,
|
4815
|
+
const IndexedPropertyHandlerConfiguration& indexed_handler,
|
4816
|
+
Local<Value> data = Local<Value>());
|
4772
4817
|
|
4773
4818
|
/**
|
4774
4819
|
* Gets the number of internal fields for objects generated from
|
@@ -4886,7 +4931,6 @@ V8_INLINE Local<Primitive> Null(Isolate* isolate);
|
|
4886
4931
|
V8_INLINE Local<Boolean> True(Isolate* isolate);
|
4887
4932
|
V8_INLINE Local<Boolean> False(Isolate* isolate);
|
4888
4933
|
|
4889
|
-
|
4890
4934
|
/**
|
4891
4935
|
* A set of constraints that specifies the limits of the runtime's memory use.
|
4892
4936
|
* You must set the heap size before initializing the VM - the size cannot be
|
@@ -4895,6 +4939,9 @@ V8_INLINE Local<Boolean> False(Isolate* isolate);
|
|
4895
4939
|
* If you are using threads then you should hold the V8::Locker lock while
|
4896
4940
|
* setting the stack limit and you must set a non-default stack limit separately
|
4897
4941
|
* for each thread.
|
4942
|
+
*
|
4943
|
+
* The arguments for set_max_semi_space_size, set_max_old_space_size,
|
4944
|
+
* set_max_executable_size, set_code_range_size specify limits in MB.
|
4898
4945
|
*/
|
4899
4946
|
class V8_EXPORT ResourceConstraints {
|
4900
4947
|
public:
|
@@ -4913,17 +4960,23 @@ class V8_EXPORT ResourceConstraints {
|
|
4913
4960
|
uint64_t virtual_memory_limit);
|
4914
4961
|
|
4915
4962
|
int max_semi_space_size() const { return max_semi_space_size_; }
|
4916
|
-
void set_max_semi_space_size(int
|
4963
|
+
void set_max_semi_space_size(int limit_in_mb) {
|
4964
|
+
max_semi_space_size_ = limit_in_mb;
|
4965
|
+
}
|
4917
4966
|
int max_old_space_size() const { return max_old_space_size_; }
|
4918
|
-
void set_max_old_space_size(int
|
4967
|
+
void set_max_old_space_size(int limit_in_mb) {
|
4968
|
+
max_old_space_size_ = limit_in_mb;
|
4969
|
+
}
|
4919
4970
|
int max_executable_size() const { return max_executable_size_; }
|
4920
|
-
void set_max_executable_size(int
|
4971
|
+
void set_max_executable_size(int limit_in_mb) {
|
4972
|
+
max_executable_size_ = limit_in_mb;
|
4973
|
+
}
|
4921
4974
|
uint32_t* stack_limit() const { return stack_limit_; }
|
4922
4975
|
// Sets an address beyond which the VM's stack may not grow.
|
4923
4976
|
void set_stack_limit(uint32_t* value) { stack_limit_ = value; }
|
4924
4977
|
size_t code_range_size() const { return code_range_size_; }
|
4925
|
-
void set_code_range_size(size_t
|
4926
|
-
code_range_size_ =
|
4978
|
+
void set_code_range_size(size_t limit_in_mb) {
|
4979
|
+
code_range_size_ = limit_in_mb;
|
4927
4980
|
}
|
4928
4981
|
|
4929
4982
|
private:
|
@@ -5005,10 +5058,6 @@ enum ObjectSpace {
|
|
5005
5058
|
kAllocationActionAll = kAllocationActionAllocate | kAllocationActionFree
|
5006
5059
|
};
|
5007
5060
|
|
5008
|
-
typedef void (*MemoryAllocationCallback)(ObjectSpace space,
|
5009
|
-
AllocationAction action,
|
5010
|
-
int size);
|
5011
|
-
|
5012
5061
|
// --- Enter/Leave Script Callback ---
|
5013
5062
|
typedef void (*BeforeCallEnteredCallback)(Isolate*);
|
5014
5063
|
typedef void (*CallCompletedCallback)(Isolate*);
|
@@ -5047,9 +5096,62 @@ class PromiseRejectMessage {
|
|
5047
5096
|
|
5048
5097
|
typedef void (*PromiseRejectCallback)(PromiseRejectMessage message);
|
5049
5098
|
|
5050
|
-
// ---
|
5099
|
+
// --- Microtasks Callbacks ---
|
5100
|
+
typedef void (*MicrotasksCompletedCallback)(Isolate*);
|
5051
5101
|
typedef void (*MicrotaskCallback)(void* data);
|
5052
5102
|
|
5103
|
+
|
5104
|
+
/**
|
5105
|
+
* Policy for running microtasks:
|
5106
|
+
* - explicit: microtasks are invoked with Isolate::RunMicrotasks() method;
|
5107
|
+
* - scoped: microtasks invocation is controlled by MicrotasksScope objects;
|
5108
|
+
* - auto: microtasks are invoked when the script call depth decrements
|
5109
|
+
* to zero.
|
5110
|
+
*/
|
5111
|
+
enum class MicrotasksPolicy { kExplicit, kScoped, kAuto };
|
5112
|
+
|
5113
|
+
|
5114
|
+
/**
|
5115
|
+
* This scope is used to control microtasks when kScopeMicrotasksInvocation
|
5116
|
+
* is used on Isolate. In this mode every non-primitive call to V8 should be
|
5117
|
+
* done inside some MicrotasksScope.
|
5118
|
+
* Microtasks are executed when topmost MicrotasksScope marked as kRunMicrotasks
|
5119
|
+
* exits.
|
5120
|
+
* kDoNotRunMicrotasks should be used to annotate calls not intended to trigger
|
5121
|
+
* microtasks.
|
5122
|
+
*/
|
5123
|
+
class V8_EXPORT MicrotasksScope {
|
5124
|
+
public:
|
5125
|
+
enum Type { kRunMicrotasks, kDoNotRunMicrotasks };
|
5126
|
+
|
5127
|
+
MicrotasksScope(Isolate* isolate, Type type);
|
5128
|
+
~MicrotasksScope();
|
5129
|
+
|
5130
|
+
/**
|
5131
|
+
* Runs microtasks if no kRunMicrotasks scope is currently active.
|
5132
|
+
*/
|
5133
|
+
static void PerformCheckpoint(Isolate* isolate);
|
5134
|
+
|
5135
|
+
/**
|
5136
|
+
* Returns current depth of nested kRunMicrotasks scopes.
|
5137
|
+
*/
|
5138
|
+
static int GetCurrentDepth(Isolate* isolate);
|
5139
|
+
|
5140
|
+
/**
|
5141
|
+
* Returns true while microtasks are being executed.
|
5142
|
+
*/
|
5143
|
+
static bool IsRunningMicrotasks(Isolate* isolate);
|
5144
|
+
|
5145
|
+
private:
|
5146
|
+
internal::Isolate* const isolate_;
|
5147
|
+
bool run_;
|
5148
|
+
|
5149
|
+
// Prevent copying.
|
5150
|
+
MicrotasksScope(const MicrotasksScope&);
|
5151
|
+
MicrotasksScope& operator=(const MicrotasksScope&);
|
5152
|
+
};
|
5153
|
+
|
5154
|
+
|
5053
5155
|
// --- Failed Access Check Callback ---
|
5054
5156
|
typedef void (*FailedAccessCheckCallback)(Local<Object> target,
|
5055
5157
|
AccessType type,
|
@@ -5121,6 +5223,7 @@ class V8_EXPORT HeapStatistics {
|
|
5121
5223
|
size_t total_available_size() { return total_available_size_; }
|
5122
5224
|
size_t used_heap_size() { return used_heap_size_; }
|
5123
5225
|
size_t heap_size_limit() { return heap_size_limit_; }
|
5226
|
+
size_t malloced_memory() { return malloced_memory_; }
|
5124
5227
|
size_t does_zap_garbage() { return does_zap_garbage_; }
|
5125
5228
|
|
5126
5229
|
private:
|
@@ -5130,6 +5233,7 @@ class V8_EXPORT HeapStatistics {
|
|
5130
5233
|
size_t total_available_size_;
|
5131
5234
|
size_t used_heap_size_;
|
5132
5235
|
size_t heap_size_limit_;
|
5236
|
+
size_t malloced_memory_;
|
5133
5237
|
bool does_zap_garbage_;
|
5134
5238
|
|
5135
5239
|
friend class V8;
|
@@ -5174,6 +5278,18 @@ class V8_EXPORT HeapObjectStatistics {
|
|
5174
5278
|
friend class Isolate;
|
5175
5279
|
};
|
5176
5280
|
|
5281
|
+
class V8_EXPORT HeapCodeStatistics {
|
5282
|
+
public:
|
5283
|
+
HeapCodeStatistics();
|
5284
|
+
size_t code_and_metadata_size() { return code_and_metadata_size_; }
|
5285
|
+
size_t bytecode_and_metadata_size() { return bytecode_and_metadata_size_; }
|
5286
|
+
|
5287
|
+
private:
|
5288
|
+
size_t code_and_metadata_size_;
|
5289
|
+
size_t bytecode_and_metadata_size_;
|
5290
|
+
|
5291
|
+
friend class Isolate;
|
5292
|
+
};
|
5177
5293
|
|
5178
5294
|
class RetainedObjectInfo;
|
5179
5295
|
|
@@ -5256,6 +5372,31 @@ struct JitCodeEvent {
|
|
5256
5372
|
};
|
5257
5373
|
};
|
5258
5374
|
|
5375
|
+
/**
|
5376
|
+
* Option flags passed to the SetRAILMode function.
|
5377
|
+
* See documentation https://developers.google.com/web/tools/chrome-devtools/
|
5378
|
+
* profile/evaluate-performance/rail
|
5379
|
+
*/
|
5380
|
+
enum RAILMode {
|
5381
|
+
// Default performance mode: V8 will optimize for both latency and
|
5382
|
+
// throughput in this mode.
|
5383
|
+
PERFORMANCE_DEFAULT,
|
5384
|
+
// Response performance mode: In this mode very low virtual machine latency
|
5385
|
+
// is provided. V8 will try to avoid JavaScript execution interruptions.
|
5386
|
+
// Throughput may be throttled.
|
5387
|
+
PERFORMANCE_RESPONSE,
|
5388
|
+
// Animation performance mode: In this mode low virtual machine latency is
|
5389
|
+
// provided. V8 will try to avoid as many JavaScript execution interruptions
|
5390
|
+
// as possible. Throughput may be throttled
|
5391
|
+
PERFORMANCE_ANIMATION,
|
5392
|
+
// Idle performance mode: The embedder is idle. V8 can complete deferred work
|
5393
|
+
// in this mode.
|
5394
|
+
PERFORMANCE_IDLE,
|
5395
|
+
// Load performance mode: In this mode high throughput is provided. V8 may
|
5396
|
+
// turn off latency optimizations.
|
5397
|
+
PERFORMANCE_LOAD
|
5398
|
+
};
|
5399
|
+
|
5259
5400
|
/**
|
5260
5401
|
* Option flags passed to the SetJitCodeEventHandler function.
|
5261
5402
|
*/
|
@@ -5294,6 +5435,77 @@ class V8_EXPORT PersistentHandleVisitor { // NOLINT
|
|
5294
5435
|
uint16_t class_id) {}
|
5295
5436
|
};
|
5296
5437
|
|
5438
|
+
/**
|
5439
|
+
* Memory pressure level for the MemoryPressureNotification.
|
5440
|
+
* kNone hints V8 that there is no memory pressure.
|
5441
|
+
* kModerate hints V8 to speed up incremental garbage collection at the cost of
|
5442
|
+
* of higher latency due to garbage collection pauses.
|
5443
|
+
* kCritical hints V8 to free memory as soon as possible. Garbage collection
|
5444
|
+
* pauses at this level will be large.
|
5445
|
+
*/
|
5446
|
+
enum class MemoryPressureLevel { kNone, kModerate, kCritical };
|
5447
|
+
|
5448
|
+
/**
|
5449
|
+
* Interface for tracing through the embedder heap. During the v8 garbage
|
5450
|
+
* collection, v8 collects hidden fields of all potential wrappers, and at the
|
5451
|
+
* end of its marking phase iterates the collection and asks the embedder to
|
5452
|
+
* trace through its heap and call PersistentBase::RegisterExternalReference on
|
5453
|
+
* each js object reachable from any of the given wrappers.
|
5454
|
+
*
|
5455
|
+
* Before the first call to the TraceWrappersFrom function TracePrologue will be
|
5456
|
+
* called. When the garbage collection cycle is finished, TraceEpilogue will be
|
5457
|
+
* called.
|
5458
|
+
*/
|
5459
|
+
class V8_EXPORT EmbedderHeapTracer {
|
5460
|
+
public:
|
5461
|
+
enum ForceCompletionAction { FORCE_COMPLETION, DO_NOT_FORCE_COMPLETION };
|
5462
|
+
struct AdvanceTracingActions {
|
5463
|
+
explicit AdvanceTracingActions(ForceCompletionAction force_completion_)
|
5464
|
+
: force_completion(force_completion_) {}
|
5465
|
+
|
5466
|
+
ForceCompletionAction force_completion;
|
5467
|
+
};
|
5468
|
+
/**
|
5469
|
+
* V8 will call this method with internal fields of found wrappers.
|
5470
|
+
* Embedder is expected to store them in it's marking deque and trace
|
5471
|
+
* reachable wrappers from them when asked by AdvanceTracing method.
|
5472
|
+
*/
|
5473
|
+
virtual void RegisterV8References(
|
5474
|
+
const std::vector<std::pair<void*, void*> >& internal_fields) = 0;
|
5475
|
+
/**
|
5476
|
+
* V8 will call this method at the beginning of the gc cycle.
|
5477
|
+
*/
|
5478
|
+
virtual void TracePrologue() = 0;
|
5479
|
+
/**
|
5480
|
+
* Embedder is expected to trace its heap starting from wrappers reported by
|
5481
|
+
* RegisterV8References method, and call
|
5482
|
+
* PersistentBase::RegisterExternalReference() on all reachable wrappers.
|
5483
|
+
* Embedder is expected to stop tracing by the given deadline.
|
5484
|
+
*
|
5485
|
+
* Returns true if there is still work to do.
|
5486
|
+
*/
|
5487
|
+
virtual bool AdvanceTracing(double deadline_in_ms,
|
5488
|
+
AdvanceTracingActions actions) = 0;
|
5489
|
+
/**
|
5490
|
+
* V8 will call this method at the end of the gc cycle. Allocation is *not*
|
5491
|
+
* allowed in the TraceEpilogue.
|
5492
|
+
*/
|
5493
|
+
virtual void TraceEpilogue() = 0;
|
5494
|
+
|
5495
|
+
/**
|
5496
|
+
* Let embedder know v8 entered final marking pause (no more incremental steps
|
5497
|
+
* will follow).
|
5498
|
+
*/
|
5499
|
+
virtual void EnterFinalPause() {}
|
5500
|
+
|
5501
|
+
/**
|
5502
|
+
* Throw away all intermediate data and reset to the initial state.
|
5503
|
+
*/
|
5504
|
+
virtual void AbortTracing() {}
|
5505
|
+
|
5506
|
+
protected:
|
5507
|
+
virtual ~EmbedderHeapTracer() = default;
|
5508
|
+
};
|
5297
5509
|
|
5298
5510
|
/**
|
5299
5511
|
* Isolate represents an isolated instance of the V8 engine. V8 isolates have
|
@@ -5310,20 +5522,21 @@ class V8_EXPORT Isolate {
|
|
5310
5522
|
*/
|
5311
5523
|
struct CreateParams {
|
5312
5524
|
CreateParams()
|
5313
|
-
: entry_hook(
|
5314
|
-
code_event_handler(
|
5315
|
-
snapshot_blob(
|
5316
|
-
counter_lookup_callback(
|
5317
|
-
create_histogram_callback(
|
5318
|
-
add_histogram_sample_callback(
|
5319
|
-
array_buffer_allocator(
|
5525
|
+
: entry_hook(nullptr),
|
5526
|
+
code_event_handler(nullptr),
|
5527
|
+
snapshot_blob(nullptr),
|
5528
|
+
counter_lookup_callback(nullptr),
|
5529
|
+
create_histogram_callback(nullptr),
|
5530
|
+
add_histogram_sample_callback(nullptr),
|
5531
|
+
array_buffer_allocator(nullptr),
|
5532
|
+
external_references(nullptr) {}
|
5320
5533
|
|
5321
5534
|
/**
|
5322
5535
|
* The optional entry_hook allows the host application to provide the
|
5323
5536
|
* address of a function that's invoked on entry to every V8-generated
|
5324
5537
|
* function. Note that entry_hook is invoked at the very start of each
|
5325
|
-
* generated function. Furthermore, if an
|
5326
|
-
*
|
5538
|
+
* generated function. Furthermore, if an entry_hook is given, V8 will
|
5539
|
+
* not use a snapshot, including custom snapshots.
|
5327
5540
|
*/
|
5328
5541
|
FunctionEntryHook entry_hook;
|
5329
5542
|
|
@@ -5364,6 +5577,14 @@ class V8_EXPORT Isolate {
|
|
5364
5577
|
* store of ArrayBuffers.
|
5365
5578
|
*/
|
5366
5579
|
ArrayBuffer::Allocator* array_buffer_allocator;
|
5580
|
+
|
5581
|
+
/**
|
5582
|
+
* Specifies an optional nullptr-terminated array of raw addresses in the
|
5583
|
+
* embedder that V8 can match against during serialization and use for
|
5584
|
+
* deserialization. This array and its content must stay valid for the
|
5585
|
+
* entire lifetime of the isolate.
|
5586
|
+
*/
|
5587
|
+
intptr_t* external_references;
|
5367
5588
|
};
|
5368
5589
|
|
5369
5590
|
|
@@ -5489,9 +5710,15 @@ class V8_EXPORT Isolate {
|
|
5489
5710
|
kArrayPrototypeConstructorModified = 26,
|
5490
5711
|
kArrayInstanceProtoModified = 27,
|
5491
5712
|
kArrayInstanceConstructorModified = 28,
|
5492
|
-
|
5493
|
-
|
5494
|
-
|
5713
|
+
kLegacyFunctionDeclaration = 29,
|
5714
|
+
kRegExpPrototypeSourceGetter = 30,
|
5715
|
+
kRegExpPrototypeOldFlagGetter = 31,
|
5716
|
+
kDecimalWithLeadingZeroInStrictMode = 32,
|
5717
|
+
kLegacyDateParser = 33,
|
5718
|
+
kDefineGetterOrSetterWouldThrow = 34,
|
5719
|
+
|
5720
|
+
// If you add new values here, you'll also need to update Chromium's:
|
5721
|
+
// UseCounter.h, V8PerIsolateData.cpp, histograms.xml
|
5495
5722
|
kUseCounterFeatureCount // This enum value must be last.
|
5496
5723
|
};
|
5497
5724
|
|
@@ -5531,6 +5758,14 @@ class V8_EXPORT Isolate {
|
|
5531
5758
|
void SetAbortOnUncaughtExceptionCallback(
|
5532
5759
|
AbortOnUncaughtExceptionCallback callback);
|
5533
5760
|
|
5761
|
+
/**
|
5762
|
+
* Optional notification that the system is running low on memory.
|
5763
|
+
* V8 uses these notifications to guide heuristics.
|
5764
|
+
* It is allowed to call this function from another thread while
|
5765
|
+
* the isolate is executing long running JavaScript code.
|
5766
|
+
*/
|
5767
|
+
void MemoryPressureNotification(MemoryPressureLevel level);
|
5768
|
+
|
5534
5769
|
/**
|
5535
5770
|
* Methods below this point require holding a lock (using Locker) in
|
5536
5771
|
* a multi-threaded environment.
|
@@ -5624,6 +5859,15 @@ class V8_EXPORT Isolate {
|
|
5624
5859
|
bool GetHeapObjectStatisticsAtLastGC(HeapObjectStatistics* object_statistics,
|
5625
5860
|
size_t type_index);
|
5626
5861
|
|
5862
|
+
/**
|
5863
|
+
* Get statistics about code and its metadata in the heap.
|
5864
|
+
*
|
5865
|
+
* \param object_statistics The HeapCodeStatistics object to fill in
|
5866
|
+
* statistics of code, bytecode and their metadata.
|
5867
|
+
* \returns true on success.
|
5868
|
+
*/
|
5869
|
+
bool GetHeapCodeAndMetadataStatistics(HeapCodeStatistics* object_statistics);
|
5870
|
+
|
5627
5871
|
/**
|
5628
5872
|
* Get a call stack sample from the isolate.
|
5629
5873
|
* \param state Execution state.
|
@@ -5655,6 +5899,12 @@ class V8_EXPORT Isolate {
|
|
5655
5899
|
V8_INLINE int64_t
|
5656
5900
|
AdjustAmountOfExternalAllocatedMemory(int64_t change_in_bytes);
|
5657
5901
|
|
5902
|
+
/**
|
5903
|
+
* Returns the number of phantom handles without callbacks that were reset
|
5904
|
+
* by the garbage collector since the last call to this function.
|
5905
|
+
*/
|
5906
|
+
size_t NumberOfPhantomHandleResetsSinceLastCall();
|
5907
|
+
|
5658
5908
|
/**
|
5659
5909
|
* Returns heap profiler for this isolate. Will return NULL until the isolate
|
5660
5910
|
* is initialized.
|
@@ -5752,6 +6002,11 @@ class V8_EXPORT Isolate {
|
|
5752
6002
|
*/
|
5753
6003
|
void RemoveGCPrologueCallback(GCCallback callback);
|
5754
6004
|
|
6005
|
+
/**
|
6006
|
+
* Sets the embedder heap tracer for the isolate.
|
6007
|
+
*/
|
6008
|
+
void SetEmbedderHeapTracer(EmbedderHeapTracer* tracer);
|
6009
|
+
|
5755
6010
|
/**
|
5756
6011
|
* Enables the host application to receive a notification after a
|
5757
6012
|
* garbage collection. Allocations are allowed in the callback function,
|
@@ -5888,17 +6143,39 @@ class V8_EXPORT Isolate {
|
|
5888
6143
|
*/
|
5889
6144
|
void EnqueueMicrotask(MicrotaskCallback microtask, void* data = NULL);
|
5890
6145
|
|
5891
|
-
|
5892
|
-
* Experimental: Controls
|
5893
|
-
*
|
6146
|
+
/**
|
6147
|
+
* Experimental: Controls how Microtasks are invoked. See MicrotasksPolicy
|
6148
|
+
* for details.
|
6149
|
+
*/
|
6150
|
+
void SetMicrotasksPolicy(MicrotasksPolicy policy);
|
6151
|
+
V8_DEPRECATE_SOON("Use SetMicrotasksPolicy",
|
6152
|
+
void SetAutorunMicrotasks(bool autorun));
|
6153
|
+
|
6154
|
+
/**
|
6155
|
+
* Experimental: Returns the policy controlling how Microtasks are invoked.
|
6156
|
+
*/
|
6157
|
+
MicrotasksPolicy GetMicrotasksPolicy() const;
|
6158
|
+
V8_DEPRECATE_SOON("Use GetMicrotasksPolicy",
|
6159
|
+
bool WillAutorunMicrotasks() const);
|
6160
|
+
|
6161
|
+
/**
|
6162
|
+
* Experimental: adds a callback to notify the host application after
|
6163
|
+
* microtasks were run. The callback is triggered by explicit RunMicrotasks
|
6164
|
+
* call or automatic microtasks execution (see SetAutorunMicrotasks).
|
6165
|
+
*
|
6166
|
+
* Callback will trigger even if microtasks were attempted to run,
|
6167
|
+
* but the microtasks queue was empty and no single microtask was actually
|
6168
|
+
* executed.
|
6169
|
+
*
|
6170
|
+
* Executing scriptsinside the callback will not re-trigger microtasks and
|
6171
|
+
* the callback.
|
5894
6172
|
*/
|
5895
|
-
void
|
6173
|
+
void AddMicrotasksCompletedCallback(MicrotasksCompletedCallback callback);
|
5896
6174
|
|
5897
6175
|
/**
|
5898
|
-
*
|
5899
|
-
* run when the script call depth decrements to zero.
|
6176
|
+
* Removes callback that was installed by AddMicrotasksCompletedCallback.
|
5900
6177
|
*/
|
5901
|
-
|
6178
|
+
void RemoveMicrotasksCompletedCallback(MicrotasksCompletedCallback callback);
|
5902
6179
|
|
5903
6180
|
/**
|
5904
6181
|
* Sets a callback for counting the number of times a feature of V8 is used.
|
@@ -5968,6 +6245,15 @@ class V8_EXPORT Isolate {
|
|
5968
6245
|
*/
|
5969
6246
|
void IsolateInBackgroundNotification();
|
5970
6247
|
|
6248
|
+
/**
|
6249
|
+
* Optional notification to tell V8 the current performance requirements
|
6250
|
+
* of the embedder based on RAIL.
|
6251
|
+
* V8 uses these notifications to guide heuristics.
|
6252
|
+
* This is an unfinished experimental feature. Semantics and implementation
|
6253
|
+
* may change frequently.
|
6254
|
+
*/
|
6255
|
+
void SetRAILMode(RAILMode rail_mode);
|
6256
|
+
|
5971
6257
|
/**
|
5972
6258
|
* Allows the host application to provide the address of a function that is
|
5973
6259
|
* notified each time code is added, moved or removed.
|
@@ -6063,18 +6349,6 @@ class V8_EXPORT Isolate {
|
|
6063
6349
|
bool capture, int frame_limit = 10,
|
6064
6350
|
StackTrace::StackTraceOptions options = StackTrace::kOverview);
|
6065
6351
|
|
6066
|
-
/**
|
6067
|
-
* Enables the host application to provide a mechanism to be notified
|
6068
|
-
* and perform custom logging when V8 Allocates Executable Memory.
|
6069
|
-
*/
|
6070
|
-
void AddMemoryAllocationCallback(MemoryAllocationCallback callback,
|
6071
|
-
ObjectSpace space, AllocationAction action);
|
6072
|
-
|
6073
|
-
/**
|
6074
|
-
* Removes callback that was installed by AddMemoryAllocationCallback.
|
6075
|
-
*/
|
6076
|
-
void RemoveMemoryAllocationCallback(MemoryAllocationCallback callback);
|
6077
|
-
|
6078
6352
|
/**
|
6079
6353
|
* Iterates through all external resources referenced from current isolate
|
6080
6354
|
* heap. GC is not invoked prior to iterating, therefore there is no
|
@@ -6104,6 +6378,12 @@ class V8_EXPORT Isolate {
|
|
6104
6378
|
*/
|
6105
6379
|
void VisitWeakHandles(PersistentHandleVisitor* visitor);
|
6106
6380
|
|
6381
|
+
/**
|
6382
|
+
* Check if this isolate is in use.
|
6383
|
+
* True if at least one thread Enter'ed this isolate.
|
6384
|
+
*/
|
6385
|
+
bool IsInUse();
|
6386
|
+
|
6107
6387
|
private:
|
6108
6388
|
template <class K, class V, class Traits>
|
6109
6389
|
friend class PersistentValueMapBase;
|
@@ -6195,11 +6475,23 @@ class V8_EXPORT V8 {
|
|
6195
6475
|
static void SetSnapshotDataBlob(StartupData* startup_blob);
|
6196
6476
|
|
6197
6477
|
/**
|
6198
|
-
*
|
6478
|
+
* Bootstrap an isolate and a context from scratch to create a startup
|
6479
|
+
* snapshot. Include the side-effects of running the optional script.
|
6480
|
+
* Returns { NULL, 0 } on failure.
|
6481
|
+
* The caller acquires ownership of the data array in the return value.
|
6482
|
+
*/
|
6483
|
+
static StartupData CreateSnapshotDataBlob(const char* embedded_source = NULL);
|
6484
|
+
|
6485
|
+
/**
|
6486
|
+
* Bootstrap an isolate and a context from the cold startup blob, run the
|
6487
|
+
* warm-up script to trigger code compilation. The side effects are then
|
6488
|
+
* discarded. The resulting startup snapshot will include compiled code.
|
6199
6489
|
* Returns { NULL, 0 } on failure.
|
6200
|
-
* The caller
|
6490
|
+
* The caller acquires ownership of the data array in the return value.
|
6491
|
+
* The argument startup blob is untouched.
|
6201
6492
|
*/
|
6202
|
-
static StartupData
|
6493
|
+
static StartupData WarmUpSnapshotDataBlob(StartupData cold_startup_blob,
|
6494
|
+
const char* warmup_source);
|
6203
6495
|
|
6204
6496
|
/**
|
6205
6497
|
* Adds a message listener.
|
@@ -6297,23 +6589,6 @@ class V8_EXPORT V8 {
|
|
6297
6589
|
"Use isolate version",
|
6298
6590
|
void RemoveGCEpilogueCallback(GCCallback callback));
|
6299
6591
|
|
6300
|
-
/**
|
6301
|
-
* Enables the host application to provide a mechanism to be notified
|
6302
|
-
* and perform custom logging when V8 Allocates Executable Memory.
|
6303
|
-
*/
|
6304
|
-
V8_INLINE static V8_DEPRECATED(
|
6305
|
-
"Use isolate version",
|
6306
|
-
void AddMemoryAllocationCallback(MemoryAllocationCallback callback,
|
6307
|
-
ObjectSpace space,
|
6308
|
-
AllocationAction action));
|
6309
|
-
|
6310
|
-
/**
|
6311
|
-
* Removes callback that was installed by AddMemoryAllocationCallback.
|
6312
|
-
*/
|
6313
|
-
V8_INLINE static V8_DEPRECATED(
|
6314
|
-
"Use isolate version",
|
6315
|
-
void RemoveMemoryAllocationCallback(MemoryAllocationCallback callback));
|
6316
|
-
|
6317
6592
|
/**
|
6318
6593
|
* Initializes V8. This function needs to be called before the first Isolate
|
6319
6594
|
* is created. It always returns true.
|
@@ -6434,7 +6709,24 @@ class V8_EXPORT V8 {
|
|
6434
6709
|
* If V8 was compiled with the ICU data in an external file, the location
|
6435
6710
|
* of the data file has to be provided.
|
6436
6711
|
*/
|
6437
|
-
|
6712
|
+
V8_DEPRECATE_SOON(
|
6713
|
+
"Use version with default location.",
|
6714
|
+
static bool InitializeICU(const char* icu_data_file = nullptr));
|
6715
|
+
|
6716
|
+
/**
|
6717
|
+
* Initialize the ICU library bundled with V8. The embedder should only
|
6718
|
+
* invoke this method when using the bundled ICU. If V8 was compiled with
|
6719
|
+
* the ICU data in an external file and when the default location of that
|
6720
|
+
* file should be used, a path to the executable must be provided.
|
6721
|
+
* Returns true on success.
|
6722
|
+
*
|
6723
|
+
* The default is a file called icudtl.dat side-by-side with the executable.
|
6724
|
+
*
|
6725
|
+
* Optionally, the location of the data file can be provided to override the
|
6726
|
+
* default.
|
6727
|
+
*/
|
6728
|
+
static bool InitializeICUDefaultLocation(const char* exec_path,
|
6729
|
+
const char* icu_data_file = nullptr);
|
6438
6730
|
|
6439
6731
|
/**
|
6440
6732
|
* Initialize the external startup data. The embedder only needs to
|
@@ -6474,24 +6766,27 @@ class V8_EXPORT V8 {
|
|
6474
6766
|
internal::Object** handle);
|
6475
6767
|
static internal::Object** CopyPersistent(internal::Object** handle);
|
6476
6768
|
static void DisposeGlobal(internal::Object** global_handle);
|
6477
|
-
|
6478
|
-
static void MakeWeak(internal::Object** global_handle, void* data,
|
6479
|
-
WeakCallback weak_callback);
|
6480
|
-
static void MakeWeak(internal::Object** global_handle, void* data,
|
6769
|
+
static void MakeWeak(internal::Object** location, void* data,
|
6481
6770
|
WeakCallbackInfo<void>::Callback weak_callback,
|
6482
6771
|
WeakCallbackType type);
|
6483
|
-
static void MakeWeak(internal::Object**
|
6772
|
+
static void MakeWeak(internal::Object** location, void* data,
|
6484
6773
|
// Must be 0 or -1.
|
6485
6774
|
int internal_field_index1,
|
6486
6775
|
// Must be 1 or -1.
|
6487
6776
|
int internal_field_index2,
|
6488
6777
|
WeakCallbackInfo<void>::Callback weak_callback);
|
6489
|
-
static void
|
6778
|
+
static void MakeWeak(internal::Object*** location_addr);
|
6779
|
+
static void* ClearWeak(internal::Object** location);
|
6490
6780
|
static void Eternalize(Isolate* isolate,
|
6491
6781
|
Value* handle,
|
6492
6782
|
int* index);
|
6493
6783
|
static Local<Value> GetEternal(Isolate* isolate, int index);
|
6494
6784
|
|
6785
|
+
static void RegisterExternallyReferencedObject(internal::Object** object,
|
6786
|
+
internal::Isolate* isolate);
|
6787
|
+
template <class K, class V, class T>
|
6788
|
+
friend class PersistentValueMapBase;
|
6789
|
+
|
6495
6790
|
static void FromJustIsNothing();
|
6496
6791
|
static void ToLocalEmpty();
|
6497
6792
|
static void InternalFieldOutOfBounds(int index);
|
@@ -6508,6 +6803,60 @@ class V8_EXPORT V8 {
|
|
6508
6803
|
friend class Context;
|
6509
6804
|
};
|
6510
6805
|
|
6806
|
+
/**
|
6807
|
+
* Helper class to create a snapshot data blob.
|
6808
|
+
*/
|
6809
|
+
class SnapshotCreator {
|
6810
|
+
public:
|
6811
|
+
enum class FunctionCodeHandling { kClear, kKeep };
|
6812
|
+
|
6813
|
+
/**
|
6814
|
+
* Create and enter an isolate, and set it up for serialization.
|
6815
|
+
* The isolate is either created from scratch or from an existing snapshot.
|
6816
|
+
* The caller keeps ownership of the argument snapshot.
|
6817
|
+
* \param existing_blob existing snapshot from which to create this one.
|
6818
|
+
* \param external_references a null-terminated array of external references
|
6819
|
+
* that must be equivalent to CreateParams::external_references.
|
6820
|
+
*/
|
6821
|
+
SnapshotCreator(intptr_t* external_references = nullptr,
|
6822
|
+
StartupData* existing_blob = nullptr);
|
6823
|
+
|
6824
|
+
~SnapshotCreator();
|
6825
|
+
|
6826
|
+
/**
|
6827
|
+
* \returns the isolate prepared by the snapshot creator.
|
6828
|
+
*/
|
6829
|
+
Isolate* GetIsolate();
|
6830
|
+
|
6831
|
+
/**
|
6832
|
+
* Add a context to be included in the snapshot blob.
|
6833
|
+
* \returns the index of the context in the snapshot blob.
|
6834
|
+
*/
|
6835
|
+
size_t AddContext(Local<Context> context);
|
6836
|
+
|
6837
|
+
/**
|
6838
|
+
* Add a template to be included in the snapshot blob.
|
6839
|
+
* \returns the index of the template in the snapshot blob.
|
6840
|
+
*/
|
6841
|
+
size_t AddTemplate(Local<Template> template_obj);
|
6842
|
+
|
6843
|
+
/**
|
6844
|
+
* Created a snapshot data blob.
|
6845
|
+
* This must not be called from within a handle scope.
|
6846
|
+
* \param function_code_handling whether to include compiled function code
|
6847
|
+
* in the snapshot.
|
6848
|
+
* \returns { nullptr, 0 } on failure, and a startup snapshot on success. The
|
6849
|
+
* caller acquires ownership of the data array in the return value.
|
6850
|
+
*/
|
6851
|
+
StartupData CreateBlob(FunctionCodeHandling function_code_handling);
|
6852
|
+
|
6853
|
+
private:
|
6854
|
+
void* data_;
|
6855
|
+
|
6856
|
+
// Disallow copying and assigning.
|
6857
|
+
SnapshotCreator(const SnapshotCreator&);
|
6858
|
+
void operator=(const SnapshotCreator&);
|
6859
|
+
};
|
6511
6860
|
|
6512
6861
|
/**
|
6513
6862
|
* A simple Maybe type, representing an object which may or may not have a
|
@@ -6794,7 +7143,8 @@ class V8_EXPORT Context {
|
|
6794
7143
|
static Local<Context> New(
|
6795
7144
|
Isolate* isolate, ExtensionConfiguration* extensions = NULL,
|
6796
7145
|
Local<ObjectTemplate> global_template = Local<ObjectTemplate>(),
|
6797
|
-
Local<Value> global_object = Local<Value>()
|
7146
|
+
Local<Value> global_object = Local<Value>(),
|
7147
|
+
size_t context_snapshot_index = 0);
|
6798
7148
|
|
6799
7149
|
/**
|
6800
7150
|
* Sets the security token for the context. To access an object in
|
@@ -7149,7 +7499,7 @@ class Internals {
|
|
7149
7499
|
1 * kApiPointerSize + kApiIntSize;
|
7150
7500
|
static const int kStringResourceOffset = 3 * kApiPointerSize;
|
7151
7501
|
|
7152
|
-
static const int kOddballKindOffset =
|
7502
|
+
static const int kOddballKindOffset = 5 * kApiPointerSize + sizeof(double);
|
7153
7503
|
static const int kForeignAddressOffset = kApiPointerSize;
|
7154
7504
|
static const int kJSObjectHeaderSize = 3 * kApiPointerSize;
|
7155
7505
|
static const int kFixedArrayHeaderSize = 2 * kApiPointerSize;
|
@@ -7161,22 +7511,18 @@ class Internals {
|
|
7161
7511
|
static const int kExternalOneByteRepresentationTag = 0x06;
|
7162
7512
|
|
7163
7513
|
static const int kIsolateEmbedderDataOffset = 0 * kApiPointerSize;
|
7164
|
-
static const int
|
7165
|
-
|
7166
|
-
|
7167
|
-
|
7168
|
-
|
7169
|
-
|
7170
|
-
|
7171
|
-
static const int
|
7172
|
-
static const int kNullValueRootIndex =
|
7173
|
-
static const int kTrueValueRootIndex =
|
7174
|
-
static const int kFalseValueRootIndex =
|
7175
|
-
static const int kEmptyStringRootIndex =
|
7176
|
-
|
7177
|
-
// The external allocation limit should be below 256 MB on all architectures
|
7178
|
-
// to avoid that resource-constrained embedders run low on memory.
|
7179
|
-
static const int kExternalAllocationLimit = 192 * 1024 * 1024;
|
7514
|
+
static const int kExternalMemoryOffset = 4 * kApiPointerSize;
|
7515
|
+
static const int kExternalMemoryLimitOffset =
|
7516
|
+
kExternalMemoryOffset + kApiInt64Size;
|
7517
|
+
static const int kIsolateRootsOffset = kExternalMemoryLimitOffset +
|
7518
|
+
kApiInt64Size + kApiInt64Size +
|
7519
|
+
kApiPointerSize + kApiPointerSize;
|
7520
|
+
static const int kUndefinedValueRootIndex = 4;
|
7521
|
+
static const int kTheHoleValueRootIndex = 5;
|
7522
|
+
static const int kNullValueRootIndex = 6;
|
7523
|
+
static const int kTrueValueRootIndex = 7;
|
7524
|
+
static const int kFalseValueRootIndex = 8;
|
7525
|
+
static const int kEmptyStringRootIndex = 9;
|
7180
7526
|
|
7181
7527
|
static const int kNodeClassIdOffset = 1 * kApiPointerSize;
|
7182
7528
|
static const int kNodeFlagsOffset = 1 * kApiPointerSize + 3;
|
@@ -7188,7 +7534,8 @@ class Internals {
|
|
7188
7534
|
static const int kNodeIsPartiallyDependentShift = 4;
|
7189
7535
|
static const int kNodeIsActiveShift = 4;
|
7190
7536
|
|
7191
|
-
static const int kJSObjectType =
|
7537
|
+
static const int kJSObjectType = 0xb7;
|
7538
|
+
static const int kJSApiObjectType = 0xb6;
|
7192
7539
|
static const int kFirstNonstringType = 0x80;
|
7193
7540
|
static const int kOddballType = 0x83;
|
7194
7541
|
static const int kForeignType = 0x87;
|
@@ -7441,39 +7788,6 @@ void PersistentBase<T>::Reset(Isolate* isolate,
|
|
7441
7788
|
}
|
7442
7789
|
|
7443
7790
|
|
7444
|
-
template <class T>
|
7445
|
-
template <typename S, typename P>
|
7446
|
-
void PersistentBase<T>::SetWeak(
|
7447
|
-
P* parameter,
|
7448
|
-
typename WeakCallbackData<S, P>::Callback callback) {
|
7449
|
-
TYPE_CHECK(S, T);
|
7450
|
-
typedef typename WeakCallbackData<Value, void>::Callback Callback;
|
7451
|
-
V8::MakeWeak(reinterpret_cast<internal::Object**>(this->val_), parameter,
|
7452
|
-
reinterpret_cast<Callback>(callback));
|
7453
|
-
}
|
7454
|
-
|
7455
|
-
|
7456
|
-
template <class T>
|
7457
|
-
template <typename P>
|
7458
|
-
void PersistentBase<T>::SetWeak(
|
7459
|
-
P* parameter,
|
7460
|
-
typename WeakCallbackData<T, P>::Callback callback) {
|
7461
|
-
SetWeak<T, P>(parameter, callback);
|
7462
|
-
}
|
7463
|
-
|
7464
|
-
|
7465
|
-
template <class T>
|
7466
|
-
template <typename P>
|
7467
|
-
void PersistentBase<T>::SetPhantom(
|
7468
|
-
P* parameter, typename WeakCallbackInfo<P>::Callback callback,
|
7469
|
-
int internal_field_index1, int internal_field_index2) {
|
7470
|
-
typedef typename WeakCallbackInfo<void>::Callback Callback;
|
7471
|
-
V8::MakeWeak(reinterpret_cast<internal::Object**>(this->val_), parameter,
|
7472
|
-
internal_field_index1, internal_field_index2,
|
7473
|
-
reinterpret_cast<Callback>(callback));
|
7474
|
-
}
|
7475
|
-
|
7476
|
-
|
7477
7791
|
template <class T>
|
7478
7792
|
template <typename P>
|
7479
7793
|
V8_INLINE void PersistentBase<T>::SetWeak(
|
@@ -7484,6 +7798,10 @@ V8_INLINE void PersistentBase<T>::SetWeak(
|
|
7484
7798
|
reinterpret_cast<Callback>(callback), type);
|
7485
7799
|
}
|
7486
7800
|
|
7801
|
+
template <class T>
|
7802
|
+
void PersistentBase<T>::SetWeak() {
|
7803
|
+
V8::MakeWeak(reinterpret_cast<internal::Object***>(&this->val_));
|
7804
|
+
}
|
7487
7805
|
|
7488
7806
|
template <class T>
|
7489
7807
|
template <typename P>
|
@@ -7492,6 +7810,13 @@ P* PersistentBase<T>::ClearWeak() {
|
|
7492
7810
|
V8::ClearWeak(reinterpret_cast<internal::Object**>(this->val_)));
|
7493
7811
|
}
|
7494
7812
|
|
7813
|
+
template <class T>
|
7814
|
+
void PersistentBase<T>::RegisterExternalReference(Isolate* isolate) const {
|
7815
|
+
if (IsEmpty()) return;
|
7816
|
+
V8::RegisterExternallyReferencedObject(
|
7817
|
+
reinterpret_cast<internal::Object**>(this->val_),
|
7818
|
+
reinterpret_cast<internal::Isolate*>(isolate));
|
7819
|
+
}
|
7495
7820
|
|
7496
7821
|
template <class T>
|
7497
7822
|
void PersistentBase<T>::MarkIndependent() {
|
@@ -7641,14 +7966,22 @@ void ReturnValue<T>::SetEmptyString() {
|
|
7641
7966
|
*value_ = *I::GetRoot(GetIsolate(), I::kEmptyStringRootIndex);
|
7642
7967
|
}
|
7643
7968
|
|
7644
|
-
template<typename T>
|
7645
|
-
Isolate* ReturnValue<T>::GetIsolate() {
|
7969
|
+
template <typename T>
|
7970
|
+
Isolate* ReturnValue<T>::GetIsolate() const {
|
7646
7971
|
// Isolate is always the pointer below the default value on the stack.
|
7647
7972
|
return *reinterpret_cast<Isolate**>(&value_[-2]);
|
7648
7973
|
}
|
7649
7974
|
|
7650
|
-
template<typename T>
|
7651
|
-
|
7975
|
+
template <typename T>
|
7976
|
+
Local<Value> ReturnValue<T>::Get() const {
|
7977
|
+
typedef internal::Internals I;
|
7978
|
+
if (*value_ == *I::GetRoot(GetIsolate(), I::kTheHoleValueRootIndex))
|
7979
|
+
return Local<Value>(*Undefined(GetIsolate()));
|
7980
|
+
return Local<Value>::New(GetIsolate(), reinterpret_cast<Value*>(value_));
|
7981
|
+
}
|
7982
|
+
|
7983
|
+
template <typename T>
|
7984
|
+
template <typename S>
|
7652
7985
|
void ReturnValue<T>::Set(S* whatever) {
|
7653
7986
|
// Uncompilable to prevent inadvertent misuse.
|
7654
7987
|
TYPE_CHECK(S*, Primitive);
|
@@ -7660,17 +7993,11 @@ internal::Object* ReturnValue<T>::GetDefaultValue() {
|
|
7660
7993
|
return value_[-1];
|
7661
7994
|
}
|
7662
7995
|
|
7663
|
-
|
7664
|
-
template<typename T>
|
7996
|
+
template <typename T>
|
7665
7997
|
FunctionCallbackInfo<T>::FunctionCallbackInfo(internal::Object** implicit_args,
|
7666
7998
|
internal::Object** values,
|
7667
|
-
int length
|
7668
|
-
|
7669
|
-
: implicit_args_(implicit_args),
|
7670
|
-
values_(values),
|
7671
|
-
length_(length),
|
7672
|
-
is_construct_call_(is_construct_call) { }
|
7673
|
-
|
7999
|
+
int length)
|
8000
|
+
: implicit_args_(implicit_args), values_(values), length_(length) {}
|
7674
8001
|
|
7675
8002
|
template<typename T>
|
7676
8003
|
Local<Value> FunctionCallbackInfo<T>::operator[](int i) const {
|
@@ -7698,8 +8025,13 @@ Local<Object> FunctionCallbackInfo<T>::Holder() const {
|
|
7698
8025
|
&implicit_args_[kHolderIndex]));
|
7699
8026
|
}
|
7700
8027
|
|
8028
|
+
template <typename T>
|
8029
|
+
Local<Value> FunctionCallbackInfo<T>::NewTarget() const {
|
8030
|
+
return Local<Value>(
|
8031
|
+
reinterpret_cast<Value*>(&implicit_args_[kNewTargetIndex]));
|
8032
|
+
}
|
7701
8033
|
|
7702
|
-
template<typename T>
|
8034
|
+
template <typename T>
|
7703
8035
|
Local<Value> FunctionCallbackInfo<T>::Data() const {
|
7704
8036
|
return Local<Value>(reinterpret_cast<Value*>(&implicit_args_[kDataIndex]));
|
7705
8037
|
}
|
@@ -7719,7 +8051,7 @@ ReturnValue<T> FunctionCallbackInfo<T>::GetReturnValue() const {
|
|
7719
8051
|
|
7720
8052
|
template<typename T>
|
7721
8053
|
bool FunctionCallbackInfo<T>::IsConstructCall() const {
|
7722
|
-
return
|
8054
|
+
return !NewTarget()->IsUndefined();
|
7723
8055
|
}
|
7724
8056
|
|
7725
8057
|
|
@@ -7813,7 +8145,9 @@ Local<Value> Object::GetInternalField(int index) {
|
|
7813
8145
|
O* obj = *reinterpret_cast<O**>(this);
|
7814
8146
|
// Fast path: If the object is a plain JSObject, which is the common case, we
|
7815
8147
|
// know where to find the internal fields and can return the value directly.
|
7816
|
-
|
8148
|
+
auto instance_type = I::GetInstanceType(obj);
|
8149
|
+
if (instance_type == I::kJSObjectType ||
|
8150
|
+
instance_type == I::kJSApiObjectType) {
|
7817
8151
|
int offset = I::kJSObjectHeaderSize + (internal::kApiPointerSize * index);
|
7818
8152
|
O* value = I::ReadField<O*>(obj, offset);
|
7819
8153
|
O** result = HandleScope::CreateHandle(reinterpret_cast<HO*>(obj), value);
|
@@ -7831,7 +8165,9 @@ void* Object::GetAlignedPointerFromInternalField(int index) {
|
|
7831
8165
|
O* obj = *reinterpret_cast<O**>(this);
|
7832
8166
|
// Fast path: If the object is a plain JSObject, which is the common case, we
|
7833
8167
|
// know where to find the internal fields and can return the value directly.
|
7834
|
-
|
8168
|
+
auto instance_type = I::GetInstanceType(obj);
|
8169
|
+
if (V8_LIKELY(instance_type == I::kJSObjectType ||
|
8170
|
+
instance_type == I::kJSApiObjectType)) {
|
7835
8171
|
int offset = I::kJSObjectHeaderSize + (internal::kApiPointerSize * index);
|
7836
8172
|
return I::ReadField<void*>(obj, offset);
|
7837
8173
|
}
|
@@ -8382,21 +8718,16 @@ uint32_t Isolate::GetNumberOfDataSlots() {
|
|
8382
8718
|
int64_t Isolate::AdjustAmountOfExternalAllocatedMemory(
|
8383
8719
|
int64_t change_in_bytes) {
|
8384
8720
|
typedef internal::Internals I;
|
8385
|
-
int64_t*
|
8386
|
-
reinterpret_cast<
|
8387
|
-
|
8388
|
-
|
8389
|
-
|
8390
|
-
|
8391
|
-
|
8392
|
-
int64_t amount = *amount_of_external_allocated_memory + change_in_bytes;
|
8393
|
-
if (change_in_bytes > 0 &&
|
8394
|
-
amount - *amount_of_external_allocated_memory_at_last_global_gc >
|
8395
|
-
I::kExternalAllocationLimit) {
|
8721
|
+
int64_t* external_memory = reinterpret_cast<int64_t*>(
|
8722
|
+
reinterpret_cast<uint8_t*>(this) + I::kExternalMemoryOffset);
|
8723
|
+
const int64_t external_memory_limit = *reinterpret_cast<int64_t*>(
|
8724
|
+
reinterpret_cast<uint8_t*>(this) + I::kExternalMemoryLimitOffset);
|
8725
|
+
const int64_t amount = *external_memory + change_in_bytes;
|
8726
|
+
*external_memory = amount;
|
8727
|
+
if (change_in_bytes > 0 && amount > external_memory_limit) {
|
8396
8728
|
ReportExternalAllocationLimitReached();
|
8397
8729
|
}
|
8398
|
-
*
|
8399
|
-
return *amount_of_external_allocated_memory;
|
8730
|
+
return *external_memory;
|
8400
8731
|
}
|
8401
8732
|
|
8402
8733
|
|
@@ -8511,21 +8842,6 @@ void V8::RemoveGCEpilogueCallback(GCCallback callback) {
|
|
8511
8842
|
reinterpret_cast<v8::Isolate::GCCallback>(callback));
|
8512
8843
|
}
|
8513
8844
|
|
8514
|
-
|
8515
|
-
void V8::AddMemoryAllocationCallback(MemoryAllocationCallback callback,
|
8516
|
-
ObjectSpace space,
|
8517
|
-
AllocationAction action) {
|
8518
|
-
Isolate* isolate = Isolate::GetCurrent();
|
8519
|
-
isolate->AddMemoryAllocationCallback(callback, space, action);
|
8520
|
-
}
|
8521
|
-
|
8522
|
-
|
8523
|
-
void V8::RemoveMemoryAllocationCallback(MemoryAllocationCallback callback) {
|
8524
|
-
Isolate* isolate = Isolate::GetCurrent();
|
8525
|
-
isolate->RemoveMemoryAllocationCallback(callback);
|
8526
|
-
}
|
8527
|
-
|
8528
|
-
|
8529
8845
|
void V8::TerminateExecution(Isolate* isolate) { isolate->TerminateExecution(); }
|
8530
8846
|
|
8531
8847
|
|