nx_wasm_vm_bounds_20260912.nx
buildroot/runtime/nx_wasm_vm_bounds_20260912.nx
about
nx_wasm_vm.nx F618 wasm-SIMD FLIP (2026-07-21, landed from the proven rung-1 twin). Adds interpretation of the
0xFD-prefixed wasm-SIMD subset the nx_wasm_v128 emitter produces (v128.load, i8x16.sub_sat_u,
v128.or, i16x8.extadd_pairwise_i8x16_u/_s, i32x4.extadd_pairwise_i16x8_u, i32x4.extract_lane),
byte-level-exact per the spec, so the faithdiff-class differential can prove SIMD == scalar == native.
v128 VALUES ride the untyped i64 stack as POINTERS into a 4096-slot x 16B ring arena (values are
consumed within an op sequence; the SAD kernel holds <=3 live). wm_skip_imm ALSO learns 0xFD --
without that the structured-control forward scanners desync on any function containing SIMD.
FLIPPED into the shared VM 2026-07-21 (F618); nx_v128_gate T2/T3 + faithdiff hold it GREEN.
nx_wasm_vm.nx -- a SOVEREIGN WebAssembly virtual machine: parses a .wasm BINARY and executes its exported functions
over a linear memory, pure NishiLang, no third-party runtime (no node/wasmtime/wasmer). Purpose: close the last
verification gap for shipped wasm -- run the COMPILED nx_vcodec.wasm offline and prove it computes bit-exact to the
gate-proven NATIVE codec (a functional gate on the actual shipped bytes, which most toolchains never do; they trust
the compiler). This is R0+R1: the parser (sections -> module) + a stack-machine executor for the opcode subset our
nx_wat_compiler emits (i32/i64 const/arith/shift/compare, local.get/set/tee, i64/i32 load/store(+8/16), call,
block/loop/if/else/end/br/br_if/br_table/return/drop/select, memory.size/grow, wrap/extend). license_tier: ORIGINAL
dependencies 2 imports · 1 importers
imports: nx_syscalls.nxnx_f32_hw.nx
imported by: nx_wasm_vm_bounds_gate_20260912.nx
structs
| 40 | struct WasmMod |
| 102 | struct WmReader { bytes: *u8, pos: i64, end: i64, error: i64 } |
consts
| 18 | const K_MAGIC_65536: i64 = 65536 |
| 19 | const K_MAGIC_1024: i64 = 1024 |
| 20 | const K_MAGIC_2048: i64 = 2048 |
| 21 | const K_MAGIC_262144: i64 = 262144 |
| 22 | const K_MAGIC_4096: i64 = 4096 |
| 23 | const K_MAGIC_131072: i64 = 131072 |
| 24 | const K_MAGIC_2654435761: i64 = 2654435761 |
| 25 | const K_MAGIC_4000000: i64 = 4000000 |
| 26 | const K_MAGIC_32768: i64 = 32768 |
| 27 | const K_MAGIC_2147483648: i64 = 2147483648 |
| 28 | const K_MAGIC_4294967296: i64 = 4294967296 |
| 29 | const K_MAGIC_4090: i64 = 4090 |
| 30 | const K_MAGIC_65530: i64 = 65530 |
| 31 | const K_MAGIC_262140: i64 = 262140 |
| 32 | const K_MAGIC_999999: i64 = 999999 |
| 99 | const WMP_U32_BYTES: i64 = 5 |
| 100 | const WMP_PAGE_BYTES: i64 = 65536 |
| 101 | const WMP_WASM32_PAGES: i64 = 65536 |
functions
| 72 | func wv_u8(b: *u8, pos: *i64) -> i64 { let p: i64 = pos[0]; pos[0] = p + 1; return b[p] as i64 } |
| 73 | func wv_uleb(b: *u8, pos: *i64) -> i64 |
| 83 | func wv_sleb(b: *u8, pos: *i64) -> i64 |
| 103 | func wmp_u8(r: *WmReader) -> i64 |
| 110 | func wmp_u32(r: *WmReader) -> i64 |
| 122 | func wmp_skip(r: *WmReader, n: i64) -> i64 |
| 127 | func wmp_count(r: *WmReader, minimum_bytes: i64) -> i64 |
| 132 | func wmp_valtype(v: i64) -> i64 |
| 136 | func wmp_limits(r: *WmReader, memory: i64) -> i64 |
| 149 | func wmp_params(b: *u8, start: i64, end: i64, wanted: i64, r: *WmReader) -> i64 |
| 162 | func wmp_scan(mod: *WasmMod, fill: i64) -> i64 |
| 281 | func wmp_array(count: i64) -> *i64 { return sys_mmap((count + 1) * 8) as *i64 } |
| 282 | func wm_parse(mod: *WasmMod) -> i64 |
| 300 | func wm_name_eq(b: *u8, off: i64, len: i64, needle: *u8) -> i64 |
| 307 | func wm_find_export(mod: *WasmMod, needle: *u8) -> i64 |
| 318 | func wm_new(bytes: *u8, len: i64) -> *WasmMod |
| 338 | func wm_memo_get(mod: *WasmMod, key: i64) -> i64 |
| 351 | func wm_memo_put(mod: *WasmMod, key: i64, val: i64) -> i64 |
| 367 | func wm_ld64(m: *u8, a: i64) -> i64 { var v: i64=0; var i: i64=0; while i<8 { v = v | ((m[a+i] as i64) << (i*8)); i=i+1 } return v } |
| 368 | func wm_st64(m: *u8, a: i64, v: i64) -> i64 { var i: i64=0; while i<8 { m[a+i] = ((v >> (i*8)) & 0xFF) as u8; i=i+1 } return 0 } |
| 370 | func wm_ld32(m: *u8, a: i64) -> i64 { var v: i64=0; var i: i64=0; while i<4 { v = v | ((m[a+i] as i64) << (i*8)); i=i+1 } return v } |
| 371 | func wm_st32(m: *u8, a: i64, v: i64) -> i64 { var i: i64=0; while i<4 { m[a+i] = ((v >> (i*8)) & 0xFF) as u8; i=i+1 } return 0 } |
| 374 | func wm_skip_imm(b: *u8, op: i64, pos: *i64) -> i64 |
| 404 | func wm_match_end(b: *u8, startpos: i64) -> i64 |
| 430 | func wm_match_else(b: *u8, startpos: i64) -> i64 |
| 450 | func wm_do_br(mod: *WasmMod, pos: *i64, lbl: i64) -> i64 |
| 459 | func wm_phexf(v: i64, fd: i64) -> i64 |
| 465 | func wm_pn2f(v: i64, fd: i64) -> i64 |
| 475 | func wm_pn2(v: i64) -> i64 { return wm_pn2f(v, 2) } |
| 476 | func wm_phex(v: i64) -> i64 { return wm_phexf(v, 2) } |
| 477 | func wm_trap1(code: i64, op: i64, a: i64, bb: i64, fd: i64) -> i64 |
| 485 | func wm_trap(code: i64, op: i64, a: i64, bb: i64) -> i64 |
| 491 | func wm_call(mod: *WasmMod, fidx: i64, args: *i64, nargs: i64) -> i64 |
| 751 | func wm_run(mod: *WasmMod, name: *u8, a0: i64, a1: i64, a2: i64, a3: i64, a4: i64, na: i64) -> i64 |