code wiki / _hdl_build / nx_x86emit_gate.nx
nx_x86emit_gate.nx
buildroot/runtime/_hdl_build/nx_x86emit_gate.nx
about
nx_x86emit_gate.nx -- VERIFY the sovereign x86-64 emitter (nx_x86emit) by EMITTING functions
through its api and EXECUTING them (cardinal rule 2: verify the primitive before the JIT rides it).
Each test emits a tiny function via the SAME encoders the Sparkplug-tier JIT will use, casts the
RWX buffer to a fn-ptr, calls it, and checks the result. Any encoding bug shows as a wrong value
or a SIGSEGV/SIGILL here -- never silently in the JIT. Covers: reg-moves, imm32/imm64, arithmetic,
imul, signed idiv (cqo+idiv), setcc booleanization, [base+disp] load/store, [base+index] SIB
load/store (the VM stack access pattern), forward jcc + backward jmp (a real counted loop), and an
indirect CALL through a register (the native->helper path). expect_exit: 0 license_tier: ORIGINAL
dependencies 1 imports · 0 importers
imports: nx_x86emit.nx
imported by: nobody (leaf or entry point)
call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown
structs
| none |
consts
| none |
functions
| 11 | func g_puts(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } sys_write(1, s, n); return 0 } |
| 12 | func g_pn(v: i64) -> i64 |
| 26 | func chk(label: *u8, got: i64, want: i64, pp: *i64, tp: *i64) -> i64 |
| 39 | func helper_triple(x: i64) -> i64 { return x * 3 } |
| 41 | func main() -> i64 |