Skip to content

Commit

Permalink
only allocate as much space on stack for return pointer as needed
Browse files Browse the repository at this point in the history
  • Loading branch information
Hood committed Jun 26, 2021
1 parent af8ce52 commit e54a30f
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/wasm32/ffi.c
Original file line number Diff line number Diff line change
Expand Up @@ -481,8 +481,19 @@ ffi_prep_closure_loc_helper,
if (ret_by_arg) {
ret_ptr = args[0];
} else {
cur_ptr -= 8;
cur_ptr &= (~(8 - 1));
var ret_size;
switch (sig[ret_by_arg]) {
case "i":
case "f":
ret_size = 4;
break;
case "j":
case "d":
ret_size = 8;
break;
}
cur_ptr -= ret_size;
cur_ptr &= (~(ret_size - 1));
ret_ptr = cur_ptr;
}
cur_ptr -= 4 * (sig.length - 1 - ret_by_arg);
Expand Down

0 comments on commit e54a30f

Please sign in to comment.