Add missing .rev() on parameter list and simulate "red zone".

This commit is contained in:
losfair 2019-04-28 13:31:22 +08:00
parent e63d7fd531
commit 46fb72af9d

View File

@ -1063,7 +1063,7 @@ impl X64FunctionCode {
let mut call_movs: Vec<(Location, GPR)> = vec![];
// Prepare register & stack parameters.
for (i, param) in params.iter().enumerate() {
for (i, param) in params.iter().enumerate().rev() {
let loc = Machine::get_param_location(1 + i);
match loc {
Location::GPR(x) => {
@ -1396,6 +1396,8 @@ impl FunctionCodeGenerator<CodegenError> for X64FunctionCode {
.machine
.init_locals(a, self.num_locals, self.num_params);
a.emit_sub(Size::S64, Location::Imm32(32), Location::GPR(GPR::RSP)); // simulate "red zone" if not supported by the platform
self.control_stack.push(ControlFrame {
label: a.get_label(),
loop_like: false,