libv8-node 15.14.0.1-aarch64-linux-musl → 18.8.0.0-aarch64-linux-musl
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ext/libv8-node/location.rb +1 -1
- data/ext/libv8-node/paths.rb +5 -1
- data/lib/libv8/node/version.rb +3 -3
- data/vendor/v8/{out.gn → aarch64-linux-musl}/libv8/obj/libv8_monolith.a +0 -0
- data/vendor/v8/include/cppgc/allocation.h +184 -47
- data/vendor/v8/include/cppgc/common.h +9 -6
- data/vendor/v8/include/cppgc/cross-thread-persistent.h +465 -0
- data/vendor/v8/include/cppgc/custom-space.h +37 -2
- data/vendor/v8/include/cppgc/default-platform.h +40 -49
- data/vendor/v8/include/cppgc/ephemeron-pair.h +30 -0
- data/vendor/v8/include/cppgc/explicit-management.h +100 -0
- data/vendor/v8/include/cppgc/garbage-collected.h +19 -29
- data/vendor/v8/include/cppgc/heap-consistency.h +266 -0
- data/vendor/v8/include/cppgc/heap-state.h +82 -0
- data/vendor/v8/include/cppgc/heap-statistics.h +120 -0
- data/vendor/v8/include/cppgc/heap.h +73 -6
- data/vendor/v8/include/cppgc/internal/api-constants.h +11 -3
- data/vendor/v8/include/cppgc/internal/caged-heap-local-data.h +27 -15
- data/vendor/v8/include/cppgc/internal/compiler-specific.h +2 -2
- data/vendor/v8/include/cppgc/internal/finalizer-trait.h +4 -1
- data/vendor/v8/include/cppgc/internal/gc-info.h +124 -13
- data/vendor/v8/include/cppgc/internal/logging.h +3 -3
- data/vendor/v8/include/cppgc/internal/name-trait.h +122 -0
- data/vendor/v8/include/cppgc/internal/persistent-node.h +116 -16
- data/vendor/v8/include/cppgc/internal/pointer-policies.h +84 -32
- data/vendor/v8/include/cppgc/internal/write-barrier.h +392 -35
- data/vendor/v8/include/cppgc/liveness-broker.h +11 -2
- data/vendor/v8/include/cppgc/macros.h +2 -0
- data/vendor/v8/include/cppgc/member.h +91 -26
- data/vendor/v8/include/cppgc/name-provider.h +65 -0
- data/vendor/v8/include/cppgc/object-size-trait.h +58 -0
- data/vendor/v8/include/cppgc/persistent.h +70 -41
- data/vendor/v8/include/cppgc/platform.h +52 -26
- data/vendor/v8/include/cppgc/prefinalizer.h +36 -13
- data/vendor/v8/include/cppgc/process-heap-statistics.h +36 -0
- data/vendor/v8/include/cppgc/sentinel-pointer.h +32 -0
- data/vendor/v8/include/cppgc/source-location.h +2 -1
- data/vendor/v8/include/cppgc/testing.h +106 -0
- data/vendor/v8/include/cppgc/trace-trait.h +8 -3
- data/vendor/v8/include/cppgc/type-traits.h +163 -32
- data/vendor/v8/include/cppgc/visitor.h +194 -28
- data/vendor/v8/include/libplatform/libplatform.h +11 -11
- data/vendor/v8/include/libplatform/v8-tracing.h +2 -1
- data/vendor/v8/include/v8-array-buffer.h +445 -0
- data/vendor/v8/include/v8-callbacks.h +397 -0
- data/vendor/v8/include/v8-container.h +129 -0
- data/vendor/v8/include/v8-context.h +407 -0
- data/vendor/v8/include/v8-cppgc.h +151 -159
- data/vendor/v8/include/v8-data.h +80 -0
- data/vendor/v8/include/v8-date.h +43 -0
- data/vendor/v8/include/v8-debug.h +168 -0
- data/vendor/v8/include/v8-embedder-heap.h +218 -0
- data/vendor/v8/include/v8-embedder-state-scope.h +51 -0
- data/vendor/v8/include/v8-exception.h +217 -0
- data/vendor/v8/include/v8-extension.h +62 -0
- data/vendor/v8/include/v8-external.h +37 -0
- data/vendor/v8/include/v8-fast-api-calls.h +703 -152
- data/vendor/v8/include/v8-forward.h +81 -0
- data/vendor/v8/include/v8-function-callback.h +475 -0
- data/vendor/v8/include/v8-function.h +125 -0
- data/vendor/v8/include/v8-initialization.h +315 -0
- data/vendor/v8/include/v8-inspector.h +76 -27
- data/vendor/v8/include/v8-internal.h +285 -51
- data/vendor/v8/include/v8-isolate.h +1709 -0
- data/vendor/v8/include/v8-json.h +47 -0
- data/vendor/v8/include/v8-local-handle.h +455 -0
- data/vendor/v8/include/v8-locker.h +149 -0
- data/vendor/v8/include/v8-maybe.h +137 -0
- data/vendor/v8/include/v8-memory-span.h +43 -0
- data/vendor/v8/include/v8-message.h +216 -0
- data/vendor/v8/include/v8-metrics.h +131 -9
- data/vendor/v8/include/v8-microtask-queue.h +152 -0
- data/vendor/v8/include/v8-microtask.h +28 -0
- data/vendor/v8/include/v8-object.h +775 -0
- data/vendor/v8/include/v8-persistent-handle.h +590 -0
- data/vendor/v8/include/v8-platform.h +433 -25
- data/vendor/v8/include/v8-primitive-object.h +118 -0
- data/vendor/v8/include/v8-primitive.h +866 -0
- data/vendor/v8/include/v8-profiler.h +149 -10
- data/vendor/v8/include/v8-promise.h +174 -0
- data/vendor/v8/include/v8-proxy.h +50 -0
- data/vendor/v8/include/v8-regexp.h +105 -0
- data/vendor/v8/include/v8-script.h +747 -0
- data/vendor/v8/include/v8-snapshot.h +196 -0
- data/vendor/v8/include/v8-statistics.h +217 -0
- data/vendor/v8/include/v8-template.h +1079 -0
- data/vendor/v8/include/v8-traced-handle.h +420 -0
- data/vendor/v8/include/v8-typed-array.h +282 -0
- data/vendor/v8/include/v8-unwinder-state.h +31 -0
- data/vendor/v8/include/v8-unwinder.h +132 -0
- data/vendor/v8/include/v8-util.h +8 -2
- data/vendor/v8/include/v8-value-serializer-version.h +1 -1
- data/vendor/v8/include/v8-value-serializer.h +279 -0
- data/vendor/v8/include/v8-value.h +526 -0
- data/vendor/v8/include/v8-version.h +4 -4
- data/vendor/v8/include/v8-wasm.h +257 -0
- data/vendor/v8/include/v8-weak-callback-info.h +87 -0
- data/vendor/v8/include/v8.h +41 -12051
- data/vendor/v8/include/v8config.h +142 -21
- metadata +64 -10
- data/vendor/v8/include/cppgc/internal/prefinalizer-handler.h +0 -30
- data/vendor/v8/include/cppgc/internal/process-heap.h +0 -34
@@ -6,22 +6,29 @@
|
|
6
6
|
#define V8_V8_PROFILER_H_
|
7
7
|
|
8
8
|
#include <limits.h>
|
9
|
+
|
9
10
|
#include <memory>
|
10
11
|
#include <unordered_set>
|
11
12
|
#include <vector>
|
12
13
|
|
13
|
-
#include "v8.h"
|
14
|
+
#include "v8-local-handle.h" // NOLINT(build/include_directory)
|
15
|
+
#include "v8-message.h" // NOLINT(build/include_directory)
|
16
|
+
#include "v8-persistent-handle.h" // NOLINT(build/include_directory)
|
14
17
|
|
15
18
|
/**
|
16
19
|
* Profiler support for the V8 JavaScript engine.
|
17
20
|
*/
|
18
21
|
namespace v8 {
|
19
22
|
|
23
|
+
enum class EmbedderStateTag : uint8_t;
|
20
24
|
class HeapGraphNode;
|
21
25
|
struct HeapStatsUpdate;
|
26
|
+
class Object;
|
27
|
+
enum StateTag : int;
|
22
28
|
|
23
29
|
using NativeObject = void*;
|
24
30
|
using SnapshotObjectId = uint32_t;
|
31
|
+
using ProfilerId = uint32_t;
|
25
32
|
|
26
33
|
struct CpuProfileDeoptFrame {
|
27
34
|
int script_id;
|
@@ -206,6 +213,16 @@ class V8_EXPORT CpuProfile {
|
|
206
213
|
*/
|
207
214
|
int64_t GetStartTime() const;
|
208
215
|
|
216
|
+
/**
|
217
|
+
* Returns state of the vm when sample was captured.
|
218
|
+
*/
|
219
|
+
StateTag GetSampleState(int index) const;
|
220
|
+
|
221
|
+
/**
|
222
|
+
* Returns state of the embedder when sample was captured.
|
223
|
+
*/
|
224
|
+
EmbedderStateTag GetSampleEmbedderState(int index) const;
|
225
|
+
|
209
226
|
/**
|
210
227
|
* Returns time when the profile recording was stopped (in microseconds)
|
211
228
|
* since some unspecified starting point.
|
@@ -248,6 +265,44 @@ enum CpuProfilingLoggingMode {
|
|
248
265
|
kEagerLogging,
|
249
266
|
};
|
250
267
|
|
268
|
+
// Enum for returning profiling status. Once StartProfiling is called,
|
269
|
+
// we want to return to clients whether the profiling was able to start
|
270
|
+
// correctly, or return a descriptive error.
|
271
|
+
enum class CpuProfilingStatus {
|
272
|
+
kStarted,
|
273
|
+
kAlreadyStarted,
|
274
|
+
kErrorTooManyProfilers
|
275
|
+
};
|
276
|
+
|
277
|
+
/**
|
278
|
+
* Result from StartProfiling returning the Profiling Status, and
|
279
|
+
* id of the started profiler, or 0 if profiler is not started
|
280
|
+
*/
|
281
|
+
struct CpuProfilingResult {
|
282
|
+
const ProfilerId id;
|
283
|
+
const CpuProfilingStatus status;
|
284
|
+
};
|
285
|
+
|
286
|
+
/**
|
287
|
+
* Delegate for when max samples reached and samples are discarded.
|
288
|
+
*/
|
289
|
+
class V8_EXPORT DiscardedSamplesDelegate {
|
290
|
+
public:
|
291
|
+
DiscardedSamplesDelegate() = default;
|
292
|
+
|
293
|
+
virtual ~DiscardedSamplesDelegate() = default;
|
294
|
+
virtual void Notify() = 0;
|
295
|
+
|
296
|
+
ProfilerId GetId() const { return profiler_id_; }
|
297
|
+
|
298
|
+
private:
|
299
|
+
friend internal::CpuProfile;
|
300
|
+
|
301
|
+
void SetId(ProfilerId id) { profiler_id_ = id; }
|
302
|
+
|
303
|
+
ProfilerId profiler_id_;
|
304
|
+
};
|
305
|
+
|
251
306
|
/**
|
252
307
|
* Optional profiling attributes.
|
253
308
|
*/
|
@@ -268,6 +323,8 @@ class V8_EXPORT CpuProfilingOptions {
|
|
268
323
|
* interval, set via SetSamplingInterval(). If
|
269
324
|
* zero, the sampling interval will be equal to
|
270
325
|
* the profiler's sampling interval.
|
326
|
+
* \param filter_context If specified, profiles will only contain frames
|
327
|
+
* using this context. Other frames will be elided.
|
271
328
|
*/
|
272
329
|
CpuProfilingOptions(
|
273
330
|
CpuProfilingMode mode = kLeafNodeLineNumbers,
|
@@ -333,12 +390,22 @@ class V8_EXPORT CpuProfiler {
|
|
333
390
|
*/
|
334
391
|
void SetUsePreciseSampling(bool);
|
335
392
|
|
393
|
+
/**
|
394
|
+
* Starts collecting a CPU profile. Several profiles may be collected at once.
|
395
|
+
* Generates an anonymous profiler, without a String identifier.
|
396
|
+
*/
|
397
|
+
CpuProfilingResult Start(
|
398
|
+
CpuProfilingOptions options,
|
399
|
+
std::unique_ptr<DiscardedSamplesDelegate> delegate = nullptr);
|
400
|
+
|
336
401
|
/**
|
337
402
|
* Starts collecting a CPU profile. Title may be an empty string. Several
|
338
403
|
* profiles may be collected at once. Attempts to start collecting several
|
339
404
|
* profiles with the same title are silently ignored.
|
340
405
|
*/
|
341
|
-
|
406
|
+
CpuProfilingResult Start(
|
407
|
+
Local<String> title, CpuProfilingOptions options,
|
408
|
+
std::unique_ptr<DiscardedSamplesDelegate> delegate = nullptr);
|
342
409
|
|
343
410
|
/**
|
344
411
|
* Starts profiling with the same semantics as above, except with expanded
|
@@ -351,15 +418,53 @@ class V8_EXPORT CpuProfiler {
|
|
351
418
|
* recorded by the profiler. Samples obtained after this limit will be
|
352
419
|
* discarded.
|
353
420
|
*/
|
354
|
-
|
421
|
+
CpuProfilingResult Start(
|
355
422
|
Local<String> title, CpuProfilingMode mode, bool record_samples = false,
|
356
423
|
unsigned max_samples = CpuProfilingOptions::kNoSampleLimit);
|
424
|
+
|
357
425
|
/**
|
358
426
|
* The same as StartProfiling above, but the CpuProfilingMode defaults to
|
359
427
|
* kLeafNodeLineNumbers mode, which was the previous default behavior of the
|
360
428
|
* profiler.
|
361
429
|
*/
|
362
|
-
|
430
|
+
CpuProfilingResult Start(Local<String> title, bool record_samples = false);
|
431
|
+
|
432
|
+
/**
|
433
|
+
* Starts collecting a CPU profile. Title may be an empty string. Several
|
434
|
+
* profiles may be collected at once. Attempts to start collecting several
|
435
|
+
* profiles with the same title are silently ignored.
|
436
|
+
*/
|
437
|
+
CpuProfilingStatus StartProfiling(
|
438
|
+
Local<String> title, CpuProfilingOptions options,
|
439
|
+
std::unique_ptr<DiscardedSamplesDelegate> delegate = nullptr);
|
440
|
+
|
441
|
+
/**
|
442
|
+
* Starts profiling with the same semantics as above, except with expanded
|
443
|
+
* parameters.
|
444
|
+
*
|
445
|
+
* |record_samples| parameter controls whether individual samples should
|
446
|
+
* be recorded in addition to the aggregated tree.
|
447
|
+
*
|
448
|
+
* |max_samples| controls the maximum number of samples that should be
|
449
|
+
* recorded by the profiler. Samples obtained after this limit will be
|
450
|
+
* discarded.
|
451
|
+
*/
|
452
|
+
CpuProfilingStatus StartProfiling(
|
453
|
+
Local<String> title, CpuProfilingMode mode, bool record_samples = false,
|
454
|
+
unsigned max_samples = CpuProfilingOptions::kNoSampleLimit);
|
455
|
+
|
456
|
+
/**
|
457
|
+
* The same as StartProfiling above, but the CpuProfilingMode defaults to
|
458
|
+
* kLeafNodeLineNumbers mode, which was the previous default behavior of the
|
459
|
+
* profiler.
|
460
|
+
*/
|
461
|
+
CpuProfilingStatus StartProfiling(Local<String> title,
|
462
|
+
bool record_samples = false);
|
463
|
+
|
464
|
+
/**
|
465
|
+
* Stops collecting CPU profile with a given id and returns it.
|
466
|
+
*/
|
467
|
+
CpuProfile* Stop(ProfilerId id);
|
363
468
|
|
364
469
|
/**
|
365
470
|
* Stops collecting CPU profile with a given title and returns it.
|
@@ -470,7 +575,7 @@ class V8_EXPORT HeapGraphNode {
|
|
470
575
|
/**
|
471
576
|
* An interface for exporting data from V8, using "push" model.
|
472
577
|
*/
|
473
|
-
class V8_EXPORT OutputStream {
|
578
|
+
class V8_EXPORT OutputStream {
|
474
579
|
public:
|
475
580
|
enum WriteResult {
|
476
581
|
kContinue = 0,
|
@@ -497,7 +602,6 @@ class V8_EXPORT OutputStream { // NOLINT
|
|
497
602
|
}
|
498
603
|
};
|
499
604
|
|
500
|
-
|
501
605
|
/**
|
502
606
|
* HeapSnapshots record the state of the JS heap at some moment.
|
503
607
|
*/
|
@@ -564,7 +668,7 @@ class V8_EXPORT HeapSnapshot {
|
|
564
668
|
* An interface for reporting progress and controlling long-running
|
565
669
|
* activities.
|
566
670
|
*/
|
567
|
-
class V8_EXPORT ActivityControl {
|
671
|
+
class V8_EXPORT ActivityControl {
|
568
672
|
public:
|
569
673
|
enum ControlOption {
|
570
674
|
kContinue = 0,
|
@@ -575,10 +679,9 @@ class V8_EXPORT ActivityControl { // NOLINT
|
|
575
679
|
* Notify about current progress. The activity can be stopped by
|
576
680
|
* returning kAbort as the callback result.
|
577
681
|
*/
|
578
|
-
virtual ControlOption ReportProgressValue(
|
682
|
+
virtual ControlOption ReportProgressValue(uint32_t done, uint32_t total) = 0;
|
579
683
|
};
|
580
684
|
|
581
|
-
|
582
685
|
/**
|
583
686
|
* AllocationProfile is a sampled profile of allocations done by the program.
|
584
687
|
* This is structured as a call-graph.
|
@@ -712,6 +815,19 @@ class V8_EXPORT EmbedderGraph {
|
|
712
815
|
public:
|
713
816
|
class Node {
|
714
817
|
public:
|
818
|
+
/**
|
819
|
+
* Detachedness specifies whether an object is attached or detached from the
|
820
|
+
* main application state. While unkown in general, there may be objects
|
821
|
+
* that specifically know their state. V8 passes this information along in
|
822
|
+
* the snapshot. Users of the snapshot may use it to annotate the object
|
823
|
+
* graph.
|
824
|
+
*/
|
825
|
+
enum class Detachedness : uint8_t {
|
826
|
+
kUnknown = 0,
|
827
|
+
kAttached = 1,
|
828
|
+
kDetached = 2,
|
829
|
+
};
|
830
|
+
|
715
831
|
Node() = default;
|
716
832
|
virtual ~Node() = default;
|
717
833
|
virtual const char* Name() = 0;
|
@@ -736,6 +852,14 @@ class V8_EXPORT EmbedderGraph {
|
|
736
852
|
*/
|
737
853
|
virtual NativeObject GetNativeObject() { return nullptr; }
|
738
854
|
|
855
|
+
/**
|
856
|
+
* Detachedness state of a given object. While unkown in general, there may
|
857
|
+
* be objects that specifically know their state. V8 passes this information
|
858
|
+
* along in the snapshot. Users of the snapshot may use it to annotate the
|
859
|
+
* object graph.
|
860
|
+
*/
|
861
|
+
virtual Detachedness GetDetachedness() { return Detachedness::kUnknown; }
|
862
|
+
|
739
863
|
Node(const Node&) = delete;
|
740
864
|
Node& operator=(const Node&) = delete;
|
741
865
|
};
|
@@ -786,6 +910,18 @@ class V8_EXPORT HeapProfiler {
|
|
786
910
|
v8::EmbedderGraph* graph,
|
787
911
|
void* data);
|
788
912
|
|
913
|
+
/**
|
914
|
+
* Callback function invoked during heap snapshot generation to retrieve
|
915
|
+
* the detachedness state of an object referenced by a TracedReference.
|
916
|
+
*
|
917
|
+
* The callback takes Local<Value> as parameter to allow the embedder to
|
918
|
+
* unpack the TracedReference into a Local and reuse that Local for different
|
919
|
+
* purposes.
|
920
|
+
*/
|
921
|
+
using GetDetachednessCallback = EmbedderGraph::Node::Detachedness (*)(
|
922
|
+
v8::Isolate* isolate, const v8::Local<v8::Value>& v8_value,
|
923
|
+
uint16_t class_id, void* data);
|
924
|
+
|
789
925
|
/** Returns the number of snapshots taken. */
|
790
926
|
int GetSnapshotCount();
|
791
927
|
|
@@ -845,7 +981,8 @@ class V8_EXPORT HeapProfiler {
|
|
845
981
|
const HeapSnapshot* TakeHeapSnapshot(
|
846
982
|
ActivityControl* control = nullptr,
|
847
983
|
ObjectNameResolver* global_object_name_resolver = nullptr,
|
848
|
-
bool treat_global_objects_as_roots = true
|
984
|
+
bool treat_global_objects_as_roots = true,
|
985
|
+
bool capture_numeric_value = false);
|
849
986
|
|
850
987
|
/**
|
851
988
|
* Starts tracking of heap objects population statistics. After calling
|
@@ -936,6 +1073,8 @@ class V8_EXPORT HeapProfiler {
|
|
936
1073
|
void RemoveBuildEmbedderGraphCallback(BuildEmbedderGraphCallback callback,
|
937
1074
|
void* data);
|
938
1075
|
|
1076
|
+
void SetGetDetachednessCallback(GetDetachednessCallback callback, void* data);
|
1077
|
+
|
939
1078
|
/**
|
940
1079
|
* Default value of persistent handle class ID. Must not be used to
|
941
1080
|
* define a class. Can be used to reset a class of a persistent
|
@@ -0,0 +1,174 @@
|
|
1
|
+
// Copyright 2021 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 INCLUDE_V8_PROMISE_H_
|
6
|
+
#define INCLUDE_V8_PROMISE_H_
|
7
|
+
|
8
|
+
#include "v8-local-handle.h" // NOLINT(build/include_directory)
|
9
|
+
#include "v8-object.h" // NOLINT(build/include_directory)
|
10
|
+
#include "v8config.h" // NOLINT(build/include_directory)
|
11
|
+
|
12
|
+
namespace v8 {
|
13
|
+
|
14
|
+
class Context;
|
15
|
+
|
16
|
+
#ifndef V8_PROMISE_INTERNAL_FIELD_COUNT
|
17
|
+
// The number of required internal fields can be defined by embedder.
|
18
|
+
#define V8_PROMISE_INTERNAL_FIELD_COUNT 0
|
19
|
+
#endif
|
20
|
+
|
21
|
+
/**
|
22
|
+
* An instance of the built-in Promise constructor (ES6 draft).
|
23
|
+
*/
|
24
|
+
class V8_EXPORT Promise : public Object {
|
25
|
+
public:
|
26
|
+
/**
|
27
|
+
* State of the promise. Each value corresponds to one of the possible values
|
28
|
+
* of the [[PromiseState]] field.
|
29
|
+
*/
|
30
|
+
enum PromiseState { kPending, kFulfilled, kRejected };
|
31
|
+
|
32
|
+
class V8_EXPORT Resolver : public Object {
|
33
|
+
public:
|
34
|
+
/**
|
35
|
+
* Create a new resolver, along with an associated promise in pending state.
|
36
|
+
*/
|
37
|
+
static V8_WARN_UNUSED_RESULT MaybeLocal<Resolver> New(
|
38
|
+
Local<Context> context);
|
39
|
+
|
40
|
+
/**
|
41
|
+
* Extract the associated promise.
|
42
|
+
*/
|
43
|
+
Local<Promise> GetPromise();
|
44
|
+
|
45
|
+
/**
|
46
|
+
* Resolve/reject the associated promise with a given value.
|
47
|
+
* Ignored if the promise is no longer pending.
|
48
|
+
*/
|
49
|
+
V8_WARN_UNUSED_RESULT Maybe<bool> Resolve(Local<Context> context,
|
50
|
+
Local<Value> value);
|
51
|
+
|
52
|
+
V8_WARN_UNUSED_RESULT Maybe<bool> Reject(Local<Context> context,
|
53
|
+
Local<Value> value);
|
54
|
+
|
55
|
+
V8_INLINE static Resolver* Cast(Value* value) {
|
56
|
+
#ifdef V8_ENABLE_CHECKS
|
57
|
+
CheckCast(value);
|
58
|
+
#endif
|
59
|
+
return static_cast<Promise::Resolver*>(value);
|
60
|
+
}
|
61
|
+
|
62
|
+
private:
|
63
|
+
Resolver();
|
64
|
+
static void CheckCast(Value* obj);
|
65
|
+
};
|
66
|
+
|
67
|
+
/**
|
68
|
+
* Register a resolution/rejection handler with a promise.
|
69
|
+
* The handler is given the respective resolution/rejection value as
|
70
|
+
* an argument. If the promise is already resolved/rejected, the handler is
|
71
|
+
* invoked at the end of turn.
|
72
|
+
*/
|
73
|
+
V8_WARN_UNUSED_RESULT MaybeLocal<Promise> Catch(Local<Context> context,
|
74
|
+
Local<Function> handler);
|
75
|
+
|
76
|
+
V8_WARN_UNUSED_RESULT MaybeLocal<Promise> Then(Local<Context> context,
|
77
|
+
Local<Function> handler);
|
78
|
+
|
79
|
+
V8_WARN_UNUSED_RESULT MaybeLocal<Promise> Then(Local<Context> context,
|
80
|
+
Local<Function> on_fulfilled,
|
81
|
+
Local<Function> on_rejected);
|
82
|
+
|
83
|
+
/**
|
84
|
+
* Returns true if the promise has at least one derived promise, and
|
85
|
+
* therefore resolve/reject handlers (including default handler).
|
86
|
+
*/
|
87
|
+
bool HasHandler() const;
|
88
|
+
|
89
|
+
/**
|
90
|
+
* Returns the content of the [[PromiseResult]] field. The Promise must not
|
91
|
+
* be pending.
|
92
|
+
*/
|
93
|
+
Local<Value> Result();
|
94
|
+
|
95
|
+
/**
|
96
|
+
* Returns the value of the [[PromiseState]] field.
|
97
|
+
*/
|
98
|
+
PromiseState State();
|
99
|
+
|
100
|
+
/**
|
101
|
+
* Marks this promise as handled to avoid reporting unhandled rejections.
|
102
|
+
*/
|
103
|
+
void MarkAsHandled();
|
104
|
+
|
105
|
+
/**
|
106
|
+
* Marks this promise as silent to prevent pausing the debugger when the
|
107
|
+
* promise is rejected.
|
108
|
+
*/
|
109
|
+
void MarkAsSilent();
|
110
|
+
|
111
|
+
V8_INLINE static Promise* Cast(Value* value) {
|
112
|
+
#ifdef V8_ENABLE_CHECKS
|
113
|
+
CheckCast(value);
|
114
|
+
#endif
|
115
|
+
return static_cast<Promise*>(value);
|
116
|
+
}
|
117
|
+
|
118
|
+
static const int kEmbedderFieldCount = V8_PROMISE_INTERNAL_FIELD_COUNT;
|
119
|
+
|
120
|
+
private:
|
121
|
+
Promise();
|
122
|
+
static void CheckCast(Value* obj);
|
123
|
+
};
|
124
|
+
|
125
|
+
/**
|
126
|
+
* PromiseHook with type kInit is called when a new promise is
|
127
|
+
* created. When a new promise is created as part of the chain in the
|
128
|
+
* case of Promise.then or in the intermediate promises created by
|
129
|
+
* Promise.{race, all}/AsyncFunctionAwait, we pass the parent promise
|
130
|
+
* otherwise we pass undefined.
|
131
|
+
*
|
132
|
+
* PromiseHook with type kResolve is called at the beginning of
|
133
|
+
* resolve or reject function defined by CreateResolvingFunctions.
|
134
|
+
*
|
135
|
+
* PromiseHook with type kBefore is called at the beginning of the
|
136
|
+
* PromiseReactionJob.
|
137
|
+
*
|
138
|
+
* PromiseHook with type kAfter is called right at the end of the
|
139
|
+
* PromiseReactionJob.
|
140
|
+
*/
|
141
|
+
enum class PromiseHookType { kInit, kResolve, kBefore, kAfter };
|
142
|
+
|
143
|
+
using PromiseHook = void (*)(PromiseHookType type, Local<Promise> promise,
|
144
|
+
Local<Value> parent);
|
145
|
+
|
146
|
+
// --- Promise Reject Callback ---
|
147
|
+
enum PromiseRejectEvent {
|
148
|
+
kPromiseRejectWithNoHandler = 0,
|
149
|
+
kPromiseHandlerAddedAfterReject = 1,
|
150
|
+
kPromiseRejectAfterResolved = 2,
|
151
|
+
kPromiseResolveAfterResolved = 3,
|
152
|
+
};
|
153
|
+
|
154
|
+
class PromiseRejectMessage {
|
155
|
+
public:
|
156
|
+
PromiseRejectMessage(Local<Promise> promise, PromiseRejectEvent event,
|
157
|
+
Local<Value> value)
|
158
|
+
: promise_(promise), event_(event), value_(value) {}
|
159
|
+
|
160
|
+
V8_INLINE Local<Promise> GetPromise() const { return promise_; }
|
161
|
+
V8_INLINE PromiseRejectEvent GetEvent() const { return event_; }
|
162
|
+
V8_INLINE Local<Value> GetValue() const { return value_; }
|
163
|
+
|
164
|
+
private:
|
165
|
+
Local<Promise> promise_;
|
166
|
+
PromiseRejectEvent event_;
|
167
|
+
Local<Value> value_;
|
168
|
+
};
|
169
|
+
|
170
|
+
using PromiseRejectCallback = void (*)(PromiseRejectMessage message);
|
171
|
+
|
172
|
+
} // namespace v8
|
173
|
+
|
174
|
+
#endif // INCLUDE_V8_PROMISE_H_
|
@@ -0,0 +1,50 @@
|
|
1
|
+
|
2
|
+
// Copyright 2021 the V8 project authors. All rights reserved.
|
3
|
+
// Use of this source code is governed by a BSD-style license that can be
|
4
|
+
// found in the LICENSE file.
|
5
|
+
|
6
|
+
#ifndef INCLUDE_V8_PROXY_H_
|
7
|
+
#define INCLUDE_V8_PROXY_H_
|
8
|
+
|
9
|
+
#include "v8-context.h" // NOLINT(build/include_directory)
|
10
|
+
#include "v8-local-handle.h" // NOLINT(build/include_directory)
|
11
|
+
#include "v8-object.h" // NOLINT(build/include_directory)
|
12
|
+
#include "v8config.h" // NOLINT(build/include_directory)
|
13
|
+
|
14
|
+
namespace v8 {
|
15
|
+
|
16
|
+
class Context;
|
17
|
+
|
18
|
+
/**
|
19
|
+
* An instance of the built-in Proxy constructor (ECMA-262, 6th Edition,
|
20
|
+
* 26.2.1).
|
21
|
+
*/
|
22
|
+
class V8_EXPORT Proxy : public Object {
|
23
|
+
public:
|
24
|
+
Local<Value> GetTarget();
|
25
|
+
Local<Value> GetHandler();
|
26
|
+
bool IsRevoked() const;
|
27
|
+
void Revoke();
|
28
|
+
|
29
|
+
/**
|
30
|
+
* Creates a new Proxy for the target object.
|
31
|
+
*/
|
32
|
+
static MaybeLocal<Proxy> New(Local<Context> context,
|
33
|
+
Local<Object> local_target,
|
34
|
+
Local<Object> local_handler);
|
35
|
+
|
36
|
+
V8_INLINE static Proxy* Cast(Value* value) {
|
37
|
+
#ifdef V8_ENABLE_CHECKS
|
38
|
+
CheckCast(value);
|
39
|
+
#endif
|
40
|
+
return static_cast<Proxy*>(value);
|
41
|
+
}
|
42
|
+
|
43
|
+
private:
|
44
|
+
Proxy();
|
45
|
+
static void CheckCast(Value* obj);
|
46
|
+
};
|
47
|
+
|
48
|
+
} // namespace v8
|
49
|
+
|
50
|
+
#endif // INCLUDE_V8_PROXY_H_
|
@@ -0,0 +1,105 @@
|
|
1
|
+
|
2
|
+
// Copyright 2021 the V8 project authors. All rights reserved.
|
3
|
+
// Use of this source code is governed by a BSD-style license that can be
|
4
|
+
// found in the LICENSE file.
|
5
|
+
|
6
|
+
#ifndef INCLUDE_V8_REGEXP_H_
|
7
|
+
#define INCLUDE_V8_REGEXP_H_
|
8
|
+
|
9
|
+
#include "v8-local-handle.h" // NOLINT(build/include_directory)
|
10
|
+
#include "v8-object.h" // NOLINT(build/include_directory)
|
11
|
+
#include "v8config.h" // NOLINT(build/include_directory)
|
12
|
+
|
13
|
+
namespace v8 {
|
14
|
+
|
15
|
+
class Context;
|
16
|
+
|
17
|
+
/**
|
18
|
+
* An instance of the built-in RegExp constructor (ECMA-262, 15.10).
|
19
|
+
*/
|
20
|
+
class V8_EXPORT RegExp : public Object {
|
21
|
+
public:
|
22
|
+
/**
|
23
|
+
* Regular expression flag bits. They can be or'ed to enable a set
|
24
|
+
* of flags.
|
25
|
+
* The kLinear value ('l') is experimental and can only be used with
|
26
|
+
* --enable-experimental-regexp-engine. RegExps with kLinear flag are
|
27
|
+
* guaranteed to be executed in asymptotic linear time wrt. the length of
|
28
|
+
* the subject string.
|
29
|
+
*/
|
30
|
+
enum Flags {
|
31
|
+
kNone = 0,
|
32
|
+
kGlobal = 1 << 0,
|
33
|
+
kIgnoreCase = 1 << 1,
|
34
|
+
kMultiline = 1 << 2,
|
35
|
+
kSticky = 1 << 3,
|
36
|
+
kUnicode = 1 << 4,
|
37
|
+
kDotAll = 1 << 5,
|
38
|
+
kLinear = 1 << 6,
|
39
|
+
kHasIndices = 1 << 7,
|
40
|
+
};
|
41
|
+
|
42
|
+
static constexpr int kFlagCount = 8;
|
43
|
+
|
44
|
+
/**
|
45
|
+
* Creates a regular expression from the given pattern string and
|
46
|
+
* the flags bit field. May throw a JavaScript exception as
|
47
|
+
* described in ECMA-262, 15.10.4.1.
|
48
|
+
*
|
49
|
+
* For example,
|
50
|
+
* RegExp::New(v8::String::New("foo"),
|
51
|
+
* static_cast<RegExp::Flags>(kGlobal | kMultiline))
|
52
|
+
* is equivalent to evaluating "/foo/gm".
|
53
|
+
*/
|
54
|
+
static V8_WARN_UNUSED_RESULT MaybeLocal<RegExp> New(Local<Context> context,
|
55
|
+
Local<String> pattern,
|
56
|
+
Flags flags);
|
57
|
+
|
58
|
+
/**
|
59
|
+
* Like New, but additionally specifies a backtrack limit. If the number of
|
60
|
+
* backtracks done in one Exec call hits the limit, a match failure is
|
61
|
+
* immediately returned.
|
62
|
+
*/
|
63
|
+
static V8_WARN_UNUSED_RESULT MaybeLocal<RegExp> NewWithBacktrackLimit(
|
64
|
+
Local<Context> context, Local<String> pattern, Flags flags,
|
65
|
+
uint32_t backtrack_limit);
|
66
|
+
|
67
|
+
/**
|
68
|
+
* Executes the current RegExp instance on the given subject string.
|
69
|
+
* Equivalent to RegExp.prototype.exec as described in
|
70
|
+
*
|
71
|
+
* https://tc39.es/ecma262/#sec-regexp.prototype.exec
|
72
|
+
*
|
73
|
+
* On success, an Array containing the matched strings is returned. On
|
74
|
+
* failure, returns Null.
|
75
|
+
*
|
76
|
+
* Note: modifies global context state, accessible e.g. through RegExp.input.
|
77
|
+
*/
|
78
|
+
V8_WARN_UNUSED_RESULT MaybeLocal<Object> Exec(Local<Context> context,
|
79
|
+
Local<String> subject);
|
80
|
+
|
81
|
+
/**
|
82
|
+
* Returns the value of the source property: a string representing
|
83
|
+
* the regular expression.
|
84
|
+
*/
|
85
|
+
Local<String> GetSource() const;
|
86
|
+
|
87
|
+
/**
|
88
|
+
* Returns the flags bit field.
|
89
|
+
*/
|
90
|
+
Flags GetFlags() const;
|
91
|
+
|
92
|
+
V8_INLINE static RegExp* Cast(Value* value) {
|
93
|
+
#ifdef V8_ENABLE_CHECKS
|
94
|
+
CheckCast(value);
|
95
|
+
#endif
|
96
|
+
return static_cast<RegExp*>(value);
|
97
|
+
}
|
98
|
+
|
99
|
+
private:
|
100
|
+
static void CheckCast(Value* obj);
|
101
|
+
};
|
102
|
+
|
103
|
+
} // namespace v8
|
104
|
+
|
105
|
+
#endif // INCLUDE_V8_REGEXP_H_
|