Skip to content

ZJIT: Compile throw instruction #1016

Description

@k0kubun

This is less important than compiling exception handlers #966 (because just handling throw, which would return to the interpreter anyway, doesn't lead to compiling more code), but leaving an issue as a reminder and a place to discuss that.

TODO

  1. We could start from calling rb_vm_throw and propagating ec->tag->state (after JIT-to-JIT calls) to the interpreter, like YJIT does.
    • It's more complicated to propagate ec->tag->state with ZJIT than with YJIT though. ZJIT uses multiple native frames for multiple ISEQ CFPs unlike YJIT, and rb_vm_throw needs to return a non-Qundef value, so the regular side-exit propagation doesn't work. It would need to check ec->tag->state besides Qundef.
    • Instead, we might want to consider unwinding multiple frames at once. It could be more efficient than propagating Qundef or ec->tag->state after JIT-to-JIT calls.
  2. We could also optimize Insn::Throw into a jump at the HIR level when the inliner sees both throw and its catch.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions