Skip to content

Commit d7a52fa

Browse files
committed
WIP
1 parent fc651d6 commit d7a52fa

File tree

2 files changed

+17
-15
lines changed

2 files changed

+17
-15
lines changed

compiler/lib/wasm/wa_gc_target.ml

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1702,13 +1702,18 @@ let handle_exceptions ~result_typ ~fall_through ~context body x exn_handler =
17021702
(block_expr
17031703
{ params = []; result = [ Value.value ] }
17041704
(let* exn =
1705-
try_expr
1705+
block_expr
17061706
{ params = []; result = [ externref ] }
1707-
(body
1708-
~result_typ:[ externref ]
1709-
~fall_through:(`Block (-1))
1710-
~context:(`Skip :: `Skip :: context))
1711-
[ ocaml_tag, 1, Value.value; js_tag, 0, externref ]
1707+
(let* e =
1708+
try_expr
1709+
{ params = []; result = [ externref ] }
1710+
(body
1711+
~result_typ:[ externref ]
1712+
~fall_through:(`Block (-1))
1713+
~context:(`Skip :: `Skip :: `Skip :: context))
1714+
[ ocaml_tag, 1, Value.value; js_tag, 0, externref ]
1715+
in
1716+
instr (W.Push e))
17121717
in
17131718
instr (W.CallInstr (f, [ exn ]))))
17141719
in

compiler/lib/wasm/wa_wat_output.ml

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -480,16 +480,13 @@ let expression_or_instructions ctx st in_function =
480480
]
481481
| Try (ty, body, catches) ->
482482
[ List
483-
(Atom "try"
483+
(Atom "try_table"
484484
:: (block_type st ty
485-
@ List (Atom "do" :: instructions body)
486-
:: List.map
487-
~f:(fun (tag, i, ty) ->
488-
List
489-
(Atom "catch"
490-
:: index st.tag_names tag
491-
:: instruction (Wa_ast.Br (i, Some (Pop ty)))))
492-
catches))
485+
@ List.map
486+
~f:(fun (tag, i, _ty) ->
487+
List [ Atom "catch"; index st.tag_names tag; Atom (string_of_int i) ])
488+
catches
489+
@ instructions body))
493490
]
494491
and instruction i =
495492
match i with

0 commit comments

Comments
 (0)