diff options
author | Max Bernstein <[email protected]> | 2025-06-12 15:22:57 -0700 |
---|---|---|
committer | Max Bernstein <[email protected]> | 2025-06-13 08:54:35 -0700 |
commit | 0674f7dfb5fa79c5b2158c38f2ae80bc5692922a (patch) | |
tree | 93f455c17626521364aeb25473b0ab154481c002 | |
parent | f208e017f200a7912cf172cfbb9849ed0214cf2f (diff) |
ZJIT: Only write LIR output of HIR instructions with output
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/13602
-rw-r--r-- | zjit/src/codegen.rs | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/zjit/src/codegen.rs b/zjit/src/codegen.rs index dd04e60602..f274a64ca6 100644 --- a/zjit/src/codegen.rs +++ b/zjit/src/codegen.rs @@ -277,7 +277,7 @@ fn gen_insn(cb: &mut CodeBlock, jit: &mut JITState, asm: &mut Assembler, functio Insn::GetIvar { self_val, id, state: _ } => gen_getivar(asm, opnd!(self_val), *id), Insn::SetGlobal { id, val, state: _ } => gen_setglobal(asm, *id, opnd!(val)), Insn::GetGlobal { id, state: _ } => gen_getglobal(asm, *id), - Insn::SetIvar { self_val, id, val, state: _ } => gen_setivar(asm, opnd!(self_val), *id, opnd!(val)), + Insn::SetIvar { self_val, id, val, state: _ } => return gen_setivar(asm, opnd!(self_val), *id, opnd!(val)), Insn::SideExit { state } => return gen_side_exit(jit, asm, &function.frame_state(*state)), _ => { debug!("ZJIT: gen_function: unexpected insn {:?}", insn); @@ -285,6 +285,8 @@ fn gen_insn(cb: &mut CodeBlock, jit: &mut JITState, asm: &mut Assembler, functio } }; + assert!(insn.has_output(), "Cannot write LIR output of HIR instruction with no output"); + // If the instruction has an output, remember it in jit.opnds jit.opnds[insn_id.0] = Some(out_opnd); @@ -312,12 +314,13 @@ fn gen_getivar(asm: &mut Assembler, recv: Opnd, id: ID) -> Opnd { } /// Emit an uncached instance variable store -fn gen_setivar(asm: &mut Assembler, recv: Opnd, id: ID, val: Opnd) -> Opnd { +fn gen_setivar(asm: &mut Assembler, recv: Opnd, id: ID, val: Opnd) -> Option<()> { asm_comment!(asm, "call rb_ivar_set"); asm.ccall( rb_ivar_set as *const u8, vec![recv, Opnd::UImm(id.0), val], - ) + ); + Some(()) } /// Look up global variables |