@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.
Files changed (137) hide show
  1. package/include/node/cppgc/allocation.h +308 -0
  2. package/include/node/cppgc/common.h +28 -0
  3. package/include/node/cppgc/cross-thread-persistent.h +462 -0
  4. package/include/node/cppgc/custom-space.h +97 -0
  5. package/include/node/cppgc/default-platform.h +68 -0
  6. package/include/node/cppgc/explicit-management.h +100 -0
  7. package/include/node/cppgc/garbage-collected.h +114 -0
  8. package/include/node/cppgc/heap-consistency.h +309 -0
  9. package/include/node/cppgc/heap-handle.h +48 -0
  10. package/include/node/cppgc/heap-state.h +82 -0
  11. package/include/node/cppgc/heap-statistics.h +126 -0
  12. package/include/node/cppgc/heap.h +202 -0
  13. package/include/node/cppgc/internal/api-constants.h +75 -0
  14. package/include/node/cppgc/internal/atomic-entry-flag.h +48 -0
  15. package/include/node/cppgc/internal/base-page-handle.h +43 -0
  16. package/include/node/cppgc/internal/caged-heap-local-data.h +117 -0
  17. package/include/node/cppgc/internal/caged-heap.h +64 -0
  18. package/include/node/cppgc/internal/compiler-specific.h +46 -0
  19. package/include/node/cppgc/internal/conditional-stack-allocated.h +41 -0
  20. package/include/node/cppgc/internal/finalizer-trait.h +93 -0
  21. package/include/node/cppgc/internal/gc-info.h +150 -0
  22. package/include/node/cppgc/internal/logging.h +50 -0
  23. package/include/node/cppgc/internal/member-storage.h +305 -0
  24. package/include/node/cppgc/internal/name-trait.h +141 -0
  25. package/include/node/cppgc/internal/persistent-node.h +219 -0
  26. package/include/node/cppgc/internal/pointer-policies.h +280 -0
  27. package/include/node/cppgc/internal/write-barrier.h +487 -0
  28. package/include/node/cppgc/liveness-broker.h +78 -0
  29. package/include/node/cppgc/macros.h +56 -0
  30. package/include/node/cppgc/member.h +669 -0
  31. package/include/node/cppgc/name-provider.h +75 -0
  32. package/include/node/cppgc/object-size-trait.h +58 -0
  33. package/include/node/cppgc/persistent.h +376 -0
  34. package/include/node/cppgc/platform.h +174 -0
  35. package/include/node/cppgc/prefinalizer.h +75 -0
  36. package/include/node/cppgc/process-heap-statistics.h +36 -0
  37. package/include/node/cppgc/sentinel-pointer.h +39 -0
  38. package/include/node/cppgc/source-location.h +16 -0
  39. package/include/node/cppgc/tagged-member.h +114 -0
  40. package/include/node/cppgc/testing.h +106 -0
  41. package/include/node/cppgc/trace-trait.h +127 -0
  42. package/include/node/cppgc/type-traits.h +272 -0
  43. package/include/node/cppgc/visitor.h +534 -0
  44. package/include/node/js_native_api.h +634 -0
  45. package/include/node/js_native_api_types.h +244 -0
  46. package/include/node/libplatform/libplatform-export.h +29 -0
  47. package/include/node/libplatform/libplatform.h +112 -0
  48. package/include/node/libplatform/v8-tracing.h +343 -0
  49. package/include/node/node.h +1744 -0
  50. package/include/node/node_api.h +265 -0
  51. package/include/node/node_api_types.h +58 -0
  52. package/include/node/node_buffer.h +94 -0
  53. package/include/node/node_object_wrap.h +145 -0
  54. package/include/node/node_version.h +116 -0
  55. package/include/node/uv/aix.h +32 -0
  56. package/include/node/uv/bsd.h +34 -0
  57. package/include/node/uv/darwin.h +61 -0
  58. package/include/node/uv/errno.h +483 -0
  59. package/include/node/uv/linux.h +34 -0
  60. package/include/node/uv/os390.h +33 -0
  61. package/include/node/uv/posix.h +31 -0
  62. package/include/node/uv/sunos.h +44 -0
  63. package/include/node/uv/threadpool.h +37 -0
  64. package/include/node/uv/tree.h +521 -0
  65. package/include/node/uv/unix.h +509 -0
  66. package/include/node/uv/version.h +43 -0
  67. package/include/node/uv/win.h +698 -0
  68. package/include/node/uv.h +1994 -0
  69. package/include/node/v8-array-buffer.h +646 -0
  70. package/include/node/v8-callbacks.h +533 -0
  71. package/include/node/v8-container.h +183 -0
  72. package/include/node/v8-context.h +580 -0
  73. package/include/node/v8-cpp-heap-external.h +56 -0
  74. package/include/node/v8-cppgc.h +194 -0
  75. package/include/node/v8-data.h +96 -0
  76. package/include/node/v8-date.h +57 -0
  77. package/include/node/v8-debug.h +210 -0
  78. package/include/node/v8-embedder-heap.h +54 -0
  79. package/include/node/v8-embedder-state-scope.h +52 -0
  80. package/include/node/v8-exception.h +298 -0
  81. package/include/node/v8-extension.h +60 -0
  82. package/include/node/v8-external-memory-accounter.h +60 -0
  83. package/include/node/v8-external.h +73 -0
  84. package/include/node/v8-fast-api-calls.h +784 -0
  85. package/include/node/v8-forward.h +82 -0
  86. package/include/node/v8-function-callback.h +708 -0
  87. package/include/node/v8-function.h +148 -0
  88. package/include/node/v8-handle-base.h +155 -0
  89. package/include/node/v8-initialization.h +343 -0
  90. package/include/node/v8-inspector-protocol.h +13 -0
  91. package/include/node/v8-inspector.h +458 -0
  92. package/include/node/v8-internal.h +1827 -0
  93. package/include/node/v8-isolate.h +1925 -0
  94. package/include/node/v8-json.h +54 -0
  95. package/include/node/v8-local-handle.h +884 -0
  96. package/include/node/v8-locker.h +138 -0
  97. package/include/node/v8-maybe.h +185 -0
  98. package/include/node/v8-memory-span.h +273 -0
  99. package/include/node/v8-message.h +215 -0
  100. package/include/node/v8-metrics.h +273 -0
  101. package/include/node/v8-microtask-queue.h +152 -0
  102. package/include/node/v8-microtask.h +28 -0
  103. package/include/node/v8-object.h +1134 -0
  104. package/include/node/v8-persistent-handle.h +556 -0
  105. package/include/node/v8-platform.h +1552 -0
  106. package/include/node/v8-primitive-object.h +118 -0
  107. package/include/node/v8-primitive.h +1056 -0
  108. package/include/node/v8-profiler.h +1401 -0
  109. package/include/node/v8-promise.h +185 -0
  110. package/include/node/v8-proxy.h +49 -0
  111. package/include/node/v8-regexp.h +105 -0
  112. package/include/node/v8-sandbox.h +170 -0
  113. package/include/node/v8-script.h +996 -0
  114. package/include/node/v8-snapshot.h +302 -0
  115. package/include/node/v8-source-location.h +91 -0
  116. package/include/node/v8-statistics.h +246 -0
  117. package/include/node/v8-template.h +1096 -0
  118. package/include/node/v8-trace-categories.h +28 -0
  119. package/include/node/v8-traced-handle.h +420 -0
  120. package/include/node/v8-typed-array.h +386 -0
  121. package/include/node/v8-unwinder-state.h +30 -0
  122. package/include/node/v8-unwinder.h +146 -0
  123. package/include/node/v8-util.h +549 -0
  124. package/include/node/v8-value-serializer-version.h +24 -0
  125. package/include/node/v8-value-serializer.h +316 -0
  126. package/include/node/v8-value.h +674 -0
  127. package/include/node/v8-version-string.h +38 -0
  128. package/include/node/v8-version.h +20 -0
  129. package/include/node/v8-wasm-trap-handler-posix.h +31 -0
  130. package/include/node/v8-wasm-trap-handler-win.h +28 -0
  131. package/include/node/v8-wasm.h +325 -0
  132. package/include/node/v8-weak-callback-info.h +88 -0
  133. package/include/node/v8.h +88 -0
  134. package/include/node/v8config.h +1077 -0
  135. package/lib/libc++_shared.so +0 -0
  136. package/lib/libnode.so +4 -0
  137. package/package.json +23 -3
