Thanks to visit codestin.com
Credit goes to github.com

Skip to content

ZJIT: setglobal should not return output #13744

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.

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

Merged
merged 2 commits into from
Jun 30, 2025
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion .github/workflows/zjit-macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ jobs:
RUST_BACKTRACE=1 ruby --disable=gems ../src/bootstraptest/runner.rb --ruby="./miniruby -I../src/lib -I. -I.ext/common --zjit-call-threshold=1" \
../src/bootstraptest/test_attr.rb \
../src/bootstraptest/test_autoload.rb \
../src/bootstraptest/test_class.rb \
../src/bootstraptest/test_constant_cache.rb \
../src/bootstraptest/test_env.rb \
../src/bootstraptest/test_fiber.rb \
Expand All @@ -128,7 +129,6 @@ jobs:
../src/bootstraptest/test_yjit_30k_methods.rb \
../src/bootstraptest/test_yjit_rust_port.rb
# ../src/bootstraptest/test_block.rb \
# ../src/bootstraptest/test_class.rb \
# ../src/bootstraptest/test_eval.rb \
# ../src/bootstraptest/test_exception.rb \
# ../src/bootstraptest/test_gc.rb \
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/zjit-ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ jobs:
RUST_BACKTRACE=1 ruby --disable=gems ../src/bootstraptest/runner.rb --ruby="./miniruby -I../src/lib -I. -I.ext/common --zjit-call-threshold=1" \
../src/bootstraptest/test_attr.rb \
../src/bootstraptest/test_autoload.rb \
../src/bootstraptest/test_class.rb \
../src/bootstraptest/test_constant_cache.rb \
../src/bootstraptest/test_env.rb \
../src/bootstraptest/test_fiber.rb \
Expand All @@ -151,7 +152,6 @@ jobs:
../src/bootstraptest/test_yjit_30k_methods.rb \
../src/bootstraptest/test_yjit_rust_port.rb
# ../src/bootstraptest/test_block.rb \
# ../src/bootstraptest/test_class.rb \
# ../src/bootstraptest/test_eval.rb \
# ../src/bootstraptest/test_exception.rb \
# ../src/bootstraptest/test_gc.rb \
Expand Down
11 changes: 4 additions & 7 deletions zjit/src/codegen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ fn gen_insn(cb: &mut CodeBlock, jit: &mut JITState, asm: &mut Assembler, functio
Insn::PatchPoint(_) => return Some(()), // For now, rb_zjit_bop_redefined() panics. TODO: leave a patch point and fix rb_zjit_bop_redefined()
Insn::CCall { cfun, args, name: _, return_type: _, elidable: _ } => gen_ccall(jit, asm, *cfun, args)?,
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::SetGlobal { id, val, state: _ } => return Some(gen_setglobal(asm, *id, opnd!(val))),
Insn::GetGlobal { id, state: _ } => gen_getglobal(asm, *id),
&Insn::GetLocal { ep_offset, level } => gen_nested_getlocal(asm, ep_offset, level)?,
Insn::SetLocal { val, ep_offset, level } => return gen_nested_setlocal(asm, opnd!(val), *ep_offset, *level),
Expand All @@ -294,7 +294,7 @@ 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");
assert!(insn.has_output(), "Cannot write LIR output of HIR instruction with no output: {insn}");

// If the instruction has an output, remember it in jit.opnds
jit.opnds[insn_id.0] = Some(out_opnd);
Expand Down Expand Up @@ -451,12 +451,9 @@ fn gen_getglobal(asm: &mut Assembler, id: ID) -> Opnd {
}

/// Set global variables
fn gen_setglobal(asm: &mut Assembler, id: ID, val: Opnd) -> Opnd {
fn gen_setglobal(asm: &mut Assembler, id: ID, val: Opnd) {
asm_comment!(asm, "call rb_gvar_set");
asm.ccall(
rb_gvar_set as *const u8,
vec![Opnd::UImm(id.0), val],
)
asm.ccall(rb_gvar_set as *const u8, vec![Opnd::UImm(id.0), val]);
}

/// Side-exit into the interpreter
Expand Down
2 changes: 1 addition & 1 deletion zjit/src/hir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1120,7 +1120,7 @@ impl Function {
| Insn::IfTrue { .. } | Insn::IfFalse { .. } | Insn::Return { .. }
| Insn::PatchPoint { .. } | Insn::SetIvar { .. } | Insn::ArrayExtend { .. }
| Insn::ArrayPush { .. } | Insn::SideExit { .. } | Insn::SetLocal { .. } =>
panic!("Cannot infer type of instruction with no output"),
panic!("Cannot infer type of instruction with no output: {}", self.insns[insn.0]),
Insn::Const { val: Const::Value(val) } => Type::from_value(*val),
Insn::Const { val: Const::CBool(val) } => Type::from_cbool(*val),
Insn::Const { val: Const::CInt8(val) } => Type::from_cint(types::CInt8, *val as i64),
Expand Down
Loading