Repository navigation
Some misc compiler fixes - #855
Merged
Merged
Conversation
…into a segment whose return is not (was: a dependent return's arms, one layout per index, died with 'a layout mismatch' or 'a constructor outside its layout' when fused into a caller typed at one index); it jumps and its return converts through the cut comp.ts 61357 -> 61372 ttok (+15) Co-Authored-By: Claude Fable 5.1 <[email protected]>
…D_HOT_T entry, the fact the emitter writes for its own constructors, and take no flag (was: a twin passed a hot flag it could not know, IO_HOTS covering six base constructors and 0 for the program's own types, so a shared foreign value fail-stopped); tests/io/foreign_shared pins it comp.ts 61372 -> 61317 ttok (-55) Co-Authored-By: Claude Fable 5.1 <[email protected]>
… F32, Nat), whose evaluated value is its C word (was: any one-word layout, so a Char or Cmp arm died in 'Failed to parse String to BigInt' and a Bool table folded by the accident of BigInt(true) being 1n); the value filter that dropped a non-number after evaluating the rows goes, the gate reaches no such row comp.ts 61317 -> 61259 ttok (-58) Co-Authored-By: Claude Fable 5.1 <[email protected]>
…parameter, a node's field slot, a tail's destination, a foreign action's box), not at its own type and reshaped, so a constant is never converted and its bit is read only where its node is built (was: a static Fail bound in a do over Result reshaped through the arm chain, whose wrong-arm slice kept the bit, and the boxing shortcut decoded a string node as a Bool tag, dying in 'arm.k'); the shortcut, node_build and the bit's passage through slices go, and emit_match, emit_tab, emit_fuse and bind_uses look a layout, type or signature up once or behind its condition; tests/run/ctr_at_position pins it comp.ts 61259 -> 61321 ttok (+62) Co-Authored-By: Claude Fable 5.1 <[email protected]>
…_pop ahead of the keep it replaces, and a binding always carries its type (was: the unbox ran at binding time gated on a nullable type, so a fork's sequential path, rebinding a held cut through a frame whose hold entry inflated the count, unboxed a value the parallel path held boxed, dropped it as a dead word, and the join died with 'a fork's paths hold different values'; an untyped binding silently skipped its type facts); a let's value and a cut's are annotated by the checker, so both die otherwise; tests/run/fork_held_family pins it comp.ts 61321 -> 61282 ttok (-39) Co-Authored-By: Claude Fable 5.1 <[email protected]>
VictorTaelin
added a commit
that referenced
this pull request
Sep 19, 2026
… before any frame lays it out; a rebinding decides nothing bind_uses decides the unbox at the fresh binding (a let, a fork's result, a parameter), where the count is the value's own; seg_open's rebind passes fresh = false and re-lays the same value. bind_pop keeps no decision (was: the unbox ran at the first sharing pop, so a fork's sequential path laid the boxed value out as one word on a frame, then unboxed it into two for the call, and the next segment popped two, reading the box as a tag: --threads 1, or a task the pool drains, printed 12 for 18 while the parallel path and JS printed 18). tests/run/fork_shared_flat pins it on both paths at any thread count; tests/run/fork_held_family stays green. (#855)
VictorTaelin
added a commit
that referenced
this pull request
Sep 19, 2026
emit_ctr heats a hot build's fields before it looks its position's layout up: #855 built the constructor at its position, so the boxing shortcut hot's call sat beside is gone.
Phylliida
pushed a commit
to Phylliida/bend
that referenced
this pull request
Sep 27, 2026
… before any frame lays it out; a rebinding decides nothing bind_uses decides the unbox at the fresh binding (a let, a fork's result, a parameter), where the count is the value's own; seg_open's rebind passes fresh = false and re-lays the same value. bind_pop keeps no decision (was: the unbox ran at the first sharing pop, so a fork's sequential path laid the boxed value out as one word on a frame, then unboxed it into two for the call, and the next segment popped two, reading the box as a tag: --threads 1, or a task the pool drains, printed 12 for 18 while the parallel path and JS printed 18). tests/run/fork_shared_flat pins it on both paths at any thread count; tests/run/fork_held_family stays green. (bendlang#855)
Phylliida
pushed a commit
to Phylliida/bend
that referenced
this pull request
Sep 27, 2026
emit_ctr heats a hot build's fields before it looks its position's layout up: bendlang#855 built the constructor at its position, so the boxing shortcut hot's call sat beside is gone.
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.
Five emitter fixes from the fuzzer: a family's return through a cut, a foreign twin's seal by the constructor, a constant table only at a word type, a constructor built at its position, and a fork's held box
comp.ts: 61357 -> 61282 ttok (-75).
hyperfine on the M4 against main at 18b2641a, 10 runs after a warmup per cell
(the branch is on this repo's main at 15ae0c8; every bench's C is still
byte-identical to main's but for the second commit's 30 runtime lines):
the delta of means with one sigma of the ratio, bold beyond two sigma and 2%;
PAR-CPU is 8 threads, PAR-GPU the Metal lane; every cell prints main's output.
No commit here touches a bench's C except the second, whose 30 lines are the
runtime's seal macros, off every bench's path, the numbers are noise.
mandelbrot SEQ came out past the threshold in this run and 2.3% ± 1.3 in a
run against b9afc634, on identical hot code: layout, not this branch.
Verified locally: the C lane over every test under tests/io, tests/run and
tests/show, the branch and main passing and failing the same set plus the
three new tests passing; the sixteen benchmarks' C byte-identical to main's
except the second commit's runtime change; the test gate run locally on the
rebased branch: every test passes but gfx_window on the C lane, a headless
expectation this Mac cannot meet, and flatten/literal_rows_cubic, whose C
hits clang's bracket-depth limit of 256 from main's own compiler as well,
with the branch's C for it differing only in the runtime lines; the 40 programs in the fuzzer's
repro corpus behaving as on main except the two this fixes; 3400 fuzzer
programs across the sequential, parallel and JS lanes. The cluster gates were
not run.
1. 30e5b93 A once-called def whose return is a box no longer fuses into a packed-return segment
A def called once is fused into its caller's segment. A def returning a
family at an open index returns a box, since the emitter cannot see the
index; fused into a caller typed at one index, whose return is that index's
packed layout, the body's arms were laid at the caller's layout, and an arm
of another index died with
a layout mismatchora constructor outside its layout. Such a def now jumps, and its return converts through the cut likeany other call whose return disagrees with the segment's. The witness needs
the family's arm to be a call the folder cannot evaluate, and the caller's
argument likewise, else both fold away before emission.
2. 7803b8e A foreign twin seals a field by the constructor's own CID_HOT_T entry
A foreign def's C twin building a value of the program's own type had to
pass
io_nodea hot flag saying whether the program shares that type, afact only the emitter has.
IO_HOTScovered six base constructors and said0 for the program's own, so a shared tree from a twin arrived unsealed, and
once the program put it under a node of its own the shared take met a raw
field and fail-stopped.
io_nodeandio_boxnow take no flag: they sealby the constructor's entry in
CID_HOT_T, the table the emitter writes forits own constructors. This repo's
bend2/effs/file_read_at.cpassed the flagtoo; the commit drops it there.
with
mk.c(on main,io_nodetakes a fifth argument, the flag, that thetwin can only pass as 0):
and
mk.js:Test:
tests/io/foreign_shared.3. 4dd1204 A Nat match folds to a constant table only at a word type
A Nat match over constant arms folds to a table whose rows are evaluated in
JS and written as C words. Any one-word layout qualified: a Char or Cmp row
evaluated to a string or an object and died in
Failed to parse String to BigInt, and a Bool table folded only by the accident ofBigInt(true)being1n. The fold now asks the match's result type first and takes a table onlyat U32, F32 or Nat, whose values are their C words. Main had meanwhile added
a filter dropping a non-number after evaluating the rows; the gate reaches no
such row, so the filter goes.
4. 2fb67be A constructor is built at the layout of its position
A constructor was emitted at its own type's layout and reshaped by its
consumer: a call's parameter, a node's field slot, a tail, a foreign
action's box. A constant reshaped through the arm chain had its wrong-arm
slices still marked constant, and the boxing shortcut then read a slice of
the wrong arm as a tag. A constructor is now built at the layout of its
position, passed down through
emit_exprthe way the type already is, so aconstant is never converted and its bit is read only where its node is
built. The shortcut,
node_buildand the bit's passage through slices go;a value that already exists, a variable or a call's result, still converts
at its use. Five tests lose a chain on a literal tag in their C.
Test:
tests/run/ctr_at_position.5. 6f5ec3a A shared flat box unboxes at its first share, and a binding always carries its type
A box of a flat type, a family or polymorphic result, unboxes before it is
shared so its words copy instead of its node being kept. That ran at binding
time, gated on a nullable type. A fork emits its calls twice, in parallel
and in sequence, and the join needs both paths to hold the same values: the
sequential path rebinds a held cut through a frame whose hold entry inflates
the use count, so it unboxed a value the parallel path held boxed, dropped it
as a dead word, and the join died. The rule now lives in
bind_pop, the oneplace a value is duplicated, ahead of the keep it replaces; rebinding decides
nothing. A binding's type is no longer nullable: a let's value and a cut's
are annotated by the checker, so both die otherwise instead of silently
skipping their type facts.
Test:
tests/run/fork_held_family.