code wiki / _hdl_build / nx_heal_selfix.nx
nx_heal_selfix.nx source
↩ module page · 24 lines · 1580 B
1// nx_heal_selfix.nx -- hand the failing nx_selfix_test to the ENGINEER's managed build gate
2// and see if the Engineer heals the register-pressure gate-clobber itself (the user's ask:
3// the Engineer manages this, not me). Prints the gate's verdict + how many regs it healed.
4import "nx_engineer_build_gate.nx"
5import "nx_itoa_lib.nx" // shared MSB-first emitter (zero-alloc)
6
7func hs_puts(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } sys_write(1, s, n); return 0 }
8// MIGRATED to the shared emitter (debt 1785563586). The old body mmapped a scratch buffer
9// per call and never freed it. At PAGE granularity that is 4096B leaked PER CALL -- the
10// defect that took 28.5GB of a 36GB host in nx_ts_lumadiff (2MB input, ~3.66M calls).
11// nxi_* is MSB-first, allocates NOTHING, and emits identical bytes including the sign.
12func hs_num(v: i64) -> i64 { nxi_out(v); return 0 }
13
14func main() -> i64 {
15 hs_puts("=== Engineer managed build gate on nx_selfix_test (does it heal the gate-clobber?) ===\n" as *u8)
16 let out: *i64 = sys_mmap(8 * 4) as *i64
17 let v: i64 = eng_build_gate("_offc/nx_cc_known_good.elf" as *u8, "runtime/_hdl_build/nx_selfix_test.nx" as *u8,
18 "/tmp/sfg.s" as *u8, "/tmp/sfg_h.s" as *u8, "/tmp/sfg.elf" as *u8, "/tmp/sfg.out" as *u8, out)
19 hs_puts("\n Engineer verdict: " as *u8); hs_puts(ebg_verdict_name(v))
20 if out[0] > 0 { hs_puts(" (HEALED " as *u8); hs_num(out[0]); hs_puts(" reg(s) -- Engineer fixed the miscompile)" as *u8) }
21 hs_puts("\n" as *u8)
22 sys_exit(0)
23 return 0
24}