HOF dispatch PR 4: lift inline lambdas Phase 1 to cross-engine#284
Merged
Conversation
Pins Phase 1 inline lambdas (the (params>ret;body) literal lifted to synthetic __lit_N decls) as arguments to every HOF that now has cross-engine dispatch: map, flt, fld, srt, grp, uniqby, partition, flatmap. Covers both 2-arg and 3-arg ctx-bind forms on tree, VM, and Cranelift. The 3-arg form is how Phase 1 lambdas thread external state without closure capture; Phase 2 capture is still tree-only, so these tests use ctx-bind to keep coverage flat across every engine. Empty-list cases on map/flt/fld pin the dispatcher short-circuit path before the first OP_CALL_DYN on every engine.
Phase 1 inline lambdas now dispatch identically on tree, VM, and Cranelift now that FnRef + native HOF dispatch + tree-bridge for the ctx forms have all landed (#274/#277/#278/#279/#280). The example harness exercises the lifted lambdas across every engine, locking in the cross-engine guarantee. Phase 2 closure capture remains tree-only and stays gated in inline-lambda-capture.ilo until a follow-up PR.
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
5 tasks
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).
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
Phase 1 of the inline lambda work (#247) shipped tree-only: a
(params>ret;body)literal lifts to a synthetic__lit_Ntop-level decl, and any HOF that consumed it had to be tree-only because VM and Cranelift didn't dispatch HOFs yet. That gating made sense at the time, but it's stale now.With the recent HOF chain landed - FnRef NaN-tagging in #274, native
mapdispatch in #277,flt/fld/flatmapin #278, the tree-bridge forgrp/uniqby/srt-2arg/partitionin #279, and closure-bind ctx forwarding in #280 - inline lambdas-as-args produce identical output on tree, VM, and Cranelift. This PR makes the guarantee explicit:engine-skip: vmfromexamples/inline-lambda.iloso the example harness runs all foursrt/flt/fldcases on both tree and VM.tests/regression_lambdas_cross_engine.rswith 15 cases pinning inline lambdas as args tomap,flt,fld,srt,grp,uniqby,partition,flatmapacross tree/VM/Cranelift. Covers both 2-arg and 3-arg ctx-bind forms plus empty-list short-circuit paths.Phase 2 closure capture (
#265) is still tree-only -examples/inline-lambda-capture.ilokeeps itsengine-skip: vm jit craneliftline, and the cross-engine tests deliberately use the ctx form to keep coverage flat. Phase 2 cross-engine support is the next follow-up in the chain.Repro before / after
examples/inline-lambda.ilo by-dist [-3,1,-5,2]on VM:Before: skipped by the example harness (gated
engine-skip: vm).After: prints
[1, 2, -3, -5]on tree, VM, and Cranelift.What's in the diff
tests/regression_lambdas_cross_engine.rs, each running tree / VM / Cranelift and asserting identical output.engine-skip: vmannotation, so the example harness exercises VM dispatch on every assertion in the file.Test plan
cargo test --release --features cranelift --test regression_lambdas_cross_engine(15 passed)cargo test --release --features cranelift --test examples_engines(full pass, inline-lambda.ilo now runs on VM)cargo test --release --features cranelift(full suite green, 0 failed)cargo fmt --allcargo clippy --release --features cranelift --all-targets -- -D warningsFollow-ups
inline-lambda-capture.ilo) needs the synthetic decl's captures plumbed through VM / Cranelift before itsengine-skipline can come off. Tracked separately as the Phase 2 cross-engine PR.