Estimated hours taken: 0.2
Branches: main
compiler/Mercury.options:
Add some bug workarounds to get stage 2 to compile
at higher optimization levels.
For the various bug workarounds here, add a pointer
to the appropriate test case in the test suite (if
we have one.)
Estimated hours taken: 10
Branches: main
Fix several performance problems that arose when compiling predicates defined
by lots of facts, e.g. 16000 facts of the edge relation used in my recent
paper with Kostis on tabling. We couldn't use fact tables because they return
solutions in a different order, which would be OK semantically but which
invalidated the performance comparison we tried to make. I had to either fix
fact tables to use standard order or fix the performance problems of the usual
path of compilation. The latter is more generally useful, and reduces the
chances of any similar surprises.
The first performance problem was the quadratic complexity of always adding
clauses at the end of the clause list. The fix is to keep the list in reverse
order while it is being added to. This takes the time to read in the 16000-fact
predicate from 80+s to ~1s.
The second performance problem was our use of generate/test to check whether
any clause had impure code when copying the clauses to procs. Since we don't
have tail recursion for model_non code, this couldn't reuse stack frames, and
as a result ran at memory speed, not cache speed. The fix is to use an explicit
recursive predicate. (A better fix would be to implement proper tail recursion
for model_non code, but that would take significantly longer.) This fix
doesn't make much difference in the usual grades, but makes a significant
difference in debug grades.
The third performance problem is the quadratic or worse behavior of the mode
checker when merging the instmaps of disjuncts at the ends of large
disjunctions. With our old setup, this was inevitable, since given a bunch of
facts of the form
edge(1, 2).
edge(2, 3).
edge(3, 4).
...
etc, the instmap delta the mode checker builds for HeadVar__1 for the
disjunction of clauses is free -> bound(1; 2; 3; ...). The solution to that
is to add a new pragma, mode_check_clauses, that causes the mode checker
to check each clause individually, and to create a simple free -> ground
(or whatever the declared mode calls for) instmap delta for HeadVar__1.
We should consider making this pragma be implied for predicates defined
by lots of facts, but this diff does not do that. This change takes the
time to modecheck that 16000-fact predicate from ~360s to ~5s.
Theoretically, another way of tackling the problem would have been to
introduce widening, in which any list of functors inside "bound()" whose
length was above the threshold would be replaced by "ground", if the arguments
of the functors themselves were bound. However, that change would be much more
complex, and its behavior would be hard for users to predict. In a future
constraint-based mode system with separate passes for computing
producers/consumers and for computing the set of function symbols a
variable can be bound to, we could simply disable the latter pass
for predicates like this.
There are at least three other performance problems left. The fourth is
the same as the third, except for unique mode checking. The fifth is in
simplification, and the sixth is in equiv_type_hlds. I'll work on those next.
compiler/hlds_pred.m:
Instead of exposing the clause list part of the clause_info, make it
an abstract type. Make the abstract type keep the reverse list when
adding clauses to the list, the forward list when the later parts
of the compiler manipulate the clause list, and both when it is
convenient to do so. Add the predicates necessary to manipulate
this more complex representation. Move the code manipulating
clauses_infos into its own implementation section, next to its
declarations.
Add a new mode_check_clauses predicate marker, which records the
presence of the new pragma.
Fix departures from our coding standard.
compiler/clause_to_proc.m:
Replace the generate/test code with an explicit loop, as
mentioned above.
compiler/prog_data.m:
Add the new pragma.
compiler/prog_io_pragma.m:
Recognize the new pragma.
compiler/modes.m:
Implement separate mode checking of clauses.
Convert the file to use four-space indentation to reduce the number of
bad line breaks. Give some predicates more meaningful names.
Use error_util to print some error messages. Fix departures from
our coding standard.
compiler/make_hlds.m:
compiler/hlds_out.m:
compiler/intermod.m:
compiler/mercury_to_mercury.m:
compiler/module_qual.m:
compiler/modules.m:
compiler/recompilation.version.m:
Handle the new pragma.
compiler/*.m:
Conform to the change in hlds_pred.m and/or prog_data.m.
In some cases, convert files to four-space indentation.
tests/hard_coded/mode_check_clauses.{m,exp}:
A new test case to check that the mode_check_clauses pragma works
correctly.
tests/hard_coded/Mmakefile:
Enable the new test case.
Estimated hours taken: 0.5
Branches: main
compiler/equiv_type_hlds.m:
compiler/mercury_compile.m:
Convert these modules to four space indentation to reduce the number
of bad line breaks. In equiv_type_hlds, consistently use `or` instead
of if-then-elses with the same effect. Make the formatting more
consistent. Format comments according to our current guidelines.
Estimated hours taken: 4
Branches: main
compiler/modules.m:
When determining the type constructors that are needed in the
implementation section of an interface file, unfold equivalence
types until no more type constructors are added, rather than
just unfolding one level.
Previously, there could be equivalence types referred to in the
implementation section which would not actually be defined anywhere
visible. Later processing of all type definitions may have led to
map lookup failures.
Estimated hours taken: 4
Branches: main
Reduce the amount of clutter on mgnuc command lines by moving arguments that
are always the same for a given directory into a file that is always consulted
by mgnuc in the current directory.
scripts/mgnuc.in:
Always include as C compiler arguments the contents of a file named
.mgnuc_copts in the current directory, if it exists. (It is named
.mgnuc_copts instead of .mgnuc_opts because it may not contain
general mgnuc options, such as --no-mercury-stdlib-dir.)
Mmake.workspace:
Comment out the additions of search paths to CFLAGS.
*/Mmakefile:
Delete the additions of search paths to CFLAGS.
*/.mgnuc_copts:
New files containing the directory-specific search paths, and in some
cases the required macro definitions. These replace what was taken out
of Mmake.workspace and */Mmakefile. In some cases, the old search paths
included inappropriate directories; the .mgnuc_copt files don't.
tests/.mgnuc_copts.ws:
New files containing the directory-specific search paths; bootcheck
makes tests/.mgnuc_copts from it.
*/.nocopyright:
Don't require copyright notices in .mgnuc_copts files.
tools/bootcheck:
Copy the various .mgnuc_copts files from the stage1 to stages 2 and 3.
They aren't needed in stage3 right now, but that may change.
Create tests/.mgnuc_copts.
browser/util.m:
Delete an unused and inappropriate #include.
scripts/Mmake.rules:
Use a single invocation of mkdir -p to create all subdirectories
needed by Java. Update a piece of documentation.
scripts/Mmakefile:
Reorganize the process of invoking config.status to avoid invoking
it on inappropriate files, and to ensure the right permissions
on the files it is invoked on.
scripts/prepare_tmp_dir_grade_part:
Copy the .mgnuc_copts files when populating tmp_dir.
Estimated hours taken: 4
Branches: main
Fix a problem reported by Michael Day. When a piece of code had several updates
to the fields of a cell in a row, we were constructing all the intermediate
versions of the cell. With this change, we now construct only the final one.
compiler/simplify.m:
The cause of the problem was simplify's use of the cannot_flush
predicate from goal_form.m. Each field update consists of a pair of
deconstruct/construct unifications inside a removable barrier scope,
but cannot_flush assumed that any goal not on its small approved list
may cause a stack flush. Simplify therefore told common.m to throw away
its list of known cells when emerging from the scope.
The fix is to replace the use of cannot_flush with a new predicate
that is explicitly written for the needs of simplify, which is not
too conservative. The concern about increasing the set of output
variables of an existentially quantified scope is now addressed
only in simplify__goal_2 when processing scope goals, not in two
places (redundantly) as before.
Simplify the logic of simplify_info_maybe_clear_structs.
Simplify the mechanism for initializing simplify_infos.
Use more descriptive variables names in simplify__pred.
Switch to four-space indentation to reduce the number of bad line
breaks.
compiler/pd_util.m:
Conform to the new mechanism for initializing simplify_infos.
compiler/goal_form.m:
Delete the cannot_flush predicate, since it now has no users.
compiler/common.m:
Clean up some code. Break up an excessively large predicate, factor
out some common code, and make comments conform to our conventions.
Estimated hours taken: 1
Branches: main
compiler/handle_options.m:
scripts/final_grade_options.sh-subr:
Make only .debug imply .tr, not .decldebug. Declarative debugging
requires retries, which work in trailing grades only if the entity
that does the trailing is prepared for them.
configure.in:
Make the decldebug grade installed when enabled be the one without .tr.
Estimated hours taken: 1
Branches: main
compiler/modules.m:
The definitions of $(ALL_MCIFLAGS) and $(ALL_MCSIFLAGS) are almost
identical (e.g. they both include MCFLAGS) and their differences
are intentional. Therefore include only the latter on the command line.
Including both, as we used to do, lead to duplicate occurrences of
"--flags COMP_FLAGS" on command lines when making short interface
files.
Estimated hours taken: 1
Branches:
Provide mechanisms for measuring individually the main sources of overheads
of minimal model tabling. This was required for the paper I have just finished
with Kostis.
runtime/mercury_stacks.h:
Allow the inclusion of the extra nondet stack slot needed in
minimal-model grades to be added even in non-minimal-model grades.
compiler/options.m:
Add two new options, --disable-mm-pneg and --disable-mm-cut, that
ask the code generator not to generate code for manipulating the pneg
stack and the cut stack respectively. Add two new options for internal
use by the compiler only, that say whether the compiler should emit
code for handling the pneg stack and cut stack respectively. None of
the options is documented, since they are not for users.
compiler/handle_options.m:
Set the options to ask for the code for the pneg and cut stacks in
minimal-model grades, unless the relevant disable option is given.
compiler/code_info.m:
compiler/ite_gen.m:
Instead of testing the minimal model grade option to see whether to
emit code for the cut stack and pneg stack respectively, test the
relevant new option.
Estimated hours taken: 0.5
Branches: main
compiler/check_typeclass.m:
Add a verbose error message to explain what is meant by a type
variable being "determined" by the arguments of a predicate, function
or constructor.
Estimated hours taken: 1.5
Branches: main
Relax the restriction on the constraints on existentially quantified data
structures. The type variables in constraints must be determined by the
constructor arguments and functional dependencies, but don't necessarily
have to appear directly in the constructor arguments.
compiler/check_typeclass.m:
Implement a check for type declarations which is analogous to the
existing check for pred/func declarations.
compiler/prog_io.m:
Relax the existing restriction, which was applied at parse-time.
Now we just check that all existentially quantified type vars appear
somewhere, either in the arguments or in the constraints.
Remove an XXX comment that asked whether the check that all
constrained variables were existentially quantified was overly
restrictive. The answer is no: we don't support existential
constraints with universal arguments, and we won't support it in
the foreseeable future.
tests/invalid/Mmakefile:
tests/invalid/fundeps_unbound_in_ctor.err_exp:
tests/invalid/fundeps_unbound_in_ctor.m:
New test case for the new and changed error messages.
tests/invalid/type_vars.err_exp:
Updated test case.
tests/valid/Mmakefile:
tests/valid/fundeps.m:
New test case.
Estimated hours taken: 0.1
Branches: main
compiler/hlds_out.m:
Fix the output of functional dependencies in the HLDS dump to more
closely match the correct Mercury syntax. I forgot to update this
part when the proposed syntax was changed.
Estimated hours taken: 0.5
Branches: main
compiler/hlds_goal.m:
Clean up the formatting of comments in this module.
Add a comment about why there is duplicate information
in the representation of unifications.
Use unexpected/2 in preference to error1.
s/creater/creator/
compiler/notes/coding_standards.html:
Fix a misformed tag.
Estimated hours taken: 0.5
Branches: main, release
compiler/module_qual.m:
Check for variables used as constructors when module qualifying types
and insts. In both cases this is currently illegal, so we report a
more sensible error message than we would otherwise get.
compiler/prog_type.m:
Export a test to check if a type uses a variable as a constructor.
tests/invalid/Mmakefile:
tests/invalid/kind.err_exp:
tests/invalid/kind.m:
Test case.
Estimated hours taken: 12
Branches: main
Remove most of the junk from the command lines executed by make when building
the compiler and by bootcheck when building test cases. We do this by moving
the junk into files consulted via the --flags option.
After this change, it is actually possible to see in a glance not just which
files are being compiled but also with which options. The size of the output
(measured in bytes) from a bootcheck is now only about 40% of what is was
before.
configure.in:
Remember the path to the bootstrap compiler and the flags it should be
invoked with separately. Put the flags into the FLAGS files in various
directories.
Test whether the default install directory actually exists, so that
the -L and -R linker options referring to this directory are passed
to the C compiler only if it does.
Mmake.common.in:
Comment out a bunch of additions of MCFLAGS, the ones whose contents
are now in FLAGS files.
Conform to the changes in configure.in.
Add a template rule for the dependencies of the FLAGS files.
Mmake.workspace:
Comment out a bunch of additions of MCFLAGS, the ones whose contents
are now in FLAGS files. In some cases, add references to the FLAGS
files.
Mmakefile:
When rebuilding Mmake.common, rebuild only Mmake.common, not all files
created by configure.
analysis/ANALYSIS_FLAGS.in:
browser/MDB_FLAGS.in:
compiler/COMP_FLAGS.in:
deep_profiler/PROF_FLAGS.in:
library/LIB_FLAGS.in:
mdbcomp/MDBCOMP_FLAGS.in:
profiler/DEEP_FLAGS.in:
slice/SLICE_FLAGS.in:
tests/TESTS_FLAGS.in:
Add these files, which each contain the junk flags (the flags which are
the same on every invocation and mostly just clutter up compiler
command lines) that are needed on each compiler invocation in the
relevant directory. Besides the results of configuration (word size
etc), and the paths to other parts of the system, these files mostly
control which warnings are enabled.
Restrict the list of directories in -I options to what is sensible;
for example, don't specify -I../analysis in the deep_profiler
directory.
*/.nocopyright:
Don't require copyright notices in FLAGS files, since that would make
them invalid.
library/INTER_FLAGS:
Add this file, which contains the flags enabled with intermodule
optimization.
tests/WS_FLAGS.ws:
Add this file. Unlike the .in files, which processed by config.status
based on the results of autoconfiguration, this one is processed to
specify the location of the workspace being tested.
analysis/Mmakefile:
browser/Mmakefile:
compiler/Mmakefile:
deep_profiler/Mmakefile:
library/Mmakefile:
mdbcomp/Mmakefile:
profiler/Mmakefile:
tests/Mmakefile:
Include the relevant directory's FLAGS file on the command line, to
replace all the additions to MCFLAGS in ../Mmake.common and in
../Mmake.workspace, and in some cases, the directory-specific Mmakefile
itself.
Build the directory's FLAGS file before executing the depend target,
since most compiler options beyond --generate-dependencies come from
there.
Delete the FLAGS files generated by config.status when doing "make
clean".
tests/Mmakefile:
Allow the environment to define DIFF_OPTS.
runtime/Mmakefile:
Use an option to tell config.status what to rebuild, not some
environment variables.
tests/invalid/Mercury.options:
For two test cases, reset an option that is set in tests/WS_FLAGS,
to match the options the affected tests were compiled with before.
tests/invalid/*.err2:
Update these expected files to account for the use of error_util
in error messages by previous changes to the compiler. These expected
output files are used only with --use-subdirs.
tests/warnings/Mmakefile:
For all test cases, reset an option that is set in tests/WS_FLAGS,
to match the options the tests were compiled with before.
scripts/prepare_tmp_dir_grade_part
Copy the flags files when creating the subdirectories of tmp_dir.
scripts/mgnuc.in:
Provide a mechanism, a per-directory .mgnuc_opts file, for specifying
the options that are required for every C file in a directory. The
intention is to use this for -I../library etc, but this is not done
yet; one thing at a time.
tools/bootcheck:
Copy the FLAGS files when creating stage2 and stage3.
Don't specify the compiler options that are now in FLAGS files.
Fill in the location of the workspace in tests/WS_FLAGS before running
the tests.
Provide a mechanism (a file ~/.bootcheck_diff_opts) to allow the user
to specify what options to invoke diff with.
Move the setting of MMAKE_USE_SUBDIRS and MMAKE_USE_MMC_MAKE after
we have built stage1, and always copy the profilers if --use-subdirs
is set. The old ways of doing things caused problems if bootcheck
was given --use-subdirs but stage1 doesn't use subdirs: the bootcheck
modified the stage1 slice, profiler and deep_profiler directories.
Estimated hours taken: 0.5
Branches: main
compiler/exprn_aux.m:
Use state variables to represent substitution counts.
compiler/unify_gen.m:
Switch to four-space indentation to avoid lots of code being squeezed
against the right margin. Make other changes to conform to our coding
standards.
compiler/var_locn.m:
Make comments conform to our coding standards.
Estimated hours taken: 0.5
Branches: main, release
Workaround a problem where the compiler generates private
interfaces for nested submodules even if the submodules
themselves, have no children. This is currently a bit
of an annoyance because realclean won't delete these
extraneous .int0 files. mmc --make also generates these
extra .int0 files except that it does clean them up.
compiler/modules.m:
Make sure that any extra .int0 files that are
being erroneously created are also cleaned up.
(I've left the correct code in, commented out with
a note to say that it should be uncommented when this
is fixed).
Fix a couple of typos.
Estimated hours taken: 24
Branches: main
Add two new command line tools "mslice" and "mdice", which manipulate slices
and dices respectively. The functionality of "mdice" duplicates the
functionality of mdb's current "dice" command, while the functionality of
"mslice" is new.
runtime/mercury_trace_base.[ch]:
When generating trace count files, include information about the
context of each execution count. While mdb has access to this
information in the running program, mslice and mdice do not.
In any case, the code in mdb for looking up this information was
terribly inefficient.
Provide a mechanism for recording all execution counts, even the zero
ones, for use in coverage testing. This mechanism is not used yet.
Put a header on trace counts files, to make them recognizable as such.
Make this header indicate whether we are including zero trace counts.
runtime/mercury_wrapper.c:
Provide a flag in MERCURY_OPTIONS for turning on recording of
zero execution counts.
browser/dice.m:
mdbcomp/slice_and_dice.m:
Move most of the code of browser/dice.m to mdbcomp/slice_and_dice.m,
much modified; browser/dice.m is now empty. The modifications are
as follows.
Factor out the code for reading dices, since dices are useful
independent of mdb's dice command.
Generalize the code for computing dices to allow either or both
of the slices being subtracted to be specified as the union of
one or more trace counts files.
Add two more sort conditions for comparing the execution counts
in two slices: ascending and descending versions of simple execution
count differences.
For each operation we have so far performed on dices, add code
for performing that operation on slices.
browser/mdb.m:
Delete the include of dice.m, since it is now empty.
Delete a duplicate include_module of term_rep, and delete the now
unnecessary include_modules of set_cc and tree234_cc.
mdbcomp/mdbcomp.m:
Add slice_and_dice.m as a submodule.
mdbcomp/trace_counts.m:
Provide a mechanism to allow a slice to be specified as coming not
from a single trace count file but from the union operation on a set
of trace count files.
Convert to four-space indentation to eliminate some excessively
indented lines.
slice/mdice.m:
slice/mslice.m:
The main modules of two new commands. Their functionality is almost
entirely in mdbcomp/slice_and_dice.m and mdbcomp/trace_counts.m.
slice/Mmakefile:
New Mmakefile for building mslice and mdice. It is modelled on
profiler/Mmakefile.
slice/Mercury.options:
Empty file, for use in the future.
slice/.nocopyright:
Don't require copyright notice in Mercury.options.
Mmakefile:
Process the slice directory at appropriate points when processing
other directories.
compiler/tupling.m:
Conform to the updated interface of mdbcomp/trace_counts.
library/list.m:
Add versions of list__map for some more arities, for use in the code
above.
trace/mercury_trace_internal.c:
Generalize the code for specifying dices to allow either or both
of the slices being subtracted to be specified as the union of
one or more trace counts files.
Fix several places where we weren't checking the return value of
malloc. Fix two places where we could conceivably free strings that
were still alive. Fix some places where we could pass NULL strings
to Mercury code, and some places where we could free NULL pointers
(which, once upon a time, was not guaranteed to work on all platforms).
Use existing functions such as MR_copy_string where appropriate.
tests/run_one_test:
Fix two small bugs in this script: make the filenames more user
friendly, and make sure that gzip isn't asked to overwrite an
existing file, since that causes it to ask a question on stdout
and to wait for an answer.
tools/bootcheck:
Copy or link the slice directory into stage 2. Rename the
--copy-profiler option as --copy-profilers, since it now copies three
directories containing performance engineering tools: profiler,
deep_profiler and slice.
Estimated hours taken: 1
Branches: main, release
Fix compilation of the standard library in grade java.
Compiling the library from Mercury -> Java now works again.
Compiling the resulting Java code -> bytecode is still broken
because of problems in the Java version of the runtime.
compiler/post_term_analysis.m:
Don't look up hlds_type_defns for builtin types that may
not have them (the termination properties for the special
preds for these types are known anyway).
library/term_size_prof_builtin.m:
Fix errors in the default Mercury clauses for some
procedures in this module; there were some module imports
and purity annotations missing.
Estimated hours taken: 3
Branches: main
compiler/typeclasses.m:
Use the constraint parameters as "head type parameters" when calling
'eliminate_constraint_by_class_rules'. This fixes a bug whereby
constraints were being reduced even when unsatisfiable, which would
result in polymorphism generating code that was not mode correct.
Also move a call to 'apply_rec_subst_to_constraints' one step up in
the call graph. This puts both calls to this predicate at the same
level, and thereby makes the code easier to understand.
Only call 'apply_rec_subst_to_constraints' on the second occasion
if the bindings have actually changed since the first call. This
is just for the purposes of optimisation.
tests/invalid/Mmakefile:
tests/invalid/unsatisfiable_super.err_exp:
tests/invalid/unsatisfiable_super.m:
New test case to test the bug fix.
Estimated hours taken: 0.1
Branches: main, release
compiler/options.m:
doc/user_guide.texi:
The name of the `--use-local-vars' option does not match
its description, which describes `--no-use-local-vars'.
Estimated hours taken: 3
Branches: main, release
Fix a bug report by Michael Day. When using mmc --make
to build .opt files the compiler wasn't responding to
SIGINT and SIGTERM.
compiler/make.module_target.m:
Build intermodule-optimization interfaces
in a forked process when when using mmc --make
so that it responds to SIGINT and SIGTERM.
Estimated hours taken: 4
Branches: main and 0.12
Fix the valid/unused_args_test2 failing test case. map.overlay_large_map
was buggy.
compiler/Mmakefile:
Include Mmake.compiler.params so that tracing can easily be turned
on for the whole compiler directory.
library/map.m:
Fix overlay_large_map. It was calling the wrong helper predicate.
Estimated hours taken: 3
Branches: main
Extend the promise_<purity> scopes.
compiler/hlds_goal.m:
Added some comment lines to the scope_reaon documentation to make it
clear to which constructor each comment pertains.
compiler/prog_io_goal.m:
compiler/purity.m:
library/ops.m:
Added promise_impure as a scope.
Added promise_{pure,semipure,impure}_implicit scopes. These are
identical to promise_{pure,semipure,impure} respectively, except that
purity annotations on goals within the scope are optional.
Purity warnings are no longer issued if the scope body has a lesser
impurity than the promised purity. To make this work, I've added a
field `implicit_purity' to the purity_info constructor, which is either
`make_implicit_promises' or `dont_make_implicit_promises'. If the
latter, then purity errors and warnings are suppressed.
doc/reference_manual.texi:
Document the new syntax.
tests/hard_coded/Mmakefile:
tests/hard_coded/impure_foreign2.m:
tests/hard_coded/impure_foreign2.exp:
tests/hard_coded/impure_foreign3.m:
tests/hard_coded/impure_foreign3.exp:
tests/hard_coded/test_promise_impure_implicit.m:
tests/hard_coded/test_promise_impure_implicit.exp:
Added test cases.
Estimated hours taken: 0.5
Branches: main
Minor cleanups for mmc --make. There are no algorithmic
changes.
compiler/make.m:
compiler/make.dependencies.m:
compiler/make.module_dep_file.m:
compiler/make.module_target.m:
compiler/make.program_target.m:
compiler/process_util.m:
Bring these modules into line with our current coding
standard.
Estimated hours taken: 0.5
Branches: main
Fix up some minor issues I noticed in saved_vars.m while
we were debugging the unused_args_test problem. There
are no changes to any algorithms.
compiler/saved_vars.m:
Don't export the predicate saved_vars_proc_no_io/4 from
this module since it isn't used anywhere else.
Fix a couple of spots where the 79 character column
limit has been exceeded.
Re-position the comments in accordance with our current
coding standard.
s/opprtunities/opportunities/
Estimated hours taken: 1
Branches: main
compiler/mode_errors.m:
When printing error messages involving lists of insts, put each inst
on a line of its own. Since insts can be deeply nested, it could be
difficult to divide the generated humongous lines into the original
sequence of insts without this diff.
tests/invalid/*.err_exp:
Expect the new format of error messages.
Estimated hours taken: 0.2
Branches: main
compiler/notes/compiler_design.html:
Update the design document after the recent changes to add functional
dependencies and split up typecheck.m.
compiler/check_typeclass.m:
Fix a typo.
Estimated hours taken: 0.1
Branches: main
compiler/typecheck_errors.m:
Back out my change to the formatting of error messages
about missing clauses - it wasn't correct.
tests/invalid/types.err_exp2:
Update the expected output of this test case to take
account of the fact that we now check for for definitions
corresponding to abstract type declarations.
Estimated hours taken: 3
Branches: main
Split typecheck.m into smaller modules.
compiler/typecheck.m:
The main typechecking pass.
compiler/typecheck_errors.m:
New module. Error messages and debugging messages.
compiler/typecheck_info.m:
New module. The typecheck_info and type_assign data structures, plus
some basic predicates.
compiler/typeclasses.m:
New module. The context reduction and improvement rules.
compiler/check_hlds.m:
Register the new modules.
compiler/check_typeclass.m:
Call typeclasses instead of typecheck to do context reduction.
compiler/prog_type.m:
Move strip_builtin_qualifiers_from_type(_list) to here.
compiler/hlds_data.m:
Define restrict_list_elements here instead of in typecheck.m and
check_typeclass.m.
Estimated hours taken: 10
Branches: main, release
Check that abstract type declarations do actually have a
corresponding definition somewhere in the module. Emit
an error message if an abstract type declarations does not
have a corresponding definition.
compiler/post_typecheck.m:
Check that abstract type declarations have a corresponding
definition somewhere in the module. Emit an error message
if they do not.
compiler/gcc.m:
Comment an abstract type declaration that does not have
a corresponding definition.
compiler/typecheck.m:
Module qualify the names of predicates in the error message
about predicates have no clauses.
tests/invalid/Mmakefile:
tests/invalid/type_with_no_defn.m:
tests/invalid/type_with_no_defn.err_exp:
Add a test case for the above.
tests/invalid/*:
Update test cases and expected error outputs as
necessary.
Estimated hours taken: 0.1
Branches: main
compiler/check_typeclass.m:
Module qualify calls to list.member so that the compiler
builds with intermodule-optimization enabled.
Estimated hours taken: 240
Branches: main
Implement functional dependencies for the typeclass system. The implementation
has two major parts. First, some of the basic checks of constraints are
relaxed. These used to occur in make_hlds but that functionality has now been
moved to check_typeclass. We also add a range of new tests to ensure that
the FDs are used correctly. Second, an "improvement" pass to context
reduction is added. This looks for constraints which match certain rules,
and when it finds them updates the current bindings. The general rule is
that type variables become more instantiated, but only in a way which provably
does not affect the satisfiability of the constraints.
XXX The plan for this change is to put the context reduction into a new
module check_hlds.typeclasses.m, but I have left the code in typecheck.m
for the moment because the diff will be easier to review that way. Moving
to the new module will also remove the problem of one particular function
being implemented in both typecheck and hlds_data, which is flagged by an XXX
in the code.
XXX the check for consistency of instances is not yet complete. We check all
visible instances, but not instances that are only present at link time. We
could check these in a similar way to the check for overlapping instances
(that is, by defining a symbol that will conflict and cause a link error
if there are overlapping instances), but in the long run a better solution
will be required. Producing this is left for a later change.
compiler/check_typeclass.m:
Check for ambiguities in typeclass constraints here, rather than
make_hlds. We check by calculating the closure of the bound type
variables under the induced functional dependencies. This pass
is merged in with the already existing pass that checks the
quantifiers on constrained type variables.
Check instances for range-restrictedness and for consistency.
When checking for cycles in the typeclass hierarchy, build up the
set of ancestors of a class which have FDs on them. This set is
used when searching for opportunities to apply improvement rules
during type checking.
compiler/hlds_data.m:
Define hlds_class_fundeps and add it to to hlds_class_defn.
Add a field to hlds_class_defn to store the ancestors which have
functional dependencies.
Define the type 'instance_id', which is just an integer. This is
what is used in proofs to identify instances.
In hlds_constraints and in constraint_ids, use the terms 'assumed'
and 'unproven' rather than 'existential' and 'universal'. The latter
are confusing to use since the treatment of constraints differs
depending on whether the constraint is on the head or the body of a
clause.
Add a field to the hlds_constraints for redundant constraints. These
are constraints that have either already been reduced or don't need to
be reduced, which may contribute to improvement of types.
Define some new predicates for initialising and updating the
hlds_constraints.
compiler/type_util.m:
Accommodate the change to hlds_constraints.
compiler/hlds_out.m:
Output the functional dependencies.
compiler/intermod.m:
Reconstruct a functional dependency from the HLDS, for outputting.
compiler/make_hlds.m:
Convert functional dependencies from parse tree form and add them
to the HLDS.
Check that functional dependencies are identical in subsequent
definitions of the same typeclass.
Don't check for ambiguity here. That is now done in check_typeclass.
compiler/mercury_to_mercury.m:
Output functional dependencies in typeclass declarations.
compiler/prog_data.m:
Define prog_fundeps and add them to the parse tree.
compiler/prog_io_typeclass.m:
Parse functional dependencies on typeclass declarations.
compiler/typecheck.m:
Require the class_table to be passed to
reduce_context_by_rule_application, since the functional dependencies
are stored here. Also thread the bindings argument through, since the
bindings may be improved by context reduction. Save the resulting
bindings in the type_assign.
Instead of passing a list of assumed constraints and threading the
unproven constraints through context reduction, thread through a
hlds_constraints structure. This contains more information about
redundant constraints than just the two lists.
Extend context reduction with two new passes. The first applies the
"class" FD rule, which tries to find two constraints which are
identical on the domain of some FD, and then unifies the range
arguments. The pair of constraints are either both redundant
constraints, or one redundant constraint and one assumed constraint.
The second applies the "instance" FD rule, which for each constraint
tries to find an instance which is more general on the domain
arguments. It then binds the instance arguments and unifies the
range arguments of the instance with those of the constraint.
When calculating the head_type_params for a predicate, include all
variables that occur in universal constraints, since these may not
necessarily occur in the arguments.
Rename some variables: use variable prefixes "Pred" and "Parent" for
types that are from the callee or that have been renamed apart
respectively. This follows the same naming scheme used in
polymorphism.
Remove the headtypes/0 type, and use head_type_params/0 throughout.
Add a new kind of cons_error for using "new" on a constructor that is
not existentially typed. We check for this situation in
convert_cons_defn, and report it in report_cons_error.
Pass a value to convert_cons_defn indicating whether the constraints
should be flipped or not, and whether the context is a constructor
that uses 'new'. We flip the constraints here rather than after the
fact, since creating the constraints now requires some extra
processing to be done, and we don't want to have to redo that
processing.
Add a constant function that specifies whether variable numbers should
be displayed as part of the debugging output. This is currently set
to 'yes' but the previous behaviour can be achieved by changing the
value to 'no'.
doc/reference_manual.texi:
Document the new feature.
NEWS:
Announce the new feature.
tests/*:
New test cases.
compler/*.m:
Minor changes related to the above.
compiler/error_util.m:
Fix comment grammar.
compiler/prog_type.m:
Fix an incorrect comment.
Estimated hours taken: 1.5
Branches: main
Clean up lp.m and bring it more into sync with the corresponding
parts of lp_rational.m. The one algorithmic change is to replace
two closures that where called by an all solutions predicate with a
single iterative predicate that does the same thing.
Shift lp.m from the transform_hlds package into the libs package.
compiler/lp.m:
Shift to 4-space indentation throughout.
Use state variables throughout and rearrange argument
orders where necessary.
Use predmode syntax throughout.
Add field names to several of the major data structures
in this module.
Standardize variable names.
s/__/./ throughout.
Other minor formatting changes.
compiler/transform_hlds.m:
compiler/libs.m:
Move the lp module from the transform_hlds package to the
libs package. It doesn't really have anything to do with
the HLDS.
compiler/term_pass1.m:
compiler/notes/compiler_design.html:
Minor changes to conform to the above.
Estimated hours taken: 2
Branches: main, release-0.12
Only allow existential constraints to constrain existentially quantified
type variables. Likewise only allow universal constraints to constrain
universally quantified type variables.
We previously didn't check these conditions, and in fact the reference
manual allowed otherwise. However, the implementation did not support
existential constraints on universally quantified type variables, and
will not do so for the foreseeable future. The implementation does support
universal constraints on existentially quantified variables, however these
are not useful since no caller will ever be able to satisfy the constraints.
compiler/check_typeclass.m:
Check these conditions as part of typeclass checking.
Also return a bool from the recently added check for concrete
instances, indicating whether errors were found or not.
compiler/error_util.m:
compiler/hlds_error_util.m:
Add a couple of utility functions for constructing error messages.
compiler/mercury_compile.m:
Stop compilation after checking typeclasses if errors were encountered.
If the above conditions are not met then typechecking may abort.
doc/reference_manual.texi:
Document the condition on typeclass constraints.
tests/invalid/Mmakefile:
tests/invalid/quant_constraint_1.err_exp:
tests/invalid/quant_constraint_1.m:
tests/invalid/quant_constraint_2.err_exp:
tests/invalid/quant_constraint_2.m:
Test cases for the new error messages.
tests/invalid/unbound_type_vars.err_exp:
Update this test case.
Estimated hours taken: 0.5
Branches: main
Make a number of minor cleanups to the exception analysis module.
There are no changes to any algorithms.
compiler/exception_analysis.m:
Use 4-space indentation throughout.
Remove the comment about needing to add annotations
for foreign_procs; they've been added.
Remove some unnecessary imports.
s/Module/ModuleInfo/ throughout.
Other minor changes to formatting throughout.
Estimated hours taken: 4
Branches: main
Fix a bug where state variables in the variable list of a
promise_equivalent_solutions goal were not handled.
compiler/prog_data.m:
Adjust the promise_equivalent_solutions data constructor to
include extra fields for "dot" and "colon" state variables in
the variable list.
compiler/make_hlds.m:
Adjust the transformation of promise_equivalent_solutions goals
to ensure that !.X and !:X in the variable list correspond to the
"initial" and "final" versions, respectively, of state variable X in
the transformed goal body.
compiler/mercury_to_mercury.m:
compiler/module_qual.m:
compiler/prog_io_goal.m:
compiler/prog_util.m:
Adjust for the new promise_equivalent_solutions constructor fields.
compiler/prog_io_util.m:
Add parse_vars_and_state_vars/4 to handle state variables
appearing in the variable list of a promise_equivalent_solutions
goal.
tests/hard_coded/Mmakefile:
tests/hard_coded/promise_equiv_with_svars.m:
tests/hard_coded/promise_equiv_with_svars.exp:
Added test case.
Estimated hours taken: 0.1
Branches: main, release
compiler/Mercury.options:
Workaround a bug that is preventing the compiler from
bootstrapping at -O5 with --intermodule-optimization.
(Previously we had to compile this module at -O0 because
of the loop invariant hoisting bug, which was why this
hasn't shown up until now).
Estimated hours taken: 3
Branches: main, release
Have the compiler emit an error if an abstract instance declaration
in the interface of a module does not have a corresponding concrete
instance declaration in the implementation of the module. Currently
the compiler just ignores this situation which leads to C compilation
errors in the MLDS grades and link-time errors in the LLDS grades.
compiler/check_typeclass.m:
Emit an error message if an abstract instance declaration
in the interface of a module does not have a corresponding
concrete instance in the implementation.
Use unexpected/2 in place of error/2.
Fix the positioning of a few comments.
Add an end_module declaration.
compiler/hlds_data.m:
Make the instance_table type a multi_map (which it
already effectively was).
tests/invalid/Mmakefile:
tests/invalid/missing_concrete_instance.m:
tests/invalid/missing_concrete_instance.err_exp:
Test case for the above.
For review by anyone.
Estimated hours taken: 10
Branches: main, release
Do not allow non-abstract instance declarations to occur in module
interfaces. Emit an error message if this occurs.
Fix the formatting of some error messages regarding typeclasses
and instances.
compiler/check_typeclass.m:
Use error_util to generate the error messages from this module.
This fixes a problem where the printing of sym_names and arities
differed in the same error message.
compiler/error_util.m:
Add a format component for the pred_or_func type.
Add the equivalence type format_components.
compiler/make_hlds.m:
Make the format of some error messages concerning typeclasses
more consistent.
compiler/modules.m:
Check for non-abstract instance declarations in module interfaces
and emit an error message if they do.
tests/invalid/Mmakefile:
tests/invalid/instance_bug.m:
tests/invalid/instance_bug.err_exp:
Test case for the above.
tests/hard_coded/typeclasses/*:
tests/invalid/*:
tests/recompilation/*:
tests/valid/*:
Update test cases as necessary.
Estimated hours taken: 0.1
Branches: main, release
compiler/Mercury.options:
library/Mercury.options:
Remove the workarounds that were necessary because of the loop
invariant hoisting bug that Ralph fixed last week.
Estimated hours taken: 10
Branches: main
Reduce the size of the bytecode representations of procedures (generated with
the --trace rep option) by applying two optimizations.
The first optimization is to store strings in the existing global string table
and just keep the offsets in the bytecode representation. This reduces the
size of the procedure representation bytecode for mercury_compile by 15.46% and
the total size of the executable by 2.34%.
The second optimization is to use a single byte to store variable numbers
where the biggest variable number in a procedure is less than or equal to 255.
An extra byte is stored at the beginning of the procedure to indicate whether
variable numbers are stored as bytes or shorts. This optimization reduces the
size of the procedure representation bytecode for mercury_compile by 11.34% and
the total size of the executable by 1.75%.
browser/declarative_execution.m:
Pass the label_layout for a call to any predicates than need to
look up strings in the bytecode. The global string table is accessable
via the label_layout.
Pass the representation used for variable numbers (byte or short) to
any predicates that need to look up variable numbers in the bytecode.
compiler/c_util.m:
Escape (') characters in the C representation of the string table.
compiler/prog_rep.m:
Update the global string table when converting a string to bytecode.
Determine the maximum variable number in a procedure and use a byte
to represent the variable numbers if this is less than 256.
compiler/stack_layout.m:
Export the predicate that adds a string to the global string table.
Export an abstract version of the stack_layout_info type that the
above predicate operates on.
Pass the stack_layout_info to the predicate that constructs the
bytecodes for a procedure, so it can update the global string
table.
mdbcomp/program_representation.m:
Add a predicate to convert the byte indicating whether bytes or shorts
are used to represent variable numbers to a Mercury value.
trace/mercury_trace_internal.c:
Pass the label layout when reading a procedure from the bytecode, so
that strings can be looked up in the global string table.
Estimated hours taken: 0.1
Branches: main
Fix a typo in an error message.
compiler/modules.m:
tests/invalid/after_end_module.err_exp:
s/delcaration/declaration/.
Estimated hours taken: 0.5
Branches: main
Standardise the sizes of higher-order types in the
termination analysers and the term-size profiler by
making term_norm.m treat higher-order types as zero sized.
This has always been the case in the termination analysers
and the term-size profiler anyway.
compiler/term_norm.m:
Change the definition of zero size types so that
higher-order types are always considered zero sized.
compiler/size_prof.m:
compiler/term_constr_util.m:
Minor changes to conform to the above.