From 78fd995ad380e8af1cbe4f9c6d5639c9820b1798 Mon Sep 17 00:00:00 2001 From: losfair Date: Mon, 25 Feb 2019 23:38:33 +0800 Subject: [PATCH] Fix argument passing at entry. --- lib/dynasm-backend/src/codegen_x64.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/dynasm-backend/src/codegen_x64.rs b/lib/dynasm-backend/src/codegen_x64.rs index 478051979..efbdb144f 100644 --- a/lib/dynasm-backend/src/codegen_x64.rs +++ b/lib/dynasm-backend/src/codegen_x64.rs @@ -159,10 +159,10 @@ impl ProtectedCaller for X64ExecutionContext { } let f = &self.functions[index]; - let mut total_size: usize = 0; + let total_size = f.num_params * 8; - for local in &f.locals[0..f.num_params] { - total_size += get_size_of_type(&local.ty).unwrap(); + if f.num_params > 0 && f.locals[f.num_params - 1].stack_offset != total_size { + panic!("internal error: inconsistent stack layout"); } let mut param_buf: Vec = vec![0; total_size];