Skip to content

Commit 42a99b6

Browse files
committed
Try using other Wasm engine instead of node
1 parent 0e9cbd0 commit 42a99b6

File tree

5 files changed

+67
-24
lines changed

5 files changed

+67
-24
lines changed

compiler/tests-jsoo/lib-effects/dune

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
(env
22
(with-effects-double-translation)
33
(with-effects)
4-
; (wasi
5-
; (wasm_of_ocaml
6-
; (flags
7-
; (:standard --enable effects))))
4+
(wasi
5+
(wasm_of_ocaml
6+
(enabled_if
7+
(or
8+
(= %{env:WASM_ENGINE=node} "wizard")
9+
(= %{env:WASM_ENGINE=node} "wizard-fast")))))
810
(_
911
(js_of_ocaml
1012
(flags

compiler/tests-ocaml/effect-syntax/dune

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
(env
22
(with-effects-double-translation)
33
(with-effects)
4-
; (wasi
5-
; (flags
6-
; (:standard -w -38))
7-
; (wasm_of_ocaml
8-
; (flags
9-
; (:standard --enable=effects))))
4+
(wasi
5+
(wasm_of_ocaml
6+
(enabled_if
7+
(or
8+
(= %{env:WASM_ENGINE=node} "wizard")
9+
(= %{env:WASM_ENGINE=node} "wizard-fast")))))
1010
(_
1111
(js_of_ocaml
1212
(flags

compiler/tests-ocaml/effects/dune

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
(env
22
(with-effects-double-translation)
33
(with-effects)
4-
; (wasi
5-
; (flags
6-
; (:standard -w -38))
7-
; (wasm_of_ocaml
8-
; (flags
9-
; (:standard --enable=effects))))
4+
(wasi
5+
(wasm_of_ocaml
6+
(enabled_if
7+
(or
8+
(= %{env:WASM_ENGINE=node} "wizard")
9+
(= %{env:WASM_ENGINE=node} "wizard-fast")))))
1010
(_
1111
(js_of_ocaml
1212
(flags

dune

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
(wasi
3434
(wasm_of_ocaml
3535
(flags
36-
(:standard --pretty --enable wasi))
36+
(:standard --pretty --enable wasi --enable trap-on-exception))
3737
(compilation_mode whole_program))
3838
(binaries
3939
(tools/node_wrapper.exe as node)

tools/node_wrapper.ml

Lines changed: 48 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,20 @@
1+
let wizard_args = [ "-ext:stack-switching"; "--dir=." ]
2+
3+
let wasmfxtime_args =
4+
[ (*"-C"
5+
; "collector=null"
6+
; *)
7+
"-W=exceptions,function-references,stack-switching,gc"
8+
; "--dir=."
9+
]
10+
11+
let wasmtime_args = [ (*"-C"
12+
; "collector=null"
13+
; *) "-W=all-proposals=y"; "--dir=." ]
14+
15+
let wasmedge_args =
16+
[ "--enable-gc"; "--enable-exception-handling"; "--enable-tail-call"; "--dir=." ]
17+
118
let extra_args_for_wasoo =
219
[ "--experimental-wasm-imported-strings"
320
; "--experimental-wasm-stack-switching"
@@ -23,16 +40,40 @@ let env =
2340
else e)
2441
env
2542

26-
let args =
43+
let find_wasm file =
44+
let dir = Filename.chop_extension file ^ ".assets" in
45+
Filename.concat
46+
dir
47+
(List.find
48+
(fun f -> Filename.check_suffix f ".wasm")
49+
(Array.to_list (Sys.readdir dir)))
50+
51+
let exe, args =
2752
match Array.to_list Sys.argv with
2853
| exe :: argv ->
29-
let argv =
54+
let exe', argv =
3055
match argv with
31-
| file :: _ when Filename.check_suffix file ".wasm.js" ->
32-
extra_args_for_wasoo @ argv
33-
| _ -> extra_args_for_jsoo @ argv
56+
| file :: _ when Filename.check_suffix file ".wasm.js" -> (
57+
match Sys.getenv_opt "WASM_ENGINE" with
58+
| Some "wizard" ->
59+
( "/home/jerome/sources/wizard-engine/bin/wizeng.x86-linux"
60+
, wizard_args @ (find_wasm file :: List.tl argv) )
61+
| Some "wizard-fast" ->
62+
( "/home/jerome/sources/wizard-engine/bin/wizeng.x86-64-linux"
63+
, wizard_args @ (find_wasm file :: List.tl argv) )
64+
| Some "wasmfxtime" ->
65+
( "/home/jerome/sources/wasmfxtime/target/debug/wasmtime"
66+
, wasmfxtime_args @ (find_wasm file :: List.tl argv) )
67+
| Some "wasmtime" ->
68+
( "/home/jerome/sources/wasmtime/target/debug/wasmtime"
69+
, wasmtime_args @ (find_wasm file :: List.tl argv) )
70+
| Some "wasmedge" ->
71+
( "/home/jerome/sources/WasmEdge/build/tools/wasmedge/wasmedge"
72+
, wasmedge_args @ (find_wasm file :: List.tl argv) )
73+
| _ -> "node", extra_args_for_wasoo @ argv)
74+
| _ -> "node", extra_args_for_jsoo @ argv
3475
in
35-
Array.of_list (exe :: argv)
76+
exe', Array.of_list (exe :: argv)
3677
| [] -> assert false
3778

3879
let () =
@@ -45,4 +86,4 @@ let () =
4586
| _, WEXITED n -> exit n
4687
| _, WSIGNALED _ -> exit 9
4788
| _, WSTOPPED _ -> exit 9
48-
else Unix.execvpe "node" args env
89+
else Unix.execvpe exe args env

0 commit comments

Comments
 (0)