vm + cranelift: closure-bind HOF ctx forms via tree-bridge#280
Merged
Conversation
The 3-arg ctx variants of map/flt/srt and 4-arg fld weren't lifted to VM/Cranelift in the earlier HOF chain. Adding them to is_tree_bridge_eligible reuses the same path PR 3b set up for grp, uniqby, partition, and 2-arg srt: the bridge passes the args straight to call_builtin_for_bridge_with_program, which the tree interpreter handles end-to-end. The native 2-arg arms for map/flt/fld short-circuit before this check, so their fast loops still win on the common shape. Only the closure-bind forms pay the bridge round-trip, which is the same cost as 2-arg srt.
The four happy-path tests (srt with external lookup, map with lookup, flt with threshold, fld with external accumulator) now run on tree, vm, and cranelift via run_all. The verifier-error tests stay tree-only because verify runs before dispatch and produces the same diagnostic on every engine.
vm and cranelift now run closure-bind via the tree-bridge. jit still lacks HOF dispatch entirely (per regression_builtins_as_hof.rs) so its skip stays.
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
This was referenced May 15, 2026
danieljohnmorris
added a commit
that referenced
this pull request
May 15, 2026
- slc / take / drop accept negative indices counting from end (bounds clamp), matching at xs i. Closes the quant-trader fencepost and the slc xs -np 1 np ergonomics gap (#266). - Map keys are typed: text or integer. mset m 7 v and mget m 7 work directly, no str conversion. Int(1) and Text("1") are distinct. Float keys floor to i64; jdmp stringifies numeric keys for JSON (#267). - Add map / flt / fld to the builtin reference. All HOFs (map, flt, fld, srt, grp, uniqby, partition, flatmap) now work cross-engine on tree, VM, Cranelift JIT, and AOT (#274 #277 #278 #279 #280 #283). - New Inline lambdas subsection: Phase 1 literals are cross-engine, Phase 2 closure capture is tree-only with automatic fallthrough surfacing ILO-R012 on VM and Cranelift (#265 #284). - AOT-compiled binaries from ilo compile now strip the top-level ~/^ wrapper byte-for-byte the same as in-process runners (#281).
5 tasks
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.
Summary
PR 3c in the HOF dispatch chain. The closure-bind variants of
map,flt,fld, andsrt(the 3-arg / 4-arg forms that thread an extractxvalue into every fn invocation) now run on VM and Cranelift, not just the tree interpreter.Builds on #277 (native
map), #278 (nativeflt/fld/flatmap), and #279 (tree-bridge forgrp/uniqby/partition/ 2-argsrt).Repro
Before, this program errored on VM/Cranelift with
UndefinedFunctionbecause the dispatcher had no path for ctx-bearing HOFs:After, all three engines produce
[10, 20, 10].What's in the diff
vm: route closure-bind HOF ctx forms through tree-bridgeadds(Map, 3),(Flt, 3),(Fld, 4),(Srt, 3)tois_tree_bridge_eligible. The existing 2-arg native arms short-circuit first, so the common shape still wins on the fast loop. Only the closure-bind forms pay the bridge round-trip, the same cost as 2-argsrtfrom PR 3b.test: cross-engine coverage for closure-bind HOF variantslifts the four happy-path tests inregression_closure_bind.rs(srt-by-lookup, map-with-lookup, flt-with-threshold, fld-with-external-accumulator) to run viarun_allacross tree, vm, and cranelift. Verifier-error tests stay tree-only because verify is engine-independent.example: lift vm/cranelift skip from closure-bind.iloremoves the two engine-skip directives.jitskip stays because jit lacks HOF dispatch entirely.Test plan
cargo test --release --features cranelift --test regression_closure_bind(8 passed)cargo test --release --features cranelift --test examples_engines(1 passed; closure-bind.ilo now exercised on vm + cranelift)cargo test --release --features craneliftfull suite (2932 + every integration suite green)cargo fmt --checkcargo clippy --release --features cranelift --all-targets -- -D warningsFollow-ups
f = dbl; f 10) lifted to OP_CALL_DYN fromExpr::Call.engine-skip: vm/craneliftfrom inline-lambda examples, now that FnRef + HOF dispatch work everywhere.