code wiki / _hdl_build / nx_js_update_gate.nx
nx_js_update_gate.nx
buildroot/runtime/_hdl_build/nx_js_update_gate.nx
about
nx_js_update_gate.nx -- SINGLE-EVALUATION of the reference in ++/-- update expressions on BOTH tiers.
JS spec: `a[expr]++` / `obj.prop++` evaluate the target reference (base sub-expr, and index sub-expr)
EXACTLY ONCE. The engine's compound-assign path (`a[k]+=e`) was already fixed to single-eval (BC_DUP2),
but the UPDATE path (c_update / tree ND_UPDATE) re-evaluated base+key for the write-back -> a side-effecting
key/base runs TWICE (spec violation; e.g. `a[i++]++`, `f().x++`). CONFIRMED via nx_js_upd_min (c=2 for
`a[k()]++` pre-fix). This gate pins single-eval + correct prefix(NEW)/postfix(OLD) result + write, on the
tree tier (js_run_source) AND the VM/JIT tier (compile_run). Two direct-call helpers (no branch-on-static:
that combo miscompiled -> SIGSEGV). expect_exit: 0 license_tier: ORIGINAL
dependencies 1 imports · 0 importers
imports: nx_js_vm.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
| 10 | func w(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } sys_write(1, s, n); return 0 } |
| 11 | func nn(v: i64) -> i64 { if v==0 { sys_write(1,"0" as *u8,1); return 0 } var m: i64=v; if m<0 { sys_write(1,"-" as *u8,1); m=0-m } let t: *u8=sys_mmap(24); var k: i64=0; while m>0 { t[k]=(48+(m%10)) as u8; m=m/10; k=k+1 } let o: *u8=sys_mmap(24); var q: i64=k-1; var x: i64=0; while q>=0 { o[x]=t[q]; x=x+1; q=q-1 } sys_write(1,o,x); return 0 } |
| 13 | func ct(label: *u8, src: *u8) -> i64 { // TREE tier |
| 21 | func cv(label: *u8, src: *u8) -> i64 { // VM/JIT tier |
| 29 | func tree_suite() -> i64 |
| 43 | func vm_suite() -> i64 |
| 57 | func main(argc: i64, argv: *i64) -> i64 |