libv8-node 15.12.0.0.beta1-aarch64-linux-musl → 17.9.1.0-aarch64-linux-musl

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-musl}/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 +65 -11
  100. data/vendor/v8/include/cppgc/internal/process-heap.h +0 -34
@@ -0,0 +1,151 @@
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_DEBUG_H_
6
+ #define INCLUDE_V8_DEBUG_H_
7
+
8
+ #include <stdint.h>
9
+
10
+ #include "v8-local-handle.h" // NOLINT(build/include_directory)
11
+ #include "v8config.h" // NOLINT(build/include_directory)
12
+
13
+ namespace v8 {
14
+
15
+ class Isolate;
16
+ class String;
17
+
18
+ /**
19
+ * A single JavaScript stack frame.
20
+ */
21
+ class V8_EXPORT StackFrame {
22
+ public:
23
+ /**
24
+ * Returns the number, 1-based, of the line for the associate function call.
25
+ * This method will return Message::kNoLineNumberInfo if it is unable to
26
+ * retrieve the line number, or if kLineNumber was not passed as an option
27
+ * when capturing the StackTrace.
28
+ */
29
+ int GetLineNumber() const;
30
+
31
+ /**
32
+ * Returns the 1-based column offset on the line for the associated function
33
+ * call.
34
+ * This method will return Message::kNoColumnInfo if it is unable to retrieve
35
+ * the column number, or if kColumnOffset was not passed as an option when
36
+ * capturing the StackTrace.
37
+ */
38
+ int GetColumn() const;
39
+
40
+ /**
41
+ * Returns the id of the script for the function for this StackFrame.
42
+ * This method will return Message::kNoScriptIdInfo if it is unable to
43
+ * retrieve the script id, or if kScriptId was not passed as an option when
44
+ * capturing the StackTrace.
45
+ */
46
+ int GetScriptId() const;
47
+
48
+ /**
49
+ * Returns the name of the resource that contains the script for the
50
+ * function for this StackFrame.
51
+ */
52
+ Local<String> GetScriptName() const;
53
+
54
+ /**
55
+ * Returns the name of the resource that contains the script for the
56
+ * function for this StackFrame or sourceURL value if the script name
57
+ * is undefined and its source ends with //# sourceURL=... string or
58
+ * deprecated //@ sourceURL=... string.
59
+ */
60
+ Local<String> GetScriptNameOrSourceURL() const;
61
+
62
+ /**
63
+ * Returns the source of the script for the function for this StackFrame.
64
+ */
65
+ Local<String> GetScriptSource() const;
66
+
67
+ /**
68
+ * Returns the source mapping URL (if one is present) of the script for
69
+ * the function for this StackFrame.
70
+ */
71
+ Local<String> GetScriptSourceMappingURL() const;
72
+
73
+ /**
74
+ * Returns the name of the function associated with this stack frame.
75
+ */
76
+ Local<String> GetFunctionName() const;
77
+
78
+ /**
79
+ * Returns whether or not the associated function is compiled via a call to
80
+ * eval().
81
+ */
82
+ bool IsEval() const;
83
+
84
+ /**
85
+ * Returns whether or not the associated function is called as a
86
+ * constructor via "new".
87
+ */
88
+ bool IsConstructor() const;
89
+
90
+ /**
91
+ * Returns whether or not the associated functions is defined in wasm.
92
+ */
93
+ bool IsWasm() const;
94
+
95
+ /**
96
+ * Returns whether or not the associated function is defined by the user.
97
+ */
98
+ bool IsUserJavaScript() const;
99
+ };
100
+
101
+ /**
102
+ * Representation of a JavaScript stack trace. The information collected is a
103
+ * snapshot of the execution stack and the information remains valid after
104
+ * execution continues.
105
+ */
106
+ class V8_EXPORT StackTrace {
107
+ public:
108
+ /**
109
+ * Flags that determine what information is placed captured for each
110
+ * StackFrame when grabbing the current stack trace.
111
+ * Note: these options are deprecated and we always collect all available
112
+ * information (kDetailed).
113
+ */
114
+ enum StackTraceOptions {
115
+ kLineNumber = 1,
116
+ kColumnOffset = 1 << 1 | kLineNumber,
117
+ kScriptName = 1 << 2,
118
+ kFunctionName = 1 << 3,
119
+ kIsEval = 1 << 4,
120
+ kIsConstructor = 1 << 5,
121
+ kScriptNameOrSourceURL = 1 << 6,
122
+ kScriptId = 1 << 7,
123
+ kExposeFramesAcrossSecurityOrigins = 1 << 8,
124
+ kOverview = kLineNumber | kColumnOffset | kScriptName | kFunctionName,
125
+ kDetailed = kOverview | kIsEval | kIsConstructor | kScriptNameOrSourceURL
126
+ };
127
+
128
+ /**
129
+ * Returns a StackFrame at a particular index.
130
+ */
131
+ Local<StackFrame> GetFrame(Isolate* isolate, uint32_t index) const;
132
+
133
+ /**
134
+ * Returns the number of StackFrames.
135
+ */
136
+ int GetFrameCount() const;
137
+
138
+ /**
139
+ * Grab a snapshot of the current JavaScript execution stack.
140
+ *
141
+ * \param frame_limit The maximum number of stack frames we want to capture.
142
+ * \param options Enumerates the set of things we will capture for each
143
+ * StackFrame.
144
+ */
145
+ static Local<StackTrace> CurrentStackTrace(
146
+ Isolate* isolate, int frame_limit, StackTraceOptions options = kDetailed);
147
+ };
148
+
149
+ } // namespace v8
150
+
151
+ #endif // INCLUDE_V8_DEBUG_H_
@@ -0,0 +1,238 @@
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_EMBEDDER_HEAP_H_
6
+ #define INCLUDE_V8_EMBEDDER_HEAP_H_
7
+
8
+ #include <stddef.h>
9
+ #include <stdint.h>
10
+
11
+ #include <utility>
12
+ #include <vector>
13
+
14
+ #include "cppgc/common.h"
15
+ #include "v8-local-handle.h" // NOLINT(build/include_directory)
16
+ #include "v8-traced-handle.h" // NOLINT(build/include_directory)
17
+ #include "v8config.h" // NOLINT(build/include_directory)
18
+
19
+ namespace v8 {
20
+
21
+ class Data;
22
+ class Isolate;
23
+ class Value;
24
+
25
+ namespace internal {
26
+ class LocalEmbedderHeapTracer;
27
+ } // namespace internal
28
+
29
+ /**
30
+ * Handler for embedder roots on non-unified heap garbage collections.
31
+ */
32
+ class V8_EXPORT EmbedderRootsHandler {
33
+ public:
34
+ virtual ~EmbedderRootsHandler() = default;
35
+
36
+ /**
37
+ * Returns true if the TracedGlobal handle should be considered as root for
38
+ * the currently running non-tracing garbage collection and false otherwise.
39
+ * The default implementation will keep all TracedGlobal references as roots.
40
+ *
41
+ * If this returns false, then V8 may decide that the object referred to by
42
+ * such a handle is reclaimed. In that case:
43
+ * - No action is required if handles are used with destructors, i.e., by just
44
+ * using |TracedGlobal|.
45
+ * - When run without destructors, i.e., by using |TracedReference|, V8 calls
46
+ * |ResetRoot|.
47
+ *
48
+ * Note that the |handle| is different from the handle that the embedder holds
49
+ * for retaining the object. The embedder may use |WrapperClassId()| to
50
+ * distinguish cases where it wants handles to be treated as roots from not
51
+ * being treated as roots.
52
+ */
53
+ virtual bool IsRoot(const v8::TracedReference<v8::Value>& handle) = 0;
54
+ virtual bool IsRoot(const v8::TracedGlobal<v8::Value>& handle) = 0;
55
+
56
+ /**
57
+ * Used in combination with |IsRoot|. Called by V8 when an
58
+ * object that is backed by a handle is reclaimed by a non-tracing garbage
59
+ * collection. It is up to the embedder to reset the original handle.
60
+ *
61
+ * Note that the |handle| is different from the handle that the embedder holds
62
+ * for retaining the object. It is up to the embedder to find the original
63
+ * handle via the object or class id.
64
+ */
65
+ virtual void ResetRoot(const v8::TracedReference<v8::Value>& handle) = 0;
66
+ };
67
+
68
+ /**
69
+ * Interface for tracing through the embedder heap. During a V8 garbage
70
+ * collection, V8 collects hidden fields of all potential wrappers, and at the
71
+ * end of its marking phase iterates the collection and asks the embedder to
72
+ * trace through its heap and use reporter to report each JavaScript object
73
+ * reachable from any of the given wrappers.
74
+ */
75
+ class V8_EXPORT EmbedderHeapTracer {
76
+ public:
77
+ using EmbedderStackState = cppgc::EmbedderStackState;
78
+
79
+ enum TraceFlags : uint64_t {
80
+ kNoFlags = 0,
81
+ kReduceMemory = 1 << 0,
82
+ kForced = 1 << 2,
83
+ };
84
+
85
+ /**
86
+ * Interface for iterating through TracedGlobal handles.
87
+ */
88
+ class V8_EXPORT TracedGlobalHandleVisitor {
89
+ public:
90
+ virtual ~TracedGlobalHandleVisitor() = default;
91
+ virtual void VisitTracedGlobalHandle(const TracedGlobal<Value>& handle) {}
92
+ virtual void VisitTracedReference(const TracedReference<Value>& handle) {}
93
+ };
94
+
95
+ /**
96
+ * Summary of a garbage collection cycle. See |TraceEpilogue| on how the
97
+ * summary is reported.
98
+ */
99
+ struct TraceSummary {
100
+ /**
101
+ * Time spent managing the retained memory in milliseconds. This can e.g.
102
+ * include the time tracing through objects in the embedder.
103
+ */
104
+ double time = 0.0;
105
+
106
+ /**
107
+ * Memory retained by the embedder through the |EmbedderHeapTracer|
108
+ * mechanism in bytes.
109
+ */
110
+ size_t allocated_size = 0;
111
+ };
112
+
113
+ virtual ~EmbedderHeapTracer() = default;
114
+
115
+ /**
116
+ * Iterates all TracedGlobal handles created for the v8::Isolate the tracer is
117
+ * attached to.
118
+ */
119
+ void IterateTracedGlobalHandles(TracedGlobalHandleVisitor* visitor);
120
+
121
+ /**
122
+ * Called by the embedder to set the start of the stack which is e.g. used by
123
+ * V8 to determine whether handles are used from stack or heap.
124
+ */
125
+ void SetStackStart(void* stack_start);
126
+
127
+ /**
128
+ * Called by the embedder to notify V8 of an empty execution stack.
129
+ */
130
+ V8_DEPRECATE_SOON(
131
+ "This call only optimized internal caches which V8 is able to figure out "
132
+ "on its own now.")
133
+ void NotifyEmptyEmbedderStack();
134
+
135
+ /**
136
+ * Called by v8 to register internal fields of found wrappers.
137
+ *
138
+ * The embedder is expected to store them somewhere and trace reachable
139
+ * wrappers from them when called through |AdvanceTracing|.
140
+ */
141
+ virtual void RegisterV8References(
142
+ const std::vector<std::pair<void*, void*>>& embedder_fields) = 0;
143
+
144
+ void RegisterEmbedderReference(const BasicTracedReference<v8::Data>& ref);
145
+
146
+ /**
147
+ * Called at the beginning of a GC cycle.
148
+ */
149
+ virtual void TracePrologue(TraceFlags flags) {}
150
+
151
+ /**
152
+ * Called to advance tracing in the embedder.
153
+ *
154
+ * The embedder is expected to trace its heap starting from wrappers reported
155
+ * by RegisterV8References method, and report back all reachable wrappers.
156
+ * Furthermore, the embedder is expected to stop tracing by the given
157
+ * deadline. A deadline of infinity means that tracing should be finished.
158
+ *
159
+ * Returns |true| if tracing is done, and false otherwise.
160
+ */
161
+ virtual bool AdvanceTracing(double deadline_in_ms) = 0;
162
+
163
+ /*
164
+ * Returns true if there no more tracing work to be done (see AdvanceTracing)
165
+ * and false otherwise.
166
+ */
167
+ virtual bool IsTracingDone() = 0;
168
+
169
+ /**
170
+ * Called at the end of a GC cycle.
171
+ *
172
+ * Note that allocation is *not* allowed within |TraceEpilogue|. Can be
173
+ * overriden to fill a |TraceSummary| that is used by V8 to schedule future
174
+ * garbage collections.
175
+ */
176
+ virtual void TraceEpilogue(TraceSummary* trace_summary) {}
177
+
178
+ /**
179
+ * Called upon entering the final marking pause. No more incremental marking
180
+ * steps will follow this call.
181
+ */
182
+ virtual void EnterFinalPause(EmbedderStackState stack_state) = 0;
183
+
184
+ /*
185
+ * Called by the embedder to request immediate finalization of the currently
186
+ * running tracing phase that has been started with TracePrologue and not
187
+ * yet finished with TraceEpilogue.
188
+ *
189
+ * Will be a noop when currently not in tracing.
190
+ *
191
+ * This is an experimental feature.
192
+ */
193
+ void FinalizeTracing();
194
+
195
+ /**
196
+ * See documentation on EmbedderRootsHandler.
197
+ */
198
+ virtual bool IsRootForNonTracingGC(
199
+ const v8::TracedReference<v8::Value>& handle);
200
+ virtual bool IsRootForNonTracingGC(const v8::TracedGlobal<v8::Value>& handle);
201
+
202
+ /**
203
+ * See documentation on EmbedderRootsHandler.
204
+ */
205
+ virtual void ResetHandleInNonTracingGC(
206
+ const v8::TracedReference<v8::Value>& handle);
207
+
208
+ /*
209
+ * Called by the embedder to immediately perform a full garbage collection.
210
+ *
211
+ * Should only be used in testing code.
212
+ */
213
+ void GarbageCollectionForTesting(EmbedderStackState stack_state);
214
+
215
+ /*
216
+ * Called by the embedder to signal newly allocated or freed memory. Not bound
217
+ * to tracing phases. Embedders should trade off when increments are reported
218
+ * as V8 may consult global heuristics on whether to trigger garbage
219
+ * collection on this change.
220
+ */
221
+ void IncreaseAllocatedSize(size_t bytes);
222
+ void DecreaseAllocatedSize(size_t bytes);
223
+
224
+ /*
225
+ * Returns the v8::Isolate this tracer is attached too and |nullptr| if it
226
+ * is not attached to any v8::Isolate.
227
+ */
228
+ v8::Isolate* isolate() const { return isolate_; }
229
+
230
+ protected:
231
+ v8::Isolate* isolate_ = nullptr;
232
+
233
+ friend class internal::LocalEmbedderHeapTracer;
234
+ };
235
+
236
+ } // namespace v8
237
+
238
+ #endif // INCLUDE_V8_EMBEDDER_HEAP_H_
@@ -0,0 +1,224 @@
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_EXCEPTION_H_
6
+ #define INCLUDE_V8_EXCEPTION_H_
7
+
8
+ #include <stddef.h>
9
+
10
+ #include "v8-local-handle.h" // NOLINT(build/include_directory)
11
+ #include "v8config.h" // NOLINT(build/include_directory)
12
+
13
+ namespace v8 {
14
+
15
+ class Context;
16
+ class Isolate;
17
+ class Message;
18
+ class StackTrace;
19
+ class String;
20
+ class Value;
21
+
22
+ namespace internal {
23
+ class Isolate;
24
+ class ThreadLocalTop;
25
+ } // namespace internal
26
+
27
+ /**
28
+ * Create new error objects by calling the corresponding error object
29
+ * constructor with the message.
30
+ */
31
+ class V8_EXPORT Exception {
32
+ public:
33
+ static Local<Value> RangeError(Local<String> message);
34
+ static Local<Value> ReferenceError(Local<String> message);
35
+ static Local<Value> SyntaxError(Local<String> message);
36
+ static Local<Value> TypeError(Local<String> message);
37
+ static Local<Value> WasmCompileError(Local<String> message);
38
+ static Local<Value> WasmLinkError(Local<String> message);
39
+ static Local<Value> WasmRuntimeError(Local<String> message);
40
+ static Local<Value> Error(Local<String> message);
41
+
42
+ /**
43
+ * Creates an error message for the given exception.
44
+ * Will try to reconstruct the original stack trace from the exception value,
45
+ * or capture the current stack trace if not available.
46
+ */
47
+ static Local<Message> CreateMessage(Isolate* isolate, Local<Value> exception);
48
+
49
+ /**
50
+ * Returns the original stack trace that was captured at the creation time
51
+ * of a given exception, or an empty handle if not available.
52
+ */
53
+ static Local<StackTrace> GetStackTrace(Local<Value> exception);
54
+ };
55
+
56
+ /**
57
+ * An external exception handler.
58
+ */
59
+ class V8_EXPORT TryCatch {
60
+ public:
61
+ /**
62
+ * Creates a new try/catch block and registers it with v8. Note that
63
+ * all TryCatch blocks should be stack allocated because the memory
64
+ * location itself is compared against JavaScript try/catch blocks.
65
+ */
66
+ explicit TryCatch(Isolate* isolate);
67
+
68
+ /**
69
+ * Unregisters and deletes this try/catch block.
70
+ */
71
+ ~TryCatch();
72
+
73
+ /**
74
+ * Returns true if an exception has been caught by this try/catch block.
75
+ */
76
+ bool HasCaught() const;
77
+
78
+ /**
79
+ * For certain types of exceptions, it makes no sense to continue execution.
80
+ *
81
+ * If CanContinue returns false, the correct action is to perform any C++
82
+ * cleanup needed and then return. If CanContinue returns false and
83
+ * HasTerminated returns true, it is possible to call
84
+ * CancelTerminateExecution in order to continue calling into the engine.
85
+ */
86
+ bool CanContinue() const;
87
+
88
+ /**
89
+ * Returns true if an exception has been caught due to script execution
90
+ * being terminated.
91
+ *
92
+ * There is no JavaScript representation of an execution termination
93
+ * exception. Such exceptions are thrown when the TerminateExecution
94
+ * methods are called to terminate a long-running script.
95
+ *
96
+ * If such an exception has been thrown, HasTerminated will return true,
97
+ * indicating that it is possible to call CancelTerminateExecution in order
98
+ * to continue calling into the engine.
99
+ */
100
+ bool HasTerminated() const;
101
+
102
+ /**
103
+ * Throws the exception caught by this TryCatch in a way that avoids
104
+ * it being caught again by this same TryCatch. As with ThrowException
105
+ * it is illegal to execute any JavaScript operations after calling
106
+ * ReThrow; the caller must return immediately to where the exception
107
+ * is caught.
108
+ */
109
+ Local<Value> ReThrow();
110
+
111
+ /**
112
+ * Returns the exception caught by this try/catch block. If no exception has
113
+ * been caught an empty handle is returned.
114
+ */
115
+ Local<Value> Exception() const;
116
+
117
+ /**
118
+ * Returns the .stack property of an object. If no .stack
119
+ * property is present an empty handle is returned.
120
+ */
121
+ V8_WARN_UNUSED_RESULT static MaybeLocal<Value> StackTrace(
122
+ Local<Context> context, Local<Value> exception);
123
+
124
+ /**
125
+ * Returns the .stack property of the thrown object. If no .stack property is
126
+ * present or if this try/catch block has not caught an exception, an empty
127
+ * handle is returned.
128
+ */
129
+ V8_WARN_UNUSED_RESULT MaybeLocal<Value> StackTrace(
130
+ Local<Context> context) const;
131
+
132
+ /**
133
+ * Returns the message associated with this exception. If there is
134
+ * no message associated an empty handle is returned.
135
+ */
136
+ Local<v8::Message> Message() const;
137
+
138
+ /**
139
+ * Clears any exceptions that may have been caught by this try/catch block.
140
+ * After this method has been called, HasCaught() will return false. Cancels
141
+ * the scheduled exception if it is caught and ReThrow() is not called before.
142
+ *
143
+ * It is not necessary to clear a try/catch block before using it again; if
144
+ * another exception is thrown the previously caught exception will just be
145
+ * overwritten. However, it is often a good idea since it makes it easier
146
+ * to determine which operation threw a given exception.
147
+ */
148
+ void Reset();
149
+
150
+ /**
151
+ * Set verbosity of the external exception handler.
152
+ *
153
+ * By default, exceptions that are caught by an external exception
154
+ * handler are not reported. Call SetVerbose with true on an
155
+ * external exception handler to have exceptions caught by the
156
+ * handler reported as if they were not caught.
157
+ */
158
+ void SetVerbose(bool value);
159
+
160
+ /**
161
+ * Returns true if verbosity is enabled.
162
+ */
163
+ bool IsVerbose() const;
164
+
165
+ /**
166
+ * Set whether or not this TryCatch should capture a Message object
167
+ * which holds source information about where the exception
168
+ * occurred. True by default.
169
+ */
170
+ void SetCaptureMessage(bool value);
171
+
172
+ V8_DEPRECATE_SOON(
173
+ "This is private information that should not be exposed by the API")
174
+ static void* JSStackComparableAddress(TryCatch* handler) {
175
+ if (handler == nullptr) return nullptr;
176
+ return reinterpret_cast<void*>(handler->JSStackComparableAddressPrivate());
177
+ }
178
+
179
+ TryCatch(const TryCatch&) = delete;
180
+ void operator=(const TryCatch&) = delete;
181
+
182
+ private:
183
+ // Declaring operator new and delete as deleted is not spec compliant.
184
+ // Therefore declare them private instead to disable dynamic alloc
185
+ void* operator new(size_t size);
186
+ void* operator new[](size_t size);
187
+ void operator delete(void*, size_t);
188
+ void operator delete[](void*, size_t);
189
+
190
+ /**
191
+ * There are cases when the raw address of C++ TryCatch object cannot be
192
+ * used for comparisons with addresses into the JS stack. The cases are:
193
+ * 1) ARM, ARM64 and MIPS simulators which have separate JS stack.
194
+ * 2) Address sanitizer allocates local C++ object in the heap when
195
+ * UseAfterReturn mode is enabled.
196
+ * This method returns address that can be used for comparisons with
197
+ * addresses into the JS stack. When neither simulator nor ASAN's
198
+ * UseAfterReturn is enabled, then the address returned will be the address
199
+ * of the C++ try catch handler itself.
200
+ */
201
+ internal::Address JSStackComparableAddressPrivate() {
202
+ return js_stack_comparable_address_;
203
+ }
204
+
205
+ void ResetInternal();
206
+
207
+ internal::Isolate* isolate_;
208
+ TryCatch* next_;
209
+ void* exception_;
210
+ void* message_obj_;
211
+ internal::Address js_stack_comparable_address_;
212
+ bool is_verbose_ : 1;
213
+ bool can_continue_ : 1;
214
+ bool capture_message_ : 1;
215
+ bool rethrow_ : 1;
216
+ bool has_terminated_ : 1;
217
+
218
+ friend class internal::Isolate;
219
+ friend class internal::ThreadLocalTop;
220
+ };
221
+
222
+ } // namespace v8
223
+
224
+ #endif // INCLUDE_V8_EXCEPTION_H_
@@ -0,0 +1,62 @@
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_EXTENSION_H_
6
+ #define INCLUDE_V8_EXTENSION_H_
7
+
8
+ #include <memory>
9
+
10
+ #include "v8-local-handle.h" // NOLINT(build/include_directory)
11
+ #include "v8-primitive.h" // NOLINT(build/include_directory)
12
+ #include "v8config.h" // NOLINT(build/include_directory)
13
+
14
+ namespace v8 {
15
+
16
+ class FunctionTemplate;
17
+
18
+ // --- Extensions ---
19
+
20
+ /**
21
+ * Ignore
22
+ */
23
+ class V8_EXPORT Extension {
24
+ public:
25
+ // Note that the strings passed into this constructor must live as long
26
+ // as the Extension itself.
27
+ Extension(const char* name, const char* source = nullptr, int dep_count = 0,
28
+ const char** deps = nullptr, int source_length = -1);
29
+ virtual ~Extension() { delete source_; }
30
+ virtual Local<FunctionTemplate> GetNativeFunctionTemplate(
31
+ Isolate* isolate, Local<String> name) {
32
+ return Local<FunctionTemplate>();
33
+ }
34
+
35
+ const char* name() const { return name_; }
36
+ size_t source_length() const { return source_length_; }
37
+ const String::ExternalOneByteStringResource* source() const {
38
+ return source_;
39
+ }
40
+ int dependency_count() const { return dep_count_; }
41
+ const char** dependencies() const { return deps_; }
42
+ void set_auto_enable(bool value) { auto_enable_ = value; }
43
+ bool auto_enable() { return auto_enable_; }
44
+
45
+ // Disallow copying and assigning.
46
+ Extension(const Extension&) = delete;
47
+ void operator=(const Extension&) = delete;
48
+
49
+ private:
50
+ const char* name_;
51
+ size_t source_length_; // expected to initialize before source_
52
+ String::ExternalOneByteStringResource* source_;
53
+ int dep_count_;
54
+ const char** deps_;
55
+ bool auto_enable_;
56
+ };
57
+
58
+ void V8_EXPORT RegisterExtension(std::unique_ptr<Extension>);
59
+
60
+ } // namespace v8
61
+
62
+ #endif // INCLUDE_V8_EXTENSION_H_