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: 0.25
compiler/options.m:
Fix a bug: the default `--trace' should be `--trace minimum'
not `--trace minimal'.
compiler/handle_options.m:
Unwrap some lines that didn't need to be wrapped.
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
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: 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: 20
Use stack layout tables to transmit information to the tracer, to allow
the tracer to print the names and values of variables at CALL and EXIT ports.
Extend stack layout tables to permit this.
For the time being the tables do not contain information about how to fill
in pseudo-typeinfos, so printing only works for monomorphic procedures.
compiler/llds.m:
Allow space for variable names in the information we gather about live
variables at given labels.
compiler/llds_out.m:
Print out variable names in the information we gather about live
variables at given labels in comments.
compiler/continuation_info.m:
Include variable names in the information we gather about live
variables at given labels.
Record the determinism of each procedure, not its code model.
compiler/{call_gen,code_gen,code_info}.m:
Include the names of variables in the data given to
continuation_info.m.
compiler/options.m:
Add a new developer-only option, --procid-stack-layout, whose effect
is to extend stack_layout structures with static info identifying the
procedure. This is used by execution tracing, and could (should) be
used by stack tracing and profiling.
Rename --alternate-liveness as --typeinfo-liveness. This is more
expressive. Later we should add a new option --trace-liveness, which
preserves every variable until the end of the clause for use by
the trace debugger.
compiler/handle_options.m:
Handle the option implications of --procid-stack-layout.
compiler/stack_layout.m:
Include the encoded determinism instead of the code model in stack
layout tables.
Include variable names in the live data section of stack layout tables
if they are available.
Include procedure identification information in the stack layout tables
if --procid-stack-layout is set.
compiler/trace.m:
Use the new interface to MR_trace.
compiler/*.m:
Trivial changes following from the renaming of --alternate-liveness.
runtime/mercury_accurate_gc.h:
Add macros to decode encoded determinisms.
Define structs for accessing the stack layout tables.
runtime/mercury_regs.h:
Define a macro similar to virtual_reg, except in that it can refer
to an arbitrary memory area, not just fake_reg.
runtime/{mercury_string,mercury_types}.h:
Move the typedefs of Char, UnsignedChar, String and ConstString
from mercury_string.h to mercury_types.h to avoid problems with
circular #includes.
runtime/mercury_trace.[ch]:
Revise the interface to MR_trace so that it takes the layout table
of the procedure as an argument. From the layout table, we can get
to the module name, predicate name, arity, mode number, and
determinism of the procedure, so we don't need to pass these any more,
reducing parameter passing overhead. We can also get to information
about where the input and output arguments are. We now use this
information to allow the user to print out the value of the arguments
at the CALL and EXIT ports.
Change the prompt to a less intrusive "mtrace> ".
runtime/mercury_wrapper.[ch]:
Add a new global variable, MR_library_trace_browser. We reserve space
for this variable in mercury_wrapper.c. It will be initialized by the
automatically generated xxx_init.c file to point to the procedure
that the tracer will invoke to let the user browse the values of
variables. This mechanism allows the runtime to maintain its current
ignorance about the contents of the standard library.
util/mkinit.c:
Generate additional code in the xxx_init.c files to fill in the value
of MR_library_trace_browser.
tests/misc_tests/debugger_test.{inp,exp}:
Add a few printing commands into the input for this test case, and
update the expected output.
Estimated hours taken: 20
Reorganize options for accurate GC, stack tracing and execution tracing.
The new options are:
--stack-trace Turn on stack traces (incomplete, just
turns on required stack layouts at the
moment).
--basic-stack-layout Turns on stack layouts for each
procedure, and (currently) each
internal label.
--agc-stack-layout Turns on stack layouts for accurate gc.
implies --basic-stack-layout.
--trace-stack-layout Turns on stack layouts for execution
tracing. Implies --basic-stack-layout.
--alternate-liveness Use what was previously called the
"accurate gc" liveness calculation
method. Execution tracing needs this too.
Add live value information (at entry and exit) for execution tracing.
compiler/call_gen.m:
compiler/handle_options.m:
compiler/live_vars.m:
compiler/liveness.m:
compiler/mercury_compile.m:
compiler/options.m:
compiler/unused_args.m:
Use new options.
Handle new option dependencies.
compiler/code_gen.m:
Use new options.
Generate live value information for entry and exit points
if we are doing execution tracing.
Add typeinfos to livevals(...) instruction so that value
numbering doesn't move them.
compiler/continuation_info.m:
Add support for collecting information on live values at entry
and exit.
Change the data structures to accomodate the new data collection
needed.
compiler/stack_layout.m:
Output tracing liveness information if needed.
Use new options.
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: 0.5
compiler/options.m:
compiler/handle_options.m:
compiler/globals.m:
compiler/polymorphism.m:
runtime/mercury_type_info.h:
Remove the last vestiges of support for type_info representations
other than "shared-one-or-two-cell".
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: 1
compiler/options.m:
Fix some bugs in the `--inhibit-warnings' option:
(1) its sense was inverted and
(2) it was not affecting the settings of the
(i) warn_interface_imports and
(ii) warn_missing_opt_files options.
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: 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.
Estimated hours taken: 1
Fix some problems Fergus pointed out after reviewing my
stack layouts change.
compiler/continuation_info.m:
Separate library imports from compiler imports.
compiler/handle_options.m:
compiler/options.m:
Add some comments to explain the stack_layouts option.
Comment out the documentation of the stack-layouts option,
as it is a developer only option.
compiler/code_gen.m:
compiler/llds.m:
compiler/llds_common.m:
compiler/llds_out.m:
compiler/mercury_compile.m:
compiler/optimize.m:
Remove llds_proc_id from c_procedure, as pred_proc_id is
available instead.
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: 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: 50
Generate stack layouts for accurate garbage collection.
compiler/base_type_layout.m:
Change the order of some arguments so that threaded data
structures are more often in the final two arguments (allows
easy use of higher order predicates).
Simplify some code using higher order preds.
Export base_type_layout__construct_pseudo_type_info, as
stack_layout.m needs to be able to generate pseudo_type_infos
too.
Fix problems with cell numbers being re-used -- get the next
cell number from module_info, and update module_info
after processing base_type_layouts.
compiler/code_gen.m:
Add information about each procedure to the continuation info.
Handle new field in c_procedure.
compiler/continuation_info.m:
Redesign most of this module to deal with labels
that are continuation points for multiple calls.
Change the order of some arguments so that threaded data
structures are in the final two arguments.
Cleaned up and documented code.
compiler/dupelim.m:
compiler/exprn_aux.m:
Handle new label_entry data type.
compiler/export.m:
compiler/opt_debug.m:
Handle new label_entry and general data types.
compiler/llds_out.m:
Add an argument to get_proc_label to control whether a
"mercury_" prefix is wanted.
Handle new label_entry and general data types.
compiler/llds.m:
Add a new alternative for data_const - a label_entry.
Add a new alternative for data_name - general, which
allows any sort of data, with names generated elsewhere.
Add the pred_proc_id as a field of c_procedure.
compiler/optimize.m:
compiler/llds_common.m:
compiler/optimize.m:
Handle new field in c_procedure.
compiler/mercury_compile.m:
Generate layout information after code has been generated,
and output stack layouts.
compiler/notes/compiler_design.html:
Document new stack_layout module.
compiler/stack_layout.m:
New file - generates the LLDS code that defines
global constants to hold the stack_layout structures.
compiler/options.m:
compiler/handle_options.m:
Add --stack-layout option which outputs stack layouts.
Make accurate gc imply stack_layout.
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: 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.
Estimated hours taken: 0.5
compiler/options.m:
Fix a few errors in the help message
(including a couple of syntax errors that I added at the
last moment before committing my previous change).
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.
Estimated hours taken: 7
First implementation of the generation of traces for Opium-style trace
analysis.
In this initial implementation, there are only three ports: call, exit
and fail. Later versions will add ports that indicate entry to an arm
of a switch or disjunction and to the then or else part of an if-then-else.
compiler/options.m:
Add a new option, --generate-trace.
compiler/handle_options.m:
When --generate-trace is on, turn off HLDS->HLDS optimizations
that would change the behavior of the trace.
compiler/code_info.m:
Add a new field in code_into for storing information that is
needed when generating trace code. (At the moment, this info is
the identity of two stack slots storing the sequence number and
depth of the current procedure call.) This info must be in the
code_info structure, because it is used not only by code_gen.m
but also by call_gen.m, and later by switch_gen.m, disj_gen.m and
ite_gen.m.
compiler/code_gen.m:
Add code to initialize the tracing info in code_info and to add
trace statements to procedure prologs and epilogs if --generate-trace
is on.
compiler/call_gen.m:
Clean up the generation of code for calls, merging the three
predicates for det, semi and non procedures into one, and factoring
out some common code between the generation of code for normal calls
and higher order calls. Add code to reset the call depth just before
each (normal or higher-order) call if --generate-trace is on.
compiler/trace.m:
New file responsible for the generation of trace statements in the
C file output by the compiler. Code in code_gen.m and call_gen.m
calls trace.m; so will code in switch_gen.m, disj_gen.m and ite_gen.m.
compiler/mercury_compile.m:
When --generate-trace is on, include mercury_trace.h at the top
of generated C files.
runtime/mercury_trace.[ch]:
The new runtime tracing module. The proper version will be written
in Rennes, this is just for initial testing.
runtime/Mmakefile:
Include the new module in the runtime library.
doc/user_guide.texi:
Document --generate-trace.
Estimated hours taken: 10
Add constant propagation within modules. This occurs during simplification
and simply attempts to evaluate "known" calls that have all their inputs
bound to constants and replaces the call with constructions of the outputs.
Currently the "known" calls are (most) of the arithmetic predicates, and
the comparison of ints and floats.
compiler/instmap.m:
add merge_instmap_deltas which merges a list of intmap deltas
rather than just two of them.
compiler/mercury_compile.m:
compiler/options.m:
add (and use) the option --optimize-constant-propagation
compiler/simplify.m:
add a bool to the simplify struct to turn on/off constant
propagation.
in the simplification of calls, check to see if all the inputs
are bound to constants. If we know how to evaluate this call
at compile time, then do so. This may change the instmap delta.
For branched goals, we merge the instmap deltas to recompute the
instmap delta for the goal as a whole so that we know when every
branch binds a variable to the same constant.
compiler/notes/compiler_design.html:
mention constant propagation.
doc/user_guide.texi:
mention constant propagation.
compiler/const_prop.m:
code that attempts to evaluate calls at compile time.
It contains tables of calls that we know how to evaluate.
current support for trailing. This part just involves changing
the names from application-specific (--constraints) to more
general ones (--use-trail).
scripts/mgnuc.in:
compiler/handle_options.m:
Rename the `*.cnstr' grades as `*.tr', and use
`-DMR_USE_TRAIL' rather than `-DCONSTRAINTS'.
compiler/options.m:
Rename the `--constraints' option as `--use-trail'.
compiler/code_gen.m:
compiler/disj_gen.m:
compiler/ite_gen.m:
compiler/mercury_compile.m:
Trivial changes to handle the renaming of the `constraints'
option as `use_trail'.
Estimated hours taken: 14
Implemented a :- use_module directive. This is the same as
:- import_module, except all uses of the imported items
must be explicitly module qualified.
:- use_module is implemented by ensuring that unqualified versions
of items only get added to the HLDS symbol tables if they were imported
using import_module.
Indirectly imported items (from `.int2' files) and items declared in `.opt'
files are treated as if they were imported with use_module, since all uses
of them should be module qualified.
compiler/module_qual.m
Keep two sets of type, mode and inst ids, those which can
be used without qualifiers and those which can't.
Renamed some predicates which no longer have unique names since
'__' became a synonym for ':'.
Made mq_info_set_module_used check whether the current item is in
the interface, rather than relying on its caller to do the check.
Removed init_mq_info_module, since make_hlds.m now uses the
mq_info built during the module qualification pass.
compiler/prog_data.m
Added a pseudo-declaration `used', same as `imported' except uses of
the following items must be module qualified.
Added a type need_qualifier to describe whether uses of an item
need to be module qualified.
compiler/make_hlds.m
Keep with the import_status whether current item was imported
using a :- use_module directive.
Use the mq_info structure passed in instead of building a new one.
Ensure unqualified versions of constructors only get added to the
cons_table if they can be used without qualification.
compiler/hlds_module.m
Added an extra argument to predicate_table_insert of type
need_qualifier.
Only add predicates to the name and name-arity indices if they
can be used without qualifiers.
Changed the structure of the module-name-arity index, so that
lookups can be made without an arity, such as when type-checking
module qualified higher-order predicate constants. This does not
change the interface to the module_name_arity index.
Factored out some common code in predicate_table_insert which
applies to both predicates and functions.
compiler/hlds_pred.m
Removed the opt_decl import_status. It isn't needed any more
since all uses of items declared in .opt files must now be
module qualified.
Added some documentation about when the clauses_info is valid.
compiler/intermod.m
Ensure that predicate and function calls in the `.opt' file are
module qualified. Use use_module instead of import_module in
`.opt' files.
compiler/modules.m
Handle use_module directives.
Report a warning if both use_module and import_module declarations
exist for the same module.
compiler/mercury_compile.m
Collect inter-module optimization information before module
qualification, since it can't cause conflicts any more. This means
that the mq_info structure built in module_qual.m can be reused in
make_hlds.m, instead of building a new one.
compiler/prog_out.m
Add a predicate prog_out__write_module_list, which was moved
here from module_qual.m.
compiler/typecheck.m
Removed code to check that predicates declared in `.opt' files
were being used appropriately, since this is now handled by
use_module.
compiler/*.m
Added missing imports, mostly for prog_data and term.
NEWS
compiler/notes/todo.html
doc/reference_manual.texi
Document `:- use_module'.
tests/valid/intermod_lambda_test.m
tests/valid/intermod_lambda_test2.m
tests/invalid/errors.m
tests/invalid/errors2.m
Test cases.
Estimated hours taken: 0.05
compiler/llds_out.m:
compiler/mercury_to_goedel.m:
compiler/options.m:
library/lexer.m:
library/string.m:
library/term_io.m:
Remove references to `character' since use of it is discouraged.
Use `char' instead.
Estimated hours taken: 3
Enable --warn-interface-imports by default. This was turned off while
list and term were defined in mercury_builtin.m, since it caused many
warnings.
Fix all the unused interface imports that have been added since then.
compiler/options.m:
Enable --warn-interface-imports by default.
compiler/module_qual.m:
Fix formatting inconsistencies with module names in warning
messages. (".m" was not appended to module names if there was
only one module).
compiler/*.m:
library/*.m:
tests/invalid/type_loop.m:
tests/warnings/*.m:
Remove usused interface imports, or move them into
implementation (mostly bool, list and std_util).
Estimated hours taken: 5
Remove support for term_to_type and type_to_term implemented as special
preds. Remove support for one-cell and one-or-two-cell type_infos (now
shared-one-or-two-cell type_infos). Move definitions that were in
mercury_builtin.m back to where they belong.
This code has been removed because it is no longer used, and was no
longer being maintained but was still quite complex.
compiler/globals.m:
compiler/handle_options.m:
compiler/mercury_compile.m:
compiler/options.m:
Remove one_cell and one_or_two_cell from type_info methods.
compiler/polymorphism.m:
Remove term_to_type and type_to_term support.
Remove one_cell and one_or_two_cell from type_info methods.
Fix documentation to reflect the new situation.
compiler/special_pred.m:
compiler/unify_proc.m:
Remove term_to_type and type_to_term support.
library/list.m:
Put the definition of `list' back into list.m
library/mercury_builtin.m:
Take the definitions of `list', `term', `var', `var__supply',
etc, out of this module.
Remove type_to_term, term_to_type, det_term_to_type,
term__init_var_supply, term__create_var, term__var_to_int
and term__context_init.
Remove references to USE_TYPE_TO_TERM and #ifdefs around
SHARED_ONE_OR_TWO_CELL_TYPE_INFO.
library/std_util.m:
Remove references ONE_OR_TWO_CELL_TYPE_INFO, and code that
handles one-cell typeinfo comparisons.
library/term.m:
Add type_to_term, term_to_type, det_term_to_type,
term__init_var_supply, term__create_var, term__var_to_int
and term__context_init back to term.m.
Add new implementation of type_to_term/2.
library/uniq_array.m:
Fix a typo in a comment - term_to_type/3 instead of term_to_type/2.
runtime/call.mod:
Remove special case code for unify, compare, index for
one-cell typeinfos.
Remove code for type_to_term/2.
runtime/type_info.h:
Remove references to ONE_CELL_TYPE_INFO or ONE_OR_TWO_CELL_TYPE_INFO.
Make sure only SHARED_ONE_OR_TWO_CELL_TYPE_INFO.
Remove references to USE_TYPE_TO_TERM.
compiler/base_type_layout.m:
compiler/bytecode_gen.m:
compiler/code_util.m:
compiler/delay_slot.m:
compiler/det_util.m:
compiler/fact_table.m:
compiler/hlds_data.m:
compiler/hlds_goal.m:
compiler/mode_debug.m:
compiler/tree.m:
library/bag.m:
library/queue.m:
Import module `list' or `term' (or both).
Estimated hours taken: 0.5
compiler/options.m:
doc/user_guide.texi:
Add shorter forms of some options:
`--make-int' for `--make-interface'
`--make-opt-int' for `--make-optimization-interface'
`--make-short-int' for `--make-short-interface'
Estimated hours taken: 6
tag_switch:
So far the switches on the primary and secondary tags have been
implemented either as try-me-else chains or jump tables. I have
added a new alternative, try chains, that should be more efficient
than try-me-else chains for small-medium sized switches.
options:
Add an option, --try-switch-size, giving the size threshold for
the new switch method.
Estimated hours taken: 0.01
Fixed the message given by 'mc --help' to conform with the user guide. The
help message indicated hlds dump stages going from 1-19, but the user guide
said 1-99
compiler/options.m:
Changed the hlds-dump range in the documentation from 1-19 to 1-99.
Estimated hours taken: 2
Fix a bug in saved_vars.m that caused an abort at -O5.
The problem was that saved_vars was renaming and pushing variables
into branched goals so that they were no longer non-local to the
branched goal, but was leaving the non-renamed variables in the
instmap_delta. The fix is to call recompute_instmap_delta.
compiler/options.m
Undisable saved_vars.m.
compiler/saved_vars.m
Call recompute instmap_delta after the saved_vars pass.
saved_vars_proc now returns a module_info.
compiler/passes_aux.m
Add a new task type update_module_io to handle saved_vars.
compiler/module_info.m
Update calls to saved_vars_proc.
Estimated hours taken: 250
Implemented `:- pragma fact_table' for string, int and float
argument types. Facts can have any combination of input and output modes.
Hash tables are used to lookup facts in modes that have input
arguments.
compiler/fact_table.m:
Added code for outputting `pragma c_code' to access facts in all
mode/determinism combinations in `pragma fact_table's.
Added code to build and output hash tables (as C arrays) for
input modes of fact tables.
Many other changes and rearrangements in the module to support the
above.
compiler/export.m:
Moved declarations for `convert_type_from_mercury/3' and
`convert_type_to_mercury/3' to the interface so they can be
used by `fact_table.m'.
compiler/handle_options.m:
Add a check to `postprocess_options' to ensure that arguments
to `--fact-table-hash-percent-full' are integers in the range
1 to 100.
compiler/inlining.m:
Stop `model_non' `pragma c_code' being inlined unless it has
the new `extra_pragma_info' field (which hasn't been fully
implemented yet). This ensures that code such as the lookup
code generated for nondet and multidet modes of `pragma
fact_table's works with inlining turned on.
compiler/make_hlds.m:
Added arguments to the calls to predicates in fact_table.m
where necessary.
Add `c_header_code' returned by `fact_table_compile_facts' to
the module_info.
compiler/mode_util.m:
Added two new predicates:
`mode_is_fully_input' which is true iff the initial
inst of the mode is ground.
`mode_is_fully_output' which is true iff the inital inst is
free and the final inst is ground.
compiler/modules.m:
Added a dependency to `.d' files to ensure that fact table C
files are recompiled whenever they are recreated.
compiler/options.m
Added new options:
`--fact_table_max_array_size <n>' where n is the
maximum size array to use for `pragma fact_table'
data. (default 1024)
`--fact_table_hash_percent_full <n>' where n is how
full the `pragma fact_table' hash tables should
be allowed to get, given as an integer percentage
(between 1 and 99). (default 90).
Documentation for these options has been added to the usage
message but is commented out at the moment.
Estimated hours taken: 4 (to find the bug) plus 0.5 (to fix it).
compiler/options.m:
Change things so that the saved-vars pass is enabled only
at -O3, not at -O1, since the benefit is probably not worth
the compilation time at -O1 or -O2.
But then disable the saved-vars pass entirely, since it is
broken (`mc -O5 --optimize-saved-vars llds_out.m' dies).
Estimated hours taken: 1
Added an option --warn-duplicate-calls to control the duplicate
call warnings. This is off by default because it produces warnings
for reasonable code, such as multiple calls to set__init with
arguments of types which are only the same after equivalence
expansion.
compiler/options.m
Added --warn-duplicate-calls.
compiler/simplify.m
compiler/common.m
compiler/mercury_compile.m
Use the new option.
Estimated hours taken: 0.25
compiler/options.m:
Enable `--optimize-jumps' and `--optimize-labels' at `-O0'
rather than at `-O1', since my (limited) testing shows
that these optimizations in fact improve overall compilation speed.
Estimated hours taken: 100
* Inter-module unused argument removal.
* Allow the user to specify which directories should be searched
for .opt files.
* Enhancements to simplify.m and common.m which will be useful for
partial deduction.
compiler/options.m
Added and documented options:
--intermod-unused-args to enable inter-module unused argument removal.
--intermod-directory <dir>, same as --search-directory except used
to locate .opt files.
--use-search-directories-for-intermod - use the search directories
for .opt files as well.
--warn-simple-code - a flag to control the warnings produced by
simplify.m so that they respect --inhibit-warnings.
compiler/unused_args.m
Use the unused argument info from the .opt file.
Clobber the dependency_info if any new preds were added.
compiler/hlds_module.m
Added a field to the module_info to store unused argument
information from .opt files.
compiler/prog_data.m
Add :- pragma unused_args to hold unused argument information.
This should only be used in .opt files.
compiler/make_hlds.m
Build the unused_arg_info field in the module_info.
Check that pragma unused_args only appears in .opt files.
Fill in the non-locals field in the goal_info for the builtin
stubs so that mode analysis computes the correct instmap delta.
compiler/intermod.m
Read in the unused argument information for the current module when
compiling to C. This is used to ensure that clauses are produced with
the correct number of removed arguments (it may be possible to remove
more arguments with the information from other modules).
Fix a bug in the handling of module qualified function calls and
higher-order predicate constants.
compiler/handle_options.m
Handle --intermod-unused-args and
--use-search-directories-for-intermod.
compiler/mercury_compile.m
Run the entire front end and polymorphism (not just up to
typechecking) when building the .opt file with
--intermod-unused-args.
Use the new interface to simplify.m, remove calls to excess.m
and common.m.
compiler/code_util.m
compiler/llds_out.m
When generating local code for a specialized version of a predicate
from another module, put this module's name on the label to avoid
link errors.
compiler/higher_order.m
Don't add the originating module name to the name of the specialized
version, since that is now done in code_util.m.
Clobber the dependency graph so that inlining will work on the
specialized versions in profiling grades (this will cause slightly
slower compilation in profiling grades, something I need to fix).
compiler/simplify.m
Merge a branching goal and an adjacent switch where the branches
of the first goal contain extra information about the switched
on variable of the second goal.
Merge the excess assignments and common subexpression elimination
passes into simplify.m.
compiler/excess.m
The functionality of this module is now in simplify.m, but I'll
leave it here for now.
compiler/instmap.m
Added predicates instmap__bind_var_to_functor and
instmap_delta_bind_var_functor to which take a var, cons_id
and an instmap and adjust the inst of the var. This is used to
update the instmap at the beginning of each case in a switch.
Fix a bug in merge_instmap_delta where variables whose inst had
information added in one branch of a switch, disj, or ite had that
changed inst included in the instmap_delta for the entire
branched goal.
compiler/mode_util.m
Use instmap_delta_bind_var_to_functor in recompute_instmap_delta.
Added predicate bind_inst_to_functor which takes a ground or bound
inst and a cons_id and adjusts the top level of the inst to be bound
to that cons_id. Other types of inst are left unchanged.
Change recompute_instmap_delta so that the switched on variable of
a switch is bound to the functor in each case even if the binding
unification has been removed. Added a boolean argument to request
recomputation of instmap_deltas for atomic goals.
compiler/modes.m
compiler/unique_modes.m
Make sure that the instmap_delta for each branch of a switch
includes the extra information added by the functor test.
compiler/common.m
Removed the goal traversal. Leave preds to be called by simplify.m
to optimise common unifications and calls.
Warn about and eliminate multiple calls to a predicate with the same
input arguments.
Replace deconstructions of known terms with assignments to the output
variables where this would not make more variables live at stack
flushes.
compiler/follow_code.m
Exported move_follow_code_select.
Don't move follow code into erroneous branches.
library/string.nu.nl
Added string__contains_char/2.
compiler/base_type_layout.m
compiler/special_pred.m
compiler/vn_order.m
library/mercury_builtin.m
Removed duplicate calls.
doc/user_guide.texi
Documented options.
tests/warnings/duplicate_call.m
tests/warnings/duplicate_call.exp
Test duplicate call warning.
Estimated hours taken: 10
This change fixes two bugs, in quantification and liveness. I made the changes
to the other files while trying to find them; they ought to be useful in
trying to find similar bugs in the future.
The compiler now bootstraps with agressive inlining enabled.
quantification:
Fix a bug that switched two different accumulators of the same type
when processing pragma_c_codes.
liveness:
Fix a bug that could cause a variable to end up in both the post-death
and post-birth set of the same goal.
options:
Reenable inlining.
hlds_out, mercury_to_mercury:
If -D v is given, include the number of each variable at the end of
its name (e.g. Varname_20).
The predicates involved (a few from mercury_to_mercury and many from
hlds_out) now have an extra argument that says whether this should be
done or not. (It is not done when printing clauses e.g. for .opt
files.)
The bug in quantification was causing the improper substitution of
one variable for another, but both had the same name; such bugs would
be very difficult to find without this change.
constraint, det_report, intermod, make_hlds, mercury_to_c, mode_debug,
mode_errors, module_qual, typecheck:
Call predicates in hlds_out or mercury_to_mercury with the extra
argument.
saved_vars:
Thread the io__state through this module to allow debugging.
mercury_compile:
Call saved_vars via its new interface.
Fix an inadvertent use of an out-of-date ModuleInfo.
goal_util, hlds_goal:
Minor formatting cleanup.
code_gen:
Clean up the import sequence.
Estimated hours taken: 1.5
options:
Make the -D option take a string argument, which governs which
annotations will be printed in HLDS dumps. With an empty string
as an argument, no annotations will be printed (this is the default).
With the argment "all", all annotations will be printed. With any
other argument value, what governs whether an annotation is printed
is whether its identifying letter appears in the argument. These
letters are:
a - argument modes in unifications,
b - builtin flags on calls,
c - contexts of goals and types,
d - determinism of goals,
f - follow_vars sets of goals,
i - instmap deltas of goals,
n - nonlocal variables of goals,
p - pre-birth, post-birth, pre-death and post-death sets of goals,
r - resume points of goals,
s - store maps of goals.
hlds_out:
Use the value of the argument of -D do decide what to print.
handle_options:
Turn -D all into what is expected by hlds_out.
intermode, mercury_to_c:
Update code that temporarily disables verbose dumps.
Estimated hours taken: 0.25
Fix a bug which meant that the "--intermod-simple-inline-threshold"
option was not being recognized.
compiler/options.m:
Add a clause for "intermod-simple-inline-threshold" to the
long_options predicate.