Skip to content

Commit fc7aff9

Browse files
committed
Flag to generate the new exception handling instructions
1 parent 5e77914 commit fc7aff9

File tree

4 files changed

+12
-8
lines changed

4 files changed

+12
-8
lines changed

.github/workflows/wasm_of_ocaml.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ jobs:
228228
working-directory: ./wasm_of_ocaml
229229
env:
230230
WASM_ENGINE: wasmtime
231-
WASI_FLAGS: --enable trap-on-exception
231+
WASI_FLAGS: --enable exnref
232232
RUST_BACKTRACE: 0
233233
continue-on-error: true
234234
run: opam exec -- dune build @runtest-wasm --profile wasi

compiler/lib-wasm/binaryen.ml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -136,12 +136,12 @@ let optimize
136136
~output_file
137137
() =
138138
command
139-
("wasm-opt"
140-
:: (common_options ()
141-
@ (if Config.Flag.trap_on_exception () then [] else [ "--traps-never-happen" ])
142-
@ (match options with
143-
| Some o -> o
144-
| None -> optimization_options profile)
145-
@ [ Filename.quote input_file; "-o"; Filename.quote output_file ])
139+
(("wasm-opt" :: (if Config.Flag.exnref () then [ "--emit-exnref" ] else []))
140+
@ (common_options ()
141+
@ (if Config.Flag.trap_on_exception () then [] else [ "--traps-never-happen" ])
142+
@ (match options with
143+
| Some o -> o
144+
| None -> optimization_options profile)
145+
@ [ Filename.quote input_file; "-o"; Filename.quote output_file ])
146146
@ opt_flag "--input-source-map" opt_input_sourcemap
147147
@ opt_flag "--output-source-map" opt_output_sourcemap)

compiler/lib/config.ml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,8 @@ module Flag = struct
109109

110110
let wasi = o ~name:"wasi" ~default:false
111111

112+
let exnref = o ~name:"exnref" ~default:false
113+
112114
let trap_on_exception = o ~name:"trap-on-exception" ~default:false
113115
end
114116

compiler/lib/config.mli

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,8 @@ module Flag : sig
7878

7979
val wasi : unit -> bool
8080

81+
val exnref : unit -> bool
82+
8183
val trap_on_exception : unit -> bool
8284

8385
val enable : string -> unit

0 commit comments

Comments
 (0)