Skip to content

Commit

Permalink
Try using other Wasm engine instead of node
Browse files Browse the repository at this point in the history
  • Loading branch information
vouillon committed Feb 6, 2025
1 parent ce895ac commit d9f8ec4
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 24 deletions.
10 changes: 6 additions & 4 deletions compiler/tests-jsoo/lib-effects/dune
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
(env
(with-effects-double-translation)
(with-effects)
; (wasi
; (wasm_of_ocaml
; (flags
; (:standard --enable effects))))
(wasi
(wasm_of_ocaml
(enabled_if
(or
(= %{env:WASM_ENGINE=node} "wizard")
(= %{env:WASM_ENGINE=node} "wizard-fast")))))
(_
(js_of_ocaml
(flags
Expand Down
12 changes: 6 additions & 6 deletions compiler/tests-ocaml/effect-syntax/dune
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
(env
(with-effects-double-translation)
(with-effects)
; (wasi
; (flags
; (:standard -w -38))
; (wasm_of_ocaml
; (flags
; (:standard --enable=effects))))
(wasi
(wasm_of_ocaml
(enabled_if
(or
(= %{env:WASM_ENGINE=node} "wizard")
(= %{env:WASM_ENGINE=node} "wizard-fast")))))
(_
(js_of_ocaml
(flags
Expand Down
12 changes: 6 additions & 6 deletions compiler/tests-ocaml/effects/dune
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
(env
(with-effects-double-translation)
(with-effects)
; (wasi
; (flags
; (:standard -w -38))
; (wasm_of_ocaml
; (flags
; (:standard --enable=effects))))
(wasi
(wasm_of_ocaml
(enabled_if
(or
(= %{env:WASM_ENGINE=node} "wizard")
(= %{env:WASM_ENGINE=node} "wizard-fast")))))
(_
(js_of_ocaml
(flags
Expand Down
2 changes: 1 addition & 1 deletion dune
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
(wasi
(wasm_of_ocaml
(flags
(:standard --pretty --enable wasi))
(:standard --pretty --enable wasi --enable trap-on-exception))
(compilation_mode whole_program))
(binaries
(tools/node_wrapper.exe as node)
Expand Down
49 changes: 42 additions & 7 deletions tools/node_wrapper.ml
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
let wizard_args = [ "-ext:stack-switching"; "--dir=." ]

let wasmfxtime_args =
[ (*"-C"
; "collector=null"
; *)
"-W=exceptions,function-references,stack-switching,gc"
; "--dir=."
]

let wasmtime_args = [ (*"-C"
; "collector=null"
; *) "-W=all-proposals=y"; "--dir=." ]

let extra_args_for_wasoo =
[ "--experimental-wasm-imported-strings"
; "--experimental-wasm-stack-switching"
Expand All @@ -23,16 +37,37 @@ let env =
else e)
env

let args =
let find_wasm file =
let dir = Filename.chop_extension file ^ ".assets" in
Filename.concat
dir
(List.find
(fun f -> Filename.check_suffix f ".wasm")
(Array.to_list (Sys.readdir dir)))

let exe, args =
match Array.to_list Sys.argv with
| exe :: argv ->
let argv =
let exe', argv =
match argv with
| file :: _ when Filename.check_suffix file ".wasm.js" ->
extra_args_for_wasoo @ argv
| _ -> extra_args_for_jsoo @ argv
| file :: _ when Filename.check_suffix file ".wasm.js" -> (
match Sys.getenv_opt "WASM_ENGINE" with
| Some "wizard" ->
( "/home/jerome/sources/wizard-engine/bin/wizeng.x86-linux"
, wizard_args @ (find_wasm file :: List.tl argv) )
| Some "wizard-fast" ->
( "/home/jerome/sources/wizard-engine/bin/wizeng.x86-64-linux"
, wizard_args @ (find_wasm file :: List.tl argv) )
| Some "wasmfxtime" ->
( "/home/jerome/sources/wasmfxtime/target/debug/wasmtime"
, wasmfxtime_args @ (find_wasm file :: List.tl argv) )
| Some "wasmtime" ->
( "/home/jerome/sources/wasmtime/target/debug/wasmtime"
, wasmtime_args @ (find_wasm file :: List.tl argv) )
| _ -> "node", extra_args_for_wasoo @ argv)
| _ -> "node", extra_args_for_jsoo @ argv
in
Array.of_list (exe :: argv)
exe', Array.of_list (exe :: argv)
| [] -> assert false

let () =
Expand All @@ -45,4 +80,4 @@ let () =
| _, WEXITED n -> exit n
| _, WSIGNALED _ -> exit 9
| _, WSTOPPED _ -> exit 9
else Unix.execvpe "node" args env
else Unix.execvpe exe args env

0 comments on commit d9f8ec4

Please sign in to comment.