@@ -716,7 +716,7 @@ let visit_all params args =
716716 in
717717 l
718718
719- let parallel_renaming back_edge params args continuation queue =
719+ let parallel_renaming loc back_edge params args continuation queue =
720720 if back_edge && Config.Flag. es6 ()
721721 (* This is likely slower than using explicit temp variable
722722 but let's experiment with es6 a bit *)
@@ -734,14 +734,14 @@ let parallel_renaming back_edge params args continuation queue =
734734 let never, code = continuation queue in
735735 match params, args with
736736 | [ p ], [ a ] ->
737- never, (J. Expression_statement (J. EBin (J. Eq , J. EVar (J. V p), a)), J. N ) :: code
737+ never, (J. Expression_statement (J. EBin (J. Eq , J. EVar (J. V p), a)), loc ) :: code
738738 | params , args ->
739739 let lhs =
740740 J. EAssignTarget
741741 (J. ArrayTarget (List. map params ~f: (fun p -> J. TargetElementId (J. V p, None ))))
742742 in
743743 let rhs = J. EArr (List. rev_map args ~f: (fun x -> J. Element x)) in
744- never, (J. Expression_statement (J. EBin (J. Eq , lhs, rhs)), J. N ) :: code
744+ never, (J. Expression_statement (J. EBin (J. Eq , lhs, rhs)), loc ) :: code
745745 else
746746 let l = visit_all params args in
747747 (* if not back_edge
@@ -767,10 +767,10 @@ let parallel_renaming back_edge params args continuation queue =
767767 if back_edge
768768 then
769769 List. map renaming ~f: (fun (t , e ) ->
770- J. Expression_statement (J. EBin (J. Eq , J. EVar (J. V t), e)), J. N )
770+ J. Expression_statement (J. EBin (J. Eq , J. EVar (J. V t), e)), loc )
771771 else
772772 List. map renaming ~f: (fun (t , e ) ->
773- J. variable_declaration [ J. V t, (e, J. N ) ], J. N )
773+ J. variable_declaration [ J. V t, (e, loc ) ], loc )
774774 in
775775 let never, code = continuation queue in
776776 never, List. rev_append before (List. rev_append renaming code)
@@ -1548,25 +1548,25 @@ and translate_instrs_rev (ctx : Ctx.t) loc expr_queue instrs acc_rev muts_map =
15481548 let acc_rev = List. rev_append st acc_rev in
15491549 translate_instrs_rev ctx loc expr_queue rem acc_rev muts_map
15501550
1551- and translate_instrs (ctx : Ctx.t ) expr_queue instrs =
1551+ and translate_instrs (ctx : Ctx.t ) loc expr_queue instrs =
15521552 let loc, st_rev, expr_queue =
1553- translate_instrs_rev (ctx : Ctx.t ) J. N expr_queue instrs [] Var.Map. empty
1553+ translate_instrs_rev (ctx : Ctx.t ) loc expr_queue instrs [] Var.Map. empty
15541554 in
15551555 loc, List. rev st_rev, expr_queue
15561556
15571557(* Compile loops. *)
1558- and compile_block st queue (pc : Addr.t ) scope_stack ~fall_through =
1558+ and compile_block st loc queue (pc : Addr.t ) scope_stack ~fall_through =
15591559 if (not (List. is_empty queue))
15601560 && (Structure. is_loop_header st.structure pc
15611561 || (* Do not inline expressions across block boundaries when --no-inline is used
15621562 Single-stepping in the debugger should work better this way (fixes #290). *)
15631563 not (Config.Flag. inline () ))
15641564 then
1565- let never, code = compile_block st [] pc scope_stack ~fall_through in
1565+ let never, code = compile_block st loc [] pc scope_stack ~fall_through in
15661566 never, flush_all queue code
15671567 else
15681568 match Structure. is_loop_header st.structure pc with
1569- | false -> compile_block_no_loop st queue pc scope_stack ~fall_through
1569+ | false -> compile_block_no_loop st loc queue pc scope_stack ~fall_through
15701570 | true ->
15711571 if debug () then Format. eprintf " @[<hv 2>for(;;) {@," ;
15721572 let never_body, body =
@@ -1581,12 +1581,11 @@ and compile_block st queue (pc : Addr.t) scope_stack ~fall_through =
15811581 | Return -> scope_stack
15821582 in
15831583 let never_body, body =
1584- compile_block_no_loop st queue pc scope_stack ~fall_through: (Block pc)
1584+ compile_block_no_loop st loc queue pc scope_stack ~fall_through: (Block pc)
15851585 in
15861586 if debug () then Format. eprintf " }@]@," ;
15871587 let for_loop =
1588- ( J. For_statement (J. Left None , None , None , Js_simpl. block body)
1589- , source_location st.ctx Before pc )
1588+ J. For_statement (J. Left None , None , None , Js_simpl. block body), loc
15901589 in
15911590 let label = if ! lab_used then Some lab else None in
15921591 let for_loop =
@@ -1599,7 +1598,7 @@ and compile_block st queue (pc : Addr.t) scope_stack ~fall_through =
15991598 never_body, body
16001599
16011600(* Compile block. Loops have already been handled. *)
1602- and compile_block_no_loop st queue (pc : Addr.t ) ~fall_through scope_stack =
1601+ and compile_block_no_loop st loc queue (pc : Addr.t ) ~fall_through scope_stack =
16031602 if pc < 0 then assert false ;
16041603 if Addr.Set. mem pc ! (st.visited_blocks)
16051604 then (
@@ -1608,7 +1607,7 @@ and compile_block_no_loop st queue (pc : Addr.t) ~fall_through scope_stack =
16081607 if debug () then Format. eprintf " Compiling block %d@;" pc;
16091608 st.visited_blocks := Addr.Set. add pc ! (st.visited_blocks);
16101609 let block = Addr.Map. find pc st.ctx.blocks in
1611- let loc, seq, queue = translate_instrs st.ctx queue block.body in
1610+ let loc, seq, queue = translate_instrs st.ctx loc queue block.body in
16121611 let nbbranch =
16131612 match fst block.branch with
16141613 | Switch (_ , a ) ->
@@ -1636,7 +1635,7 @@ and compile_block_no_loop st queue (pc : Addr.t) ~fall_through scope_stack =
16361635 let used = ref false in
16371636 let scope_stack = (x, (l, used, Forward )) :: scope_stack in
16381637 let _never_inner, inner = loop ~scope_stack ~fall_through: (Block x) xs in
1639- let never, code = compile_block st [] x scope_stack ~fall_through in
1638+ let never, code = compile_block st loc [] x scope_stack ~fall_through in
16401639 match ! used with
16411640 | true -> never, [ J. Labelled_statement (l, (J. Block inner, J. N )), J. N ] @ code
16421641 | false -> never, inner @ code)
@@ -1659,7 +1658,7 @@ and compile_decision_tree kind st scope_stack loc cx dtree ~fall_through =
16591658 ~pp_sep: (fun fmt () -> Format. pp_print_string fmt " , " )
16601659 (fun fmt pc -> Format. fprintf fmt " %d" pc))
16611660 l;
1662- let never, code = compile_branch st [] cont scope_stack ~fall_through in
1661+ let never, code = compile_branch st loc [] cont scope_stack ~fall_through in
16631662 if debug () then Format. eprintf " }@]@;" ;
16641663 never, code
16651664 | DTree. If (cond , cont1 , cont2 ) ->
@@ -1776,11 +1775,13 @@ and compile_conditional st queue ~fall_through loc last scope_stack : _ * _ =
17761775 if st.ctx.Ctx. should_export then Some (s_var Global_constant. exports) else None
17771776 in
17781777 true , flush_all queue [ J. Return_statement (e_opt, loc), loc ]
1779- | Branch cont -> compile_branch st queue cont scope_stack ~fall_through
1778+ | Branch cont -> compile_branch st loc queue cont scope_stack ~fall_through
17801779 | Pushtrap (c1 , x , e1 ) ->
1781- let never_body, body = compile_branch st [] c1 scope_stack ~fall_through in
1780+ let never_body, body = compile_branch st J. N [] c1 scope_stack ~fall_through in
17821781 if debug () then Format. eprintf " @,}@]@,@[<hv 2>catch {@;" ;
1783- let never_handler, handler = compile_branch st [] e1 scope_stack ~fall_through in
1782+ let never_handler, handler =
1783+ compile_branch st J. U [] e1 scope_stack ~fall_through
1784+ in
17841785 let exn_var, handler =
17851786 assert (not (List. mem x ~set: (snd e1)));
17861787 let wrap_exn x =
@@ -1805,7 +1806,7 @@ and compile_conditional st queue ~fall_through loc last scope_stack : _ * _ =
18051806 , loc )
18061807 ] )
18071808 | Poptrap cont ->
1808- let never, code = compile_branch st [] cont scope_stack ~fall_through in
1809+ let never, code = compile_branch st J. N [] cont scope_stack ~fall_through in
18091810 never, flush_all queue code
18101811 | Cond (x , c1 , c2 ) ->
18111812 let (_px, cx), queue = access_queue queue x in
@@ -1841,14 +1842,14 @@ and compile_conditional st queue ~fall_through loc last scope_stack : _ * _ =
18411842 | Switch _ | Cond _ | Pushtrap _ -> Format. eprintf " }@]@;" );
18421843 res
18431844
1844- and compile_argument_passing ctx queue (pc , args ) back_edge continuation =
1845+ and compile_argument_passing ctx loc queue (pc , args ) back_edge continuation =
18451846 if List. is_empty args
18461847 then continuation queue
18471848 else
18481849 let block = Addr.Map. find pc ctx.Ctx. blocks in
1849- parallel_renaming back_edge block.params args continuation queue
1850+ parallel_renaming loc back_edge block.params args continuation queue
18501851
1851- and compile_branch st queue ((pc , _ ) as cont ) scope_stack ~fall_through : bool * _ =
1852+ and compile_branch st loc queue ((pc , _ ) as cont ) scope_stack ~fall_through : bool * _ =
18521853 let scope = List. assoc_opt pc scope_stack in
18531854 let back_edge =
18541855 List. exists
@@ -1857,7 +1858,7 @@ and compile_branch st queue ((pc, _) as cont) scope_stack ~fall_through : bool *
18571858 | _ -> false )
18581859 scope_stack
18591860 in
1860- compile_argument_passing st.ctx queue cont back_edge (fun queue ->
1861+ compile_argument_passing st.ctx loc queue cont back_edge (fun queue ->
18611862 if match fall_through with
18621863 | Block pc' -> pc' = pc
18631864 | Return -> false
@@ -1917,14 +1918,16 @@ and compile_branch st queue ((pc, _) as cont) scope_stack ~fall_through : bool *
19171918 if debug () then Format. eprintf " (br %d)@;" pc;
19181919 used := true ;
19191920 true , flush_all queue [ J. Break_statement (Some l), J. N ]
1920- | None -> compile_block st queue pc scope_stack ~fall_through )
1921+ | None -> compile_block st loc queue pc scope_stack ~fall_through )
19211922
19221923and compile_closure ctx (pc , args ) =
19231924 let st = build_graph ctx pc in
19241925 let current_blocks = Structure. get_nodes st.structure in
19251926 if debug () then Format. eprintf " @[<hv 2>closure {@;" ;
19261927 let scope_stack = [] in
1927- let _never, res = compile_branch st [] (pc, args) scope_stack ~fall_through: Return in
1928+ let _never, res =
1929+ compile_branch st J. N [] (pc, args) scope_stack ~fall_through: Return
1930+ in
19281931 if Addr.Set. cardinal ! (st.visited_blocks) <> Addr.Set. cardinal current_blocks
19291932 then (
19301933 let missing = Addr.Set. diff current_blocks ! (st.visited_blocks) in
0 commit comments