Skip to content

feat(jit): Cranelift lazy-stdin dispatch for for-line iterator (ILO-342)#681

Merged
danieljohnmorris merged 1 commit into
mainfrom
feature/jit-for-line
May 22, 2026
Merged

feat(jit): Cranelift lazy-stdin dispatch for for-line iterator (ILO-342)#681
danieljohnmorris merged 1 commit into
mainfrom
feature/jit-for-line

Conversation

@danieljohnmorris
Copy link
Copy Markdown
Collaborator

Summary

  • Implements Cranelift JIT support for for-line "stdin" lazy iterator (ILO-70 / feat: for-line stdin lazy line iterator (ILO-70) #601)
  • Both JIT backends (jit_cranelift.rs and compile_cranelift.rs) now dispatch OP_FOREACHPREP / OP_FOREACHNEXT to jit_foreachprep_lazy / jit_foreachnext_lazy trampolines when the HeapObj discriminant at ptr+0 equals 8 (LazyStdinLines); the existing plain-List fast path (discriminant == 1) is unchanged
  • Foreach cache vars expanded from 4 → 5 per loop to carry an is_lazy flag so FOREACHNEXT knows which path to take without re-reading the discriminant each iteration
  • Two new extern "C" helpers in vm/mod.rs: jit_foreachprep_lazy and jit_foreachnext_lazy — both call handle.next_line() via the Arc<Mutex<...>> and return a heap-string NanVal or TAG_NIL on EOF/error
  • StdinLinesHandle::from_lines test helper added (#[cfg(test)]) for in-memory iterator injection

Test plan

  • cranelift_foreachprep_lazy_stdin_count — 3-line handle yields count 3
  • cranelift_foreachprep_lazy_stdin_empty — empty handle skips loop body, returns 0
  • cranelift_foreachprep_lazy_stdin_collects_text — actual line text ("hi" + "world" → len sum 7) flows through the lazy dispatch path
  • probe_heapobj_lazy_discriminant — runtime-confirms discriminant values (List=1, LazyStdinLines=8) match JIT constants
  • Full cargo build --features cranelift — clean (only pre-existing unrelated warnings)

🤖 Generated with Claude Code

@danieljohnmorris danieljohnmorris added the mini Created by mini PC autonomous workflow label May 22, 2026
@danieljohnmorris
Copy link
Copy Markdown
Collaborator Author

needs manual rebase (conflicts in: src/builtins.rs)

@danieljohnmorris
Copy link
Copy Markdown
Collaborator Author

needs manual — rebase conflict in non-doc file(s)

hotfix(codegen/js): handle Pattern::Or, Expr::Todo, Expr::Panic
@danieljohnmorris danieljohnmorris merged commit 8945626 into main May 22, 2026
7 of 11 checks passed
@danieljohnmorris danieljohnmorris deleted the feature/jit-for-line branch May 22, 2026 10:40
@codecov
Copy link
Copy Markdown

codecov Bot commented May 22, 2026

❌ 1 Tests Failed:

Tests completed Failed Passed Skipped
688 1 687 0
View the full list of 1 ❄️ flaky test(s)
ilo::interpreter::tests::interpret_braced_guard_in_loop_no_early_return

Flake rate in main: 66.67% (Passed 1 times, Failed 2 times)

Stack Traces | 0.012s run time
thread 'interpreter::tests::interpret_braced_guard_in_loop_no_early_return' (32989) panicked at src/interpreter/mod.rs:10350:9:
parse errors: [ParseError { code: "ILO-P003", position: 27, span: Span { start: 35, end: 36 }, message: "expected `{`, got `;`", hint: Some("ilo bodies are single-line, `;`-separated — not python/swift-style indented. Use either the brace-block form `name p:t>r;{body1;body2}` or the single-line form `name p:t>r;body1;body2`. For statements that require a block (`@k xs{...}`, `wh cond{...}`, `?subj{...}`), the `{...}` must be on the same line as the head.") }]
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

To view more test analytics, go to the Test Analytics Dashboard
📋 Got 3 mins? Take this short survey to help us improve Test Analytics.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

mini Created by mini PC autonomous workflow

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant