Skip to content

Use Global_module.Name.t to stand for a global module identifier #1872

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 217 commits into from
Sep 27, 2024
Merged
Show file tree
Hide file tree
Changes from 208 commits
Commits
Show all changes
217 commits
Select commit Hold shift + click to select a range
80a2978
Add `-as-parameter` option
lukemaurer Aug 16, 2023
65d7cbd
Use `CU.Name.t` for name of .cmi; support import info for parameters
lukemaurer Aug 16, 2023
cf8f9e1
Missed a few changes
lukemaurer Aug 21, 2023
25b63ca
Refactor `Persistent_env` to separate imports from bound names
lukemaurer Aug 23, 2023
d0a1675
Merge branch 'cu-name-is-cmi' into layered-persistent_env
lukemaurer Aug 23, 2023
5cde426
Add `-as-argument-for`
lukemaurer Aug 30, 2023
ef2c16b
Add checks for misuse of `-as-parameter`
lukemaurer Aug 30, 2023
546e73a
Raise error on combination of `-as-parameter` and `-for-pack`
lukemaurer Aug 30, 2023
7f03329
Add test for check for compiling `.ml` of parameter `.mli`
lukemaurer Aug 30, 2023
431d6bb
Add test of check for `-as-parameter` on implementation
lukemaurer Aug 30, 2023
37e88f3
Remove stray debug code
lukemaurer Aug 31, 2023
171ba39
Fix formatting
lukemaurer Aug 31, 2023
3d952f6
Implement `register_parameter_import` and `is_registered_parameter_im…
lukemaurer Aug 31, 2023
73835a0
Code review
lukemaurer Aug 31, 2023
f95b877
Merge branch 'as-parameter' into cu-name-is-cmi
lukemaurer Aug 31, 2023
e2c7976
Merge branch 'cu-name-is-cmi' into layered-persistent_env
lukemaurer Aug 31, 2023
0c87e5c
Merge branch 'layered-persistent_env' into as-argument-for
lukemaurer Aug 31, 2023
cd5ff12
Fix missing change to use of `Env.read_signature`
lukemaurer Sep 13, 2023
c4a43ca
Merge branch 'cu-name-is-cmi' into layered-persistent_env
lukemaurer Sep 13, 2023
68dd87f
Pass shape into `Env` callback
lukemaurer Sep 13, 2023
bc78a1d
Improve API for reading signatures from files
lukemaurer Sep 13, 2023
3875b13
Merge branch 'layered-persistent_env' into as-argument-for
lukemaurer Sep 13, 2023
0283acb
Forgot the code to check .mli files
lukemaurer Sep 20, 2023
61b5aee
Forgot the code to access double module blocks correctly
lukemaurer Sep 20, 2023
5d92b39
Add `-parameter` parameter
lukemaurer Sep 20, 2023
91ea4aa
Add missing objinfo code
lukemaurer Sep 26, 2023
c2cc72e
Merge branch 'as-argument-for' into parameter-parameter
lukemaurer Sep 26, 2023
7b6d875
Pull in `print_global_line` early
lukemaurer Sep 26, 2023
93b491f
Merge branch 'as-argument-for' into parameter-parameter
lukemaurer Sep 26, 2023
617dd89
Add to objinfo
lukemaurer Sep 26, 2023
ab62d1d
New library for computing instance names after substitution
lukemaurer Mar 8, 2023
2caadb2
Rename library to `Global`; defunctorize; move test
lukemaurer Mar 16, 2023
9124af4
Merge remote-tracking branch 'upstream/main' into instance-library
lukemaurer Sep 27, 2023
4a5f03d
Hide records behind checked smart constructors
lukemaurer May 11, 2023
e901457
Have `subst` return original record if the result is equal
lukemaurer May 15, 2023
f8587a5
Fix bug introduced by last commit
lukemaurer May 15, 2023
67ad5fe
Merge remote-tracking branch 'upstream/main' into instance-library
lukemaurer Sep 27, 2023
4710f66
Pull in changes from the 'instance-typing' branch
lukemaurer Aug 10, 2023
4b01ef5
Merge remote-tracking branch 'upstream/main' into instance-library
lukemaurer Sep 27, 2023
db4fa04
Make `Global.Name.print` act like `CU.Name.print` in simple cases
lukemaurer Sep 20, 2023
3ad4ace
Merge branch 'instance-library' into global-name-is-module-id
lukemaurer Sep 27, 2023
0264bdd
Use `Global.Name.t` to stand for a module identifier
lukemaurer Sep 25, 2023
cd80dd5
Merge branch 'parameter-parameter' into global-name-is-module-id
lukemaurer Sep 27, 2023
7a6f98e
Fix compilation following merge
lukemaurer Sep 26, 2023
ef9ee8c
objinfo: Include arguments in names of compilation units
lukemaurer Sep 26, 2023
28d352f
Pull in check for instance arguments on interface import
lukemaurer Sep 27, 2023
c24e14f
Code review
lukemaurer Sep 29, 2023
4336e64
Merge remote-tracking branch 'upstream/main' into as-parameter
lukemaurer Sep 29, 2023
d530f6b
Add to .cmo format rather than only .cmx format
lukemaurer Oct 4, 2023
f403dd8
Fix comment
lukemaurer Oct 4, 2023
a529df1
Merge branch 'as-argument-for' into parameter-parameter
lukemaurer Oct 4, 2023
8440403
Merge branch 'parameter-parameter' into global-name-is-module-id
lukemaurer Oct 4, 2023
243264c
Also change the new `cu_implements_param` field
lukemaurer Oct 4, 2023
8b52f69
Fix error message and re-enable test
lukemaurer Oct 19, 2023
c1ebcbe
Merge branch 'as-parameter' into cu-name-is-cmi
lukemaurer Oct 19, 2023
2dda1ca
Fix compilation following merge
lukemaurer Oct 19, 2023
a3b7a31
Update bootstrap compiler
lukemaurer Oct 19, 2023
fa251ce
Fix upstream build
lukemaurer Oct 19, 2023
6f86fb9
Disable test of error message
lukemaurer Oct 19, 2023
88b6185
Merge branch 'cu-name-is-cmi' into layered-persistent_env
lukemaurer Oct 19, 2023
52ea8fd
Revert "Disable test of error message"
lukemaurer Oct 19, 2023
a9eea0b
Fix upstream build
lukemaurer Oct 19, 2023
4f01e24
Merge branch 'layered-persistent_env' into as-argument-for
lukemaurer Oct 19, 2023
3c5b7b5
Merge branch 'as-argument-for' into parameter-parameter
lukemaurer Oct 19, 2023
d619a45
Fix conflicts
lukemaurer Oct 19, 2023
156fd09
Merge branch 'parameter-parameter' into global-name-is-module-id
lukemaurer Oct 19, 2023
b4ec625
Normalise test specification
lukemaurer Oct 20, 2023
591a4ec
Generate test specifications
lukemaurer Oct 10, 2023
268ebbd
Test native compilation
lukemaurer Oct 10, 2023
c15dcfb
Ability to add extra variables to actions in `gen_test`
lukemaurer Oct 11, 2023
0a8ee56
Merge branch 'as-argument-for' into parameter-parameter
lukemaurer Oct 20, 2023
a17d34c
Update test generation and add native tests
lukemaurer Oct 20, 2023
70b77ea
Merge branch 'parameter-parameter' into global-name-is-module-id
lukemaurer Oct 20, 2023
294ad42
Merge remote-tracking branch 'upstream/main' into as-parameter
lukemaurer Nov 16, 2023
5518617
Merge remote-tracking branch 'upstream/main' into as-parameter
lukemaurer Nov 16, 2023
77e4338
Merge branch 'as-parameter' into cu-name-is-cmi
lukemaurer Nov 17, 2023
23adeca
Merge branch 'as-parameter' into cu-name-is-cmi
lukemaurer Nov 17, 2023
9234fcd
Bootstrap
lukemaurer Nov 17, 2023
4b2f192
Merge branch 'cu-name-is-cmi' into layered-persistent_env
lukemaurer Nov 17, 2023
025558c
Remove warning boilerplate from new files
lukemaurer Nov 17, 2023
4c0c8b6
Update `ocaml/.depend`
lukemaurer Nov 17, 2023
f494b9f
Merge branch 'layered-persistent_env' into as-argument-for
lukemaurer Nov 17, 2023
3b8a7f5
Fix a bit of silly back-and-forth
lukemaurer Nov 17, 2023
daaf996
Update tests following rebase
lukemaurer Nov 17, 2023
987a2bd
Partially fix Closure
lukemaurer Nov 17, 2023
2c8ca86
Merge branch 'as-argument-for' into parameter-parameter
lukemaurer Nov 17, 2023
4dd61bb
Merge remote-tracking branch 'upstream/main' into as-parameter
lukemaurer Dec 5, 2023
c67a202
Merge remote-tracking branch 'upstream/main' into as-parameter
lukemaurer Dec 8, 2023
4322629
Use unnamed field instead of double module block
lukemaurer Dec 11, 2023
6d22bc4
Store argument block itself rather than coercion function
lukemaurer Dec 12, 2023
398cc90
Bring in squashed merge of 'as-parameter' branch
lukemaurer Dec 12, 2023
9db2c13
Merge branch 'unsquash/as-parameter' into cu-name-is-cmi
lukemaurer Dec 12, 2023
bf51bd8
Merge remote-tracking branch 'upstream/main' into cu-name-is-cmi
lukemaurer Dec 12, 2023
28654cc
Merge remote-tracking branch 'upstream/main' into unsquash/as-parameter
lukemaurer Dec 12, 2023
f1e32a9
Merge branch 'unsquash/as-parameter' into cu-name-is-cmi
lukemaurer Dec 12, 2023
7d7a241
Merge branch 'as-argument-for' into parameter-parameter
lukemaurer Dec 12, 2023
65e2a92
Fix build of upstream objinfo
lukemaurer Dec 12, 2023
dc7eeaf
Bootstrap
lukemaurer Dec 12, 2023
489b046
Merge branch 'parameter-parameter' into global-name-is-module-id
lukemaurer Dec 13, 2023
fa9a22e
Fix upstream build
lukemaurer Dec 13, 2023
3cb1126
Code review
lukemaurer Dec 18, 2023
e05a7f5
Code review
lukemaurer Dec 19, 2023
b3be73d
Merge branch 'cu-name-is-cmi' into layered-persistent_env
lukemaurer Dec 19, 2023
b07af9b
Merge branch 'layered-persistent_env' into as-argument-for
lukemaurer Dec 19, 2023
a277c51
Bootstrap
lukemaurer Dec 19, 2023
73f2689
Merge branch 'as-argument-for' into parameter-parameter
lukemaurer Dec 19, 2023
e94a213
Fix compilation following merge
lukemaurer Dec 19, 2023
5de168d
Bootstrap
lukemaurer Dec 19, 2023
0372eae
Merge branch 'parameter-parameter' into global-name-is-module-id
lukemaurer Dec 19, 2023
e8abb3a
Remove code gen changes from `-as-argument-for` branch
lukemaurer Dec 22, 2023
c816563
Merge branch 'as-argument-for' into parameter-parameter
lukemaurer Feb 5, 2024
1cee4f4
Remove code gen changes from 'parameter-parameter' branch
lukemaurer Feb 5, 2024
68e347c
Bootstrap
lukemaurer Feb 5, 2024
814a8a7
Remove more code gen code from 'parameter-parameter' branch
lukemaurer Feb 5, 2024
c36393a
Merge branch 'parameter-parameter' into global-name-is-module-id
lukemaurer Feb 5, 2024
95e7772
Generate stub variables for runtime parameters
lukemaurer Feb 7, 2024
abf0b5d
Merge branch 'parameter-parameter' into global-name-is-module-id
lukemaurer Feb 7, 2024
7d6f798
Rename `secondary_interface` to `argument_interface`
lukemaurer Feb 20, 2024
87ab117
Merge branch 'as-argument-for' into parameter-parameter
lukemaurer Feb 20, 2024
a903a9a
Merge branch 'parameter-parameter' into global-name-is-module-id
lukemaurer Feb 20, 2024
c086a8a
Remove .cmx-related code gen code from 'parameter-parameter' branch
lukemaurer Feb 20, 2024
ee1958b
Merge branch 'parameter-parameter' into global-name-is-module-id
lukemaurer Feb 20, 2024
766cfa9
Fix compilation following merge
lukemaurer Feb 20, 2024
ccd7064
Overhaul `Import_info` implementation and new API
lukemaurer Apr 30, 2024
c6f988b
Code review
lukemaurer Apr 30, 2024
91c2329
Bootstrap
lukemaurer Apr 30, 2024
8a2b5c2
Merge branch 'cu-name-is-cmi' into layered-persistent_env
lukemaurer Apr 30, 2024
a3641bb
Compilation fixes following merge
lukemaurer Apr 30, 2024
7e760a1
Copy changes from `asmlink.ml` to `asmlink.ml`
lukemaurer May 1, 2024
014a2d3
Rename a few things for consistency and update comments
lukemaurer May 1, 2024
66fb8b8
Merge branch 'cu-name-is-cmi' into layered-persistent_env
lukemaurer May 1, 2024
447c2dd
Merge remote-tracking branch 'upstream/main' into cu-name-is-cmi
lukemaurer May 1, 2024
f1be371
Merge branch 'layered-persistent_env' into as-argument-for
lukemaurer May 1, 2024
91b0725
Merge branch 'cu-name-is-cmi' into layered-persistent_env
lukemaurer May 1, 2024
d701be1
Code review
lukemaurer May 1, 2024
d4cacae
Re-check visibility on _either_ cache hit
lukemaurer May 1, 2024
efd3020
Merge remote-tracking branch 'upstream/main' into cu-name-is-cmi
lukemaurer May 9, 2024
2adb8bd
Rename a few things for code review
lukemaurer May 15, 2024
381a67c
Merge branch 'cu-name-is-cmi' into layered-persistent_env
lukemaurer May 15, 2024
4ad0aa3
Merge branch 'upstream/main' into layered-persistent_env, up to squas…
lukemaurer May 15, 2024
5af30a5
Bring in squashed merge of 'cu-name-is-cmi' branch
lukemaurer May 15, 2024
f255c62
Merge remote-tracking branch 'upstream/main' into layered-persistent_env
lukemaurer May 15, 2024
6c16e9d
Merge branch 'as-argument-for' into parameter-parameter
lukemaurer May 15, 2024
9fcab53
Merge branch 'layered-persistent_env' into as-argument-for
lukemaurer May 15, 2024
288ed6c
Remove test spec generator
lukemaurer May 15, 2024
5f5a85b
Merge remote-tracking branch 'upstream/main' into instance-library
lukemaurer May 22, 2024
1159e12
Remove now-unused functions from `Misc`
lukemaurer May 22, 2024
531c90c
Have `Global.subst` return whether the input changed
lukemaurer May 22, 2024
1e681ac
Bring in squashed merge of 'layered-persistent_env' branch
lukemaurer May 23, 2024
9dde77e
Rename `global.ml` to `global_module.ml` and move into `typing/`
lukemaurer May 28, 2024
6272975
Improve error messages
lukemaurer May 29, 2024
70a9aa2
Code review
lukemaurer May 29, 2024
2eb82e8
Translate test file ahead of rebase
lukemaurer May 30, 2024
59ea4f9
Merge branch 'as-argument-for' into parameter-parameter
lukemaurer May 30, 2024
81e099e
Fix compilation following merge
lukemaurer May 30, 2024
ec20f9c
Merge branch 'parameter-parameter' into global-name-is-module-id
lukemaurer May 30, 2024
e6904d6
Merge branch 'parameter-parameter' into global-name-is-module-id
lukemaurer May 30, 2024
6733ace
Partially merge remote-tracking branch 'upstream/main' into as-argume…
lukemaurer May 30, 2024
84c9c49
Merge branch 'as-argument-for' into parameter-parameter
lukemaurer May 30, 2024
7398e80
Merge branch 'parameter-parameter' into global-name-is-module-id
lukemaurer May 30, 2024
b87ccc0
Merge branch 'instance-library' into global-name-is-module-id
lukemaurer May 30, 2024
9595527
Restore `Misc.merge_iter` and `Misc.merge_map`
lukemaurer May 30, 2024
a87959b
Merge remote-tracking branch 'upstream/main' into as-argument-for
lukemaurer May 30, 2024
453d7a6
Merge branch 'as-argument-for' into parameter-parameter
lukemaurer May 30, 2024
54637cf
Remove stale dynlink changes left over from 'instance-library' branch
lukemaurer May 30, 2024
4061e54
Add unsquashed 'instance-library' branch as parent
lukemaurer May 30, 2024
c6c696e
Merge branch 'as-argument-for' into parameter-parameter
lukemaurer May 30, 2024
67e7bd9
Merge branch 'parameter-parameter' into global-name-is-module-id
lukemaurer May 30, 2024
dce211c
Fix compilation following merge
lukemaurer May 30, 2024
156aa4d
More awful `dynlink_compilerlibs` fiddling
lukemaurer May 30, 2024
5a8b458
Even more `dynlink` fiddling for my sins
lukemaurer Jun 4, 2024
33a0476
Put back inadvertently-removed argument label in `Typemod`
lukemaurer Jun 6, 2024
6e596bf
Don't register the argument type as a parameter import
lukemaurer Jun 6, 2024
051fb88
Merge branch 'as-argument-for' into parameter-parameter
lukemaurer Jun 6, 2024
91f658c
Remove concept of unexported parameters
lukemaurer Jun 6, 2024
0ebda3d
Make `param_imports` a `Param_set.t`
lukemaurer Jun 6, 2024
e554cb4
Merge branch 'parameter-parameter' into global-name-is-module-id
lukemaurer Jun 6, 2024
3feced2
Small bit of cleanup
lukemaurer Jun 6, 2024
4fe7cf7
Remove test generation code (again)
lukemaurer Jun 12, 2024
dddbeaf
Add test for error on `-parameter A` when `A` is not a parameter
lukemaurer Jun 12, 2024
4e55d0d
Merge branch 'parameter-parameter' into global-name-is-module-id
lukemaurer Jun 12, 2024
de086d2
Merge from 'upstream/main' up to squashed 'as-argument-for' branch
lukemaurer Jun 18, 2024
65376e1
Merge squashed 'as-argument-for' branch from 'upstream/main'
lukemaurer Jun 18, 2024
eb4f173
Merge branch 'parameter-parameter' into global-name-is-module-id
lukemaurer Jun 18, 2024
32ea6ef
Add test for positive case of subset rule
lukemaurer Jun 26, 2024
8466bfa
Bind parameterized modules locally
lukemaurer Jun 26, 2024
042b14d
Fix compilation
lukemaurer Jun 27, 2024
2f3ad28
Update tests to expect local binding of parameterized modules
lukemaurer Jun 27, 2024
79678ae
Update test output to account for missing flambda2 export information
lukemaurer Jun 27, 2024
44400e8
Skip output check for objinfo on .cmx
lukemaurer Jun 27, 2024
649b8e7
Always check for `-as-parameter` on implementation
lukemaurer Jun 28, 2024
1b350b9
Disallow combining `-as-parameter` and `-parameter`
lukemaurer Jun 28, 2024
08a831a
Code review: Improve error message for subset rule
lukemaurer Jul 3, 2024
e1c7627
Code review
lukemaurer Jul 3, 2024
298f477
More code review
lukemaurer Jul 3, 2024
949b7be
Code review: Use, explain "runtime parameters" terminology
lukemaurer Jul 3, 2024
de20fe3
Add a bit more explanation about runtime parameters
lukemaurer Jul 4, 2024
81c50a7
Properly stub out shapes of parameters and parameterised modules
lukemaurer Jul 4, 2024
114ff61
Merge branch 'parameter-parameter' into global-name-is-module-id
lukemaurer Jul 5, 2024
e359add
Merge from 'upstream/main' up to squashed 'parameter-parameter' into …
lukemaurer Jul 5, 2024
5ae92d0
Merge squashed 'parameter-parameter' into global-name-is-module-id
lukemaurer Jul 5, 2024
def8739
Merge remote-tracking branch 'upstream/main' into global-name-is-modu…
lukemaurer Jul 5, 2024
5173c87
Merge remote-tracking branch 'upstream/main' into global-name-is-modu…
lukemaurer Jul 8, 2024
ca4c418
Revert changes to `ocaml/.depend` relative to 'upstream/main'
lukemaurer Jul 9, 2024
e6e922c
Deal with stale upstream references to `Global`
lukemaurer Jul 9, 2024
0f76c03
Punt changes to `Shape`
lukemaurer Jul 9, 2024
227e212
Don't put line breaks in `name`s of idents
lukemaurer Jul 9, 2024
e2b2da3
Merge remote-tracking branch 'upstream/main' into global-name-is-modu…
lukemaurer Jul 18, 2024
e7cd6f8
Merge remote-tracking branch 'upstream/main' into global-name-is-modu…
lukemaurer Aug 20, 2024
a843f8f
Introduce record type for instance arguments
lukemaurer Sep 23, 2024
084e460
Code review
lukemaurer Sep 23, 2024
ea3d62e
Merge tag '5.1.1minus-24' into global-name-is-module-id
lukemaurer Sep 24, 2024
1625c02
Merge remote-tracking branch 'upstream/main' into global-name-is-modu…
lukemaurer Sep 25, 2024
86eac6d
Remove accidental copy of `Makefile.compilerlibs`
lukemaurer Sep 25, 2024
e143e8b
Reluctantly fix failure of egregious test
lukemaurer Sep 26, 2024
70ea5f6
Code review
lukemaurer Sep 26, 2024
3d0b5d1
One more change I left out of code review
lukemaurer Sep 26, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 21 additions & 11 deletions middle_end/compilenv.ml
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,13 @@ type error =

exception Error of error

module Infos_table = Global_module.Name.Tbl

let global_infos_table =
(CU.Name.Tbl.create 17 : unit_infos option CU.Name.Tbl.t)
(Infos_table.create 17 : unit_infos option Infos_table.t)

let reset_info_tables () =
CU.Name.Tbl.reset global_infos_table
Infos_table.reset global_infos_table

module String = Misc.Stdlib.String

Expand All @@ -62,7 +64,7 @@ let current_unit =
}

let reset compilation_unit =
CU.Name.Tbl.clear global_infos_table;
Infos_table.clear global_infos_table;
Zero_alloc_info.reset cached_zero_alloc_info;
CU.set_current (Some compilation_unit);
current_unit.ui_unit <- compilation_unit;
Expand Down Expand Up @@ -133,41 +135,48 @@ let read_library_info filename =

(* Read and cache info on global identifiers *)

let equal_args (name1, value1) (name2, value2) =
CU.equal name1 name2 && CU.equal value1 value2

let equal_up_to_pack_prefix cu1 cu2 =
CU.Name.equal (CU.name cu1) (CU.name cu2)
&& List.equal equal_args (CU.instance_arguments cu1) (CU.instance_arguments cu2)

let get_unit_info comp_unit =
(* If this fails, it likely means that someone didn't call
[CU.which_cmx_file]. *)
assert (CU.can_access_cmx_file comp_unit ~accessed_by:current_unit.ui_unit);
(* CR lmaurer: Surely this should just compare [comp_unit] to
[current_unit.ui_unit], but doing so seems to break Closure. We should fix
that. *)
if CU.Name.equal (CU.name comp_unit) (CU.name current_unit.ui_unit)
if equal_up_to_pack_prefix comp_unit current_unit.ui_unit
then
Some current_unit
else begin
let cmx_name = CU.name comp_unit in
let name = CU.to_global_name_without_prefix comp_unit in
try
CU.Name.Tbl.find global_infos_table cmx_name
Infos_table.find global_infos_table name
with Not_found ->
let (infos, crc) =
if Env.is_imported_opaque cmx_name then (None, None)
if Env.is_imported_opaque (CU.name comp_unit) then (None, None)
else begin
try
let filename =
Load_path.find_uncap ((cmx_name |> CU.Name.to_string) ^ ".cmx") in
Load_path.find_uncap (CU.base_filename comp_unit ^ ".cmx") in
let (ui, crc) = read_unit_info filename in
if not (CU.equal ui.ui_unit comp_unit) then
raise(Error(Illegal_renaming(comp_unit, ui.ui_unit, filename)));
cache_zero_alloc_info ui.ui_zero_alloc_info;
(Some ui, Some crc)
with Not_found ->
let warn = Warnings.No_cmx_file (cmx_name |> CU.Name.to_string) in
let warn = Warnings.No_cmx_file (Global_module.Name.to_string name) in
Location.prerr_warning Location.none warn;
(None, None)
end
in
let import = Import_info.create_normal comp_unit ~crc in
current_unit.ui_imports_cmx <- import :: current_unit.ui_imports_cmx;
CU.Name.Tbl.add global_infos_table cmx_name infos;
Infos_table.add global_infos_table name infos;
infos
end

Expand All @@ -189,7 +198,8 @@ let get_global_export_info id =

let cache_unit_info ui =
cache_zero_alloc_info ui.ui_zero_alloc_info;
CU.Name.Tbl.add global_infos_table (CU.name ui.ui_unit) (Some ui)
Infos_table.add global_infos_table
(ui.ui_unit |> CU.to_global_name_without_prefix) (Some ui)

(* Exporting cross-module information *)

Expand Down
1 change: 1 addition & 0 deletions ocaml/compilerlibs/Makefile.compilerlibs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ UTILS = \
utils/domainstate.cmo \
utils/binutils.cmo \
utils/target_system.cmo \
utils/global.cmo \
typing/ident.cmo \
utils/compilation_unit.cmo utils/linkage_name.cmo utils/symbol.cmo \
utils/import_info.cmo \
Expand Down
2 changes: 1 addition & 1 deletion ocaml/driver/compile_common.ml
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ let emit_signature info ast tsg =
else begin
let cmi_arg_for =
match !Clflags.as_argument_for with
| Some arg_type -> Some (Compilation_unit.Name.of_string arg_type)
| Some arg_type -> Some (Global_module.Name.create arg_type [])
| None -> None
in
Normal { cmi_impl = info.module_name; cmi_arg_for }
Expand Down
6 changes: 3 additions & 3 deletions ocaml/file_formats/cmi_format.ml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ type pers_flags =
type kind =
| Normal of {
cmi_impl : Compilation_unit.t;
cmi_arg_for : Compilation_unit.Name.t option;
cmi_arg_for : Global_module.Name.t option;
}
| Parameter

Expand Down Expand Up @@ -64,14 +64,14 @@ type header = {
header_name : Compilation_unit.Name.t;
header_kind : kind;
header_sign : Serialized.signature;
header_params : Compilation_unit.Name.t list;
header_params : Global_module.Name.t list;
}

type 'sg cmi_infos_generic = {
cmi_name : Compilation_unit.Name.t;
cmi_kind : kind;
cmi_sign : 'sg;
cmi_params : Compilation_unit.Name.t list;
cmi_params : Global_module.Name.t list;
cmi_crcs : crcs;
cmi_flags : flags;
}
Expand Down
4 changes: 2 additions & 2 deletions ocaml/file_formats/cmi_format.mli
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@ type kind =
cmi_impl : Compilation_unit.t;
(* If this module takes parameters, [cmi_impl] will be the functor that
generates instances *)
cmi_arg_for : Compilation_unit.Name.t option;
cmi_arg_for : Global_module.Name.t option;
}
| Parameter

type 'sg cmi_infos_generic = {
cmi_name : Compilation_unit.Name.t;
cmi_kind : kind;
cmi_sign : 'sg;
cmi_params : Compilation_unit.Name.t list;
cmi_params : Global_module.Name.t list;
cmi_crcs : Import_info.t array;
cmi_flags : pers_flags list;
}
Expand Down
40 changes: 25 additions & 15 deletions ocaml/middle_end/compilenv.ml
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,12 @@ type error =

exception Error of error

module Infos_table = Global.Name.Tbl

let global_infos_table =
(CU.Name.Tbl.create 17 : unit_infos option CU.Name.Tbl.t)
(Infos_table.create 17 : unit_infos option Infos_table.t)
let export_infos_table =
(CU.Name.Tbl.create 10 : Export_info.t CU.Name.Tbl.t)
(Infos_table.create 10 : Export_info.t Infos_table.t)

let imported_sets_of_closures_table =
(Set_of_closures_id.Tbl.create 10
Expand Down Expand Up @@ -93,7 +95,7 @@ let current_unit =
ui_for_pack = None }

let reset compilation_unit =
CU.Name.Tbl.clear global_infos_table;
Infos_table.clear global_infos_table;
Set_of_closures_id.Tbl.clear imported_sets_of_closures_table;
CU.set_current (Some compilation_unit);
current_unit.ui_unit <- compilation_unit;
Expand All @@ -108,7 +110,7 @@ let reset compilation_unit =
structured_constants := structured_constants_empty;
current_unit.ui_export_info <- default_ui_export_info;
merged_environment := Export_info.empty;
CU.Name.Tbl.clear export_infos_table
Infos_table.clear export_infos_table

let current_unit_infos () =
current_unit
Expand Down Expand Up @@ -140,27 +142,34 @@ let read_library_info filename =

(* Read and cache info on global identifiers *)

let equal_args (name1, value1) (name2, value2) =
CU.equal name1 name2 && CU.equal value1 value2

let equal_up_to_pack_prefix cu1 cu2 =
CU.Name.equal (CU.name cu1) (CU.name cu2)
&& List.equal equal_args (CU.instance_arguments cu1) (CU.instance_arguments cu2)

let get_unit_info comp_unit =
(* If this fails, it likely means that someone didn't call
[CU.which_cmx_file]. *)
assert (CU.can_access_cmx_file comp_unit ~accessed_by:current_unit.ui_unit);
(* CR lmaurer: Surely this should just compare [comp_unit] to
[current_unit.ui_unit], but doing so seems to break Closure. We should fix
that. *)
if CU.Name.equal (CU.name comp_unit) (CU.name current_unit.ui_unit)
if equal_up_to_pack_prefix comp_unit current_unit.ui_unit
then
Some current_unit
else begin
let cmx_name = CU.name comp_unit in
let name = CU.to_global_name_without_prefix comp_unit in
try
CU.Name.Tbl.find global_infos_table cmx_name
Infos_table.find global_infos_table name
with Not_found ->
let (infos, crc) =
if Env.is_imported_opaque cmx_name then (None, None)
if Env.is_imported_opaque (CU.name comp_unit) then (None, None)
else begin
try
let filename =
Load_path.find_uncap ((cmx_name |> CU.Name.to_string) ^ ".cmx") in
Load_path.find_uncap (CU.base_filename comp_unit ^ ".cmx") in
let (ui, crc) = read_unit_info filename in
if not (CU.equal ui.ui_unit comp_unit) then
raise(Error(Illegal_renaming(comp_unit, ui.ui_unit, filename)));
Expand All @@ -182,15 +191,15 @@ let get_unit_info comp_unit =
(filename, p1, CU.name current_unit.ui_unit, p2))));
(Some ui, Some crc)
with Not_found ->
let warn = Warnings.No_cmx_file (cmx_name |> CU.Name.to_string) in
let warn = Warnings.No_cmx_file (Global.Name.to_string name) in
Location.prerr_warning Location.none warn;
(None, None)
end
in
let import = Import_info.create_normal comp_unit ~crc in
current_unit.ui_imports_cmx <-
Array.append [| import |] current_unit.ui_imports_cmx;
CU.Name.Tbl.add global_infos_table cmx_name infos;
Infos_table.add global_infos_table name infos;
infos
end

Expand All @@ -201,7 +210,8 @@ let get_global_info global_ident =
get_unit_info (which_cmx_file global_ident)

let cache_unit_info ui =
CU.Name.Tbl.add global_infos_table (CU.name ui.ui_unit) (Some ui)
Infos_table.add global_infos_table
(ui.ui_unit |> CU.to_global_name_without_prefix) (Some ui)

(* Return the approximation of a global identifier *)

Expand Down Expand Up @@ -248,15 +258,15 @@ let approx_for_global comp_unit =
if CU.equal comp_unit CU.predef_exn
then invalid_arg "approx_for_global with predef_exn compilation unit";
let accessible_comp_unit = which_cmx_file comp_unit in
let cmx_name = CU.name accessible_comp_unit in
match CU.Name.Tbl.find export_infos_table cmx_name with
let name = accessible_comp_unit |> CU.to_global_name_without_prefix in
match Infos_table.find export_infos_table name with
| otherwise -> Some otherwise
| exception Not_found ->
match get_unit_info accessible_comp_unit with
| None -> None
| Some ui ->
let exported = get_flambda_export_info ui in
CU.Name.Tbl.add export_infos_table cmx_name exported;
Infos_table.add export_infos_table name exported;
merged_environment := Export_info.merge !merged_environment exported;
Some exported

Expand Down
5 changes: 5 additions & 0 deletions ocaml/otherlibs/dynlink/dune
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@
ast_mapper
attr_helper
builtin_attributes
global_module
ident
path
shape
Expand Down Expand Up @@ -190,6 +191,7 @@
(copy_files ../../parsing/ast_mapper.ml)
(copy_files ../../parsing/attr_helper.ml)
(copy_files ../../parsing/builtin_attributes.ml)
(copy_files ../../typing/global_module.ml)
(copy_files ../../typing/ident.ml)
(copy_files ../../typing/path.ml)
(copy_files ../../typing/jkind.ml)
Expand Down Expand Up @@ -261,6 +263,7 @@
(copy_files ../../parsing/ast_mapper.mli)
(copy_files ../../parsing/attr_helper.mli)
(copy_files ../../parsing/builtin_attributes.mli)
(copy_files ../../typing/global_module.mli)
(copy_files ../../typing/ident.mli)
(copy_files ../../typing/path.mli)
(copy_files ../../typing/jkind.mli)
Expand Down Expand Up @@ -361,6 +364,7 @@
.dynlink_compilerlibs.objs/byte/dynlink_compilerlibs__Language_extension.cmo
.dynlink_compilerlibs.objs/byte/dynlink_compilerlibs__Terminfo.cmo
.dynlink_compilerlibs.objs/byte/dynlink_compilerlibs__Location.cmo
.dynlink_compilerlibs.objs/byte/dynlink_compilerlibs__Global_module.cmo
.dynlink_compilerlibs.objs/byte/dynlink_compilerlibs__Ident.cmo
.dynlink_compilerlibs.objs/byte/dynlink_compilerlibs__Longident.cmo
.dynlink_compilerlibs.objs/byte/dynlink_compilerlibs__Compilation_unit.cmo
Expand Down Expand Up @@ -446,6 +450,7 @@
.dynlink_compilerlibs.objs/native/dynlink_compilerlibs__Language_extension.cmx
.dynlink_compilerlibs.objs/native/dynlink_compilerlibs__Terminfo.cmx
.dynlink_compilerlibs.objs/native/dynlink_compilerlibs__Location.cmx
.dynlink_compilerlibs.objs/native/dynlink_compilerlibs__Global_module.cmx
.dynlink_compilerlibs.objs/native/dynlink_compilerlibs__Ident.cmx
.dynlink_compilerlibs.objs/native/dynlink_compilerlibs__Longident.cmx
.dynlink_compilerlibs.objs/native/dynlink_compilerlibs__Compilation_unit.cmx
Expand Down
1 change: 1 addition & 0 deletions ocaml/tools/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ OCAMLPROF=config.cmo build_path_prefix_map.cmo misc.cmo identifiable.cmo \
debug.cmo terminfo.cmo \
warnings.cmo location.cmo longident.cmo docstrings.cmo \
syntaxerr.cmo ast_helper.cmo \
global_module.cmo \
language_extension_kernel.cmo language_extension.cmo \
jane_syntax_parsing.cmo jane_syntax.cmo \
ast_iterator.cmo zero_alloc_utils.cmo builtin_attributes.cmo \
Expand Down
Loading
Loading