@@ -109,7 +109,7 @@ let rec is_tailcall = function
109
109
from the tail call optimization? *)
110
110
111
111
let preserve_tailcall_for_prim = function
112
- Pidentity | Popaque | Pdirapply | Prevapply | Psequor | Psequand ->
112
+ Pidentity | Popaque | Pdirapply _ | Prevapply _ | Psequor | Psequand ->
113
113
true
114
114
| Pbytes_to_string | Pbytes_of_string | Pignore | Pgetglobal _ | Psetglobal _
115
115
| Pmakeblock _ | Pmakefloatblock _
@@ -118,8 +118,8 @@ let preserve_tailcall_for_prim = function
118
118
| Pccall _ | Praise _ | Pnot | Pnegint | Paddint | Psubint | Pmulint
119
119
| Pdivint _ | Pmodint _ | Pandint | Porint | Pxorint | Plslint | Plsrint
120
120
| Pasrint | Pintcomp _ | Poffsetint _ | Poffsetref _ | Pintoffloat
121
- | Pfloatofint | Pnegfloat | Pabsfloat | Paddfloat | Psubfloat | Pmulfloat
122
- | Pdivfloat | Pfloatcomp _ | Pstringlength | Pstringrefu | Pstringrefs
121
+ | Pfloatofint _ | Pnegfloat _ | Pabsfloat _ | Paddfloat _ | Psubfloat _ | Pmulfloat _
122
+ | Pdivfloat _ | Pfloatcomp _ | Pstringlength | Pstringrefu | Pstringrefs
123
123
| Pcompare_ints | Pcompare_floats | Pcompare_bints _
124
124
| Pbyteslength | Pbytesrefu | Pbytessetu | Pbytesrefs | Pbytessets
125
125
| Pmakearray _ | Pduparray _ | Parraylength _ | Parrayrefu _ | Parraysetu _
@@ -209,12 +209,12 @@ let rec size_of_lambda env = function
209
209
in
210
210
size_of_lambda env body
211
211
| Lprim (Pmakeblock _ , args , _ ) -> RHS_block (List. length args)
212
- | Lprim (Pmakearray ((Paddrarray |Pintarray ), _ ), args , _ ) ->
212
+ | Lprim (Pmakearray ((Paddrarray |Pintarray ), _ , _ ), args , _ ) ->
213
213
RHS_block (List. length args)
214
- | Lprim (Pmakearray (Pfloatarray , _), args, _)
214
+ | Lprim (Pmakearray (Pfloatarray , _, _ ), args, _)
215
215
| Lprim (Pmakefloatblock _ , args , _ ) ->
216
216
RHS_floatblock (List. length args)
217
- | Lprim (Pmakearray (Pgenarray, _ ), _ , _ ) ->
217
+ | Lprim (Pmakearray (Pgenarray, _ , _ ), _ , _ ) ->
218
218
(* Pgenarray is excluded from recursive bindings by the
219
219
check in Translcore.check_recursive_lambda *)
220
220
RHS_nonrec
@@ -227,6 +227,7 @@ let rec size_of_lambda env = function
227
227
| Lprim (Pduprecord (Record_float, size ), _ , _ ) -> RHS_floatblock size
228
228
| Levent (lam , _ ) -> size_of_lambda env lam
229
229
| Lsequence (_lam , lam' ) -> size_of_lambda env lam'
230
+ | Lregion lam -> size_of_lambda env lam
230
231
| _ -> RHS_nonrec
231
232
232
233
(* *** Merging consecutive events ****)
@@ -398,7 +399,7 @@ let comp_primitive p args =
398
399
| Pfield_computed _sem -> Kgetvectitem
399
400
| Psetfield (n , _ptr , _init ) -> Ksetfield n
400
401
| Psetfield_computed (_ptr , _init ) -> Ksetvectitem
401
- | Pfloatfield (n , _sem ) -> Kgetfloatfield n
402
+ | Pfloatfield (n , _sem , _mode ) -> Kgetfloatfield n
402
403
| Psetfloatfield (n , _init ) -> Ksetfloatfield n
403
404
| Pduprecord _ -> Kccall (" caml_obj_dup" , 1 )
404
405
| Pccall p -> Kccall (p.prim_name, p.prim_arity)
@@ -417,13 +418,13 @@ let comp_primitive p args =
417
418
| Poffsetint n -> Koffsetint n
418
419
| Poffsetref n -> Koffsetref n
419
420
| Pintoffloat -> Kccall (" caml_int_of_float" , 1 )
420
- | Pfloatofint -> Kccall (" caml_float_of_int" , 1 )
421
- | Pnegfloat -> Kccall (" caml_neg_float" , 1 )
422
- | Pabsfloat -> Kccall (" caml_abs_float" , 1 )
423
- | Paddfloat -> Kccall (" caml_add_float" , 2 )
424
- | Psubfloat -> Kccall (" caml_sub_float" , 2 )
425
- | Pmulfloat -> Kccall (" caml_mul_float" , 2 )
426
- | Pdivfloat -> Kccall (" caml_div_float" , 2 )
421
+ | Pfloatofint _ -> Kccall (" caml_float_of_int" , 1 )
422
+ | Pnegfloat _ -> Kccall (" caml_neg_float" , 1 )
423
+ | Pabsfloat _ -> Kccall (" caml_abs_float" , 1 )
424
+ | Paddfloat _ -> Kccall (" caml_add_float" , 2 )
425
+ | Psubfloat _ -> Kccall (" caml_sub_float" , 2 )
426
+ | Pmulfloat _ -> Kccall (" caml_mul_float" , 2 )
427
+ | Pdivfloat _ -> Kccall (" caml_div_float" , 2 )
427
428
| Pstringlength -> Kccall (" caml_ml_string_length" , 1 )
428
429
| Pbyteslength -> Kccall (" caml_ml_bytes_length" , 1 )
429
430
| Pstringrefs -> Kccall (" caml_string_get" , 2 )
@@ -467,26 +468,26 @@ let comp_primitive p args =
467
468
Kccall (Printf. sprintf " caml_sys_const_%s" const_name, 1 )
468
469
| Pisint -> Kisint
469
470
| Pisout -> Kisout
470
- | Pbintofint bi -> comp_bint_primitive bi " of_int" args
471
+ | Pbintofint ( bi , _ ) -> comp_bint_primitive bi " of_int" args
471
472
| Pintofbint bi -> comp_bint_primitive bi " to_int" args
472
- | Pcvtbint (Pint32, Pnativeint) -> Kccall (" caml_nativeint_of_int32" , 1 )
473
- | Pcvtbint (Pnativeint, Pint32) -> Kccall (" caml_nativeint_to_int32" , 1 )
474
- | Pcvtbint (Pint32, Pint64) -> Kccall (" caml_int64_of_int32" , 1 )
475
- | Pcvtbint (Pint64, Pint32) -> Kccall (" caml_int64_to_int32" , 1 )
476
- | Pcvtbint (Pnativeint, Pint64) -> Kccall (" caml_int64_of_nativeint" , 1 )
477
- | Pcvtbint (Pint64, Pnativeint) -> Kccall (" caml_int64_to_nativeint" , 1 )
478
- | Pnegbint bi -> comp_bint_primitive bi " neg" args
479
- | Paddbint bi -> comp_bint_primitive bi " add" args
480
- | Psubbint bi -> comp_bint_primitive bi " sub" args
481
- | Pmulbint bi -> comp_bint_primitive bi " mul" args
473
+ | Pcvtbint (Pint32, Pnativeint, _ ) -> Kccall (" caml_nativeint_of_int32" , 1 )
474
+ | Pcvtbint (Pnativeint, Pint32, _ ) -> Kccall (" caml_nativeint_to_int32" , 1 )
475
+ | Pcvtbint (Pint32, Pint64, _ ) -> Kccall (" caml_int64_of_int32" , 1 )
476
+ | Pcvtbint (Pint64, Pint32, _ ) -> Kccall (" caml_int64_to_int32" , 1 )
477
+ | Pcvtbint (Pnativeint, Pint64, _ ) -> Kccall (" caml_int64_of_nativeint" , 1 )
478
+ | Pcvtbint (Pint64, Pnativeint, _ ) -> Kccall (" caml_int64_to_nativeint" , 1 )
479
+ | Pnegbint ( bi , _ ) -> comp_bint_primitive bi " neg" args
480
+ | Paddbint ( bi , _ ) -> comp_bint_primitive bi " add" args
481
+ | Psubbint ( bi , _ ) -> comp_bint_primitive bi " sub" args
482
+ | Pmulbint ( bi , _ ) -> comp_bint_primitive bi " mul" args
482
483
| Pdivbint { size = bi } -> comp_bint_primitive bi " div" args
483
484
| Pmodbint { size = bi } -> comp_bint_primitive bi " mod" args
484
- | Pandbint bi -> comp_bint_primitive bi " and" args
485
- | Porbint bi -> comp_bint_primitive bi " or" args
486
- | Pxorbint bi -> comp_bint_primitive bi " xor" args
487
- | Plslbint bi -> comp_bint_primitive bi " shift_left" args
488
- | Plsrbint bi -> comp_bint_primitive bi " shift_right_unsigned" args
489
- | Pasrbint bi -> comp_bint_primitive bi " shift_right" args
485
+ | Pandbint ( bi , _ ) -> comp_bint_primitive bi " and" args
486
+ | Porbint ( bi , _ ) -> comp_bint_primitive bi " or" args
487
+ | Pxorbint ( bi , _ ) -> comp_bint_primitive bi " xor" args
488
+ | Plslbint ( bi , _ ) -> comp_bint_primitive bi " shift_left" args
489
+ | Plsrbint ( bi , _ ) -> comp_bint_primitive bi " shift_right_unsigned" args
490
+ | Pasrbint ( bi , _ ) -> comp_bint_primitive bi " shift_right" args
490
491
| Pbintcomp (_ , Ceq) -> Kccall (" caml_equal" , 2 )
491
492
| Pbintcomp (_ , Cne) -> Kccall (" caml_notequal" , 2 )
492
493
| Pbintcomp (_ , Clt) -> Kccall (" caml_lessthan" , 2 )
@@ -503,7 +504,7 @@ let comp_primitive p args =
503
504
| Pbigstring_set_32 (_ ) -> Kccall (" caml_ba_uint8_set32" , 3 )
504
505
| Pbigstring_set_64 (_ ) -> Kccall (" caml_ba_uint8_set64" , 3 )
505
506
| Pbswap16 -> Kccall (" caml_bswap16" , 1 )
506
- | Pbbswap (bi ) -> comp_bint_primitive bi " bswap" args
507
+ | Pbbswap (bi , _ ) -> comp_bint_primitive bi " bswap" args
507
508
| Pint_as_pointer -> Kccall (" caml_int_as_pointer" , 1 )
508
509
| Pbytes_to_string -> Kccall (" caml_string_of_bytes" , 1 )
509
510
| Pbytes_of_string -> Kccall (" caml_bytes_of_string" , 1 )
@@ -563,7 +564,7 @@ let rec comp_expr env exp sz cont =
563
564
(Kapply nargs :: cont1))
564
565
end
565
566
end
566
- | Lsend (kind , met , obj , args , _ ) ->
567
+ | Lsend (kind , met , obj , args , _ , _ , _ ) ->
567
568
let args = if kind = Cached then List. tl args else args in
568
569
let nargs = List. length args + 1 in
569
570
let getmethod, args' =
@@ -678,12 +679,14 @@ let rec comp_expr env exp sz cont =
678
679
comp_expr env arg sz cont
679
680
| Lprim (Pignore, [arg ], _ ) ->
680
681
comp_expr env arg sz (add_const_unit cont)
681
- | Lprim (Pdirapply , [func;arg], loc)
682
- | Lprim (Prevapply, [arg ;func ], loc ) ->
682
+ | Lprim (Pdirapply pos , [func;arg], loc)
683
+ | Lprim (Prevapply pos , [arg ;func ], loc ) ->
683
684
let exp = Lapply {
684
685
ap_loc= loc;
685
686
ap_func= func;
686
687
ap_args= [arg];
688
+ ap_region_close= pos;
689
+ ap_mode= Alloc_heap ;
687
690
ap_tailcall= Default_tailcall ;
688
691
ap_inlined= Default_inlined ;
689
692
ap_specialised= Default_specialise ;
@@ -739,10 +742,10 @@ let rec comp_expr env exp sz cont =
739
742
(Kpush ::
740
743
Kconst (Const_base (Const_int n))::
741
744
Kaddint ::cont)
742
- | Lprim (Pmakefloatblock _mut , args , loc ) ->
745
+ | Lprim (Pmakefloatblock _ , args , loc ) ->
743
746
let cont = add_pseudo_event loc ! compunit_name cont in
744
747
comp_args env args sz (Kmakefloatblock (List. length args) :: cont)
745
- | Lprim (Pmakearray (kind , _ ), args , loc ) ->
748
+ | Lprim (Pmakearray (kind , _ , _ ), args , loc ) ->
746
749
let cont = add_pseudo_event loc ! compunit_name cont in
747
750
begin match kind with
748
751
Pintarray | Paddrarray ->
@@ -757,9 +760,9 @@ let rec comp_expr env exp sz cont =
757
760
Kccall (" caml_make_array" , 1 ) :: cont)
758
761
end
759
762
| Lprim (Pduparray (kind, mutability),
760
- [Lprim (Pmakearray (kind',_),args,_)], loc) ->
763
+ [Lprim (Pmakearray (kind',_,m ),args,_)], loc) ->
761
764
assert (kind = kind');
762
- comp_expr env (Lprim (Pmakearray (kind, mutability), args, loc)) sz cont
765
+ comp_expr env (Lprim (Pmakearray (kind, mutability, m ), args, loc)) sz cont
763
766
| Lprim (Pduparray _ , [arg ], loc ) ->
764
767
let prim_obj_dup =
765
768
Primitive. simple ~name: " caml_obj_dup" ~arity: 1 ~alloc: true
@@ -787,10 +790,10 @@ let rec comp_expr env exp sz cont =
787
790
| CFnge -> Kccall (" caml_ge_float" , 2 ) :: Kboolnot :: cont
788
791
in
789
792
comp_args env args sz cont
790
- | Lprim (Pmakeblock(tag , _mut , _ ), args , loc ) ->
793
+ | Lprim (Pmakeblock(tag , _mut , _ , _ ), args , loc ) ->
791
794
let cont = add_pseudo_event loc ! compunit_name cont in
792
795
comp_args env args sz (Kmakeblock (List. length args, tag) :: cont)
793
- | Lprim (Pfloatfield (n , _sem ), args , loc ) ->
796
+ | Lprim (Pfloatfield (n , _ , _ ), args , loc ) ->
794
797
let cont = add_pseudo_event loc ! compunit_name cont in
795
798
comp_args env args sz (Kgetfloatfield n :: cont)
796
799
| Lprim (p , args , _ ) ->
@@ -984,7 +987,8 @@ let rec comp_expr env exp sz cont =
984
987
let info =
985
988
match lam with
986
989
Lapply {ap_args = args } -> Event_return (List. length args)
987
- | Lsend (_ , _ , _ , args , _ ) -> Event_return (List. length args + 1 )
990
+ | Lsend (_ , _ , _ , args , _ , _ , _ ) ->
991
+ Event_return (List. length args + 1 )
988
992
| Lprim (_ ,args ,_ ) -> Event_return (List. length args)
989
993
| _ -> Event_other
990
994
in
@@ -997,6 +1001,8 @@ let rec comp_expr env exp sz cont =
997
1001
end
998
1002
| Lifused (_ , exp ) ->
999
1003
comp_expr env exp sz cont
1004
+ | Lregion exp ->
1005
+ comp_expr env exp sz cont
1000
1006
1001
1007
(* Compile a list of arguments [e1; ...; eN] to a primitive operation.
1002
1008
The values of eN ... e2 are pushed on the stack, e2 at top of stack,
0 commit comments