Skip to content

Commit a6a9031

Browse files
committed
Merge flambda-backend changes
2 parents 0ac7fdd + 06c189a commit a6a9031

File tree

160 files changed

+5346
-5691
lines changed

Some content is hidden

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

160 files changed

+5346
-5691
lines changed

.depend

Lines changed: 89 additions & 48 deletions
Large diffs are not rendered by default.

Makefile.common-jst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,9 @@ install_for_test: _install
178178
# replace backend-specific testsuite/tools with their new versions
179179
rm _runtest/testsuite/tools/*
180180
cp -a testsuite/tools/* _runtest/testsuite/tools/
181+
# replace backend-specific testsuite/tests/asmcomp with their new versions
182+
rm _runtest/testsuite/tests/asmcomp/*
183+
cp -a testsuite/tests/asmcomp/* _runtest/testsuite/tests/asmcomp/
181184
# replace backend-specific testsuite/tests/asmgen with their new versions
182185
rm _runtest/testsuite/tests/asmgen/*
183186
cp -a testsuite/tests/asmgen/* _runtest/testsuite/tests/asmgen/

Makefile.config.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,7 @@ STDLIB_MANPAGES=@stdlib_manpages@
252252
NAKED_POINTERS=@naked_pointers@
253253
INTEL_JCC_BUG_CFLAGS=@intel_jcc_bug_cflags@
254254
STACK_ALLOCATION=@stack_allocation@
255+
POLL_INSERTION=@poll_insertion@
255256
DUNE=@dune@
256257

257258
### Native command to build ocamlrun.exe

asmcomp/asmgen.ml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ let linear_unit_info =
6565
let reset () =
6666
start_from_emit := false;
6767
if should_save_before_emit () then begin
68-
linear_unit_info.unit <- Compilation_unit.get_current_exn ();
68+
linear_unit_info.unit <- Compilation_unit.get_current_or_dummy ();
6969
linear_unit_info.items <- [];
7070
end
7171

@@ -272,7 +272,8 @@ let compile_implementation ?toplevel ~backend ~prefixname ~middle_end
272272
~asm_filename:(asm_filename prefixname) ~keep_asm:!keep_asm_file
273273
~obj_filename:(prefixname ^ ext_obj)
274274
(fun () ->
275-
Ident.Set.iter Compilenv.require_global program.required_globals;
275+
Compilation_unit.Set.iter Compilenv.require_global
276+
program.required_globals;
276277
let clambda_with_constants =
277278
middle_end ~backend ~prefixname ~ppf_dump program
278279
in

asmcomp/asmlink.ml

Lines changed: 42 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -25,40 +25,40 @@ module CU = Compilation_unit
2525
type error =
2626
| File_not_found of filepath
2727
| Not_an_object_file of filepath
28-
| Missing_implementations of (Linkage_name.t * string list) list
28+
| Missing_implementations of (CU.t * string list) list
2929
| Inconsistent_interface of CU.Name.t * filepath * filepath
30-
| Inconsistent_implementation of CU.Name.t * filepath * filepath
30+
| Inconsistent_implementation of CU.t * filepath * filepath
3131
| Assembler_error of filepath
3232
| Linking_error of int
3333
| Multiple_definition of CU.Name.t * filepath * filepath
34-
| Missing_cmx of filepath * CU.Name.t
34+
| Missing_cmx of filepath * CU.t
3535

3636
exception Error of error
3737

3838
(* Consistency check between interfaces and implementations *)
3939

40-
module Cmi_consistbl = Consistbl.Make (CU.Name)
40+
module Cmi_consistbl = Consistbl.Make (CU.Name) (CU)
4141
let crc_interfaces = Cmi_consistbl.create ()
4242
let interfaces = ref ([] : CU.Name.t list)
4343

44-
module Cmx_consistbl = Consistbl.Make (CU.Name)
44+
module Cmx_consistbl = Consistbl.Make (CU) (Unit)
4545
let crc_implementations = Cmx_consistbl.create ()
46-
let implementations = ref ([] : CU.Name.t list)
47-
let implementations_defined = ref ([] : (CU.Name.t * string) list)
48-
let cmx_required = ref ([] : CU.Name.t list)
46+
let implementations = ref ([] : CU.t list)
47+
let implementations_defined = ref ([] : (CU.t * string) list)
48+
let cmx_required = ref ([] : CU.t list)
4949

5050
let check_consistency file_name unit crc =
5151
begin try
5252
List.iter
5353
(fun (name, crco) ->
54-
let name = CU.Name.of_string name in
5554
interfaces := name :: !interfaces;
5655
match crco with
5756
None -> ()
58-
| Some crc ->
57+
| Some (full_name, crc) ->
5958
if CU.Name.equal name (CU.name unit.ui_unit)
60-
then Cmi_consistbl.set crc_interfaces name crc file_name
61-
else Cmi_consistbl.check crc_interfaces name crc file_name)
59+
then Cmi_consistbl.set crc_interfaces name full_name crc file_name
60+
else
61+
Cmi_consistbl.check crc_interfaces name full_name crc file_name)
6262
unit.ui_imports_cmi
6363
with Cmi_consistbl.Inconsistency {
6464
unit_name = name;
@@ -70,14 +70,13 @@ let check_consistency file_name unit crc =
7070
begin try
7171
List.iter
7272
(fun (name, crco) ->
73-
let name = name |> CU.Name.of_string in
7473
implementations := name :: !implementations;
7574
match crco with
7675
None ->
7776
if List.mem name !cmx_required then
7877
raise(Error(Missing_cmx(file_name, name)))
7978
| Some crc ->
80-
Cmx_consistbl.check crc_implementations name crc file_name)
79+
Cmx_consistbl.check crc_implementations name () crc file_name)
8180
unit.ui_imports_cmx
8281
with Cmx_consistbl.Inconsistency {
8382
unit_name = name;
@@ -88,25 +87,22 @@ let check_consistency file_name unit crc =
8887
end;
8988
let ui_name = CU.name unit.ui_unit in
9089
begin try
91-
let source = List.assoc ui_name !implementations_defined in
92-
raise (Error(Multiple_definition(CU.name unit.ui_unit, file_name, source)))
90+
let source = List.assoc unit.ui_unit !implementations_defined in
91+
raise (Error(Multiple_definition(ui_name, file_name, source)))
9392
with Not_found -> ()
9493
end;
95-
implementations := ui_name :: !implementations;
96-
Cmx_consistbl.set crc_implementations ui_name crc file_name;
94+
implementations := unit.ui_unit :: !implementations;
95+
Cmx_consistbl.set crc_implementations unit.ui_unit () crc file_name;
9796
implementations_defined :=
98-
(ui_name, file_name) :: !implementations_defined;
97+
(unit.ui_unit, file_name) :: !implementations_defined;
9998
if CU.is_packed unit.ui_unit then
100-
cmx_required := ui_name :: !cmx_required
99+
cmx_required := unit.ui_unit :: !cmx_required
101100

102-
let extract_crc_interfaces0 () =
103-
Cmi_consistbl.extract !interfaces crc_interfaces
104101
let extract_crc_interfaces () =
105-
extract_crc_interfaces0 ()
106-
|> List.map (fun (name, crc) -> (name |> CU.Name.to_string, crc))
102+
Cmi_consistbl.extract !interfaces crc_interfaces
107103
let extract_crc_implementations () =
108104
Cmx_consistbl.extract !implementations crc_implementations
109-
|> List.map (fun (name, crc) -> (name |> CU.Name.to_string, crc))
105+
|> List.map (fun (name, crco) -> name, Option.map snd crco)
110106

111107
(* Add C objects and options and "custom" info from a library descriptor.
112108
See bytecomp/bytelink.ml for comments on the order of C objects. *)
@@ -135,7 +131,7 @@ let runtime_lib () =
135131

136132
let missing_globals =
137133
(Hashtbl.create 17 :
138-
(Linkage_name.t, string list ref) Hashtbl.t)
134+
(CU.t, string list ref) Hashtbl.t)
139135

140136
let is_required name =
141137
try ignore (Hashtbl.find missing_globals name); true
@@ -193,26 +189,17 @@ let read_file obj_name =
193189
end
194190
else raise(Error(Not_an_object_file file_name))
195191

196-
let linkage_name_of_modname modname =
192+
let assume_no_prefix modname =
197193
(* We're the linker, so we assume that everything's already been packed, so
198194
no module needs its prefix considered. *)
199-
modname |> Linkage_name.of_string
195+
CU.create CU.Prefix.empty modname
200196

201197
let scan_file file tolink =
202198
match file with
203199
| Unit (file_name,info,crc) ->
204200
(* This is a .cmx file. It must be linked in any case. *)
205-
let linkage_name =
206-
info.ui_unit
207-
|> Compilation_unit.name
208-
|> Compilation_unit.Name.to_string
209-
|> linkage_name_of_modname
210-
in
211-
remove_required linkage_name;
212-
List.iter (fun (name, crc) ->
213-
let name = name |> linkage_name_of_modname in
214-
add_required file_name (name, crc))
215-
info.ui_imports_cmx;
201+
remove_required info.ui_unit;
202+
List.iter (add_required file_name) info.ui_imports_cmx;
216203
(info, file_name, crc) :: tolink
217204
| Library (file_name,infos) ->
218205
(* This is an archive file. Each unit contained in it will be linked
@@ -221,20 +208,15 @@ let scan_file file tolink =
221208
List.fold_right
222209
(fun (info, crc) reqd ->
223210
let ui_name = CU.name info.ui_unit in
224-
let linkage_name =
225-
ui_name |> CU.Name.to_string |> linkage_name_of_modname
226-
in
227211
if info.ui_force_link
228212
|| !Clflags.link_everything
229-
|| is_required linkage_name
213+
|| is_required info.ui_unit
230214
then begin
231-
remove_required linkage_name;
215+
remove_required info.ui_unit;
232216
let req_by =
233217
Printf.sprintf "%s(%s)" file_name (ui_name |> CU.Name.to_string)
234218
in
235-
info.ui_imports_cmx |> List.iter (fun (modname, digest) ->
236-
let linkage_name = modname |> Linkage_name.of_string in
237-
add_required req_by (linkage_name, digest));
219+
List.iter (add_required req_by) info.ui_imports_cmx;
238220
(info, file_name, crc) :: reqd
239221
end else
240222
reqd)
@@ -254,22 +236,24 @@ let make_globals_map units_list ~crc_interfaces =
254236
let defined =
255237
List.map (fun (unit, _, impl_crc) ->
256238
let name = CU.name unit.ui_unit in
257-
let intf_crc = CU.Name.Tbl.find crc_interfaces name in
239+
let intf_crc =
240+
CU.Name.Tbl.find crc_interfaces name
241+
|> Option.map (fun (_unit, crc) -> crc)
242+
in
258243
CU.Name.Tbl.remove crc_interfaces name;
259244
let syms = List.map Symbol.for_compilation_unit unit.ui_defines in
260-
(name, intf_crc, Some impl_crc, syms))
245+
(unit.ui_unit, intf_crc, Some impl_crc, syms))
261246
units_list
262247
in
263248
CU.Name.Tbl.fold (fun name intf acc ->
264-
(name, intf, None, []) :: acc)
249+
let intf = Option.map (fun (_unit, crc) -> crc) intf in
250+
(assume_no_prefix name, intf, None, []) :: acc)
265251
crc_interfaces defined
266252

267253
let make_startup_file ~ppf_dump units_list ~crc_interfaces =
268254
let compile_phrase p = Asmgen.compile_phrase ~ppf_dump p in
269255
Location.input_name := "caml_startup"; (* set name of "current" input *)
270-
let startup_comp_unit =
271-
CU.create CU.Prefix.empty (CU.Name.of_string "_startup")
272-
in
256+
let startup_comp_unit = CU.of_string "_startup" in
273257
Compilenv.reset startup_comp_unit;
274258
Emit.begin_assembly ();
275259
let name_list =
@@ -390,16 +374,14 @@ let link ~ppf_dump objfiles output_name =
390374
else stdlib :: (objfiles @ [stdexit]) in
391375
let obj_infos = List.map read_file objfiles in
392376
let units_tolink = List.fold_right scan_file obj_infos [] in
393-
Array.iter (fun name -> remove_required (name |> Linkage_name.of_string))
394-
Runtimedef.builtin_exceptions;
395377
begin match extract_missing_globals() with
396378
[] -> ()
397379
| mg -> raise(Error(Missing_implementations mg))
398380
end;
399381
List.iter
400382
(fun (info, file_name, crc) -> check_consistency file_name info crc)
401383
units_tolink;
402-
let crc_interfaces = extract_crc_interfaces0 () in
384+
let crc_interfaces = extract_crc_interfaces () in
403385
Clflags.ccobjs := !Clflags.ccobjs @ !lib_ccobjs;
404386
Clflags.all_ccopts := !lib_ccopts @ !Clflags.all_ccopts;
405387
(* put user's opts first *)
@@ -439,7 +421,7 @@ let report_error ppf = function
439421
List.iter
440422
(fun (md, rq) ->
441423
fprintf ppf "@ @[<hov 2>%a referenced from %a@]"
442-
Linkage_name.print md
424+
Compilation_unit.print md
443425
print_references rq) in
444426
fprintf ppf
445427
"@[<v 2>No implementations provided for the following modules:%a@]"
@@ -457,7 +439,7 @@ let report_error ppf = function
457439
over implementation %a@]"
458440
Location.print_filename file1
459441
Location.print_filename file2
460-
CU.Name.print intf
442+
CU.print intf
461443
| Assembler_error file ->
462444
fprintf ppf "Error while assembling %a" Location.print_filename file
463445
| Linking_error exitcode ->
@@ -476,9 +458,9 @@ let report_error ppf = function
476458
Please recompile %a@ with the correct `-I' option@ \
477459
so that %a.cmx@ is found.@]"
478460
Location.print_filename filename
479-
CU.Name.print name
461+
CU.print name
480462
Location.print_filename filename
481-
CU.Name.print name
463+
CU.Name.print (CU.name name)
482464

483465
let () =
484466
Location.register_error_of_exn

asmcomp/asmlink.mli

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,19 +26,19 @@ val call_linker_shared: string list -> string -> unit
2626

2727
val reset : unit -> unit
2828
val check_consistency: filepath -> Cmx_format.unit_infos -> Digest.t -> unit
29-
val extract_crc_interfaces: unit -> crcs
30-
val extract_crc_implementations: unit -> crcs
29+
val extract_crc_interfaces: unit -> Cmx_format.import_info_cmi list
30+
val extract_crc_implementations: unit -> Cmx_format.import_info_cmx list
3131

3232
type error =
3333
| File_not_found of filepath
3434
| Not_an_object_file of filepath
35-
| Missing_implementations of (Linkage_name.t * string list) list
35+
| Missing_implementations of (Compilation_unit.t * string list) list
3636
| Inconsistent_interface of Compilation_unit.Name.t * filepath * filepath
37-
| Inconsistent_implementation of Compilation_unit.Name.t * filepath * filepath
37+
| Inconsistent_implementation of Compilation_unit.t * filepath * filepath
3838
| Assembler_error of filepath
3939
| Linking_error of int
4040
| Multiple_definition of Compilation_unit.Name.t * filepath * filepath
41-
| Missing_cmx of filepath * Compilation_unit.Name.t
41+
| Missing_cmx of filepath * Compilation_unit.t
4242

4343
exception Error of error
4444

0 commit comments

Comments
 (0)