8000 ZJIT: SideExit on optional args by composerinteralia · Pull Request #13633 · ruby/ruby · GitHub
[go: up one dir, main page]

Skip to content

ZJIT: SideExit on optional args #13633

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

< 8000 div class="d-flex flex-items-center"> Sign up for GitHub

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions zjit/src/hir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2127,6 +2127,13 @@ pub fn iseq_to_hir(iseq: *const rb_iseq_t) -> Result<Function, ParseError> {
let exit_state = state.clone();
profiles.profile_stack(&exit_state);

// TODO: Remove this and implement optional arguments
if unsafe { get_iseq_flags_has_opt(iseq) } {
let exit_id = fun.push_insn(block, Insn::Snapshot { state: exit_state });
fun.push_insn(block, Insn::SideExit { state: exit_id });
break; // End the block
}

// try_into() call below is unfortunate. Maybe pick i32 instead of usize for opcodes.
let opcode: u32 = unsafe { rb_iseq_opcode_at_pc(iseq, pc) }
.try_into()
Expand Down Expand Up @@ -3476,6 +3483,18 @@ mod tests {
"#]]);
}

#[test]
fn test_cant_compile_optional_arg() {
eval("
def test(a=nil) = a
");
assert_method_hir("test", expect![[r#"
fn test:
bb0(v0:BasicObject, v1:BasicObject):
SideExit
"#]]);
}

#[test]
fn test_cant_compile_splat() {
eval("
Expand Down
Loading
0