From: Brendan Hansen Date: Mon, 24 Aug 2020 02:32:27 +0000 (-0500) Subject: bugfixes with alignment X-Git-Url: https://git.brendanfh.com/?a=commitdiff_plain;h=0bdbbf9e2a6958b3280b4e28caaeb548466832aa;p=onyx.git bugfixes with alignment --- diff --git a/onyx b/onyx index 4775a53c..a8ec7737 100755 Binary files a/onyx and b/onyx differ diff --git a/progs/wasi_test.onyx b/progs/wasi_test.onyx index b7d737df..4e1ff14d 100644 --- a/progs/wasi_test.onyx +++ b/progs/wasi_test.onyx @@ -301,8 +301,10 @@ main :: proc (argc: u32, argv: ^cstring) { |> print(); } - while i := 0; i < 10 { + while i := 10; i < 10 { print("Looping\n"); i += 1; + } else { + print("Never ran the loop\n"); } } diff --git a/src/onyxwasm.c b/src/onyxwasm.c index dad44852..3ba6923c 100644 --- a/src/onyxwasm.c +++ b/src/onyxwasm.c @@ -966,6 +966,9 @@ COMPILE_FUNC(call, AstCall* call) { Type* return_type = call->callee->type->Function.return_type; u32 return_size = type_size_of(return_type); + u32 return_align = type_alignment_of(return_type); + bh_align(return_size, return_align); + u64 stack_top_idx = bh_imap_get(&mod->index_map, (u64) &builtin_stack_top); if (cc == CC_Return_Stack) { @@ -1686,6 +1689,8 @@ COMPILE_FUNC(return, AstReturn* ret) { COMPILE_FUNC(stack_enter, u64 stacksize) { bh_arr(WasmInstruction) code = *pcode; + bh_align(stacksize, 16); + u64 stack_top_idx = bh_imap_get(&mod->index_map, (u64) &builtin_stack_top); // HACK: slightly... There will be space for 5 instructions