Skip to content

Commit

Permalink
Swaps RBP and R10.
Browse files Browse the repository at this point in the history
  • Loading branch information
Lichtso committed Sep 27, 2024
1 parent 871b459 commit ab7bc38
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/jit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ impl JitProgram {
// RBX must be saved and restored manually in the current version of rustc and llvm.
"push rbx",
"mov [{host_stack_pointer}], rsp",
"add QWORD PTR [{host_stack_pointer}], -8", // We will push RIP in "call r10" later
"add QWORD PTR [{host_stack_pointer}], -8", // We will push RIP in "call rbp" later
"mov rbp, rax",
"mov rax, [r11 + 0x00]",
"mov rsi, [r11 + 0x08]",
Expand All @@ -126,12 +126,12 @@ impl JitProgram {
"mov r14, [r11 + 0x48]",
"mov r15, [r11 + 0x50]",
"mov r11, [r11 + 0x58]",
"call r10",
"call rbp",
"pop rbx",
host_stack_pointer = in(reg) &mut vm.host_stack_pointer,
inlateout("rdi") std::ptr::addr_of_mut!(*vm).cast::<u64>().offset(get_runtime_environment_key() as isize) => _,
inlateout("rax") (vm.previous_instruction_meter as i64).wrapping_add(registers[11] as i64) => _,
inlateout("r10") self.pc_section[registers[11] as usize] => _,
inlateout("r10") (vm.previous_instruction_meter as i64).wrapping_add(registers[11] as i64) => _,
inlateout("rax") self.pc_section[registers[11] as usize] => _,
inlateout("r11") &registers => _,
lateout("rsi") _, lateout("rdx") _, lateout("rcx") _, lateout("r8") _,
lateout("r9") _, lateout("r12") _, lateout("r13") _, lateout("r14") _, lateout("r15") _,
Expand Down Expand Up @@ -213,10 +213,10 @@ const REGISTER_MAP: [u8; 11] = [

/// RDI: Used together with slot_in_vm()
const REGISTER_PTR_TO_VM: u8 = ARGUMENT_REGISTERS[0];
/// RBP: Program counter limit
const REGISTER_INSTRUCTION_METER: u8 = CALLEE_SAVED_REGISTERS[0];
/// R10: Other scratch register
// const REGISTER_OTHER_SCRATCH: u8 = CALLER_SAVED_REGISTERS[7];
/// R10: Program counter limit
const REGISTER_INSTRUCTION_METER: u8 = CALLER_SAVED_REGISTERS[7];
/// RBP: Other scratch register
const REGISTER_OTHER_SCRATCH: u8 = CALLEE_SAVED_REGISTERS[0];
/// R11: Scratch register
const REGISTER_SCRATCH: u8 = CALLER_SAVED_REGISTERS[8];

Expand Down

0 comments on commit ab7bc38

Please sign in to comment.