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];