Skip to content

Commit fe6b12c

Browse files
authored
Merge 5.2.0minus 16 retag2 (#175)
* Import ocaml sources for oxcaml/oxcaml@2314e9cbd6a * Automatic merges
1 parent f90210e commit fe6b12c

File tree

7 files changed

+31
-15
lines changed

7 files changed

+31
-15
lines changed

src/ocaml/typing/datarepr.ml

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -107,10 +107,10 @@ let constructor_args ~current_unit priv cd_args cd_res path rep =
107107

108108
let constructor_descrs ~current_unit ty_path decl cstrs rep =
109109
let ty_res = newgenconstr ty_path decl.type_params in
110-
let cstr_shapes_and_arg_jkinds =
110+
let cstr_shapes_and_arg_jkinds, is_unboxed =
111111
match rep, cstrs with
112112
| Variant_extensible, _ -> assert false
113-
| Variant_boxed x, _ -> x
113+
| Variant_boxed x, _ -> x, false
114114
| Variant_unboxed, [{ cd_args }] ->
115115
(* CR layouts: It's tempting just to use [decl.type_jkind] here, instead
116116
of grabbing the jkind from the argument. However, doing so does not
@@ -124,7 +124,7 @@ let constructor_descrs ~current_unit ty_path decl cstrs rep =
124124
begin match cd_args with
125125
| Cstr_tuple [{ ca_sort = sort }]
126126
| Cstr_record [{ ld_sort = sort }] ->
127-
[| Constructor_uniform_value, [| sort |] |]
127+
[| Constructor_uniform_value, [| sort |] |], true
128128
| Cstr_tuple ([] | _ :: _) | Cstr_record ([] | _ :: _) ->
129129
Misc.fatal_error "Multiple arguments in [@@unboxed] variant"
130130
end
@@ -135,15 +135,19 @@ let constructor_descrs ~current_unit ty_path decl cstrs rep =
135135
users to write their own null constructors. *)
136136
(* CR layouts v3.3: generalize to [any]. *)
137137
[| Constructor_uniform_value, [| |]
138-
; Constructor_uniform_value, [| Jkind.Sort.Const.value |] |]
138+
; Constructor_uniform_value, [| Jkind.Sort.Const.value |] |],
139+
false
139140
in
140141
let num_consts = ref 0 and num_nonconsts = ref 0 in
141142
let cstr_constant =
142143
Array.map
143144
(fun (_, sorts) ->
144145
let all_void = Array.for_all Jkind.Sort.Const.all_void sorts in
145-
if all_void then incr num_consts else incr num_nonconsts;
146-
all_void)
146+
(* constant constructors are constructors of non-[@@unboxed] variants
147+
with 0 bits of payload *)
148+
let is_const = all_void && not is_unboxed in
149+
if is_const then incr num_consts else incr num_nonconsts;
150+
is_const)
147151
cstr_shapes_and_arg_jkinds
148152
in
149153
let describe_constructor (src_index, const_tag, nonconst_tag, acc)

src/ocaml/typing/types.ml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -960,7 +960,10 @@ type constructor_description =
960960
cstr_tag: tag; (* Tag for heap blocks *)
961961
cstr_repr: variant_representation; (* Repr of the outer variant *)
962962
cstr_shape: constructor_representation; (* Repr of the constructor itself *)
963-
cstr_constant: bool; (* True if all args are void *)
963+
cstr_constant: bool;
964+
(* True if it's the constructor of a non-[@@unboxed] variant with 0 bits of
965+
payload. (Or equivalently, if it's represented as either a tagged int or
966+
the null pointer) *)
964967
cstr_consts: int; (* Number of constant constructors *)
965968
cstr_nonconsts: int; (* Number of non-const constructors *)
966969
cstr_generalized: bool; (* Constrained return type? *)

