Estimated hours taken: 0.25
doc/user/guide.texi
Document that -I options may need to be added to MGNUCFLAGS if
inter-module optimization is being used on a library which
uses the C interface.
Estimated hours taken: 3
Allow a predicate to have matching `cc' and `non-cc' modes.
compiler/det_analysis.m:
If there is a call to a cc procedure in a non-cc context,
then search for a mode of that predicate which is
identical to the called mode except that it is not cc.
If such a mode is found, use it, rather than reporting
an error.
compiler/modecheck_call.m:
Add predicate modes_are_identical_bar_cc, for use by
det_analysis.m.
NEWS:
LIMITATIONS:
doc/reference_manual.texi:
Document the new feature and delete documentation about the
lack of this feature.
tests/hard_coded/Mmakefile:
tests/hard_coded/cc_and_non_cc_test.m:
tests/hard_coded/cc_and_non_cc_test.exp:
Add a test case for the new feature.
Estimated hours taken: 12
Allow modules to be put in source files whose names do not directly match
their the module names. When looking for the source for a module such
as `foo:bar:baz', search for it first in `foo.bar.baz.m', then in `bar.baz.m',
and finally in `baz.m'.
compiler/prog_io.m:
Change prog_io__read_module so that it returns the name of
the module read, as determined by the `:- module' declaration.
Add predicate `check_module_has_expected_name', for checking
that this name matches what was expected.
compiler/modules.m:
Add read_mod_from_file, for reading a module given the file name,
and generated_file_dependencies, for generating the dependencies
of a module given the file name. (As opposed to the module name.)
Change read_mod and read_mod_ignore_errors so that they
search for `.m' files as described above, and return the name
of the source file read.
Also improve the efficiency of read_dependencies slightly:
when reading in `.int' files, there's no need to call
split_into_submodules, because we generate a seperate
`.int' file for each submodule anyway.
compiler/mercury_compile.m:
Change the handling of command-line arguments.
Arguments ending with `.m' are assumed to be file names,
and other arguments are assumed to be module names.
For file names, call read_mod_from_file instead of read_mod.
compiler/handle_options.m:
Change help message to reflect the above change to the semantics
of command-line arguments.
compiler/intermod.m:
compiler/trans_opt.m:
Fix a bug: call prog_io__read_opt_file instead of prog_io__read_module.
doc/user_guide.texi:
Document the above change to the semantics of command-line arguments.
Update the "libraries" chapter to reflect our support for nested
modules.
tests/*/*.m:
tests/*/*.exp:
Fix a few incorrect module names in `:- module' declarations.
Estimated hours taken: 6
Add Mmake support for nested sub-modules.
compiler/mercury_compile.m:
compiler/modules.m:
compiler/intermod.m:
Pass down the source file name to various places.
Store the source file name in the module_imports data structure.
In various places, use this source file name instead of assuming
that the source file name can be obtained from the module name.
compiler/modules.m:
Change the generated .d and .dep files to use the source file names.
Add hard-coded rules in the .d files if the source file name does not
match the form expected by the pattern rules in scripts/Mmake.rules.
XXX unfortunately the rules don't work right for parallel makes of
nested modules
scripts/Mmake.rules:
Add a comment saying that any changes here might need to
be duplicated in compiler/modules.m.
tests/hard_coded/Mmakefile:
tests/hard_coded/nested.m:
tests/hard_coded/nested2.m:
tests/hard_coded/nested.exp:
tests/hard_coded/nested2.exp:
Add a couple of test cases for nested modules (XXX not enabled,
due to the above-mentioned problem with parallel makes).
doc/reference_manual.texi:
Update the "implementation bugs and limitations" section.
NEWS:
Update the news about nested modules.
Estimated hours taken: 6
Fix various invasions of the user's namespace by `mercury_builtin.m',
by splitting mercury_builtin.m into two modules, called builtin.m and
private_builtin.m, and ensuring that the latter is imported as if
by `:- use_module' rather than `:- import_module'.
library/builtin.m:
library/private_builtin.m:
Split mercury_builtin.m into two modules, builtin.m,
which contains stuff intended to be public,
and private_builtin.m, which contains implementation
details that are not supposed to be public.
library/mercury_builtin.m:
Add a comment saying that this module is no longer used, and
should eventually be removed. I have not removed it yet, since
that would prevent bootstrapping with the current compiler. It
will be removed as a seperate change later, once all the
changes have propagated.
compiler/prog_util.m:
Change the definition of mercury_private_builtin_module/1 and
mercury_public_builtin_module so that instead of automatically
importing mercury_builtin.m as if by `import_module', the
copiler will now automatically import builtin.m as if by
`import_module' and private_builtin.m as if by `use_module'.
compiler/polymorphism.m:
Change a call to mercury_private_builtin_module/1 for
unsafe_promise_unique to instead call mercury_public_builtin_module/1.
compiler/unify_proc.m:
Avoid hard-coding "mercury_builtin" by instead
calling one of mercury_{private,public}_builtin_module/1.
runtime/mercury_type_info.[ch]:
library/term.m:
library/std_util.m:
compiler/code_util.m:
Change a few hard-coded instances of "mercury_builtin"
to "builtin" or "private_builtin" as appropriate.
runtime/mercury_trace_util.c:
runtime/mercury_trace_internal.c:
library/prolog.m:
compiler/*.m:
Update comments that refer to "mercury_builtin" to instead
refer to either "builtin" or "private_builtin".
doc/Mmakefile:
Don't include the interface to private_builtin.m in the
library reference manual.
tools/bootcheck:
Add `-p'/`--copy-profiler' option. This is needed to get
the above changes to bootstrap.
tools/test_mercury:
Pass `-p' to tools/bootcheck.
tests/term/*.trans_opt_exp:
s/mercury_builtin/builtin/g
Estimated hours taken: 3
doc/reference_manual.texi:
Document tabling.
Move the overview of termination analysis
from the menu into the termination analysis section.
Move the book references into a "Bibliography".
Estimated hours taken: 6
Add a `--debug' option for Mercury-level debugging
using the trace-based debugger.
scripts/init_grade_options.sh-subr:
scripts/parse_grade_options.sh-subr:
scripts/mgnuc.in:
scripts/ml.in:
compiler/options.m:
compiler/handle_options.m:
compiler/mercury_compile.m:
Split the old `--debug' option into `--low-level-debug'
(formerly the absence of -DSPEED, now handle by -DLOWLEVEL_DEBUG)
and `--c-debug' (passes -g to C compiler).
Delete the old `debug' grade.
Add support for new options `--require-tracing'
(makes --trace minimum equivalent to --trace interfaces,
and passes -DMR_REQUIRE_TRACING to C compiler)
`--stack-trace' (passes -DMR_STACK_TRACE to C compiler;
actually this one was already supported)
and `--debug' (implies previous two),
with corresponding grade modifiers `.trace', `.strce', and `.debug'.
Actually I think there's little point in specifying just one
of `--require-tracing' and `--stack-trace' so for the moment
I'm just providing `--debug': the code for the more fine-grained
options and grade modifiers has been added but commented out.
runtime/mercury_conf_param.h:
Document the new configuration parameter MR_REQUIRE_TRACING
and the existing but undocumented parameter MR_STACK_TRACE.
runtime/mercury_grade.h:
Include MR_REQUIRE_TRACING in the mangled grade identifier.
compiler/globals.m:
compiler/handle_options.m:
compiler/options.m:
Allow new tracing type `--trace default', and make it the default.
This gets replaced with `full' if require_tracing is yes
or `minimal' if require_tracing is no.
Also `--trace minimum' gets replaced with `interface' if
require_tracing is yes.
doc/user_guide.texi:
Document the new `--debug', `--low-level-debug', and `--c-debug'
options.
scripts/mgnuc.in:
compiler/mercury_compile.m:
doc/user_guide.texi:
Change things so that `--c-debug' does not imply `--no-c-optimize'.
configure.in:
Add `-fomit-frame-pointer' to CFLAGS_FOR_GOTOS on alpha-*.
Empirically, this seems to be needed, otherwise lots of
the test cases fail when compiled with `--no-c-optimize'.
(It might also be needed for other architectures, I don't know.)
Estimated hours taken: 50
This change introduces interface tracing, and makes it possible to successfully
bootstrap the compiler with tracing (either interface or full).
compiler/options.m:
Change the bool options --generate-trace into a string option --trace
with three valid values: minimal, interface and full. The last two mean
what they say; the intention is that eventually minimal will mean
no tracing in non-tracing grades and interface tracing in tracing
grades.
compiler/globals.m:
Add a new global for the trace level.
compiler/handle_options.m:
Convert the argument of --trace to a trace level.
Use only consistent 4-space indentation in the deeply nested
if-then-else.
compiler/trace.m:
Implement interface tracing.
Rename trace__generate_depth_reset_code as trace__prepare_for_call,
since it does more than reset the depth if this module is compiled
with interface tracing.
Do not check whether tracing is enabled before calling MR_trace;
let MR_trace make the check. This trades increased non-tracing
execution time for a substantial code size reduction (which may
in turn benefit execution time).
compiler/call_gen.m:
Call trace__generate_depth_reset_code by its new name.
compiler/code_info.m:
Fix a bug in the handling of non/semi commits. When entering a commit,
we used to push a clone of whatever the top failure continuation was.
However, the resume setup for this continuation could have started
with a label that assumed that the resume vars were in their original
locations (which are often registers), whereas the method of
backtracking to that point only guarantees the survival of stack slots,
not registers.
(This bug caused two lines of incorrect code to be generated among
the approx 30 million lines of code in the stage 2 compiler when
compiled with tracing.)
Fix another bug (previously untriggered as far as I know) in the
handling of multi/det commits. This one was breaking the invariant
that the resume vars set of each entry on the failure continuation
stack included the resume vars set of every other entry below it,
which meant that the values of these resume vars were not guaranteed
to be preserved.
compiler/stack_layout.m:
Make layout structures local to their module. They are not (yet)
referred to by name from other modules, and by declaring them
to be global we caused their names to be included even in stripped
executables, adding several megabytes to the size of the binary.
(The names are not stripped because a dynamically linked library
may want to refer to them.)
Change the mercury_data__stack_layout__ prefix on the names of
generated globals vars to just mercury_data__layout__. It is now
merely too long instead of far too long.
Include the label number in the label layout structure and the number
of typeinfo variables in a var_info structure only with native gc.
Their only use is in debugging native gc.
Fix some documentation rot.
compiler/llds.m:
Add a new field to the pragma_c instruction that says whether the
compiler-generated C code fragments access any stack variables.
compiler/frameopt.m:
Use the new field in pragma_c's to avoid a bug. Because frameopt was
assuming that the pragma_c instruction that filled in the stack slots
containing the call sequence number and depth did not access the stack,
it moved the pragma_c before the incr_sp that allocates the frame
(it was trying to get it out of the loop).
compiler/*.m:
Minor changes to set or ignore the extra field in pragma_c, to refer
to layout structures via the new prefix, or to handle the --trace
option.
doc/user_guide.texi:
Update the documentation for --trace.
runtime/mercury_types.h:
Add the type Unsigned.
runtime/mercury_goto.h:
Use the shorter layout prefix.
runtime/mercury_stack_layout.h:
Use the shorter layout prefix, and include the label number only with
native gc.
runtime/mercury_trace.[ch]:
runtime/mercury_trace_internal.[ch]:
runtime/mercury_trace_external.[ch]:
runtime/mercury_trace_util.[ch]:
Divide the old mercury_trace.[ch] into several components, with one
module for the internal debugger, one for the interface to the
external debugger, one for utilities needed by both. Mercury_trace.c
now has only the top-level stuff that steers between the two
debuggers.
runtime/mercury_trace.[ch]:
Add the new global variable MR_trace_from_full. Before each call,
the calling procedure assigns TRUE to this variable if the caller
is fully traced, and FALSE otherwise. Interface traced procedures
generate trace events only if this variable is TRUE when they are
called (fully traced callee procedures ignore the initial value of
the variable).
Make MR_trace return immediately without doing anything unless
tracing is enabled and a new extra argument to MR_trace is TRUE.
This extra argument is always TRUE for trace events in fully traced
procedures, while for trace events from interface traced procedures,
its value is set from the value of MR_trace_from_full at the time
that the procedure was called (i.e. the event is ignored unless the
interface traced procedure was called from a fully traced procedure).
runtime/mercury_trace.[ch]:
runtime/mercury_trace_internal.[ch]:
For global variables that are stored in stack slots, make their type
Word rather than int.
Use a new function MR_trace_event_report instead of calling
MR_trace_event with a NULL command structure pointer to indicate
that the event is to be reported but there is to be no user
interaction.
Use %ld formats in printfs and casts to long for better portability.
runtime/mercury_trace_internal.c:
Save trace-related globals across calls to Mercury library code
in the debugger, since otherwise any trace events in this code
could screw up e.g. the event number or the call number sequence.
Create separate functions for printing port names and determinisms.
runtime/mercury_wrapper.h:
Disable the tracing of the initialization and finalization code
written in Mercury.
runtime/Mmakefile:
Update for the new source and header files.
tests/debugger/{debugger_regs,interpreter,queens}_lib.{m,inp,exp}:
One new copy of each existing test case. These ones are intended
to be used when the stage 2 library is compiled with tracing, which
affects the tests by adding events for the library procedures called
from the test programs.
The .m files are the same as before; one of the .inp files is a bit
different; the .exp files reflect the correct output when the library
is compiled with full tracing.
tests/debugger/Mmakefile:
Provide separate targets for the new set of test cases.
Use --trace full instead of --generate-trace.
tests/debugger/runtests:
Try both the new set of test cases if the old set fails, and report
failure only if both sets fail. This is simpler than trying to figure
out which set should be really tested, and the probability of a false
positive is negligible.
Estimated hours taken: 400
Deforestation.
This increases the code size of the compiler by ~80k when compiling
with --intermodule-optimization --deforestation.
The improvement from deforestation is not measurable for mmc -C make_hlds.m.
Compile time for make_hlds.m increased from 50.7 seconds to 52.2 seconds
when running deforestation.
compiler/simplify.m
compiler/common.m
Provide a nicer interface for simplifying a goal,
not an entire procedure.
Rework the interface to avoid manipulating lots of booleans.
Return an estimate of the improvement in cost from simplification.
Remove failing cases and disjuncts.
Add an option to optimize common structures even across calls.
Remove code to merge branched goals, since that is now
done by deforestation.
Fix a bug: the code to collect instmap_deltas for cases was not
including the switched-on variable in the instmap_delta,
which caused an abort in merge_instmap_delta if the switched
on variable was further instantiated in the switch.
This came up while compiling the compiler with --deforestation.
compiler/det_report.
Output duplicate call warnings even if --warn-simple-code is not set.
XXX fix the same problem with `:- pragma obsolete'.
compiler/code_aux.m
Update code_aux__cannot_loop to use termination information.
compiler/hlds_pred.m
compiler/dnf.m
Pass the type_info_varmap and typeclass_info_varmap
into hlds_pred__define_new_pred.
Restrict the variables of the new procedure onto the variables
of the goal.
Make sure all relevant type_infos are passed into the new
procedure if --typeinfo-liveness is set.
compiler/modes.m
compiler/unique_modes.m
compiler/mode_info.m
compiler/modecheck_unify.m
Put `how_to_check_goal' into the mode_info, rather
than passing it around.
Add a field to the `check_unique_modes' case which
controls whether unique modes is allowed to choose
a different procedure. For deforestation, this is
not allowed, since it could result in choosing a less
efficient procedure after generalisation.
compiler/options.m
New options:
--deforestation
--deforestation-depth-limit
Safety net for termination of the algorithm.
--deforestation-cost-factor
Fudge factor for working out whether deforestation
was worthwhile.
--deforestation-vars-threshold
Like --inline-vars-threshold.
Enable deforestation at -O3.
Removed an unnecessary mode for option_defaults_2, since it
resulted in a warning about disjuncts which cannot succeed.
compiler/handle_options.m
--no-reorder-conj implies --no-deforestation.
compiler/inlining.m
Separate code to rename goals into inlining__do_inline_call.
compiler/hlds_goal.m
Added predicates goal_list_nonlocals, goal_list_instmap_delta
and goal_list_determinism to approximate information about
conjunctions.
compiler/hlds_module.m
Added module_info_set_pred_proc_info to put an updated
pred_info and proc_info back into the module_info.
compiler/hlds_out.m
Exported hlds_out__write_instmap for debugging of deforestation.
Bracket module names on constructors where necessary.
compiler/mercury_compile.m
Call deforestation.
Use the new interface to simplify.m.
compiler/intermod.m
Put recursive predicates with a top-level branched goal
into `.opt' files.
goal_util.m
Added goal_calls_pred_id to work out if a predicate is
recursive before mode analysis.
Export goal_util__goals_goal_vars for use by deforestation.
Give a better message for a missing variable in a substitution.
compiler/instmap.m
Give a better message for inst_merge failing.
compiler/notes/compiler_design.m
Document the new modules.
library/varset.m
Add varset__select to project a varset's names and values
onto a set of variables.
doc/user_guide.texi
Document deforestation.
Remove a reference to a non-existent option, --no-specialize.
util/mdemangle.c
profiler/demangle.m
tests/misc_tests/mdemangle_test.{exp,inp}
Handle the `DeforestationIn__' predicate names introduced by
deforestation, similar to the `IntroducedFrom__' for lambda goals.
New files:
deforest.m Deforestation.
pd_cost.m Cost estimation.
pd_debug.m Debugging output.
pd_info.m State type and version control.
pd_term.m Termination checking.
pd_util.m Utility predicates
From Fergus:
> On 26-Mar-1998, Peter Schachte <pets@students.cs.mu.oz.au> wrote:
> > Better still, I think there should be a specialized syntax for
> > declaring DCG predicates, ideally some variation on the EDCG
> > notation. There should also be a special syntax for calling DCG
> > predicates from non-DCG code; maybe something like phrase/2,3 in Prolog.
> > Then the current practice of declaring and calling DCG predicates with
> > 2 extra arguments should be phased out.
>
> Yes, I agree.
Estimated hours taken: .2
reference_manual.texi:
Try to clear up the confusion caused by defining a predicate
with 2 fewer arguments than it was declared with.
Estimated hours taken: 4
Fix a limitation of the current nested module support:
ensure that we check for attempts to import inaccessible modules.
compiler/modules.m:
Check for attempts to import inaccessible modules
(modules whose parent has not been imported,
or for which there is no `include_module'
declaration in the parent's interface).
compiler/intermod.m:
Modify the way we import `.opt' files. The previous method
temporarily set the items field of the module_imports
structure to [], but check_module_accessibility relies
on the assumption that the items field contains the
items for all modules previously read in.
tests/invalid/Mmakefile:
tests/invalid/test_nested.m:
tests/invalid/test_nested.err_exp:
tests/invalid/parent.m:
tests/invalid/parent.private_child.m:
tests/invalid/parent.public_child.m:
tests/invalid/parent.undeclared_child.m:
tests/invalid/parent.undeclared_child.err_exp:
tests/invalid/parent2.m:
tests/invalid/parent2.child.m:
Add some tests for the above change.
doc/reference_manual.texi:
Update the "bugs and limitations" sub-section of the modules
chapter to reflect the new status quo.
Estimated hours taken: 11
Finish off the centralization of the file name handling code, and
add support for generating intermediate files in subdirectories.
scripts/mmake.in:
Add a new boolean option `--use-subdirs';
if enabled, it just sets the environment variable MMAKE_USE_SUBDIRS
to `yes' before invoking Make.
Also add negative versions of the various options
(`--no-use-subdirs', `--no-verbose', `--no-save-makefile').
scripts/Mmake.rules:
Add code to handle generating intermediate file names
in subdirectories. If MMAKE_USE_SUBDIRS=yes, we add
`--use-subdirs' to MCFLAGS, and most of the pattern rules
are changed to use subdirectories.
Note that getting this to work required a bit of a hack:
due to what seem to be bugs in GNU Make, `mmake depend'
needs to do `mmc --make-short-interface *.m' to get things
started. But once the int3s are there, the dependencies
seem to work OK.
compiler/options.m:
Add a new boolean option `--use-subdirs'.
compiler/modules.m:
Add new predicate `fact_table_file_name'.
Add an extra argument to `module_name_to_file_name',
specifying whether or not to create any directories
needed for the file name.
Change all the file-name-creating predicates here
to go through a single new predicate `choose_file_name',
and add code in that predicate to handle the `--use-subdirs'
option.
Also if the `--use-subdirs' option is set, don't use the
compact dependencies format, since it can't work in that case.
compiler/fact_table.m:
Call `fact_table_file_name' rather than using `string__append'.
compiler/mercury_compile.m:
Change `link_module_list' and `join_module_list'
so that they create file names by calling `module_name_to_file_name'.
compiler/export.m:
compiler/intermod.m:
compiler/llds_out.m:
compiler/mercury_compile.m:
compiler/module_qual.m:
compiler/modules.m:
compiler/termination.m:
compiler/trans_opt.m:
compiler/unused_args.m:
Change all calls to `module_name_to_file_name' to pass
the extra argument specifying whether or not to make
any directories needed for the file name.
library/Mmakefile:
Change the rule for `mmake install_ints' so that it
creates a `Mercury' subdirectory with symbolic links
`ints', `int2s', `int3s', `opts', and `trans_opts'
which just point to `..'. This is needed for the
`--use-subdirs' option to work, because Mmake currently
does not support mixing libraries compiled with and
without `--use-subdirs'.
doc/user_guide.texi:
Document the above changes.
Estimated hours taken: 24
Add support to the Mercury tracer for interacting with an external
Opium-style debugger via a socket.
TODO: currently there is no way for the debugger to specify
constraints on the arguments for a `forward_move' query.
The current code for doing that doesn't work.
(However, the reporting of arguments to the debugger
for an `output_current' query works fine.)
runtime/mercury_trace.c:
Add code to MR_trace() to open a socket connection to
an external debugger, and to process requests from that
debugger, and send responses back.
runtime/mercury_trace.h:
runtime/mercury_wrapper.c:
Call MR_trace_end() from mercury_runtime_terminate() so that
the external debugger gets notified when the program does
a (normal) exit.
runtime/mercury_stack_layout.h:
Fix a bug where the structures here did not match
the output produced by compiler/stack_layout.m.
library/debugger_interface.m:
New file. Declares the Mercury types used for the debugger
socket interface and defines support routines used by
runtime/mercury_trace.c.
library/io.m:
runtime/mercury_types.h:
Move the definition of MercuryFile from library/io.m to
runtime/mercury_types.h, for use by runtime/mercury_trace.c.
library/io.m:
When printing out values of type `c_pointer', print out
the "<<c_pointer>>" string in single quotes, to ensure
that it has valid syntax for a Prolog or Mercury term.
This is necessary because otherwise c_pointers in procedure
arguments could lead to the Mercury process sending a
syntactically invalid term down the socket to the debugger,
which would then be unable to parse it.
library/library.m:
Add reference to debugger_interface.m, so that it gets
include in libmercury.a.
doc/Mmakefile:
Make sure that the library/debugger_interface.m does *not*
get included in the Mercury library reference manual.
runtime/mercury_wrapper.h:
runtime/mercury_wrapper.c:
runtime/mercury_init.h:
util/mkinit.c:
Declare, define, and initialize pointers to the C functions
exported by library/debugger_interface.m.
(This is to avoid having a circular dependency where the
runtime depends on the library.)
compiler/notes/authors.html:
Add Erwan Jahier.
Estimated hours taken: 50
Add support for nested modules.
- module names may themselves be module-qualified
- modules may contain `:- include_module' declarations
which name sub-modules
- a sub-module has access to all the declarations in the
parent module (including its implementation section).
This support is not yet complete; see the BUGS and LIMITATIONS below.
LIMITATIONS
- source file names must match module names
(just as they did previously)
- mmc doesn't allow path names on the command line any more
(e.g. `mmc --make-int ../library/foo.m').
- import_module declarations must use the fully-qualified module name
- module qualifiers must use the fully-qualified module name
- no support for root-qualified module names
(e.g. `:parent:child' instead of `parent:child').
- modules may not be physically nested (only logical nesting, via
`include_module').
BUGS
- doesn't check that the parent module is imported/used before allowing
import/use of its sub-modules.
- doesn't check that there is an include_module declaration in the
parent for each module claiming to be a child of that parent
- privacy of private modules is not enforced
-------------------
NEWS:
Mention that we support nested modules.
library/ops.m:
library/nc_builtin.nl:
library/sp_builtin.nl:
compiler/mercury_to_mercury.m:
Add `include_module' as a new prefix operator.
Change the associativity of `:' from xfy to yfx
(since this made parsing module qualifiers slightly easier).
compiler/prog_data.m:
Add new `include_module' declaration.
Change the `module_name' and `module_specifier' types
from strings to sym_names, so that module names can
themselves be module qualified.
compiler/modules.m:
Add predicates module_name_to_file_name/2 and
file_name_to_module_name/2.
Lots of changes to handle parent module dependencies,
to create parent interface (`.int0') files, to read them in,
to output correct dependencies information for them to the
`.d' and `.dep' files, etc.
Rewrite a lot of the code to improve the readability
(add comments, use subroutines, better variable names).
Also fix a couple of bugs:
- generate_dependencies was using the transitive implementation
dependencies rather than the transitive interface dependencies
to compute the `.int3' dependencies when writing `.d' files
(this bug was introduced during crs's changes to support
`.trans_opt' files)
- when creating the `.int' file, it was reading in the
interfaces for modules imported in the implementation section,
not just those in the interface section.
This meant that the compiler missed a lot of errors.
library/graph.m:
library/lexer.m:
library/term.m:
library/term_io.m:
library/varset.m:
compiler/*.m:
Add `:- import_module' declarations to the interface needed
by declarations in the interface. (The previous version
of the compiler did not detect these missing interface imports,
due to the above-mentioned bug in modules.m.)
compiler/mercury_compile.m:
compiler/intermod.m:
Change mercury_compile__maybe_grab_optfiles and
intermod__grab_optfiles so that they grab the opt files for
parent modules as well as the ones for imported modules.
compiler/mercury_compile.m:
Minor changes to handle parent module dependencies.
(Also improve the wording of the warning about trans-opt
dependencies.)
compiler/make_hlds.m:
compiler/module_qual.m:
Ignore `:- include_module' declarations.
compiler/module_qual.m:
A couple of small changes to handle nested module names.
compiler/prog_out.m:
compiler/prog_util.m:
Add new predicates string_to_sym_name/3 (prog_util.m) and
sym_name_to_string/{2,3} (prog_out.m).
compiler/*.m:
Replace many occurrences of `string' with `module_name'.
Change code that prints out module names or converts
them to strings or filenames to handle the fact that
module names are now sym_names intead of strings.
Also change a few places (e.g. in intermod.m, hlds_module.m)
where the code assumed that any qualified symbol was
fully-qualified.
compiler/prog_io.m:
compiler/prog_io_goal.m:
Move sym_name_and_args/3, parse_qualified_term/4 and
parse_qualified_term/5 preds from prog_io_goal.m to prog_io.m,
since they are very similar to the parse_symbol_name/2 predicate
already in prog_io.m. Rewrite these predicates, both
to improve maintainability, and to handle the newly
allowed syntax (module-qualified module names).
Rename parse_qualified_term/5 as `parse_implicit_qualified_term'.
compiler/prog_io.m:
Rewrite the handling of `:- module' and `:- end_module'
declarations, so that it can handle nested modules.
Add code to parse `include_module' declarations.
compiler/prog_util.m:
compiler/*.m:
Add new predicates mercury_public_builtin_module/1 and
mercury_private_builtin_module/1 in prog_util.m.
Change most of the hard-coded occurrences of "mercury_builtin"
to call mercury_private_builtin_module/1 or
mercury_public_builtin_module/1 or both.
compiler/llds_out.m:
Add llds_out__sym_name_mangle/2, for mangling module names.
compiler/special_pred.m:
compiler/mode_util.m:
compiler/clause_to_proc.m:
compiler/prog_io_goal.m:
compiler/lambda.m:
compiler/polymorphism.m:
Move the predicates in_mode/1, out_mode/1, and uo_mode/1
from special_pred.m to mode_util.m, and change various
hard-coded definitions to instead call these predicates.
compiler/polymorphism.m:
Ensure that the type names `type_info' and `typeclass_info' are
module-qualified in the generated code. This avoids a problem
where the code generated by polymorphism.m was not considered
type-correct, due to the type `type_info' not matching
`mercury_builtin:type_info'.
compiler/check_typeclass.m:
Simplify the code for check_instance_pred and
get_matching_instance_pred_ids.
compiler/mercury_compile.m:
compiler/modules.m:
Disallow directory names in command-line arguments.
compiler/options.m:
compiler/handle_options.m:
compiler/mercury_compile.m:
compiler/modules.m:
Add a `--make-private-interface' option.
The private interface file `<module>.int0' contains
all the declarations in the module; it is used for
compiling sub-modules.
scripts/Mmake.rules:
scripts/Mmake.vars.in:
Add support for creating `.int0' and `.date0' files
by invoking mmc with `--make-private-interface'.
doc/user_guide.texi:
Document `--make-private-interface' and the `.int0'
and `.date0' file extensions.
doc/reference_manual.texi:
Document nested modules.
util/mdemangle.c:
profiler/demangle.m:
Demangle names with multiple module qualifiers.
tests/general/Mmakefile:
tests/general/string_format_test.m:
tests/general/string_format_test.exp:
tests/general/string__format_test.m:
tests/general/string__format_test.exp:
tests/general/.cvsignore:
Change the `:- module string__format_test' declaration in
`string__format_test.m' to `:- module string_format_test',
because with the original declaration the `__' was taken
as a module qualifier, which lead to an error message.
Hence rename the file accordingly, to avoid the warning
about file name not matching module name.
tests/invalid/Mmakefile:
tests/invalid/missing_interface_import.m:
tests/invalid/missing_interface_import.err_exp:
Regression test to check that the compiler reports
errors for missing `import_module' in the interface section.
tests/invalid/*.err_exp:
tests/warnings/unused_args_test.exp:
tests/warnings/unused_import.exp:
Update the expected diagnostics output for the test cases to
reflect a few minor changes to the warning messages.
tests/hard_coded/Mmakefile:
tests/hard_coded/parent.m:
tests/hard_coded/parent.child.m:
tests/hard_coded/parent.exp:
tests/hard_coded/parent2.m:
tests/hard_coded/parent2.child.m:
tests/hard_coded/parent2.exp:
Two simple tests case for the use of nested modules with
separate compilation.
Estimated hours taken: 1
scripts/mgnuc.in:
Use a new environment variable MERCURY_ALL_C_INCL_DIRS, which may
be defined by the user as a list of -I<dir> options, whose default
value is -I$MERCURY_C_INCL_DIR. This replaces MERCURY_GC_INCL_DIR.
The advantage of the new arrangement is that it allows the garbage
collector header files to be in more than one directory, as they
are with the Boehm collector (the file gc_inl.h, which is needed at
-O6, is in boehm_gc/include, while the usual gc.h is in boehm_gc).
tools/bootcheck:
Set up MERCURY_ALL_C_INCL_DIRS instead of MERCURY_GC_INCL_DIR.
Tidy some other parts of the script.
doc/user_guide.texi:
Document the change.
Estimated hours taken: 9
compiler/hlds_out.m:
This diff makes a few things that were dumped in any
hlds-stage optional. They can be recovered using the following
field of -D output compiling option:
'T' for type and typeclasses information.
'M' for modes and instantiation information.
'C' for clause information.
'U' for unify predicates.
compiler/handle_options.m:
A small change to handle those new suboptions when compiling
with -Dall.
doc/user_guide.texi:
Update the documentation for T, M, U, C and P suboptions.
Estimated hours taken: 0.25
doc/reference_manual.texi:
Fix some minor spelling and formatting errors and
improve the wording slightly in a couple of places.
Estimated hours taken: 2
Add support to Mmake for new variables MLOBJS and MLPICOBJS,
since simply listing object files in MLLIBS doesn't do the
right thing in the case when you're building a library package
rather than a program.
scripts/Mmake.vars.in:
Add definitions of MLOBJS and MLPICOBJS.
compiler/modules.m:
Add code to use the $(MLOBJS) and $(MLPICOBJS) variables
to the rules for building programs and libraries that are
output in the generated `.dep' files.
doc/user_guide.texi:
Document the use of MLOBJS and MLPICOBJS.
Estimated hours taken: 0.25
doc/reference_manual.texi:
Update the documentation in the C interface section on link in
other object files and libraries to reflect the new `MLOBJS'
variable.
Estimated hours taken: 0.75
doc/user_guide.texi:
Document that library builders need to include `--trans-intermod-opt'
in their MCFLAGS if they want to build transitive optimization
interfaces.
Various other minor corrections to the trans-opt documentation.
Also make sure that full stops are followed by two spaces,
and reword a few things to avoid "overful hbox" problems.
Estimated hours taken: 0.5
compiler/options.m:
Fix a couple of places where the help messages didn't line up
or didn't fit in 80 columns.
Change some old comments that referred to the `mc' script
to instead talk about the `mmc' script (`mc' was renamed).
compiler/options.m:
doc/user_guide.texi:
Move the documentation of the termination analysis options
from the "overall optimization options" section to a new
"termination analysis options" section.
(Termination analysis might have some effect on optimization,
but that is not it's primary purpose, so it doesn't belong
in the optimization options section at all.)
In the User Guide, add a pointer to the section on
termination analysis in the Language Reference Manual.
Estimated hours taken: 15?
A first go at user documentation for typeclasses. There are probably a few
things that are not well explained, and a few things to be made more rigorous,
but it's an okay first go.
doc/reference_manual.texi:
Add explanation of typeclass related stuff, and update a few bits and
pieces to reflect the changes that have been made to support
typeclasses. There are probably quite a few changes like that left to
be made.
Estimated hours taken: 1
doc/reference_manual.texi:
Document the restriction that the C code in `pragma c_code'
declarations must be type-, mode-, determinism-, and
purity-correct with respect to its Mercury declaration.
Estimated hours taken: 20
Fix the processing of .trans_opt files so that circular dependencies
cannot occur. This also guarantees correctness of the information in
the .trans_opt file.
compiler/handle_options.m:
Add the fact that --transitive-intermodule-optimization implies
--intermodule-optimization, and that
--make-transitive-optimization-interface implies
--transitive-intermodule-optimization.
compiler/mercury_compile.m:
Add code to read the .d file before new .d files are written.
The .d file is only read if transitive intermodule optimization
is enabled. Also changed the pre-hlds pass so that .d files
were not written when `error-check only' or `type-check only'
options were selected.
compiler/modules.m:
Modified so that the trans_opt dependencies were correctly
created, and so they were written out to the .d files. Also
added new code to read the .d files in. Removed the
transitive_dependencies set of predicates as they were no longer
used.
compiler/options.m:
Added new option 'warn-missing-trans-opt-deps', to control
whether warnings are emitted when the dependency information in
the .d file is lost. Also uncommented the help messages
describing transitive-intermodule-optimization.
compiler/trans_opt.m:
Small changes to trans_opt__grab_optfiles. Also modified the
comment at the beginning of the file to reflect the current set
of changes.
doc/user_guide.texi:
Uncommented the documentation on transitive intermodule
optimization.
Estimated hours taken: 1
Add new options for disabling some warnings, so that they
can be disabled by `--inhibit-warnings'.
compiler/options.m:
Add new options `warn-missing-module-name'
and `warn-wrong-module-name' (enabled by default),
and ensure that `--inhibit-warnings' disables these options.
compiler/prog_io.m:
Add code to conditionalize the printing of warnings
based on the settings of the new options.
doc/user_guide.texi:
Document the new options.
tests/valid/Mmakefile:
tests/valid/inhibit_warn_test.m:
A regression test.
Estimated hours taken: 10
compiler/tag_switch.m:
Add a new way of generating code for switches, binary searches.
These have the form:
if (tag(var)) > 1) goto L23
if (tag(var)) != 0) goto L1
code for tag 0
goto end
L1: code for tag 1
goto end
L23: if (tag(var)) != 2) goto L3
code for tag 2
goto end
L3: code for tag 3
goto end
These have a lower number of expected comparisons than try chains,
especially for machines with three tag bits, although some of the
tests, requiring a subtraction, may be slightly more expensive.
They can be useful for switches where the number of alternatives is
not high enough to justify the overhead of using a jump table.
Make the use of the --dense-switch-size and --try-switch-size options
conform to their documentation. Their arguments are inclusive lower
bounds; they were used as exclusive lower bounds.
compiler/options.m:
Add a new option --binary-switch-size, that controls when we use
the new method.
doc/user_guide.texi:
Document the new option.
Estimated hours taken: 0.5
scripts/mgnuc.in:
Use the value of a new environment variable, MERCURY_GC_INCL_DIR,
when invoking the C compiler. This allows the include directory
for the garbage collector to be different from the include directory
for the runtime system, which is useful when making incompatible
changes to the runtime system.
Fix a bug: the option signalling which argument passing convention
to use was not being passed to the C compiler in all cases.
doc/user_guide.texi:
Document the new environment variable.
Estimated hours taken: 60
A rewrite of termination analysis to make it significantly easier to modify,
and to extend its capabilities.
compiler/error_util.m:
A new file containing code that makes it easier to generate
nicely formatted error messages.
compiler/termination.m:
Updates to reflect the changes to the representation of termination
information.
Instead of doing pass 1 on all SCCs and then pass 2 on all SCCs,
we now do both pass 1 and 2 on an SCC before moving on to the next.
Do not insist that either all procedures in an SCC are
compiler-generated or all are user-written, since this need not be
true in the presence of user-defined equality predicates.
Clarify the structure of the code that handles builtins and compiler
generated predicates.
Concentrate all the code for updating module_infos in this module.
Previously it was scattered in several places in several files.
Put all the code for writing out termination information at the
end of the module in a logical order.
compiler/term_traversal.m:
A new file containing code used by both pass 1 and pass 2 to
traverse procedure bodies.
compiler/term_pass1.m:
Use the new traversal module.
Clarify the fixpoint computation on the set of output supplier
arguments.
Remove duplicates from the list of equations given to the solver.
This avoids a det stack overflow in lp.m when doing termination
analysis on options.m.
If an output argument of a predicate makes sense only in the absence
of errors, then return it only in the absence of errors.
compiler/term_pass2.m:
Use the new traversal module. Unlike the previous code, this allows us
to ignore recursive calls with input arguments bigger than the head
if those calls occur after goals that cannot succeed (since those
calls will never be reached).
Implement a better way of doing single argument analysis, which
(unlike the previous version) works in the presence of mutual recursion
and other calls between the recursive call and the start of the clause.
Implement a more precise way of checking for recursions that don't
cause termination problems. We now allow calls from p to q in which
the recursive input supplier arguments can grow, provided that on
any path on which q can call p, directly or indirectly, the recursive
input supplier arguments shrink by a greater amount.
If an output argument of a predicate makes sense only in the absence
of errors, then return it only in the absence of errors.
compiler/term_util.m:
Updates to reflect the changes to the representation of termination
information.
Reorder to put related code together.
Change the interface of several predicates to better reflect the
way they are used.
Add some more utility predicates.
compiler/term_errors.m:
Small changes to the set of possible errors, and major changes in
the way the messages are printed out (we now use error_util).
compiler/options.m:
Change --term-single-arg from being a bool to an int option,
whose value indicates the maximum size of an SCC in which we try
single argument analysis. (Large SCCs can cause single-arg analysis
to require a lot of iterations.)
Add an (int) option that controls the max number of paths
that we are willing to analyze (analyzing too many paths can cause
det stack overflow).
Add an (int) option that controls the max number of causes of
nontermination that we print out.
compiler/hlds_pred.m:
Use two separate slots in the proc_info to hold argument size data
and termination info, instead of the single slot used until now.
The two kinds of information are produced and used separately.
Make the layout of the get and set procedures for proc_infos more
regular, to facilitate later updates.
The procedures proc_info_{,set_}variables did the same work as
proc_info_{,set_}varset. To eliminate potential confusion, I
removed the first set.
compiler/*.m:
Change proc_info_{,set_}variables to proc_info_{,set_}varset.
compiler/hlds_out.m:
compiler/make_hlds.m:
compiler/mercury_to_mercury.m:
Change the code to handle the arg size data and the termination
info separately.
compiler/prog_data.m:
Change the internal representation of termination_info pragmas to
hold the arg size data and the termination info separately.
compiler/prog_io_pragma.m:
Change the external representation of termination_info pragmas to
group the arg size data together with the output supplier data,
to which it is logically connected.
compiler/module_qual.m:
compiler/modules.m:
Change the code to accommodate the change to the internal
representation of termination_info pragmas.
compiler/notes/compiler_design.html:
Fix some documentation rot, and clarify some points.
Document termination analysis.
doc/user_guide.texi:
Document --term-single-arg and the new options.
Remove spaces from the ends of lines.
library/bag.m:
Add a new predicate, bag__least_upper_bound.
Fix code that would do the wrong thing if executed by Prolog.
Remove spaces from the ends of lines.
library/list.m:
Add a new predicate, list__take_upto.
library/set{,_ordlist}.m:
Add a new predicate, set{,_ordlist}__count.
tests/term/*:
A bunch of new test cases to test the behaviour of termination
analysis. They are the small benchmark suite from our paper.
tests/Mmakefile:
Enable the new test case directory.
The purpose of this diff is to allow Mercury programs to contain
impure Mercury code without the compiler changing its behavior
inappropriately, while still allowing the compiler to aggressively
optimize pure code. To do this, we require impure predicates to be so
declared, and calls to impure predicates to be flagged as such. We
also allow predicates implemented in terms of impure predicates to be
promised to be pure; lacking such a promise, any predicate that calls
an impure predicate is assumed to be impure.
At the moment, we don't allow impure functions (only predicates),
though some of the work necessary to support them has been done.
Note that to make the operators work properly, the precedence of the
`pred' and `func' operators has been changed from 1199 to 800.
Estimated hours taken: 150
compiler/purity.m:
New compiler pass for purity checking.
compiler/hlds_goal.m:
Add `impure' and `semipure' to the goal_feature enum.
compiler/hlds_out.m:
compiler/typecheck.m:
compiler/special_pred.m:
Fixed code that prints predicate name to write something more
helpful for special (compiler-generated) predicates. Added
code to print new markers. Added purity argument to
mercury_output_pred_type. New public predicate
special_pred_description/2 provides an english description for
each compiler-generated predicate.
compiler/hlds_pred.m:
Add `impure' and `semipure' to marker enum. Added new
public predicates to get predicate purity and whether or not
it's promised to be pure.
compiler/prog_data.m:
compiler/mercury_to_mercury.m:
compiler/prog_io.m:
compiler/prog_io_goal.m:
compiler/prog_io_pragma.m:
compiler/prog_io_dcg.m:
compiler/prog_util.m:
compiler/equiv_type.m:
compiler/intermod.m:
compiler/mercury_to_c.m:
compiler/module_qual.m:
Add purity argument to pred and func items. Add new `impure'
and `semipure' operators. Add promise_pure pragma. Add
purity/2 wrapper to goal_expr type.
compiler/make_hlds.m:
compiler/mercury_to_goedel.m:
Added purity argument to module_add_{pred,func},
clauses_info_add_pragma_c_code, and to pred and func items.
Handle promise_pure pragma. Handle purity/2 wrapper used to
handle user-written impurity annotations on goals.
compiler/mercury_compile.m:
Add purity checking pass between type and mode checking.
compiler/mode_errors.m:
Distinguish mode errors caused by impure goals preventing
goals being delayed.
compiler/modes.m:
Don't delay impure goals, and ensure before scheduling an
impure goal that no goals are delayed. Actually, we go ahead
and try to schedule goals even if impurity causes a problem,
and then if it still doesn't mode check, then we report an
ordinary mode error. Only if the clause would be mode correct
except for an impure goal do we report it as an impurity problem.
compiler/simplify.m:
Don't optimize away non-pure duplicate calls. We could do
better and still optimize duplicate semipure goals without an
intervening impure goal, but it's probably not worth the
trouble. Also don't eliminate impure goals on a failing branch.
compiler/notes/compiler_design.html:
Documented purity checking pass.
doc/reference_manual.texi:
Document purity system.
doc/transition_guide.texi:
library/nc_builtin.nl:
library/ops.m:
library/sp_builtin.nl:
New operators and new precdence for `pred' and `func'
operators.
tests/hard_coded/purity.m
tests/hard_coded/purity.exp
tests/hard_coded/Mmakefile:
tests/invalid/purity.m
tests/invalid/purity_nonsense.m
tests/invalid/purity.err_exp
tests/invalid/purity_nonsense.err_exp
tests/invalid/Mmakefile:
Test cases for purity.
Estimated hours taken: 40 (+ unknown time by Zoltan)
Add support for memory profiling.
(A significant part of this change is actuallly Zoltan's work. Zoltan
did the changes to the compiler and a first go at the changes to the
runtime and library. I rewrote much of Zoltan's changes to the runtime
and library, added support for the new options/grades, added code to
interface with mprof, did the changes to the profiler, and wrote the
documentation.)
[TODO: add test cases.]
NEWS:
Mention support for memory profiling.
runtime/mercury_heap_profile.h:
runtime/mercury_heap_profile.c:
New files. These contain code to record heap profiling information.
runtime/mercury_heap.h:
Add new macros incr_hp_msg(), tag_incr_hp_msg(),
incr_hp_atomic_msg(), and tag_incr_hp_atomic_msg().
These are like the non-`msg' versions, except that if
PROFILE_MEMORY is defined, they also call MR_record_allocation()
from mercury_heap_profile.h to record heap profiling information.
Also, fix up the indentation in lots of places.
runtime/mercury_prof.h:
runtime/mercury_prof.c:
Added code to dump out memory profiling information to files
`Prof.MemoryWords' and `Prof.MemoryCells' (for use by mprof).
Change the format of the `Prof.Counts' file so that the
first line says what it is counting, the units, and a scale
factor. Prof.MemoryWords and Prof.MemoryCells can thus have
exactly the same format as Prof.Counts.
Also cleaned up the interface to mercury_prof.c a bit, and did
various other minor cleanups -- indentation changes, changes to
use MR_ prefixes, additional comments, etc.
runtime/mercury_prof_mem.h:
runtime/mercury_prof_mem.c:
Rename prof_malloc() as MR_prof_malloc().
Rename prof_make() as MR_PROF_NEW() and add MR_PROF_NEW_ARRAY().
runtime/mercury_wrapper.h:
Minor modifications to reflect the new interface to mercury_prof.c.
runtime/mercury_wrapper.c:
runtime/mercury_label.c:
Rename the old `-p' (primary cache size) option as `-C'.
Add a new `-p' option to disable profiling.
runtime/Mmakefile:
Add mercury_heap_profile.[ch].
Put the list of files in alphabetical order.
Delete some obsolete stuff for supporting `.mod' files.
Mention that libmer_dll.h and libmer_globals.h are
produced by Makefile.DLLs.
runtime/mercury_imp.h:
Mention that libmer_dll.h is produced by Makefile.DLLs.
runtime/mercury_dummy.c:
Change a comment to refer to libmer_dll.h rather than
libmer_globals.h.
compiler/llds.m:
Add a new field to `create' and `incr_hp' instructions
holding the name of the type, for heap profiling.
compiler/unify_gen.m:
Initialize the new field of `create' instructions with
the appropriate type name.
compiler/llds_out.m:
Output incr_hp_msg() / tag_incr_hp_msg() instead of
incr_hp() / tag_incr_hp().
compiler/*.m:
Minor changes to most files in the compiler back-end to
accomodate the new field in `incr_hp' and `create' instructions.
library/io.m:
Add `io__report_full_memory_stats'.
library/benchmarking.m:
Add `report_full_memory_stats'. This uses the information saved
by runtime/mercury_heap_profile.{c,h} to print out a report
of memory usage by procedures and by types.
Also modify `report_stats' to print out some of that information.
compiler/mercury_compile.m:
If `--statistics' is enabled, call io__report_full_memory_stats
at the end of main/2. This will print out full memory statistics,
if the compiler was compiled with memory profiling enabled.
compiler/options.m:
compiler/handle_options.m:
runtime/mercury_grade.h:
scripts/ml.in:
scripts/mgnuc.in:
scripts/init_grade_options.sh-subr:
scripts/parse_grade_options.sh-subr:
Add new option `--memory-profiling' and new grade `.memprof'.
Add `--time-profiling' as a new synonym for `--profiling'.
Also add `--profile-memory' for more fine-grained control:
`--memory-profiling' implies both `--profile-memory' and
`--profile-calls'.
scripts/mprof_merge_runs:
Update to handle the new format of Prof.Counts and to
also merge Prof.MemoryWords and Prof.MemoryCells.
profiler/options.m:
profiler/mercury_profile.m:
Add new options `--profile memory-words' (`-m'),
`--profile memory-cells' (`-M') and `--profile time' (`-t').
Thes options make the profiler select a different count file,
Prof.MemoryWords or Prof.MemoryCells instead of Prof.Counts.
specific to time profiling.
profiler/read.m:
profiler/process_file.m:
profiler/prof_info.m:
profiler/generate_output.m:
Update to handle the new format of the counts file.
When reading the counts file, look at the first line of
the file to determine what is being profiled.
profiler/globals.m:
Add a new global variable `what_to_profile' that records
what is being profiled.
profiler/output.m:
Change the headings to reflect what is being profiled.
doc/user_guide.texi:
Document memory profiling.
Document new options.
doc/user_guide.texi:
compiler/options.m:
Comment out the documentation for `.proftime'/`--profile-time',
since doing time and call profiling seperately doesn't work,
because the code addresses change when you recompile with a
different grade. Ditto for `.profmem'/`--profile-memory'.
Also comment out the documentation for
`.profcalls'/`--profile-calls', since it is redundant --
`.memprof' produces the same information and more.
configure.in:
Build a `.memprof' grade. (Hmm, should we do this only
if `--enable-all-grades' is specified?)
Don't ever build a `.profcalls' grade.
Estimated hours taken: 1
Add support for a new `GRADEFLAGS' variable to Mmake,
so that you can use the more readable (and more portable)
`GRADEFLAGS = --profiling' rather than e.g. `GRADEFLAGS = asm_fast.gc.prof'.
scripts/Mmake.vars.in:
Add GRADEFLAGS variable, defaulting to `--grade $(GRADE)'.
scripts/Mmake.rules:
Change various rules to use `$(GRADEFLAGS)' instead of
`--grade $(GRADE)'.
compiler/modules.m:
Change various rules in the generated `.dep' files to
use `$(GRADEFLAGS)' instead of `--grade $(GRADE)'.
doc/user_guide.texi:
Modify the documentation to reflect the above changes.
Estimated hours taken: 0.5
Delete support for `.mod' files, since they are obsolete now.
scripts/mod2c:
Delete this script.
scripts/Mmakefile:
Delete reference to `mod2c'.
scripts/Mmake.rules:
Delete the `.mod' suffix and the rule for .mod -> .c,
scripts/Mmake.vars.in:
Delete the MOD2C, MOD2CFLAGS, MOD2H, and MOD2HFLAGS variables.
doc/user_guide.texi
Delete mention of `.mod' files.
This is useful on Unix because it lets you profile elapsed (real time)
or just user time rather than user+system time.
It is also essential on Windows because gnu-win32 only supports
ITIMER_REAL (for the other two, setitimer() just returns an error).
runtime/mercury_wrapper.h:
runtime/mercury_wrapper.c:
Add new options for selecting the time profiling method.
runtime/mercury_prof.c:
Use the new option settings to control the argument passed to
setitimer(), and (since that in turn affects which signal will
be sent) the argument to signal().
doc/user_guide.texi:
Document the above changes.
Estimated hours taken: 2
compiler/options.m:
Add new options `--mode-inference-iteration-limit'
and `--type-inference-iteration-limit'.
compiler/typecheck.m:
Only perform a finite number of iterations of type inference,
to work around infinite loops for preds such as `p(p)'.
compiler/modes.m:
Use the new option rather than a hard-coded limit.
doc/user_guide.texi:
Document the new options.
Estimated hours taken: 18
library/portray.nl:
You can now control the depth limit, and separately the limit
on the lengths of lists and the number of arguments shown for
high-arity terms. You can also "turn off" certain arguments
of certain terms, based on the functor of the term, or even
turn off the whole term. Finally, you can define your own
print methods for terms if you like, so lists of character
codes can be printed as double-quoted strings, and maps can be
printed out as associations. Both of these are provided, and
serve as examples.
doc/user_guide.texi:
Documented all the above.
Estimated hours taken: 1
Added option --generate-module-order which writes the module dependency
ordering to <module>.order during dependency generation. This is expected
to be useful for improving the effectiveness of termination analysis.
compiler/options.m
compiler/handle_options.m
Added option --generate-module-order.
compiler/modules.m
Compute and print out the ordering.
doc/user_guide.texi
Document --generate-module-order.
Estimated hours taken: 2
scripts/mprof_merge_runs:
New file. A script for merging multiple runs into a single
profile.
scripts/Mmakefile:
Add mprof_merge_runs to the list of scripts.
doc/Mmakefile:
Add mprof_merge_runs to the list of things which need manpages.
(The manpage will be created automatically by `make_manpage'.)
doc/user_guide.texi:
Document the use of mprof_merge_runs.
Estimated hours taken: 4
Dectect floundering in solutions/2 and nondet if-then-else.
library/std_util.m:
Change the code for builtin_aggregate to (a) check for
floundering and (b) reset the trail properly.
compiler/code_gen.m:
Change the code for if-then-elses with nondet conditions
so that it checks for floundering.
runtime/mercury_trail.h:
compiler/llds.m:
compiler/llds_out.m:
Add new alternative `MR_solve' to MR_untrail_reason.
This is used to for checking for floundering in the
above-mentioned two cases.
extras/clpr/cfloat.m:
extras/trailed_update/var.m:
Handle the MR_solve case.
doc/reference_manual.texi:
Document MR_solve.
NEWS:
Delete the mention of the limitation that we didn't
dectect floundering in solutions/2 and nondet if-then-else.
Estimated hours taken: 500
Add termination analysis to the compiler. The termination analysis
annotates each procinfo structure with termination information stating
whether each procedure is guaranteed to terminate.
Add transitive intermodule optimization to the compiler. Transitive
intermodule optimization uses .trans_opt files to store optimization
information. The difference between .trans_opt files and .opt files is
that .trans_opt files may depend on other .trans_opt files, whereas .opt
files may only depend on a .m file.
compiler/termination.m:
New file. The main module which controls the termination
analysis.
compiler/term_pass1.m:
New file. This file implements the first pass of the
termination analysis which attempts to derive relationships
between the relative sizes of variables. This information is
used by term_pass2.m
compiler/term_pass2.m:
New file. The second pass of the termination analysis attempts
to prove that each predicate or function in the program is
guaranteed to terminate.
compiler/term_util.m:
New file. Contains utilities which are used in various stages
of the termination analysis.
compiler/term_errors.m:
New file. Contains predicates for printing out error messages
produced by termination analysis.
compiler/trans_opt.m:
New file. This module contains predicates for both reading in
and writing .trans_opt files.
compiler/globals.m:
compiler/handle_options.m:
compiler/options.m:
Various modifications to handle the new options. Some of the
new options imply other options, and the `--termination-norm'
option is a string option which needs processing.
compiler/hlds_goal.m:
Added a comment that the list(uni_mode) subfield of construct,
and the unify_mode subfield of unify are not necessarily valid
when the unification applies to higher order terms.
compiler/hlds_out.m:
Added code to output termination information, as well as code to
print out the new markers.
compiler/hlds_pred.m:
Added the termination subfield to the proc_info structure and
added code to support it. Also added support for the new
markers.
compiler/make_hlds.m:
compiler/mercury_to_mercury.m:
compiler/module_qual.m:
compiler/modules.m:
compiler/prog_io_pragma.m:
Added support for the new pragmas, `termination_info',
`teminates', `check_termination' and `does_not_terminate'.
compiler/prog_data.m:
Added the new pragmas to the pragma_type. Also reformatted the
type declarations to conform with the coding specifications.
compiler/prog_io.m:
Reformatted some code and comments.
compiler/mercury_compiler.m:
Added code to call the termination analyser and to call the
predicate which creates .trans_opt files.
doc/reference_manual.texi:
Documented the termination analysis and the new pragmas.
doc/user_guide.texi:
Documented the new options.
compilation model options as mmc.
Allow the user to mix `--grade foo' options with
other options that affect the grade such as `--profiling'.
Compute the final grade to link with from the options.
Also add a few new options and grade modifiers.
compiler/options.m:
compiler/mercury_compile.m:
Add `--profile-time' and `--profile-calls' options.
Change `--profiling' to now just imply both of those.
Add `--pic-reg' option (just implies `-DPIC_REG' in cflags).
compiler/handle_options.m:
Add support for grade modifiers `.proftime' and `.profcalls'.
Make `.debug' a grade modifier, rather than having a base
grade `debug'.
scripts/init_grade_options.sh-subr:
scripts/parse_grade_options.sh-subr:
New files containing sh subroutines for parsing grade-related
options.
configure.in:
bindist/bindist.configure.in:
Use AC_SUBST_FILE to allow #inclusion of the above-mentioned
`.sh-subr' files.
scripts/ml.in:
scripts/mgnuc.in:
Use the above-mentioned sh subroutines.
scripts/ml.in:
compiler/mercury_compile.m:
compiler/handle_options.m:
Compute the final grade to link with from the various
grade-related options.
scripts/mgnuc.in:
Support the `--inline-alloc' option.
doc/user_guide.texi:
README.Linux:
Document the above changes.