Branches: main
Make `mmc --make' support submodules when compiling to Java. Java files must
be placed in subdirectories named after the package that each class belongs to.
compiler/java_names.m
compiler/parse_tree.m:
compiler/notes/compiler_design.html:
Add a new module in the parse_tree package to contain code related to
name mangling for Java.
compiler/mlds.m:
compiler/java_util.m:
Move predicates to java_names.m.
compiler/mlds_to_java.m:
Move predicates to java_names.m.
Delete an unused predicate.
compiler/file_names.m:
Rename `erlang_module_name' as it is now also used for Java.
Make `module_name_to_file_name_general' return file names for `.java'
and `.class' files that include package subdirectories.
compiler/make.program_target.m:
Clean `.class' files on make clean.
compiler/mlds_to_il.m:
mdbcomp/prim_data.m:
Move `sym_name_to_list' to mdbcomp.prim_data.
compiler/compile_target_code.m:
compiler/elds_to_erlang.m:
Conform to changes.
library/Mmakefile:
Delete hacks that work around Mercury not writing submodule .java files
in subdirectories.
Branches: main
With mmc --make, invoke `javac' once only for a linked target, passing it all
the .java files which need compiling. This is how the Java compiler is meant
to be used, and is much quicker.
compiler/make.program_target.m:
As above.
Clear cached timestamps of all `.class' files afterwards.
compiler/compile_target_code.m:
Change `compile_java_file' to accept multiple Java files.
compiler/make.dependencies.m:
Fix a bug. `.class' files should depend on the `.java' file only.
compiler/make.module_target.m:
compiler/mercury_compile.m:
Conform to changes.
Branches: main
Make `mmc --make' work for Java grade.
compiler/make.dependencies.m:
compiler/make.m:
compiler/make.module_target.m:
compiler/make.program_target.m:
compiler/make.util.m:
Make `mmc --make' know to generate `.class' files.
compiler/compile_target_code.m:
Pass "-sourcepath Mercury/javas" to javac when using subdirectories.
compiler/module_cmds.m:
Make the shell script we generate to invoke `java' pass command line
arguments through to the user program. `exec' the java process.
library/Mmakefile:
Use $(ALL_JAVACFLAGS) when compiling standard library modules so
$(EXTRA_JAVACFLAGS) has its effect.
Branches: main
Add mmc --make --track-flags:
--track-flags
With `--make', keep track of the options used when compiling
each module. If an option for a module is added or removed,
`mmc --make' will then know to recompile the module even if the
timestamp on the file itself has not changed. Warning and
verbosity options are not tracked.
The motivation was to be able to set the execution trace level on selected
modules by editing Mercury.options, without needing to manually touch the
affected files afterwards to force recompilation. It's probably useful for
anyone that's worried about consistent builds.
The implementation works by recording a hash of the option table which is the
product of the options set for each particular module in .track_flags files,
not a hash of the actual options passed by the user, which might be reordered
or redundant, etc. Hashes are used as they are much quicker to compare and
take less space (the full options tables are quite big).
compiler/options.m:
Add the new option.
Add a predicate to return options that shouldn't be tracked
(e.g. adding -v shouldn't cause everything to recompile).
compiler/make.m:
When --track-flags is enabled, write `.track_flags' files which need
to be changed.
compiler/make.dependencies.m:
When --track-flags is enabled, make compiled code files depend on the
`.track_flags' files.
compiler/make.program_target.m:
Delete .track_flags files on realclean.
compiler/make.module_target.m:
compiler/make.util.m:
Conform to changes above.
compiler/libs.m:
compiler/md4.m:
Add an implementation of the MD4 digest function to libs.
doc/user_guide.texi:
NEWS:
Document the new option.
Recommend `mmc --make' instead of `mmake' in the user guide.
library/term_io.m:
Avoid unnecessary memory allocation in should_atom_be_quoted.
Branches: main
Replace the implementations of (version) hash tables by separate chaining hash
tables. The old open addressing scheme was broken in the presence of deletes.
Fixes bug #68.
library/hash_table.m:
library/version_hash_table.m:
As above.
We no longer use double hashing in case of a hash collision, so hash
predicates only need to return one value now.
Add fold with predicate arguments.
library/array.m:
Add array.foldl for a predicate argument.
Add array.foldl2 with a unique state pair.
library/version_array.m:
Add version_array.foldl for a predicate argument.
compiler/make.m:
compiler/make.program_target.m:
compiler/make.util.m:
library/robdd.m:
Conform to change in hashing predicates.
deep_profiler/dense_bitset.m:
Add module qualifier to avoid ambiguity.
tests/hard_coded/Mmakefile:
tests/hard_coded/hash_table_delete.exp:
tests/hard_coded/hash_table_delete.m:
tests/hard_coded/hash_table_test.exp:
tests/hard_coded/hash_table_test.m:
tests/hard_coded/version_hash_table_delete.exp:
tests/hard_coded/version_hash_table_delete.m:
tests/hard_coded/version_hash_table_test2.exp:
tests/hard_coded/version_hash_table_test2.m:
Add new test cases.
tests/hard_coded/hash_bug.m:
tests/hard_coded/hash_init_bug.m:
tests/hard_coded/version_hash_table_test.m:
Conform to change in hashing predicates.
NEWS:
Document additions.
compiler/file_util.m:
Quote the directory passed to the C compiler's
-install-name option in case it contains spaces.
compiler/make.program_target.m:
Update a comment.
Estimated hours taken: 1
Branches: main
Add a mechanism that allows extra C header files to be installed as part
of a Mercury library, in the same location as the header files generated
by the Mercury compiler. This is useful when writing Mercury bindings
to C++ libraries since these often require an interface from C++ to C to
be written (at least where one does not already exist) and this usually
involves one or more header files that are then referenced from foreign_decl
pragmas on the Mercury side of things.
compiler/options.m:
Add a new option, --extra-library-header, that specifies extra
header files to install.
compiler/make.program_target.m:
When installing a library installing any extra header files.
doc/user_guide.texi:
Document the new option.
Branches: main
Add a caching feature for `mmc --make' so as to avoid reparsing the same
`.analysis' files repeatedly when many modules in the program or library
import similar sets of modules.
An `.analysis_cache' file contains a binary representation of the parsed
information in its corresponding `.analysis' file. These can be faster to
load, under certain conditions. Cache files are stored in
`Mercury/analysis_cache' or `Mercury/<grade>/<arch>/Mercury/analysis_cache'
for the duration of a single make target. Afterwards the directory is
deleted. This avoids stale cache files lying around which are incompatible
between different versions of the compiler, host platform, etc.
compiler/libs.m:
compiler/pickle.m:
Add a module in libs to un/serialise arbitrary data structures.
compiler/options.m:
Add `--analysis-file-cache' and `--analysis-file-cache-dir <dir>'
(internal option).
compiler/analysis.file.m:
Read and write analysis cache files if the cache directory is set.
Cache files are written after `.analysis' files are written (if
changed) or after an `.analysis' file is read (if it didn't exist).
compiler/make.program_target.m:
For certain targets, set up the analysis cache directory before
running the build procedure, and remove it afterwards.
compiler/module_cmds.m:
Add a version of update_interface that returns whether the
interface file changed.
doc/user_guide.texi:
Add commented out documentation for `--analysis-file-cache'.
Estimated hours taken: 16
Branches: main
The file modules.m contains lots of different kinds of functionality.
While much of it belongs together, much of it does not. This diff moves
most of the functionality that does not belong with the rest to several
new modules:
libs.file_util
parse_tree.deps_map
parse_tree.file_names
parse_tree.module_cmds
parse_tree.module_imports
parse_tree.read_module
parse_tree.write_deps_file
To make them coherent, move some predicates from hlds.passes_aux,
parse_tree.prog_io and parse_tree.prog_out to the new modules, making them
more accessible, reducing the required access from the hlds package to
parse_tree, or from the parse_tree package to libs.
In the same spirit, this diff also moves some simple predicates and functions
dealing with sym_names from prog_util.m to mdbcomp/prim_data.m. This allows
several modules to avoid depending on parse_tree.prog_util.
Rename some of the moved predicates and function symbols where this avoids
ambiguity. (There were several that differed from other predicates or function
symbols only in arity.)
Replace several uses of bools with purpose-specific types. This makes some
of the code significantly easier to read.
This diff moves modules.m from being by far the largest module, to being
only the seventh largest, from 8900+ lines to just 4200+. It also reduces
the number of modules that import parse_tree.modules considerably; most
modules that imported it now import only one or two of the new modules instead.
Despite the size of the diff, there should be no algorithmic changes.
compiler/modules.m:
compiler/passes_aux.m:
compiler/prog_io.m:
compiler/prog_out.m:
Delete the moved functionality.
compiler/file_util.m:
New module in the libs package. Its predicates search for files
and do simple error or progress reporting.
compiler/file_names.m:
New module in the parse_tree package. It contains predicates for
converting module names to file names.
compiler/module_cmds.m:
New module in the parse_tree package. Its predicates handle the
commands for manipulating interface files of various kinds.
compiler/module_import.m:
New module in the parse_tree package. It contains the module_imports
type and its access predicates, and the predicates that compute
various sorts of direct dependencies (those caused by imports)
between modules.
compiler/deps_map.m:
New module in the parse_tree package. It contains the data structure
for recording indirect dependencies between modules, and the predicates
for creating it.
compiler/read_module.m:
New module in the parse_tree package. Its job is reading in modules,
both human-written and machine-written (such as interface and
optimization files).
compiler/write_deps_file.m:
New module in the parse_tree package. Its job is writing out
makefile fragments.
compiler/libs.m:
compiler/parse_tree.m:
Include the new modules.
compiler/notes/compiler_design.m:
Document the new modules.
mdbcomp/prim_data.m:
compiler/prog_util.m:
Move the predicates that operate on nothing but sym_names from
prog_util to prim_data.
Move get_ancestors from modules to prim_data.
compiler/prog_item.m:
Move stuff that looks for foreign code in a list of items here from
modules.m.
compiler/source_file_map.m:
Note why this module needs to be in the parse_tree package.
compiler/add_pred.m:
compiler/add_special_pred.m:
compiler/analysis.file.m:
compiler/analysis.m:
compiler/assertion.m:
compiler/check_typeclass.m:
compiler/compile_target_code.m:
compiler/cse_detection.m:
compiler/det_analysis.m:
compiler/elds_to_erlang.m:
compiler/exception_analysis.m:
compiler/export.m:
compiler/fact_table.m:
compiler/higher_order.m:
compiler/hlds_module.m:
compiler/hlds_pred.m:
compiler/intermod.m:
compiler/llds_out.m:
compiler/make.dependencies.m:
compiler/make.m:
compiler/make.module_dep_file.m:
compiler/make.module_target.m:
compiler/make.program_target.m:
compiler/make.util.m:
compiler/make_hlds_passes.m:
compiler/maybe_mlds_to_gcc.pp:
compiler/mercury_compile.m:
compiler/mlds.m:
compiler/mlds_to_c.m:
compiler/mlds_to_gcc.m:
compiler/mlds_to_ilasm.m:
compiler/mlds_to_java.m:
compiler/mmc_analysis.m:
compiler/mode_constraints.m:
compiler/mode_debug.m:
compiler/modes.m:
compiler/module_qual.m:
compiler/optimize.m:
compiler/passes_aux.m:
compiler/proc_gen.m:
compiler/prog_foreign.m:
compiler/prog_io.m:
compiler/prog_io_util.m:
compiler/prog_mutable.m:
compiler/prog_out.m:
compiler/pseudo_type_info.m:
compiler/purity.m:
compiler/recompilation.check.m:
compiler/recompilation.usage.m:
compiler/simplify.m:
compiler/structure_reuse.analysis.m:
compiler/structure_reuse.direct.detect_garbage.m:
compiler/structure_reuse.direct.m:
compiler/structure_sharing.analysis.m:
compiler/tabling_analysis.m:
compiler/term_constr_main.m:
compiler/termination.m:
compiler/trailing_analysis.m:
compiler/trans_opt.m:
compiler/type_util.m:
compiler/typecheck.m:
compiler/typecheck_info.m:
compiler/unify_proc.m:
compiler/unused_args.m:
compiler/unused_imports.m:
compiler/xml_documentation.m:
Minor changes to conform to the changes above.
Branches: main
Restore mmc --make speedup change. The abort was due to an off-by-one bug
in version_hash_table.fold, now fixed.
compiler/make.dependencies.m:
compiler/make.m:
compiler/make.module_target.m:
compiler/make.program_target.m:
compiler/make.util.m:
As above.
version_hash_table.delete was also found to be buggy. Until it is
fixed, don't use it in a spot.
Branches: main
Revert `mmc --make' speedup changes. They were causing a compiler aborts when
installing libgrade libraries.
compiler/make.dependencies.m:
compiler/make.m:
compiler/make.module_target.m:
compiler/make.program_target.m:
compiler/make.util.m:
As above.
Estimated hours taken: 15
Branches: main
Speed up dependency computation in `mmc --make'. It was spending the majority
of its time taking unions of sets. Therefore change to a set representation
which is fast for unions, sparse_bitset. To make use of bitsets, maintain a
mapping between module_names and integers, and dependency_files and integers.
Use version_hash_tables and version_arrays to hold the forward and reverse
mappings. (We don't really need version types.)
Also cache the results of `non_intermod_direct_imports',
`find_module_foreign_imports' and `get_file_name'.
In one workspace, the time for `mmc --make' to check that all the .c files in
the `compiler' directory were up-to-date dropped from ~120 seconds to ~20
seconds after these changes.
compiler/make.m:
Add fields to the `make_info' structure to hold the module_name- and
dependency_file-to-index mappings.
Change the dependency_status map from a tree234 map to a
version_hash_table.
Add fields to cache results for `get_file_name' and
`non_intermod_direct_imports'.
compiler/make.dependencies.m:
Add the equivalence type `deps_set(T)' to make it easier to try
different set representations in the future. Change the set
representation as above.
Add procedures to convert between indices and the real values, and
index sets and the real sets.
Conform to the data representation changes.
Add caching to `non_intermod_direct_imports' and
`find_module_foreign_imports'.
Replace two generate-and-test sites with deterministic code.
Make `deps_result' a discriminated union. Delete
the `transitive_deps_result' type which is not useful.
compiler/make.util.m:
Add hash functions for `module_name' and `dependency_file' values.
Add caching to `get_file_name' (when Search = yes).
Delete an unused predicate.
compiler/make.module_target.m:
compiler/make.program_target.m:
Conform to changes.
Minor cleanups.
Branches: main
compiler/make.program_target.m:
Don't try to build `.analysis' files in parallel with `mmc --make'.
It doesn't and can't work without more extensive changes.
Branches: main
The `--intermodule-analysis' option was broken in that touching a `.m' file
would cause its `.analysis' file to be remade (correct) but then all the
target code files which depend on that `.analysis' file would be remade,
even if the `.analysis' file should be unchanged.
Fix that by making analysis files work like other interface files: the
timestamp on the `.analysis' file reflects the last time it was changed, and
the `.analysis_date' file reflects the last time the module was analysed.
To that end we need to move the module status out of the `.analysis' file into
a corresponding `.analysis_status' file. Then analysing other modules will
only touch the `.analysis_status' file. `.analysis_status' are not installed.
compiler/analysis.m:
compiler/analysis.file.m:
Separate predicates for reading/writing the module status from the
module analysis results proper.
Use the usual technique of writing analysis results to `.analysis.tmp'
and only updating the `.analysis' file if its changed.
Write analysis results for a single function-id in sorted order to
remove spurious differences.
Use some standard interface file handling predicates.
compiler/make.util.m:
Simplify the special treatment of timestamps for `.analysis' files.
compiler/make.module_target.m:
compiler/make.program_target.m:
Conform to interface changes.
Estimated hours taken: 4
Branches: main
Add a check to `mmc --make' that causes it to check that any libraries
(including the standard library) required for building an executable or
library target are installed and accessible in the compilation grade. Emit an
error message where they are not. (The compiler's current behaviour varies
from reporting .mih files are missing through to linker errors.)
The check is implemented by searching for a library's .init file, which works
since every library has a .init file and the .init file is grade dependent.
The check is currently only performed when compiling in a C grade.
compiler/options.m:
Add a new option `--libgrade-install-check' to control the new check.
compiler/handle_options.m:
Only enable --libgrade-intall-check if --make is enabled.
compiler/make.program_target.m:
Implement the new check.
When building a linked target, i.e. an executable or library,
first check that all required libraries are available in the
compilation grade.
doc/user_guide.texi:
Document the new option.
Branches: main
Make the structure sharing analysis capable of using the intermodule analysis
framework.
This requires changes to the analysis framework. Structure sharing answer
patterns need information from the module_info and proc_info in order to be
compared. In Simon Taylor's original analysis framework implementation, this
would have been provided for by a `FuncInfo' parameter in the `partial_order'
typeclass. I removed it two years ago as it was causing difficulties which
couldn't be solved cleanly while the analysis framework was not specific to
the Mercury compiler. Also, there were no analyses at the time which needed
FuncInfos. Now that we do require it, and the analysis framework has been
made Mercury specific, we can restore the `FuncInfo' parameter.
Also make some more simplifications to the analysis framework.
compiler/analysis.m:
compiler/analysis.file.m:
Remove the `module_id' type and replace occurrences by `module_name'.
Remove "extra info" facilities. They were intended for storing
information needed by intermodule inlining and higher order
specialisation but now that information is in `.opt' files, even
when using `--intermodule-analysis'.
Change `func_id' from a string to a structured type so we can extract
its components easily.
Add a message argument to the `invalid_analysis_file' functor so when
we throw an exception due to being unable to parse a `.analysis'
we get a meaningful message.
Change the `.analysis' file format to account for the changes to
`module_id' and `func_id'. Bump the file version number.
Add a `FuncInfo' parameter to the `partial_order' typeclass, as
explained above.
Add a `no_func_info' dummy type.
Add a `get_func_info' method to the `analysis' framework. When
updating the analysis files after analysing a module, we need to be
able to materialise FuncInfos for each procedure in order to compare
its call or answer patterns. This is what couldn't be added cleanly
while the analysis framework was not specific to the Mercury compiler.
compiler/structure_sharing.analysis.m:
Make the structure sharing analysis capable of using the analysis
framework, i.e. use imported answers from the analysis registry,
record new answers, dependencies and requests, and keeping track of
the optimality of results during analysis.
compiler/structure_sharing.domain.m:
Add `sharing_as_and_status' to pair `sharing_as' with an
`analysis_status'.
Make `sharing_as_table' record the `analysis_status' alongside a
sharing domain. Update access predicates.
Move `sharing_as' into the interface section as it is needed by
structure_sharing.m to convert between `sharing_as' and
`structure_sharing_answer' values for the analysis framework.
When we can't look up the sharing result for an `:- external'
predicate, that should not be a sign that the analysis is non-optimal
since we can't get a better result by reanalysis.
Make special predicates be approximated by `bottom' sharing as we know
they don't introduce sharing.
Avoid an assertion failure in removing subsumed sharing pairs from a
sharing set.
compiler/ctgc.util.m:
Make `pred_requires_no_analysis' not succeed on special predicates
(unify, compare, index, init) which causes the analysis to assume all
possible sharing between its arguments, whereas we know that those
predicates don't introduce any sharing.
Also make `pred_requires_no_analysis' not succeed on `:- external'
predicates.
compiler/ctgc.selector.m:
Make type_on_path_2 fail instead of aborting if asked to select a
subtype which turns out to be existentially typed.
compiler/structure_reuse.direct.m:
Don't run direct structure reuse on compiler generated special
predicates. We need to handle them specifically now due to the change
to `pred_requires_no_analysis'.
compiler/structure_reuse.indirect.m:
Don't run indirect structure reuse on compiler generated special
predicates, as for the direct reuse pass.
Conform to change to `top_feedback'.
Change a semidet function to a predicate.
compiler/hlds_pred.m:
compiler/hlds_out.m:
Change `structure_sharing_info' to associate an analysis status with
the structure sharing domain of a procedure (if any). Add a type
`structure_sharing_domain_and_status' for this.
compiler/prog_data.m:
Make `top_feedback' a structured type instead of a string. Divide the
reasons that we might approximate structure sharing by `top' into
different classes.
compiler/exception_analysis.m:
compiler/tabling_analysis.m:
compiler/trailing_analysis.m:
Conform to analysis framework changes.
compiler/unused_args.m:
Conform to analysis framework changes.
Move the predicate arity from the call pattern into a FuncInfo,
where it belongs.
Bump the analysis version number.
compiler/prog_ctgc.m:
compiler/structure_reuse.direct.detect_garbage.m:
Conform to change to `top_feedback'.
compiler/make.dependencies.m:
compiler/make.module_target.m:
compiler/make.program_target.m:
compiler/make.util.m:
Conform to removal of `module_id' type.
compiler/mercury_compile.m:
Call mm_tabling_analysis, structure sharing and structure reuse passes
when making `.analysis' files.
Conform to removal of `module_id' type.
compiler/mmc_analysis.m:
Add structure sharing to the list of analyses.
Add `func_id_to_ppid'.
Conform to analysis framework changes.
compiler/ctgc.fixpoint_table.m:
Replace a semidet function by a predicate.
Branches: main
Support `.opt' files with `--intermodule-analysis'. Unlike with
`--intermodule-optimisation', in this case `.opt' files only contain the
initial information produced by `intermod.m' and not later analyses which
should instead use the analysis framework. This makes intermodule inlining,
etc. work with `--intermodule-analysis'. Also, the CTGC analyses will require
the definitions of abstract types from imported modules.
compiler/mercury_compile.m:
Read and make `.opt' files with `--intermodule-analysis'.
Don't run exception analysis, etc. when producing `.opt' files for
`--intermodule-analysis'.
Eliminate unnecessary clauses from `.opt' files to speed up
compilation with `--intermodule-analysis', as we do for
`--intermodule-optimisation'.
compiler/make.dependencies.m:
compiler/make.program_target.m:
Account for `.opt' files being made with `--intermodule-analysis'
in `mmc --make'.
Make `.analysis' files depend on `.opt' files.
compiler/globals.m:
Add a predicate to return whether either intermodule optimisation
system is enabled.
compiler/post_typecheck.m:
Avoid spurious warning about duplicate mode declarations when using
`--intermodule-analysis' as they may be read from `.opt' files (same
as for `--intermodule-optimisation').
compiler/exception_analysis.m:
compiler/structure_sharing.analysis.m:
compiler/tabling_analysis.m:
compiler/trailing_analysis.m:
compiler/unused_args.m:
Don't write the analysis results into `.opt' files.
compiler/term_constr_main.m:
compiler/termination.m:
Add todos for when these analyses are updated to support
`--intermodule-analysis'.
compiler/trans_opt.m:
Fix a comment.
Estimated hours taken: 20
Branches: main
Add a new compiler option. --inform-ite-instead-of-switch. If this is enabled,
the compiler will generate informational messages about if-then-elses that
it thinks should be converted to switches for the sake of program reliability.
Act on the output generated by this option.
compiler/simplify.m:
Implement the new option.
Fix an old bug that could cause us to generate warnings about code
that was OK in one duplicated copy but not in another (where a switch
arm's code is duplicated due to the case being selected for more than
one cons_id).
compiler/options.m:
Add the new option.
Add a way to test for the bug fix in simplify.
doc/user_guide.texi:
Document the new option.
NEWS:
Mention the new option.
library/*.m:
mdbcomp/*.m:
browser/*.m:
compiler/*.m:
deep_profiler/*.m:
Convert if-then-elses to switches at most of the sites suggested by the
new option. At the remaining sites, switching to switches would have
nontrivial downsides. This typically happens with the switched-on type
has many functors, and we treat one or two specially (e.g. cons/2 in
the cons_id type).
Perform misc cleanups in the vicinity of the if-then-else to switch
conversions.
In a few cases, improve the error messages generated.
compiler/accumulator.m:
compiler/hlds_goal.m:
(Rename and) move insts for particular kinds of goal from
accumulator.m to hlds_goal.m, to allow them to be used in other
modules. Using these insts allowed us to eliminate some if-then-elses
entirely.
compiler/exprn_aux.m:
Instead of fixing some if-then-elses, delete the predicates containing
them, since they aren't used, and (as pointed out by the new option)
would need considerable other fixing if they were ever needed again.
compiler/lp_rational.m:
Add prefixes to the names of the function symbols on some types,
since without those prefixes, it was hard to figure out what type
the switch corresponding to an old if-then-else was switching on.
tests/invalid/reserve_tag.err_exp:
Expect a new, improved error message.
Estimated hours taken: 12
Branches: main
library/digraph.m:
New module for directed graphs. This is essentially the relation
module but with more consistent terminology, and with argument
ordering that suits state variables. Other differences with the
relation module:
- The digraph_key type has a phantom type parameter, which helps to
ensure that keys from one digraph are not used with another digraph.
- Exports a version of digraph.reduced which also returns the mapping
between the original digraph keys and the new ones.
- The implementation of compose/3 doesn't try to use the "domain" and
"range" of the graphs (which is meaningless in the relation module
anyway).
- New, more efficient algorithm for is_dag/1. Correctness proof is
documented.
- components/2 uses a more efficient data representation, and avoids
some intermediate data structures.
- reduced/{2,3} avoids some intermediate data structures.
- tc/2 avoids some intermediate data structures.
library/library.m:
Add the new module.
library/relation.m:
Document that this module is deprecated in favour of digraph.
Flag relation.init/{0,1} as obsolete (it would be better to flag
the entire module, or the relation/1 type as obsolete, but Mercury
does not support this).
NEWS:
Mention that the new module supersedes relation.m and svrelation.m.
compiler/*.m:
profiler/*.m:
Use the digraph module rather than the relation module.
Estimated hours taken: 2
Branches: main
In parallel mmc --make, disable the effect of `--rebuild' during the second
sequential pass over a list of target files (when we are just reading in file
timestamps), otherwise all the target files will be rebuilt a second time.
compiler/make.util.m:
Make the fix above.
compiler/make.m:
compiler/make.program_target.m:
compiler/make.module_dep_file.m:
Rename the field `rebuild_dependencies' in the `make_info' type to
`rebuild_module_deps' to avoid confusion with the `--rebuild' option.
Give it a distinct type instead of bool.
Rename `RebuildDeps' everywhere to `RebuildModuleDeps'.
Estimated hours taken: 3
Branches: main
Removed support for Managed C++ as a foreign language for the IL backend.
This is being removed for the following reasons:
* It is only supported by Microsoft, making it harder to use code
using it with other CIL platforms (e.g. Mono).
* It is not used in any of the standard library (only C# and IL are used).
* Removing it will simplify the dependencies and the build process.
* Microsoft have deprecated it in favour of C++/CLI.
NEWS:
Mentioned the change.
aclocal.m4:
Remove checks for the Microsoft.NET C++ compiler.
compiler/globals.m:
Delete Managed C++ from the set of supported languages.
compiler/mlds_to_managed.m:
Remove support for Managed C++ code generation.
compiler/*.m:
Remove all references to Managed C++.
runtime/Mmakefile:
runtime/mercury_mcpp.h:
Remove the Managed C++ part of the Mercury runtime.
runtime/mercury_il.il:
runtime/mercury_typeclass_info.h:
runtime/mercury_type_info.h:
Remove all references to Managed C++, including instructions to keep
certain parts in sync with Managed C++ part of the runtime.
doc/reference_manual.texi:
Remove the Managed C++ sections in the Foreign Language Interface
chapter.
doc/user_guide.texi:
Remove the documentation of Managed C++ related flags.
library/Mmakefile:
Remove Managed C++ flag settings.
library/io.m:
Remove commented out Managed C++ code.
library/list.m:
Change a comment referring to Managed C++ to refer to C# instead.
scripts/Mmake.rules:
scripts/Mmake.vars.in:
Remove all rules and variables for Managed C++ from mmake.
tests/hard_coded/foreign_import_module.m:
tests/hard_coded/foreign_import_module_2.m:
tests/hard_coded/foreign_proc_make.m:
tests/hard_coded/redoip_clobber.m:
Replace Managed C++ code with C# code in the relevant tests.
Estimated hours taken: 4
Branches: main
Add support for header files to the Erlang back-end. These have the extension
.hrl. Code from :- pragma foreign_decls are put into the modules's .hrl file,
unless it has the `local' attribute. Header files of imported modules
are automatically included in the generated Erlang source files.
compiler/elds.m:
compiler/erl_code_gen.m:
Record imported modules in the ELDS structure.
compiler/elds_to_erlang.m:
Generate .hrl files when generating .erl files.
Add -include("<module>.erl"). directives in generated .erl files,
for each imported module.
compiler/options.m:
Add option --erlang-include-directory <dir> which specifies
where to search for .hrl files.
compiler/handle_options.m:
Add --erlang-include-directory <dir>/lib/<grade>/inc
to search for .hrl files for installed libraries.
Add --erlang-include-directory <pwd>/Mercury/hrls
or <pwd>/Mercury/<grade>/Mercury/hrls
to search for .hrl files for the current directory.
compiler/compile_target_code.m:
Pass -I<dir> options to the Erlang compiler for each
--erlang-include-directory <dir> option.
compiler/make.dependencies.m:
compiler/make.m:
compiler/make.module_target.m:
compiler/make.program_target.m:
compiler/make.util.m:
compiler/modules.m:
Update `mmc --make' to build, install and clean .hrl files.
Unrelated fix: mark _init.erl and _init.beam files as grade dependent.
doc/user_guide.texi:
Document --erlang-include-directory and --erlang-native-code (which was
missed previously).
library/io.m:
Add `local' attributes to foreign_decls which shouldn't be exported.
library/erlang_rtti_implementation.m:
Add "ML_" prefixes to macros which will be exported now.
Estimated hours taken: 12
Branches: main
Support :- initialise and :- finalise predicates in the Erlang backend.
compiler/compile_target_code.m:
Refactor the code relating to running mkinit to generate .init and
_init.c files, and compiling _init.c files.
Generalise the code so that it can call mkinit_erl with the right
options.
compiler/dead_proc_elim.m:
Add initialisation and finalisation predicates to the queue at the
start of the pass so that they won't be eliminated. For the C
backends we implicitly :- foreign_export init and final preds so they
would never be eliminated, but we don't do that in the Erlang
backend.
compiler/elds.m:
Extend the ELDS to hold pred_proc_ids of init/final preds.
compiler/erl_code_gen.m:
compiler/mercury_compile.m:
Conform to change in ELDS.
compiler/elds_to_erlang.m:
Output mercury__required_init and mercury__required_final functions
which call user initialisation and finalisation predicates, if any.
Write out -export annotations for those functions.
Write out REQUIRED_INIT and REQUIRED_FINAL directives for those
functions.
compiler/hlds_module.m:
compiler/make_hlds_passes.m:
Remember the arity of init/final preds in the HLDS, not just the
sym_name.
Add predicates to return the pred_proc_ids of init/final preds.
Delete module_info_user_init_pred_c_name and
module_info_user_final_pred_c_name as they are unused.
compiler/make.program_target.m:
Call make_erlang_program_init_file and make_erlang_library_init_file
when building an Erlang executable or library, respectively.
Install a .init file when installing an Erlang library.
Conform to changes in compile_target_code.m.
compiler/modules.m:
In module_name_to_file_name, treat extensions specially if they end
".erl" and ".beam", not only if they are exactly those strings. This
is because we may pass "_init.erl" or "_init.beam" as the extension.
compiler/options.m:
Add an option `--mkinit-erl-command'.
util/Mmakefile:
util/.cvsignore:
util/mkinit_erl.c:
Add `mkinit_erl' program which is a modified version of `mkinit'.
util/mkinit.c:
util/mkinit_common.c:
util/mkinit_common.h:
Factor out code common to mkinit and mkinit_erl into mkinit_common.c
and mkinit_common.h.
tests/hard_coded/Mmakefile:
Fix misspellings of "MERCURY_SUPPRESS_STACK_TRACE".
tests/hard_coded/impure_init_and_final.m:
Add Erlang foreign proc.
Estimated hours taken: 25
Branches: main
Add support for :- external procedures to the Erlang backend.
Add Erlang support to mmc --make.
compiler/elds.m:
Extend the ELDS for definitions of external procedures.
compiler/elds_to_erlang.m:
Move the logic for mapping a module name to a file name into
module_name_to_file_name, as it is needed for mmc --make as well.
Similarly move erlang_module_name to modules.m.
Output export annotations for :- external procedures which are
exported.
Conform to changes in the ELDS.
compiler/erl_call_gen.m:
Don't generate assignment statements between variables of dummy types.
compiler/erl_code_gen.m:
Generate skeleton ELDS definitions for external procedures.
Fix more cases where success expressions could be inserted after
`erroneous' goals. The Erlang compiler would complain about unbound
variables appearing in success expressions following erroneous goals,
because it doesn't know that the erroneous goal would throw an
exception.
Handle some special cases with `erroneous' and `failure' goals where we
used to generate code that the Erlang compiler would complain about
references to unbound variables, or variables being bound in one branch
of a conditional statement but not another, etc.
- handle a special case where the goal inside a commit scope has
determinism `failure', i.e. it would never actually commit;
- handle a special case where the condition of an if-then-else is
`erroneous', so the Then branch can't be reached;
- handle a special case where a disjunct has determinism `failure',
so later disjuncts will always be evaluated.
Generate code for promise_solutions and exist_quant scopes.
Wrap large success expressions in closures instead of duplicating them
into each disjunct, in the same way that we do for switches.
Disable duplicating of small success expressions into branches of
switches and disjunctions for now, as the implmentation is buggy.
compiler/handle_options.m:
Remove the LLDS and MLDS options from the grade_component_table entry
for the "erlang" grade. They caused compute_grade to return "none" if
only --target erlang was used (because --target erlang didn't imply the
same set of meaningless options).
compiler/hlds_pred.m:
Fix the implementations of `status_is_exported' and
`status_defined_in_this_module' for external procedures.
compiler/compile_target_code.m:
compiler/make.dependencies.m:
compiler/make.m:
compiler/make.module_target.m:
compiler/make.program_target.m:
compiler/make.util.m:
compiler/modules.m:
Add Erlang support to mmc --make. It can build "libraries" (we just
use directories called libFOO.beams containing Erlang .beam bytecode
files), install them and executables (which are just shell scripts
which invoke the Erlang runtime system).
Refactor some code and fix a few assumptions in places that we were
building for the C backends.
Replace some calls to io.remove_file by io.remove_file_recursively as
our Erlang "libraries" are actually directories.
Unrelated bugfix: for mmc --make --use-grade-subdirs foo.realclean,
remove the symlink created for foo.init in the current directory.
Delete module_name_to_file_name_sep as it is no longer used.
compiler/options.m:
Add options --erlang-interpreter, --erlang-object-file-extension
adn --install-command-dir-option.
doc/user_guide.texi:
Document --install-command-dir-option.
tests/mmc_make/Mmakefile:
Generate TEST_FLAGS *after* start_runtests_local as
start_runtests_local runs make realclean_local, which deletes
TEST_FLAGS.
library/io.m:
Add io.remove_file_recursively which can remove non-empty directories.
Fix the fallback implmentation io.buffer_to_string which was calling a
non-existent `from_char_list_semidet' predicate.
NEWS:
Mention io.remove_file_recursively.
Estimated hours taken: 0.5
Branches: main
Remove redundant uniqueness promises from the compiler. These have
been unnecessary since the globals field in the I/O state was made
non-unique.
compiler/globals.m:
compiler/handle_options.m:
compiler/make.program_target.m:
compiler/make.util.m:
compiler/source_file_map.m:
Delete unnecessary uniqueness promises and the odd unique mode.
util/.cvsignore:
Unrelated change: ignore pad_backslash.
Estimated hours take: 4
Branches: main
Add some preliminary infrastructure for an HLDS->Erlang code generator.
compiler/globals.m:
compiler/options.m:
Recognise "erlang" as a valid compilation target.
Add new options: `--erlang' and `--erlang-only' as synonyms
for `--target erlang' and `--target erlang --target-code-only'.
XXX the new options are currently undocumented.
compiler/hlds_data.m:
compiler/prog_data.m:
compiler/prog_io_pragma.m:
Recognise "Erlang" as a valid language for foreign code.
compiler/handle_options.m:
For erlang targets, set the gc_method to automatic and disable
optimize_constructor_last_call.
compiler/add_pragma.m:
compiler/add_type.m:
compiler/code_gen.m:
compiler/compile_target_code.m:
compiler/export.m:
compiler/foreign.m:
compiler/granularity.m:
compiler/intermod.m:
compiler/llds_out.m:
compiler/make.module_target.m:
compiler/make.program_target.m:
compiler/make_hlds_passes.m:
compiler/mercury_compile.m:
compiler/mercury_to_mercury.m:
compiler/ml_code_gen.m:
compiler/ml_optimize.m:
compiler/ml_switch_gen.m:
compiler/ml_type_gen.m:
compiler/ml_unify_gen.m:
compiler/mlds.m:
compiler/mlds_to_c.m:
compiler/mlds_to_il.m:
compiler/mlds_to_ilasm.m:
compiler/mlds_to_java.m:
compiler/modules.m:
compiler/pragma_c_gen.m:
compiler/prog_foreign.m:
compiler/simplify.m:
Conform to the above changes.
Estimated hours taken: 0.5
Branches: main
compiler/make.util.m:
compiler/make.*.m:
When building a `.clean' or `.realclean' target, only report
individual files being removed when `--very-verbose' is set,
not `--verbose-make'.
Still report each file when cleaning up the target files after
an interrupted build.
Branches: main
Extend parallel mmc --make support.
compiler/make.program_target.m:
Allow the target code and object code steps to be done in parallel.
Force all interface files to be made before the Mercury -> target code
step. This prevents a problem when two parallel branches try to
generate the same missing interface file later.
Allow intermodule analysis to proceed in parallel, i.e. building
`.analysis' files. Ensure that all interface files are made before the
analysis step also.
Branches: main
When using mmc --make --use-grade-subdirs, don't make a symlink or copy of
the target file to the user directory if the file in the user directory is
already up to date. This avoids bumping the timestamp unnecessarily.
compiler/compile_target_code.m:
Make post_link_make_symlink_or_copy check the timestamp of the file
in the user directory and do nothing if it is the same as the
timestamp of the file to be linked/copied.
Add an output argument to post_link_make_symlink_or_copy to indicate
if the symlink/copy was made.
compiler/make.program_target.m:
Make build_linked_target_2 only write a "Made symlink/copy of ..."
message if the symlink/copy is actually made by
post_link_make_symlink_or_copy.
Also make it warn in the case that there is nothing for mmc --make to
do. This was previously the case only for --no-use-grade-subdirs.
compiler/make.util.m:
Change maybe_symlink_or_copy_linked_target_message to write "Made
symlink/copy ..." rather than "Making symlink/copy ..." as the
message is now written after the fact.
Branches: main
Add initial support for parallel make functionality in `mmc --make', using
Mercury threads (not processes). Currently this is limited to running the
"compile target code to object code" step in parallel.
configure.in:
Require that the bootstrap compiler support the `thread_local'
attribute on mutables.
compiler/globals.m:
Use a thread-local mutable to hold the compiler's globals instead of
the globals facility in the io module.
Make the `extra_error_info' mutable thread-local.
compiler/options.m:
doc/user_guide.texi:
Add a `--jobs <n>' option, with shorthand '-j <n>'.
compiler/make.util.m:
Add a `foldl2_maybe_stop_at_error_maybe_parallel' predicate which is
like `foldl2_maybe_stop_at_error' but capable of running tasks in
parallel depending on the `--jobs' option.
compiler/make.program_target.m:
Use `foldl2_maybe_stop_at_error_maybe_parallel' for the "target code to
object code" step.
library/io.m:
Make the current input/output streams thread-local in C grades. This
uses the same underlying mechanisms as thread-local mutables. Direct
references to the current stream variables are replaced by calls to
functions which work with the thread-local current streams instead.
Add a mutex and locking predicates to protect the stream_db structure.
Mark `get_stream_db' and `set_stream_db' as thread-safe and protect
calls to those predicates with the locking predicates.
Rename the impure version of `get_stream_db' to
`get_stream_db_with_locking' and make it acquire and release the
stream_db mutex.
Add a mutex to protect the `ML_next_stream_id' counter.
Add a note about a thread-safety problem in `io.get_system_error'.
Mark `io.call_system_code' as `thread_safe'.
library/list.m:
Add the predicate `list.split_upto', which is to `list.split_list' as
`list.take_upto' is to `list.take'.
library/stream.string_writer.m:
Conform to the renaming of the impure `io.get_stream_db'.
library/thread.m:
Add a predicate `can_spawn', which succeeds if `spawn' is supported in
the current grade.
NEWS:
Announce parallel make support.
Announce `list.split_upto' and 'thread.can_spawn'.
Estimated hours taken: 2
Branches: main
Add some preliminary infrastructure for the LLDS->x86_64 assembler
code generator that Fransiska is working on.
compiler/globals.m:
compiler/options.m:
compiler/handle_options.m:
compiler/mercury_compile.m:
Recognise "x86_64" as a valid compilation target.
Add new options: `--x86_64' and `--x86_64-only' as synonyms
for `--target x86_64' and `--target x86_64 --target-code-only'.
In the backend passes for the lowlevel backend branch
appropriately depending on whether we are generating C or
x86_64 assembler.
compiler/foreign.m:
compiler/prog_foreign.m:
When compiling to x86_64 assembler use C as the preferred foreign
language.
compiler/mlds.m:
compiler/ml_code_gen.m:
compiler/ml_optimize.m:
compiler/ml_switch_gen.m:
compiler/ml_type_gen.m:
compiler/ml_unify_gen.m:
compiler/mlds_to_c.m:
Handle "x86_64" as a target in the MLDS backend. This does
(and should) cause a compiler abort since "x86_64" is intended
to be an MLDS target language.
compiler/make.module_target.m:
compiler/make.program_target.m:
compiler/modules.m:
Add placeholders for --target x86_64 in the build systems.
compiler/make_hlds_passes.m.
We don't currently support mutables with --target x86_64.
compiler/simplify.m:
We don't currently support runtime conditions on trace goals
with --target x86_64.
compiler/add_type.m:
compiler/compile_target_code.m:
compiler/granularity.m:
compiler/intermod.m:
Conform to the above changes.
Estimated hours taken: 1
Branches: main
compiler/make.program_target.m:
Fix behaviour when a library grade installation is interrupted.
It used to clean the default grade instead of the grade that was
interrupted.
Estimated hours taken: 0.5
Branches: main
Remove support for non-grade specific .init files.
browser/Mmakefile:
runtime/Mmakefile:
scripts/Mmake.rules:
compiler/make.program_target.m:
Don't install the .init files in the non-grade specific location.
Estimated hours taken: 0.5
Branches: main
compiler/make.program_target.m:
Don't remove grade-dependent files after installing a library with
`mmc --make' if `--use-grade-subdirs' is used.
Estimated hours taken: 3
Branches: main
Clean up in unused module imports in the Mercury system detected
by --warn-unused-imports.
analysis/*.m:
browser/*.m:
deep_profiler/*.m:
compiler/*.m:
library/*.m:
mdbcomp/*.m:
profiler/*.m:
slice/*.m:
Remove unused module imports.
Fix some minor departures from our coding standards.
analysis/Mercury.options:
browser/Mercury.options:
deep_profiler/Mercury.options:
compiler/Mercury.options:
library/Mercury.options:
mdbcomp/Mercury.options:
profiler/Mercury.options:
slice/Mercury.options:
Set --no-warn-unused-imports for those modules that are used as
packages or otherwise break --warn-unused-imports, e.g. because they
contain predicates with both foreign and Mercury clauses and some of
the imports only depend on the latter.
Estimated hours taken: 1.5
Branches: main
Being integrating the recently add `--make-xml-doc' functionality into
mmc --make. This will remain undocumented until the documentation system
has been developed further.
compiler/make.dependencies.m:
compiler/make.m:
compiler/make.module_target.m:
compiler/make.program_target.m:
compiler/make.util.m:
Add support for a .doc target that builds files containg the XML
representation of the local modules reachable from a specified
target, e.g. `mmc --make mer_std.doc' could be used to generate
XML files for the standard library modules.
compiler/modules.m:
Delete some leftover Aditi stuff.
Remove residual support for generating .h files (instead of .mh
or .mih files).
Fix the formatting of some comments.
compiler/xml_documentation.m:
Put the .xml files in Mercury/xmls if we are compiling if
--use-subdirs is enabled.
Estimated hours taken: 10
Branches: main
A side effect of the introduction of trace goals is that .init files are
now grade dependent. Consider a module that contains the following
trace goal:
trace [ compile_time(grade(debug)),
run_time(env("FOO"))
] (
...
),
In a debug grade the .init file for a library containing that module will
include the following directive:
ENVVAR FOO
In a non-debug grade it won't. At the moment which version of the .init
file is actually installed depends upon which grade was the first to
be built. This can result in linker errors if the wrong grade is used
with the wrong .init file.
There are two possible fixes. (1) always output ENVVAR directives
regardless of whether the compile time conditions of the trace goals to
which they are attached are true or not. (2) build grade specific .init
files and install them in grade specific locations.
The following diff implements the first stage of (2). For each grade in
which a library is to be installed we create a grade specific .init file
and then install it in a grade specific location, e.g.
`$(INSTALL_PREFIX)/lib/mercury/modules/<grade>'. (For bootstrapping
purposes .init files are currently still installed in the old location
as well.)
After this change has been installed on our machines I will add the
second part of this change which modifies the compiler to look for the
.init files in the new grade specific locations. The final part of the
change will then remove support for installing .init files in the old
location.)
scripts/Mmake.vars.in:
Add a variable that holds the name of a grade specific directory
in which to install .init files.
scripts/Mmake.rules:
Add a rule to install the .init files in a grade specific location.
browser/Mmakefile:
mdbcomp/Mmakefile:
runtime/Mmakefile:
Change the dependencies on the library installation targets so
that installing a library causes the .init files to be built and
installed.
(Currently this dependency is on the install target, which means
that the install_init rule is only invoked once, rather than
every time a grade is built.)
Install the .init files for these libraries in grade specific
locations. (For bootstrapping purposes they are currently also
installed in the old location.)
runtime/Mmakefile:
Remove the code that deletes runtime.init if it exists.
(Anyone who has a Mercury installation old enough for this to
be a problem is going to encounter more serious problems than
the runtime being initialized twice.)
Unrelated change: remove some duplicate entries from the list
of header files.
compiler/make.program_target.m:
Have mmc --make install the .init files in a grade specific location.
(They are also still installed in the old location.)
NOTE: the `XXX trace goal fix.' comments are placeholders for
things that need to be changed during the latter stages of this change.
Estimated hours taken: 1
Branches: main
Change the representation of some types used by mmc --make.
Minor formatting and style cleanups for mmc --make. There are no changes
to any algorithms.
compiler/make.m:
Delete the compilation_task type; it is unused.
Convert the target_file and linked_target_file types into
du's with named fields. This is nicer in mdb then pairs.
compiler/make.dependencies.m:
compiler/make.module_dep_file.m:
compiler/make.module_target.m:
compiler/make.program_target.m:
compiler/options_file.m:
Conform to the above changes.
Make a bunch of minor formatting and style changes.
compiler/make.util.m:
Add a predicate make_target_file_list required by the above.
compiler/inst_graph.m:
Replace DCGs with state variables.
compiler/common.m:
Fix some typos.
Estimated hours taken: 1.5
Branches: main, release
Fix a bug in mmc --make's handling of ranlib.
configure.in:
Set the value of RANLIBFLAGS.
On most systems it will be empty; on Mac OS X it needs to be set
to "-c".
Check that the installed compiler supports the `--ranlib-flags'
option.
compiler/make.program_target.m:
Fix the problem with the quoting in the command line used to
invoke ranlib on Mac OS X by using the recently introduced
`--ranlib-flags' option.
Remove the workaround for this bug.
scripts/Mercury.config.bootstrap.in:
scripts/Mercury.config.in:
Set the default value of the `--ranlib-flags' option.
scripts/Mmake.vars.in:
scripts/Mmake.rules:
Have mmake conform to the new way of handling flags for
ranlib.
Estimated hours taken: 1.5
Branches: main, release
Workaround a bug with mmc --make that shows up on Mac OS X.
Implement the first stage of a proper fix for this bug.
compiler/make.program_target.m:
Workaround a bug with the quoting of the command used to invoke
ranlib.
compiler/options.m:
Add a flag that for use as part of a proper fix for this
problem. This will need to bootstrap before the rest of the
fix, changing the configuration files to use the flag, can be
added.
Estimated hours taken: 0.2
Branches: main
Minor cleanups to some compiler modules.
There are no changes to any algorithms.
compiler/make.module_target.m:
compiler/make.program_target.m:
compiler/make.util.m:
compiler/mercury_compile.m:
Convert some if-then-elses into switches.
Don't ingore the error value returne by I/O operations
in some places.
Fix some comments.
Other minor formatting changes.
Estimated hours taken: 1
Branches: main, release
Fix a bug with mmc --make and static libraries. We need to update the
archive index after copying the library to the installation directory.
The linker on Mac OS X complains if we don't do this. This is also the
behaviour of mmake anyway, so mmc --make should do the same.
compiler/make.program_target.m:
Rebuild the archive index after installing a static library.
Estimated hours taken: 6
Branches: main
browser/*.m:
compiler/*.m:
Rename a bunch of predicates and function symbols to eliminate
ambiguities.
The only real change is factoring out some common code in the mlds
and llds code generators, replacing them with single definitions
in switch_util.m.
Estimated hours taken: 6
Branches: main
This diff contains no algorithmic changes. It merely renames apart a bunch more
function symbols to reduce ambiguity.
After this diff, the summary line from the mdb command "ambiguity -f" is
Total: 351 names used 975 times, maximum 31, average: 2.78
browser/*.m:
compiler/*.m:
Rename function symbols to eliminate ambiguities.
tests/debugger/declarative/dependency.exp:
tests/debugger/declarative/dependency2.exp:
Update the expected out where some internal function symbol names
appear in the output of the debugger. (This output is meant for
implementors only.)
Estimated hours taken: 8
Branches: main
This diff contains no algorithmic changes. It merely renames apart a bunch of
function symbols to reduce ambiguity. Basically I went through prog_data.m,
prog_item.m, hlds_data.m, hlds_goal.m and hlds_pred.m looking for type
definitions containing function symbol names that were either language
"keywords" (e.g. "terminates", which is an annotation on foreign_procs),
used with slightly different meanings in several types (e.g. "sym"),
or both (e.g. "call"). When I found such type definitions, I changed the
names of the function symbols, usually by adding a prefix or suffix
indicating the type to all function symbols of the type. For example,
the old function symbol "foreign_proc" in type "pragma_type" is now named
"pragma_foreign_proc", and the names of all other function symbols in that
type also start with "pragma_".
All of this should yield simpler compiler error messages when we make mistakes,
and will make it more likely that looking up a function symbol using a tags
file will take you to the actual definition of the relevant instance of that
function symbol. However, the most important benefit is the increase in
the readability of unfamiliar code; the reader won't have to emulate the
compiler's type ambiguity resolution algorithm (which in many cases used to
require distinguishing between f/14 and f/15 by counting the arguments,
e.g. for "pred_or_func").
compiler/prog_data.m:
compiler/prog_item.m:
compiler/hlds_data.m:
compiler/hlds_goal.m:
compiler/hlds_pred.m:
Rename function symbols as explained above.
compiler/*.m:
Conform to the function symbol renames.
In some cases, rename other function symbols as well.
Minor style fixes, e.g. replace if-then-elses with switches,
or simple det predicates with functions.
Estimated hours taken: 60
Branches: main
Provide a mechanism for collecting statistics about tabling operations,
and provide a much more convenient mechanism for resetting tables.
Since it would too complex to do this while preserving the capability
of setting --tabling-via-extra-args to no, eliminate that capability
and the option. That option was useful only for measurements of the
performance boost from setting --tabling-via-extra-args to yes in any case,
so users lose no functionality.
Previously, the only way to debug the low level details of the tabling
mechanism was to build a runtime with a specific C macro (MR_TABLE_DEBUG)
and link with that runtime; this was cumbersome. Change that so that
every one of the debuggable tabling macros has a bool argument that says
whether debugging is enabled or not. The compiler can then set this to
MR_TRUE if the new option --table-debug is given, and to MR_FALSE otherwise.
If set to MR_FALSE, the C compiler should optimize away the debug code,
with zero impact on program size or speed.
Since these changes to macros require nontrivial bootstrapping, which we don't
want to do unnecessarily, modify the interface of the tabling macros as
required to support size limits on tables. This diff also implements the
parsing of size limit specifications on tables, but does not implement them
yet; that is for a future change.
To make the syntax simpler, this diff deletes the free-standing fast_loose_memo
pragma. The same functionality is now available with a fast_loose annotation
on an ordinary memo pragma.
Make a bunch of changes to improve readability and maintainability
in the process. These mostly take the form of renaming ambiguous and/or
not sufficiently expressive function symbols.
runtime/mercury_stack_layout.h:
runtime/mercury_tabling.h:
Move the description of structure of tables from mercury_stack_layout.h
to mercury_tabling.h, since we now need it for statistics even if
execution tracing is not enabled.
Modify those data structures to have room for the statistics.
Don't distinguish "strict", "fast_loose" and "specified" memoing
as separate eval methods; treat them as just different kinds
of the same eval method: "memo".
Remove underscores from the names of some types that the style guide
says shouldn't be there.
runtime/mercury_tabling_preds.h:
runtime/mercury_tabling_macros.h:
Modify the approach we use for macros that implement the predicates
of library/table_builtin.m. Instead of selecting between debug and
nondebug based on whether MR_TABLE_DEBUG is defined or not, add
an explicit argument controlling this to each debuggable macro.
The advantage of the new arrangement is that it scales. Another
argument controls whether we are computing statistics (and if yes,
where do we put it), and a third argument controls whether we maintain
back links in the tries and hash tables (this last argument is present
but is ignored for now).
Since the values of the arguments will be known when the .c files
containing calls to these macros are compiled, we pay the space and
time cost of debugging, statistics gathering and the maintenance of
back links if and only we need the revelant functionality.
Provide macros for limited backward compatibility with the old set
of macros; these allow workspaces created by old compilers to work
with the new macros in the runtime. The old macros followed the
naming scheme MR_table_*, the new ones are named MR_tbl_*.
runtime/mercury_table_int_fix_index_body.h:
runtime/mercury_table_int_start_index_body.h:
runtime/mercury_table_type_body.h:
New files containing parts of the old mercury_tabling.c. Each of these
files contains the body of the functions that used to be in
mercury_tabling.c. The new mercury_tabling.c #includes each of these
files more than once, to provide more than one variant of the old
function. These variants differ in aspects such as whether debugging
is enabled or statistics is being collected. Each variant therefore
incurs only the time costs it needs to. (We pay the space cost of
having all these variants all the time of course, but this cost
is negligible.)
runtime/mercury_tabling_stats_defs.h:
runtime/mercury_tabling_stats_nodefs.h:
runtime/mercury_tabling_stats_undefs.h:
New files that serve as wrappers around the newly #included files,
controlling how they handle statistics.
runtime/mercury_tabling.c:
Delete functions now in the new files, and #include them instead.
Delete the data structures that used to contain summary statistics;
the new approach keeps statistics in compiler-generated,
procedure-specific data structures.
runtime/mercury_trace_base.c:
Use the new versions of the tabling macros to access the I/O table.
runtime/mercury_type_info.h:
Update some documentation for the movement of code out of
mercury_tabling.c.
runtime/mercury_types.h:
Provide forward declarations of the identifiers denoting the new types
in mercury_tabling.h.
runtime/mercury_grade.h:
Increment the exec trace version number, since we have changed
a part of the exec trace structure.
runtime/mercury_bootstrap.h:
Fix some temporary issues that arise from some renames above.
runtime/mercury_hash_lookup_or_add_body.h:
Fix comment.
runtime/Mmakefile:
Mention the new files and the dependencies that involve them.
library/table_builtin.m:
Provide a type for representing statistics and a predicate for
printing statistics.
Use the updated versions of the macros in
runtime/mercury_tabling_preds.h.
compiler/prog_item.m:
Change representation of tabling pragmas to allow room for the new
attributes.
Allow an item to be marked as being generated by the compiler
as a result of a pragma memo attribute. We use this for the reset
and statistics predicates.
compiler/mercury_to_mercury.m:
Write out the new attributes of the tabling pragma.
compiler/prog_data.m:
compiler/hlds_data.m:
Change the cons_id that used to refer to a procedure's call table root
to refer to the entirety of the new data structure now containing it.
The compiler now needs a way to refer to the other components of this
new data structure, since it contains the statistics.
As in the runtime, don't distinguish "strict", "fast_loose" and
"specified" memoing as separate eval methods; treat them as just
different kinds of the same eval method: "memo".
Rename some of the uses of the function symbols "c", "java", "il".
compiler/hlds_pred.m:
Add an extra field in proc_infos for storing any tabling attributes.
Change the existing proc_info field that records information about
the kinds of arguments of tabled procedures to record the information
needed by the debugger too. This was needed to allow us to shift all
the RTTI for procedure-specific tables (as opposed to the RTTI for
the global I/O table) from mercury_stack_layout.h to mercury_tabling.h
without duplicating the data (which would be a maintenance problem).
Reformat some comments to make them easier to read.
compiler/layout.m:
compiler/layout_out.m:
Delete the part of the exec trace information that used to record
RTTI for tables, since this information is not generated only as
part of the debugger data structures anymore.
compiler/prog_io_pragma.m:
Recognize the updated syntax for tabling pragmas.
compiler/add_pragma.m:
When processing tabling pragmas for inclusion in the HLDS, create
any reset and statistics predicates they ask for.
compiler/make_hlds_passes.m:
Export a predicate now needed by add_pragma.m.
Handle the new attributes on tabling pragmas
compiler/globals.m:
Change the function symbols of the types describing backends and
foreign languages to say what they are. Previously, both types (as well
as several others) included the function symbol "c"; now, they are
target_c and lang_c respectively.
compiler/table_gen.m:
Implement the changes described at the top.
When passing around varsets and vartypes, pass the arguments in the
standard order.
compiler/goal_util.m:
compiler/hlds_goal.m:
When passing around varsets and vartypes, pass the arguments in the
standard order.
compiler/rtti.m:
Provide types for representing the runtime's data structures for
tabling (which are now significantly more complex than a single word)
and predicates for manipulating them, for use by both the ml and ll
backends.
compiler/llds.m:
Replace the comp_gen_c_var type with the tabling_info_struct type,
which contains the information needed to create the per-procedure
tabling data structures.
Replace references to call tables with references to the various
components of the new tabling data structures.
compiler/llds_out.m:
Add code to write out tabling_info_structs.
Delete the code required for the old, hacky way of resetting tables.
Reorder some code more logically.
compiler/proc_gen.m:
Generate tabling_info_structs.
compiler/stack_layout.m:
Don't generate the information now generated in proc_gen.m.
compiler/mlds.m:
Give mlds_proc_labels their own function symbols, instead of using
a pair. Rename some other function symbols to avoid ambiguity and add
expressiveness.
Provide for the representation of references to the various components
of the new tabling data structures, and for the representation of their
types.
compiler/ml_code_gen.m:
When generating code for a tabled procedure, generate also the data
structures required for its table.
compiler/rtti_to_mlds.m:
compiler/ml_util.m:
Move some predicates from rtti_to_mlds.m to ml_util.m, since we
now also want to call them from ml_code_gen.m.
compiler/name_mangle.m:
Add some utility predicates.
compiler/options.m:
Delete the old --allow-table-reset option.
Add the new --table-debug option.
Comment out an implementor-only option.
compiler/add_pred.m:
compiler/add_solver.m:
compiler/add_trail_ops.m:
compiler/add_type.m:
compiler/bytecode_gen.m:
compiler/code_gen.m:
compiler/compile_target_code.m:
compiler/complexity.m:
compiler/dependency_graph.m:
compiler/det_report.m:
compiler/export.m:
compiler/fact_table.m:
compiler/foreign.m:
compiler/global_data.m:
compiler/globals.m:
compiler/handle_options.m:
compiler/higher_order.m:
compiler/hlds_code_util.m:
compiler/hlds_data.m:
compiler/hlds_goal.m:
compiler/hlds_out.m:
compiler/inlining.m:
compiler/intermod.m:
compiler/make.dependencies.m:
compiler/make.module_target.m:
compiler/make.program_target.m:
compiler/make.util.m:
compiler/make_hlds_passes.m:
compiler/mercury_compile.m:
compiler/ml_call_gen.m:
compiler/ml_closure_gen.m:
compiler/ml_code_gen.m:
compiler/ml_code_util.m:
compiler/ml_elim_nested.m:
compiler/ml_optimize.m:
compiler/ml_switch_gen.m:
compiler/ml_tailcall.m:
compiler/ml_type_gen.m:
compiler/ml_unify_gen.m:
compiler/mlds_to_c.m:
compiler/mlds_to_gcc.m:
compiler/mlds_to_il.m:
compiler/mlds_to_ilasm.m:
compiler/mlds_to_java.m:
compiler/mlds_to_managed.m:
compiler/modes.m:
compiler/module_qual.m:
compiler/modules.m:
compiler/opt_debug.m:
compiler/opt_util.m:
compiler/polymorphism.m:
compiler/pragma_c_gen.m:
compiler/proc_label.m:
compiler/prog_data.m:
compiler/prog_foreign.m:
compiler/prog_item.m:
compiler/prog_mutable.m:
compiler/prog_out.m:
compiler/prog_rep.m:
compiler/prog_util.m:
compiler/recompilation.version.m:
compiler/size_prof.m:
compiler/special_pred.m:
compiler/switch_util.m:
compiler/transform_llds.m:
compiler/tupling.m:
compiler/type_ctor_info.m:
compiler/unify_gen.m:
Conform to the changes above, and/or improve some comments.
mdbcomp/prim_data.m:
Make the names of the function symbols of the proc_label type more
expressive and less ambiguous.
mdbcomp/prim_data.m:
mdbcomp/mdbcomp.m:
mdbcomp/program_representation.m:
mdbcomp/rtti_access.m:
mdbcomp/slice_and_dice.m:
mdbcomp/trace_counts.m:
Use . instead of __ as module qualifier.
Conform to the change to prim_data.m.
browser/declarative_execution.m:
browser/declarative_oracle.m:
browser/declarative_tree.m:
Conform the change to mdbcomp/prim_data.m.
tests/debugger/Mercury.options:
Don't specify --allow-table-reset for fib.m, since that option
doesn't exist anymore.
tests/debugger/fib.m:
Use the new mechanism for resetting the table.
tests/debugger/print_table.m:
Use the new syntax for pragma memo attributes.
tests/invalid/specified.{m,err_exp}:
Use to the new syntax and reset method for pragma memo attributes.
Test the handling of errors in the new attribute syntax.
tests/tabling/Mercury.options:
Don't specify --allow-table-reset for specified.m, since that option
doesn't exist anymore.
tests/tabling/specified.m:
Use the new syntax for pragma memo attributes, and use the new
mechanism for resetting tables. We could also use this test case
for testing the printing of statistics, but the format of that
output is still not final.
tests/tabling/fast_loose.m:
Use the new syntax for pragma memo attributes, and use the new
mechanism for resetting tables.
trace/mercury_trace.c:
trace/mercury_trace_cmd_developer.c:
Conform to the changes in the RTTI data structures regarding tabling.
Remove underscores from the names of some types that the style guide
says shouldn't be there.
library/robdd.m:
Comment out the tabling pragma until this change is bootstrapped.
Without this, the conflict between the old calls to macros generated
by the existing compiler and the new definition of those macros
in the runtime would cause errors from the C compiler.
Estimated hours taken: 7
Branches: main, release
Fix the bug with initialisers/finalisers in libraries not being called ( and
as consequence also fixes the bug with mutables not being given their correct
initial value). The problem was that the directives necessary to call them
were not being included in the libraries' .init file.
The fix is to add a new mode of operation to mkinit that given a list of
.c files that make up some Mercury library, constructs the .init file for
that library. In particular, it now constructs the .init file so that
it contains any REQUIRED_{INIT,FINAL} directives needed by the library.
The new mode of operation is invoked when mkinit is given the `-k' option.
Modify the build systems (i.e. mmake and mmc --make) to conform to the
above change.
compiler/modules.m:
Change the rule mmake uses to build .init files so that it calls
mkinit -k on all the .c files generated for the library.
scripts/Mmake.vars.in:
Add a new mmake variable MKLIBINIT. This is the program used to
create .init files. (It will nearly always be mkinit.)
compiler/compile_target_code.m:
Change how .init files are built. We now have to call mkinit -k to
scan all of the .c files to write out the correct set of INIT,
REQUIRED_INIT and REQUIRED_FINAL directives. The code here is
that used by mmc --make for creating the .init files.
compiler/make.program_target.m:
Build the .init file after building the .c files, since building
it before will no longer work.