@@ -532,7 +532,8 @@ module Value = struct
532532 | Pop _
533533 | Call_ref _
534534 | Br_on_cast _
535- | Br_on_cast_fail _ -> false
535+ | Br_on_cast_fail _
536+ | Try _ -> false
536537 | IfExpr (_ , e1 , e2 , e3 ) -> effect_free e1 && effect_free e2 && effect_free e3
537538 | ArrayNewFixed (_ , l ) | StructNew (_ , l ) -> List. for_all ~f: effect_free l
538539
@@ -1696,16 +1697,25 @@ let handle_exceptions ~result_typ ~fall_through ~context body x exn_handler =
16961697 block
16971698 { params = [] ; result = result_typ }
16981699 (let * () =
1699- try_
1700- { params = [] ; result = [] }
1701- (body ~result_typ: [] ~fall_through: (`Block (- 1 )) ~context: (`Skip :: context))
1702- [ ocaml_tag, store ~always: true x (return (W. Pop Value. value))
1703- ; ( js_tag
1704- , let exn = Code.Var. fresh () in
1705- let * () = store ~always: true ~typ: externref exn (return (W. Pop externref)) in
1706- let * exn = load exn in
1707- store ~always: true x (return (W. Call (f, [ exn ]))) )
1708- ]
1700+ store
1701+ x
1702+ (block_expr
1703+ { params = [] ; result = [ Value. value ] }
1704+ (let * exn =
1705+ block_expr
1706+ { params = [] ; result = [ 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))
1717+ in
1718+ instr (W. CallInstr (f, [ exn ]))))
17091719 in
17101720 exn_handler ~result_typ ~fall_through ~context )
17111721
0 commit comments