Skip to content

Commit cbeeb72

Browse files
committed
Import ocaml sources for oxcaml/oxcaml@87a4cecacc0e
1 parent 989914a commit cbeeb72

40 files changed

+973
-307
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
60158e06115c6fc6e30325bb720e65acf351dbce
1+
87a4cecacc0e2f9afee93898f81f55b012c69214

upstream/ocaml_flambda/file_formats/cms_format.ml

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717

1818
(** cms and cmsi files format. *)
1919

20+
module Uid = Shape.Uid
21+
2022
let read_magic_number ic =
2123
let len_magic_number = String.length Config.cms_magic_number in
2224
really_input_string ic len_magic_number
@@ -32,7 +34,9 @@ type cms_infos = {
3234
cms_uid_to_attributes : Parsetree.attributes Shape.Uid.Tbl.t;
3335
cms_impl_shape : Shape.t option; (* None for mli *)
3436
cms_ident_occurrences :
35-
(Longident.t Location.loc * Shape_reduce.result) array
37+
(Longident.t Location.loc * Shape_reduce.result) array;
38+
cms_declaration_dependencies :
39+
(Cmt_format.dependency_kind * Uid.t * Uid.t) list;
3640
}
3741

3842
type error =
@@ -94,7 +98,8 @@ let uid_tables_of_binary_annots binary_annots =
9498
);
9599
cms_uid_to_loc, cms_uid_to_attributes
96100

97-
let save_cms target modname binary_annots initial_env shape =
101+
let save_cms target modname binary_annots initial_env shape
102+
cms_declaration_dependencies =
98103
if (!Clflags.binary_annotations_cms && not !Clflags.print_types) then begin
99104
Misc.output_to_file_via_temporary
100105
~mode:[Open_binary] (Unit_info.Artifact.filename target)
@@ -125,7 +130,8 @@ let save_cms target modname binary_annots initial_env shape =
125130
cms_uid_to_loc;
126131
cms_uid_to_attributes;
127132
cms_impl_shape = shape;
128-
cms_ident_occurrences
133+
cms_ident_occurrences;
134+
cms_declaration_dependencies;
129135
}
130136
in
131137
output_cms oc cms)

upstream/ocaml_flambda/file_formats/cms_format.mli

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717

1818
(** cms and cmsi files format. *)
1919

