Skip to content

Commit 9821b45

Browse files
committed
Fix storing unboxed_vec128 in closures
1 parent 4ef38bf commit 9821b45

File tree

5 files changed

+17
-6
lines changed

5 files changed

+17
-6
lines changed

middle_end/clambda_layout.ml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ type atom =
1717
| Value_int
1818
| Unboxed_float
1919
| Unboxed_int of Lambda.boxed_integer
20+
| Unboxed_vector of Lambda.boxed_vector
2021

2122
let rec fold_left_layout (f : 'acc -> 'e -> atom -> 'acc) (acc : 'acc)
2223
(expr : Clambda.ulambda) (layout : Clambda_primitives.layout) : 'acc =
@@ -28,6 +29,7 @@ let rec fold_left_layout (f : 'acc -> 'e -> atom -> 'acc) (acc : 'acc)
2829
closure."
2930
| Punboxed_float -> f acc expr Unboxed_float
3031
| Punboxed_int bi -> f acc expr (Unboxed_int bi)
32+
| Punboxed_vector bv -> f acc expr (Unboxed_vector bv)
3133
| Pvalue Pintval -> f acc expr Value_int
3234
| Pvalue _ -> f acc expr Value
3335
| Punboxed_product layouts ->
@@ -59,6 +61,7 @@ let print_atom ppf = function
5961
| Unboxed_int Pint32 -> Format.fprintf ppf "unboxed_int32"
6062
| Unboxed_int Pint64 -> Format.fprintf ppf "unboxed_int64"
6163
| Unboxed_int Pnativeint -> Format.fprintf ppf "unboxed_nativeint"
64+
| Unboxed_vector Pvec128 -> Format.fprintf ppf "unboxed_vec128"
6265

6366
let equal_decomposition = ( = )
6467

@@ -80,6 +83,7 @@ let rec decompose (layout : Lambda.layout) : _ decomposition' =
8083
closure."
8184
| Punboxed_float -> Gc_invisible ((), Unboxed_float)
8285
| Punboxed_int bi -> Gc_invisible ((), Unboxed_int bi)
86+
| Punboxed_vector bv -> Gc_invisible ((), Unboxed_vector bv)
8387
| Pvalue Pintval -> Gc_invisible ((), Value_int)
8488
| Pvalue _ -> Gc_visible ((), Value)
8589
| Punboxed_product l -> Product (Array.of_list (List.map decompose l))
@@ -105,7 +109,9 @@ let rec fold_decompose (f1 : 'acc -> 'a -> atom -> 'acc * 'b)
105109
acc, Product elts
106110

107111
let atom_size (layout : atom) =
108-
match layout with Value | Value_int | Unboxed_float | Unboxed_int _ -> 1
112+
match layout with
113+
| Value | Value_int | Unboxed_float | Unboxed_int _ -> 1
114+
| Unboxed_vector Pvec128 -> 2
109115

110116
let assign_invisible_offsets init_pos (var, dec) =
111117
let f_visible acc () _layout = acc, () in

middle_end/clambda_layout.mli

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ type atom =
1717
| Value_int
1818
| Unboxed_float
1919
| Unboxed_int of Lambda.boxed_integer
20+
| Unboxed_vector of Lambda.boxed_vector
2021

2122
val fold_left_layout :
2223
('acc -> Clambda.ulambda -> atom -> 'acc) ->

middle_end/closure/closure.ml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -970,7 +970,7 @@ let split_closure_fv env kinds fv =
970970
let f (not_scanned_fv, scanned_fv) expr (atom : Clambda_layout.atom) =
971971
match atom with
972972
| Value -> not_scanned_fv, ((expr, atom) :: scanned_fv)
973-
| Value_int | Unboxed_float | Unboxed_int _ ->
973+
| Value_int | Unboxed_float | Unboxed_int _ | Unboxed_vector _ ->
974974
((expr, atom) :: not_scanned_fv, scanned_fv)
975975
in
976976
Clambda_layout.fold_left_layout f acc (close_var env id) kind)
@@ -984,6 +984,7 @@ let layout_of_atom (atom : Closure_offsets.layout_atom) : Lambda.layout =
984984
| Value_int -> Pvalue Pintval
985985
| Unboxed_float -> Punboxed_float
986986
| Unboxed_int bi -> Punboxed_int bi
987+
| Unboxed_vector bv -> Punboxed_vector bv
987988

988989
let load_env_field ~base_offset
989990
~closure (parts : Clambda_layout.decomposition) : Clambda.ulambda =

middle_end/flambda/flambda_to_clambda.ml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,7 @@ let layout_of_atom (atom : Closure_offsets.layout_atom) : Lambda.layout =
250250
| Value_int -> Pvalue Pintval
251251
| Unboxed_float -> Punboxed_float
252252
| Unboxed_int bi -> Punboxed_int bi
253+
| Unboxed_vector bv -> Punboxed_vector bv
253254

254255
let load_env_field ~fun_offset
255256
~closure_using_field (parts : Closure_offsets.parts) : Clambda.ulambda =
@@ -735,7 +736,7 @@ and to_clambda_set_of_closures t env
735736
(expr: Clambda.ulambda) (atom : Closure_offsets.layout_atom) =
736737
match atom with
737738
| Value -> not_scanned_fv, (expr :: scanned_fv)
738-
| Value_int | Unboxed_float | Unboxed_int _ ->
739+
| Value_int | Unboxed_float | Unboxed_int _ | Unboxed_vector _ ->
739740
(expr :: not_scanned_fv, scanned_fv)
740741
in
741742
let closure, var_layout = subst_var env free_var.var in

middle_end/flambda2/simplify_shared/slot_offsets.ml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -873,10 +873,12 @@ end = struct
873873
| Region | Rec_info ->
874874
Misc.fatal_errorf "Value slot %a has Region or Rec_info kind"
875875
Value_slot.print value_slot
876-
| Naked_number _ ->
876+
| Naked_number (Naked_immediate | Naked_float | Naked_int32 | Naked_int64 | Naked_nativeint) ->
877877
1, true
878-
(* flambda only supports 64-bits for now, so naked numbers can only
879-
be of size 1 *)
878+
(* flambda only supports 64-bits for now, so naked numbers can only
879+
be of size 1 *)
880+
| Naked_number Naked_vec128 ->
881+
2, true
880882
| Value -> (
881883
match[@ocaml.warning "-4"]
882884
Flambda_kind.With_subkind.subkind kind

0 commit comments

Comments
 (0)