@downdraft/native-mobile-android-arm64 0.0.0 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/include/node/cppgc/allocation.h +308 -0
- package/include/node/cppgc/common.h +28 -0
- package/include/node/cppgc/cross-thread-persistent.h +462 -0
- package/include/node/cppgc/custom-space.h +97 -0
- package/include/node/cppgc/default-platform.h +68 -0
- package/include/node/cppgc/explicit-management.h +100 -0
- package/include/node/cppgc/garbage-collected.h +114 -0
- package/include/node/cppgc/heap-consistency.h +309 -0
- package/include/node/cppgc/heap-handle.h +48 -0
- package/include/node/cppgc/heap-state.h +82 -0
- package/include/node/cppgc/heap-statistics.h +126 -0
- package/include/node/cppgc/heap.h +202 -0
- package/include/node/cppgc/internal/api-constants.h +75 -0
- package/include/node/cppgc/internal/atomic-entry-flag.h +48 -0
- package/include/node/cppgc/internal/base-page-handle.h +43 -0
- package/include/node/cppgc/internal/caged-heap-local-data.h +117 -0
- package/include/node/cppgc/internal/caged-heap.h +64 -0
- package/include/node/cppgc/internal/compiler-specific.h +46 -0
- package/include/node/cppgc/internal/conditional-stack-allocated.h +41 -0
- package/include/node/cppgc/internal/finalizer-trait.h +93 -0
- package/include/node/cppgc/internal/gc-info.h +150 -0
- package/include/node/cppgc/internal/logging.h +50 -0
- package/include/node/cppgc/internal/member-storage.h +305 -0
- package/include/node/cppgc/internal/name-trait.h +141 -0
- package/include/node/cppgc/internal/persistent-node.h +219 -0
- package/include/node/cppgc/internal/pointer-policies.h +280 -0
- package/include/node/cppgc/internal/write-barrier.h +487 -0
- package/include/node/cppgc/liveness-broker.h +78 -0
- package/include/node/cppgc/macros.h +56 -0
- package/include/node/cppgc/member.h +669 -0
- package/include/node/cppgc/name-provider.h +75 -0
- package/include/node/cppgc/object-size-trait.h +58 -0
- package/include/node/cppgc/persistent.h +376 -0
- package/include/node/cppgc/platform.h +174 -0
- package/include/node/cppgc/prefinalizer.h +75 -0
- package/include/node/cppgc/process-heap-statistics.h +36 -0
- package/include/node/cppgc/sentinel-pointer.h +39 -0
- package/include/node/cppgc/source-location.h +16 -0
- package/include/node/cppgc/tagged-member.h +114 -0
- package/include/node/cppgc/testing.h +106 -0
- package/include/node/cppgc/trace-trait.h +127 -0
- package/include/node/cppgc/type-traits.h +272 -0
- package/include/node/cppgc/visitor.h +534 -0
- package/include/node/js_native_api.h +634 -0
- package/include/node/js_native_api_types.h +244 -0
- package/include/node/libplatform/libplatform-export.h +29 -0
- package/include/node/libplatform/libplatform.h +112 -0
- package/include/node/libplatform/v8-tracing.h +343 -0
- package/include/node/node.h +1744 -0
- package/include/node/node_api.h +265 -0
- package/include/node/node_api_types.h +58 -0
- package/include/node/node_buffer.h +94 -0
- package/include/node/node_object_wrap.h +145 -0
- package/include/node/node_version.h +116 -0
- package/include/node/uv/aix.h +32 -0
- package/include/node/uv/bsd.h +34 -0
- package/include/node/uv/darwin.h +61 -0
- package/include/node/uv/errno.h +483 -0
- package/include/node/uv/linux.h +34 -0
- package/include/node/uv/os390.h +33 -0
- package/include/node/uv/posix.h +31 -0
- package/include/node/uv/sunos.h +44 -0
- package/include/node/uv/threadpool.h +37 -0
- package/include/node/uv/tree.h +521 -0
- package/include/node/uv/unix.h +509 -0
- package/include/node/uv/version.h +43 -0
- package/include/node/uv/win.h +698 -0
- package/include/node/uv.h +1994 -0
- package/include/node/v8-array-buffer.h +646 -0
- package/include/node/v8-callbacks.h +533 -0
- package/include/node/v8-container.h +183 -0
- package/include/node/v8-context.h +580 -0
- package/include/node/v8-cpp-heap-external.h +56 -0
- package/include/node/v8-cppgc.h +194 -0
- package/include/node/v8-data.h +96 -0
- package/include/node/v8-date.h +57 -0
- package/include/node/v8-debug.h +210 -0
- package/include/node/v8-embedder-heap.h +54 -0
- package/include/node/v8-embedder-state-scope.h +52 -0
- package/include/node/v8-exception.h +298 -0
- package/include/node/v8-extension.h +60 -0
- package/include/node/v8-external-memory-accounter.h +60 -0
- package/include/node/v8-external.h +73 -0
- package/include/node/v8-fast-api-calls.h +784 -0
- package/include/node/v8-forward.h +82 -0
- package/include/node/v8-function-callback.h +708 -0
- package/include/node/v8-function.h +148 -0
- package/include/node/v8-handle-base.h +155 -0
- package/include/node/v8-initialization.h +343 -0
- package/include/node/v8-inspector-protocol.h +13 -0
- package/include/node/v8-inspector.h +458 -0
- package/include/node/v8-internal.h +1827 -0
- package/include/node/v8-isolate.h +1925 -0
- package/include/node/v8-json.h +54 -0
- package/include/node/v8-local-handle.h +884 -0
- package/include/node/v8-locker.h +138 -0
- package/include/node/v8-maybe.h +185 -0
- package/include/node/v8-memory-span.h +273 -0
- package/include/node/v8-message.h +215 -0
- package/include/node/v8-metrics.h +273 -0
- package/include/node/v8-microtask-queue.h +152 -0
- package/include/node/v8-microtask.h +28 -0
- package/include/node/v8-object.h +1134 -0
- package/include/node/v8-persistent-handle.h +556 -0
- package/include/node/v8-platform.h +1552 -0
- package/include/node/v8-primitive-object.h +118 -0
- package/include/node/v8-primitive.h +1056 -0
- package/include/node/v8-profiler.h +1401 -0
- package/include/node/v8-promise.h +185 -0
- package/include/node/v8-proxy.h +49 -0
- package/include/node/v8-regexp.h +105 -0
- package/include/node/v8-sandbox.h +170 -0
- package/include/node/v8-script.h +996 -0
- package/include/node/v8-snapshot.h +302 -0
- package/include/node/v8-source-location.h +91 -0
- package/include/node/v8-statistics.h +246 -0
- package/include/node/v8-template.h +1096 -0
- package/include/node/v8-trace-categories.h +28 -0
- package/include/node/v8-traced-handle.h +420 -0
- package/include/node/v8-typed-array.h +386 -0
- package/include/node/v8-unwinder-state.h +30 -0
- package/include/node/v8-unwinder.h +146 -0
- package/include/node/v8-util.h +549 -0
- package/include/node/v8-value-serializer-version.h +24 -0
- package/include/node/v8-value-serializer.h +316 -0
- package/include/node/v8-value.h +674 -0
- package/include/node/v8-version-string.h +38 -0
- package/include/node/v8-version.h +20 -0
- package/include/node/v8-wasm-trap-handler-posix.h +31 -0
- package/include/node/v8-wasm-trap-handler-win.h +28 -0
- package/include/node/v8-wasm.h +325 -0
- package/include/node/v8-weak-callback-info.h +88 -0
- package/include/node/v8.h +88 -0
- package/include/node/v8config.h +1077 -0
- package/lib/libc++_shared.so +0 -0
- package/lib/libnode.so +4 -0
- package/package.json +23 -3
|
@@ -0,0 +1,298 @@
|
|
|
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 "v8-object.h" // NOLINT(build/include_directory)
|
|
12
|
+
#include "v8config.h" // NOLINT(build/include_directory)
|
|
13
|
+
|
|
14
|
+
namespace v8 {
|
|
15
|
+
|
|
16
|
+
class Context;
|
|
17
|
+
class Isolate;
|
|
18
|
+
class Message;
|
|
19
|
+
class StackTrace;
|
|
20
|
+
class String;
|
|
21
|
+
class Value;
|
|
22
|
+
|
|
23
|
+
namespace internal {
|
|
24
|
+
class Isolate;
|
|
25
|
+
class ThreadLocalTop;
|
|
26
|
+
} // namespace internal
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Create new error objects by calling the corresponding error object
|
|
30
|
+
* constructor with the message.
|
|
31
|
+
*/
|
|
32
|
+
class V8_EXPORT Exception {
|
|
33
|
+
public:
|
|
34
|
+
static Local<Value> RangeError(Local<String> message,
|
|
35
|
+
Local<Value> options = {});
|
|
36
|
+
static Local<Value> ReferenceError(Local<String> message,
|
|
37
|
+
Local<Value> options = {});
|
|
38
|
+
static Local<Value> SyntaxError(Local<String> message,
|
|
39
|
+
Local<Value> options = {});
|
|
40
|
+
static Local<Value> TypeError(Local<String> message,
|
|
41
|
+
Local<Value> options = {});
|
|
42
|
+
static Local<Value> WasmCompileError(Local<String> message,
|
|
43
|
+
Local<Value> options = {});
|
|
44
|
+
static Local<Value> WasmLinkError(Local<String> message,
|
|
45
|
+
Local<Value> options = {});
|
|
46
|
+
static Local<Value> WasmRuntimeError(Local<String> message,
|
|
47
|
+
Local<Value> options = {});
|
|
48
|
+
static Local<Value> WasmSuspendError(Local<String> message,
|
|
49
|
+
Local<Value> options = {});
|
|
50
|
+
static Local<Value> Error(Local<String> message, Local<Value> options = {});
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Creates an error message for the given exception.
|
|
54
|
+
* Will try to reconstruct the original stack trace from the exception value,
|
|
55
|
+
* or capture the current stack trace if not available.
|
|
56
|
+
*/
|
|
57
|
+
static Local<Message> CreateMessage(Isolate* isolate, Local<Value> exception);
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Returns the original stack trace that was captured at the creation time
|
|
61
|
+
* of a given exception, or an empty handle if not available.
|
|
62
|
+
*/
|
|
63
|
+
static Local<StackTrace> GetStackTrace(Local<Value> exception);
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Captures the current stack trace and attaches it to the given object in the
|
|
67
|
+
* form of `stack` property.
|
|
68
|
+
*/
|
|
69
|
+
static Maybe<bool> CaptureStackTrace(Local<Context> context,
|
|
70
|
+
Local<Object> object);
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* This is a part of experimental Api and might be changed without further
|
|
75
|
+
* notice.
|
|
76
|
+
* Do not use it.
|
|
77
|
+
*/
|
|
78
|
+
enum class ExceptionContext : uint32_t {
|
|
79
|
+
kUnknown,
|
|
80
|
+
kConstructor,
|
|
81
|
+
kOperation,
|
|
82
|
+
kAttributeGet,
|
|
83
|
+
kAttributeSet,
|
|
84
|
+
kIndexedQuery,
|
|
85
|
+
kIndexedGetter,
|
|
86
|
+
kIndexedDescriptor,
|
|
87
|
+
kIndexedSetter,
|
|
88
|
+
kIndexedDefiner,
|
|
89
|
+
kIndexedDeleter,
|
|
90
|
+
kNamedQuery,
|
|
91
|
+
kNamedGetter,
|
|
92
|
+
kNamedDescriptor,
|
|
93
|
+
kNamedSetter,
|
|
94
|
+
kNamedDefiner,
|
|
95
|
+
kNamedDeleter,
|
|
96
|
+
kNamedEnumerator
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* This is a part of experimental Api and might be changed without further
|
|
101
|
+
* notice.
|
|
102
|
+
* Do not use it.
|
|
103
|
+
*/
|
|
104
|
+
class ExceptionPropagationMessage {
|
|
105
|
+
public:
|
|
106
|
+
ExceptionPropagationMessage(v8::Isolate* isolate, Local<Object> exception,
|
|
107
|
+
Local<String> interface_name,
|
|
108
|
+
Local<String> property_name,
|
|
109
|
+
ExceptionContext exception_context)
|
|
110
|
+
: isolate_(isolate),
|
|
111
|
+
exception_(exception),
|
|
112
|
+
interface_name_(interface_name),
|
|
113
|
+
property_name_(property_name),
|
|
114
|
+
exception_context_(exception_context) {}
|
|
115
|
+
|
|
116
|
+
V8_INLINE Isolate* GetIsolate() const { return isolate_; }
|
|
117
|
+
V8_INLINE Local<Object> GetException() const { return exception_; }
|
|
118
|
+
V8_INLINE Local<String> GetInterfaceName() const { return interface_name_; }
|
|
119
|
+
V8_INLINE Local<String> GetPropertyName() const { return property_name_; }
|
|
120
|
+
V8_INLINE ExceptionContext GetExceptionContext() const {
|
|
121
|
+
return exception_context_;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
private:
|
|
125
|
+
Isolate* isolate_;
|
|
126
|
+
Local<Object> exception_;
|
|
127
|
+
Local<String> interface_name_;
|
|
128
|
+
Local<String> property_name_;
|
|
129
|
+
ExceptionContext exception_context_;
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
using ExceptionPropagationCallback =
|
|
133
|
+
void (*)(ExceptionPropagationMessage message);
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* An external exception handler.
|
|
137
|
+
*/
|
|
138
|
+
class V8_EXPORT TryCatch {
|
|
139
|
+
public:
|
|
140
|
+
/**
|
|
141
|
+
* Creates a new try/catch block and registers it with v8. Note that
|
|
142
|
+
* all TryCatch blocks should be stack allocated because the memory
|
|
143
|
+
* location itself is compared against JavaScript try/catch blocks.
|
|
144
|
+
*/
|
|
145
|
+
explicit TryCatch(Isolate* isolate);
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* Unregisters and deletes this try/catch block.
|
|
149
|
+
*/
|
|
150
|
+
~TryCatch();
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* Returns true if an exception has been caught by this try/catch block.
|
|
154
|
+
*/
|
|
155
|
+
bool HasCaught() const;
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* For certain types of exceptions, it makes no sense to continue execution.
|
|
159
|
+
*
|
|
160
|
+
* If CanContinue returns false, the correct action is to perform any C++
|
|
161
|
+
* cleanup needed and then return. If CanContinue returns false and
|
|
162
|
+
* HasTerminated returns true, it is possible to call
|
|
163
|
+
* CancelTerminateExecution in order to continue calling into the engine.
|
|
164
|
+
*/
|
|
165
|
+
bool CanContinue() const;
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* Returns true if an exception has been caught due to script execution
|
|
169
|
+
* being terminated.
|
|
170
|
+
*
|
|
171
|
+
* There is no JavaScript representation of an execution termination
|
|
172
|
+
* exception. Such exceptions are thrown when the TerminateExecution
|
|
173
|
+
* methods are called to terminate a long-running script.
|
|
174
|
+
*
|
|
175
|
+
* If such an exception has been thrown, HasTerminated will return true,
|
|
176
|
+
* indicating that it is possible to call CancelTerminateExecution in order
|
|
177
|
+
* to continue calling into the engine.
|
|
178
|
+
*/
|
|
179
|
+
bool HasTerminated() const;
|
|
180
|
+
|
|
181
|
+
/**
|
|
182
|
+
* Throws the exception caught by this TryCatch in a way that avoids
|
|
183
|
+
* it being caught again by this same TryCatch. As with ThrowException
|
|
184
|
+
* it is illegal to execute any JavaScript operations after calling
|
|
185
|
+
* ReThrow; the caller must return immediately to where the exception
|
|
186
|
+
* is caught.
|
|
187
|
+
*/
|
|
188
|
+
Local<Value> ReThrow();
|
|
189
|
+
|
|
190
|
+
/**
|
|
191
|
+
* Returns the exception caught by this try/catch block. If no exception has
|
|
192
|
+
* been caught an empty handle is returned.
|
|
193
|
+
*/
|
|
194
|
+
Local<Value> Exception() const;
|
|
195
|
+
|
|
196
|
+
/**
|
|
197
|
+
* Returns the .stack property of an object. If no .stack
|
|
198
|
+
* property is present an empty handle is returned.
|
|
199
|
+
*/
|
|
200
|
+
V8_WARN_UNUSED_RESULT static MaybeLocal<Value> StackTrace(
|
|
201
|
+
Local<Context> context, Local<Value> exception);
|
|
202
|
+
|
|
203
|
+
/**
|
|
204
|
+
* Returns the .stack property of the thrown object. If no .stack property is
|
|
205
|
+
* present or if this try/catch block has not caught an exception, an empty
|
|
206
|
+
* handle is returned.
|
|
207
|
+
*/
|
|
208
|
+
V8_WARN_UNUSED_RESULT MaybeLocal<Value> StackTrace(
|
|
209
|
+
Local<Context> context) const;
|
|
210
|
+
|
|
211
|
+
/**
|
|
212
|
+
* Returns the message associated with this exception. If there is
|
|
213
|
+
* no message associated an empty handle is returned.
|
|
214
|
+
*/
|
|
215
|
+
Local<v8::Message> Message() const;
|
|
216
|
+
|
|
217
|
+
/**
|
|
218
|
+
* Clears any exceptions that may have been caught by this try/catch block.
|
|
219
|
+
* After this method has been called, HasCaught() will return false. Cancels
|
|
220
|
+
* the scheduled exception if it is caught and ReThrow() is not called before.
|
|
221
|
+
*
|
|
222
|
+
* It is not necessary to clear a try/catch block before using it again; if
|
|
223
|
+
* another exception is thrown the previously caught exception will just be
|
|
224
|
+
* overwritten. However, it is often a good idea since it makes it easier
|
|
225
|
+
* to determine which operation threw a given exception.
|
|
226
|
+
*/
|
|
227
|
+
void Reset();
|
|
228
|
+
|
|
229
|
+
/**
|
|
230
|
+
* Set verbosity of the external exception handler.
|
|
231
|
+
*
|
|
232
|
+
* By default, exceptions that are caught by an external exception
|
|
233
|
+
* handler are not reported. Call SetVerbose with true on an
|
|
234
|
+
* external exception handler to have exceptions caught by the
|
|
235
|
+
* handler reported as if they were not caught.
|
|
236
|
+
*/
|
|
237
|
+
void SetVerbose(bool value);
|
|
238
|
+
|
|
239
|
+
/**
|
|
240
|
+
* Returns true if verbosity is enabled.
|
|
241
|
+
*/
|
|
242
|
+
bool IsVerbose() const;
|
|
243
|
+
|
|
244
|
+
/**
|
|
245
|
+
* Set whether or not this TryCatch should capture a Message object
|
|
246
|
+
* which holds source information about where the exception
|
|
247
|
+
* occurred. True by default.
|
|
248
|
+
*/
|
|
249
|
+
void SetCaptureMessage(bool value);
|
|
250
|
+
|
|
251
|
+
TryCatch(const TryCatch&) = delete;
|
|
252
|
+
void operator=(const TryCatch&) = delete;
|
|
253
|
+
|
|
254
|
+
private:
|
|
255
|
+
// Declaring operator new and delete as deleted is not spec compliant.
|
|
256
|
+
// Therefore declare them private instead to disable dynamic alloc
|
|
257
|
+
void* operator new(size_t size);
|
|
258
|
+
void* operator new[](size_t size);
|
|
259
|
+
void operator delete(void*, size_t);
|
|
260
|
+
void operator delete[](void*, size_t);
|
|
261
|
+
|
|
262
|
+
/**
|
|
263
|
+
* There are cases when the raw address of C++ TryCatch object cannot be
|
|
264
|
+
* used for comparisons with addresses into the JS stack. The cases are:
|
|
265
|
+
* 1) ARM, ARM64 and MIPS simulators which have separate JS stack.
|
|
266
|
+
* 2) Address sanitizer allocates local C++ object in the heap when
|
|
267
|
+
* UseAfterReturn mode is enabled.
|
|
268
|
+
* This method returns address that can be used for comparisons with
|
|
269
|
+
* addresses into the JS stack. When neither simulator nor ASAN's
|
|
270
|
+
* UseAfterReturn is enabled, then the address returned will be the address
|
|
271
|
+
* of the C++ try catch handler itself.
|
|
272
|
+
*/
|
|
273
|
+
internal::Address JSStackComparableAddressPrivate() {
|
|
274
|
+
return js_stack_comparable_address_;
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
void ResetInternal();
|
|
278
|
+
|
|
279
|
+
// Helper methods for internal::Isolate.
|
|
280
|
+
bool capture_message() const;
|
|
281
|
+
void set_can_continue(bool value);
|
|
282
|
+
bool rethrow() const;
|
|
283
|
+
void set_rethrow(bool value);
|
|
284
|
+
|
|
285
|
+
internal::Isolate* i_isolate_;
|
|
286
|
+
TryCatch* next_;
|
|
287
|
+
void* exception_;
|
|
288
|
+
void* message_obj_;
|
|
289
|
+
internal::Address js_stack_comparable_address_;
|
|
290
|
+
uint8_t flags_;
|
|
291
|
+
|
|
292
|
+
friend class internal::Isolate;
|
|
293
|
+
friend class internal::ThreadLocalTop;
|
|
294
|
+
};
|
|
295
|
+
|
|
296
|
+
} // namespace v8
|
|
297
|
+
|
|
298
|
+
#endif // INCLUDE_V8_EXCEPTION_H_
|
|
@@ -0,0 +1,60 @@
|
|
|
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
|
+
const String::ExternalOneByteStringResource* source() const {
|
|
37
|
+
return source_;
|
|
38
|
+
}
|
|
39
|
+
int dependency_count() const { return dep_count_; }
|
|
40
|
+
const char** dependencies() const { return deps_; }
|
|
41
|
+
void set_auto_enable(bool value) { auto_enable_ = value; }
|
|
42
|
+
bool auto_enable() { return auto_enable_; }
|
|
43
|
+
|
|
44
|
+
// Disallow copying and assigning.
|
|
45
|
+
Extension(const Extension&) = delete;
|
|
46
|
+
void operator=(const Extension&) = delete;
|
|
47
|
+
|
|
48
|
+
private:
|
|
49
|
+
const char* name_;
|
|
50
|
+
String::ExternalOneByteStringResource* source_;
|
|
51
|
+
int dep_count_;
|
|
52
|
+
const char** deps_;
|
|
53
|
+
bool auto_enable_;
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
void V8_EXPORT RegisterExtension(std::unique_ptr<Extension>);
|
|
57
|
+
|
|
58
|
+
} // namespace v8
|
|
59
|
+
|
|
60
|
+
#endif // INCLUDE_V8_EXTENSION_H_
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
// Copyright 2024 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_EXTERNAL_MEMORY_ACCOUNTER_H_
|
|
6
|
+
#define INCLUDE_EXTERNAL_MEMORY_ACCOUNTER_H_
|
|
7
|
+
|
|
8
|
+
#include <stdint.h>
|
|
9
|
+
|
|
10
|
+
#include "v8-isolate.h"
|
|
11
|
+
|
|
12
|
+
namespace v8 {
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* This class is used to give V8 an indication of the amount of externally
|
|
16
|
+
* allocated memory that is kept alive by JavaScript objects. V8 uses this to
|
|
17
|
+
* decide when to perform garbage collections. Registering externally allocated
|
|
18
|
+
* memory will trigger garbage collections more often than it would otherwise in
|
|
19
|
+
* an attempt to garbage collect the JavaScript objects that keep the externally
|
|
20
|
+
* allocated memory alive. Instances of ExternalMemoryAccounter check that the
|
|
21
|
+
* reported external memory is back to 0 on destruction.
|
|
22
|
+
*/
|
|
23
|
+
class V8_EXPORT ExternalMemoryAccounter {
|
|
24
|
+
public:
|
|
25
|
+
/**
|
|
26
|
+
* Returns the amount of external memory registered for `isolate`.
|
|
27
|
+
*/
|
|
28
|
+
static int64_t GetTotalAmountOfExternalAllocatedMemoryForTesting(
|
|
29
|
+
const Isolate* isolate);
|
|
30
|
+
|
|
31
|
+
ExternalMemoryAccounter() = default;
|
|
32
|
+
~ExternalMemoryAccounter();
|
|
33
|
+
ExternalMemoryAccounter(ExternalMemoryAccounter&&);
|
|
34
|
+
ExternalMemoryAccounter& operator=(ExternalMemoryAccounter&&);
|
|
35
|
+
ExternalMemoryAccounter(const ExternalMemoryAccounter&) = delete;
|
|
36
|
+
ExternalMemoryAccounter& operator=(const ExternalMemoryAccounter&) = delete;
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Reports an increase of `size` bytes of external memory.
|
|
40
|
+
*/
|
|
41
|
+
void Increase(Isolate* isolate, size_t size);
|
|
42
|
+
/**
|
|
43
|
+
* Reports an update of `delta` bytes of external memory.
|
|
44
|
+
*/
|
|
45
|
+
void Update(Isolate* isolate, int64_t delta);
|
|
46
|
+
/**
|
|
47
|
+
* Reports an decrease of `size` bytes of external memory.
|
|
48
|
+
*/
|
|
49
|
+
void Decrease(Isolate* isolate, size_t size);
|
|
50
|
+
|
|
51
|
+
private:
|
|
52
|
+
#ifdef V8_ENABLE_MEMORY_ACCOUNTING_CHECKS
|
|
53
|
+
size_t amount_of_external_memory_ = 0;
|
|
54
|
+
v8::Isolate* isolate_ = nullptr;
|
|
55
|
+
#endif
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
} // namespace v8
|
|
59
|
+
|
|
60
|
+
#endif // INCLUDE_EXTERNAL_MEMORY_ACCOUNTER_H_
|
|
@@ -0,0 +1,73 @@
|
|
|
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 tag for external pointers. Objects with different C++ types should use
|
|
17
|
+
* different values of ExternalPointerTypeTag when using v8::External. The
|
|
18
|
+
* allowed range is 0..V8_EXTERNAL_POINTER_TAG_COUNT - 1. If this is not
|
|
19
|
+
* sufficient, V8_EXTERNAL_POINTER_TAG_COUNT can be increased.
|
|
20
|
+
*/
|
|
21
|
+
using ExternalPointerTypeTag = uint16_t;
|
|
22
|
+
|
|
23
|
+
constexpr ExternalPointerTypeTag kExternalPointerTypeTagDefault = 0;
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* A JavaScript value that wraps a C++ void*. This type of value is mainly used
|
|
27
|
+
* to associate C++ data structures with JavaScript objects.
|
|
28
|
+
*/
|
|
29
|
+
class V8_EXPORT External : public Value {
|
|
30
|
+
public:
|
|
31
|
+
V8_DEPRECATED("Use the version with the type tag.")
|
|
32
|
+
static Local<External> New(Isolate* isolate, void* value) {
|
|
33
|
+
return New(isolate, value, kExternalPointerTypeTagDefault);
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Creates a new External object.
|
|
37
|
+
*
|
|
38
|
+
* \param isolate The isolate for the external object.
|
|
39
|
+
* \param value The C++ pointer value.
|
|
40
|
+
* \param tag The type tag of the external pointer. If type tags are not used
|
|
41
|
+
* in the embedder, the default value `kExternalPointerTypeTagDefault` can be
|
|
42
|
+
* used.
|
|
43
|
+
* \return The new External object.
|
|
44
|
+
*/
|
|
45
|
+
static Local<External> New(Isolate* isolate, void* value,
|
|
46
|
+
ExternalPointerTypeTag tag);
|
|
47
|
+
V8_INLINE static External* Cast(Data* value) {
|
|
48
|
+
#ifdef V8_ENABLE_CHECKS
|
|
49
|
+
CheckCast(value);
|
|
50
|
+
#endif
|
|
51
|
+
return static_cast<External*>(value);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
V8_DEPRECATED("Use the version with the type tag.")
|
|
55
|
+
void* Value() const { return Value(kExternalPointerTypeTagDefault); }
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Returns the value of the external pointer.
|
|
59
|
+
*
|
|
60
|
+
* \param tag The type tag of the external pointer. If type tags are not used
|
|
61
|
+
* in the embedder, the default value `kExternalPointerTypeTagDefault` can be
|
|
62
|
+
* used.
|
|
63
|
+
* \return The value of the external pointer.
|
|
64
|
+
*/
|
|
65
|
+
void* Value(ExternalPointerTypeTag tag) const;
|
|
66
|
+
|
|
67
|
+
private:
|
|
68
|
+
static void CheckCast(v8::Data* obj);
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
} // namespace v8
|
|
72
|
+
|
|
73
|
+
#endif // INCLUDE_V8_EXTERNAL_H_
|