Run arbitrary WASM/WASI files
$ npm install wasm-run -g
$ wasm-run --help
wasm-run [options] <file> [--] [args..]
Options:
-i, --invoke Function to execute [string]
-t, --timeout Execution timeout (ms)
--trace Trace imported function calls [boolean]
--gas-limit Gas limit [default: 100000]
--version Show version number [boolean]
--help Show help [boolean]
$ wasm-run ./test/fib32.wasm 32
[runtime] Running fib(32)...
[runtime] Result: 2178309
$ wasm-run --invoke=swap_i64 ./test/swap.wat 10 12
[runtime] Converted to binary (256 bytes)
[runtime] Running swap_i64(10,12)...
[runtime] Result: 12,10
$ wasm-run wasi-hello-world.wasm
Hello world!
$ wasm-run --trace wasi-hello-world.wasm
[runtime] wasi_snapshot_preview1!fd_prestat_get 3,65528 => 0
[runtime] wasi_snapshot_preview1!fd_prestat_dir_name 3,70064,2 => 0
[runtime] wasi_snapshot_preview1!fd_prestat_get 4,65528 => 0
[runtime] wasi_snapshot_preview1!fd_prestat_dir_name 4,70064,2 => 0
...
wasm-meter
can be installed via npm install wasm-metering -g
$ wasm-meter fib64.wasm fib64.metered.wasm
$ wasm-run fib64.metered.wasm 8
[runtime] Running fib(8)...
[runtime] Result: 21
[runtime] Gas used: 5.1874
$ wasm-run fib64.metered.wasm 30
[runtime] Running fib(30)...
[runtime] Error: Run out of gas (gas used: 100000.0177)
☑ Load wasm
and wat
files (using Binaryen
)
☑ Run specific exported function
☑ Run wasi-snapshot-preview1
apps via --experimental-wasi-unstable-preview1
flag
☑ Run wasi-unstable
apps (compatibility layer)
☑ i64
args, multi-value
, bulk-memory
, tail-calls
support via experimental flags
☑ Generic imports tracing
☑ Gas metering/limiting
☐ Compiled wasm caching (blocked by #1)
☐ WASI API and structures decoding (generate from witx?)
☐ REPL mode
Author: wasm3
Download Link: Download The Source Code
Official Website: https://github.com/wasm3/node-wasm-run
License: MIT
#javascript #wasm #webassembly #node #nodejs