Skip to content

Commit

Permalink
Swap REGISTER_PTR_TO_VM, REGISTER_INSTRUCTION_METER and registers[10].
Browse files Browse the repository at this point in the history
  • Loading branch information
Lichtso committed Sep 30, 2023
1 parent f25c759 commit e45b16f
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions src/jit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ impl JitProgram {
"push rbp",
"mov [{host_stack_pointer}], rsp",
"add QWORD PTR [{host_stack_pointer}], -8", // We will push RIP in "call r10" later
"mov rbp, {rbp}",
"mov rbx, rax",
"mov rax, [r11 + 0x00]",
"mov rsi, [r11 + 0x08]",
"mov rdx, [r11 + 0x10]",
Expand All @@ -121,17 +121,18 @@ impl JitProgram {
"mov r13, [r11 + 0x38]",
"mov r14, [r11 + 0x40]",
"mov r15, [r11 + 0x48]",
"mov rbx, [r11 + 0x50]",
"mov rbp, [r11 + 0x50]",
"mov r11, [r11 + 0x58]",
"call r10",
"mov rax, rbx",
"pop rbp",
"pop rbx",
host_stack_pointer = in(reg) &mut vm.host_stack_pointer,
rbp = in(reg) (vm as *mut _ as *mut u64).offset(*RUNTIME_ENVIRONMENT_KEY.get().unwrap() as isize),
inlateout("rdi") instruction_meter,
inlateout("rax") instruction_meter,
inlateout("rdi") (vm as *mut _ as *mut u64).offset(*RUNTIME_ENVIRONMENT_KEY.get().unwrap() as isize) => _,
inlateout("r10") self.pc_section[registers[11] as usize] => _,
inlateout("r11") &registers => _,
lateout("rax") _, lateout("rsi") _, lateout("rdx") _, lateout("rcx") _, lateout("r8") _,
lateout("rsi") _, lateout("rdx") _, lateout("rcx") _, lateout("r8") _,
lateout("r9") _, lateout("r12") _, lateout("r13") _, lateout("r14") _, lateout("r15") _,
// lateout("rbp") _, lateout("rbx") _,
);
Expand Down Expand Up @@ -207,13 +208,13 @@ const REGISTER_MAP: [u8; 11] = [
CALLEE_SAVED_REGISTERS[3], // R13
CALLEE_SAVED_REGISTERS[4], // R14
CALLEE_SAVED_REGISTERS[5], // R15
CALLEE_SAVED_REGISTERS[1], // RBX
CALLEE_SAVED_REGISTERS[0], // RBP
];

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

0 comments on commit e45b16f

Please sign in to comment.