[m-rev.] for review: determine more minimal dependency relations
Peter Ross
peter.ross at miscrit.be
Fri Feb 15 03:14:52 AEDT 2002
Hi,
For Fergus or Simon to review.
Note that I can now build the dependencies for a 1000 sub-module
hierarchy where various sub-modules import each other in 37 secs as
opposed to 10 hours under the previous system.
Also note this code uses the relation__write predicate that I submitted
for review in another change.
Also note that this was incredibly painful to debug!
Also note that I have finished noting things.
===================================================================
Estimated hours taken: 16
Branches: main
Determine the minimal relation which captures all the dependencies
between modules. This has the side-effect of not triggering a
performance problem in relation__compose when composing dependency
relations for large sub-module hierarchies.
compiler/modules.m:
The `.*_date' files for modules which contain nested sub-modules
depend on the `.int0' file for that module.
Add code which fixes an XXX left by fjh.
Add some debugging code which outputs the dependency relations in a
format suitable for graphing by the dot utility.
In add_int_deps don't generate a dependency between a parent module
and its children, as a parent must add its own explicit import if
this is true.
Index: modules.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/modules.m,v
retrieving revision 1.215
diff -u -r1.215 modules.m
--- modules.m 8 Feb 2002 02:26:53 -0000 1.215
+++ modules.m 14 Feb 2002 16:00:13 -0000
@@ -1793,7 +1793,7 @@
write_dependency_file(Module, AllDepsSet, MaybeTransOptDeps) -->
{ Module = module_imports(SourceFileName, ModuleName, ParentDeps,
- IntDeps, ImplDeps, IndirectDeps, _InclDeps, FactDeps0,
+ IntDeps, ImplDeps, IndirectDeps, InclDeps, FactDeps0,
ContainsForeignCode, ForeignImports0,
Items, _Error, _Timestamps) },
globals__io_lookup_bool_option(verbose, Verbose),
@@ -1906,6 +1906,8 @@
ILDateFileName),
module_name_to_file_name(ModuleName, ".pic_o", no,
PicObjFileName),
+ module_name_to_file_name(ModuleName, ".int0", no,
+ Int0FileName),
module_name_to_split_c_file_pattern(ModuleName, ".$O",
SplitObjPattern),
io__write_strings(DepStream, ["\n\n",
@@ -1920,6 +1922,13 @@
ILDateFileName, " : ",
SourceFileName
] ),
+ % If the module contains nested sub-modules then `.int0'
+ % file must first be built.
+ ( { InclDeps = [_ | _] } ->
+ io__write_strings(DepStream, [" ", Int0FileName])
+ ;
+ []
+ ),
write_dependencies_list(ParentDeps, ".int0", DepStream),
write_dependencies_list(LongDeps, ".int", DepStream),
write_dependencies_list(ShortDeps, ".int2", DepStream),
@@ -2054,9 +2063,9 @@
% parent modules also depend on the same things as the
% `.date' files for this module, since all the `.date'
% files will get produced by a single mmc command.
- % XXX The same is true for the `.date0' files, but
- % including those dependencies here might result in
- % cyclic dependencies(?).
+ % Similarly for `.date0' files, except these don't
+ % depend on the `.int0' files as this would lead to a
+ % circular dependency.
module_name_to_file_name(ModuleName, ".date", no,
DateFileName),
@@ -2075,6 +2084,15 @@
write_dependencies_list(LongDeps, ".int3", DepStream),
write_dependencies_list(ShortDeps, ".int3", DepStream),
+ io__write_strings(DepStream, ["\n\n", Date0FileName]),
+ write_dependencies_list(ParentDeps, ".date0", DepStream),
+ io__write_strings(DepStream, [
+ " : ",
+ SourceFileName
+ ]),
+ write_dependencies_list(LongDeps, ".int3", DepStream),
+ write_dependencies_list(ShortDeps, ".int3", DepStream),
+
module_name_to_file_name(ModuleName, ".dir", no, DirFileName),
module_name_to_split_c_file_name(ModuleName, 0, ".$O",
SplitCObj0FileName),
@@ -2169,8 +2187,6 @@
[]
),
- module_name_to_file_name(ModuleName, ".int0", no,
- Int0FileName),
module_name_to_file_name(ModuleName, ".int", no,
IntFileName),
module_name_to_file_name(ModuleName, ".int2", no,
@@ -2694,11 +2710,69 @@
%
{ relation__tc(ImplDepsRel, IndirectOptDepsRel) },
+ /*
+ write_relation("Rel", IntDepsRel, TransIntDepsRel, ImplDepsRel,
+ IndirectDepsRel, IndirectOptDepsRel),
+ */
+
generate_dependencies_write_d_files(DepsList,
IntDepsRel, ImplDepsRel, IndirectDepsRel,
IndirectOptDepsRel, TransOptDepsOrdering, DepsMap)
).
+/*
+ % Output the various relations into a file which can be
+ % processed by the dot package to draw the relations.
+:- pred write_relation(string::in, relation(sym_name)::in,
+ relation(sym_name)::in, relation(sym_name)::in,
+ relation(sym_name)::in, relation(sym_name)::in,
+ io__state::di, io__state::uo) is det.
+
+write_relation(FileName, IntDepsRel, TransIntDepsRel,
+ ImplDepsRel, IndirectDepsRel, IndirectOptDepsRel) -->
+ io__open_output(FileName, Result),
+ ( { Result = ok(Stream) } ->
+ write_relation(Stream, "IntDepsRel", IntDepsRel),
+ write_relation(Stream, "TransIntDepsRel", TransIntDepsRel),
+ write_relation(Stream, "ImplDepsRel", ImplDepsRel),
+ write_relation(Stream, "IndirectDepsRel", IndirectDepsRel),
+ write_relation(Stream, "IndirectOptDepsRel",
+ IndirectOptDepsRel)
+ ;
+ { error("unable to open file: " ++ FileName) }
+ ).
+
+:- pred write_relation(io__output_stream::in,
+ string::in, relation(sym_name)::in,
+ io__state::di, io__state::uo) is det.
+
+write_relation(Stream, Name, Relation) -->
+ io__write_string(Stream, "digraph " ++ Name ++ " {\n"),
+ io__write_string(Stream, "label=\"" ++ Name ++ "\";\n"),
+ io__write_string(Stream, "center=true;\n"),
+ relation__write(Relation, write_node(Stream), write_edge(Stream)),
+ io__write_string(Stream, "}\n").
+
+:- pred write_node(io__output_stream::in, sym_name::in,
+ io__state::di, io__state::uo) is det.
+
+write_node(Stream, Node) -->
+ { sym_name_to_string(Node, "__", NodeStr) },
+ io__write_string(Stream, NodeStr),
+ io__write_string(Stream, ";\n").
+
+:- pred write_edge(io__output_stream::in, sym_name::in, sym_name::in,
+ io__state::di, io__state::uo) is det.
+
+write_edge(Stream, A, B) -->
+ { sym_name_to_string(A, "__", AStr) },
+ { sym_name_to_string(B, "__", BStr) },
+ io__write_string(Stream, AStr),
+ io__write_string(Stream, " -> "),
+ io__write_string(Stream, BStr),
+ io__write_string(Stream, ";\n").
+*/
+
:- pred maybe_output_module_order(module_name::in, list(set(module_name))::in,
io__state::di, io__state::uo) is det.
maybe_output_module_order(Module, DepsOrdering) -->
@@ -2936,8 +3010,7 @@
add_int_deps(ModuleKey, ModuleImports, Rel0, Rel) :-
AddDep = add_dep(ModuleKey),
list__foldl(AddDep, ModuleImports ^ parent_deps, Rel0, Rel1),
- list__foldl(AddDep, ModuleImports ^ int_deps, Rel1, Rel2),
- list__foldl(AddDep, ModuleImports ^ public_children, Rel2, Rel).
+ list__foldl(AddDep, ModuleImports ^ int_deps, Rel1, Rel).
% add direct implementation dependencies for a module to the
% impl. deps relation
--------------------------------------------------------------------------
mercury-reviews mailing list
post: mercury-reviews at cs.mu.oz.au
administrative address: owner-mercury-reviews at cs.mu.oz.au
unsubscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: unsubscribe
subscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------
More information about the reviews
mailing list