They turned out to have a zero hit rate, making them useless.
compiler/make.dependencies.m:
Add code to use the two new caches, indirect_imports_non_intermod
and anc0_dir1_indir2_non_intermod. I got statistics on their
performance while they were enabled, but since their hit rate was zero,
this diff includes them only in a commented-out form.
Note that adding the second cache required adding a new dep_spec,
which remains, since it shouldn't affect performance at all.
compiler/make.deps_cache.m:
Disable the those two caches.
Fix an issue where the original statistics-gathering code
mixed up hits and misses.
Include the statistics gathered in course of implementing this diff.
tools/make_deps_cache_stats:
Update this script to fix the hit/miss issue, and to print more info.
compiler/make.deps_cache.m:
Add conditionally-compiled code to count the search and addition
operations on each cache, as well as code to write out these counts.
Where a cache has two versions, one for intermod and non-intermod
operations, put the non-intermod version first, since it is more basic.
Add two new non-intermod cache versions that are not used yet,
but whose intermod versions are used: one for non-intermod
indirect imports, and one for non-intermod anc0_dir1_indir2.
For the latter, include "intermod" in the name of the old cache,
which uses intermodule information.
compiler/make.make_info.m:
Add those two caches, and follow the updated order and names of the caches.
compiler/mercury_compile_main.m:
Call make.deps_cache.m to dump out its cache, it it was enabled
and gathered any info.
compiler/make.m:
Make make.deps_cache.m visible from outside the make package,
in order to make possible the change top mercury_compile_main.m above.
compiler/make.dependencies.m:
Conform to the changes above.
tools/make_deps_cache_stats:
A new script to summarize the information recorded by the new code.
... instead of building a bunch of .c files.
Our tradition of adding an "s" at the end of a suffix to mean "all of the
files with the original suffix" had a problem when we added C# as a target
language. Until then, just as "os" stood for ".o files" when it occurred
as either a mmake target, mmc --make target, or mmake variable name component.
"cs" likewise stood for ".c files", but was now also needed to mean ".cs file".
We coped by keeping "cs" meaning ".c files", and adding "csharp" as a target
name synonym to mean ".cs file".
This diff keeps that synonym, but it changes
- the name needed to refer to ".c files" from "cs" to "all_cs"
- the name needed to refer to ".o files" from "os" to "all_os"
- the name needed to refer to ".pic_o files" from "pic_os" to "all_pic_os"
- the name needed to refer to ".cs files" from "css" to "all_css"
- the name needed to refer to ".java files" from "javas" to "all_javas"
- the name needed to refer to ".opt files" from "opts" to "all_opts"
- the name needed to refer to ".trans_opt files"
from "trans_opts" to "all_trans_opts"
It would be nice if we could apply this same change to all other similar
target names and mmake variable name suffixes, such as "ints" and "int3s",
but some of those names are already in use to mean semantically different
things. All of the names above that used to have the form "<ext>s" and
now have the form "all_<ext>s" stood for all the files with extension
".<ext>" that are prerequisites for building a linked target, i.e.
an executable or a library. But the mmake variable name suffixes
".all_mihs", ".all_mhs" and ".all_int0s" each stand for something subtly
different: the names of files that *may or may not exist", but which,
if they do exist, should be deleted by a clean or realclean target.
To make this breaking change easier to handle by users, this diff does
not simply redefine the meaning of ".all_int0s". (It does change the meaning
of the "cs" target, but the fact this will happen at some time has been
announced ages ago.) Instead, it defines three new mmake var suffixes,
".mihs_to_clean", ".mhs_to_clean" and ".int0s_to_clean", which are
synonyms for ".all_mihs", ".all_mhs" and ".all_int0s" respectively,
and announces that ".all_mihs", ".all_mhs" and ".all_int0s" are being
deprecated, and will have the above change of semantics applied to them
in the future.
NEWS.md:
Announce the breaking change.
compiler/make.top_level.m:
Stop treating the target "cs" as meaning "build all the .c files
for this program".
The code of classify_target_2 has long been semidet, but only in a way
that was not apparent to the compiler. Change the code to allow the
compiler to see its semidet nature while keeping the algorithm the same,
except for the change in the paragraph above.
This includes keeping e.g. "ints" as meaning "build all the .int/.int2
files needed by this program".
compiler/write_deps_file.m:
Stop generating mmake variables with suffixes ".cs", ".os", ".pic_os",
".javas" and ".css". The mmake variables with suffixes ".all_cs",
".all_os", ".all_pic_os", ".all_javas" and ".all_css" already existed.
All had the same value as the mmake variable without the "all",
with one exception: ".cs". However, in this case, the old (and still
current) value of ".all_cs" is what the value of ".cs" *should* have been.
Simplify some code.
The following changes in compiler/*.m are only cosmetic, but they helped me
rule out possible sources of problems with incomplete versions of this diff.
compiler/file_names.m:
Add a version of a fact_table_file_name_return_dirs which does not
return directories, since most of its callers don't need that info.
compiler/make.program_target.m:
Clarify code by making variable names more descriptive,
compiler/make.file_names.m:
compiler/make.module_target.m:
Conform to the changes above,
browser/Mmakefile:
compiler/Mmakefile:
deep_profiler/Mmakefile:
grade_lib/Mmakefile:
library/Mmakefile:
mdbcomp/Mmakefile:
mfilterjavac/Mmakefile:
profiler/Mmakefile:
slice/Mmakefile:
ssdb/Mmakefile:
Rename os to all_os, cs to all_cs, css to all_css, javas to all_javas,
and opts to all_opts. (There were no occurrences of trans_opts to rename.)
Replace [s as sh command names in actions.
scripts/Mmake.vars.in:
Specify the names of mmake variables holding the names of sets of files
with a given extension directly, since for some of them, adding an "s"
at the end of the name of the extension does not generate the name
of the corresponding mmake variable anymore.
scripts/Mmake.rules:
Use the directly specified mmake variable names from Mmake.vars.in
in the rule for installing lbraries. Temporarily add some debugging
output to make suree that the updated nested mmake variable references
work as intended.
tools/bootcheck:
Specify the names of mmake targets for making all the files in a program
with a given extension directly, since adding an "s" at the end of the
name of the extension does not generate the name of the corresponding
mmake target anymore.
Print timestamps around the action of checking namespace cleanliness,
to allow the time taken by that action to be measured. (I kept track
of bootchecks as they happened while working on this diff, and found
this time to be nontrivial.)
compiler/make.dependencies.m:
The task of this module is to find which source files are needed
to build each target file of an "mmc --make" invocation.
(In this case, "source" and "target" files mean the files
on the right and left hand sides of a make rule respectively.)
The original machinery used for this purpose used three-level towers
of closures, which made the code hard to read and to understand, and
also made it effectively impossible to change the argument list
of any of the predicates involved without also making the same change
to all the other predicates used at the same tower level.
This diff implements new machinery that replaces the towers of closures
with
- explicit data structures, to take over for the data in the closures, and
- simple code walking over those data structures, to take over for
the code in the closures.
The new machinery is intended to replace the old machinery after
a trial period of a week or two. Until then, we execute all operations
using both the old and the new machinery, and compare their outputs.
During a bootcheck in csharp grade, the comparisons detect differences
only in about half a dozen test cases, and it is not clear whether
they are actually due to the new machinery doing different things
than the old machinery, or due to the same actions being repeated.
Note that some of the infrastructure used by both sets of machinery
still uses the old approach; switching it over to the new approach
is future work.
The new machinery also lacks (most of) the caches used by
the old machinery. Adding caches to the new machinery is also future work,
because the new machinery is more flexible in *what* can be cached
reasonably conveniently, and therefore it is not clear whether the
set of things cached by the old machinery is also the best set of
things for the new machinery to cache.
The execution of both machineries and this lack of caching by
the new machinery will affect performance for probably a couple of weeks.
Add comments marked with "XXX MDNEW" about ideas for future improvements.
Add infrastructure to debug both this diff, and some other issues.
compiler/make.find_local_modules.m:
Add infrastructure to debug some other issues.
tools/bootcheck:
Delete the tests/*/Mercury directories before starting the execution
of the test suite. Without this, the files left in there by one bootcheck
can influence the outcome of the next bootcheck.
Change the naming scheme we use to record the timestamp of files
in the TEST_FAILS directory. The old scheme included colon characters,
which don't play nice with some of my personal scripts :-(
compiler/write_deps_file.m:
Move the filename creation code to the end of the file. Expand it
with conditionally-enabled code that gathers statistics about the
hit rate of the file name cache for each extension, and document
its result, which validates the existing approach.
Document an approach that looks like would speed up the file name
creation process, but does not.
compiler/mercury_compile_main.m:
Call a new predicate in write_deps_file.m to dump out the statistics
it gathered, if there are any.
tools/write_deps_file_stats:
A new script to summarize the raw data dumped out by write_deps_file.m.
library/dir.m:
Improve indentation.
tools/bootcheck:
Ignore differences between the stage 2 and stage 3 .java files
where those differences are caused by the fact that the stage 1
compiler, when generating the stage 2 .java files, is not allowed
to evaluate calls to int.\ (the one's complement operator)
at compile time, due to the host machine having 64 bit ints
and the java target having 32 bit ints.
tools/bootcheck:
Ignore differences between the stage 2 and stage 3 .cs files
where those differences are caused by the fact that the stage 1
compiler, when generating the stage 2 .cs files, is not allowed
to evaluate calls to int.\ (the one's complement operator)
at compile time, due to the host machine having 64 bit ints
and the csharp target having 32 bit ints.
tools/make_optimization_options:
Instead of generating a file to be manually copied into the middle
of compiler/options.m, do that update automatically.
compiler/options.m:
Mark both ends of the region whose contents are controlled by
tools/make_optimization_options.
compiler/simplify_goal_conj.m:
When a switch on a variable is followed by a switch on the *same* variable,
merge the two switches together, if doing so looks like it can save
the execution of some branches for at least some input values.
This transform is the second one to merge the goal following a switch
into the switch itself. Move the parts of the code involved that are
common between the two transformation to its caller, to reduce runtime
overhead.
compiler/simplify_goal.m:
Add infrastructure for printing the pre- and post-simplification versions
of specific goals. This helped debug the new code in simplify_goal_conj.m.
Fix an inadvertent unification between two module_infos.
This was caused by code that
- defined the variable ModuleInfo, and then
- reuses the "ModuleInfo" variable name for a slightly different purpose,
but did so in the condition of an if-then-else, where the semidet nature
of the implicit unification between the new value intended to be assigned
to ModuleInfo, and its old value, was expected.
compiler/simplify_proc.m:
Add infrastructure for printing versions of the procedure body
before and after quantification, instmap delta recomputation, and
determinism analysis have been rerun. This helped debug the new code
in simplify_goal_conj.m.
The rest of the changes concern the option that
- previously called only for the existing transformation to merge a test
unification following a switch into a switch
- and which now also calls for the merging of two succesive switches
on the same variable.
compiler/options.m:
The option was named test_after_switch; this diff updates its name to
merge_code_after_switch.
compiler/handle_options.m:
compiler/simplify_info.m:
compiler/simplify_tasks.m:
compiler/optimization_options.m:
tools/make_optimization_options_db:
tools/make_optimization_options_end:
Conform to this name change.
Given a switch arm that matches several cons_ids, and which contains
one or more switches on the *same* variable, such as the arm for
f1/f2/f3/f4 below,
(
(X = f1 ; X = f2 ; X = f3 ; X = f4),
...
(
X = f1,
...
;
(X = f2 ; X = f3),
...
;
X = f4,
...
),
...
;
...
)
this new optimization
- partitions the set of cons_id in that arm (in this case, {f1,f2,f3,f4})
as finely as needed by any other the switches on X in that arm
(in this case, that is three partitions containing {f1}, {f2,f3} and {f4}),
- splits that original switch arm into N arms, one arm for each partition,
making a copy of the switch arm's goal for each partition,
- restricts any switches on the original switch variable (in this case, X)
inside the copy of the arm goal inside each new case to only the cons_ids
in that case's partition, and then replacing any resulting one-arm switches
with the just goal inside that one arm.
The code resulting from these three steps will include some code duplication
(some of the pieces of code denoted by ... in the example above would be
duplicated), but it will need to execute fewer transfers of control.
This is worthwhile because (a) the branch instructions used to implement
switches are hard to predict unless most paths through the nested switches
are rarely if ever taken, and (b) the pipeline breaks caused by branches
that are not correctly predicted are one of the two major contributors
to the runtime of Mercury programs. (The other major contributors are
data cache misses.)
The implementation of this option has two major parts.
- Part 1 consists of discovering whether a procedure body contains
any code in which a switch on a variable is nested inside an arm
of another switch on that same variable. For any instance of such
a pair of switches, it records the identity of the variable and
the set of cons_ids of the outermost arm.
- Part 2 consists of actually transforming the procedure body
by splitting each outermost switch arm thus recorded. (This part
contains all three of the steps above.)
We integrate part 1 with the usual procedure body traversal of the
simplification pass, which makes it quite cheap. In most procedure bodies,
it won't find any nested switches meeting its criteria. We execute part 2,
which is relatively expensive, only if it does.
compiler/simplify_info.m:
Add a new type, switch_arm, which represents one arm of a switch.
Add a new field to the simplify_nested_context type. Its type
is list(switch_arm), and it represents the stack of switch arms (if any)
that the goal currently being simplified is inside. simplify_goal_switch.m
uses this field to detect switches that occur inside an arm of an
ancestor goal that is also a switch on the same variable.
Add a new field to the simplify_info, a set of switch_arms,
that denotes the set of switch arms from which that detection
has actually happened, and which should therefore be
partitioned and split.
compiler/simplify_goal_switch.m:
Add the code for doing the detection and recording mentioned just above.
This is the Part 1 mentioned above.
compiler/split_switch_arms.m:
This new module implements the splitting up process.
This is the Part 2 mentioned above.
compiler/simplify.m:
Include the new module in the simplify subpackage of the check_hlds
package.
compiler/notes/compiler_design.html:
Document the new module.
compiler/simplify_proc.m:
Invoke split_switch_arms.m (part 2) if the part of simplify_goal_switch.m
implementing part 1 has found any work for it to do.
compiler/simplify_tasks.m:
Add split_switch_arms as one of the tasks that simplification
may be asked to do. Set its default value from the value of
a new optimization option that, when specified, calls for it to be done.
compiler/options.m:
Add this option, --split-switch-arms.
Change the internal name of an existing option,
everything_in_one_c_function, to the one expected by
tools/make_optimization_options_middle.
Replace the part of this file that is constructed by
tools/make_optimization_options_middle.
doc/user_guide.texi:
Document the new option.
tools/make_optimization_options_db:
Add --split-switch-arms to the optimization tuple.
Fix software rot by
- renaming optimize_tailcalls to optimize_mlds_tailcalls inside the
optimization tuple, as it has been in options.m, and
- deleting erlang_switch_on_strings_as_atoms from the opt_tuple,
as it has been from options.m.
tools/make_optimization_options_end:
Enable the new option by default at optimization level 2.
tools/make_optimization_options_middle:
Fix bugs in this script, which generates compiler/optimization_options.m.
One bug was that it referred to the opt_level and opt_space options
by the wrong name (optopt_level and optopt_space respectively).
The other bug was that it expected opt_level to be a string_special option,
when it is an int_special option.
Make the handler_file this script generates easier to put into options.m
by not generating a line that (a) already exists in options.m, and
(b) would need to have a comma put after it, if one wanted this line
to replace the copy already in options.m.
compiler/optimization_options.m:
Rebuild this file after the changes above.
compiler/simplify_goal_unify.m:
Conform to the changes above.
compiler/inst_merge.m:
Mark two predicates, inst_merge_[34], to be inlined. The intention
is that inst_merge_4 should be inlined into inst_merge_3, and then
inst_merge_3 should be inlined inside inst_merge_2; that would then
generate six levels of switches, three on one of the insts to be
merged and three on the other, which the new optimization could
then flatten. Unfortunately, inlining does not do this yet.
tests/hard_coded/test_split_switch_arms.{m,exp}:
A new test case for the the new transformation.
tests/hard_coded/Mmakefile:
tests/hard_coded/Mercury.options:
Enable the new test case, and specify the new option for it.
compiler/options.m:
Add --inst-statistics as a developer-only option.
compiler/hlds_statistics.m:
Add code to gather and write out statistics about how frequently
each function symbol of the mer_inst type occurs in (a) the instmaps
of procedures' goals, and (b) in the automatically generated inst
tables.
compiler/mercury_compile_front_end.m:
Invoke the new code if the new option is specified.
(The code to do so is a near-copy of the nearby code for invoking
the other functionality in hlds_statistics.m.)
tools/inst_stats:
Add this tool for summarizing the statistics generated by the new option.
compiler/mlds.m:
Add the type mlds_env_defn, which is a version of mlds_class_defn
that is specialized to represent the environment structures we use
in the MLDS backend to implement model_non continuations. The original
mlds_class_defn has 13 fields; mlds_env_defn has only three. This
difference effectively encodes a whole lot of invariants about
environments. Not only does it omit fields of mlds_class_defns
that are always the same for all environments, it also omits
fields of mlds_class_defns that can differ between target languages
but which are always the same for any given target language.
These differences are implemented by mlds_to_*_class.m.
Add mlds_env_id as a new type to represent the ids of environment
structures.
Add mlds_env_type as a new function symbol in the mlds_type type
to represent the type of environment structures.
Include a list of mlds_env_defns in the MLDS representation of the
translated module.
compiler/ml_elim_nested.m:
Generate mlds_env_defns instead of mlds_class_defns to represent
environment structures.
compiler/mlds_to_c_class.m:
compiler/mlds_to_cs_class.m:
compiler/mlds_to_java_class.m:
Add code to write out mlds_env_defns. In each case, this code is
a version of the code to write out mlds_class_defns, specialized
to the invariants of environment structures.
compiler/mlds_to_c_file.m:
compiler/mlds_to_cs_file.m:
compiler/mlds_to_java_file.m:
Call the new code in mlds_to_X_class.m.
compiler/ml_rename_classes.m:
Add utility predicates for operating on environment structures.
compiler/mercury_compile_mlds_back_end.m:
compiler/ml_accurate_gc.m:
compiler/ml_lookup_switch.m:
compiler/ml_simplify_switch.m:
compiler/ml_top_gen.m:
compiler/mlds_dump.m:
compiler/mlds_to_c_data.m:
compiler/mlds_to_c_export.m:
compiler/mlds_to_c_stmt.m:
compiler/mlds_to_c_type.m:
compiler/mlds_to_cs_data.m:
compiler/mlds_to_cs_type.m:
compiler/mlds_to_java_data.m:
compiler/mlds_to_java_type.m:
Conform to the changes above.
tools/bootcheck:
Redirect the input of mmake in each test directory to come from
/dev/null, to avoid bootchecks in the Java grade being temporarily
suspended for input from the terminal.
tools/bootcheck:
Fix the setting of the WORKSPACE variable when running the tests.
Due to incorrect use of pwd it was actually pointing back at stage 1.
If we are running under MSYS2, then set --windows automatically.
(It's too easy to forget to do this otherwise.)
Mention this in the documentation for the --windows option. Also,
the --windows option does not imply anything about the library
extension -- despite what the usage message has claimed for many
years.
tools/bootcheck:
On MSYS2, translate paths written to .options and _FLAGS files into
Windows-style paths.
On MYS2, pass -u and --strip-trailing-cr to diff.
compiler/file_names.m:
Document the meaning of the maybe_create_dirs and maybe_search types.
Delete long-obsolete references to .il files.
compiler/make.util.m:
Rename make_remove_target_file to remove_make_target_file, since this
predicate removes target files in Makefiles, and does not "make" anything.
Rename several other predicates in a similar manner, for the same reason.
Add an extra argument to get_file_name and some related predicates
that will allow future conditionally-enabled trace goals in the compiler
to track where the requests for file name translations come from.
compiler/write_deps_file.m:
Factor out some code.
compiler/make.dependencies.m:
compiler/make.module_dep_file.m:
compiler/make.module_target.m:
compiler/make.program_target.m:
Conform to the changes above.
tools/file_name_translation_stats:
Allow for large numbers of file name translations.
tools/line_len_stats:
A new script that computes and prints a histogram of the line lengths
in the input given to it.
tools/find_long_lines:
A new script that, when given a line length and a list of filenames,
prints out the location of the lines in those files that are longer
than the given line length.
tools/bootcheck:
If a directory named TEST_FAILS exists in the top level directory.
copy tests/UNEXPECTED_FAILED_TESTS to that directory, with a name
that contains (a) the grade, and (b) the date and time. A diff between
two of these files with the same grade but different times will make
it easy to see which test failures are *new*.
compiler/parse_tree_out_cons_id.m:
Move the predicates and functions in prog_out.m that deal with cons_ids
to this module.
compiler/parse_tree_out_sym_name.m:
Move the predicates and functions in prog_out.m that deal with sym_names
and similar entities to this module.
compiler/parse_tree_out_type.m:
Move the predicates and functions in prog_out.m that deal with types
to this module.
compiler/parse_tree_out_misc.m:
Move the predicates and functions in prog_out.m that deal with simple
types to this module.
Delete mercury_output_det and mercury_format_det, replacing all their
uses with calls to mercury_det_to_string.
compiler/prog_out.m:
Delete this module.
compiler/parse_tree.m:
Delete prog_out from the parse_tree package.
compiler/Mercury.options:
compiler/notes/compiler_design.html:
Delete references to prog_out.m.
compiler/*.m:
Update imports and any explicit module qualifications to account
for the moved code.
tools/filter_sort_imports:
Automatically filter out any repeated imports. This can help with
changes like this that redistribute the contents of one module to other
modules. In this case, after a global replacement of prog_out's import
with the import of parse_tree_out_misc, this updated script could
remove this changed import from modules that already imported
parse_tree_out_misc.
Use the recently added --trans-opt-deps-spec option to break cycles in
the trans-opt dependency graph for the standard library. This enables
more parallelism when making the .trans_opt files; it now takes about
half as long as before.
Ordering modules sensibly, so that .trans_opt files are created in a
logical order, also improves analysis results for many predicates and
functions. The only results which show a regression with this change are
for deprecated forwarding predicates/functions.
In future, we will probably be able to trim more dependencies to further
improve parallelism, without impacting analysis results.
configure.ac:
Check that the bootstrap compiler supports --trans-opt-deps-spec.
library/mer_std.trans_opt_deps_spec:
Add the spec file that adjusts dependencies in the trans-opt
dependency graph.
library/INTER_FLAGS:
Use the --trans-opt-deps-spec option when building with mmake.
scripts/prepare_install_dir.in:
tools/binary:
tools/bootcheck:
tools/unary:
Copy mer_std.trans_opt_deps_spec when preparing a copy of the
library directory.
tools/bootcheck:
Allow the executable name used for sed to be overridden
in the environment. (This is useful for using the GNU
version of sed on macOS instead of the one it ships with.)
tools/bootcheck.java:
Use $(...) in preference to `...` for command substitutions.
Quote variables.
Abort if we attempt to rm / due to a variable not being set.
Rename mmc and mgnuc options that set this grade component to --c-debug-grade.
Let the options named --c-debug of both mmc and mgnuc enable C level debugging
of only the module being compiled.
runtime/mercury_grade.h:
Rename the .ll_debug grade component to .c_debug. Also rename the C macro
that controls the presence or absence of this grade component
from MR_LL_DEBUG to MR_C_DEBUG_GRADE.
runtime/mercury_conf_param.h:
runtime/mercury_debug.c:
runtime/mercury_debug.h:
runtime/mercury_engine.c:
runtime/mercury_label.c:
runtime/mercury_memory_zones.c:
runtime/mercury_memory_zones.h:
runtime/mercury_overflow.c:
runtime/mercury_std.h:
runtime/mercury_wrapper.c:
Rename the MR_LOWLEVEL_DEBUG macro to MR_DEBUG_THE_RUNTIME.
Previously, the name of this macro wrongly implied that it had
something to do with the old .ll_debug grade component, even though
- the MR_LOWLEVEL_DEBUG macro was designed to debug LLDS grades,
since only these existed when it was created, while
- the .ll_debug grade component (now .c_debug) is useful only for
MLDS grades targeting C.
compiler/options.m:
Rename the old confusingly named low_level_debug option to c_debug_grade.
Move it to the list of grade options, and fix its documentation, which
was completely wrong:
- code in compile_target_code.m treated it as being a synonym of
the .ll_debug (now .c_debug) grade component, while
- its (commented out) documentation here in options.m said it called for
the enabling of what is now MR_DEBUG_THE_RUNTIME.
compiler/compile_target_code.m:
Conform to the rename just above.
Define MR_C_DEBUG_GRADE instead of MR_LL_DEBUG if c_debug_grade is enabled.
Pass -g to the C compiler if either c_debug_grade or target_debug
is enabled.
Add an XXX about a missing safety check for an obsolete experimental
feature.
compiler/compute_grade.m:
When given a grade with a .c_debug grade component, set only the
c_debug_grade option; don't set the target_debug option, which is NOT
a grade option. The change to compile_target_code.m above handles the
only situation in which this implication was formerly required.
scripts/canonical_grade.sh-subr:
scripts/init_grade_options.sh-subr:
scripts/parse_grade_options.sh-subr:
Look for and process the .c_debug grade component instead of .ll_debug.
Use a sh variable named c_debug_grade to record its absence/presence.
Look for and process the --c-debug-grade grade-component option,
setting the same sh variable, c_debug_grade. (All grade components
can be set piecemeal using sh options to the scripts using these
subroutines.) This replaces the old, confusingly named option
--low-level-debug.
scripts/mgnuc.in:
scripts/mgnuc_file_opts.sh-subr:
Consistently use the sh variable c_debug to record the presence of
the (non-grade) --c-debug option to mgnuc, and the sh variable
c_debug_grade to record the presence of the .c_debug grade component.
Stop looking for and handling the --low-level-debug option, which
mgnuc used to document, even though this duplicated the same documentation
in init_grade_options.sh-subr, which mgnuc includes. The difference was
that init_grade_options.sh-subr meant it to represent the old .ll_debug
MLDS grade component, while mgnuc treated it as specifying what is now
MR_DEBUG_THE_RUNTIME for LLDS grades. It didn't help that two sh variables
with quite different semantics had names that differed only in an
underscore: LLDEBUG_OPTS vs LL_DEBUG_OPTS.
scripts/Mmakefile:
Add a missing dependency to force the rebuild of mgnuc after each update
of its sh subroutine mgnuc_file_ops.sh-subr.
doc/user_guide.texi:
Document the --c-debug-grade option of mmc. This option was not publicly
documented under its original misleading name (--low-level-debug), but
its documentation is now possible without contorted dancing around the
name.
Clarify the documentation of mgnuc's --c-debug option.
README.sanitizers:
configure.ac:
Conform to the rename of the grade component.
grade_lib/grade_spec.m:
grade_lib/grade_string.m:
grade_lib/grade_structure.m:
grade_lib/try_all_grade_structs.m:
Conform to the rename of the grade component .ll_debug to .c_debug.
Don't allow the .c_debug grade component in LLDS grades.
In grade_string.m, add some obvious implications of some grade components.
grade_lib/choose_grade.m:
grade_lib/grade_lib.m:
grade_lib/test_grades.m:
grade_lib/var_value_names.m:
Fix white space.
scripts/ml.in:
tools/lmc.in:
tools/test_mercury:
Conform to the change in compile_target_code.m to the naming of
Boehm gc library variants.
All the strings returned by MR_win32_error_name include a common prefix
"ERROR_". Since there are many (1749) such strings, we can reduce the
size of the data by about 10 KB by returning only the part following the
prefix.
tools/generate_windows_error_name:
runtime/mercury_windows_error_name.c:
Make MR_win32_error_name return strings without the "ERROR_" prefix.
library/io.m:
Update caller system_error_win32_error_name to add the "ERROR_"
prefix.
Fix compilation with older versions of MinGW(-w64) and any other
compilers which don't have as many ERROR_ constants defined.
tools/generate_windows_error_name:
Reduce the list of ERROR_ constants.
runtime/mercury_windows_error_name.c:
Regenerate.
Implement the error handling proposals from February 2022 on the
mercury-users list, and August 2022 on the mercury-reviews list.
We add io.system_error to the public interface of io.m
and document what its foreign representation is for each backend.
We allow io.error to optionally contain an io.system_error value,
and provide predicates to retrieve the io.system_error from an io.error.
The user may then inspect the system error via foreign code.
We also provide a predicate that takes an io.error and returns a name
for the system error it contains (if any). This makes it relatively easy
for Mercury programs to check for specific error conditions.
By returning platform-specific (actually, implementation-dependent)
error names, we are pushing the responsibility of mapping strings to
error conditions onto the application programmer. On the other hand, it
is not practical for us to map all possible system-specific error codes
to some common set of values. We could do it for a small set of common
error codes/exceptions, perhaps.
The standard library will construct io.error values containing
io.system_errors. However, we do not yet provide a facility for user
code to do the same.
library/io.m:
Move io.system_error to the public interface.
Change the internal representation of io.error to support containing
a io.system_error. An io.system_error may originate from an errno
value or a Windows system error code; the constructor distinguishes
those cases.
Add predicates to retrieve a system_error from io.error.
Add predicate to return the name of the system error in an io.error.
Replace make_err_msg with make_io_error_from_system_error.
Replace make_maybe_win32_err_msg with
make_io_error_from_maybe_win32_error.
Delete ML_make_err_msg and ML_make_win32_err_msg macros.
browser/listing.m:
library/bitmap.m:
library/dir.m:
library/io.call_system.m:
library/io.environment.m:
library/io.file.m:
library/io.text_read.m:
mdbcomp/program_representation.m:
Conform to changes.
Leave comments for followup work.
tools/generate_errno_name:
tools/generate_windows_error_name:
Add scripts to generate mercury_errno_name.c and
mercury_windows_error_name.c.
runtime/Mmakefile:
runtime/mercury_errno_name.c:
runtime/mercury_errno_name.h:
runtime/mercury_windows_error_name.c:
runtime/mercury_windows_error_name.h:
Add MR_errno_name() and MR_win32_error_name() functions,
used by io.m to convert error codes to string names.
tests/hard_coded/null_char.exp:
Update expected output.
README.cross.md:
Add instructions for cross-compiling using clang.
tools/configure_cross:
Adapt script to support a FreeBSD x86-64 target using clang.
NEWS:
Announce change to script.
The configure script for the cross compiler did not recognise MXE
targets with a '.static' suffix, e.g. --host=x86_64-w64-mingw32.static
Running the configure script with such a target resulted in an error
message, e.g. 'unknown host: x86_64-w64-mingw32.static'
See https://mxe.cc/ to find examples of valid MXE targets.
tools/configure_cross:
As above.
Since this is the first converted module that dumps out goals when
debugging trace flags are enabled, this required generalizing the code
that does that, to take either varsets or var_tables as a means of
specifying the names of variables. We do this via a new type,
var_name_source, which contains either a varset or a var_table.
Almost all of this diff is there to implement this generalization.
A large part of it affects code in the parse_tree package that we use
to write out the parts of HLDS goals that are defined by types defined
in that package. Since we want to avoid making any part of the parse_tree
package dependent on the hlds package, this required defining the
var_name_source type in the parse_tree package, which in turn requires
var_table.m to be in that same package.
compiler/lco.m:
Convert this module to use var_tables instead of varsets and vartypes.
compiler/var_table.m:
Move this module from the hlds package to the parse_tree package.
To make this, possible, move the parts that required access to the HLDS
to hlds_pred.m, from where it was usually invoked.
Export some utility predicates to allow the moved code to work
in hlds_pred.m without access to the actual definition of the
var_table type.
Define the var_name_source type.
Add some utility functions for use by code writing out variable names.
compiler/hlds_pred.m:
Add the code moved from var_table.m.
compiler/vartypes.m:
Move this module from the hlds package to the parse_tree package,
for symmetry with var_table.m. It did not depend on being in hlds
in any way.
compiler/hlds.m:
compiler/parse_tree.m:
Move vartypes.m and var_table.m from the hlds package
to the parse_tree package.
compiler/hlds_out_goal.m:
Change all the predicates in this module to take a var_name_source
instead of a prog_varset.
Fix some comments.
compiler/hlds_out_util.m:
Change some of the predicates in this module (those called from
hlds_out_goal.m) to take a var_name_source instead of a prog_varset.
compiler/parse_tree_out_term.m:
Provide variants of some existing predicates and functions that take
var_name_sources instead of varsets. The code of the copies
duplicates the logic of the originals, though I hope that this
duplication can be done away with at the end of the transition.
(The best solution would be to use a typeclass with methods
that convert vars to their names, but we would want to ensure
that the compiler can specialize all the affected predicates
and functions to the two instances of this typeclass, which is
something that we cannot do yet. In the meantime, the lack of
any generalization in the old versions preserves their performance.)
tools/sort_imports:
tools/filter_sort_imports:
A new tool that automatically sorts any occurrences of consecutive
":- import_module" declarations in the named files. The sorting is done
in filter_sort_imports; sort_imports loops over the named files.
After automatically replacing all occurrences of hlds.{vartypes,var_table}
in import_module declarations with their parse_tree versions, the updated
import_module declarations were usually out of order with respect to
their neighbours. I used this script to fix that, and some earlier
out-of-order imports.
compiler/accumulator.m:
compiler/add_class.m:
compiler/add_clause.m:
compiler/add_foreign_proc.m:
compiler/add_heap_ops.m:
compiler/add_pragma_type_spec.m:
compiler/add_pred.m:
compiler/add_trail_ops.m:
compiler/analysis.m:
compiler/arg_info.m:
compiler/build_mode_constraints.m:
compiler/bytecode_gen.m:
compiler/call_gen.m:
compiler/check_promise.m:
compiler/closure_analysis.m:
compiler/closure_gen.m:
compiler/code_info.m:
compiler/code_loc_dep.m:
compiler/common.m:
compiler/compile_target_code.m:
compiler/complexity.m:
compiler/const_prop.m:
compiler/constraint.m:
compiler/continuation_info.m:
compiler/convert_parse_tree.m:
compiler/coverage_profiling.m:
compiler/cse_detection.m:
compiler/ctgc.datastruct.m:
compiler/ctgc.util.m:
compiler/dead_proc_elim.m:
compiler/deep_profiling.m:
compiler/deforest.m:
compiler/delay_construct.m:
compiler/delay_partial_inst.m:
compiler/dep_par_conj.m:
compiler/det_analysis.m:
compiler/det_report.m:
compiler/det_util.m:
compiler/direct_arg_in_out.m:
compiler/disj_gen.m:
compiler/distance_granularity.m:
compiler/equiv_type_hlds.m:
compiler/exception_analysis.m:
compiler/file_names.m:
compiler/float_regs.m:
compiler/follow_vars.m:
compiler/format_call.m:
compiler/generate_dep_d_files.m:
compiler/get_dependencies.m:
compiler/goal_expr_to_goal.m:
compiler/goal_mode.m:
compiler/goal_path.m:
compiler/goal_store.m:
compiler/goal_util.m:
compiler/granularity.m:
compiler/hhf.m:
compiler/higher_order.m:
compiler/hlds_clauses.m:
compiler/hlds_code_util.m:
compiler/hlds_error_util.m:
compiler/hlds_goal.m:
compiler/hlds_llds.m:
compiler/hlds_out_pred.m:
compiler/hlds_rtti.m:
compiler/hlds_statistics.m:
compiler/inlining.m:
compiler/inst_check.m:
compiler/inst_test.m:
compiler/inst_user.m:
compiler/instance_method_clauses.m:
compiler/instmap.m:
compiler/intermod.m:
compiler/intermod_analysis.m:
compiler/interval.m:
compiler/introduce_exists_casts.m:
compiler/introduce_parallelism.m:
compiler/item_util.m:
compiler/lambda.m:
compiler/live_vars.m:
compiler/liveness.m:
compiler/llds.m:
compiler/llds_out_data.m:
compiler/llds_out_file.m:
compiler/llds_out_util.m:
compiler/lookup_switch.m:
compiler/loop_inv.m:
compiler/make.module_target.m:
compiler/make.util.m:
compiler/make_goal.m:
compiler/make_hlds_separate_items.m:
compiler/make_hlds_types.m:
compiler/mark_tail_calls.m:
compiler/mercury_compile_mlds_back_end.m:
compiler/middle_rec.m:
compiler/ml_accurate_gc.m:
compiler/ml_args_util.m:
compiler/ml_call_gen.m:
compiler/ml_closure_gen.m:
compiler/ml_code_gen.m:
compiler/ml_code_util.m:
compiler/ml_commit_gen.m:
compiler/ml_disj_gen.m:
compiler/ml_foreign_proc_gen.m:
compiler/ml_gen_info.m:
compiler/ml_lookup_switch.m:
compiler/ml_proc_gen.m:
compiler/ml_simplify_switch.m:
compiler/ml_switch_gen.m:
compiler/ml_tag_switch.m:
compiler/ml_unify_gen.m:
compiler/ml_unify_gen_construct.m:
compiler/ml_unify_gen_deconstruct.m:
compiler/ml_unify_gen_test.m:
compiler/ml_unify_gen_util.m:
compiler/mlds_to_c_data.m:
compiler/mlds_to_c_func.m:
compiler/mlds_to_c_global.m:
compiler/mlds_to_cs_class.m:
compiler/mlds_to_cs_file.m:
compiler/mlds_to_java_data.m:
compiler/mlds_to_java_file.m:
compiler/mlds_to_java_stmt.m:
compiler/mlds_to_java_type.m:
compiler/mmc_analysis.m:
compiler/mode_comparison.m:
compiler/mode_constraints.m:
compiler/mode_debug.m:
compiler/mode_errors.m:
compiler/mode_info.m:
compiler/mode_ordering.m:
compiler/modecheck_call.m:
compiler/modecheck_coerce.m:
compiler/modecheck_goal.m:
compiler/modecheck_unify.m:
compiler/modecheck_util.m:
compiler/modes.m:
compiler/module_cmds.m:
compiler/old_type_constraints.m:
compiler/opt_debug.m:
compiler/optimize.m:
compiler/options_file.m:
compiler/ordering_mode_constraints.m:
compiler/par_loop_control.m:
compiler/parse_item.m:
compiler/parse_string_format.m:
compiler/parse_tree_out_inst.m:
compiler/parse_tree_to_term.m:
compiler/parse_util.m:
compiler/pd_debug.m:
compiler/pd_info.m:
compiler/pd_util.m:
compiler/peephole.m:
compiler/polymorphism.m:
compiler/polymorphism_info.m:
compiler/polymorphism_lambda.m:
compiler/polymorphism_type_class_info.m:
compiler/polymorphism_type_info.m:
compiler/post_typecheck.m:
compiler/pragma_c_gen.m:
compiler/pred_name.m:
compiler/pred_table.m:
compiler/prog_item.m:
compiler/prog_rep.m:
compiler/prop_mode_constraints.m:
compiler/purity.m:
compiler/push_goals_together.m:
compiler/qual_info.m:
compiler/quantification.m:
compiler/rbmm.execution_path.m:
compiler/rbmm.m:
compiler/rbmm.points_to_analysis.m:
compiler/rbmm.points_to_graph.m:
compiler/rbmm.points_to_info.m:
compiler/rbmm.region_resurrection_renaming.m:
compiler/rbmm.region_transformation.m:
compiler/recompilation.used_file.m:
compiler/recompilation.version.m:
compiler/recompute_instmap_deltas.m:
compiler/resolve_unify_functor.m:
compiler/rtti.m:
compiler/rtti_out.m:
compiler/rtti_to_mlds.m:
compiler/saved_vars.m:
compiler/set_of_var.m:
compiler/simplify_goal_call.m:
compiler/simplify_goal_conj.m:
compiler/simplify_goal_disj.m:
compiler/simplify_goal_ite.m:
compiler/simplify_goal_scope.m:
compiler/simplify_goal_switch.m:
compiler/simplify_goal_unify.m:
compiler/simplify_info.m:
compiler/simplify_proc.m:
compiler/size_prof.m:
compiler/smm_common.m:
compiler/ssdebug.m:
compiler/stack_alloc.m:
compiler/stack_layout.m:
compiler/stack_opt.m:
compiler/stm_expand.m:
compiler/store_alloc.m:
compiler/structure_reuse.analysis.m:
compiler/structure_reuse.direct.choose_reuse.m:
compiler/structure_reuse.direct.detect_garbage.m:
compiler/structure_reuse.domain.m:
compiler/structure_reuse.indirect.m:
compiler/structure_reuse.lbu.m:
compiler/structure_reuse.lfu.m:
compiler/structure_sharing.analysis.m:
compiler/structure_sharing.domain.m:
compiler/superhomogeneous.m:
compiler/switch_detection.m:
compiler/switch_gen.m:
compiler/switch_util.m:
compiler/table_gen.m:
compiler/tabling_analysis.m:
compiler/term_constr_build.m:
compiler/term_constr_data.m:
compiler/term_constr_initial.m:
compiler/term_constr_main.m:
compiler/term_constr_main_types.m:
compiler/term_constr_util.m:
compiler/term_pass1.m:
compiler/term_traversal.m:
compiler/term_util.m:
compiler/trace_gen.m:
compiler/trailing_analysis.m:
compiler/transform_llds.m:
compiler/try_expand.m:
compiler/tupling.m:
compiler/type_assign.m:
compiler/type_ctor_info.m:
compiler/type_util.m:
compiler/typecheck.m:
compiler/typecheck_debug.m:
compiler/typecheck_errors.m:
compiler/typecheck_info.m:
compiler/unify_gen_construct.m:
compiler/unify_gen_deconstruct.m:
compiler/unify_proc.m:
compiler/unique_modes.m:
compiler/unneeded_code.m:
compiler/untupling.m:
compiler/unused_args.m:
compiler/unused_imports.m:
compiler/var_locn.m:
compiler/write_deps_file.m:
compiler/write_module_interface_files.m:
Conform to the changes above.
compiler/instmap.m:
Before code generation, the MLDS backend recomputes all nonlocal sets,
because the MLDS code generator needs them to contain exact information,
but the compiler's rules allow the nonlocal sets in goal_infos
to overapproximate the true nonlocals set. Since instmap_deltas can
contain a variable as a key only if that variable is in the nonlocals set,
this also involved calling instmap_delta_restrict to ensure this.
However, while the nonlocals sets of goal_infos *may* include variables
that are not true nonlocals, they typically do not do so. This diff
adds conditionally-enabled code to record information about this,
and the results show that 90+% of calls to instmap_delta_restrict
make no changes to the instmap_delta. This diff therefore also
special-cases the handling of such calls. The reason why I believe
this to be worthwhile is that in a deep profiled compiler run,
I observed that the instmap_delta_restrict predicate accounted for
about 1.4% of the call counts, and about 1.3% of the memory allocated.
library/map.m:
library/tree234.m:
Add the library predicates needed by the special case code.
Use predmode declarations in some other places.
NEWS:
Mention the new library predicates.
compiler/mercury_compile_main.m:
Invoke the predicate in instmap.m that, if statistics collection
was enabled, appends its results to a file.
tools/restrict_stats:
A script to summarize the contents of that file.
tools/bootcheck:
Delete support for checking out the tests directory alongside
the Mercury source tree. This was useful back when we used
CVS, but has not been relevant since the switch to git.
... during bootchecks in C# and Java grades by not comparing the generated
.cs and .java files of the few modules that are known to differ between
the two stages for understood reasons.
This reduces the size of the output of tools/bootcheck by 3700+ lines,
or about 25%.
Mmake.common.in:
Don't print the actions implementing namespace cleanliness checks.
To allow the attribution of any violations of the namespace rules,
print the name of the C module before any list of detected
nonallowed symbols.
To avoid mmake printing the actions for creating the .o files
that some of the check_namespace actions later check, rename
the affected object files .pseudo_o files, so that we can specify
a rule for them that is a copy of the rule for .o files, differing
only in not printing the compilation command.
Mark the files involved in check_namespace actions as dependencies
of .SECONDARY, which means that mmake does not automatically delete them
after building them as intermediate files. The reason for this is that
there is no way to tell make to delete intermediate files *silently*,
i.e. without writing out the rm command that deletes them.
To make up for this, tools/bootcheck now cleans up each directory
immediately after "mmake check_namespace" with "mmake clean_check",
which invokes mmake rules that do not print the rm commands.
This change does have the effect that these intermediate files *will*
hang around if the check_namespace target is every invoked manually.
However,
- we just about never run check_namespace in a directory manually, and
- when we do, a simple "mmake clean_check" will do the required cleanup.
scripts/Mmake.rules:
Move the vim tag line to its usual place at the top.
Replace old-school rules such as .m.err with their modern equivalents
(such as %.err: %.m).
scripts/Mmakefile:
Instead of printing the rules that make test_mdbrc, print only a
"making test_mdbrc" message.
runtime/Mmakefile:
Conform to the change of the name of a make variable in Mmake.common.in.
ssdb/Mmakefile:
Fix an old bug that something else in this diff tickled: make the
.depend target of each main module depend on SSDB_FLAGS, *not* just
the phony general "depend" target. This was a bug because tools/bootcheck
- copied across to stage 2 ONLY SSDB_FLAGS.in, and NOT SSDB_FLAGS,
- did NOT explicitly make SSDB_FLAGS from SSDB_FLAGS.in, even though
pretty much invocations of the Mercury compiler in this directory
have "--flags SSDB_FLAGS" as an implicit argument, and then
- built dependencies in the ssdb directory by invoking the top
Mmakefile's dep_ssdb target, which (indirectly) invokes
$(SSDB_LIB_NAME).depend.
Due to all the above, I don't actually know how tools/bootcheck
could ever build stage2/ssdb until now :-(
tools/bootcheck:
Invoke "mmake clean_check" after each "mmake check_namespace".
Change the code that explicitly builds the directory-specific
X_FLAGS file in each directory (which is invoked only when using
mmc --make) to actually build all such files, when previously
it built only a subset.
tests/invalid/Mmakefile:
tests/invalid_nodepend/Mmakefile:
tests/invalid_onlydepend/Mmakefile:
tests/invalid_options_file/Mmakefile:
tests/invalid_purity/Mmakefile:
tests/invalid_submodules/Mmakefile:
tests/stm/Mmakefile:
Fix an unintended consequence of replacing the .m.err rule in
scripts/Mmake.rules with %.err: %.m, which is that the %.err: %.m
rules in these mmakefiles became ineffective, because they appear
in the makefile we construct *after* the rule in scripts/Mmake.rules,
which specify a different action (the rules here return a nonzero
status in the *absence* of failure, which would be ridiculous
for the rule in scripts/Mmake.rules). Apparently, the %.err: %.m rules
overrode the rule in scripts/Mmake.rules while it had the old form,
but do not do so now it has the new form.
The fix is to make replace all the "%.err: %.m" rules in these Mmakefiles
with "$(PROGS:%=%.err): %.err: %.m" rules, which specify that they
override the generic rule for the .err files of the test cases
in each directory.
In invalid_purity/Mmakefile, fix a bug: -nodepend suffixes make sense
in only in the name of a *test*, not the name of a *program*, so
move such a suffix from a program name to a test name. Without this,
the program's .err file would be included in the list of .err files
to which the ".err: .m" rule applies under the wrong name.
In invalid_submodules/Mmakefile, fix the misleading names of some
make variables, and fix a misspelt directory name.
Standardize on "$(PROGS:%=%.err)" notation, replacing earlier instances
of "$(addsuffix .err,$(PROGS))". The reason for this is that when I tried
using "$addsuffix .int_err,$(PROGS))" in tests/invalid/invalid_make_int,
it did not work. (A google search on "gnu make addsuffix" did not yield
any clues as to why. Maybe you can only add suffixes that do not contain
underscores?)
This diff does not implement the option itself. The reason is that we want
to turn it off in library/LIB_FLAGS.in, and we can do that only when the
installed compiler knows about the option. This diff is therefore the first
step in the two-step bootstrapping process.
compiler/options.m:
Add a new option --warn-stdlib-shadowing, which, after the bootstrapping
step, will cause the compiler to warn about module names that could be
confused with the name of a module in the Mercury standard library.
Add a new option, --output-stdlib-modules, that tools/bootcheck can use
to test whether the compiler's list of Mercury standard library modules
is complete.
Rename the option name output_class_dir to output_java_class_dir
(internally only, leaving the user-visible name unchanged), to fit in
with the names of options related to C#, which have csharp in the name.
compiler/op_mode.m:
Add a new op_mode for --output-stdlib-modules.
compiler/mercury_compile_main.m:
Implement the new op_mode, using new code in library/library.m.
Simplify some existing code.
library/library.m:
Add an exported but undocumented predicate that mercury_compile_main.m
can use to
- find a list of all the Mercury standard library modules, and
- find out for each whether it is documented or not.
Reimplement the existing exported-but-undocumented predicate
in terms of the new one.
library/Mmakefile:
Add mmake targets that check whether the contents of MODULES_DOC and
MODULES_UNDOC match the output of mmc --output-stdlib-modules.
tools/bootcheck:
Use the new mmake targets to do that check.