src/ocaml/typing/typetexp.ml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1446,6 +1446,7 @@ let transl_type_scheme_poly env attrs loc vars inner_type =
14461446
~post:(fun (_,_,typ) -> generalize_ctyp typ)
14471447
in
14481448
let _ : _ list = TyVarEnv.instance_poly_univars env loc univars in
1449+
remove_mode_and_jkind_variables typ.ctyp_type;
14491450
{ ctyp_desc = Ttyp_poly (typed_vars, typ);
14501451
ctyp_type = typ.ctyp_type;
14511452
ctyp_env = env;
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
31a75865c155563d3d9f84cd4ec5bcaaffa2c81d
1+
2314e9cbd6ae3e5c70fa08e95d49bb9dc27cc812

upstream/ocaml_flambda/typing/datarepr.ml

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -107,10 +107,10 @@ let constructor_args ~current_unit priv cd_args cd_res path rep =
107107

108108
let constructor_descrs ~current_unit ty_path decl cstrs rep =
109109
let ty_res = newgenconstr ty_path decl.type_params in
110-
let cstr_shapes_and_arg_jkinds =
110+
let cstr_shapes_and_arg_jkinds, is_unboxed =
111111
match rep, cstrs with
112112
| Variant_extensible, _ -> assert false
113-
| Variant_boxed x, _ -> x
113+
| Variant_boxed x, _ -> x, false
114114
| Variant_unboxed, [{ cd_args }] ->
115115
(* CR layouts: It's tempting just to use [decl.type_jkind] here, instead
116116
of grabbing the jkind from the argument. However, doing so does not
@@ -124,7 +124,7 @@ let constructor_descrs ~current_unit ty_path decl cstrs rep =
124124
begin match cd_args with
125125
| Cstr_tuple [{ ca_sort = sort }]
126126
| Cstr_record [{ ld_sort = sort }] ->
127-
[| Constructor_uniform_value, [| sort |] |]
127+
[| Constructor_uniform_value, [| sort |] |], true
128128
| Cstr_tuple ([] | _ :: _) | Cstr_record ([] | _ :: _) ->
129129
Misc.fatal_error "Multiple arguments in [@@unboxed] variant"
130130
end
@@ -135,15 +135,19 @@ let constructor_descrs ~current_unit ty_path decl cstrs rep =
135135
users to write their own null constructors. *)
136136
(* CR layouts v3.3: generalize to [any]. *)
137137
[| Constructor_uniform_value, [| |]
138-
; Constructor_uniform_value, [| Jkind.Sort.Const.value |] |]
138+
; Constructor_uniform_value, [| Jkind.Sort.Const.value |] |],
139+
false
139140
in
140141
let num_consts = ref 0 and num_nonconsts = ref 0 in
141142
let cstr_constant =
142143
Array.map
143144
(fun (_, sorts) ->
144145
let all_void = Array.for_all Jkind.Sort.Const.all_void sorts in
145-
if all_void then incr num_consts else incr num_nonconsts;
146-
all_void)
146+
(* constant constructors are constructors of non-[@@unboxed] variants
147+
with 0 bits of payload *)
148+
let is_const = all_void && not is_unboxed in
149+
if is_const then incr num_consts else incr num_nonconsts;
150+
is_const)
147151
cstr_shapes_and_arg_jkinds
148152
in
149153
let describe_constructor (src_index, const_tag, nonconst_tag, acc)

upstream/ocaml_flambda/typing/types.ml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -953,7 +953,10 @@ type constructor_description =
953953
cstr_tag: tag; (* Tag for heap blocks *)
954954
cstr_repr: variant_representation; (* Repr of the outer variant *)
955955
cstr_shape: constructor_representation; (* Repr of the constructor itself *)
956-
cstr_constant: bool; (* True if all args are void *)
956+
cstr_constant: bool;
957+
(* True if it's the constructor of a non-[@@unboxed] variant with 0 bits of
958+
payload. (Or equivalently, if it's represented as either a tagged int or
959+
the null pointer) *)
957960
cstr_consts: int; (* Number of constant constructors *)
958961
cstr_nonconsts: int; (* Number of non-const constructors *)
959962
cstr_generalized: bool; (* Constrained return type? *)

upstream/ocaml_flambda/typing/typetexp.ml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1432,6 +1432,7 @@ let transl_type_scheme_poly env attrs loc vars inner_type =
14321432
~post:(fun (_,_,typ) -> generalize_ctyp typ)
14331433
in
14341434
let _ : _ list = TyVarEnv.instance_poly_univars env loc univars in
1435+
remove_mode_and_jkind_variables typ.ctyp_type;
14351436
{ ctyp_desc = Ttyp_poly (typed_vars, typ);
14361437
ctyp_type = typ.ctyp_type;
14371438
ctyp_env = env;

0 commit comments

Comments
 (0)