@@ -0,0 +1,533 @@
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_ISOLATE_CALLBACKS_H_
6
+ #define INCLUDE_V8_ISOLATE_CALLBACKS_H_
7
+
8
+ #include <stddef.h>
9
+
10
+ #include <functional>
11
+ #include <string>
12
+
13
+ #include "cppgc/common.h"
14
+ #include "v8-data.h" // NOLINT(build/include_directory)
15
+ #include "v8-local-handle.h" // NOLINT(build/include_directory)
16
+ #include "v8-promise.h" // NOLINT(build/include_directory)
17
+ #include "v8config.h" // NOLINT(build/include_directory)
18
+
19
+ #if defined(V8_OS_WIN)
20
+ struct _EXCEPTION_POINTERS;
21
+ #endif
22
+
23
+ namespace v8 {
24
+
25
+ template <typename T>
26
+ class FunctionCallbackInfo;
27
+ class Isolate;
28
+ class Message;
29
+ class Module;
30
+ class Object;
31
+ class Promise;
32
+ class ScriptOrModule;
33
+ class String;
34
+ class UnboundScript;
35
+ class Value;
36
+
37
+ /**
38
+ * A JIT code event is issued each time code is added, moved or removed.
39
+ *
40
+ * \note removal events are not currently issued.
41
+ */
42
+ struct JitCodeEvent {
43
+ enum EventType {
44
+ CODE_ADDED,
45
+ CODE_MOVED,
46
+ CODE_REMOVED,
47
+ CODE_ADD_LINE_POS_INFO,
48
+ CODE_START_LINE_INFO_RECORDING,
49
+ CODE_END_LINE_INFO_RECORDING
50
+ };
51
+ // Definition of the code position type. The "POSITION" type means the place
52
+ // in the source code which are of interest when making stack traces to
53
+ // pin-point the source location of a stack frame as close as possible.
54
+ // The "STATEMENT_POSITION" means the place at the beginning of each
55
+ // statement, and is used to indicate possible break locations.
56
+ enum PositionType { POSITION, STATEMENT_POSITION };
57
+
58
+ // There are three different kinds of CodeType, one for JIT code generated
59
+ // by the optimizing compiler, one for byte code generated for the
60
+ // interpreter, and one for code generated from Wasm. For JIT_CODE and
61
+ // WASM_CODE, |code_start| points to the beginning of jitted assembly code,
62
+ // while for BYTE_CODE events, |code_start| points to the first bytecode of
63
+ // the interpreted function.
64
+ enum CodeType { BYTE_CODE, JIT_CODE, WASM_CODE };
65
+
66
+ // Type of event.
67
+ EventType type;
68
+ CodeType code_type;
69
+ // Start of the instructions.
70
+ void* code_start;
71
+ // Size of the instructions.
72
+ size_t code_len;
73
+ // Script info for CODE_ADDED event.
74
+ Local<UnboundScript> script;
75
+ // User-defined data for *_LINE_INFO_* event. It's used to hold the source
76
+ // code line information which is returned from the
77
+ // CODE_START_LINE_INFO_RECORDING event. And it's passed to subsequent
78
+ // CODE_ADD_LINE_POS_INFO and CODE_END_LINE_INFO_RECORDING events.
79
+ void* user_data;
80
+
81
+ struct name_t {
82
+ // Name of the object associated with the code, note that the string is not
83
+ // zero-terminated.
84
+ const char* str;
85
+ // Number of chars in str.
86
+ size_t len;
87
+ };
88
+
89
+ struct line_info_t {
90
+ // PC offset
91
+ size_t offset;
92
+ // Code position
93
+ size_t pos;
94
+ // The position type.
95
+ PositionType position_type;
96
+ };
97
+
98
+ struct wasm_source_info_t {
99
+ // Source file name.
100
+ const char* filename;
101
+ // Length of filename.
102
+ size_t filename_size;
103
+ // Line number table, which maps offsets of JITted code to line numbers of
104
+ // source file.
105
+ const line_info_t* line_number_table;
106
+ // Number of entries in the line number table.
107
+ size_t line_number_table_size;
108
+ };
109
+
110
+ wasm_source_info_t* wasm_source_info = nullptr;
111
+
112
+ union {
113
+ // Only valid for CODE_ADDED.
114
+ struct name_t name;
115
+
116
+ // Only valid for CODE_ADD_LINE_POS_INFO
117
+ struct line_info_t line_info;
118
+
119
+ // New location of instructions. Only valid for CODE_MOVED.
120
+ void* new_code_start;
121
+ };
122
+
123
+ Isolate* isolate;
124
+ };
125
+
126
+ /**
127
+ * Option flags passed to the SetJitCodeEventHandler function.
128
+ */
129
+ enum JitCodeEventOptions {
130
+ kJitCodeEventDefault = 0,
131
+ // Generate callbacks for already existent code.
132
+ kJitCodeEventEnumExisting = 1,
133
+
134
+ kLastJitCodeEventOption = kJitCodeEventEnumExisting
135
+ };
136
+
137
+ /**
138
+ * Callback function passed to SetJitCodeEventHandler.
139
+ *
140
+ * \param event code add, move or removal event.
141
+ */
142
+ using JitCodeEventHandler = void (*)(const JitCodeEvent* event);
143
+
144
+ // --- Garbage Collection Callbacks ---
145
+
146
+ /**
147
+ * Applications can register callback functions which will be called before and
148
+ * after certain garbage collection operations. Allocations are not allowed in
149
+ * the callback functions, you therefore cannot manipulate objects (set or
150
+ * delete properties for example) since it is possible such operations will
151
+ * result in the allocation of objects.
152
+ * TODO(v8:12612): Deprecate kGCTypeMinorMarkSweep after updating blink.
153
+ */
154
+ enum GCType {
155
+ kGCTypeScavenge = 1 << 0,
156
+ kGCTypeMinorMarkSweep = 1 << 1,
157
+ kGCTypeMarkSweepCompact = 1 << 2,
158
+ kGCTypeIncrementalMarking = 1 << 3,
159
+ kGCTypeProcessWeakCallbacks = 1 << 4,
160
+ kGCTypeAll = kGCTypeScavenge | kGCTypeMinorMarkSweep |
161
+ kGCTypeMarkSweepCompact | kGCTypeIncrementalMarking |
162
+ kGCTypeProcessWeakCallbacks
163
+ };
164
+
165
+ /**
166
+ * GCCallbackFlags is used to notify additional information about the GC
167
+ * callback.
168
+ * - kGCCallbackFlagConstructRetainedObjectInfos: The GC callback is for
169
+ * constructing retained object infos.
170
+ * - kGCCallbackFlagForced: The GC callback is for a forced GC for testing.
171
+ * - kGCCallbackFlagSynchronousPhantomCallbackProcessing: The GC callback
172
+ * is called synchronously without getting posted to an idle task.
173
+ * - kGCCallbackFlagCollectAllAvailableGarbage: The GC callback is called
174
+ * in a phase where V8 is trying to collect all available garbage
175
+ * (e.g., handling a low memory notification).
176
+ * - kGCCallbackScheduleIdleGarbageCollection: The GC callback is called to
177
+ * trigger an idle garbage collection.
178
+ */
179
+ enum GCCallbackFlags {
180
+ kNoGCCallbackFlags = 0,
181
+ kGCCallbackFlagConstructRetainedObjectInfos = 1 << 1,
182
+ kGCCallbackFlagForced = 1 << 2,
183
+ kGCCallbackFlagSynchronousPhantomCallbackProcessing = 1 << 3,
184
+ kGCCallbackFlagCollectAllAvailableGarbage = 1 << 4,
185
+ kGCCallbackFlagCollectAllExternalMemory = 1 << 5,
186
+ kGCCallbackScheduleIdleGarbageCollection = 1 << 6,
187
+ kGCCallbackFlagLastResort = 1 << 7,
188
+ };
189
+
190
+ using GCCallback = void (*)(GCType type, GCCallbackFlags flags);
191
+
192
+ using InterruptCallback = void (*)(Isolate* isolate, void* data);
193
+
194
+ using PrintCurrentStackTraceFilterCallback =
195
+ bool (*)(Isolate* isolate, Local<String> script_name);
196
+
197
+ /**
198
+ * This callback is invoked when the heap size is close to the heap limit and
199
+ * V8 is likely to abort with out-of-memory error.
200
+ * The callback can extend the heap limit by returning a value that is greater
201
+ * than the current_heap_limit. The initial heap limit is the limit that was
202
+ * set after heap setup.
203
+ */
204
+ using NearHeapLimitCallback = size_t (*)(void* data, size_t current_heap_limit,
205
+ size_t initial_heap_limit);
206
+
207
+ /**
208
+ * Callback function passed to SetUnhandledExceptionCallback.
209
+ */
210
+ #if defined(V8_OS_WIN)
211
+ using UnhandledExceptionCallback =
212
+ int (*)(_EXCEPTION_POINTERS* exception_pointers);
213
+ #endif
214
+
215
+ // --- Counters Callbacks ---
216
+
217
+ using CounterLookupCallback = int* (*)(const char* name);
218
+
219
+ using CreateHistogramCallback = void* (*)(const char* name, int min, int max,
220
+ size_t buckets);
221
+
222
+ using AddHistogramSampleCallback = void (*)(void* histogram, int sample);
223
+
224
+ // --- Exceptions ---
225
+
226
+ using FatalErrorCallback = void (*)(const char* location, const char* message);
227
+
228
+ struct OOMDetails {
229
+ bool is_heap_oom = false;
230
+ const char* detail = nullptr;
231
+ };
232
+
233
+ using OOMErrorCallback = void (*)(const char* location,
234
+ const OOMDetails& details);
235
+
236
+ using OOMErrorCallbackWithData = void (*)(const char* location,
237
+ const OOMDetails& details,
238
+ void* data);
239
+
240
+ using MessageCallback = void (*)(Local<Message> message, Local<Value> data);
241
+
242
+ // --- Tracing ---
243
+
244
+ enum LogEventStatus : int { kStart = 0, kEnd = 1, kLog = 2 };
245
+ using LogEventCallback = void (*)(const char* name,
246
+ int /* LogEventStatus */ status);
247
+
248
+ // --- Crashkeys Callback ---
249
+ enum class CrashKeyId {
250
+ kIsolateAddress,
251
+ kReadonlySpaceFirstPageAddress,
252
+ kMapSpaceFirstPageAddress V8_ENUM_DEPRECATE_SOON("Map space got removed"),
253
+ kOldSpaceFirstPageAddress,
254
+ kCodeRangeBaseAddress,
255
+ kCodeSpaceFirstPageAddress,
256
+ kDumpType,
257
+ kSnapshotChecksumCalculated,
258
+ kSnapshotChecksumExpected,
259
+ };
260
+
261
+ using AddCrashKeyCallback = void (*)(CrashKeyId id, const std::string& value);
262
+
263
+ // --- CrashKeyString Callbacks ---
264
+ using CrashKey = void*;
265
+ enum class CrashKeySize { Size32, Size64, Size256, Size1024 };
266
+
267
+ using AllocateCrashKeyStringCallback =
268
+ std::function<CrashKey(const char key[], CrashKeySize size)>;
269
+ using SetCrashKeyStringCallback =
270
+ std::function<void(CrashKey key, const std::string_view value)>;
271
+
272
+ // --- Enter/Leave Script Callback ---
273
+ using BeforeCallEnteredCallback = void (*)(Isolate*);
274
+ using CallCompletedCallback = void (*)(Isolate*);
275
+
276
+ // --- Modify Code Generation From Strings Callback ---
277
+ struct ModifyCodeGenerationFromStringsResult {
278
+ // If true, proceed with the codegen algorithm. Otherwise, block it.
279
+ bool codegen_allowed = false;
280
+ // Overwrite the original source with this string, if present.
281
+ // Use the original source if empty.
282
+ // This field is considered only if codegen_allowed is true.
283
+ MaybeLocal<String> modified_source;
284
+ };
285
+
286
+ /**
287
+ * Callback to check if codegen is allowed from a source object, and convert
288
+ * the source to string if necessary. See: ModifyCodeGenerationFromStrings.
289
+ */
290
+ using ModifyCodeGenerationFromStringsCallback =
291
+ ModifyCodeGenerationFromStringsResult (*)(Local<Context> context,
292
+ Local<Value> source);
293
+ using ModifyCodeGenerationFromStringsCallback2 =
294
+ ModifyCodeGenerationFromStringsResult (*)(Local<Context> context,
295
+ Local<Value> source,
296
+ bool is_code_like);
297
+
298
+ // --- Failed Access Check Callback ---
299
+
300
+ /**
301
+ * Access type specification.
302
+ */
303
+ enum AccessType {
304
+ ACCESS_GET,
305
+ ACCESS_SET,
306
+ ACCESS_HAS,
307
+ ACCESS_DELETE,
308
+ ACCESS_KEYS
309
+ };
310
+
311
+ using FailedAccessCheckCallback = void (*)(Local<Object> target,
312
+ AccessType type, Local<Value> data);
313
+
314
+ // --- WebAssembly compilation callbacks ---
315
+ using ExtensionCallback = bool (*)(const FunctionCallbackInfo<Value>&);
316
+
317
+ using AllowWasmCodeGenerationCallback = bool (*)(Local<Context> context,
318
+ Local<String> source);
319
+
320
+ // --- Callback for APIs defined on v8-supported objects, but implemented
321
+ // by the embedder. Example: WebAssembly.{compile|instantiate}Streaming ---
322
+ using ApiImplementationCallback = void (*)(const FunctionCallbackInfo<Value>&);
323
+
324
+ // --- Callback for WebAssembly.compileStreaming ---
325
+ using WasmStreamingCallback = void (*)(const FunctionCallbackInfo<Value>&);
326
+
327
+ enum class WasmAsyncSuccess { kSuccess, kFail };
328
+
329
+ // --- Callback called when async WebAssembly operations finish ---
330
+ using WasmAsyncResolvePromiseCallback = void (*)(
331
+ Isolate* isolate, Local<Context> context, Local<Promise::Resolver> resolver,
332
+ Local<Value> result, WasmAsyncSuccess success);
333
+
334
+ // --- Callback for loading source map file for Wasm profiling support
335
+ using WasmLoadSourceMapCallback = Local<String> (*)(Isolate* isolate,
336
+ const char* name);
337
+
338
+ // --- Callback for checking if WebAssembly Custom Descriptors are enabled ---
339
+ using WasmCustomDescriptorsEnabledCallback = bool (*)(Local<Context> context);
340
+
341
+ // --- Callback for checking if the SharedArrayBuffer constructor is enabled ---
342
+ using SharedArrayBufferConstructorEnabledCallback =
343
+ bool (*)(Local<Context> context);
344
+
345
+ /**
346
+ * Import phases in import requests.
347
+ */
348
+ enum class ModuleImportPhase {
349
+ kSource,
350
+ kDefer,
351
+ kEvaluation,
352
+ };
353
+
354
+ /**
355
+ * HostImportModuleDynamicallyCallback is called when we
356
+ * require the embedder to load a module. This is used as part of the dynamic
357
+ * import syntax.
358
+ *
359
+ * The referrer contains metadata about the script/module that calls
360
+ * import.
361
+ *
362
+ * The specifier is the name of the module that should be imported.
363
+ *
364
+ * The import_attributes are import attributes for this request in the form:
365
+ * [key1, value1, key2, value2, ...] where the keys and values are of type
366
+ * v8::String. Note, unlike the FixedArray passed to ResolveModuleCallback and
367
+ * returned from ModuleRequest::GetImportAttributes(), this array does not
368
+ * contain the source Locations of the attributes.
369
+ *
370
+ * The embedder must compile, instantiate, evaluate the Module, and
371
+ * obtain its namespace object.
372
+ *
373
+ * The Promise returned from this function is forwarded to userland
374
+ * JavaScript. The embedder must resolve this promise with the module
375
+ * namespace object. In case of an exception, the embedder must reject
376
+ * this promise with the exception. If the promise creation itself
377
+ * fails (e.g. due to stack overflow), the embedder must propagate
378
+ * that exception by returning an empty MaybeLocal.
379
+ */
380
+ using HostImportModuleDynamicallyCallback = MaybeLocal<Promise> (*)(
381
+ Local<Context> context, Local<Data> host_defined_options,
382
+ Local<Value> resource_name, Local<String> specifier,
383
+ Local<FixedArray> import_attributes);
384
+
385
+ /**
386
+ * HostImportModuleWithPhaseDynamicallyCallback is called when we
387
+ * require the embedder to load a module with a specific phase. This is used
388
+ * as part of the dynamic import syntax.
389
+ *
390
+ * The referrer contains metadata about the script/module that calls
391
+ * import.
392
+ *
393
+ * The specifier is the name of the module that should be imported.
394
+ *
395
+ * The phase is the phase of the import requested.
396
+ *
397
+ * The import_attributes are import attributes for this request in the form:
398
+ * [key1, value1, key2, value2, ...] where the keys and values are of type
399
+ * v8::String. Note, unlike the FixedArray passed to ResolveModuleCallback and
400
+ * returned from ModuleRequest::GetImportAttributes(), this array does not
401
+ * contain the source Locations of the attributes.
402
+ *
403
+ * The Promise returned from this function is forwarded to userland
404
+ * JavaScript. The embedder must resolve this promise according to the phase
405
+ * requested:
406
+ * - For ModuleImportPhase::kSource, the promise must be resolved with a
407
+ * compiled ModuleSource object, or rejected with a SyntaxError if the
408
+ * module does not support source representation.
409
+ * - For ModuleImportPhase::kEvaluation, the promise must be resolved with a
410
+ * ModuleNamespace object of a module that has been compiled, instantiated,
411
+ * and evaluated.
412
+ *
413
+ * In case of an exception, the embedder must reject this promise with the
414
+ * exception. If the promise creation itself fails (e.g. due to stack
415
+ * overflow), the embedder must propagate that exception by returning an empty
416
+ * MaybeLocal.
417
+ *
418
+ * This callback is still experimental and is only invoked for source phase
419
+ * imports.
420
+ */
421
+ using HostImportModuleWithPhaseDynamicallyCallback = MaybeLocal<Promise> (*)(
422
+ Local<Context> context, Local<Data> host_defined_options,
423
+ Local<Value> resource_name, Local<String> specifier,
424
+ ModuleImportPhase phase, Local<FixedArray> import_attributes);
425
+
426
+ /**
427
+ * Callback for requesting a compile hint for a function from the embedder. The
428
+ * first parameter is the position of the function in source code and the second
429
+ * parameter is embedder data to be passed back.
430
+ */
431
+ using CompileHintCallback = bool (*)(int, void*);
432
+
433
+ /**
434
+ * HostInitializeImportMetaObjectCallback is called the first time import.meta
435
+ * is accessed for a module. Subsequent access will reuse the same value.
436
+ *
437
+ * The method combines two implementation-defined abstract operations into one:
438
+ * HostGetImportMetaProperties and HostFinalizeImportMeta.
439
+ *
440
+ * The embedder should use v8::Object::CreateDataProperty to add properties on
441
+ * the meta object.
442
+ */
443
+ using HostInitializeImportMetaObjectCallback = void (*)(Local<Context> context,
444
+ Local<Module> module,
445
+ Local<Object> meta);
446
+
447
+ /**
448
+ * HostCreateShadowRealmContextCallback is called each time a ShadowRealm is
449
+ * being constructed in the initiator_context.
450
+ *
451
+ * The method combines Context creation and implementation defined abstract
452
+ * operation HostInitializeShadowRealm into one.
453
+ *
454
+ * The embedder should use v8::Context::New or v8::Context:NewFromSnapshot to
455
+ * create a new context. If the creation fails, the embedder must propagate
456
+ * that exception by returning an empty MaybeLocal.
457
+ */
458
+ using HostCreateShadowRealmContextCallback =
459
+ MaybeLocal<Context> (*)(Local<Context> initiator_context);
460
+
461
+ /**
462
+ * IsJSApiWrapperNativeErrorCallback is called on an JSApiWrapper object to
463
+ * determine if Error.isError should return true or false. For instance, in an
464
+ * HTML embedder, DOMExceptions return true when passed to Error.isError.
465
+ */
466
+ using IsJSApiWrapperNativeErrorCallback = bool (*)(Isolate* isolate,
467
+ Local<Object> obj);
468
+
469
+ /**
470
+ * PrepareStackTraceCallback is called when the stack property of an error is
471
+ * first accessed. The return value will be used as the stack value. If this
472
+ * callback is registed, the |Error.prepareStackTrace| API will be disabled.
473
+ * |sites| is an array of call sites, specified in
474
+ * https://v8.dev/docs/stack-trace-api
475
+ */
476
+ using PrepareStackTraceCallback = MaybeLocal<Value> (*)(Local<Context> context,
477
+ Local<Value> error,
478
+ Local<Array> sites);
479
+
480
+ #if defined(V8_OS_WIN)
481
+ /**
482
+ * Callback to selectively enable ETW tracing based on the document URL.
483
+ * Implemented by the embedder, it should never call back into V8.
484
+ *
485
+ * Windows allows passing additional data to the ETW EnableCallback:
486
+ * https://learn.microsoft.com/en-us/windows/win32/api/evntprov/nc-evntprov-penablecallback
487
+ *
488
+ * This data can be configured in a WPR (Windows Performance Recorder)
489
+ * profile, adding a CustomFilter to an EventProvider like the following:
490
+ *
491
+ * <EventProvider Id=".." Name="57277741-3638-4A4B-BDBA-0AC6E45DA56C" Level="5">
492
+ * <CustomFilter Type="0x80000000" Value="AQABAAAAAAA..." />
493
+ * </EventProvider>
494
+ *
495
+ * Where:
496
+ * - Name="57277741-3638-4A4B-BDBA-0AC6E45DA56C" is the GUID of the V8
497
+ * ETW provider, (see src/libplatform/etw/etw-provider-win.h),
498
+ * - Type="0x80000000" is EVENT_FILTER_TYPE_SCHEMATIZED,
499
+ * - Value="AQABAAAAAA..." is a base64-encoded byte array that is
500
+ * base64-decoded by Windows and passed to the ETW enable callback in
501
+ * the 'PEVENT_FILTER_DESCRIPTOR FilterData' argument; see:
502
+ * https://learn.microsoft.com/en-us/windows/win32/api/evntprov/ns-evntprov-event_filter_descriptor.
503
+ *
504
+ * This array contains a struct EVENT_FILTER_HEADER followed by a
505
+ * variable length payload, and as payload we pass a string in JSON format,
506
+ * with a list of regular expressions that should match the document URL
507
+ * in order to enable ETW tracing:
508
+ * {
509
+ * "version": "2.0",
510
+ * "filtered_urls": [
511
+ * "https:\/\/.*\.chromium\.org\/.*", "https://v8.dev/";, "..."
512
+ * ],
513
+ * "trace_interpreter_frames": true
514
+ * }
515
+ */
516
+
517
+ using FilterETWSessionByURLCallback =
518
+ bool (*)(Local<Context> context, const std::string& etw_filter_payload);
519
+
520
+ struct FilterETWSessionByURLResult {
521
+ // If true, enable ETW tracing for the current isolate.
522
+ bool enable_etw_tracing;
523
+
524
+ // If true, also enables ETW tracing for interpreter stack frames.
525
+ bool trace_interpreter_frames;
526
+ };
527
+ using FilterETWSessionByURL2Callback = FilterETWSessionByURLResult (*)(
528
+ Local<Context> context, const std::string& etw_filter_payload);
529
+ #endif // V8_OS_WIN
530
+
531
+ } // namespace v8
532
+
533
+ #endif // INCLUDE_V8_ISOLATE_CALLBACKS_H_