Repository navigation
refactor(comp): the intrinsic table is keyed by Base's def name, intr_of has no flag, a spare carries its size class, and a fold walks its body once - #2129
Merged
Conversation
…_of has no flag, a spare carries its size class, and a fold walks its body once intr_of looks a def up by its own name, so op_name and its cache are gone, and an op is an intrinsic in a lane exactly when it has that lane's text. In JS, Base's bodies of the String ops are no longer emitted. A spare records its class instead of a word count, so the emitted free names the class as a number, as every alloc already did. emit_fold charges fuel in the walk that folds the inner calls, instead of a walk of its own. Co-Authored-By: Claude Fable 5.2 <[email protected]>
…runtime's does Co-Authored-By: Claude Fable 5.2 <[email protected]>
Co-Authored-By: Claude Fable 5.2 <[email protected]>
nicolas-abril
force-pushed
the
ai/comp-simplify
branch
from
November 12, 2026 08:47
7b05bcc to
5a86938
Compare
raymond-w-ko
added a commit
to raymond-w-ko/bend
that referenced
this pull request
Nov 29, 2026
Two conflicts in bend2/comp.ts: - OPERATIONS: upstream keys intrinsics by Base's def name (bendlang#2129), so the fork's vec_* entries become "Vec.length", "Vec.get", ...; and bool_pick calls intr_of(k), which no longer takes a JS flag. - loop_of: keep the fork's walk through Bool.and/or and picks in tail position, and drop the done_live check on the callee as upstream did (bendlang#2036). Co-Authored-By: Claude Opus 5.5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A simplification pass over
bend2/comp.ts: 65,952 → 65,913 ttok (−39; the cap is 66k), in that file only.What changes
OPERATIONShad keys likeu32_add, reached by lowercasingU32.addand replacing dots, with a cache (FL.ops) over that translation. The keys are now the Bend names ("U32.add","Array.atomic.cas","Map.msb.u"), sointr_ofis a direct lookup andop_nameand its cache are gone. No other cache is touched.intr_ofhas nojsflag. An op is an intrinsic in a lane exactly when it has that lane's text. Before, a JS-only op (the String ones) counted as an ordinary def in the JS lane unless the caller passedtrue.heap_free(e, 2, sp)) instead of callingcls_fit(3)in C, as every emitted alloc already did.emit_foldwalks an unfolded body once. It charged fuel in one walk and folded the inner calls in a second; one walk does both. When a body runs the fuel out, the inner calls visited before that point now stay folded, where the two walks discarded them; the folds are valid either way, and no program in the corpus changed.cls_fitgives class 0 for no words, as the runtime's does (it gave 32). No caller reaches it with zero today;lay_arrdrops its own guard for that case.Effect on emitted programs
Compared on all 1,944 test, demo and bench programs,
-o f.cand-o f.js, againstmain(8ec4c88):.cis identical oncecls_fit(n)is read as its number. Every compile error is identical.intr_ofchange:String.order,Cmp.is_eq,String.starts_with), are no longer emitted, or are emitted at a different position.One edge not tested directly: in the JS lane, a U32 match whose arm goes through a String op no longer constant-folds through Base's body when building a lookup table. No program in the corpus changed its tables.
Verification
clang -O3) were byte-identical tomain's for all 938 programs that build. This was run on the first two changes, before the rebase over fix(cli): only a stack overflow prints the stack overflow message (#2120) #2122, and not repeated; the later changes leave the C output as it was.gates/repo.ts56 / 56 andgates/test.ts1,853 / 1,853, run with the first three changes. Theemit_foldandcls_fitchanges came after and leave every.cand.jsin the corpus byte-identical to that gated state;gates/repo.tswas rerun on the final commit. An earlier test run had one miss, a JS-lane timeout inio_chan_reclaim_limit, which did not repeat.gates/perf.tson this branch, and CUDA.🤖 Generated with Claude Code