Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generate new exception handling instructions #1759

Draft
wants to merge 5 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions compiler/lib-wasm/binaryen.ml
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ let optimize ~profile ~opt_input_sourcemap ~input_file ~opt_output_sourcemap ~ou
in
command
("wasm-opt"
:: "--emit-exnref"
:: (common_options ()
@ optimization_options.(level - 1)
@ [ Filename.quote input_file; "-o"; Filename.quote output_file ])
Expand Down
11 changes: 6 additions & 5 deletions compiler/lib-wasm/wasm_output.ml
Original file line number Diff line number Diff line change
Expand Up @@ -648,15 +648,16 @@ end = struct
output_byte ch 0x0B
| Try (typ, l, catches) ->
Feature.require exception_handling;
output_byte ch 0x06;
output_byte ch 0x1f;
output_blocktype st.type_names ch typ;
List.iter ~f:(fun i' -> output_instruction st ch i') l;
output_uint ch (List.length catches);
List.iter
~f:(fun (tag, l, ty) ->
output_byte ch 0x07;
~f:(fun (tag, l, _) ->
output_byte ch 0x00;
output_uint ch (Hashtbl.find st.tag_names tag);
output_instruction st ch (Br (l + 1, Some (Pop ty))))
output_uint ch l)
catches;
List.iter ~f:(fun i' -> output_instruction st ch i') l;
output_byte ch 0X0B

and output_instruction st ch i =
Expand Down
16 changes: 6 additions & 10 deletions compiler/lib-wasm/wat_output.ml
Original file line number Diff line number Diff line change
Expand Up @@ -445,17 +445,13 @@ let expression_or_instructions ctx st in_function =
]
| Try (ty, body, catches) ->
[ List
(Atom "try"
(Atom "try_table"
:: (block_type st ty
@ List (Atom "do" :: instructions body)
:: List.map
~f:(fun (tag, i, ty) ->
List
(Atom "catch"
:: index st.tag_names tag
:: (instruction (Wasm_ast.Event Code_generation.hidden_location)
@ instruction (Wasm_ast.Br (i + 1, Some (Pop ty))))))
catches))
@ List.map
~f:(fun (tag, i, _ty) ->
List [ Atom "catch"; index st.tag_names tag; Atom (string_of_int i) ])
catches
@ instructions body))
]
and instruction i =
match i with
Expand Down
1 change: 1 addition & 0 deletions tools/node_wrapper.ml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
let extra_args_for_wasoo =
[ "--experimental-wasm-imported-strings"
; "--experimental-wasm-stack-switching"
; "--experimental-wasm-exnref"
; "--stack-size=10000"
]

Expand Down
Loading