@@ -530,7 +530,8 @@ module Value = struct
530530 | Pop _
531531 | Call_ref _
532532 | Br_on_cast _
533- | Br_on_cast_fail _ -> false
533+ | Br_on_cast_fail _
534+ | Try _ -> false
534535 | IfExpr (_ , e1 , e2 , e3 ) -> effect_free e1 && effect_free e2 && effect_free e3
535536 | ArrayNewFixed (_ , l ) | StructNew (_ , l ) -> List. for_all ~f: effect_free l
536537
@@ -1701,16 +1702,25 @@ let handle_exceptions ~result_typ ~fall_through ~context body x exn_handler =
17011702 block
17021703 { params = [] ; result = result_typ }
17031704 (let * () =
1704- try_
1705- { params = [] ; result = [] }
1706- (body ~result_typ: [] ~fall_through: (`Block (- 1 )) ~context: (`Skip :: context))
1707- [ ocaml_tag, store ~always: true x (return (W. Pop Value. value))
1708- ; ( js_tag
1709- , let exn = Code.Var. fresh () in
1710- let * () = store ~always: true ~typ: externref exn (return (W. Pop externref)) in
1711- let * exn = load exn in
1712- store ~always: true x (return (W. Call (f, [ exn ]))) )
1713- ]
1705+ store
1706+ x
1707+ (block_expr
1708+ { params = [] ; result = [ Value. value ] }
1709+ (let * exn =
1710+ block_expr
1711+ { params = [] ; result = [ externref ] }
1712+ (let * e =
1713+ try_expr
1714+ { params = [] ; result = [ externref ] }
1715+ (body
1716+ ~result_typ: [ externref ]
1717+ ~fall_through: (`Block (- 1 ))
1718+ ~context: (`Skip :: `Skip :: `Skip :: context))
1719+ [ ocaml_tag, 1 , Value. value; js_tag, 0 , externref ]
1720+ in
1721+ instr (W. Push e))
1722+ in
1723+ instr (W. CallInstr (f, [ exn ]))))
17141724 in
17151725 exn_handler ~result_typ ~fall_through ~context )
17161726
0 commit comments