Repository navigation
refactor(comp): simplify comp.ts with the same behavior (-137 ttok) - #1891
Conversation
|
Thanks, gates are green here too, merged onto 9a4dfe3: repo 54/54, test 1750/1750, ping 81/81, safe 0 false rejects. perf is 123/124, and the miss is merkle's compiler time, which misses on main the same way. Five of the six changes look good to me, and the C/JS output matches main apart from the CUDA move and the Nat
(the file has two such defs and a main that calls both)
Leaving out checking, the C build gets about 50% slower, and putting the old Two smaller things:
|
- node_fields, val_to, val_unbox, emit_open: build the root gate list with val_new / map instead of by hand - unit_emit: one Object.assign for the unit's fresh state, and FL.unit is reset after the unit emits - js_match: Nat rows go through lits_cond like the other literal rows - JS closures: the nested function/arrow pair is two block() calls instead of manual tab and line wrapping - CUDA: gpu_map zeroes the stack area itself, so corpus_setup no longer needs its own #if BEND_CUDA memset The C and JS outputs of every test, demo and bench match main except the CUDA memset move and `=== N` -> `== N` on JS Nat rows. Co-Authored-By: Claude Opus 5.5 <[email protected]>
11e883f to
fe97354
Compare
|
Thanks, I reproduced it. With your generator (every 7th literal up to 399, two defs) built with
The C is byte-identical between the last two columns. I've dropped the I'm leaving the JS Nat rows as they are for now, per your nit. |
… tail mode Every emit_put ends a body, so it starts with bind_dead(sc, []) itself: emit_spin loses its tail flag and emit_body / emit_match their own bind_dead before emit_put. The C and JS of every test, demo and bench are unchanged. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
I pushed one more small simplification, ccbe933 (−27 ttok, so the PR is now −137: 65,982 → 65,845). Every
The other two callers already have no bindings left when they reach it: the closure at the top of Checked against fe97354:
I also went over the rest of |
Structural simplifications to
bend2/comp.ts, taking it from 65,982 to 65,845 ttok on main 757180e so #1880 can restore the comments it removed and still fit under the 66k cap. No names are shortened, no comments removed, nothing golfed; each change removes a concept or a duplicate of an existing helper.emit_putdrops the bindings left at a body's end, since everyemit_putends a body:emit_spinloses itstailmode, andemit_body/emit_matchtheir ownbind_deadbeforeemit_put.val_newis the one place that decides which words keep a root; four callers stop filtering byboxthemselves.js_matchsends Nat rows through the literal rows, asemit_matchdoes for C.gpu_mapzeroes the managed memory it maps, instead ofcorpus_setupdoing it under#if BEND_CUDA.block(), asjs_defdoes.unit_emitresetsFL.unitto null after the unit emits, instead of saving and restoring it: units never nest and it starts out null, so a use outside a unit still fails.Output
All 1,762 tests, and the 72
.bendfiles underdemos/andbench/, built to C and JS with main and with this branch:corpus_setupintogpu_map(compiled out on Metal and CPU).x === Nand is nowx == N, the same as word literals. A Nat in JS is always a number, so the two are equivalent.bun gates/repo.ts: 54 / 54.tsc: no errors in comp.ts. Compiling the 17 runtime benches: 1.605 s on main, 1.606 s here (hyperfine, 8 runs).Gates on the cluster (
bun gates/_run.ts) at ccbe933:The one ping miss (a hyphenated entry,
lic_bom--name.bend, refused by the localhost hub) fails the same way on main.The
emit_putchange (ccbe933) was checked separately against fe97354: all 1,837.bendfiles undertests/,demos/andbench/build to byte-identical C and JS, with identical logs, and compiling the runtime benches takes the same time (1.596 s vs 1.602 s).Not verified: the CUDA path (no CUDA toolkit on this Mac or the minis).
🤖 Generated with Claude Code