1+ let wizard_args = [ " -ext:stack-switching" ; " -stack-size=2M" ; " --dir=." ; " --dir=/tmp" ]
2+
3+ let wasmtime_args =
4+ [ (* "-C"; "collector=null"; *) " -W=all-proposals=y" ; " --dir=." ; " --dir=/tmp" ]
5+
6+ let wasmedge_args =
7+ [ " --enable-gc"
8+ ; " --enable-exception-handling"
9+ ; " --enable-tail-call"
10+ ; " --dir=."
11+ ; " --dir=/tmp"
12+ ]
13+
114let extra_args_for_wasoo =
215 [ " --experimental-wasm-imported-strings"
316 ; " --experimental-wasm-stack-switching"
17+ ; " --experimental-wasm-exnref"
418 ; " --stack-size=10000"
519 ]
620
@@ -23,16 +37,37 @@ let env =
2337 else e)
2438 env
2539
26- let args =
40+ let environment_args () =
41+ List. filter
42+ (fun e -> not (String. contains e ',' ))
43+ (Array. to_list (Array. map (fun e -> " --env=" ^ e) env))
44+
45+ let find_wasm file =
46+ let dir = Filename. chop_extension file ^ " .assets" in
47+ Filename. concat
48+ dir
49+ (List. find
50+ (fun f -> Filename. check_suffix f " .wasm" )
51+ (Array. to_list (Sys. readdir dir)))
52+
53+ let common_args file argv = environment_args () @ (find_wasm file :: List. tl argv)
54+
55+ let exe, args =
2756 match Array. to_list Sys. argv with
2857 | exe :: argv ->
29- let argv =
58+ let exe', argv =
3059 match argv with
31- | file :: _ when Filename. check_suffix file " .wasm.js" ->
32- extra_args_for_wasoo @ argv
33- | _ -> extra_args_for_jsoo @ argv
60+ | file :: _ when Filename. check_suffix file " .wasm.js" -> (
61+ match Sys. getenv_opt " WASM_ENGINE" with
62+ | Some "wizard" -> " wizeng.x86-linux" , wizard_args @ common_args file argv
63+ | Some "wizard-fast" ->
64+ " wizeng.x86-64-linux" , wizard_args @ common_args file argv
65+ | Some "wasmtime" -> " wasmtime" , wasmtime_args @ common_args file argv
66+ | Some "wasmedge" -> " wasmedge" , wasmedge_args @ common_args file argv
67+ | _ -> " node" , extra_args_for_wasoo @ argv)
68+ | _ -> " node" , extra_args_for_jsoo @ argv
3469 in
35- Array. of_list (exe :: argv)
70+ exe', Array. of_list (exe :: argv)
3671 | [] -> assert false
3772
3873let () =
@@ -45,4 +80,4 @@ let () =
4580 | _ , WEXITED n -> exit n
4681 | _ , WSIGNALED _ -> exit 9
4782 | _ , WSTOPPED _ -> exit 9
48- else Unix. execvpe " node " args env
83+ else Unix. execvpe exe args env
0 commit comments