Repository navigation
Conversation
9950495 to
c603f49
Compare
c603f49 to
425e1dd
Compare
|
Rebased onto current I still cannot run the cluster gates from this checkout ( |
|
Thanks for the careful write-up and the blast-radius check. I think this moves in the wrong direction, though, so I'd rather not merge it. The C lane's We've already gone this way before:
If the lanes should agree, the fix belongs in the interpreter and JS lanes, which would skip the argument instead. Whether evaluation should be strict is still open (see #775), so that's a separate decision. I'll note this on #2181 too. |
|
Closing per the comment above: the C lane's result is the one we want, and #2181 will be fixed on the JS side instead. |
Fixes #2181.
emit_unfoldfolds a call whose constant arguments decide its matches. A live, non-constant argument becomes a probe, and the chosen arm body is wrapped in aletfor it. When the arm did not use that argument, the binding was dead, the emitter dropped it, and the argument was never evaluated: the C lane printed100forpick(boom(k), 0n, 100n)where the interpreter and JS evaluateboomand stop at the Nat wall.emit_unfoldnow refuses a fold whose body does not use one of its probes, so the call is emitted normally and evaluates its arguments like the other lanes.What changed
bend2/comp.ts,emit_unfold(+7/-7 lines): thebadpredicate that already rejects a fold now also reports a probe the folded body does not use. Four behavior-neutral tightenings in the same function (merged declarations, awhileloop over the probe list,&&in place of a ternary) keepcomp.tsat 65,996 / 66,000 ttok (main is 65,995).tests/reg/unfold_drop_arg.bend: the issue's file; expectsbend: a Nat past the largest immediate 2^48-1andexit 1on all three lanes.tests/reg/unfold_drop_arg_run.bend: control; the same call withNat.sub(k, k)as the selector, so no fold happens. It already stopped on every lane before the fix, which isolates the literal selector as the trigger.Checks run (local, macOS arm64)
bun bend2/main.tsand-o .js && bun .jsprint the Nat wall (exit 1);-o drop && ./dropprinted100(exit 0). The emitted C had noboomcall and only100ullreachedNat.show.bend: a Nat past the largest immediate 2^48-1(exit 1); the emitted C now callsspin_boombeforespin_pick.bun gates/repo.ts->PASS: 56 / 56.tests/**/*.bend,bench/runtime/*/main.bendanddemos/*/main.bendthat compiles: 927 identical, 14 differ, plus the 2 new tests. The 14 aretests/check/{convoy_dependent,kind_domain_self_call,kind_generic_none,kind_none_is_type,kind_self_call_eta,meet_uses_in_arms},tests/compile/loop_peel_countdown,tests/cost/accumulator_loop,tests/io/bool_bridge,tests/proof/fold_assoc,tests/run/{bit_walking,graph_bfs,word_wrap_chains}andbench/runtime/raytrace. Each was built and run on the interpreted, JS and C lanes in both trees: byte-identical output, and their#|lines still match.tests/reg/unfold_arg_type.bend(prints0) andtests/run/nat_overflow.bend(wall, exit 1) still pass on all three lanes.The change is in the C emitter only; the interpreter and the JS emitter do not use
emit_unfold.Rebase onto current
main(0e2f38f7)maingrew from 65,981 to 65,995 ttok after this PR was opened, so the patch was 66,011 / 66,000. The tightenings above bring it back to 65,996, and the branch is rebased on0e2f38f7. Re-checked on Linux x86_64:ttok -m gpt-3.5-turbo < bend2/comp.ts->65996bun gates/repo.ts->PASS: 56 / 56tests/reg/unfold_drop_arg.bendandtests/reg/unfold_drop_arg_run.bend: interpreted, JS and C lanes all print the Nat wall and exit1tests/reg/unfold_arg_type.bend,tests/run/{nat_overflow,bit_walking,graph_bfs}.bend,tests/compile/loop_peel_countdown.bend: expected output on the interpreted laneNot run
bun gates/test.ts,gates/perf.ts,gates/ping.ts, Metal/CUDA: the cluster is unreachable from this checkout (ssh clusterrefused).gates/test.tsruns on the cluster, so this needs a cluster run before it merges. No cluster qualification is claimed; the results above are local.AI-assisted.