Skip to content

Commit ac462d4

Browse files
authored
flambda-backend: Backport 12508 (#2294)
* Backport 12508. shape-index tests + cms not working * Fix tests format for shape-index * store occurrences as an array instead as of a list * Reimplement cms files * extensions have no shape for now * Update .depend * code review * fix build * restored objinfo * bootstrap * fix build_upstream_closure
1 parent 2485d6c commit ac462d4

Some content is hidden

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

72 files changed

+2720
-721
lines changed

.depend

Lines changed: 60 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -824,7 +824,6 @@ typing/env.cmo : \
824824
typing/predef.cmi \
825825
typing/persistent_env.cmi \
826826
typing/path.cmi \
827-
parsing/parsetree.cmi \
828827
typing/mode.cmi \
829828
utils/misc.cmi \
830829
parsing/longident.cmi \
@@ -851,7 +850,6 @@ typing/env.cmx : \
851850
typing/predef.cmx \
852851
typing/persistent_env.cmx \
853852
typing/path.cmx \
854-
parsing/parsetree.cmi \
855853
typing/mode.cmx \
856854
utils/misc.cmx \
857855
parsing/longident.cmx \
@@ -876,7 +874,6 @@ typing/env.cmi : \
876874
typing/subst.cmi \
877875
typing/shape.cmi \
878876
typing/path.cmi \
879-
parsing/parsetree.cmi \
880877
typing/mode.cmi \
881878
utils/misc.cmi \
882879
parsing/longident.cmi \
@@ -1514,15 +1511,13 @@ typing/rec_check.cmi : \
15141511
typing/typedtree.cmi \
15151512
typing/ident.cmi
15161513
typing/shape.cmo : \
1517-
utils/profile.cmi \
15181514
typing/path.cmi \
15191515
utils/misc.cmi \
15201516
utils/identifiable.cmi \
15211517
typing/ident.cmi \
15221518
utils/compilation_unit.cmi \
15231519
typing/shape.cmi
15241520
typing/shape.cmx : \
1525-
utils/profile.cmx \
15261521
typing/path.cmx \
15271522
utils/misc.cmx \
15281523
utils/identifiable.cmx \
@@ -1534,6 +1529,21 @@ typing/shape.cmi : \
15341529
utils/identifiable.cmi \
15351530
typing/ident.cmi \
15361531
utils/compilation_unit.cmi
1532+
typing/shape_reduce.cmo : \
1533+
typing/shape.cmi \
1534+
utils/local_store.cmi \
1535+
typing/ident.cmi \
1536+
typing/env.cmi \
1537+
typing/shape_reduce.cmi
1538+
typing/shape_reduce.cmx : \
1539+
typing/shape.cmx \
1540+
utils/local_store.cmx \
1541+
typing/ident.cmx \
1542+
typing/env.cmx \
1543+
typing/shape_reduce.cmi
1544+
typing/shape_reduce.cmi : \
1545+
typing/shape.cmi \
1546+
typing/env.cmi
15371547
typing/signature_group.cmo : \
15381548
typing/types.cmi \
15391549
typing/ident.cmi \
@@ -1845,6 +1855,7 @@ typing/typedecl.cmo : \
18451855
typing/typedecl_variance.cmi \
18461856
typing/typedecl_separability.cmi \
18471857
typing/subst.cmi \
1858+
typing/shape.cmi \
18481859
typing/printtyp.cmi \
18491860
typing/primitive.cmi \
18501861
typing/predef.cmi \
@@ -1882,6 +1893,7 @@ typing/typedecl.cmx : \
18821893
typing/typedecl_variance.cmx \
18831894
typing/typedecl_separability.cmx \
18841895
typing/subst.cmx \
1896+
typing/shape.cmx \
18851897
typing/printtyp.cmx \
18861898
typing/primitive.cmx \
18871899
typing/predef.cmx \
@@ -1915,6 +1927,7 @@ typing/typedecl.cmi : \
19151927
typing/typedtree.cmi \
19161928
typing/typedecl_variance.cmi \
19171929
typing/typedecl_separability.cmi \
1930+
typing/shape.cmi \
19181931
typing/path.cmi \
19191932
parsing/parsetree.cmi \
19201933
parsing/longident.cmi \
@@ -2063,6 +2076,7 @@ typing/typemod.cmo : \
20632076
typing/typeclass.cmi \
20642077
typing/subst.cmi \
20652078
typing/signature_group.cmi \
2079+
typing/shape_reduce.cmi \
20662080
typing/shape.cmi \
20672081
utils/profile.cmi \
20682082
typing/printtyp.cmi \
@@ -2106,6 +2120,7 @@ typing/typemod.cmx : \
21062120
typing/typeclass.cmx \
21072121
typing/subst.cmx \
21082122
typing/signature_group.cmx \
2123+
typing/shape_reduce.cmx \
21092124
typing/shape.cmx \
21102125
utils/profile.cmx \
21112126
typing/printtyp.cmx \
@@ -4582,68 +4597,93 @@ file_formats/cmo_format.cmi : \
45824597
typing/ident.cmi \
45834598
utils/compilation_unit.cmi
45844599
file_formats/cms_format.cmo : \
4600+
typing/types.cmi \
4601+
typing/shape_reduce.cmi \
45854602
typing/shape.cmi \
45864603
parsing/parsetree.cmi \
45874604
utils/misc.cmi \
4605+
parsing/longident.cmi \
45884606
parsing/location.cmi \
45894607
parsing/lexer.cmi \
4590-
typing/env.cmi \
45914608
utils/config.cmi \
45924609
utils/compilation_unit.cmi \
4610+
file_formats/cmt_format.cmi \
45934611
utils/clflags.cmi \
45944612
file_formats/cms_format.cmi
45954613
file_formats/cms_format.cmx : \
4614+
typing/types.cmx \
4615+
typing/shape_reduce.cmx \
45964616
typing/shape.cmx \
45974617
parsing/parsetree.cmi \
45984618
utils/misc.cmx \
4619+
parsing/longident.cmx \
45994620
parsing/location.cmx \
46004621
parsing/lexer.cmx \
4601-
typing/env.cmx \
46024622
utils/config.cmx \
46034623
utils/compilation_unit.cmx \
4624+
file_formats/cmt_format.cmx \
46044625
utils/clflags.cmx \
46054626
file_formats/cms_format.cmi
46064627
file_formats/cms_format.cmi : \
4628+
typing/shape_reduce.cmi \
46074629
typing/shape.cmi \
46084630
parsing/parsetree.cmi \
4631+
parsing/longident.cmi \
46094632
parsing/location.cmi \
4610-
utils/compilation_unit.cmi
4633+
utils/compilation_unit.cmi \
4634+
file_formats/cmt_format.cmi
46114635
file_formats/cmt_format.cmo : \
46124636
typing/types.cmi \
46134637
typing/typedtree.cmi \
46144638
typing/tast_mapper.cmi \
4639+
typing/tast_iterator.cmi \
4640+
typing/shape_reduce.cmi \
46154641
typing/shape.cmi \
4642+
typing/predef.cmi \
4643+
typing/path.cmi \
46164644
utils/misc.cmi \
4645+
parsing/longident.cmi \
46174646
parsing/location.cmi \
46184647
utils/load_path.cmi \
46194648
parsing/lexer.cmi \
46204649
utils/import_info.cmi \
4650+
typing/ident.cmi \
46214651
typing/env.cmi \
46224652
utils/config.cmi \
46234653
utils/compilation_unit.cmi \
46244654
file_formats/cmi_format.cmi \
46254655
utils/clflags.cmi \
4656+
typing/btype.cmi \
46264657
file_formats/cmt_format.cmi
46274658
file_formats/cmt_format.cmx : \
46284659
typing/types.cmx \
46294660
typing/typedtree.cmx \
46304661
typing/tast_mapper.cmx \
4662+
typing/tast_iterator.cmx \
4663+
typing/shape_reduce.cmx \
46314664
typing/shape.cmx \
4665+
typing/predef.cmx \
4666+
typing/path.cmx \
46324667
utils/misc.cmx \
4668+
parsing/longident.cmx \
46334669
parsing/location.cmx \
46344670
utils/load_path.cmx \
46354671
parsing/lexer.cmx \
46364672
utils/import_info.cmx \
4673+
typing/ident.cmx \
46374674
typing/env.cmx \
46384675
utils/config.cmx \
46394676
utils/compilation_unit.cmx \
46404677
file_formats/cmi_format.cmx \
46414678
utils/clflags.cmx \
4679+
typing/btype.cmx \
46424680
file_formats/cmt_format.cmi
46434681
file_formats/cmt_format.cmi : \
46444682
typing/types.cmi \
46454683
typing/typedtree.cmi \
4684+
typing/shape_reduce.cmi \
46464685
typing/shape.cmi \
4686+
parsing/longident.cmi \
46474687
parsing/location.cmi \
46484688
utils/load_path.cmi \
46494689
utils/import_info.cmi \
@@ -7259,6 +7299,7 @@ toplevel/byte/topeval.cmo : \
72597299
toplevel/topcommon.cmi \
72607300
bytecomp/symtable.cmi \
72617301
lambda/simplif.cmi \
7302+
typing/shape_reduce.cmi \
72627303
typing/shape.cmi \
72637304
typing/printtyped.cmi \
72647305
typing/printtyp.cmi \
@@ -7295,6 +7336,7 @@ toplevel/byte/topeval.cmx : \
72957336
toplevel/topcommon.cmx \
72967337
bytecomp/symtable.cmx \
72977338
lambda/simplif.cmx \
7339+
typing/shape_reduce.cmx \
72987340
typing/shape.cmx \
72997341
typing/printtyped.cmx \
73007342
typing/printtyp.cmx \
@@ -7401,6 +7443,7 @@ toplevel/native/topeval.cmo : \
74017443
toplevel/topcommon.cmi \
74027444
utils/symbol.cmi \
74037445
lambda/simplif.cmi \
7446+
typing/shape_reduce.cmi \
74047447
typing/shape.cmi \
74057448
typing/printtyped.cmi \
74067449
typing/printtyp.cmi \
@@ -7435,6 +7478,7 @@ toplevel/native/topeval.cmx : \
74357478
toplevel/topcommon.cmx \
74367479
utils/symbol.cmx \
74377480
lambda/simplif.cmx \
7481+
typing/shape_reduce.cmx \
74387482
typing/shape.cmx \
74397483
typing/printtyped.cmx \
74407484
typing/printtyp.cmx \
@@ -7737,11 +7781,15 @@ tools/make_opcodes.cmx : \
77377781
tools/make_opcodes.cmi
77387782
tools/make_opcodes.cmi :
77397783
tools/objinfo.cmo : \
7784+
typing/typedtree.cmi \
77407785
bytecomp/symtable.cmi \
77417786
utils/symbol.cmi \
7787+
typing/shape_reduce.cmi \
77427788
typing/shape.cmi \
77437789
middle_end/printclambda.cmi \
7790+
parsing/pprintast.cmi \
77447791
utils/misc.cmi \
7792+
parsing/location.cmi \
77457793
lambda/lambda.cmi \
77467794
utils/import_info.cmi \
77477795
typing/ident.cmi \
@@ -7757,11 +7805,15 @@ tools/objinfo.cmo : \
77577805
utils/binutils.cmi \
77587806
tools/objinfo.cmi
77597807
tools/objinfo.cmx : \
7808+
typing/typedtree.cmx \
77607809
bytecomp/symtable.cmx \
77617810
utils/symbol.cmx \
7811+
typing/shape_reduce.cmx \
77627812
typing/shape.cmx \
77637813
middle_end/printclambda.cmx \
7814+
parsing/pprintast.cmx \
77647815
utils/misc.cmx \
7816+
parsing/location.cmx \
77657817
lambda/lambda.cmx \
77667818
utils/import_info.cmx \
77677819
typing/ident.cmx \

Changes

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -741,6 +741,12 @@ Some of those changes will benefit all OCaml packages.
741741
bytecode executable (`ocamlc -custom`).
742742
(Antonin Décimo, review by Xavier Leroy)
743743

744+
- #12508 : Add compiler-side support for project-wide occurrences in Merlin, by
745+
generating index tables of all identifier occurrences. This extra data in .cmt
746+
files is only added when the new flag -bin-annot-occurrences is passed.
747+
(Ulysse Gérard, Nathanaëlle Courant, suggestions by Gabriel Scherer and Thomas
748+
Refis, review by Florian Angeletti, Gabriel Scherer and Thomas Refis)
749+
744750
### Build system:
745751

746752
- #11844: Reduce verbosity of `make` logs by printing program invocations in

boot/ocamlc

26.9 KB
Binary file not shown.

compilerlibs/Makefile.compilerlibs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ TYPING = \
9898
file_formats/cmi_format.cmo \
9999
typing/persistent_env.cmo \
100100
typing/env.cmo \
101+
typing/shape_reduce.cmo \
101102
typing/errortrace.cmo \
102103
typing/typedtree.cmo \
103104
typing/signature_group.cmo \

driver/main_args.ml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,13 @@ let mk_binannot_cms f =
4545
"-bin-annot-cms", Arg.Unit f, " Save shapes in <filename>.cms"
4646
;;
4747

48+
let mk_binannot_occurrences f =
49+
"-bin-annot-occurrences", Arg.Unit f,
50+
" Store every occurrence of a bound name in the .cmt file.\n\
51+
This information can be used by external tools to provide\n\
52+
features such as project-wide occurrences. This flag has\n\
53+
no effect in the absence of '-bin-annot'."
54+
4855
let mk_c f =
4956
"-c", Arg.Unit f, " Compile only (do not link)"
5057

@@ -941,6 +948,7 @@ module type Compiler_options = sig
941948
val _as_parameter : unit -> unit
942949
val _binannot : unit -> unit
943950
val _binannot_cms : unit -> unit
951+
val _binannot_occurrences : unit -> unit
944952
val _c : unit -> unit
945953
val _cc : string -> unit
946954
val _cclib : string -> unit
@@ -1140,6 +1148,7 @@ struct
11401148
mk_as_parameter F._as_parameter;
11411149
mk_binannot F._binannot;
11421150
mk_binannot_cms F._binannot_cms;
1151+
mk_binannot_occurrences F._binannot_occurrences;
11431152
mk_c F._c;
11441153
mk_cc F._cc;
11451154
mk_cclib F._cclib;
@@ -1353,6 +1362,7 @@ struct
13531362
mk_as_parameter F._as_parameter;
13541363
mk_binannot F._binannot;
13551364
mk_binannot_cms F._binannot_cms;
1365+
mk_binannot_occurrences F._binannot_occurrences;
13561366
mk_inline_branch_factor F._inline_branch_factor;
13571367
mk_c F._c;
13581368
mk_cc F._cc;
@@ -1921,6 +1931,7 @@ module Default = struct
19211931
let _as_parameter = set as_parameter
19221932
let _binannot = set binary_annotations
19231933
let _binannot_cms = set binary_annotations_cms
1934+
let _binannot_occurrences = set store_occurrences
19241935
let _c = set compile_only
19251936
let _cc s = c_compiler := (Some s)
19261937
let _cclib s = Compenv.defer (ProcessObjects (Misc.rev_split_words s))

driver/main_args.mli

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ module type Compiler_options = sig
8989
val _as_parameter : unit -> unit
9090
val _binannot : unit -> unit
9191
val _binannot_cms : unit -> unit
92+
val _binannot_occurrences : unit -> unit
9293
val _c : unit -> unit
9394
val _cc : string -> unit
9495
val _cclib : string -> unit

dune

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@
8686
jane_syntax ; manual update: mli only files asttypes parsetree
8787

8888
;; TYPING
89-
ident path jkind primitive shape types btype oprint subst predef datarepr
89+
ident path jkind primitive shape shape_reduce types btype oprint subst predef datarepr
9090
cmi_format persistent_env env errortrace mode
9191
typedtree printtyped ctype printtyp includeclass mtype envaux includecore
9292
tast_iterator tast_mapper signature_group cmt_format cms_format untypeast

0 commit comments

Comments
 (0)