@@ -606,7 +606,8 @@ let unbox_float dbg =
606
606
(* Complex *)
607
607
608
608
let 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)
610
611
611
612
let complex_re c dbg = Cop (Cload (Double , Immutable ), [c], dbg)
612
613
let complex_im c dbg = Cop (Cload (Double , Immutable ),
@@ -760,16 +761,16 @@ let unboxed_float_array_ref arr ofs dbg =
760
761
Cop (Cload (Double , Mutable ),
761
762
[array_indexing log2_size_float arr ofs dbg], dbg)
762
763
let 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)
764
765
765
766
let addr_array_set arr ofs newval dbg =
766
767
Cop (Cextcall (" caml_modify" , typ_void, [] , false ),
767
768
[array_indexing log2_size_addr arr ofs dbg; newval], dbg)
768
769
let int_array_set arr ofs newval dbg =
769
- Cop (Cstore (Word_int , Lambda. Assignment ),
770
+ Cop (Cstore (Word_int , Lambda. Assignment Lambda. alloc_heap ),
770
771
[array_indexing log2_size_addr arr ofs dbg; newval], dbg)
771
772
let float_array_set arr ofs newval dbg =
772
- Cop (Cstore (Double , Lambda. Assignment ),
773
+ Cop (Cstore (Double , Lambda. Assignment Lambda. alloc_heap ),
773
774
[array_indexing log2_size_float arr ofs dbg; newval], dbg)
774
775
775
776
let addr_array_set_local arr ofs newval dbg =
@@ -828,7 +829,7 @@ let call_cached_method obj tag cache pos args (apos,mode) dbg =
828
829
(* Allocation *)
829
830
830
831
let 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
832
833
let hdr =
833
834
match mode with
834
835
| Lambda. Alloc_local -> local_block_header tag wordsize
@@ -1003,13 +1004,14 @@ let bigarray_set unsafe elt_kind layout b args newval dbg =
1003
1004
bind " addr" (bigarray_indexing unsafe elt_kind layout b args dbg)
1004
1005
(fun addr ->
1005
1006
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),
1008
1010
[Cop (Cadda , [addr; Cconst_int (sz, dbg)], dbg);
1009
1011
complex_im newv dbg],
1010
1012
dbg))))
1011
1013
| _ ->
1012
- Cop (Cstore (bigarray_word_kind elt_kind, Assignment ),
1014
+ Cop (Cstore (bigarray_word_kind elt_kind, Assignment Lambda. alloc_heap ),
1013
1015
[bigarray_indexing unsafe elt_kind layout b args dbg; newval],
1014
1016
dbg))
1015
1017
@@ -1162,7 +1164,7 @@ let unaligned_load_16 ptr idx dbg =
1162
1164
let unaligned_set_16 ptr idx newval dbg =
1163
1165
if Arch. allow_unaligned_access
1164
1166
then
1165
- Cop (Cstore (Sixteen_unsigned , Assignment ),
1167
+ Cop (Cstore (Sixteen_unsigned , Assignment Lambda. alloc_heap ),
1166
1168
[add_int ptr idx dbg; newval], dbg)
1167
1169
else
1168
1170
let cconst_int i = Cconst_int (i, dbg) in
@@ -1173,8 +1175,8 @@ let unaligned_set_16 ptr idx newval dbg =
1173
1175
let v2 = Cop (Cand , [newval; cconst_int 0xFF ], dbg) in
1174
1176
let b1, b2 = if Arch. big_endian then v1, v2 else v2, v1 in
1175
1177
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 ),
1178
1180
[add_int (add_int ptr idx dbg) (cconst_int 1 ) dbg; b2], dbg))
1179
1181
1180
1182
let unaligned_load_32 ptr idx dbg =
@@ -1205,7 +1207,7 @@ let unaligned_load_32 ptr idx dbg =
1205
1207
let unaligned_set_32 ptr idx newval dbg =
1206
1208
if Arch. allow_unaligned_access
1207
1209
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],
1209
1211
dbg)
1210
1212
else
1211
1213
let cconst_int i = Cconst_int (i, dbg) in
@@ -1225,16 +1227,16 @@ let unaligned_set_32 ptr idx newval dbg =
1225
1227
else v4, v3, v2, v1 in
1226
1228
Csequence (
1227
1229
Csequence (
1228
- Cop (Cstore (Byte_unsigned , Assignment ),
1230
+ Cop (Cstore (Byte_unsigned , Assignment Lambda. alloc_heap ),
1229
1231
[add_int ptr idx dbg; b1], dbg),
1230
- Cop (Cstore (Byte_unsigned , Assignment ),
1232
+ Cop (Cstore (Byte_unsigned , Assignment Lambda. alloc_heap ),
1231
1233
[add_int (add_int ptr idx dbg) (cconst_int 1 ) dbg; b2],
1232
1234
dbg)),
1233
1235
Csequence (
1234
- Cop (Cstore (Byte_unsigned , Assignment ),
1236
+ Cop (Cstore (Byte_unsigned , Assignment Lambda. alloc_heap ),
1235
1237
[add_int (add_int ptr idx dbg) (cconst_int 2 ) dbg; b3],
1236
1238
dbg),
1237
- Cop (Cstore (Byte_unsigned , Assignment ),
1239
+ Cop (Cstore (Byte_unsigned , Assignment Lambda. alloc_heap ),
1238
1240
[add_int (add_int ptr idx dbg) (cconst_int 3 ) dbg; b4],
1239
1241
dbg)))
1240
1242
@@ -1280,7 +1282,7 @@ let unaligned_load_64 ptr idx dbg =
1280
1282
let unaligned_set_64 ptr idx newval dbg =
1281
1283
assert (size_int = 8 );
1282
1284
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)
1284
1286
else
1285
1287
let cconst_int i = Cconst_int (i, dbg) in
1286
1288
let v1 =
@@ -1319,32 +1321,32 @@ let unaligned_set_64 ptr idx newval dbg =
1319
1321
Csequence (
1320
1322
Csequence (
1321
1323
Csequence (
1322
- Cop (Cstore (Byte_unsigned , Assignment ),
1324
+ Cop (Cstore (Byte_unsigned , Assignment Lambda. alloc_heap ),
1323
1325
[add_int ptr idx dbg; b1],
1324
1326
dbg),
1325
- Cop (Cstore (Byte_unsigned , Assignment ),
1327
+ Cop (Cstore (Byte_unsigned , Assignment Lambda. alloc_heap ),
1326
1328
[add_int (add_int ptr idx dbg) (cconst_int 1 ) dbg; b2],
1327
1329
dbg)),
1328
1330
Csequence (
1329
- Cop (Cstore (Byte_unsigned , Assignment ),
1331
+ Cop (Cstore (Byte_unsigned , Assignment Lambda. alloc_heap ),
1330
1332
[add_int (add_int ptr idx dbg) (cconst_int 2 ) dbg; b3],
1331
1333
dbg),
1332
- Cop (Cstore (Byte_unsigned , Assignment ),
1334
+ Cop (Cstore (Byte_unsigned , Assignment Lambda. alloc_heap ),
1333
1335
[add_int (add_int ptr idx dbg) (cconst_int 3 ) dbg; b4],
1334
1336
dbg))),
1335
1337
Csequence (
1336
1338
Csequence (
1337
- Cop (Cstore (Byte_unsigned , Assignment ),
1339
+ Cop (Cstore (Byte_unsigned , Assignment Lambda. alloc_heap ),
1338
1340
[add_int (add_int ptr idx dbg) (cconst_int 4 ) dbg; b5],
1339
1341
dbg),
1340
- Cop (Cstore (Byte_unsigned , Assignment ),
1342
+ Cop (Cstore (Byte_unsigned , Assignment Lambda. alloc_heap ),
1341
1343
[add_int (add_int ptr idx dbg) (cconst_int 5 ) dbg; b6],
1342
1344
dbg)),
1343
1345
Csequence (
1344
- Cop (Cstore (Byte_unsigned , Assignment ),
1346
+ Cop (Cstore (Byte_unsigned , Assignment Lambda. alloc_heap ),
1345
1347
[add_int (add_int ptr idx dbg) (cconst_int 6 ) dbg; b7],
1346
1348
dbg),
1347
- Cop (Cstore (Byte_unsigned , Assignment ),
1349
+ Cop (Cstore (Byte_unsigned , Assignment Lambda. alloc_heap ),
1348
1350
[add_int (add_int ptr idx dbg) (cconst_int 7 ) dbg; b8],
1349
1351
dbg))))
1350
1352
@@ -1824,7 +1826,7 @@ let cache_public_method meths tag cache dbg =
1824
1826
VP. create tagged,
1825
1827
Cop (Caddi , [lsl_const (Cvar li) log2_size_addr dbg;
1826
1828
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),
1828
1830
Cvar tagged)))))
1829
1831
1830
1832
let has_local_allocs e =
@@ -1896,9 +1898,12 @@ let apply_function_body (arity, (mode : Lambda.alloc_mode)) =
1896
1898
(* In the slowpath, a region is necessary in case
1897
1899
the initial applications do local allocations *)
1898
1900
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
1902
1907
in
1903
1908
let rec app_fun clos n =
1904
1909
if n = arity-1 then begin
@@ -2130,8 +2135,9 @@ let rec intermediate_curry_functions ~nlocal ~arity num =
2130
2135
let name2 = if num = 0 then name1 else name1 ^ " _" ^ Int. to_string num in
2131
2136
let arg = V. create_local " arg" and clos = V. create_local " clos" in
2132
2137
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
2135
2141
let curried n : Clambda.arity = (Curried {nlocal= min nlocal n}, n) in
2136
2142
Cfunction
2137
2143
{fun_name = name2;
@@ -2214,7 +2220,7 @@ module ApplyFnSet =
2214
2220
module AritySet =
2215
2221
Set. Make (struct type t = Clambda. arity let compare = compare end )
2216
2222
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 ]
2218
2224
(* These apply funs are always present in the main program because
2219
2225
the run-time system needs them (cf. runtime/<arch>.S) . *)
2220
2226
@@ -2260,7 +2266,7 @@ let negint arg dbg =
2260
2266
let offsetref n arg dbg =
2261
2267
return_unit dbg
2262
2268
(bind " ref" arg (fun arg ->
2263
- Cop (Cstore (Word_int , Assignment ),
2269
+ Cop (Cstore (Word_int , Assignment Lambda. alloc_heap ),
2264
2270
[arg;
2265
2271
add_const (Cop (Cload (Word_int , Mutable ), [arg], dbg))
2266
2272
(n lsl 1 ) dbg],
@@ -2318,11 +2324,13 @@ let assignment_kind
2318
2324
(ptr : Lambda.immediate_or_pointer )
2319
2325
(init : Lambda.initialization_or_assignment ) =
2320
2326
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
2323
2331
| Heap_initialization , _ ->
2324
2332
Misc. fatal_error " Cmm_helpers: Lambda.Heap_initialization unsupported"
2325
- | (Assignment | Local_assignment ), Immediate
2333
+ | (Assignment _ ), Immediate
2326
2334
| Root_initialization , (Immediate | Pointer ) -> Simple
2327
2335
2328
2336
let setfield n ptr init arg1 arg2 dbg =
@@ -2505,7 +2513,7 @@ let arrayref_safe kind arg1 arg2 dbg =
2505
2513
(get_header_without_profinfo arr dbg) dbg; idx],
2506
2514
int_array_ref arr idx dbg)))
2507
2515
| Pfloatarray ->
2508
- box_float dbg Alloc_heap (
2516
+ box_float dbg Lambda. alloc_heap (
2509
2517
bind " index" arg2 (fun idx ->
2510
2518
bind " arr" arg1 (fun arr ->
2511
2519
Csequence (
@@ -2528,7 +2536,7 @@ let setfield_computed ptr init arg1 arg2 arg3 dbg =
2528
2536
return_unit dbg (int_array_set arg1 arg2 arg3 dbg)
2529
2537
2530
2538
let 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 ),
2532
2540
[add_int arg1 (untag_int arg2 dbg) dbg;
2533
2541
ignore_high_bit_int (untag_int arg3 dbg)], dbg))
2534
2542
@@ -2539,7 +2547,7 @@ let bytesset_safe arg1 arg2 arg3 dbg =
2539
2547
bind " str" arg1 (fun str ->
2540
2548
Csequence (
2541
2549
make_checkbound dbg [string_length str dbg; idx],
2542
- Cop (Cstore (Byte_unsigned , Assignment ),
2550
+ Cop (Cstore (Byte_unsigned , Assignment Lambda. alloc_heap ),
2543
2551
[add_int str idx dbg;
2544
2552
ignore_high_bit_int newval],
2545
2553
dbg))))))
@@ -2716,7 +2724,7 @@ let entry_point namelist =
2716
2724
let cconst_int i = Cconst_int (i, dbg () ) in
2717
2725
let cconst_symbol sym = Cconst_symbol (sym, dbg () ) in
2718
2726
let incr_global_inited () =
2719
- Cop (Cstore (Word_int , Assignment ),
2727
+ Cop (Cstore (Word_int , Assignment Lambda. alloc_heap ),
2720
2728
[cconst_symbol " caml_globals_inited" ;
2721
2729
Cop (Caddi , [Cop (Cload (Word_int , Mutable ),
2722
2730
[cconst_symbol " caml_globals_inited" ], dbg () );
0 commit comments