code wiki / (root) / nx_probe_bchk_asm.nx

nx_probe_bchk_asm.nx

buildroot/runtime/nx_probe_bchk_asm.nx

1258 B23 linesdepth 0pulls 0 transitivereach 0 importersview sourcekind probetopic probe
docsdependenciesstructsconstsfunctions

about

nx_probe_bchk_asm.nx -- INSTRUMENT, not a witness: the smallest bounds-checked hot loop, so the emitted assembly for ONE checked access can be read directly. It answers "what does the check actually cost in instructions" before anyone decides how to make it cheaper -- and on 2026-08-14 it re-ranked the whole perf lane by showing the answer is NOT the check. COMPILE IT AND READ main's bb2/bb4/bb6. Measured that day on the shipped compiler: ~17 instructions per iteration, of which the bounds check is 2 compares + 2 branches and SIX are pure memory traffic. The loop counter lives in r12 and the accumulator in r13 for the entire loop -- register allocation WORKED -- and the emitter still spills both to stack homes on entry and reloads the counter TWICE more from a register that never changed. => the dominant cost is the backend not consuming the allocation it already computed, not the check and not missing phi nodes (the loop-carried values are already in registers here). Debt: lang-perf-regalloc-unconsumed. Keep this file: it is the reproducer.

dependencies 0 imports · 0 importers

imports: none

imported by: nobody (leaf or entry point)

structs

none

consts

none

functions

14func main(argc: i64, argv: *u8) -> i64