libv8-node 15.14.0.1-aarch64-linux → 17.9.1.0-aarch64-linux

Sign up to get free protection for your applications and to get access to all the features.
Files changed (100) hide show
  1. checksums.yaml +4 -4
  2. data/ext/libv8-node/location.rb +1 -1
  3. data/ext/libv8-node/paths.rb +5 -1
  4. data/lib/libv8/node/version.rb +3 -3
  5. data/vendor/v8/{out.gn → aarch64-linux}/libv8/obj/libv8_monolith.a +0 -0
  6. data/vendor/v8/include/cppgc/allocation.h +110 -44
  7. data/vendor/v8/include/cppgc/common.h +9 -6
  8. data/vendor/v8/include/cppgc/cross-thread-persistent.h +465 -0
  9. data/vendor/v8/include/cppgc/custom-space.h +37 -2
  10. data/vendor/v8/include/cppgc/default-platform.h +47 -48
  11. data/vendor/v8/include/cppgc/ephemeron-pair.h +30 -0
  12. data/vendor/v8/include/cppgc/explicit-management.h +82 -0
  13. data/vendor/v8/include/cppgc/garbage-collected.h +4 -3
  14. data/vendor/v8/include/cppgc/heap-consistency.h +253 -0
  15. data/vendor/v8/include/cppgc/heap-state.h +70 -0
  16. data/vendor/v8/include/cppgc/heap-statistics.h +120 -0
  17. data/vendor/v8/include/cppgc/heap.h +68 -6
  18. data/vendor/v8/include/cppgc/internal/api-constants.h +3 -3
  19. data/vendor/v8/include/cppgc/internal/caged-heap-local-data.h +4 -3
  20. data/vendor/v8/include/cppgc/internal/compiler-specific.h +2 -2
  21. data/vendor/v8/include/cppgc/internal/finalizer-trait.h +2 -0
  22. data/vendor/v8/include/cppgc/internal/gc-info.h +124 -13
  23. data/vendor/v8/include/cppgc/internal/name-trait.h +122 -0
  24. data/vendor/v8/include/cppgc/internal/persistent-node.h +94 -6
  25. data/vendor/v8/include/cppgc/internal/pointer-policies.h +81 -29
  26. data/vendor/v8/include/cppgc/internal/prefinalizer-handler.h +1 -1
  27. data/vendor/v8/include/cppgc/internal/write-barrier.h +398 -35
  28. data/vendor/v8/include/cppgc/liveness-broker.h +11 -2
  29. data/vendor/v8/include/cppgc/macros.h +2 -0
  30. data/vendor/v8/include/cppgc/member.h +87 -25
  31. data/vendor/v8/include/cppgc/name-provider.h +65 -0
  32. data/vendor/v8/include/cppgc/object-size-trait.h +58 -0
  33. data/vendor/v8/include/cppgc/persistent.h +41 -11
  34. data/vendor/v8/include/cppgc/platform.h +49 -25
  35. data/vendor/v8/include/cppgc/prefinalizer.h +2 -2
  36. data/vendor/v8/include/cppgc/process-heap-statistics.h +36 -0
  37. data/vendor/v8/include/cppgc/sentinel-pointer.h +32 -0
  38. data/vendor/v8/include/cppgc/source-location.h +2 -1
  39. data/vendor/v8/include/cppgc/testing.h +99 -0
  40. data/vendor/v8/include/cppgc/trace-trait.h +8 -3
  41. data/vendor/v8/include/cppgc/type-traits.h +157 -19
  42. data/vendor/v8/include/cppgc/visitor.h +194 -28
  43. data/vendor/v8/include/libplatform/libplatform.h +11 -0
  44. data/vendor/v8/include/libplatform/v8-tracing.h +2 -0
  45. data/vendor/v8/include/v8-array-buffer.h +433 -0
  46. data/vendor/v8/include/v8-callbacks.h +377 -0
  47. data/vendor/v8/include/v8-container.h +129 -0
  48. data/vendor/v8/include/v8-context.h +418 -0
  49. data/vendor/v8/include/v8-cppgc.h +261 -159
  50. data/vendor/v8/include/v8-data.h +65 -0
  51. data/vendor/v8/include/v8-date.h +43 -0
  52. data/vendor/v8/include/v8-debug.h +151 -0
  53. data/vendor/v8/include/v8-embedder-heap.h +238 -0
  54. data/vendor/v8/include/v8-exception.h +224 -0
  55. data/vendor/v8/include/v8-extension.h +62 -0
  56. data/vendor/v8/include/v8-external.h +37 -0
  57. data/vendor/v8/include/v8-fast-api-calls.h +652 -152
  58. data/vendor/v8/include/v8-forward.h +81 -0
  59. data/vendor/v8/include/v8-function-callback.h +475 -0
  60. data/vendor/v8/include/v8-function.h +122 -0
  61. data/vendor/v8/include/v8-initialization.h +282 -0
  62. data/vendor/v8/include/v8-inspector.h +33 -25
  63. data/vendor/v8/include/v8-internal.h +178 -31
  64. data/vendor/v8/include/v8-isolate.h +1662 -0
  65. data/vendor/v8/include/v8-json.h +47 -0
  66. data/vendor/v8/include/v8-local-handle.h +459 -0
  67. data/vendor/v8/include/v8-locker.h +148 -0
  68. data/vendor/v8/include/v8-maybe.h +137 -0
  69. data/vendor/v8/include/v8-memory-span.h +43 -0
  70. data/vendor/v8/include/v8-message.h +241 -0
  71. data/vendor/v8/include/v8-metrics.h +114 -9
  72. data/vendor/v8/include/v8-microtask-queue.h +152 -0
  73. data/vendor/v8/include/v8-microtask.h +28 -0
  74. data/vendor/v8/include/v8-object.h +770 -0
  75. data/vendor/v8/include/v8-persistent-handle.h +590 -0
  76. data/vendor/v8/include/v8-platform.h +74 -25
  77. data/vendor/v8/include/v8-primitive-object.h +118 -0
  78. data/vendor/v8/include/v8-primitive.h +858 -0
  79. data/vendor/v8/include/v8-profiler.h +72 -9
  80. data/vendor/v8/include/v8-promise.h +174 -0
  81. data/vendor/v8/include/v8-proxy.h +50 -0
  82. data/vendor/v8/include/v8-regexp.h +105 -0
  83. data/vendor/v8/include/v8-script.h +771 -0
  84. data/vendor/v8/include/v8-snapshot.h +198 -0
  85. data/vendor/v8/include/v8-statistics.h +215 -0
  86. data/vendor/v8/include/v8-template.h +1052 -0
  87. data/vendor/v8/include/v8-traced-handle.h +605 -0
  88. data/vendor/v8/include/v8-typed-array.h +282 -0
  89. data/vendor/v8/include/v8-unwinder-state.h +31 -0
  90. data/vendor/v8/include/v8-unwinder.h +129 -0
  91. data/vendor/v8/include/v8-util.h +8 -2
  92. data/vendor/v8/include/v8-value-serializer.h +249 -0
  93. data/vendor/v8/include/v8-value.h +526 -0
  94. data/vendor/v8/include/v8-version.h +3 -3
  95. data/vendor/v8/include/v8-wasm.h +245 -0
  96. data/vendor/v8/include/v8-weak-callback-info.h +73 -0
  97. data/vendor/v8/include/v8.h +41 -12050
  98. data/vendor/v8/include/v8config.h +87 -11
  99. metadata +60 -6
  100. data/vendor/v8/include/cppgc/internal/process-heap.h +0 -34
