virtual-machine 0.1.3 → 0.1.5
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/build/{chunk-S3CJQKBH.mjs → chunk-JU756VDZ.mjs} +49 -254
- package/build/cli.js +51 -318
- package/build/index.d.ts +24 -381
- package/build/index.js +51 -318
- package/build/index.mjs +3 -65
- package/build/{riscv_vm-B3MWUK6W.mjs → riscv_vm-TWECKOQY.mjs} +1 -3
- package/build/worker.js +22 -19
- package/native/riscv-vm-native.darwin-arm64.node +0 -0
- package/native/riscv-vm-native.darwin-x64.node +0 -0
- package/native/riscv-vm-native.linux-arm64-gnu.node +0 -0
- package/native/riscv-vm-native.linux-arm64-musl.node +0 -0
- package/native/riscv-vm-native.linux-x64-gnu.node +0 -0
- package/native/riscv-vm-native.linux-x64-musl.node +0 -0
- package/native/riscv-vm-native.win32-x64-msvc.node +0 -0
- package/package.json +1 -6
package/build/index.d.ts
CHANGED
|
@@ -1,36 +1,6 @@
|
|
|
1
1
|
/* tslint:disable */
|
|
2
2
|
/* eslint-disable */
|
|
3
3
|
|
|
4
|
-
declare class JitWorkerContext {
|
|
5
|
-
free(): void;
|
|
6
|
-
[Symbol.dispose](): void;
|
|
7
|
-
/**
|
|
8
|
-
* Create a new JIT worker context with custom configuration.
|
|
9
|
-
*
|
|
10
|
-
* # Arguments
|
|
11
|
-
* * `min_block_size` - Minimum number of instructions for JIT compilation
|
|
12
|
-
* * `debug_wat` - Enable debug WAT output
|
|
13
|
-
*/
|
|
14
|
-
static newWithConfig(min_block_size: number, debug_wat: boolean): JitWorkerContext;
|
|
15
|
-
/**
|
|
16
|
-
* Create a new JIT worker context with default configuration.
|
|
17
|
-
*/
|
|
18
|
-
constructor();
|
|
19
|
-
/**
|
|
20
|
-
* Compile a block from serialized request bytes.
|
|
21
|
-
*
|
|
22
|
-
* # Arguments
|
|
23
|
-
* * `request_bytes` - Bincode-serialized `CompileRequest`
|
|
24
|
-
*
|
|
25
|
-
* # Returns
|
|
26
|
-
* A JavaScript object with the compilation result:
|
|
27
|
-
* - On success: `{ success: true, pc: number, wasmBytes: Uint8Array }`
|
|
28
|
-
* - On unsuitable: `{ success: false, pc: number, status: 'unsuitable' }`
|
|
29
|
-
* - On error: `{ success: false, pc: number, status: 'error' }`
|
|
30
|
-
*/
|
|
31
|
-
compile(request_bytes: Uint8Array): any;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
4
|
/**
|
|
35
5
|
* Network connection status for the WASM VM.
|
|
36
6
|
*/
|
|
@@ -61,17 +31,13 @@ declare class WasmVm {
|
|
|
61
31
|
*/
|
|
62
32
|
print_status(message: string): void;
|
|
63
33
|
/**
|
|
64
|
-
*
|
|
65
|
-
*/
|
|
66
|
-
reenableJit(): void;
|
|
67
|
-
/**
|
|
68
|
-
* Get JIT statistics as JSON string.
|
|
34
|
+
* Get CPU count (from kernel-reported value).
|
|
69
35
|
*/
|
|
70
|
-
|
|
36
|
+
get_cpu_count(): number;
|
|
71
37
|
/**
|
|
72
|
-
*
|
|
38
|
+
* Get system uptime in milliseconds (from kernel-reported value).
|
|
73
39
|
*/
|
|
74
|
-
|
|
40
|
+
get_uptime_ms(): bigint;
|
|
75
41
|
/**
|
|
76
42
|
* Start worker threads for secondary harts (1..num_harts).
|
|
77
43
|
*
|
|
@@ -83,13 +49,15 @@ declare class WasmVm {
|
|
|
83
49
|
*/
|
|
84
50
|
start_workers(worker_url: string): void;
|
|
85
51
|
/**
|
|
86
|
-
*
|
|
52
|
+
* Get disk usage from the guest kernel.
|
|
53
|
+
* Returns (used_bytes, total_bytes).
|
|
87
54
|
*/
|
|
88
|
-
|
|
55
|
+
get_disk_usage(): Array<any>;
|
|
89
56
|
/**
|
|
90
|
-
*
|
|
57
|
+
* Get heap memory usage from the guest kernel.
|
|
58
|
+
* Returns (used_bytes, total_bytes).
|
|
91
59
|
*/
|
|
92
|
-
|
|
60
|
+
get_heap_usage(): Array<any>;
|
|
93
61
|
/**
|
|
94
62
|
* Get the current network connection status.
|
|
95
63
|
* This checks the actual connection state by seeing if an IP was assigned.
|
|
@@ -103,39 +71,20 @@ declare class WasmVm {
|
|
|
103
71
|
* * `num_harts` - Number of harts (0 = auto-detect)
|
|
104
72
|
*/
|
|
105
73
|
static new_with_harts(kernel: Uint8Array, num_harts: number): WasmVm;
|
|
106
|
-
/**
|
|
107
|
-
* Clear JIT cache.
|
|
108
|
-
*/
|
|
109
|
-
clearJitCache(): void;
|
|
110
|
-
/**
|
|
111
|
-
* Enable or disable JIT compilation.
|
|
112
|
-
*/
|
|
113
|
-
setJitEnabled(enabled: boolean): void;
|
|
114
|
-
/**
|
|
115
|
-
* Enable or disable JIT execution tracing.
|
|
116
|
-
*/
|
|
117
|
-
setJitTracing(enabled: boolean): void;
|
|
118
74
|
/**
|
|
119
75
|
* Get current memory usage (DRAM size) in bytes.
|
|
120
76
|
*/
|
|
121
77
|
get_memory_usage(): bigint;
|
|
122
78
|
/**
|
|
123
|
-
*
|
|
79
|
+
* Get the total disk capacity from attached VirtIO block devices.
|
|
80
|
+
* Returns total bytes across all block devices.
|
|
124
81
|
*/
|
|
125
|
-
|
|
126
|
-
/**
|
|
127
|
-
* Get current JIT compilation threshold.
|
|
128
|
-
*/
|
|
129
|
-
getJitThreshold(): number;
|
|
82
|
+
get_disk_capacity(): bigint;
|
|
130
83
|
/**
|
|
131
84
|
* Get the SharedArrayBuffer for external worker management.
|
|
132
85
|
* Returns None if not in SMP mode.
|
|
133
86
|
*/
|
|
134
87
|
get_shared_buffer(): SharedArrayBuffer | undefined;
|
|
135
|
-
/**
|
|
136
|
-
* Set JIT compilation threshold (min exec_count before compiling).
|
|
137
|
-
*/
|
|
138
|
-
setJitThreshold(threshold: number): void;
|
|
139
88
|
/**
|
|
140
89
|
* Terminate all workers.
|
|
141
90
|
*/
|
|
@@ -144,22 +93,6 @@ declare class WasmVm {
|
|
|
144
93
|
* Disconnect from the network.
|
|
145
94
|
*/
|
|
146
95
|
disconnect_network(): void;
|
|
147
|
-
/**
|
|
148
|
-
* Get number of cached JIT blocks.
|
|
149
|
-
*/
|
|
150
|
-
getJitCacheSize(): number;
|
|
151
|
-
/**
|
|
152
|
-
* Add a PC to the JIT blacklist.
|
|
153
|
-
*/
|
|
154
|
-
blacklistJitBlock(pc: bigint): void;
|
|
155
|
-
/**
|
|
156
|
-
* Clear the JIT blacklist.
|
|
157
|
-
*/
|
|
158
|
-
clearJitBlacklist(): void;
|
|
159
|
-
/**
|
|
160
|
-
* Get JIT diagnostics as JSON string.
|
|
161
|
-
*/
|
|
162
|
-
getJitDiagnostics(): string;
|
|
163
96
|
/**
|
|
164
97
|
* Check how many bytes are pending in the UART output buffer.
|
|
165
98
|
* Useful for debugging output issues.
|
|
@@ -175,10 +108,6 @@ declare class WasmVm {
|
|
|
175
108
|
* Called from JavaScript when the native WebTransport addon receives a packet.
|
|
176
109
|
*/
|
|
177
110
|
inject_network_packet(packet: Uint8Array): boolean;
|
|
178
|
-
/**
|
|
179
|
-
* Enable TLB fast-path optimization.
|
|
180
|
-
*/
|
|
181
|
-
setJitTlbFastPath(enabled: boolean): void;
|
|
182
111
|
/**
|
|
183
112
|
* Signal that workers can start executing.
|
|
184
113
|
* Called by the main thread after hart 0 has finished initializing
|
|
@@ -190,14 +119,6 @@ declare class WasmVm {
|
|
|
190
119
|
* Returns the packet data or null if no packet is pending.
|
|
191
120
|
*/
|
|
192
121
|
extract_network_packet(): Uint8Array | undefined;
|
|
193
|
-
/**
|
|
194
|
-
* Check if JIT tracing is enabled.
|
|
195
|
-
*/
|
|
196
|
-
isJitTracingEnabled(): boolean;
|
|
197
|
-
/**
|
|
198
|
-
* Set maximum block size for JIT compilation.
|
|
199
|
-
*/
|
|
200
|
-
setJitMaxBlockSize(size: number): void;
|
|
201
122
|
/**
|
|
202
123
|
* Set up an external network backend for packet bridging.
|
|
203
124
|
* This is used by the Node.js CLI to bridge packets between the native
|
|
@@ -206,28 +127,11 @@ declare class WasmVm {
|
|
|
206
127
|
* @param mac_bytes - MAC address as 6 bytes [0x52, 0x54, 0x00, 0x12, 0x34, 0x56]
|
|
207
128
|
*/
|
|
208
129
|
setup_external_network(mac_bytes: Uint8Array): void;
|
|
209
|
-
/**
|
|
210
|
-
* Get JIT cache hit ratio.
|
|
211
|
-
*/
|
|
212
|
-
getJitCacheHitRatio(): number;
|
|
213
|
-
/**
|
|
214
|
-
* Get JIT execution ratio (JIT executions / total executions).
|
|
215
|
-
* Calculated from CPU's block cache statistics.
|
|
216
|
-
*/
|
|
217
|
-
getJitExecutionRatio(): number;
|
|
218
|
-
/**
|
|
219
|
-
* Invalidate JIT cache for a specific address.
|
|
220
|
-
*/
|
|
221
|
-
invalidateJitCacheAt(pc: bigint): boolean;
|
|
222
130
|
/**
|
|
223
131
|
* Set the assigned IP address for the external network.
|
|
224
132
|
* Called when the native WebTransport addon receives an IP assignment.
|
|
225
133
|
*/
|
|
226
134
|
set_external_network_ip(ip_bytes: Uint8Array): boolean;
|
|
227
|
-
/**
|
|
228
|
-
* Get JIT cache memory usage in bytes.
|
|
229
|
-
*/
|
|
230
|
-
getJitCacheMemoryUsage(): number;
|
|
231
135
|
/**
|
|
232
136
|
* Get the number of pending RX packets.
|
|
233
137
|
*/
|
|
@@ -245,10 +149,6 @@ declare class WasmVm {
|
|
|
245
149
|
* Check if external network is connected (has IP assigned).
|
|
246
150
|
*/
|
|
247
151
|
is_external_network_connected(): boolean;
|
|
248
|
-
/**
|
|
249
|
-
* Set interrupt check interval (0 = disabled).
|
|
250
|
-
*/
|
|
251
|
-
setJitInterruptCheckInterval(interval: number): void;
|
|
252
152
|
/**
|
|
253
153
|
* Create a new VM instance and load a kernel (ELF or raw binary).
|
|
254
154
|
*
|
|
@@ -384,39 +284,27 @@ type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Modul
|
|
|
384
284
|
|
|
385
285
|
interface InitOutput {
|
|
386
286
|
readonly memory: WebAssembly.Memory;
|
|
387
|
-
readonly __wbg_jitworkercontext_free: (a: number, b: number) => void;
|
|
388
287
|
readonly __wbg_wasmvm_free: (a: number, b: number) => void;
|
|
389
288
|
readonly __wbg_workerstate_free: (a: number, b: number) => void;
|
|
390
|
-
readonly jitworkercontext_compile: (a: number, b: number, c: number) => any;
|
|
391
|
-
readonly jitworkercontext_new: () => number;
|
|
392
|
-
readonly jitworkercontext_newWithConfig: (a: number, b: number) => number;
|
|
393
289
|
readonly wasmvm_allow_workers_to_start: (a: number) => void;
|
|
394
|
-
readonly wasmvm_blacklistJitBlock: (a: number, b: bigint) => void;
|
|
395
|
-
readonly wasmvm_clearJitBlacklist: (a: number) => void;
|
|
396
|
-
readonly wasmvm_clearJitCache: (a: number) => void;
|
|
397
290
|
readonly wasmvm_connect_webtransport: (a: number, b: number, c: number, d: number, e: number) => [number, number];
|
|
398
291
|
readonly wasmvm_disconnect_network: (a: number) => void;
|
|
399
|
-
readonly wasmvm_dumpJitTrace: (a: number, b: number) => void;
|
|
400
292
|
readonly wasmvm_entry_pc: (a: number) => bigint;
|
|
401
293
|
readonly wasmvm_external_network_rx_pending: (a: number) => number;
|
|
402
294
|
readonly wasmvm_external_network_tx_pending: (a: number) => number;
|
|
403
295
|
readonly wasmvm_extract_all_network_packets: (a: number) => any;
|
|
404
296
|
readonly wasmvm_extract_network_packet: (a: number) => any;
|
|
405
|
-
readonly
|
|
406
|
-
readonly
|
|
407
|
-
readonly
|
|
408
|
-
readonly
|
|
409
|
-
readonly wasmvm_getJitStats: (a: number) => [number, number];
|
|
410
|
-
readonly wasmvm_getJitThreshold: (a: number) => number;
|
|
297
|
+
readonly wasmvm_get_cpu_count: (a: number) => number;
|
|
298
|
+
readonly wasmvm_get_disk_capacity: (a: number) => bigint;
|
|
299
|
+
readonly wasmvm_get_disk_usage: (a: number) => any;
|
|
300
|
+
readonly wasmvm_get_heap_usage: (a: number) => any;
|
|
411
301
|
readonly wasmvm_get_memory_usage: (a: number) => bigint;
|
|
412
302
|
readonly wasmvm_get_output: (a: number) => number;
|
|
413
303
|
readonly wasmvm_get_shared_buffer: (a: number) => any;
|
|
304
|
+
readonly wasmvm_get_uptime_ms: (a: number) => bigint;
|
|
414
305
|
readonly wasmvm_halt_code: (a: number) => bigint;
|
|
415
306
|
readonly wasmvm_inject_network_packet: (a: number, b: any) => number;
|
|
416
307
|
readonly wasmvm_input: (a: number, b: number) => void;
|
|
417
|
-
readonly wasmvm_invalidateJitCacheAt: (a: number, b: bigint) => number;
|
|
418
|
-
readonly wasmvm_isJitEnabled: (a: number) => number;
|
|
419
|
-
readonly wasmvm_isJitTracingEnabled: (a: number) => number;
|
|
420
308
|
readonly wasmvm_is_external_network_connected: (a: number) => number;
|
|
421
309
|
readonly wasmvm_is_halted: (a: number) => number;
|
|
422
310
|
readonly wasmvm_is_smp: (a: number) => number;
|
|
@@ -427,15 +315,6 @@ interface InitOutput {
|
|
|
427
315
|
readonly wasmvm_num_harts: (a: number) => number;
|
|
428
316
|
readonly wasmvm_print_banner: (a: number) => void;
|
|
429
317
|
readonly wasmvm_print_status: (a: number, b: number, c: number) => void;
|
|
430
|
-
readonly wasmvm_reenableJit: (a: number) => void;
|
|
431
|
-
readonly wasmvm_resetJitErrors: (a: number) => void;
|
|
432
|
-
readonly wasmvm_setJitDebug: (a: number, b: number) => void;
|
|
433
|
-
readonly wasmvm_setJitEnabled: (a: number, b: number) => void;
|
|
434
|
-
readonly wasmvm_setJitInterruptCheckInterval: (a: number, b: number) => void;
|
|
435
|
-
readonly wasmvm_setJitMaxBlockSize: (a: number, b: number) => void;
|
|
436
|
-
readonly wasmvm_setJitThreshold: (a: number, b: number) => void;
|
|
437
|
-
readonly wasmvm_setJitTlbFastPath: (a: number, b: number) => void;
|
|
438
|
-
readonly wasmvm_setJitTracing: (a: number, b: number) => void;
|
|
439
318
|
readonly wasmvm_set_external_network_ip: (a: number, b: any) => number;
|
|
440
319
|
readonly wasmvm_setup_external_network: (a: number, b: any) => [number, number];
|
|
441
320
|
readonly wasmvm_start_workers: (a: number, b: number, c: number) => [number, number];
|
|
@@ -449,13 +328,12 @@ interface InitOutput {
|
|
|
449
328
|
readonly workerstate_new: (a: number, b: any, c: bigint) => number;
|
|
450
329
|
readonly workerstate_step_batch: (a: number, b: number) => number;
|
|
451
330
|
readonly workerstate_step_count: (a: number) => bigint;
|
|
452
|
-
readonly
|
|
453
|
-
readonly
|
|
454
|
-
readonly wasm_bindgen__closure__destroy__h1292c9e7657b72ef: (a: number, b: number) => void;
|
|
455
|
-
readonly wasm_bindgen__convert__closures_____invoke__h3eb569f20d255f19: (a: number, b: number) => void;
|
|
331
|
+
readonly wasm_bindgen__convert__closures_____invoke__h585740b37ab67ddc: (a: number, b: number) => void;
|
|
332
|
+
readonly wasm_bindgen__closure__destroy__h37d1b5fcb52cb1b9: (a: number, b: number) => void;
|
|
456
333
|
readonly wasm_bindgen__convert__closures_____invoke__h39d3e89751b07765: (a: number, b: number, c: any) => void;
|
|
457
334
|
readonly wasm_bindgen__closure__destroy__hf225e18fc5ab9bc1: (a: number, b: number) => void;
|
|
458
|
-
readonly
|
|
335
|
+
readonly wasm_bindgen__convert__closures_____invoke__hc7b58d5dcf05d71f: (a: number, b: number, c: any) => void;
|
|
336
|
+
readonly wasm_bindgen__convert__closures_____invoke__he5e8d2a2af985b7e: (a: number, b: number) => void;
|
|
459
337
|
readonly __wbindgen_malloc: (a: number, b: number) => number;
|
|
460
338
|
readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
|
|
461
339
|
readonly __wbindgen_exn_store: (a: number) => void;
|
|
@@ -490,8 +368,6 @@ declare function __wbg_init (module_or_path?: { module_or_path: InitInput | Prom
|
|
|
490
368
|
|
|
491
369
|
type __pkg_riscv_vm_InitInput = InitInput;
|
|
492
370
|
type __pkg_riscv_vm_InitOutput = InitOutput;
|
|
493
|
-
type __pkg_riscv_vm_JitWorkerContext = JitWorkerContext;
|
|
494
|
-
declare const __pkg_riscv_vm_JitWorkerContext: typeof JitWorkerContext;
|
|
495
371
|
type __pkg_riscv_vm_NetworkStatus = NetworkStatus;
|
|
496
372
|
declare const __pkg_riscv_vm_NetworkStatus: typeof NetworkStatus;
|
|
497
373
|
type __pkg_riscv_vm_SyncInitInput = SyncInitInput;
|
|
@@ -505,7 +381,7 @@ declare const __pkg_riscv_vm_initSync: typeof initSync;
|
|
|
505
381
|
declare const __pkg_riscv_vm_worker_check_interrupts: typeof worker_check_interrupts;
|
|
506
382
|
declare const __pkg_riscv_vm_worker_entry: typeof worker_entry;
|
|
507
383
|
declare namespace __pkg_riscv_vm {
|
|
508
|
-
export { type __pkg_riscv_vm_InitInput as InitInput, type __pkg_riscv_vm_InitOutput as InitOutput,
|
|
384
|
+
export { type __pkg_riscv_vm_InitInput as InitInput, type __pkg_riscv_vm_InitOutput as InitOutput, __pkg_riscv_vm_NetworkStatus as NetworkStatus, type __pkg_riscv_vm_SyncInitInput as SyncInitInput, __pkg_riscv_vm_WasmVm as WasmVm, __pkg_riscv_vm_WorkerState as WorkerState, __pkg_riscv_vm_WorkerStepResult as WorkerStepResult, __wbg_init as default, __pkg_riscv_vm_initSync as initSync, __pkg_riscv_vm_worker_check_interrupts as worker_check_interrupts, __pkg_riscv_vm_worker_entry as worker_entry };
|
|
509
385
|
}
|
|
510
386
|
|
|
511
387
|
/**
|
|
@@ -558,209 +434,6 @@ declare function isHalted(sharedMem: SharedArrayBuffer): boolean;
|
|
|
558
434
|
|
|
559
435
|
declare function WasmInternal(): Promise<typeof __pkg_riscv_vm>;
|
|
560
436
|
|
|
561
|
-
/**
|
|
562
|
-
* Message sent to JIT worker to request compilation.
|
|
563
|
-
*/
|
|
564
|
-
interface JitCompileRequest {
|
|
565
|
-
type: "compile";
|
|
566
|
-
/** Starting PC of the block */
|
|
567
|
-
pc: number;
|
|
568
|
-
/** Bincode-serialized CompileRequest bytes */
|
|
569
|
-
requestBytes: ArrayBuffer;
|
|
570
|
-
}
|
|
571
|
-
/**
|
|
572
|
-
*
|
|
573
|
-
*
|
|
574
|
-
* Message received from JIT worker with compilation result.
|
|
575
|
-
*/
|
|
576
|
-
interface JitCompileResponse {
|
|
577
|
-
type: "compiled";
|
|
578
|
-
/** Starting PC of the compiled block */
|
|
579
|
-
pc: number;
|
|
580
|
-
/** Whether compilation succeeded */
|
|
581
|
-
success: boolean;
|
|
582
|
-
/** Compiled WASM bytes (if successful) */
|
|
583
|
-
wasmBytes?: Uint8Array;
|
|
584
|
-
/** Status if not successful */
|
|
585
|
-
status?: "unsuitable" | "error";
|
|
586
|
-
/** Compilation time in microseconds */
|
|
587
|
-
compileTimeUs?: number;
|
|
588
|
-
}
|
|
589
|
-
/**
|
|
590
|
-
* JIT worker ready message.
|
|
591
|
-
*/
|
|
592
|
-
interface JitWorkerReadyMessage {
|
|
593
|
-
type: "ready";
|
|
594
|
-
}
|
|
595
|
-
/**
|
|
596
|
-
* JIT worker error message.
|
|
597
|
-
*/
|
|
598
|
-
interface JitWorkerErrorMessage {
|
|
599
|
-
type: "error";
|
|
600
|
-
message: string;
|
|
601
|
-
}
|
|
602
|
-
/**
|
|
603
|
-
* All possible JIT worker outbound messages.
|
|
604
|
-
*/
|
|
605
|
-
type JitWorkerOutboundMessage = JitCompileResponse | JitWorkerReadyMessage | JitWorkerErrorMessage;
|
|
606
|
-
/**
|
|
607
|
-
* All possible JIT worker inbound messages.
|
|
608
|
-
*/
|
|
609
|
-
type JitWorkerInboundMessage = JitCompileRequest;
|
|
610
|
-
/**
|
|
611
|
-
* Cache statistics from the JIT system.
|
|
612
|
-
*/
|
|
613
|
-
interface JitCacheStats {
|
|
614
|
-
/** Number of cache hits */
|
|
615
|
-
hits: number;
|
|
616
|
-
/** Number of cache misses */
|
|
617
|
-
misses: number;
|
|
618
|
-
/** Number of blocks inserted into cache */
|
|
619
|
-
insertions: number;
|
|
620
|
-
/** Number of blocks evicted from cache */
|
|
621
|
-
evictions: number;
|
|
622
|
-
/** Total bytes of WASM compiled */
|
|
623
|
-
bytesCompiled: number;
|
|
624
|
-
/** Number of cache invalidations */
|
|
625
|
-
invalidations: number;
|
|
626
|
-
}
|
|
627
|
-
/**
|
|
628
|
-
* Execution trace statistics.
|
|
629
|
-
*/
|
|
630
|
-
interface JitTraceStats {
|
|
631
|
-
/** Number of JIT block executions */
|
|
632
|
-
jitExecutions: number;
|
|
633
|
-
/** Number of interpreter block executions */
|
|
634
|
-
interpExecutions: number;
|
|
635
|
-
/** Number of successful compilations */
|
|
636
|
-
compilations: number;
|
|
637
|
-
/** Number of failed compilations */
|
|
638
|
-
compilationFailures: number;
|
|
639
|
-
/** Total WASM bytes compiled */
|
|
640
|
-
totalWasmBytes: number;
|
|
641
|
-
/** Total compilation time in microseconds */
|
|
642
|
-
totalCompileTimeUs: number;
|
|
643
|
-
/** Number of traps during JIT execution */
|
|
644
|
-
traps: number;
|
|
645
|
-
/** Number of cache invalidations */
|
|
646
|
-
invalidations: number;
|
|
647
|
-
/** Number of cache hits */
|
|
648
|
-
cacheHits: number;
|
|
649
|
-
/** Number of cache misses */
|
|
650
|
-
cacheMisses: number;
|
|
651
|
-
/** Number of interrupt-triggered exits */
|
|
652
|
-
interruptExits: number;
|
|
653
|
-
}
|
|
654
|
-
/**
|
|
655
|
-
* Complete JIT diagnostics information.
|
|
656
|
-
*/
|
|
657
|
-
interface JitDiagnostics {
|
|
658
|
-
/** Whether JIT is currently enabled and operational */
|
|
659
|
-
enabled: boolean;
|
|
660
|
-
/** Whether JIT was disabled due to errors */
|
|
661
|
-
disabledByError: boolean;
|
|
662
|
-
/** Reason JIT was disabled (if applicable) */
|
|
663
|
-
disabledReason: string | null;
|
|
664
|
-
/** Number of consecutive compilation failures */
|
|
665
|
-
consecutiveFailures: number;
|
|
666
|
-
/** Total number of compilation failures */
|
|
667
|
-
totalFailures: number;
|
|
668
|
-
/** Total number of successful compilations */
|
|
669
|
-
successfulCompilations: number;
|
|
670
|
-
/** Number of blocks that failed to compile (blacklisted) */
|
|
671
|
-
failedBlocksCount: number;
|
|
672
|
-
/** Number of blocks currently in cache */
|
|
673
|
-
cacheEntries: number;
|
|
674
|
-
/** Current cache memory usage in bytes */
|
|
675
|
-
cacheBytes: number;
|
|
676
|
-
/** Cache statistics */
|
|
677
|
-
cacheStats: JitCacheStats;
|
|
678
|
-
/** Trace statistics */
|
|
679
|
-
traceStats: JitTraceStats;
|
|
680
|
-
}
|
|
681
|
-
/**
|
|
682
|
-
* JIT configuration options.
|
|
683
|
-
*/
|
|
684
|
-
interface JitConfig {
|
|
685
|
-
/** Enable JIT compilation (default: true) */
|
|
686
|
-
enabled?: boolean;
|
|
687
|
-
/** Minimum execution count before compiling (default: 50) */
|
|
688
|
-
compileThreshold?: number;
|
|
689
|
-
/** Maximum block size in ops (default: 256) */
|
|
690
|
-
maxBlockSize?: number;
|
|
691
|
-
/** Maximum WASM module size in bytes (default: 65536) */
|
|
692
|
-
maxWasmSize?: number;
|
|
693
|
-
/** Maximum cache entries (default: 1024) */
|
|
694
|
-
cacheMaxEntries?: number;
|
|
695
|
-
/** Maximum cache size in bytes (default: 16MB) */
|
|
696
|
-
cacheMaxBytes?: number;
|
|
697
|
-
/** Enable debug WAT output to console (default: false) */
|
|
698
|
-
debugWat?: boolean;
|
|
699
|
-
/** Enable execution tracing (default: false) */
|
|
700
|
-
traceEnabled?: boolean;
|
|
701
|
-
/** Compilation timeout in ms (default: 100, 0=no timeout) */
|
|
702
|
-
compileTimeoutMs?: number;
|
|
703
|
-
/** Max consecutive failures before disabling (default: 10) */
|
|
704
|
-
maxConsecutiveFailures?: number;
|
|
705
|
-
/** Enable TLB fast-path optimization (default: false) */
|
|
706
|
-
enableTlbFastPath?: boolean;
|
|
707
|
-
/** Interrupt check interval in ops (default: 32, 0=disabled) */
|
|
708
|
-
interruptCheckInterval?: number;
|
|
709
|
-
}
|
|
710
|
-
/**
|
|
711
|
-
* Extended WasmVm interface with JIT methods.
|
|
712
|
-
*
|
|
713
|
-
* This interface extends the base WasmVm class exported from the WASM module
|
|
714
|
-
* with type definitions for all JIT-related methods.
|
|
715
|
-
*/
|
|
716
|
-
interface WasmVmJitMethods {
|
|
717
|
-
/** Enable or disable JIT compilation */
|
|
718
|
-
setJitEnabled(enabled: boolean): void;
|
|
719
|
-
/** Check if JIT is currently enabled and operational */
|
|
720
|
-
isJitEnabled(): boolean;
|
|
721
|
-
/** Re-enable JIT after it was disabled by errors */
|
|
722
|
-
reenableJit(): void;
|
|
723
|
-
/** Enable/disable JIT debug WAT output to console */
|
|
724
|
-
setJitDebug(debug: boolean): void;
|
|
725
|
-
/** Enable/disable JIT execution tracing */
|
|
726
|
-
setJitTracing(enabled: boolean): void;
|
|
727
|
-
/** Check if JIT tracing is enabled */
|
|
728
|
-
isJitTracingEnabled(): boolean;
|
|
729
|
-
/** Get JIT diagnostics as JSON string */
|
|
730
|
-
getJitDiagnostics(): string;
|
|
731
|
-
/** Get JIT statistics as JSON string */
|
|
732
|
-
getJitStats(): string;
|
|
733
|
-
/** Dump recent JIT trace events to console */
|
|
734
|
-
dumpJitTrace(count?: number): void;
|
|
735
|
-
/** Clear all entries from JIT cache */
|
|
736
|
-
clearJitCache(): void;
|
|
737
|
-
/** Invalidate JIT cache for a specific PC */
|
|
738
|
-
invalidateJitCacheAt(pc: bigint): boolean;
|
|
739
|
-
/** Get number of cached JIT blocks */
|
|
740
|
-
getJitCacheSize(): number;
|
|
741
|
-
/** Get JIT cache memory usage in bytes */
|
|
742
|
-
getJitCacheMemoryUsage(): number;
|
|
743
|
-
/** Set JIT compilation threshold */
|
|
744
|
-
setJitThreshold(threshold: number): void;
|
|
745
|
-
/** Get current JIT compilation threshold */
|
|
746
|
-
getJitThreshold(): number;
|
|
747
|
-
/** Set maximum block size for JIT compilation */
|
|
748
|
-
setJitMaxBlockSize(size: number): void;
|
|
749
|
-
/** Add a PC to the JIT blacklist */
|
|
750
|
-
blacklistJitBlock(pc: bigint): void;
|
|
751
|
-
/** Clear the JIT blacklist */
|
|
752
|
-
clearJitBlacklist(): void;
|
|
753
|
-
/** Reset all JIT error tracking */
|
|
754
|
-
resetJitErrors(): void;
|
|
755
|
-
/** Enable TLB fast-path optimization */
|
|
756
|
-
setJitTlbFastPath(enabled: boolean): void;
|
|
757
|
-
/** Set interrupt check interval (0 = disabled) */
|
|
758
|
-
setJitInterruptCheckInterval(interval: number): void;
|
|
759
|
-
/** Get JIT execution ratio (0.0 to 1.0) */
|
|
760
|
-
getJitExecutionRatio(): number;
|
|
761
|
-
/** Get JIT cache hit ratio (0.0 to 1.0) */
|
|
762
|
-
getJitCacheHitRatio(): number;
|
|
763
|
-
}
|
|
764
437
|
interface VmOptions {
|
|
765
438
|
/** Number of harts (auto-detected if not specified) */
|
|
766
439
|
harts?: number;
|
|
@@ -848,35 +521,5 @@ interface WorkerManager {
|
|
|
848
521
|
* Create a worker manager for manual worker control.
|
|
849
522
|
*/
|
|
850
523
|
declare function createWorkerManager(): WorkerManager;
|
|
851
|
-
/**
|
|
852
|
-
* Parse JIT diagnostics from the VM.
|
|
853
|
-
*
|
|
854
|
-
* @param vm - WasmVm instance with JIT methods
|
|
855
|
-
* @returns Parsed JIT diagnostics object
|
|
856
|
-
*/
|
|
857
|
-
declare function parseJitDiagnostics(vm: WasmVmJitMethods): JitDiagnostics;
|
|
858
|
-
/**
|
|
859
|
-
* Parse JIT trace statistics from the VM.
|
|
860
|
-
*
|
|
861
|
-
* @param vm - WasmVm instance with JIT methods
|
|
862
|
-
* @returns Parsed JIT trace statistics object
|
|
863
|
-
*/
|
|
864
|
-
declare function parseJitStats(vm: WasmVmJitMethods): JitTraceStats;
|
|
865
|
-
/**
|
|
866
|
-
* Configure JIT with a partial configuration object.
|
|
867
|
-
*
|
|
868
|
-
* @param vm - WasmVm instance with JIT methods
|
|
869
|
-
* @param config - Partial JIT configuration
|
|
870
|
-
*/
|
|
871
|
-
declare function configureJit(vm: WasmVmJitMethods, config: JitConfig): void;
|
|
872
|
-
/**
|
|
873
|
-
* Print JIT diagnostic summary to console.
|
|
874
|
-
*
|
|
875
|
-
* Displays a formatted summary of JIT status, compilations,
|
|
876
|
-
* cache statistics, and hit ratios.
|
|
877
|
-
*
|
|
878
|
-
* @param vm - WasmVm instance with JIT methods
|
|
879
|
-
*/
|
|
880
|
-
declare function printJitSummary(vm: WasmVmJitMethods): void;
|
|
881
524
|
|
|
882
|
-
export {
|
|
525
|
+
export { NetworkStatus, REQUIRED_HEADERS, type SharedMemorySupport, type VmOptions, WasmInternal, WasmVm, type WorkerErrorMessage, type WorkerHaltedMessage, type WorkerInitMessage, type WorkerManager, type WorkerOutboundMessage, type WorkerReadyMessage, checkSharedMemorySupport, createVM, createWorkerManager, isCrossOriginIsolated, isHaltRequested, isHalted, requestHalt, runVM };
|