Skip to content

Commit cfa429e

Browse files
committed
ZJIT: Add asm.sub_into helper
1 parent a9d9b9d commit cfa429e

2 files changed

Lines changed: 7 additions & 4 deletions

File tree

zjit/src/backend/lir.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2233,6 +2233,11 @@ impl Assembler {
22332233
out
22342234
}
22352235

2236+
pub fn sub_into(&mut self, left: Opnd, right: Opnd) -> Opnd {
2237+
self.push_insn(Insn::Sub { left, right, out: left });
2238+
left
2239+
}
2240+
22362241
#[must_use]
22372242
pub fn mul(&mut self, left: Opnd, right: Opnd) -> Opnd {
22382243
let out = self.new_vreg(Opnd::match_num_bits(&[left, right]));

zjit/src/codegen.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -876,8 +876,7 @@ fn gen_send_without_block_direct(
876876
asm.je(Target::SideExit { context: None, reason: CalleeSideExit, label: None });
877877

878878
asm_comment!(asm, "restore SP register for the caller");
879-
let new_sp = asm.sub(SP, sp_offset.into());
880-
asm.mov(SP, new_sp);
879+
asm.sub_into(SP, sp_offset.into());
881880

882881
Some(ret)
883882
}
@@ -1474,8 +1473,7 @@ fn gen_string_concat(jit: &mut JITState, asm: &mut Assembler, strings: Vec<Opnd>
14741473
let allocation_size = aligned_stack_bytes(n);
14751474

14761475
asm_comment!(asm, "allocate {} bytes on C stack for {} strings", allocation_size, n);
1477-
let new_sp = asm.sub(NATIVE_STACK_PTR, allocation_size.into());
1478-
asm.mov(NATIVE_STACK_PTR, new_sp);
1476+
asm.sub_into(NATIVE_STACK_PTR, allocation_size.into());
14791477

14801478
// Calculate the total offset from NATIVE_BASE_PTR to our buffer
14811479
let total_offset_from_base = (frame_size + allocation_size) as i32;

0 commit comments

Comments
 (0)