Skip to content

Commit

Permalink
do not use exception runtime when using multi-return, fix segfault in
Browse files Browse the repository at this point in the history
node by setting stack size and ulimit correctly
  • Loading branch information
zapashcanon committed Oct 17, 2024
1 parent 4d446c5 commit 7bb6b4c
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
1 change: 1 addition & 0 deletions wasm/emit_wat.ml
Original file line number Diff line number Diff line change
Expand Up @@ -492,6 +492,7 @@ module Conv = struct
match e with
| Var _ | I32 _ | I64 _ | F64 _ | Global_get _ -> true
| Unop (I31_new, e) -> expr_is_pure e
| Let2 { defining_expr; body; _ }
| Let { defining_expr; body } ->
expr_is_pure defining_expr && expr_is_pure body
| _ -> false
Expand Down
10 changes: 7 additions & 3 deletions wasm/link_wat.ml
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,17 @@ let options =
[ "--enable-multivalue"
; "--enable-gc"
; "--enable-reference-types"
; "--enable-exception-handling"
; "--enable-tail-call"
]
] @ match Wstate.exception_repr with
| Native_exceptions -> [ "--enable-exception-handling" ]
| Multi_return -> []

let wasm_merge = "wasm-merge"

let runtime = [ "exn_tag"; "runtime"; "imports" ]
let runtime = [ "runtime"; "imports" ]
@ match Wstate.exception_repr with
| Native_exceptions -> [ "exn_tag" ]
| Multi_return -> []

let merge_files ~runtime_dir ~text files output =
let text = if text then [ emit_text ] else [] in
Expand Down
8 changes: 6 additions & 2 deletions wasm/test/test_node.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,18 @@ set -eu

alias time='/usr/bin/time -f"real %e user %U sys %S"'

NODE='node-canary --stack-size=10000'
ULIMIT_STACK_SIZE=20000
STACK_SIZE=10000
NODE="node-canary --stack-size=${STACK_SIZE}"

ulimit -s $ULIMIT_STACK_SIZE

bench() {
echo "*** Running ${1}"
echo -n "Wasocaml (node): "
../../ocamlopt -O3 ./${2}.ml > /dev/null
time $NODE ./main_node.mjs > /dev/null
wasm-opt --enable-gc --enable-reference-types --enable-exception-handling --enable-multivalue --enable-tail-call a.out.wasm -o a.out.wasm -O3
wasm-opt --enable-gc --enable-reference-types --enable-multivalue --enable-tail-call a.out.wasm -o a.out.wasm -O3
echo -n "Wasocaml + wasm-opt (node): "
time $NODE ./main_node.mjs > /dev/null
echo -n "OCaml native: "
Expand Down

0 comments on commit 7bb6b4c

Please sign in to comment.