@@ -6,11 +6,14 @@
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" // NOLINT(build/include_directory)
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.
@@ -19,6 +22,7 @@ namespace v8 {
19
22
 
20
23
  class HeapGraphNode;
21
24
  struct HeapStatsUpdate;
25
+ class Object;
22
26
 
23
27
  using NativeObject = void*;
24
28
  using SnapshotObjectId = uint32_t;
@@ -248,6 +252,26 @@ enum CpuProfilingLoggingMode {
248
252
  kEagerLogging,
249
253
  };
250
254
 
255
+ // Enum for returning profiling status. Once StartProfiling is called,
256
+ // we want to return to clients whether the profiling was able to start
257
+ // correctly, or return a descriptive error.
258
+ enum class CpuProfilingStatus {
259
+ kStarted,
260
+ kAlreadyStarted,
261
+ kErrorTooManyProfilers
262
+ };
263
+
264
+ /**
265
+ * Delegate for when max samples reached and samples are discarded.
266
+ */
267
+ class V8_EXPORT DiscardedSamplesDelegate {
268
+ public:
269
+ DiscardedSamplesDelegate() {}
270
+
271
+ virtual ~DiscardedSamplesDelegate() = default;
272
+ virtual void Notify() = 0;
273
+ };
274
+
251
275
  /**
252
276
  * Optional profiling attributes.
253
277
  */
@@ -268,6 +292,8 @@ class V8_EXPORT CpuProfilingOptions {
268
292
  * interval, set via SetSamplingInterval(). If
269
293
  * zero, the sampling interval will be equal to
270
294
  * the profiler's sampling interval.
295
+ * \param filter_context If specified, profiles will only contain frames
296
+ * using this context. Other frames will be elided.
271
297
  */
272
298
  CpuProfilingOptions(
273
299
  CpuProfilingMode mode = kLeafNodeLineNumbers,
@@ -338,7 +364,9 @@ class V8_EXPORT CpuProfiler {
338
364
  * profiles may be collected at once. Attempts to start collecting several
339
365
  * profiles with the same title are silently ignored.
340
366
  */
341
- void StartProfiling(Local<String> title, CpuProfilingOptions options);
367
+ CpuProfilingStatus StartProfiling(
368
+ Local<String> title, CpuProfilingOptions options,
369
+ std::unique_ptr<DiscardedSamplesDelegate> delegate = nullptr);
342
370
 
343
371
  /**
344
372
  * Starts profiling with the same semantics as above, except with expanded
@@ -351,7 +379,7 @@ class V8_EXPORT CpuProfiler {
351
379
  * recorded by the profiler. Samples obtained after this limit will be
352
380
  * discarded.
353
381
  */
354
- void StartProfiling(
382
+ CpuProfilingStatus StartProfiling(
355
383
  Local<String> title, CpuProfilingMode mode, bool record_samples = false,
356
384
  unsigned max_samples = CpuProfilingOptions::kNoSampleLimit);
357
385
  /**
@@ -359,7 +387,8 @@ class V8_EXPORT CpuProfiler {
359
387
  * kLeafNodeLineNumbers mode, which was the previous default behavior of the
360
388
  * profiler.
361
389
  */
362
- void StartProfiling(Local<String> title, bool record_samples = false);
390
+ CpuProfilingStatus StartProfiling(Local<String> title,
391
+ bool record_samples = false);
363
392
 
364
393
  /**
365
394
  * Stops collecting CPU profile with a given title and returns it.
@@ -470,7 +499,7 @@ class V8_EXPORT HeapGraphNode {
470
499
  /**
471
500
  * An interface for exporting data from V8, using "push" model.
472
501
  */
473
- class V8_EXPORT OutputStream { // NOLINT
502
+ class V8_EXPORT OutputStream {
474
503
  public:
475
504
  enum WriteResult {
476
505
  kContinue = 0,
@@ -497,7 +526,6 @@ class V8_EXPORT OutputStream { // NOLINT
497
526
  }
498
527
  };
499
528
 
500
-
501
529
  /**
502
530
  * HeapSnapshots record the state of the JS heap at some moment.
503
531
  */
@@ -564,7 +592,7 @@ class V8_EXPORT HeapSnapshot {
564
592
  * An interface for reporting progress and controlling long-running
565
593
  * activities.
566
594
  */
567
- class V8_EXPORT ActivityControl { // NOLINT
595
+ class V8_EXPORT ActivityControl {
568
596
  public:
569
597
  enum ControlOption {
570
598
  kContinue = 0,
@@ -578,7 +606,6 @@ class V8_EXPORT ActivityControl { // NOLINT
578
606
  virtual ControlOption ReportProgressValue(int done, int total) = 0;
579
607
  };
580
608
 
581
-
582
609
  /**
583
610
  * AllocationProfile is a sampled profile of allocations done by the program.
584
611
  * This is structured as a call-graph.
@@ -712,6 +739,19 @@ class V8_EXPORT EmbedderGraph {
712
739
  public:
713
740
  class Node {
714
741
  public:
742
+ /**
743
+ * Detachedness specifies whether an object is attached or detached from the
744
+ * main application state. While unkown in general, there may be objects
745
+ * that specifically know their state. V8 passes this information along in
746
+ * the snapshot. Users of the snapshot may use it to annotate the object
747
+ * graph.
748
+ */
749
+ enum class Detachedness : uint8_t {
750
+ kUnknown = 0,
751
+ kAttached = 1,
752
+ kDetached = 2,
753
+ };
754
+
715
755
  Node() = default;
716
756
  virtual ~Node() = default;
717
757
  virtual const char* Name() = 0;
@@ -736,6 +776,14 @@ class V8_EXPORT EmbedderGraph {
736
776
  */
737
777
  virtual NativeObject GetNativeObject() { return nullptr; }
738
778
 
779
+ /**
780
+ * Detachedness state of a given object. While unkown in general, there may
781
+ * be objects that specifically know their state. V8 passes this information
782
+ * along in the snapshot. Users of the snapshot may use it to annotate the
783
+ * object graph.
784
+ */
785
+ virtual Detachedness GetDetachedness() { return Detachedness::kUnknown; }
786
+
739
787
  Node(const Node&) = delete;
740
788
  Node& operator=(const Node&) = delete;
741
789
  };
@@ -786,6 +834,18 @@ class V8_EXPORT HeapProfiler {
786
834
  v8::EmbedderGraph* graph,
787
835
  void* data);
788
836
 
837
+ /**
838
+ * Callback function invoked during heap snapshot generation to retrieve
839
+ * the detachedness state of an object referenced by a TracedReference.
840
+ *
841
+ * The callback takes Local<Value> as parameter to allow the embedder to
842
+ * unpack the TracedReference into a Local and reuse that Local for different
843
+ * purposes.
844
+ */
845
+ using GetDetachednessCallback = EmbedderGraph::Node::Detachedness (*)(
846
+ v8::Isolate* isolate, const v8::Local<v8::Value>& v8_value,
847
+ uint16_t class_id, void* data);
848
+
789
849
  /** Returns the number of snapshots taken. */
790
850
  int GetSnapshotCount();
791
851
 
@@ -845,7 +905,8 @@ class V8_EXPORT HeapProfiler {
845
905
  const HeapSnapshot* TakeHeapSnapshot(
846
906
  ActivityControl* control = nullptr,
847
907
  ObjectNameResolver* global_object_name_resolver = nullptr,
848
- bool treat_global_objects_as_roots = true);
908
+ bool treat_global_objects_as_roots = true,
909
+ bool capture_numeric_value = false);
849
910
 
850
911
  /**
851
912
  * Starts tracking of heap objects population statistics. After calling
@@ -936,6 +997,8 @@ class V8_EXPORT HeapProfiler {
936
997
  void RemoveBuildEmbedderGraphCallback(BuildEmbedderGraphCallback callback,
937
998
  void* data);
938
999
 
1000
+ void SetGetDetachednessCallback(GetDetachednessCallback callback, void* data);
1001
+
939
1002
  /**
940
1003
  * Default value of persistent handle class ID. Must not be used to
941
1004
  * 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_