Skip to content

jit: support functions with no return value - #8479

Open
kyokuping wants to merge 1 commit into
RustPython:mainfrom
kyokuping:codex/jit-none-return
Open

jit: support functions with no return value#8479
kyokuping wants to merge 1 commit into
RustPython:mainfrom
kyokuping:codex/jit-none-return

Conversation

@kyokuping

@kyokuping kyokuping commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Enable no_return_value test (crates/jit/tests/misc_tests.rs).
  • Add a JitType::None variant to represent a void/None return, instead of
    overloading Option<JitType> to mean both "return type not yet inferred"
    and "unsupported value". :
    Option::None = not seen a return yet, Some(JitType::None) = confirmed
    void return, Some(Int/Float/Bool) = confirmed typed return.
  • JitType::to_cranelift now returns Option<types::Type> (None for the
    void case), and all four call sites handle it instead of unconditionally
    pushing a cranelift return param.
  • return_value compares JitTypes directly and emits return_(&[]) when
    there's no cranelift value.

Summary by CodeRabbit

  • New Features

    • Added support for JIT-compiled functions that do not return a value.
    • Void functions now invoke successfully without producing a result.
    • Functions containing only a pass operation are now supported.
  • Bug Fixes

    • Improved handling of unsupported argument and return types during JIT compilation.
    • Corrected return behavior for typed and void functions.

@coderabbitai

coderabbitai Bot commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

The JIT now supports JitValue::None and void functions. Cranelift and libffi omit return values for JitType::None. Instruction return handling and tests now support empty returns.

Changes

JIT void return support

Layer / File(s) Summary
Void type and ABI integration
crates/jit/src/lib.rs
JitType::None maps to absent Cranelift return types and libffi void values. Argument conversion rejects unsupported types, and invocation returns no value for void functions.
Instruction type and return handling
crates/jit/src/instructions.rs
JitValue::None maps to JitType::None. Local storage validates optional Cranelift types. Return generation supports empty returns and typed zero-value returns.
Void return test
crates/jit/tests/misc_tests.rs
The no-return-value test now executes a pass-only function and checks for Ok(()).

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant JITCompiler
  participant CraneliftSignature
  participant LibffiInvocation
  JITCompiler->>CraneliftSignature: omit return parameter for JitType::None
  JITCompiler->>LibffiInvocation: use libffi void type
  LibffiInvocation-->>JITCompiler: return no value
Loading

Suggested reviewers: shaharnaveh

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: JIT support for functions with no return value.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@kyokuping
kyokuping marked this pull request as ready for review August 10, 2026 09:52
@kyokuping
kyokuping marked this pull request as draft August 10, 2026 10:20
@kyokuping
kyokuping marked this pull request as ready for review August 10, 2026 10:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant