virtual-machine 0.0.36 → 0.0.37
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-YJ5P3VGQ.mjs → chunk-ASAZFOYQ.mjs} +39 -17
- package/build/cli.js +110 -35
- package/build/index.d.ts +26 -4
- package/build/index.js +43 -19
- package/build/index.mjs +6 -4
- package/build/node-worker.js +120 -0
- package/build/{riscv_vm-HSOJGHGR.mjs → riscv_vm-RB3UJCQZ.mjs} +1 -1
- package/build/worker.js +64 -47
- 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 -1
package/build/index.d.ts
CHANGED
|
@@ -85,6 +85,12 @@ declare class WasmVm {
|
|
|
85
85
|
* Called from JavaScript when the native WebTransport addon receives a packet.
|
|
86
86
|
*/
|
|
87
87
|
inject_network_packet(packet: Uint8Array): boolean;
|
|
88
|
+
/**
|
|
89
|
+
* Signal that workers can start executing.
|
|
90
|
+
* Called by the main thread after hart 0 has finished initializing
|
|
91
|
+
* kernel data structures.
|
|
92
|
+
*/
|
|
93
|
+
allow_workers_to_start(): void;
|
|
88
94
|
/**
|
|
89
95
|
* Extract a network packet sent by the guest.
|
|
90
96
|
* Returns the packet data or null if no packet is pending.
|
|
@@ -155,6 +161,11 @@ declare class WasmVm {
|
|
|
155
161
|
* JS-WASM boundary crossings.
|
|
156
162
|
*/
|
|
157
163
|
step_n(count: number): number;
|
|
164
|
+
/**
|
|
165
|
+
* Get the entry PC address for workers.
|
|
166
|
+
* This is the address where secondary harts should start executing.
|
|
167
|
+
*/
|
|
168
|
+
entry_pc(): bigint;
|
|
158
169
|
/**
|
|
159
170
|
* Get the halt code if the VM has halted.
|
|
160
171
|
* Code 0x5555 typically means successful shutdown (PASS).
|
|
@@ -185,6 +196,11 @@ declare class WorkerState {
|
|
|
185
196
|
* the event loop to yield between batches. This prevents the worker
|
|
186
197
|
* from blocking indefinitely and allows it to respond to messages.
|
|
187
198
|
*
|
|
199
|
+
* Performance optimization: We reduce atomic operations by:
|
|
200
|
+
* - Only checking halt signals every HALT_CHECK_INTERVAL instructions
|
|
201
|
+
* - Only checking interrupts every INTERRUPT_CHECK_INTERVAL instructions
|
|
202
|
+
* - Doing a full interrupt check at the end of each batch
|
|
203
|
+
*
|
|
188
204
|
* Returns a WorkerStepResult indicating whether to continue, halt, etc.
|
|
189
205
|
*/
|
|
190
206
|
step_batch(batch_size: number): WorkerStepResult;
|
|
@@ -247,8 +263,10 @@ interface InitOutput {
|
|
|
247
263
|
readonly memory: WebAssembly.Memory;
|
|
248
264
|
readonly __wbg_wasmvm_free: (a: number, b: number) => void;
|
|
249
265
|
readonly __wbg_workerstate_free: (a: number, b: number) => void;
|
|
266
|
+
readonly wasmvm_allow_workers_to_start: (a: number) => void;
|
|
250
267
|
readonly wasmvm_connect_webtransport: (a: number, b: number, c: number, d: number, e: number) => [number, number];
|
|
251
268
|
readonly wasmvm_disconnect_network: (a: number) => void;
|
|
269
|
+
readonly wasmvm_entry_pc: (a: number) => bigint;
|
|
252
270
|
readonly wasmvm_external_network_rx_pending: (a: number) => number;
|
|
253
271
|
readonly wasmvm_external_network_tx_pending: (a: number) => number;
|
|
254
272
|
readonly wasmvm_extract_all_network_packets: (a: number) => any;
|
|
@@ -282,12 +300,12 @@ interface InitOutput {
|
|
|
282
300
|
readonly workerstate_new: (a: number, b: any, c: bigint) => number;
|
|
283
301
|
readonly workerstate_step_batch: (a: number, b: number) => number;
|
|
284
302
|
readonly workerstate_step_count: (a: number) => bigint;
|
|
303
|
+
readonly wasm_bindgen__convert__closures_____invoke__h633c7630e96bf7ba: (a: number, b: number) => void;
|
|
304
|
+
readonly wasm_bindgen__closure__destroy__h219b6c77d9281450: (a: number, b: number) => void;
|
|
305
|
+
readonly wasm_bindgen__convert__closures_____invoke__h1ead60eaa5163c89: (a: number, b: number) => void;
|
|
285
306
|
readonly wasm_bindgen__convert__closures_____invoke__h39d3e89751b07765: (a: number, b: number, c: any) => void;
|
|
286
307
|
readonly wasm_bindgen__closure__destroy__hf225e18fc5ab9bc1: (a: number, b: number) => void;
|
|
287
|
-
readonly
|
|
288
|
-
readonly wasm_bindgen__closure__destroy__h4a8089319832ef98: (a: number, b: number) => void;
|
|
289
|
-
readonly wasm_bindgen__convert__closures_____invoke__hd016cca7bbf341cd: (a: number, b: number) => void;
|
|
290
|
-
readonly wasm_bindgen__convert__closures_____invoke__h07c9b936df37d4f2: (a: number, b: number, c: any) => void;
|
|
308
|
+
readonly wasm_bindgen__convert__closures_____invoke__hcefed207e507b803: (a: number, b: number, c: any) => void;
|
|
291
309
|
readonly __wbindgen_malloc: (a: number, b: number) => number;
|
|
292
310
|
readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
|
|
293
311
|
readonly __wbindgen_exn_store: (a: number) => void;
|
|
@@ -400,6 +418,10 @@ interface VmOptions {
|
|
|
400
418
|
* If SharedArrayBuffer is available (requires COOP/COEP headers), the VM
|
|
401
419
|
* will run in true parallel mode with Web Workers for secondary harts.
|
|
402
420
|
*
|
|
421
|
+
* NOTE: In WASM, multi-hart mode is significantly slower due to
|
|
422
|
+
* SharedArrayBuffer/Atomics overhead (see tasks/improvements.md).
|
|
423
|
+
* Default is 1 hart unless explicitly specified.
|
|
424
|
+
*
|
|
403
425
|
* @param kernelData - ELF kernel binary
|
|
404
426
|
* @param options - VM configuration options
|
|
405
427
|
* @returns WasmVm instance
|