Skip to content

Commit e03c574

Browse files
committed
Initial support for value slots not of value kind: closure, flambda & flambda2
1 parent 4cd4891 commit e03c574

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+1105
-467
lines changed

backend/cmmgen.ml

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -156,8 +156,9 @@ type rhs_kind =
156156
let rec expr_size env = function
157157
| Uvar id ->
158158
begin try V.find_same id env with Not_found -> RHS_nonrec end
159-
| Uclosure(fundecls, clos_vars) ->
160-
RHS_block (fundecls_size fundecls + List.length clos_vars)
159+
| Uclosure { functions ; not_scanned_slots ; scanned_slots } ->
160+
RHS_block (fundecls_size functions + List.length not_scanned_slots
161+
+ List.length scanned_slots)
161162
| Ulet(_str, _kind, id, exp, body) ->
162163
expr_size (V.add (VP.var id) (expr_size env exp) env) body
163164
| Uletrec(bindings, body) ->
@@ -426,18 +427,18 @@ let rec transl env e =
426427
end
427428
| Uconst sc ->
428429
transl_constant Debuginfo.none sc
429-
| Uclosure(fundecls, []) ->
430+
| Uclosure { functions ; not_scanned_slots = [] ; scanned_slots = [] } ->
430431
let sym = Compilenv.new_const_symbol() in
431-
Cmmgen_state.add_constant sym (Const_closure (Local, fundecls, []));
432-
List.iter (fun f -> Cmmgen_state.add_function f) fundecls;
432+
Cmmgen_state.add_constant sym (Const_closure (Local, functions, []));
433+
List.iter (fun f -> Cmmgen_state.add_function f) functions;
433434
let dbg =
434-
match fundecls with
435+
match functions with
435436
| [] -> Debuginfo.none
436437
| fundecl::_ -> fundecl.dbg
437438
in
438439
Cconst_symbol (sym, dbg)
439-
| Uclosure(fundecls, clos_vars) ->
440-
let startenv = fundecls_size fundecls in
440+
| Uclosure { functions ; not_scanned_slots ; scanned_slots } ->
441+
let startenv = fundecls_size functions + List.length not_scanned_slots in
441442
let mode =
442443
Option.get @@
443444
List.fold_left (fun s { mode; dbg; _ } ->
@@ -447,10 +448,10 @@ let rec transl env e =
447448
if not (Lambda.eq_mode mode m') then
448449
Misc.fatal_errorf "Inconsistent modes in let rec at %s"
449450
(Debuginfo.to_string dbg);
450-
s) None fundecls in
451+
s) None functions in
451452
let rec transl_fundecls pos = function
452453
[] ->
453-
List.map (transl env) clos_vars
454+
List.map (transl env) (not_scanned_slots @ scanned_slots)
454455
| f :: rem ->
455456
let is_last = match rem with [] -> true | _::_ -> false in
456457
Cmmgen_state.add_function f;
@@ -474,11 +475,11 @@ let rec transl env e =
474475
else alloc_infix_header pos f.dbg :: without_header
475476
in
476477
let dbg =
477-
match fundecls with
478+
match functions with
478479
| [] -> Debuginfo.none
479480
| fundecl::_ -> fundecl.dbg
480481
in
481-
make_alloc ~mode dbg Obj.closure_tag (transl_fundecls 0 fundecls)
482+
make_alloc ~mode dbg Obj.closure_tag (transl_fundecls 0 functions)
482483
| Uoffset(arg, offset) ->
483484
(* produces a valid Caml value, pointing just after an infix header *)
484485
let ptr = transl env arg in

middle_end/clambda.ml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,11 @@ and ulambda =
5252
function_label * ulambda list * Lambda.probe * apply_kind * Debuginfo.t
5353
| Ugeneric_apply of
5454
ulambda * ulambda list * apply_kind * Debuginfo.t
55-
| Uclosure of ufunction list * ulambda list
55+
| Uclosure of {
56+
functions : ufunction list ;
57+
not_scanned_slots : ulambda list ;
58+
scanned_slots : ulambda list ;
59+
}
5660
| Uoffset of ulambda * int
5761
| Ulet of mutable_flag * value_kind * Backend_var.With_provenance.t
5862
* ulambda * ulambda

middle_end/clambda.mli

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,11 @@ and ulambda =
6363
function_label * ulambda list * Lambda.probe * apply_kind * Debuginfo.t
6464
| Ugeneric_apply of
6565
ulambda * ulambda list * apply_kind * Debuginfo.t
66-
| Uclosure of ufunction list * ulambda list
66+
| Uclosure of {
67+
functions : ufunction list ;
68+
not_scanned_slots : ulambda list ;
69+
scanned_slots : ulambda list
70+
}
6771
| Uoffset of ulambda * int
6872
| Ulet of mutable_flag * value_kind * Backend_var.With_provenance.t
6973
* ulambda * ulambda

0 commit comments

Comments
 (0)