Skip to content

Commit 44e4b02

Browse files
authored
ZJIT: setglobal should not return output (ruby#13744)
* ZJIT: setglobal should not return output * Let the caller wrap Some
1 parent 81a2fdf commit 44e4b02

File tree

4 files changed

+7
-10
lines changed

4 files changed

+7
-10
lines changed

.github/workflows/zjit-macos.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ jobs:
108108
RUST_BACKTRACE=1 ruby --disable=gems ../src/bootstraptest/runner.rb --ruby="./miniruby -I../src/lib -I. -I.ext/common --zjit-call-threshold=1" \
109109
../src/bootstraptest/test_attr.rb \
110110
../src/bootstraptest/test_autoload.rb \
111+
../src/bootstraptest/test_class.rb \
111112
../src/bootstraptest/test_constant_cache.rb \
112113
../src/bootstraptest/test_env.rb \
113114
../src/bootstraptest/test_fiber.rb \
@@ -128,7 +129,6 @@ jobs:
128129
../src/bootstraptest/test_yjit_30k_methods.rb \
129130
../src/bootstraptest/test_yjit_rust_port.rb
130131
# ../src/bootstraptest/test_block.rb \
131-
# ../src/bootstraptest/test_class.rb \
132132
# ../src/bootstraptest/test_eval.rb \
133133
# ../src/bootstraptest/test_exception.rb \
134134
# ../src/bootstraptest/test_gc.rb \

.github/workflows/zjit-ubuntu.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ jobs:
130130
RUST_BACKTRACE=1 ruby --disable=gems ../src/bootstraptest/runner.rb --ruby="./miniruby -I../src/lib -I. -I.ext/common --zjit-call-threshold=1" \
131131
../src/bootstraptest/test_attr.rb \
132132
../src/bootstraptest/test_autoload.rb \
133+
../src/bootstraptest/test_class.rb \
133134
../src/bootstraptest/test_constant_cache.rb \
134135
../src/bootstraptest/test_env.rb \
135136
../src/bootstraptest/test_fiber.rb \
@@ -151,7 +152,6 @@ jobs:
151152
../src/bootstraptest/test_yjit_30k_methods.rb \
152153
../src/bootstraptest/test_yjit_rust_port.rb
153154
# ../src/bootstraptest/test_block.rb \
154-
# ../src/bootstraptest/test_class.rb \
155155
# ../src/bootstraptest/test_eval.rb \
156156
# ../src/bootstraptest/test_exception.rb \
157157
# ../src/bootstraptest/test_gc.rb \

zjit/src/codegen.rs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ fn gen_insn(cb: &mut CodeBlock, jit: &mut JITState, asm: &mut Assembler, functio
278278
Insn::PatchPoint(_) => return Some(()), // For now, rb_zjit_bop_redefined() panics. TODO: leave a patch point and fix rb_zjit_bop_redefined()
279279
Insn::CCall { cfun, args, name: _, return_type: _, elidable: _ } => gen_ccall(jit, asm, *cfun, args)?,
280280
Insn::GetIvar { self_val, id, state: _ } => gen_getivar(asm, opnd!(self_val), *id),
281-
Insn::SetGlobal { id, val, state: _ } => gen_setglobal(asm, *id, opnd!(val)),
281+
Insn::SetGlobal { id, val, state: _ } => return Some(gen_setglobal(asm, *id, opnd!(val))),
282282
Insn::GetGlobal { id, state: _ } => gen_getglobal(asm, *id),
283283
&Insn::GetLocal { ep_offset, level } => gen_nested_getlocal(asm, ep_offset, level)?,
284284
Insn::SetLocal { val, ep_offset, level } => return gen_nested_setlocal(asm, opnd!(val), *ep_offset, *level),
@@ -294,7 +294,7 @@ fn gen_insn(cb: &mut CodeBlock, jit: &mut JITState, asm: &mut Assembler, functio
294294
}
295295
};
296296

297-
assert!(insn.has_output(), "Cannot write LIR output of HIR instruction with no output");
297+
assert!(insn.has_output(), "Cannot write LIR output of HIR instruction with no output: {insn}");
298298

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

453453
/// Set global variables
454-
fn gen_setglobal(asm: &mut Assembler, id: ID, val: Opnd) -> Opnd {
454+
fn gen_setglobal(asm: &mut Assembler, id: ID, val: Opnd) {
455455
asm_comment!(asm, "call rb_gvar_set");
456-
asm.ccall(
457-
rb_gvar_set as *const u8,
458-
vec![Opnd::UImm(id.0), val],
459-
)
456+
asm.ccall(rb_gvar_set as *const u8, vec![Opnd::UImm(id.0), val]);
460457
}
461458

462459
/// Side-exit into the interpreter

zjit/src/hir.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1120,7 +1120,7 @@ impl Function {
11201120
| Insn::IfTrue { .. } | Insn::IfFalse { .. } | Insn::Return { .. }
11211121
| Insn::PatchPoint { .. } | Insn::SetIvar { .. } | Insn::ArrayExtend { .. }
11221122
| Insn::ArrayPush { .. } | Insn::SideExit { .. } | Insn::SetLocal { .. } =>
1123-
panic!("Cannot infer type of instruction with no output"),
1123+
panic!("Cannot infer type of instruction with no output: {}", self.insns[insn.0]),
11241124
Insn::Const { val: Const::Value(val) } => Type::from_value(*val),
11251125
Insn::Const { val: Const::CBool(val) } => Type::from_cbool(*val),
11261126
Insn::Const { val: Const::CInt8(val) } => Type::from_cint(types::CInt8, *val as i64),

0 commit comments

Comments
 (0)