Skip to content

Commit c1cec78

Browse files
committed
ZJIT: Make lir::Opnd::const_ptr take any pointer to save on casts
1 parent da3b6ee commit c1cec78

2 files changed

Lines changed: 4 additions & 4 deletions

File tree

zjit/src/backend/lir.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ impl Opnd
116116
}
117117

118118
/// Constructor for constant pointer operand
119-
pub fn const_ptr(ptr: *const u8) -> Self {
119+
pub fn const_ptr<T>(ptr: *const T) -> Self {
120120
Opnd::UImm(ptr as u64)
121121
}
122122

@@ -1808,7 +1808,7 @@ impl Assembler
18081808
}
18091809

18101810
asm_comment!(self, "save cfp->pc");
1811-
self.load_into(Opnd::Reg(Assembler::SCRATCH_REG), Opnd::const_ptr(pc as *const u8));
1811+
self.load_into(Opnd::Reg(Assembler::SCRATCH_REG), Opnd::const_ptr(pc));
18121812
self.store(Opnd::mem(64, CFP, RUBY_OFFSET_CFP_PC), Opnd::Reg(Assembler::SCRATCH_REG));
18131813

18141814
asm_comment!(self, "save cfp->sp");

zjit/src/codegen.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,7 @@ fn gen_get_constant_path(asm: &mut Assembler, ic: *const iseq_inline_constant_ca
396396
// Save PC since the call can allocate an IC
397397
gen_save_pc(asm, state);
398398

399-
ccall![rb_vm_opt_getconstant_path(EC, CFP, Opnd::const_ptr(ic as *const u8)), asm]
399+
ccall![rb_vm_opt_getconstant_path(EC, CFP, Opnd::const_ptr(ic)), asm]
400400
}
401401

402402
fn gen_invokebuiltin(jit: &mut JITState, asm: &mut Assembler, state: &FrameState, bf: &rb_builtin_function, args: &Vec<InsnId>) -> Option<lir::Opnd> {
@@ -952,7 +952,7 @@ fn gen_save_pc(asm: &mut Assembler, state: &FrameState) {
952952
let next_pc: *const VALUE = unsafe { state.pc.offset(insn_len(opcode) as isize) };
953953

954954
asm_comment!(asm, "save PC to CFP");
955-
asm.mov(Opnd::mem(64, CFP, RUBY_OFFSET_CFP_PC), Opnd::const_ptr(next_pc as *const u8));
955+
asm.mov(Opnd::mem(64, CFP, RUBY_OFFSET_CFP_PC), Opnd::const_ptr(next_pc));
956956
}
957957

958958
/// Save the current SP on the CFP

0 commit comments

Comments
 (0)