code wiki / _hdl_build / nx_eng_asm_scan.nx
nx_eng_asm_scan.nx
buildroot/runtime/_hdl_build/nx_eng_asm_scan.nx
about
nx_eng_asm_scan.nx -- the ENGINEER reads the bug straight from the MACHINE CODE. Not a
synthetic probe (those don't reproduce it) -- a single deterministic pass over the
emitted x86-64 assembly that finds the register-pressure miscompile WHERE IT LIVES:
a CALLER-SAVED register is written, a `call` happens, then that register is READ
again with no spill+reload in between -> the call clobbered it -> wrong value.
x86-64 SysV: caller-saved = rax,rcx,rdx,rsi,rdi,r8,r9,r10,r11 (a call destroys them);
callee-saved = rbx,rbp,r12-r15 (survive). Per-register state: CLEAN(0) -> FRESH(1) on a
write -> CLOBBERED(2) when a call crosses it while FRESH. A read of a CLOBBERED caller-
saved reg is the bug; a write or a reload-from-memory makes it FRESH (safe) again. State
resets at each function label. One pass, milliseconds -- identify from machine code up.
RACI: detection only. The Engineer reports (reg + the clobbering call's line); the Doctor
consumes that artifact to fix. license_tier: ORIGINAL
dependencies 1 imports · 3 importers
imports: nx_syscalls.nx
imported by: nx_asm_selfheal_test.nxnx_eng_asm_scan_min_test.nxnx_engineer_build_gate.nx
structs
| none |
consts
| 18 | const AS_CLEAN: i64 = 0 |
| 19 | const AS_FRESH: i64 = 1 |
| 20 | const AS_CLOBBERED: i64 = 2 |
functions
| 22 | func as_isalnum(c: i64) -> i64 called by 1: as_match |
| 31 | func as_match(buf: *u8, p: i64, lim: i64, lit: *u8) -> i64 |
| 43 | func as_reg_at(buf: *u8, p: i64, lim: i64) -> i64 |
| 63 | func as_is_caller(id: i64) -> i64 |
| 77 | func as_operand_reg(buf: *u8, s: i64, e: i64, ismem: *i64) -> i64 |
| 91 | func as_mnem_class(buf: *u8, ms: i64, lim: i64) -> i64 |
| 111 | func as_read(reg: i64, state: *i64, clobline: *i64, fl_reg: *i64, fl_line: *i64, nf: *i64) -> i64 |
| 120 | func as_write(reg: i64, state: *i64) -> i64 { if reg >= 0 { state[reg] = AS_FRESH } return 0 } called by 1: as_proc_line |
| 123 | func as_is_ws(c: i64) -> i64 { if c == 32 { return 1 } if c == 9 { return 1 } return 0 } called by 1: as_proc_line |
| 126 | func as_proc_line(buf: *u8, ls: i64, le: i64, line: i64, state: *i64, clobline: *i64, |
| 193 | func eng_asm_scan(path: *u8, fl_reg: *i64, fl_line: *i64) -> i64 |
| 217 | func as_regname(id: i64) -> *u8 |