From 4994e3671c6c7e86d5b69cf6b2deafa2a3f877f7 Mon Sep 17 00:00:00 2001 From: Jef Date: Thu, 13 Dec 2018 11:08:34 +0100 Subject: [PATCH] Remove unused argument from fibonacci example --- src/backend.rs | 9 +++------ src/tests.rs | 8 +++----- 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/src/backend.rs b/src/backend.rs index 9759a6b49f..e74c85af9b 100644 --- a/src/backend.rs +++ b/src/backend.rs @@ -481,12 +481,9 @@ pub fn prologue(ctx: &mut Context, stack_slots: u32) { } pub fn epilogue(ctx: &mut Context) { - // TODO: This doesn't work with stack alignment. - // assert_eq!( - // ctx.sp_depth, - // StackDepth(0), - // "imbalanced pushes and pops detected" - // ); + // We don't need to clean up the stack - `rsp` is restored and + // the calling function has its own register stack and will + // stomp on the registers from our stack if necessary. dynasm!(ctx.asm ; mov rsp, rbp ; pop rbp diff --git a/src/tests.rs b/src/tests.rs index fda8c6d64d..7cf63eee11 100644 --- a/src/tests.rs +++ b/src/tests.rs @@ -272,7 +272,7 @@ fn literals() { const FIBONACCI: &str = r#" (module - (func $fib (param $n i32) (param $_unused i32) (result i32) + (func $fib (param $n i32) (result i32) (if (result i32) (i32.eq (i32.const 0) @@ -298,7 +298,6 @@ const FIBONACCI: &str = r#" (get_local $n) (i32.const -1) ) - (i32.const 0) ) ;; fib(n - 2) (call $fib @@ -306,7 +305,6 @@ const FIBONACCI: &str = r#" (get_local $n) (i32.const -2) ) - (i32.const 0) ) ) ) @@ -327,7 +325,7 @@ fn fib() { for x in 0..10 { unsafe { assert_eq!( - translated.execute_func::<_, u32>(0, (x, 0u32)), + translated.execute_func::<_, u32>(0, (x,)), FIB_SEQ[x as usize] ); } @@ -346,5 +344,5 @@ fn bench_run(b: &mut test::Bencher) { let wasm = wabt::wat2wasm(FIBONACCI).unwrap(); let module = translate(&wasm).unwrap(); - b.iter(|| unsafe { module.execute_func::<_, u32>(0, (20, 0u32)) }); + b.iter(|| unsafe { module.execute_func::<_, u32>(0, (20,)) }); }