Skip to content

Commit 5580042

Browse files
committed
Merge compiler changes (with conflicts)
1 parent cbeeb72 commit 5580042

37 files changed

+1120
-278
lines changed

src/ocaml/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))

src/ocaml/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;

src/ocaml/typing/cms_format.ml

Lines changed: 20 additions & 2 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,6 +130,19 @@ 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;
133+
<<<<<<< janestreet/merlin-jst:merge-compiler-renaming-changes
134+
||||||| ocaml-flambda/flambda-backend:60158e06115c6fc6e30325bb720e65acf351dbce
135+
cms_ident_occurrences
136+
}
137+
in
138+
output_cms oc cms)
139+
=======
140+
cms_ident_occurrences;
141+
cms_declaration_dependencies;
142+
}
143+
in
144+
output_cms oc cms)
145+
>>>>>>> ocaml-flambda/flambda-backend:87a4cecacc0e2f9afee93898f81f55b012c69214
128146
`cms_comments = Lexer.comments ()`
129147
here. But we don't seem to have the same lexer, so we can't
130148
do that straightforwardly. On the other hand, this function

src/ocaml/typing/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 :

src/ocaml/typing/cmt_format.ml

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,11 @@ and binary_part =
6161
| Partial_signature_item of signature_item
6262
| Partial_module_type of module_type
6363

64+
type dependency_kind = Definition_to_declaration | Declaration_to_declaration
6465
type cmt_infos = {
6566
cmt_modname : Compilation_unit.t;
6667
cmt_annots : binary_annots;
67-
cmt_value_dependencies :
68-
(Types.value_description * Types.value_description) list;
68+
cmt_declaration_dependencies : (dependency_kind * Uid.t * Uid.t) list;
6969
cmt_comments : (string * Location.t) list;
7070
cmt_args : string array;
7171
cmt_sourcefile : string option;
@@ -467,21 +467,31 @@ let read_cmi filename =
467467
| Some cmi, _ -> cmi
468468

469469
let saved_types = ref []
470-
let value_deps = ref []
470+
let uids_deps : (dependency_kind * Uid.t * Uid.t) list ref = ref []
471471

472472
let clear () =
473473
saved_types := [];
474-
value_deps := []
474+
uids_deps := []
475475

476476
let add_saved_type b = saved_types := b :: !saved_types
477477
let get_saved_types () = !saved_types
478478
let set_saved_types l = saved_types := l
479479

480+
<<<<<<< janestreet/merlin-jst:merge-compiler-renaming-changes
480481
(*let record_value_dependency vd1 vd2 =
481482
if vd1.Types.val_loc <> vd2.Types.val_loc then
482483
value_deps := (vd1, vd2) :: !value_deps*)
483484

484485
let record_value_dependency _vd1 _vd2 = ()
486+
||||||| ocaml-flambda/flambda-backend:60158e06115c6fc6e30325bb720e65acf351dbce
487+
let record_value_dependency vd1 vd2 =
488+
if vd1.Types.val_loc <> vd2.Types.val_loc then
489+
value_deps := (vd1, vd2) :: !value_deps
490+
=======
491+
let record_declaration_dependency (rk, uid1, uid2) =
492+
if not (Uid.equal uid1 uid2) then
493+
uids_deps := (rk, uid1, uid2) :: !uids_deps
494+
>>>>>>> ocaml-flambda/flambda-backend:87a4cecacc0e2f9afee93898f81f55b012c69214
485495

486496
let save_cmt target cu binary_annots initial_env cmi shape =
487497
if !Clflags.binary_annotations && not !Clflags.print_types then begin
@@ -516,8 +526,16 @@ let save_cmt target cu binary_annots initial_env cmi shape =
516526
let cmt = {
517527
cmt_modname = cu;
518528
cmt_annots;
529+
<<<<<<< janestreet/merlin-jst:merge-compiler-renaming-changes
519530
cmt_value_dependencies = !value_deps;
520531
cmt_comments = [];
532+
||||||| ocaml-flambda/flambda-backend:60158e06115c6fc6e30325bb720e65acf351dbce
533+
cmt_value_dependencies = !value_deps;
534+
cmt_comments = Lexer.comments ();
535+
=======
536+
cmt_declaration_dependencies = !uids_deps;
537+
cmt_comments = Lexer.comments ();
538+
>>>>>>> ocaml-flambda/flambda-backend:87a4cecacc0e2f9afee93898f81f55b012c69214
521539
cmt_args = Sys.argv;
522540
cmt_sourcefile = sourcefile;
523541
cmt_builddir = Location.rewrite_absolute_path (Sys.getcwd ());
@@ -535,3 +553,5 @@ let save_cmt target cu binary_annots initial_env cmi shape =
535553
output_cmt oc cmt)
536554
end;
537555
clear ()
556+
557+
let get_declaration_dependencies () = !uids_deps

src/ocaml/typing/cmt_format.mli

Lines changed: 16 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
@@ -143,6 +142,19 @@ val iter_on_occurrences :
143142
f:(namespace:Shape.Sig_component_kind.t ->
144143
Env.t ->
145144
Path.t ->
145+
<<<<<<< janestreet/merlin-jst:merge-compiler-renaming-changes
146146
Longident.t Location.loc ->
147147
unit)
148148
-> Tast_iterator.iterator
149+
||||||| ocaml-flambda/flambda-backend:60158e06115c6fc6e30325bb720e65acf351dbce
150+
val read_signature : 'a -> string -> Types.signature * 'b list * 'c list
151+
152+
*)
153+
=======
154+
val read_signature : 'a -> string -> Types.signature * 'b list * 'c list
155+
156+
*)
157+
158+
val get_declaration_dependencies :
159+
unit -> (dependency_kind * Uid.t * Uid.t) list
160+
>>>>>>> ocaml-flambda/flambda-backend:87a4cecacc0e2f9afee93898f81f55b012c69214

