@@ -606,7 +606,8 @@ let unbox_float dbg =
606606(* Complex *)
607607
608608let box_complex dbg c_re c_im =
609- Cop (Calloc Alloc_heap , [alloc_floatarray_header 2 dbg; c_re; c_im], dbg)
609+ Cop (Calloc Lambda. alloc_heap,
610+ [alloc_floatarray_header 2 dbg; c_re; c_im], dbg)
610611
611612let complex_re c dbg = Cop (Cload (Double , Immutable ), [c], dbg)
612613let complex_im c dbg = Cop (Cload (Double , Immutable ),
@@ -760,16 +761,16 @@ let unboxed_float_array_ref arr ofs dbg =
760761 Cop (Cload (Double , Mutable ),
761762 [array_indexing log2_size_float arr ofs dbg], dbg)
762763let float_array_ref arr ofs dbg =
763- box_float dbg Alloc_heap (unboxed_float_array_ref arr ofs dbg)
764+ box_float dbg Lambda. alloc_heap (unboxed_float_array_ref arr ofs dbg)
764765
765766let addr_array_set arr ofs newval dbg =
766767 Cop (Cextcall (" caml_modify" , typ_void, [] , false ),
767768 [array_indexing log2_size_addr arr ofs dbg; newval], dbg)
768769let int_array_set arr ofs newval dbg =
769- Cop (Cstore (Word_int , Lambda. Assignment ),
770+ Cop (Cstore (Word_int , Lambda. Assignment Lambda. alloc_heap ),
770771 [array_indexing log2_size_addr arr ofs dbg; newval], dbg)
771772let float_array_set arr ofs newval dbg =
772- Cop (Cstore (Double , Lambda. Assignment ),
773+ Cop (Cstore (Double , Lambda. Assignment Lambda. alloc_heap ),
773774 [array_indexing log2_size_float arr ofs dbg; newval], dbg)
774775
775776let addr_array_set_local arr ofs newval dbg =
@@ -828,7 +829,7 @@ let call_cached_method obj tag cache pos args (apos,mode) dbg =
828829(* Allocation *)
829830
830831let make_alloc_generic ~mode set_fn dbg tag wordsize args =
831- if mode = Lambda. Alloc_local || wordsize < = Config. max_young_wosize then
832+ if Lambda. is_local_mode mode || wordsize < = Config. max_young_wosize then
832833 let hdr =
833834 match mode with
834835 | Lambda. Alloc_local -> local_block_header tag wordsize
@@ -1003,13 +1004,14 @@ let bigarray_set unsafe elt_kind layout b args newval dbg =
10031004 bind " addr" (bigarray_indexing unsafe elt_kind layout b args dbg)
10041005 (fun addr ->
10051006 Csequence (
1006- Cop (Cstore (kind, Assignment ), [addr; complex_re newv dbg], dbg),
1007- Cop (Cstore (kind, Assignment ),
1007+ Cop (Cstore (kind, Assignment Lambda. alloc_heap),
1008+ [addr; complex_re newv dbg], dbg),
1009+ Cop (Cstore (kind, Assignment Lambda. alloc_heap),
10081010 [Cop (Cadda , [addr; Cconst_int (sz, dbg)], dbg);
10091011 complex_im newv dbg],
10101012 dbg))))
10111013 | _ ->
1012- Cop (Cstore (bigarray_word_kind elt_kind, Assignment ),
1014+ Cop (Cstore (bigarray_word_kind elt_kind, Assignment Lambda. alloc_heap ),
10131015 [bigarray_indexing unsafe elt_kind layout b args dbg; newval],
10141016 dbg))
10151017
@@ -1162,7 +1164,7 @@ let unaligned_load_16 ptr idx dbg =
11621164let unaligned_set_16 ptr idx newval dbg =
11631165 if Arch. allow_unaligned_access
11641166 then
1165- Cop (Cstore (Sixteen_unsigned , Assignment ),
1167+ Cop (Cstore (Sixteen_unsigned , Assignment Lambda. alloc_heap ),
11661168 [add_int ptr idx dbg; newval], dbg)
11671169 else
11681170 let cconst_int i = Cconst_int (i, dbg) in
@@ -1173,8 +1175,8 @@ let unaligned_set_16 ptr idx newval dbg =
11731175 let v2 = Cop (Cand , [newval; cconst_int 0xFF ], dbg) in
11741176 let b1, b2 = if Arch. big_endian then v1, v2 else v2, v1 in
11751177 Csequence (
1176- Cop (Cstore (Byte_unsigned , Assignment ), [add_int ptr idx dbg; b1], dbg),
1177- Cop (Cstore (Byte_unsigned , Assignment ),
1178+ Cop (Cstore (Byte_unsigned , Assignment Lambda. alloc_heap ), [add_int ptr idx dbg; b1], dbg),
1179+ Cop (Cstore (Byte_unsigned , Assignment Lambda. alloc_heap ),
11781180 [add_int (add_int ptr idx dbg) (cconst_int 1 ) dbg; b2], dbg))
11791181
11801182let unaligned_load_32 ptr idx dbg =
@@ -1205,7 +1207,7 @@ let unaligned_load_32 ptr idx dbg =
12051207let unaligned_set_32 ptr idx newval dbg =
12061208 if Arch. allow_unaligned_access
12071209 then
1208- Cop (Cstore (Thirtytwo_unsigned , Assignment ), [add_int ptr idx dbg; newval],
1210+ Cop (Cstore (Thirtytwo_unsigned , Assignment Lambda. alloc_heap ), [add_int ptr idx dbg; newval],
12091211 dbg)
12101212 else
12111213 let cconst_int i = Cconst_int (i, dbg) in
@@ -1225,16 +1227,16 @@ let unaligned_set_32 ptr idx newval dbg =
12251227 else v4, v3, v2, v1 in
12261228 Csequence (
12271229 Csequence (
1228- Cop (Cstore (Byte_unsigned , Assignment ),
1230+ Cop (Cstore (Byte_unsigned , Assignment Lambda. alloc_heap ),
12291231 [add_int ptr idx dbg; b1], dbg),
1230- Cop (Cstore (Byte_unsigned , Assignment ),
1232+ Cop (Cstore (Byte_unsigned , Assignment Lambda. alloc_heap ),
12311233 [add_int (add_int ptr idx dbg) (cconst_int 1 ) dbg; b2],
12321234 dbg)),
12331235 Csequence (
1234- Cop (Cstore (Byte_unsigned , Assignment ),
1236+ Cop (Cstore (Byte_unsigned , Assignment Lambda. alloc_heap ),
12351237 [add_int (add_int ptr idx dbg) (cconst_int 2 ) dbg; b3],
12361238 dbg),
1237- Cop (Cstore (Byte_unsigned , Assignment ),
1239+ Cop (Cstore (Byte_unsigned , Assignment Lambda. alloc_heap ),
12381240 [add_int (add_int ptr idx dbg) (cconst_int 3 ) dbg; b4],
12391241 dbg)))
12401242
@@ -1280,7 +1282,7 @@ let unaligned_load_64 ptr idx dbg =
12801282let unaligned_set_64 ptr idx newval dbg =
12811283 assert (size_int = 8 );
12821284 if Arch. allow_unaligned_access
1283- then Cop (Cstore (Word_int , Assignment ), [add_int ptr idx dbg; newval], dbg)
1285+ then Cop (Cstore (Word_int , Assignment Lambda. alloc_heap ), [add_int ptr idx dbg; newval], dbg)
12841286 else
12851287 let cconst_int i = Cconst_int (i, dbg) in
12861288 let v1 =
@@ -1319,32 +1321,32 @@ let unaligned_set_64 ptr idx newval dbg =
13191321 Csequence (
13201322 Csequence (
13211323 Csequence (
1322- Cop (Cstore (Byte_unsigned , Assignment ),
1324+ Cop (Cstore (Byte_unsigned , Assignment Lambda. alloc_heap ),
13231325 [add_int ptr idx dbg; b1],
13241326 dbg),
1325- Cop (Cstore (Byte_unsigned , Assignment ),
1327+ Cop (Cstore (Byte_unsigned , Assignment Lambda. alloc_heap ),
13261328 [add_int (add_int ptr idx dbg) (cconst_int 1 ) dbg; b2],
13271329 dbg)),
13281330 Csequence (
1329- Cop (Cstore (Byte_unsigned , Assignment ),
1331+ Cop (Cstore (Byte_unsigned , Assignment Lambda. alloc_heap ),
13301332 [add_int (add_int ptr idx dbg) (cconst_int 2 ) dbg; b3],
13311333 dbg),
1332- Cop (Cstore (Byte_unsigned , Assignment ),
1334+ Cop (Cstore (Byte_unsigned , Assignment Lambda. alloc_heap ),
13331335 [add_int (add_int ptr idx dbg) (cconst_int 3 ) dbg; b4],
13341336 dbg))),
13351337 Csequence (
13361338 Csequence (
1337- Cop (Cstore (Byte_unsigned , Assignment ),
1339+ Cop (Cstore (Byte_unsigned , Assignment Lambda. alloc_heap ),
13381340 [add_int (add_int ptr idx dbg) (cconst_int 4 ) dbg; b5],
13391341 dbg),
1340- Cop (Cstore (Byte_unsigned , Assignment ),
1342+ Cop (Cstore (Byte_unsigned , Assignment Lambda. alloc_heap ),
13411343 [add_int (add_int ptr idx dbg) (cconst_int 5 ) dbg; b6],
13421344 dbg)),
13431345 Csequence (
1344- Cop (Cstore (Byte_unsigned , Assignment ),
1346+ Cop (Cstore (Byte_unsigned , Assignment Lambda. alloc_heap ),
13451347 [add_int (add_int ptr idx dbg) (cconst_int 6 ) dbg; b7],
13461348 dbg),
1347- Cop (Cstore (Byte_unsigned , Assignment ),
1349+ Cop (Cstore (Byte_unsigned , Assignment Lambda. alloc_heap ),
13481350 [add_int (add_int ptr idx dbg) (cconst_int 7 ) dbg; b8],
13491351 dbg))))
13501352
@@ -1824,7 +1826,7 @@ let cache_public_method meths tag cache dbg =
18241826 VP. create tagged,
18251827 Cop (Caddi , [lsl_const (Cvar li) log2_size_addr dbg;
18261828 cconst_int(1 - 3 * size_addr)], dbg),
1827- Csequence (Cop (Cstore (Word_int , Assignment ), [cache; Cvar tagged], dbg),
1829+ Csequence (Cop (Cstore (Word_int , Assignment Lambda. alloc_heap ), [cache; Cvar tagged], dbg),
18281830 Cvar tagged)))))
18291831
18301832let has_local_allocs e =
@@ -1896,9 +1898,12 @@ let apply_function_body (arity, (mode : Lambda.alloc_mode)) =
18961898 (* In the slowpath, a region is necessary in case
18971899 the initial applications do local allocations *)
18981900 let region =
1899- match mode with
1900- | Alloc_heap -> Some (V. create_local " region" )
1901- | Alloc_local -> None
1901+ if not Config. stack_allocation then None
1902+ else begin
1903+ match mode with
1904+ | Alloc_heap -> Some (V. create_local " region" )
1905+ | Alloc_local -> None
1906+ end
19021907 in
19031908 let rec app_fun clos n =
19041909 if n = arity-1 then begin
@@ -2130,8 +2135,9 @@ let rec intermediate_curry_functions ~nlocal ~arity num =
21302135 let name2 = if num = 0 then name1 else name1 ^ " _" ^ Int. to_string num in
21312136 let arg = V. create_local " arg" and clos = V. create_local " clos" in
21322137 let fun_dbg = placeholder_fun_dbg ~human_name: name2 in
2133- let mode : Lambda.alloc_mode =
2134- if num > = arity - nlocal then Alloc_local else Alloc_heap in
2138+ let mode =
2139+ if num > = arity - nlocal then Lambda. alloc_local else Lambda. alloc_heap
2140+ in
21352141 let curried n : Clambda.arity = (Curried {nlocal= min nlocal n}, n) in
21362142 Cfunction
21372143 {fun_name = name2;
@@ -2214,7 +2220,7 @@ module ApplyFnSet =
22142220module AritySet =
22152221 Set. Make (struct type t = Clambda. arity let compare = compare end )
22162222
2217- let default_apply = ApplyFnSet. of_list [2 ,Alloc_heap ; 3 ,Alloc_heap ]
2223+ let default_apply = ApplyFnSet. of_list [2 ,Lambda. alloc_heap ; 3 ,Lambda. alloc_heap ]
22182224 (* These apply funs are always present in the main program because
22192225 the run-time system needs them (cf. runtime/<arch>.S) . *)
22202226
@@ -2260,7 +2266,7 @@ let negint arg dbg =
22602266let offsetref n arg dbg =
22612267 return_unit dbg
22622268 (bind " ref" arg (fun arg ->
2263- Cop (Cstore (Word_int , Assignment ),
2269+ Cop (Cstore (Word_int , Assignment Lambda. alloc_heap ),
22642270 [arg;
22652271 add_const (Cop (Cload (Word_int , Mutable ), [arg], dbg))
22662272 (n lsl 1 ) dbg],
@@ -2318,11 +2324,13 @@ let assignment_kind
23182324 (ptr : Lambda.immediate_or_pointer )
23192325 (init : Lambda.initialization_or_assignment ) =
23202326 match init, ptr with
2321- | Assignment , Pointer -> Caml_modify
2322- | Local_assignment , Pointer -> Caml_modify_local
2327+ | Assignment Alloc_heap , Pointer -> Caml_modify
2328+ | Assignment Alloc_local , Pointer ->
2329+ assert Config. stack_allocation;
2330+ Caml_modify_local
23232331 | Heap_initialization , _ ->
23242332 Misc. fatal_error " Cmm_helpers: Lambda.Heap_initialization unsupported"
2325- | (Assignment | Local_assignment ), Immediate
2333+ | (Assignment _ ), Immediate
23262334 | Root_initialization , (Immediate | Pointer ) -> Simple
23272335
23282336let setfield n ptr init arg1 arg2 dbg =
@@ -2505,7 +2513,7 @@ let arrayref_safe kind arg1 arg2 dbg =
25052513 (get_header_without_profinfo arr dbg) dbg; idx],
25062514 int_array_ref arr idx dbg)))
25072515 | Pfloatarray ->
2508- box_float dbg Alloc_heap (
2516+ box_float dbg Lambda. alloc_heap (
25092517 bind " index" arg2 (fun idx ->
25102518 bind " arr" arg1 (fun arr ->
25112519 Csequence (
@@ -2528,7 +2536,7 @@ let setfield_computed ptr init arg1 arg2 arg3 dbg =
25282536 return_unit dbg (int_array_set arg1 arg2 arg3 dbg)
25292537
25302538let bytesset_unsafe arg1 arg2 arg3 dbg =
2531- return_unit dbg (Cop (Cstore (Byte_unsigned , Assignment ),
2539+ return_unit dbg (Cop (Cstore (Byte_unsigned , Assignment Lambda. alloc_heap ),
25322540 [add_int arg1 (untag_int arg2 dbg) dbg;
25332541 ignore_high_bit_int (untag_int arg3 dbg)], dbg))
25342542
@@ -2539,7 +2547,7 @@ let bytesset_safe arg1 arg2 arg3 dbg =
25392547 bind " str" arg1 (fun str ->
25402548 Csequence (
25412549 make_checkbound dbg [string_length str dbg; idx],
2542- Cop (Cstore (Byte_unsigned , Assignment ),
2550+ Cop (Cstore (Byte_unsigned , Assignment Lambda. alloc_heap ),
25432551 [add_int str idx dbg;
25442552 ignore_high_bit_int newval],
25452553 dbg))))))
@@ -2716,7 +2724,7 @@ let entry_point namelist =
27162724 let cconst_int i = Cconst_int (i, dbg () ) in
27172725 let cconst_symbol sym = Cconst_symbol (sym, dbg () ) in
27182726 let incr_global_inited () =
2719- Cop (Cstore (Word_int , Assignment ),
2727+ Cop (Cstore (Word_int , Assignment Lambda. alloc_heap ),
27202728 [cconst_symbol " caml_globals_inited" ;
27212729 Cop (Caddi , [Cop (Cload (Word_int , Mutable ),
27222730 [cconst_symbol " caml_globals_inited" ], dbg () );
0 commit comments