Fix stack depth in rem, update cranelift-codegen

This commit is contained in:
Jef
2019-07-11 13:10:47 +02:00
parent f53dc0b309
commit 7cc6a1d9f3
2 changed files with 13 additions and 1 deletions

View File

@@ -19,7 +19,7 @@ itertools = "0.8"
capstone = "0.5.0"
failure = "0.1.3"
failure_derive = "0.1.3"
cranelift-codegen = "0.30"
cranelift-codegen = "0.33"
multi_mut = "0.1"
either = "1.5"
wabt = "0.7"

View File

@@ -843,6 +843,8 @@ macro_rules! int_div {
let is_neg1 = self.create_label();
let current_depth = self.block_state.depth.clone();
// TODO: This could cause segfaults because of implicit push/pop
let gen_neg1_case = match divisor {
ValueLocation::Immediate(_) => {
@@ -858,6 +860,11 @@ macro_rules! int_div {
let reg = self.into_reg(GPRType::Rq, divisor).unwrap();
dynasm!(self.asm
; cmp $reg_ty(reg.rq().unwrap()), -1
);
// TODO: We could choose `current_depth` as the depth here instead but we currently
// don't for simplicity
self.set_stack_depth(current_depth.clone());
dynasm!(self.asm
; je =>is_neg1.0
);
@@ -867,6 +874,9 @@ macro_rules! int_div {
let offset = self.adjusted_offset(offset);
dynasm!(self.asm
; cmp $pointer_ty [rsp + offset], -1
);
self.set_stack_depth(current_depth.clone());
dynasm!(self.asm
; je =>is_neg1.0
);
@@ -902,6 +912,7 @@ macro_rules! int_div {
if gen_neg1_case {
let ret = self.create_label();
self.set_stack_depth(current_depth.clone());
dynasm!(self.asm
; jmp =>ret.0
);
@@ -912,6 +923,7 @@ macro_rules! int_div {
CCLoc::try_from(rem).expect("Programmer error")
);
self.set_stack_depth(current_depth.clone());
self.define_label(ret);
}