Commit 74d45d10 authored by qinsoon's avatar qinsoon

[wip] frame size is always a multiple of 16bytes (do not need to align

stack pointer before calling, unless we pushed arguments by stack)
parent 1bac277e
......@@ -705,15 +705,8 @@ impl MachineCode for ASMCode {
regs_to_remove
}
#[allow(unused_variables)]
fn patch_frame_size(&mut self, size: usize, size_used: usize) {
// calling convention requires stack pointer to be 16 bytes aligned before a call
// we make frame size a multipl of 16 bytes
let size = if (size + size_used) % 16 == 0 {
size
} else {
( (size + size_used) / 16 + 1) * 16 - size_used
};
let size = size.to_string();
debug_assert!(size.len() <= FRAME_SIZE_PLACEHOLDER_LEN);
......
......@@ -2206,9 +2206,6 @@ impl <'a> InstructionSelection {
&mut self,
args: &Vec<P<Value>>,
vm: &VM) -> usize {
// if we need to save caller saved regs
// put it here (since this is fastpath compile, we wont have them)
// put args into registers if we can
// in the meantime record args that do not fit in registers
let mut stack_args : Vec<P<Value>> = vec![];
......
......@@ -20,7 +20,7 @@ use vm::VM;
#[derive(RustcEncodable, RustcDecodable, Clone)]
pub struct Frame {
func_ver_id: MuID,
cur_offset: isize, // offset to rbp
cur_offset: isize, // offset to frame base pointer
pub argument_by_reg: HashMap<MuID, P<Value>>,
pub argument_by_stack: HashMap<MuID, P<Value>>,
......@@ -41,6 +41,7 @@ impl fmt::Display for Frame {
for &(ref callsite, ref dest) in self.exception_callsites.iter() {
writeln!(f, " callsite: {} -> {}", callsite, dest).unwrap()
}
writeln!(f, " cur offset: {}", self.cur_offset).unwrap();
writeln!(f, "}}")
}
}
......@@ -58,13 +59,20 @@ impl Frame {
exception_callsites: vec![]
}
}
pub fn cur_offset(&self) -> isize {
self.cur_offset
}
#[cfg(target_arch = "x86_64")]
pub fn cur_size(&self) -> usize {
self.cur_offset.abs() as usize
// frame size is a multiple of 16 bytes
let size = self.cur_offset.abs() as usize;
// frame size is at least 8 byte aligned
assert!(size % 8 == 0);
if size % 16 == 0 {
size
} else {
size + 8
}
}
pub fn add_argument_by_reg(&mut self, temp: MuID, reg: P<Value>) {
......
......@@ -138,7 +138,7 @@ pub extern fn throw_exception_internal(exception_obj: Address, last_frame_callee
let rbp = cursor.rbp.as_usize() as Word;
let array = vec![rbx, rbp, r12, r13, r14, r15];
let rsp = cursor.rbp.offset(frame.cur_offset());
let rsp = cursor.rbp.offset(- (frame.cur_size() as isize));
info!("going to restore thread to {} with RSP {}", dest_addr, rsp);
unsafe {thread::exception_restore(dest_addr, array.as_ptr(), rsp)};
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment