diff options
| author | Takashi Kokubun <takashikkbn@gmail.com> | 2025-08-19 11:57:19 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-08-19 11:57:19 -0700 |
| commit | da01faaaccba3be326bfa607f6b36699274e329c (patch) | |
| tree | 98a239b263c1215ee723948b56f776916b007057 /zjit/src | |
| parent | 3ff1ca07bab3603ad2c0744983d5d7b8b9ac3a44 (diff) | |
ZJIT: Remove try_num_bits (#14272)
Diffstat (limited to 'zjit/src')
| -rw-r--r-- | zjit/src/backend/lir.rs | 25 | ||||
| -rw-r--r-- | zjit/src/codegen.rs | 4 |
2 files changed, 9 insertions, 20 deletions
diff --git a/zjit/src/backend/lir.rs b/zjit/src/backend/lir.rs index 460e2719dd..be5bda052d 100644 --- a/zjit/src/backend/lir.rs +++ b/zjit/src/backend/lir.rs @@ -147,26 +147,15 @@ impl Opnd } } - /// Return Some(Opnd) with a given num_bits if self has num_bits. - /// None if self doesn't have a num_bits field. - pub fn try_num_bits(&self, num_bits: u8) -> Option<Opnd> { - assert!(num_bits == 8 || num_bits == 16 || num_bits == 32 || num_bits == 64); - match *self { - Opnd::Reg(reg) => Some(Opnd::Reg(reg.with_num_bits(num_bits))), - Opnd::Mem(Mem { base, disp, .. }) => Some(Opnd::Mem(Mem { base, disp, num_bits })), - Opnd::VReg { idx, .. } => Some(Opnd::VReg { idx, num_bits }), - _ => None, - } - } - - /// Return Opnd with a given num_bits if self has num_bits. - /// Panic otherwise. This should be used only when you know which Opnd self is. + /// Return Opnd with a given num_bits if self has num_bits. Panic otherwise. #[track_caller] pub fn with_num_bits(&self, num_bits: u8) -> Opnd { - if let Some(opnd) = self.try_num_bits(num_bits) { - opnd - } else { - unreachable!("with_num_bits should not be used on: {self:?}"); + assert!(num_bits == 8 || num_bits == 16 || num_bits == 32 || num_bits == 64); + match *self { + Opnd::Reg(reg) => Opnd::Reg(reg.with_num_bits(num_bits)), + Opnd::Mem(Mem { base, disp, .. }) => Opnd::Mem(Mem { base, disp, num_bits }), + Opnd::VReg { idx, .. } => Opnd::VReg { idx, num_bits }, + _ => unreachable!("with_num_bits should not be used for: {self:?}"), } } diff --git a/zjit/src/codegen.rs b/zjit/src/codegen.rs index 5fb83b5f48..c588a93651 100644 --- a/zjit/src/codegen.rs +++ b/zjit/src/codegen.rs @@ -1183,8 +1183,8 @@ fn gen_guard_type(jit: &mut JITState, asm: &mut Assembler, val: lir::Opnd, guard asm.jne(side_exit(jit, state, GuardType(guard_type))); } else if guard_type.is_subtype(types::StaticSymbol) { // Static symbols have (val & 0xff) == RUBY_SYMBOL_FLAG - // Use 8-bit comparison like YJIT does - debug_assert!(val.try_num_bits(8).is_some(), "GuardType should not be used for a known constant, but val was: {val:?}"); + // Use 8-bit comparison like YJIT does. GuardType should not be used + // for a known VALUE, which with_num_bits() does not support. asm.cmp(val.with_num_bits(8), Opnd::UImm(RUBY_SYMBOL_FLAG as u64)); asm.jne(side_exit(jit, state, GuardType(guard_type))); } else if guard_type.is_subtype(types::NilClass) { |
