bugfixes with alignment
authorBrendan Hansen <brendan.f.hansen@gmail.com>
Mon, 24 Aug 2020 02:32:27 +0000 (21:32 -0500)
committerBrendan Hansen <brendan.f.hansen@gmail.com>
Mon, 24 Aug 2020 02:32:27 +0000 (21:32 -0500)
onyx
progs/wasi_test.onyx
src/onyxwasm.c

diff --git a/onyx b/onyx
index 4775a53ced31956564e0e8af7153bb33f6b3f45d..a8ec773716b9d5449f5a0adfaa03f6b21d7a0e87 100755 (executable)
Binary files a/onyx and b/onyx differ
index b7d737df347e5778042902e6d7be41943cc41a70..4e1ff14d7897fdf5f1b75361d095c70da5a448e9 100644 (file)
@@ -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");
     }
 }
index dad44852a8d6f31a221478f0deba958d89ab04bc..3ba6923cf33e51703354d4292bf109eb4aea7a4a 100644 (file)
@@ -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