diff --git a/wasm/emit_wat.ml b/wasm/emit_wat.ml index a27ca4b0f..6f19062b7 100644 --- a/wasm/emit_wat.ml +++ b/wasm/emit_wat.ml @@ -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 diff --git a/wasm/link_wat.ml b/wasm/link_wat.ml index 7c319e277..ea7fc7e7a 100644 --- a/wasm/link_wat.ml +++ b/wasm/link_wat.ml @@ -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 diff --git a/wasm/test/test_node.sh b/wasm/test/test_node.sh index 9651b305a..b3ae5323e 100755 --- a/wasm/test/test_node.sh +++ b/wasm/test/test_node.sh @@ -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: " diff --git a/wasm/wat.ml b/wasm/wat.ml index 74eb481c1..f362ab379 100644 --- a/wasm/wat.ml +++ b/wasm/wat.ml @@ -371,7 +371,10 @@ module C = struct (node "tag" [ !$"exc"; node "param" [ node "ref" [ atom "eq" ] ] ]) let module_ m = - let m = import_tag :: m in + let m = match Wstate.exception_repr with + | Native_exceptions -> import_tag :: m + | Multi_return -> m + in nodev "module" m end