src/ocaml/typing/ctype.ml

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7231,8 +7231,31 @@ let check_decl_jkind env decl jkind =
72317231
to expand only as much as needed, but the l/l subtype algorithm is tricky,
72327232
and so we leave this optimization for later. *)
72337233
let type_equal = type_equal env in
7234-
let jkind_of_type ty = Some (type_jkind_purely env ty) in
7235-
match Jkind.sub_jkind_l ~type_equal ~jkind_of_type decl.type_jkind jkind with
7234+
let type_jkind_purely = type_jkind_purely env in
7235+
let jkind_of_type ty = Some (type_jkind_purely ty) in
7236+
(* CR layouts v2.8: When we have [layout_of], this logic should move to the
7237+
place where [type_jkind] is set. But for now, it has to be here, because we
7238+
want this in module inclusion but not other places (because substitutions
7239+
won't improve the layout) *)
7240+
(* CR layouts v2.8: This improvement ignores types with both [@@unboxed]
7241+
and [@@unsafe_allow_any_mode_crossing], because the stdlib didn't build
7242+
otherwise. But we really shouldn't allow mixing those two features, and
7243+
so instead of trying to get to the bottom of it, I'm just punting. *)
7244+
let decl_jkind = match decl.type_kind, decl.type_manifest with
7245+
| Type_abstract _, Some inner_ty
7246+
(* These next cases are more properly rule TK_UNBOXED from kind-inference.md
7247+
(not rule FIND_ABBREV, as documented with [Jkind.for_abbreviation]), but
7248+
they should be fine here. This will all get fixed up later with the
7249+
above CRs. *)
7250+
| Type_record ([{ ld_type = inner_ty }], Record_unboxed, None), _
7251+
| Type_record_unboxed_product ([{ ld_type = inner_ty }], _, None), _
7252+
| Type_variant ([{ cd_args = (Cstr_tuple [{ ca_type = inner_ty }] |
7253+
Cstr_record [{ ld_type = inner_ty }]) }],
7254+
Variant_unboxed, None), _ ->
7255+
Jkind.for_abbreviation ~type_jkind_purely inner_ty
7256+
| _ -> decl.type_jkind
7257+
in
7258+
match Jkind.sub_jkind_l ~type_equal ~jkind_of_type decl_jkind jkind with
72367259
| Ok () -> Ok ()
72377260
| Error _ as err ->
72387261
match decl.type_manifest with

src/ocaml/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

src/ocaml/typing/env.ml

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -323,13 +323,13 @@ type locality_context =
323323

324324
type closure_context =
325325
| Function of locality_context option
326+
| Functor
326327
| Lazy
327328

328329
type escaping_context =
329330
| Letop
330331
| Probe
331332
| Class
332-
| Module
333333

334334
type shared_context =
335335
| For_loop
@@ -338,7 +338,6 @@ type shared_context =
338338
| Closure
339339
| Comprehension
340340
| Class
341-
| Module
342341
| Probe
343342

344343
type lock =
@@ -1548,7 +1547,7 @@ and find_type_unboxed_version path env seen =
15481547
(* CR layouts v7.2: this should be reworked to expand abbrevations, e.g.
15491548
in [type 'a id = 'a and f = float id], [f] can have an unboxed type.
15501549
Parts of the logic looking at type kinds also belong in Ctype.
1551-
See https://github.com/ocaml-flambda/flambda-backend/pull/3526#discussion_r1957157050
1550+
See https://github.com/oxcaml/oxcaml/pull/3526#discussion_r1957157050
15521551
*)
15531552
and find_type_unboxed_version_data path env seen =
15541553
let tda_declaration = find_type_unboxed_version path env seen in
@@ -3089,6 +3088,8 @@ let add_language_extension_types env =
30893088
lazy
30903089
Language_extension.(env
30913090
|> add SIMD Stable Predef.add_simd_stable_extension_types
3091+
|> add SIMD Beta Predef.add_simd_beta_extension_types
3092+
|> add SIMD Alpha Predef.add_simd_alpha_extension_types
30923093
|> add Small_numbers Stable Predef.add_small_number_extension_types
30933094
|> add Small_numbers Beta Predef.add_small_number_beta_extension_types
30943095
|> add Layouts Stable Predef.add_or_null)
@@ -4538,7 +4539,6 @@ let string_of_escaping_context : escaping_context -> string =
45384539
| Letop -> "a letop"
45394540
| Probe -> "a probe"
45404541
| Class -> "a class"
4541-
| Module -> "a module"
45424542

45434543
let string_of_shared_context : shared_context -> string =
45444544
function
@@ -4548,7 +4548,6 @@ let string_of_shared_context : shared_context -> string =
45484548
| Closure -> "a closure that is not once"
45494549
| Comprehension -> "a comprehension"
45504550
| Class -> "a class"
4551-
| Module -> "a module"
45524551
| Probe -> "a probe"
45534552

45544553
let sharedness_hint ppf : shared_context -> _ = function
@@ -4577,10 +4576,6 @@ let sharedness_hint ppf : shared_context -> _ = function
45774576
"@[Hint: This identifier was defined outside of the current closure.@ \
45784577
Either this closure has to be once, or the identifier can be used only@ \
45794578
as aliased.@]"
4580-
| Module ->
4581-
Format.fprintf ppf
4582-
"@[Hint: This identifier cannot be used uniquely,@ \
4583-
because it is defined in a module.@]"
45844579
| Probe ->
45854580
Format.fprintf ppf
45864581
"@[Hint: This identifier cannot be used uniquely,@ \
@@ -4790,6 +4785,13 @@ let report_lookup_error _loc env ppf = function
47904785
| _ -> fun _ppf -> ()
47914786
in
47924787
"function that " ^ e1, hint
4788+
| Functor ->
4789+
let s =
4790+
match error with
4791+
| Error (Areality, _) -> "functor"
4792+
| _ -> "functor that " ^ e1
4793+
in
4794+
s, fun _ppf -> ()
47934795
| Lazy ->
47944796
let s =
47954797
match error with

src/ocaml/typing/env.mli

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,13 +188,13 @@ type locality_context =
188188

189189
type closure_context =
190190
| Function of locality_context option
191+
| Functor
191192
| Lazy
192193

193194
type escaping_context =
194195
| Letop
195196
| Probe
196197
| Class
197-
| Module
198198

199199
type shared_context =
200200
| For_loop
@@ -203,7 +203,6 @@ type shared_context =
203203
| Closure
204204
| Comprehension
205205
| Class
206-
| Module
207206
| Probe
208207

209208
type locks

0 commit comments

Comments
 (0)