@@ -291,7 +291,7 @@ let add_pseudo_event loc modname c =
291
291
let ev_defname = string_of_scoped_location loc in
292
292
let ev =
293
293
{ ev_pos = 0 ; (* patched in emitcode *)
294
- ev_module = modname;
294
+ ev_module = Compilation_unit. full_path_as_string modname;
295
295
ev_loc = to_location loc;
296
296
ev_defname;
297
297
ev_kind = Event_pseudo ;
@@ -363,7 +363,7 @@ let functions_to_compile = (Stack.create () : function_to_compile Stack.t)
363
363
364
364
(* Name of current compilation unit (for debugging events) *)
365
365
366
- let compunit_name = ref " "
366
+ let compunit_name = ref Compilation_unit. dummy
367
367
368
368
let check_stack stack_info sz =
369
369
let curr = stack_info.max_stack_used in
@@ -395,11 +395,9 @@ let array_primitive (index_kind : Lambda.array_index_kind) prefix =
395
395
let comp_primitive stack_info p sz args =
396
396
check_stack stack_info sz;
397
397
match p with
398
- Pgetglobal cu ->
399
- Kgetglobal (cu |> Compilation_unit. to_global_ident_for_bytecode)
400
- | Psetglobal cu ->
401
- Ksetglobal (cu |> Compilation_unit. to_global_ident_for_bytecode)
402
- | Pgetpredef id -> Kgetglobal id
398
+ Pgetglobal cu -> Kgetglobal cu
399
+ | Psetglobal cu -> Ksetglobal cu
400
+ | Pgetpredef id -> Kgetpredef id
403
401
| Pintcomp cmp -> Kintcomp cmp
404
402
| Pcompare_ints -> Kccall (" caml_int_compare" , 2 )
405
403
| Pcompare_floats Pfloat64 -> Kccall (" caml_float_compare" , 2 )
@@ -709,16 +707,8 @@ let rec comp_expr stack_info env exp sz cont =
709
707
let fv = Ident.Set. elements(free_variables exp) in
710
708
let entries = closure_entries Single_non_recursive fv in
711
709
let to_compile =
712
- <<<<<<< HEAD
713
710
{ params = List. map (fun p -> p.name) params; body = body; label = lbl;
714
- free_vars = fv; num_defs = 1 ; rec_vars = [] ; rec_pos = 0 } in
715
- ||||||| 121 bedcfd2
716
- { params = List. map fst params; body = body; label = lbl;
717
- free_vars = fv; num_defs = 1 ; rec_vars = [] ; rec_pos = 0 } in
718
- =======
719
- { params = List. map fst params; body = body; label = lbl;
720
711
entries = entries; rec_pos = 0 } in
721
- >>>>>>> 5.2 .0
722
712
Stack. push to_compile functions_to_compile;
723
713
comp_args stack_info env (List. map (fun n -> Lvar n) fv) sz
724
714
(Kclosure (lbl, List. length fv) :: cont)
@@ -729,18 +719,19 @@ let rec comp_expr stack_info env exp sz cont =
729
719
(add_pop 1 cont))
730
720
| Lletrec (decl , body ) ->
731
721
let ndecl = List. length decl in
732
- <<<<<<< HEAD
733
722
let fv =
734
723
Ident.Set. elements (free_variables (Lletrec (decl, lambda_unit))) in
735
724
let rec_idents = List. map (fun { id } -> id) decl in
725
+ let entries =
726
+ closure_entries (Multiple_recursive rec_idents) fv
727
+ in
736
728
let rec comp_fun pos = function
737
729
[] -> []
738
730
| { def = {params; body} } :: rem ->
739
731
let lbl = new_label() in
740
732
let to_compile =
741
733
{ params = List. map (fun p -> p.name) params; body = body; label = lbl;
742
- free_vars = fv; num_defs = ndecl; rec_vars = rec_idents;
743
- rec_pos = pos} in
734
+ entries = entries; rec_pos = pos} in
744
735
Stack. push to_compile functions_to_compile;
745
736
lbl :: comp_fun (pos + 1 ) rem
746
737
in
@@ -756,107 +747,6 @@ let rec comp_expr stack_info env exp sz cont =
756
747
| Punbox_float (Pfloat64 | Pfloat32 )), [arg], _ ) ->
757
748
comp_expr stack_info env arg sz cont
758
749
| Lprim ((Pbox_int _ | Punbox_int _ ), [arg], _ ) ->
759
- ||||||| 121 bedcfd2
760
- if List. for_all (function (_ , Lfunction _ ) -> true | _ -> false )
761
- decl then begin
762
- (* let rec of functions *)
763
- let fv =
764
- Ident.Set. elements (free_variables (Lletrec (decl, lambda_unit))) in
765
- let rec_idents = List. map (fun (id , _lam ) -> id) decl in
766
- let rec comp_fun pos = function
767
- [] -> []
768
- | (_id , Lfunction{params; body} ) :: rem ->
769
- let lbl = new_label() in
770
- let to_compile =
771
- { params = List. map fst params; body = body; label = lbl;
772
- free_vars = fv; num_defs = ndecl; rec_vars = rec_idents;
773
- rec_pos = pos} in
774
- Stack. push to_compile functions_to_compile;
775
- lbl :: comp_fun (pos + 1 ) rem
776
- | _ -> assert false in
777
- let lbls = comp_fun 0 decl in
778
- comp_args stack_info env (List. map (fun n -> Lvar n) fv) sz
779
- (Kclosurerec (lbls, List. length fv) ::
780
- (comp_expr stack_info
781
- (add_vars rec_idents (sz+ 1 ) env) body (sz + ndecl)
782
- (add_pop ndecl cont)))
783
- end else begin
784
- let decl_size =
785
- List. map (fun (id , exp ) -> (id, exp, size_of_lambda Ident. empty exp))
786
- decl in
787
- let rec comp_init new_env sz = function
788
- | [] -> comp_nonrec new_env sz ndecl decl_size
789
- | (id , _exp , RHS_floatblock blocksize ) :: rem ->
790
- Kconst (Const_base (Const_int blocksize)) ::
791
- Kccall (" caml_alloc_dummy_float" , 1 ) :: Kpush ::
792
- comp_init (add_var id (sz+ 1 ) new_env) (sz+ 1 ) rem
793
- | (id , _exp , RHS_block blocksize ) :: rem ->
794
- Kconst (Const_base (Const_int blocksize)) ::
795
- Kccall (" caml_alloc_dummy" , 1 ) :: Kpush ::
796
- comp_init (add_var id (sz+ 1 ) new_env) (sz+ 1 ) rem
797
- | (id , _exp , RHS_infix { blocksize; offset } ) :: rem ->
798
- Kconst (Const_base (Const_int offset)) ::
799
- Kpush ::
800
- Kconst (Const_base (Const_int blocksize)) ::
801
- Kccall (" caml_alloc_dummy_infix" , 2 ) :: Kpush ::
802
- comp_init (add_var id (sz+ 1 ) new_env) (sz+ 1 ) rem
803
- | (id , _exp , RHS_function (blocksize ,arity )) :: rem ->
804
- Kconst (Const_base (Const_int arity)) ::
805
- Kpush ::
806
- Kconst (Const_base (Const_int blocksize)) ::
807
- Kccall (" caml_alloc_dummy_function" , 2 ) :: Kpush ::
808
- comp_init (add_var id (sz+ 1 ) new_env) (sz+ 1 ) rem
809
- | (id , _exp , RHS_nonrec) :: rem ->
810
- Kconst (Const_base (Const_int 0 )) :: Kpush ::
811
- comp_init (add_var id (sz+ 1 ) new_env) (sz+ 1 ) rem
812
- and comp_nonrec new_env sz i = function
813
- | [] -> comp_rec new_env sz ndecl decl_size
814
- | (_id, _exp, (RHS_block _ | RHS_infix _ |
815
- RHS_floatblock _ | RHS_function _))
816
- :: rem ->
817
- comp_nonrec new_env sz (i-1 ) rem
818
- | (_id , exp , RHS_nonrec) :: rem ->
819
- comp_expr stack_info new_env exp sz
820
- (Kassign (i-1 ) :: comp_nonrec new_env sz (i-1 ) rem)
821
- and comp_rec new_env sz i = function
822
- | [] -> comp_expr stack_info new_env body sz (add_pop ndecl cont)
823
- | (_id, exp, (RHS_block _ | RHS_infix _ |
824
- RHS_floatblock _ | RHS_function _))
825
- :: rem ->
826
- comp_expr stack_info new_env exp sz
827
- (Kpush :: Kacc i :: Kccall (" caml_update_dummy" , 2 ) ::
828
- comp_rec new_env sz (i-1 ) rem)
829
- | (_id , _exp , RHS_nonrec) :: rem ->
830
- comp_rec new_env sz (i-1 ) rem
831
- in
832
- comp_init env sz decl_size
833
- end
834
- | Lprim (Popaque, [arg ], _ ) ->
835
- =======
836
- let fv =
837
- Ident.Set. elements (free_variables (Lletrec (decl, lambda_unit))) in
838
- let rec_idents = List. map (fun { id } -> id) decl in
839
- let entries =
840
- closure_entries (Multiple_recursive rec_idents) fv
841
- in
842
- let rec comp_fun pos = function
843
- [] -> []
844
- | { def = {params; body} } :: rem ->
845
- let lbl = new_label() in
846
- let to_compile =
847
- { params = List. map fst params; body = body; label = lbl;
848
- entries = entries; rec_pos = pos} in
849
- Stack. push to_compile functions_to_compile;
850
- lbl :: comp_fun (pos + 1 ) rem
851
- in
852
- let lbls = comp_fun 0 decl in
853
- comp_args stack_info env (List. map (fun n -> Lvar n) fv) sz
854
- (Kclosurerec (lbls, List. length fv) ::
855
- (comp_expr stack_info
856
- (add_vars rec_idents (sz+ 1 ) env) body (sz + ndecl)
857
- (add_pop ndecl cont)))
858
- | Lprim (Popaque, [arg ], _ ) ->
859
- >>>>>>> 5.2 .0
860
750
comp_expr stack_info env arg sz cont
861
751
| Lprim (Pignore, [arg ], _ ) ->
862
752
comp_expr stack_info env arg sz (add_const_unit cont)
@@ -1186,7 +1076,7 @@ let rec comp_expr stack_info env exp sz cont =
1186
1076
let ev_defname = string_of_scoped_location lev.lev_loc in
1187
1077
let event kind info =
1188
1078
{ ev_pos = 0 ; (* patched in emitcode *)
1189
- ev_module = ! compunit_name;
1079
+ ev_module = Compilation_unit. full_path_as_string ! compunit_name;
1190
1080
ev_loc = to_location lev.lev_loc;
1191
1081
ev_kind = kind;
1192
1082
ev_defname;
@@ -1353,7 +1243,7 @@ let comp_remainder cont =
1353
1243
1354
1244
let reset () =
1355
1245
label_counter := 0 ;
1356
- compunit_name := " " ;
1246
+ compunit_name := Compilation_unit. dummy ;
1357
1247
Stack. clear functions_to_compile
1358
1248
1359
1249
let compile_gen ?modulename ~init_stack expr =
0 commit comments