diff options
| author | Benoit Daloze <eregontp@gmail.com> | 2025-11-18 16:41:15 +0100 |
|---|---|---|
| committer | Benoit Daloze <eregontp@gmail.com> | 2025-11-18 18:54:40 +0100 |
| commit | 79633437e1a971abd5dda54dc584eec3adb4e7a7 (patch) | |
| tree | 741b73897a74df0aad6b182d8e7bac3e15437801 | |
| parent | 0e10dfded0498cf71efb9fc61a804db6db540009 (diff) | |
ZJIT: Rename the operand of Insn::GuardNotFrozen from val to recv
* When writing to an object, the receiver should be checked if it's frozen,
not the value, so this avoids an error-prone autocomplete.
| -rw-r--r-- | zjit/src/codegen.rs | 8 | ||||
| -rw-r--r-- | zjit/src/cruby_methods.rs | 4 | ||||
| -rw-r--r-- | zjit/src/hir.rs | 14 |
3 files changed, 13 insertions, 13 deletions
diff --git a/zjit/src/codegen.rs b/zjit/src/codegen.rs index fd72ea8a47..8fc66791a6 100644 --- a/zjit/src/codegen.rs +++ b/zjit/src/codegen.rs @@ -415,7 +415,7 @@ fn gen_insn(cb: &mut CodeBlock, jit: &mut JITState, asm: &mut Assembler, functio Insn::GuardTypeNot { val, guard_type, state } => gen_guard_type_not(jit, asm, opnd!(val), *guard_type, &function.frame_state(*state)), Insn::GuardBitEquals { val, expected, state } => gen_guard_bit_equals(jit, asm, opnd!(val), *expected, &function.frame_state(*state)), &Insn::GuardBlockParamProxy { level, state } => no_output!(gen_guard_block_param_proxy(jit, asm, level, &function.frame_state(state))), - Insn::GuardNotFrozen { val, state } => gen_guard_not_frozen(jit, asm, opnd!(val), &function.frame_state(*state)), + Insn::GuardNotFrozen { recv, state } => gen_guard_not_frozen(jit, asm, opnd!(recv), &function.frame_state(*state)), &Insn::GuardLess { left, right, state } => gen_guard_less(jit, asm, opnd!(left), opnd!(right), &function.frame_state(state)), &Insn::GuardGreaterEq { left, right, state } => gen_guard_greater_eq(jit, asm, opnd!(left), opnd!(right), &function.frame_state(state)), Insn::PatchPoint { invariant, state } => no_output!(gen_patch_point(jit, asm, invariant, &function.frame_state(*state))), @@ -645,12 +645,12 @@ fn gen_guard_block_param_proxy(jit: &JITState, asm: &mut Assembler, level: u32, asm.jz(side_exit(jit, state, SideExitReason::BlockParamProxyNotIseqOrIfunc)); } -fn gen_guard_not_frozen(jit: &JITState, asm: &mut Assembler, val: Opnd, state: &FrameState) -> Opnd { - let ret = asm_ccall!(asm, rb_obj_frozen_p, val); +fn gen_guard_not_frozen(jit: &JITState, asm: &mut Assembler, recv: Opnd, state: &FrameState) -> Opnd { + let ret = asm_ccall!(asm, rb_obj_frozen_p, recv); asm_comment!(asm, "side-exit if rb_obj_frozen_p returns Qtrue"); asm.cmp(ret, Qtrue.into()); asm.je(side_exit(jit, state, GuardNotFrozen)); - val + recv } fn gen_guard_less(jit: &JITState, asm: &mut Assembler, left: Opnd, right: Opnd, state: &FrameState) -> Opnd { diff --git a/zjit/src/cruby_methods.rs b/zjit/src/cruby_methods.rs index 8dc5330283..d2d6be2dec 100644 --- a/zjit/src/cruby_methods.rs +++ b/zjit/src/cruby_methods.rs @@ -306,7 +306,7 @@ fn inline_array_push(fun: &mut hir::Function, block: hir::BlockId, recv: hir::In fn inline_array_pop(fun: &mut hir::Function, block: hir::BlockId, recv: hir::InsnId, args: &[hir::InsnId], state: hir::InsnId) -> Option<hir::InsnId> { // Only inline the case of no arguments. let &[] = args else { return None; }; - let arr = fun.push_insn(block, hir::Insn::GuardNotFrozen { val: recv, state }); + let arr = fun.push_insn(block, hir::Insn::GuardNotFrozen { recv, state }); Some(fun.push_insn(block, hir::Insn::ArrayPop { array: arr, state })) } @@ -367,7 +367,7 @@ fn inline_string_setbyte(fun: &mut hir::Function, block: hir::BlockId, recv: hir let unboxed_index = fun.push_insn(block, hir::Insn::GuardLess { left: unboxed_index, right: len, state }); let zero = fun.push_insn(block, hir::Insn::Const { val: hir::Const::CInt64(0) }); let _ = fun.push_insn(block, hir::Insn::GuardGreaterEq { left: unboxed_index, right: zero, state }); - let recv = fun.push_insn(block, hir::Insn::GuardNotFrozen { val: recv, state }); + let recv = fun.push_insn(block, hir::Insn::GuardNotFrozen { recv, state }); let _ = fun.push_insn(block, hir::Insn::StringSetbyteFixnum { string: recv, index, value }); // String#setbyte returns the fixnum provided as its `value` argument back to the caller. Some(value) diff --git a/zjit/src/hir.rs b/zjit/src/hir.rs index e1a61b2399..b3c72393f2 100644 --- a/zjit/src/hir.rs +++ b/zjit/src/hir.rs @@ -879,7 +879,7 @@ pub enum Insn { /// is neither ISEQ nor ifunc, which makes it incompatible with rb_block_param_proxy. GuardBlockParamProxy { level: u32, state: InsnId }, /// Side-exit if val is frozen. - GuardNotFrozen { val: InsnId, state: InsnId }, + GuardNotFrozen { recv: InsnId, state: InsnId }, /// Side-exit if left is not greater than or equal to right (both operands are C long). GuardGreaterEq { left: InsnId, right: InsnId, state: InsnId }, /// Side-exit if left is not less than right (both operands are C long). @@ -1191,7 +1191,7 @@ impl<'a> std::fmt::Display for InsnPrinter<'a> { Insn::GuardBitEquals { val, expected, .. } => { write!(f, "GuardBitEquals {val}, {}", expected.print(self.ptr_map)) }, &Insn::GuardShape { val, shape, .. } => { write!(f, "GuardShape {val}, {:p}", self.ptr_map.map_shape(shape)) }, Insn::GuardBlockParamProxy { level, .. } => write!(f, "GuardBlockParamProxy l{level}"), - Insn::GuardNotFrozen { val, .. } => write!(f, "GuardNotFrozen {val}"), + Insn::GuardNotFrozen { recv, .. } => write!(f, "GuardNotFrozen {recv}"), Insn::GuardLess { left, right, .. } => write!(f, "GuardLess {left}, {right}"), Insn::GuardGreaterEq { left, right, .. } => write!(f, "GuardGreaterEq {left}, {right}"), Insn::PatchPoint { invariant, .. } => { write!(f, "PatchPoint {}", invariant.print(self.ptr_map)) }, @@ -1786,7 +1786,7 @@ impl Function { &GuardBitEquals { val, expected, state } => GuardBitEquals { val: find!(val), expected, state }, &GuardShape { val, shape, state } => GuardShape { val: find!(val), shape, state }, &GuardBlockParamProxy { level, state } => GuardBlockParamProxy { level, state: find!(state) }, - &GuardNotFrozen { val, state } => GuardNotFrozen { val: find!(val), state }, + &GuardNotFrozen { recv, state } => GuardNotFrozen { recv: find!(recv), state }, &GuardGreaterEq { left, right, state } => GuardGreaterEq { left: find!(left), right: find!(right), state }, &GuardLess { left, right, state } => GuardLess { left: find!(left), right: find!(right), state }, &FixnumAdd { left, right, state } => FixnumAdd { left: find!(left), right: find!(right), state }, @@ -2004,7 +2004,7 @@ impl Function { Insn::GuardTypeNot { .. } => types::BasicObject, Insn::GuardBitEquals { val, expected, .. } => self.type_of(*val).intersection(Type::from_const(*expected)), Insn::GuardShape { val, .. } => self.type_of(*val), - Insn::GuardNotFrozen { val, .. } => self.type_of(*val), + Insn::GuardNotFrozen { recv, .. } => self.type_of(*recv), Insn::GuardLess { left, .. } => self.type_of(*left), Insn::GuardGreaterEq { left, .. } => self.type_of(*left), Insn::FixnumAdd { .. } => types::Fixnum, @@ -2513,7 +2513,7 @@ impl Function { }; let replacement = if let (OptimizedMethodType::StructAset, &[val]) = (opt_type, args.as_slice()) { - self.push_insn(block, Insn::GuardNotFrozen { val: recv, state }); + self.push_insn(block, Insn::GuardNotFrozen { recv, state }); self.push_insn(block, Insn::StoreField { recv: target, id: mid, offset, val }); self.push_insn(block, Insn::WriteBarrier { recv, val }); val @@ -3402,7 +3402,7 @@ impl Function { | &Insn::GuardTypeNot { val, state, .. } | &Insn::GuardBitEquals { val, state, .. } | &Insn::GuardShape { val, state, .. } - | &Insn::GuardNotFrozen { val, state } + | &Insn::GuardNotFrozen { recv: val, state } | &Insn::ToArray { val, state } | &Insn::IsMethodCfunc { val, state, .. } | &Insn::ToNewArray { val, state } @@ -3882,7 +3882,7 @@ impl Function { | Insn::IsNil { val } | Insn::IsMethodCfunc { val, .. } | Insn::GuardShape { val, .. } - | Insn::GuardNotFrozen { val, .. } + | Insn::GuardNotFrozen { recv: val, .. } | Insn::SetGlobal { val, .. } | Insn::SetLocal { val, .. } | Insn::SetClassVar { val, .. } |
