diff options
| author | Max Bernstein <rubybugs@bernsteinbear.com> | 2025-10-20 12:22:53 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-10-20 12:22:53 -0400 |
| commit | 33f1af6779a22ab84633b43d42dcf273a7e3bbe9 (patch) | |
| tree | 7410c575f288f15e67cc336803830cf67da82558 | |
| parent | fba349e65883b7b9541433f7716e41d27c7e8a69 (diff) | |
ZJIT: Remove idx from hir::Insn::Param (#14872)
It turns out that we don't use it anywhere.
| -rw-r--r-- | zjit/src/codegen.rs | 6 | ||||
| -rw-r--r-- | zjit/src/hir.rs | 21 |
2 files changed, 12 insertions, 15 deletions
diff --git a/zjit/src/codegen.rs b/zjit/src/codegen.rs index ea4a7ecc7c..1f04e61dbc 100644 --- a/zjit/src/codegen.rs +++ b/zjit/src/codegen.rs @@ -264,9 +264,9 @@ fn gen_function(cb: &mut CodeBlock, iseq: IseqPtr, function: &Function) -> Resul asm.write_label(label); // Compile all parameters - for &insn_id in block.params() { + for (idx, &insn_id) in block.params().enumerate() { match function.find(insn_id) { - Insn::Param { idx } => { + Insn::Param => { jit.opnds[insn_id.0] = Some(gen_param(&mut asm, idx)); }, insn => unreachable!("Non-param insn found in block.params: {insn:?}"), @@ -367,7 +367,7 @@ fn gen_insn(cb: &mut CodeBlock, jit: &mut JITState, asm: &mut Assembler, functio &Insn::StringGetbyteFixnum { string, index } => gen_string_getbyte_fixnum(asm, opnd!(string), opnd!(index)), Insn::StringIntern { val, state } => gen_intern(asm, opnd!(val), &function.frame_state(*state)), Insn::ToRegexp { opt, values, state } => gen_toregexp(jit, asm, *opt, opnds!(values), &function.frame_state(*state)), - Insn::Param { idx } => unreachable!("block.insns should not have Insn::Param({idx})"), + Insn::Param => unreachable!("block.insns should not have Insn::Param"), Insn::Snapshot { .. } => return Ok(()), // we don't need to do anything for this instruction at the moment Insn::Jump(branch) => no_output!(gen_jump(jit, asm, branch)), Insn::IfTrue { val, target } => no_output!(gen_if_true(jit, asm, opnd!(val), target)), diff --git a/zjit/src/hir.rs b/zjit/src/hir.rs index 73b7cca8d0..370ed56857 100644 --- a/zjit/src/hir.rs +++ b/zjit/src/hir.rs @@ -552,7 +552,7 @@ pub enum SendFallbackReason { pub enum Insn { Const { val: Const }, /// SSA block parameter. Also used for function parameters in the function's entry block. - Param { idx: usize }, + Param, StringCopy { val: InsnId, chilled: bool, state: InsnId }, StringIntern { val: InsnId, state: InsnId }, @@ -888,7 +888,7 @@ impl<'a> std::fmt::Display for InsnPrinter<'a> { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { match &self.inner { Insn::Const { val } => { write!(f, "Const {}", val.print(self.ptr_map)) } - Insn::Param { idx } => { write!(f, "Param {idx}") } + Insn::Param => { write!(f, "Param") } Insn::NewArray { elements, .. } => { write!(f, "NewArray")?; let mut prefix = " "; @@ -3661,18 +3661,15 @@ pub fn iseq_to_hir(iseq: *const rb_iseq_t) -> Result<Function, ParseError> { } // Load basic block params first - let self_param = fun.push_insn(block, Insn::Param { idx: SELF_PARAM_IDX }); + let self_param = fun.push_insn(block, Insn::Param); let mut state = { let mut result = FrameState::new(iseq); - let mut idx = 1; let local_size = if insn_idx == 0 { num_locals(iseq) } else { incoming_state.locals.len() }; for _ in 0..local_size { - result.locals.push(fun.push_insn(block, Insn::Param { idx })); - idx += 1; + result.locals.push(fun.push_insn(block, Insn::Param)); } for _ in incoming_state.stack { - result.stack.push(fun.push_insn(block, Insn::Param { idx })); - idx += 1; + result.stack.push(fun.push_insn(block, Insn::Param)); } result }; @@ -4581,11 +4578,11 @@ fn compile_jit_entry_state(fun: &mut Function, jit_entry_block: BlockId) -> (Ins let iseq = fun.iseq; let param_size = unsafe { get_iseq_body_param_size(iseq) }.as_usize(); - let self_param = fun.push_insn(jit_entry_block, Insn::Param { idx: SELF_PARAM_IDX }); + let self_param = fun.push_insn(jit_entry_block, Insn::Param); let mut entry_state = FrameState::new(iseq); for local_idx in 0..num_locals(iseq) { if local_idx < param_size { - entry_state.locals.push(fun.push_insn(jit_entry_block, Insn::Param { idx: local_idx + 1 })); // +1 for self + entry_state.locals.push(fun.push_insn(jit_entry_block, Insn::Param)); } else { entry_state.locals.push(fun.push_insn(jit_entry_block, Insn::Const { val: Const::Value(Qnil) })); } @@ -4935,7 +4932,7 @@ mod infer_tests { function.push_insn(entry, Insn::IfFalse { val, target: BranchEdge { target: side, args: vec![] } }); let v1 = function.push_insn(entry, Insn::Const { val: Const::Value(VALUE::fixnum_from_usize(4)) }); function.push_insn(entry, Insn::Jump(BranchEdge { target: exit, args: vec![v1] })); - let param = function.push_insn(exit, Insn::Param { idx: 0 }); + let param = function.push_insn(exit, Insn::Param); crate::cruby::with_rubyvm(|| { function.infer_types(); }); @@ -4954,7 +4951,7 @@ mod infer_tests { function.push_insn(entry, Insn::IfFalse { val, target: BranchEdge { target: side, args: vec![] } }); let v1 = function.push_insn(entry, Insn::Const { val: Const::Value(Qfalse) }); function.push_insn(entry, Insn::Jump(BranchEdge { target: exit, args: vec![v1] })); - let param = function.push_insn(exit, Insn::Param { idx: 0 }); + let param = function.push_insn(exit, Insn::Param); crate::cruby::with_rubyvm(|| { function.infer_types(); assert_bit_equal(function.type_of(param), types::TrueClass.union(types::FalseClass)); |
