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
@@ -0,0 +1,218 @@
|
|
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 |TracedReference| handle should be considered as root
|
38
|
+
* for the currently running non-tracing garbage collection and false
|
39
|
+
* otherwise. The default implementation will keep all |TracedReference|
|
40
|
+
* references as roots.
|
41
|
+
*
|
42
|
+
* If this returns false, then V8 may decide that the object referred to by
|
43
|
+
* such a handle is reclaimed. In that case, V8 calls |ResetRoot()| for the
|
44
|
+
* |TracedReference|.
|
45
|
+
*
|
46
|
+
* Note that the `handle` is different from the handle that the embedder holds
|
47
|
+
* for retaining the object. The embedder may use |WrapperClassId()| to
|
48
|
+
* distinguish cases where it wants handles to be treated as roots from not
|
49
|
+
* being treated as roots.
|
50
|
+
*/
|
51
|
+
virtual bool IsRoot(const v8::TracedReference<v8::Value>& handle) = 0;
|
52
|
+
|
53
|
+
/**
|
54
|
+
* Used in combination with |IsRoot|. Called by V8 when an
|
55
|
+
* object that is backed by a handle is reclaimed by a non-tracing garbage
|
56
|
+
* collection. It is up to the embedder to reset the original handle.
|
57
|
+
*
|
58
|
+
* Note that the |handle| is different from the handle that the embedder holds
|
59
|
+
* for retaining the object. It is up to the embedder to find the original
|
60
|
+
* handle via the object or class id.
|
61
|
+
*/
|
62
|
+
virtual void ResetRoot(const v8::TracedReference<v8::Value>& handle) = 0;
|
63
|
+
};
|
64
|
+
|
65
|
+
/**
|
66
|
+
* Interface for tracing through the embedder heap. During a V8 garbage
|
67
|
+
* collection, V8 collects hidden fields of all potential wrappers, and at the
|
68
|
+
* end of its marking phase iterates the collection and asks the embedder to
|
69
|
+
* trace through its heap and use reporter to report each JavaScript object
|
70
|
+
* reachable from any of the given wrappers.
|
71
|
+
*/
|
72
|
+
class V8_EXPORT EmbedderHeapTracer {
|
73
|
+
public:
|
74
|
+
using EmbedderStackState = cppgc::EmbedderStackState;
|
75
|
+
|
76
|
+
enum TraceFlags : uint64_t {
|
77
|
+
kNoFlags = 0,
|
78
|
+
kReduceMemory = 1 << 0,
|
79
|
+
kForced = 1 << 2,
|
80
|
+
};
|
81
|
+
|
82
|
+
/**
|
83
|
+
* Interface for iterating through |TracedReference| handles.
|
84
|
+
*/
|
85
|
+
class V8_EXPORT TracedGlobalHandleVisitor {
|
86
|
+
public:
|
87
|
+
virtual ~TracedGlobalHandleVisitor() = default;
|
88
|
+
virtual void VisitTracedReference(const TracedReference<Value>& handle) {}
|
89
|
+
};
|
90
|
+
|
91
|
+
/**
|
92
|
+
* Summary of a garbage collection cycle. See |TraceEpilogue| on how the
|
93
|
+
* summary is reported.
|
94
|
+
*/
|
95
|
+
struct TraceSummary {
|
96
|
+
/**
|
97
|
+
* Time spent managing the retained memory in milliseconds. This can e.g.
|
98
|
+
* include the time tracing through objects in the embedder.
|
99
|
+
*/
|
100
|
+
double time = 0.0;
|
101
|
+
|
102
|
+
/**
|
103
|
+
* Memory retained by the embedder through the |EmbedderHeapTracer|
|
104
|
+
* mechanism in bytes.
|
105
|
+
*/
|
106
|
+
size_t allocated_size = 0;
|
107
|
+
};
|
108
|
+
|
109
|
+
virtual ~EmbedderHeapTracer() = default;
|
110
|
+
|
111
|
+
/**
|
112
|
+
* Iterates all |TracedReference| handles created for the |v8::Isolate| the
|
113
|
+
* tracer is attached to.
|
114
|
+
*/
|
115
|
+
void IterateTracedGlobalHandles(TracedGlobalHandleVisitor* visitor);
|
116
|
+
|
117
|
+
/**
|
118
|
+
* Called by the embedder to set the start of the stack which is e.g. used by
|
119
|
+
* V8 to determine whether handles are used from stack or heap.
|
120
|
+
*/
|
121
|
+
void SetStackStart(void* stack_start);
|
122
|
+
|
123
|
+
/**
|
124
|
+
* Called by v8 to register internal fields of found wrappers.
|
125
|
+
*
|
126
|
+
* The embedder is expected to store them somewhere and trace reachable
|
127
|
+
* wrappers from them when called through |AdvanceTracing|.
|
128
|
+
*/
|
129
|
+
virtual void RegisterV8References(
|
130
|
+
const std::vector<std::pair<void*, void*>>& embedder_fields) = 0;
|
131
|
+
|
132
|
+
void RegisterEmbedderReference(const BasicTracedReference<v8::Data>& ref);
|
133
|
+
|
134
|
+
/**
|
135
|
+
* Called at the beginning of a GC cycle.
|
136
|
+
*/
|
137
|
+
virtual void TracePrologue(TraceFlags flags) {}
|
138
|
+
|
139
|
+
/**
|
140
|
+
* Called to advance tracing in the embedder.
|
141
|
+
*
|
142
|
+
* The embedder is expected to trace its heap starting from wrappers reported
|
143
|
+
* by RegisterV8References method, and report back all reachable wrappers.
|
144
|
+
* Furthermore, the embedder is expected to stop tracing by the given
|
145
|
+
* deadline. A deadline of infinity means that tracing should be finished.
|
146
|
+
*
|
147
|
+
* Returns |true| if tracing is done, and false otherwise.
|
148
|
+
*/
|
149
|
+
virtual bool AdvanceTracing(double deadline_in_ms) = 0;
|
150
|
+
|
151
|
+
/*
|
152
|
+
* Returns true if there no more tracing work to be done (see AdvanceTracing)
|
153
|
+
* and false otherwise.
|
154
|
+
*/
|
155
|
+
virtual bool IsTracingDone() = 0;
|
156
|
+
|
157
|
+
/**
|
158
|
+
* Called at the end of a GC cycle.
|
159
|
+
*
|
160
|
+
* Note that allocation is *not* allowed within |TraceEpilogue|. Can be
|
161
|
+
* overriden to fill a |TraceSummary| that is used by V8 to schedule future
|
162
|
+
* garbage collections.
|
163
|
+
*/
|
164
|
+
virtual void TraceEpilogue(TraceSummary* trace_summary) {}
|
165
|
+
|
166
|
+
/**
|
167
|
+
* Called upon entering the final marking pause. No more incremental marking
|
168
|
+
* steps will follow this call.
|
169
|
+
*/
|
170
|
+
virtual void EnterFinalPause(EmbedderStackState stack_state) = 0;
|
171
|
+
|
172
|
+
/*
|
173
|
+
* Called by the embedder to request immediate finalization of the currently
|
174
|
+
* running tracing phase that has been started with TracePrologue and not
|
175
|
+
* yet finished with TraceEpilogue.
|
176
|
+
*
|
177
|
+
* Will be a noop when currently not in tracing.
|
178
|
+
*
|
179
|
+
* This is an experimental feature.
|
180
|
+
*/
|
181
|
+
void FinalizeTracing();
|
182
|
+
|
183
|
+
/**
|
184
|
+
* See documentation on EmbedderRootsHandler.
|
185
|
+
*/
|
186
|
+
virtual bool IsRootForNonTracingGC(
|
187
|
+
const v8::TracedReference<v8::Value>& handle);
|
188
|
+
|
189
|
+
/**
|
190
|
+
* See documentation on EmbedderRootsHandler.
|
191
|
+
*/
|
192
|
+
virtual void ResetHandleInNonTracingGC(
|
193
|
+
const v8::TracedReference<v8::Value>& handle);
|
194
|
+
|
195
|
+
/*
|
196
|
+
* Called by the embedder to signal newly allocated or freed memory. Not bound
|
197
|
+
* to tracing phases. Embedders should trade off when increments are reported
|
198
|
+
* as V8 may consult global heuristics on whether to trigger garbage
|
199
|
+
* collection on this change.
|
200
|
+
*/
|
201
|
+
void IncreaseAllocatedSize(size_t bytes);
|
202
|
+
void DecreaseAllocatedSize(size_t bytes);
|
203
|
+
|
204
|
+
/*
|
205
|
+
* Returns the v8::Isolate this tracer is attached too and |nullptr| if it
|
206
|
+
* is not attached to any v8::Isolate.
|
207
|
+
*/
|
208
|
+
v8::Isolate* isolate() const { return isolate_; }
|
209
|
+
|
210
|
+
protected:
|
211
|
+
v8::Isolate* isolate_ = nullptr;
|
212
|
+
|
213
|
+
friend class internal::LocalEmbedderHeapTracer;
|
214
|
+
};
|
215
|
+
|
216
|
+
} // namespace v8
|
217
|
+
|
218
|
+
#endif // INCLUDE_V8_EMBEDDER_HEAP_H_
|
@@ -0,0 +1,51 @@
|
|
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_STATE_SCOPE_H_
|
6
|
+
#define INCLUDE_V8_EMBEDDER_STATE_SCOPE_H_
|
7
|
+
|
8
|
+
#include <memory>
|
9
|
+
|
10
|
+
#include "v8-context.h" // NOLINT(build/include_directory)
|
11
|
+
#include "v8-internal.h" // NOLINT(build/include_directory)
|
12
|
+
#include "v8-local-handle.h" // NOLINT(build/include_directory)
|
13
|
+
|
14
|
+
namespace v8 {
|
15
|
+
|
16
|
+
namespace internal {
|
17
|
+
class EmbedderState;
|
18
|
+
} // namespace internal
|
19
|
+
|
20
|
+
// A StateTag represents a possible state of the embedder.
|
21
|
+
enum class EmbedderStateTag : uint8_t {
|
22
|
+
// reserved
|
23
|
+
EMPTY = 0,
|
24
|
+
OTHER = 1,
|
25
|
+
// embedder can define any state after
|
26
|
+
};
|
27
|
+
|
28
|
+
// A stack-allocated class that manages an embedder state on the isolate.
|
29
|
+
// After an EmbedderState scope has been created, a new embedder state will be
|
30
|
+
// pushed on the isolate stack.
|
31
|
+
class V8_EXPORT EmbedderStateScope {
|
32
|
+
public:
|
33
|
+
EmbedderStateScope(Isolate* isolate, Local<v8::Context> context,
|
34
|
+
EmbedderStateTag tag);
|
35
|
+
|
36
|
+
~EmbedderStateScope();
|
37
|
+
|
38
|
+
private:
|
39
|
+
// Declaring operator new and delete as deleted is not spec compliant.
|
40
|
+
// Therefore declare them private instead to disable dynamic alloc
|
41
|
+
void* operator new(size_t size);
|
42
|
+
void* operator new[](size_t size);
|
43
|
+
void operator delete(void*, size_t);
|
44
|
+
void operator delete[](void*, size_t);
|
45
|
+
|
46
|
+
std::unique_ptr<internal::EmbedderState> embedder_state_;
|
47
|
+
};
|
48
|
+
|
49
|
+
} // namespace v8
|
50
|
+
|
51
|
+
#endif // INCLUDE_V8_EMBEDDER_STATE_SCOPE_H_
|
@@ -0,0 +1,217 @@
|
|
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
|
+
TryCatch(const TryCatch&) = delete;
|
173
|
+
void operator=(const TryCatch&) = delete;
|
174
|
+
|
175
|
+
private:
|
176
|
+
// Declaring operator new and delete as deleted is not spec compliant.
|
177
|
+
// Therefore declare them private instead to disable dynamic alloc
|
178
|
+
void* operator new(size_t size);
|
179
|
+
void* operator new[](size_t size);
|
180
|
+
void operator delete(void*, size_t);
|
181
|
+
void operator delete[](void*, size_t);
|
182
|
+
|
183
|
+
/**
|
184
|
+
* There are cases when the raw address of C++ TryCatch object cannot be
|
185
|
+
* used for comparisons with addresses into the JS stack. The cases are:
|
186
|
+
* 1) ARM, ARM64 and MIPS simulators which have separate JS stack.
|
187
|
+
* 2) Address sanitizer allocates local C++ object in the heap when
|
188
|
+
* UseAfterReturn mode is enabled.
|
189
|
+
* This method returns address that can be used for comparisons with
|
190
|
+
* addresses into the JS stack. When neither simulator nor ASAN's
|
191
|
+
* UseAfterReturn is enabled, then the address returned will be the address
|
192
|
+
* of the C++ try catch handler itself.
|
193
|
+
*/
|
194
|
+
internal::Address JSStackComparableAddressPrivate() {
|
195
|
+
return js_stack_comparable_address_;
|
196
|
+
}
|
197
|
+
|
198
|
+
void ResetInternal();
|
199
|
+
|
200
|
+
internal::Isolate* isolate_;
|
201
|
+
TryCatch* next_;
|
202
|
+
void* exception_;
|
203
|
+
void* message_obj_;
|
204
|
+
internal::Address js_stack_comparable_address_;
|
205
|
+
bool is_verbose_ : 1;
|
206
|
+
bool can_continue_ : 1;
|
207
|
+
bool capture_message_ : 1;
|
208
|
+
bool rethrow_ : 1;
|
209
|
+
bool has_terminated_ : 1;
|
210
|
+
|
211
|
+
friend class internal::Isolate;
|
212
|
+
friend class internal::ThreadLocalTop;
|
213
|
+
};
|
214
|
+
|
215
|
+
} // namespace v8
|
216
|
+
|
217
|
+
#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_
|
@@ -0,0 +1,37 @@
|
|
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_EXTERNAL_H_
|
6
|
+
#define INCLUDE_V8_EXTERNAL_H_
|
7
|
+
|
8
|
+
#include "v8-value.h" // NOLINT(build/include_directory)
|
9
|
+
#include "v8config.h" // NOLINT(build/include_directory)
|
10
|
+
|
11
|
+
namespace v8 {
|
12
|
+
|
13
|
+
class Isolate;
|
14
|
+
|
15
|
+
/**
|
16
|
+
* A JavaScript value that wraps a C++ void*. This type of value is mainly used
|
17
|
+
* to associate C++ data structures with JavaScript objects.
|
18
|
+
*/
|
19
|
+
class V8_EXPORT External : public Value {
|
20
|
+
public:
|
21
|
+
static Local<External> New(Isolate* isolate, void* value);
|
22
|
+
V8_INLINE static External* Cast(Value* value) {
|
23
|
+
#ifdef V8_ENABLE_CHECKS
|
24
|
+
CheckCast(value);
|
25
|
+
#endif
|
26
|
+
return static_cast<External*>(value);
|
27
|
+
}
|
28
|
+
|
29
|
+
void* Value() const;
|
30
|
+
|
31
|
+
private:
|
32
|
+
static void CheckCast(v8::Value* obj);
|
33
|
+
};
|
34
|
+
|
35
|
+
} // namespace v8
|
36
|
+
|
37
|
+
#endif // INCLUDE_V8_EXTERNAL_H_
|