20+
module Uid = Shape.Uid
21+
2022
type cms_infos = {
2123
cms_modname : Compilation_unit.t;
2224
cms_comments : (string * Location.t) list;
@@ -28,7 +30,9 @@ type cms_infos = {
2830
cms_uid_to_attributes : Parsetree.attributes Shape.Uid.Tbl.t;
2931
cms_impl_shape : Shape.t option; (* None for mli *)
3032
cms_ident_occurrences :
31-
(Longident.t Location.loc * Shape_reduce.result) array
33+
(Longident.t Location.loc * Shape_reduce.result) array;
34+
cms_declaration_dependencies :
35+
(Cmt_format.dependency_kind * Uid.t * Uid.t) list;
3236
}
3337

3438
type error =
@@ -49,6 +53,7 @@ val save_cms :
4953
Cmt_format.binary_annots ->
5054
Env.t -> (* initial env *)
5155
Shape.t option ->
56+
(Cmt_format.dependency_kind * Uid.t * Uid.t) list ->
5257
unit
5358

5459
val register_toplevel_attributes :

upstream/ocaml_flambda/file_formats/cmt_format.ml

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,11 @@ and binary_part =
4545
| Partial_signature_item of signature_item
4646
| Partial_module_type of module_type
4747

48+
type dependency_kind = Definition_to_declaration | Declaration_to_declaration
4849
type cmt_infos = {
4950
cmt_modname : Compilation_unit.t;
5051
cmt_annots : binary_annots;
51-
cmt_value_dependencies :
52-
(Types.value_description * Types.value_description) list;
52+
cmt_declaration_dependencies : (dependency_kind * Uid.t * Uid.t) list;
5353
cmt_comments : (string * Location.t) list;
5454
cmt_args : string array;
5555
cmt_sourcefile : string option;
@@ -453,19 +453,19 @@ let read_cmi filename =
453453
| Some cmi, _ -> cmi
454454

455455
let saved_types = ref []
456-
let value_deps = ref []
456+
let uids_deps : (dependency_kind * Uid.t * Uid.t) list ref = ref []
457457

458458
let clear () =
459459
saved_types := [];
460-
value_deps := []
460+
uids_deps := []
461461

462462
let add_saved_type b = saved_types := b :: !saved_types
463463
let get_saved_types () = !saved_types
464464
let set_saved_types l = saved_types := l
465465

466-
let record_value_dependency vd1 vd2 =
467-
if vd1.Types.val_loc <> vd2.Types.val_loc then
468-
value_deps := (vd1, vd2) :: !value_deps
466+
let record_declaration_dependency (rk, uid1, uid2) =
467+
if not (Uid.equal uid1 uid2) then
468+
uids_deps := (rk, uid1, uid2) :: !uids_deps
469469

470470
let save_cmt target cu binary_annots initial_env cmi shape =
471471
if !Clflags.binary_annotations && not !Clflags.print_types then begin
@@ -500,7 +500,7 @@ let save_cmt target cu binary_annots initial_env cmi shape =
500500
let cmt = {
501501
cmt_modname = cu;
502502
cmt_annots;
503-
cmt_value_dependencies = !value_deps;
503+
cmt_declaration_dependencies = !uids_deps;
504504
cmt_comments = Lexer.comments ();
505505
cmt_args = Sys.argv;
506506
cmt_sourcefile = sourcefile;
@@ -519,3 +519,5 @@ let save_cmt target cu binary_annots initial_env cmi shape =
519519
output_cmt oc cmt)
520520
end;
521521
clear ()
522+
523+
let get_declaration_dependencies () = !uids_deps

upstream/ocaml_flambda/file_formats/cmt_format.mli

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,11 @@ and binary_part =
4848
| Partial_signature_item of signature_item
4949
| Partial_module_type of module_type
5050

51+
type dependency_kind = Definition_to_declaration | Declaration_to_declaration
5152
type cmt_infos = {
5253
cmt_modname : Compilation_unit.t;
5354
cmt_annots : binary_annots;
54-
cmt_value_dependencies :
55-
(Types.value_description * Types.value_description) list;
55+
cmt_declaration_dependencies : (dependency_kind * Uid.t * Uid.t) list;
5656
cmt_comments : (string * Location.t) list;
5757
cmt_args : string array;
5858
cmt_sourcefile : string option;
@@ -108,8 +108,7 @@ val add_saved_type : binary_part -> unit
108108
val get_saved_types : unit -> binary_part list
109109
val set_saved_types : binary_part list -> unit
110110

111-
val record_value_dependency:
112-
Types.value_description -> Types.value_description -> unit
111+
val record_declaration_dependency: dependency_kind * Uid.t * Uid.t -> unit
113112

114113
val index_occurrences :
115114
binary_annots -> (Longident.t Location.loc * Shape_reduce.result) array
@@ -134,3 +133,6 @@ val need_to_clear_env : bool
134133
val read_signature : 'a -> string -> Types.signature * 'b list * 'c list
135134
136135
*)
136+
137+
val get_declaration_dependencies :
138+
unit -> (dependency_kind * Uid.t * Uid.t) list

upstream/ocaml_flambda/file_formats/cmx_format.mli

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,9 @@ open Misc
3232
of these infos *)
3333

3434
(* Declare machtype here to avoid depending on [Cmm]. *)
35-
type machtype_component = Val | Addr | Int | Float | Vec128 | Float32 | Valx2
35+
type machtype_component =
36+
Val | Addr | Int | Float | Vec128 | Vec256 | Vec512 | Float32 | Valx2
37+
3638
type machtype = machtype_component array
3739

3840
(* [alloc_mode] should be isomorphic to [Cmm.Alloc_mode.t],

upstream/ocaml_flambda/parsing/language_extension.ml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ module Exist_pair = struct
152152
| "layouts_beta" -> Some (Pair (Layouts, Beta))
153153
| "simd" -> Some (Pair (SIMD, Stable))
154154
| "simd_beta" -> Some (Pair (SIMD, Beta))
155+
| "simd_alpha" -> Some (Pair (SIMD, Alpha))
155156
| "labeled_tuples" -> Some (Pair (Labeled_tuples, ()))
156157
| "small_numbers" -> Some (Pair (Small_numbers, Stable))
157158
| "small_numbers_beta" -> Some (Pair (Small_numbers, Beta))

upstream/ocaml_flambda/parsing/parsetree.mli

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1214,7 +1214,7 @@ and module_expr_desc =
12141214
(** [Foo(Param1)(Arg1(Param2)(Arg2)) [@jane.non_erasable.instances]]
12151215
12161216
The name of an instance module. Gets converted to [Global.Name.t] in
1217-
the flambda-backend compiler. *)
1217+
the OxCaml compiler. *)
12181218

12191219
and module_instance =
12201220
{ pmod_instance_head : string;

upstream/ocaml_flambda/typing/ctype.ml

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7197,8 +7197,31 @@ let check_decl_jkind env decl jkind =
71977197
to expand only as much as needed, but the l/l subtype algorithm is tricky,
71987198
and so we leave this optimization for later. *)
71997199
let type_equal = type_equal env in
7200-
let jkind_of_type ty = Some (type_jkind_purely env ty) in
7201-
match Jkind.sub_jkind_l ~type_equal ~jkind_of_type decl.type_jkind jkind with
7200+
let type_jkind_purely = type_jkind_purely env in
7201+
let jkind_of_type ty = Some (type_jkind_purely ty) in
7202+
(* CR layouts v2.8: When we have [layout_of], this logic should move to the
7203+
place where [type_jkind] is set. But for now, it has to be here, because we
7204+
want this in module inclusion but not other places (because substitutions
7205+
won't improve the layout) *)
7206+
(* CR layouts v2.8: This improvement ignores types with both [@@unboxed]
7207+
and [@@unsafe_allow_any_mode_crossing], because the stdlib didn't build
7208+
otherwise. But we really shouldn't allow mixing those two features, and
7209+
so instead of trying to get to the bottom of it, I'm just punting. *)
7210+
let decl_jkind = match decl.type_kind, decl.type_manifest with
7211+
| Type_abstract _, Some inner_ty
7212+
(* These next cases are more properly rule TK_UNBOXED from kind-inference.md
7213+
(not rule FIND_ABBREV, as documented with [Jkind.for_abbreviation]), but
7214+
they should be fine here. This will all get fixed up later with the
7215+
above CRs. *)
7216+
| Type_record ([{ ld_type = inner_ty }], Record_unboxed, None), _
7217+
| Type_record_unboxed_product ([{ ld_type = inner_ty }], _, None), _
7218+
| Type_variant ([{ cd_args = (Cstr_tuple [{ ca_type = inner_ty }] |
7219+
Cstr_record [{ ld_type = inner_ty }]) }],
7220+
Variant_unboxed, None), _ ->
7221+
Jkind.for_abbreviation ~type_jkind_purely inner_ty
7222+
| _ -> decl.type_jkind
7223+
in
7224+
match Jkind.sub_jkind_l ~type_equal ~jkind_of_type decl_jkind jkind with
72027225
| Ok () -> Ok ()
72037226
| Error _ as err ->
72047227
match decl.type_manifest with

upstream/ocaml_flambda/typing/datarepr.ml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,8 @@ let find_constr ~constant tag cstrs =
284284
(function
285285
| ({cstr_tag=Ordinary {runtime_tag=tag'}; cstr_constant},_) ->
286286
tag' = tag && cstr_constant = constant
287-
| ({cstr_tag=Null; cstr_constant}, _) -> tag = -1 && cstr_constant = constant
287+
| ({cstr_tag=Null; cstr_constant}, _) ->
288+
tag = -1 && cstr_constant = constant
288289
| ({cstr_tag=Extension _},_) -> false)
289290
cstrs
290291
with

0 commit comments

Comments
 (0)