Estimated hours taken: 0.5
Branches: main
compiler/options.m:
Add a bunch of options which will be needed by future changes
to implement `ml' and `c2init' in the compiler. I'm committing
this now to make bootstrapping easier.
Estimated hours taken: 2
Branches: main, release
Update the documentation to reflect recent changes in what is/is not
supported.
compiler/options.m:
doc/user_guide.texi:
Document the `--high-level-data' option.
Document the `il' and `hl' grades.
Delete documentation of the `ilc' grade.
Avoid using "Microsoft" for things which are no longer
Microsoft-specific.
Various other minor wording changes.
Estimated hours taken: 20
Branches: main
Fix several occurrences of a bug that prevented the compiler from passing
all the tests in deep profiling grades. We now pass all the tests in deep
profiling grades.
Some additional changes were useful in tracking this bug down. Using C types
to represent deep profiling data structures allowed us to delete a bunch of
casts and thus eliminate them as potential bug locations. Another was to fix
some bugs in low level debugging support.
In light of the fragility of the deep profiling invariants, always check them
when writing out deep profiling data files. Since mdprof depends on these
invariants, they have to be checked somewhere, and we already have code for the
checks in the runtime.
Reenable tail recursion support in deep profiling grades, since it now works.
(The bug this change fixes used to occur most in tail recursive procedures,
which is why previously I turned it off.)
compiler/options.m:
Reenable tail recursion support in deep profiling grades.
runtime/mercury_unify_compare_body.h:
Fix the bug that prevented us from passing all the tests with
invariants checked and tail recursion support enabled. The bug was
that in several cases, the code in mercury_unify_compare_body.h
did not invoke the appropriate deep profiling routines and thus
did not fill in the deep profiling data structure they were supposed to
fill in, breaking an invariant.
There were several instances of this bug: unify, compare and
compare_representation on tuples, and compare_representation on
functions, predicates and user-defined types.
These oversights were possible because the actions of returning an
answer and filling in the deep profiling data structures (in deep
profiling grades) were separate. If one omitted the latter, tests could
still work in all grades except deep profiling grades.
The fix therefore uses one macro (return_compare_answer or return
unify_answer, depending on the the operation) to fill in the deep
profiling data structure (in deep profiling grades) and return the
answer, making it impossible to forget to do the former.
The new approach treats compare_representation the same as compare,
and gathers the same information for it.
runtime/mercury_ho_call.c:
Factor out some commonalities in the definitions of the MR_ProcStatic
data structures used by the code in mercury_unify_compare_body.h.
Change a macro name to support the changes in
mercury_unify_compare_body.h.
Change the module name of compare_representation/3 from std_util to
builtin, to match unify/2 and compare/3.
compiler/deep_profiling.m:
Treat compare_representation/3 the same way as we treat compare/3.
library/builtin.m
library/std_util.m
Move the declaration of compare_representation/3 from std_util to
builtin, to make it easier to handle it the same way as compare/3.
Since it is just a variant of compare/3 and is at least as built
into the implementation, it belongs there anyway.
library/profiling_builtin.m:
Use C types to represent deep profiling data structures.
Delete the casts that are redundant after this change.
Fix formatting of foreign_procs.
runtime/mercury_deep_profiling.c:
As mentioned above, always check the invariants of the deep profiling
data structures when writing them out.
runtime/mercury_deep_profiling.h:
Avoid a warning about nested declarations of variable "i".
runtime/mercury_deep_rec_depth_body.h:
Delete a bunch of casts we don't need anymore.
runtime/mercury_wrapper.[ch]:
Initialize a couple of predicate names in the low level debug support
to "" instead of NULL. The code that accesses these variables passes
them to strcmp directly, which lead to core dumps. We could change the
accessing code to test for NULL, but since that code is executed on
every call when low level debugging is enabled, that would lead to
even greater slowdowns, which we can do without.
To avoid a warning about casting away const, make the variables
involved "const char *" instead of plain "char *"; we don't want
to update the pointed-to strings anyway.
tools/bootcheck:
In profiling grades, write out profiling data files by default, and
require the use of an option to turn them off. This is needed to make
sure that the deep profiling invariants are checked by default.
tests/hard_coded/compare_rep_usereq.m:
tests/hard_coded/compare_representation.m:
Avoid hard-coding the name of the module defining
compare_representation/3.
Estimated hours taken: 3
Branches: main
Gets the tests in tests/invalid working in the il grade.
compiler/options.m:
Add a new developer option, --no-automatic-intermodule-optimization.
This is used to turn off intermodule optimization in the
tests/invalid directory so that the error messages are no
longer generated during the --make-optimization-interface
process.
compiler/handle_options.m:
Test automatic-intermodule-optimization when determining
whether to turn intermodule optimization on in the il grade.
tests/invalid/Mercury.options:
tests/invalid/purity/Mercury.options:
Add --no-automatic-intermodule-optimization.
tests/invalid/foreign_singleton.err_exp2:
tests/invalid/foreign_type_2.err_exp2:
tests/invalid/pragma_c_code_dup_var.err_exp2:
tests/invalid/pragma_c_code_no_det.err_exp2:
Add a second expected error message for non C backends.
tests/invalid/impure_method_impl.m:
tests/invalid/multimode_missing_impure.m:
tests/invalid/multimode_syntax.m:
tests/invalid/pragma_c_code_no_det.m:
tests/invalid/purity/impure_func_t2.m:
tests/invalid/purity/impure_func_t3.m:
tests/invalid/purity/impure_func_t4.m:
tests/invalid/purity/impure_func_t5.m:
tests/invalid/purity/impure_func_t7.m:
tests/invalid/purity/impure_pred_t1.m:
tests/invalid/purity/impure_pred_t2.m:
tests/invalid/purity/purity.m:
Add Mercury implementations of foreign_code predicates.
Estimated hours taken: 2.5
Branches: main
Improve the handling of `--use-grade-subdirs' so that it can
be documented.
compiler/compile_target_code.m:
With `--use-grade-subdirs', link or copy executables
and libraries into the user's directory.
compiler/make.program_target.m:
compiler/modules.m:
Move code to create a symlink into modules.m, next to
the code to create directories (all of this should really
go in the standard library).
Add a predicate to copy a file (which should also go
in the standard library).
compiler/make.program_target.m:
Make the realclean target delete the symlinks or copies
of executables and libraries.
NEWS:
library/io.m:
Add io__binary_input_stream_foldl, etc. for use in copying files.
NEWS:
compiler/options.m:
doc/user_guide.texi:
Document `--use-grade-subdirs'.
tests/Mmakefile:
tests/grade_subdirs:
tests/grade_subdirs/Mmakefile:
tests/grade_subdirs/Mercury.options:
tests/grade_subdirs/hello.{m,exp}:
Test case.
Estimated hours taken: 900
Branches: main
Added loop-invariant hoisting optimization.
liveness.m:
Improved the debugging output to show HLDS before and after
liveness analysis.
loop_inv.m:
New module containing the implementation of the loop invariant
hoisting optimization.
mercury_compile.m:
Added loop_inv at step 34, moving inlining to step 35.
options.m:
Added bool option --loop-invariants (default `no').
This optimization is set at -O4.
passes_aux.m:
Minor changes to support introduction of the loop
invariant hoisting optmimization.
follow_code.m:
Updated to reflect the new interface to passes_aux.m.
transform_hlds.m:
Added include_module declaration for loop_inv.
Estimated hours taken: 1
Branches: main
With `--make', warn if a target specified on the command line
is already up to date.
compiler/make.util.m:
Check whether a target that was found to be up to date
was specified on the command line.
compiler/make.m:
Add the targets specified on the command line to the make_info.
compiler/make.module_target.m:
compiler/make.program_target.m:
compiler/make.dependencies.m:
Call make__util__maybe_warn_up_to_date_target when a target
is found to be up to date.
Remove targets from the list of targets specified on the command
line as they are processed to avoid generating multiple warnings.
compiler/options.m:
doc/user_guide.texi:
Add an option `--no-warn-up-to-date'.
tests/warnings/Mmakefile:
tests/warnings/up_to_date.{m,exp}:
Test case.
Estimated hours taken: 6
Branches: main
Document I/O tabling, after cleaning it up for public use.
We have previously implemented two forms of I/O tabling. One tables
only the output arguments of each primitive; this allows transparent
retries across I/O. The other tables all the arguments and the name
of the predicate; this allows transparent retries across I/O, the
declarative debugging of code that does I/O, and the printing of tabled
I/O actions. Since we now support declarative debugging in the standard
debugging grades, standardize on the second form of I/O tabling, and
make the first form accessible to implementors only, via a deliberately
undocumented option. This option, --trace-table-io-only-retry, is sort of
the inverse of the old option --trace-table-io-decl, which this change
deletes. (Only "sort of" because --trace-table-io-decl used to turn on
I/O tabling, whereas --trace-table-io-only-retry is consulted only if
I/O tabling is turned on by some other mechanism.)
NEWS:
Mention I/O tabling.
compiler/options.m:
Delete --trace-table-io-decl, and add --trace-table-io-only-retry.
Update documentation.
compiler/table_gen.m:
Base decisions on --trace-table-io-only-retry, not
--trace-table-io-decl.
compiler/handle_options.m:
Delete an implication involving --trace-table-io-decl that is now
unnecessary.
doc/user_guide.texi:
Document the idea of I/O tabling, and move the table_io command
out of the list of developer only commands into a category of its own
(since it doesn't naturally fit anywhere else).
Change the old mismatched "table_io start" "table_io end" pair to
the matched "table_io start" "table_io stop" pair.
Document the variants of the print and browse commands that print and
browse I/O actions.
Be consistent about formatting of categories of mdb commands.
Comment out some obsolete material in the documentation of retry.
doc/generate_mdb_doc:
Include the new table_io category in the list of mdb command
categories.
Squeeze out repeated blank lines in the automatically generated
documentation, to make maximum use of screen real estate.
doc/squeeze:
A new script to do the squeezing.
doc/mdb_categories:
Include the new table_io category in the list of mdb command
categories.
runtime/mercury_trace_base.[ch]:
Add a new global variable MR_io_tabling_allowed. It is initialized
to TRUE in debugging grades and FALSE in other grades.
trace/mercury_trace_internal.c:
Accept "table_io begin" and "table_io end" as well as "table_io start"
and "table_io stop". Consistently use "start" and "stop" in output.
Make "table_io" print a message saying the executable is not set up
for I/O tabling unless MR_io_tabling_allowed is set.
Add a new command, "table allow", that sets MR_io_tabling_allowed to
TRUE. In debugging grades, this has no effect. In other grades, it
allows I/O tabling, even though some parts of the program may have
been compiled with --trace-table-io and some without. This
inconsistency can yield weird results, which is why this command is
deliberately undocumented. However, we can use it in a disciplined
fashion to test I/O tabling even in nondebugging grades, thus spotting
any regression in this area more quickly than if we tested I/O tabling
only in debugging grades.
tests/debugger/Mercury.options:
tests/debugger/declarative/Mercury.options:
Delete all occurrences of --trace-table-io-decl, since its effect is
now the default.
tests/debugger/mdb_command_test.inp:
Move the location of the table_io command test in this autogenerated
file to reflect its move to a new category.
tests/debugger/tabled_read*.{inp,exp}:
tests/debugger/declarative/tabled_read*.{inp,exp}:
Execute "table_io allow" before trying to turn on I/O tabling, since
this is now required in non-debugging grades.
Reflect the change in terminology: expect "stopped", not "ended",
Estimated hours taken: 2
Branches: main
Fix some inconsistent documentation of the declarative debugging
options and grades. This finishes off Zoltan's earlier change
to expunge all mention of the `--decl-debug' option and `.decldebug'
grade component from the user documentation, and adds mention of
`--trace rep' in some places where previously it was missing.
doc/user_guide.texi:
- Fix a typo in some XXX comments: s/usefull/usefully/
- Comment out all remaining occurrences of `.decldebug'
compiler/options.m:
- Mention (again) that all options should be documented,
and describe in detail how/where it should be done.
- Add a pointer to the documentation for the
stack_trace, require_tracing, and decl_debug options
in runtime/mercury_conf_param.h.
- Update the explanation of why `--trace decl' isn't included
in the help message; the previous explanation was no longer true.
- Include `--trace rep' in the help message,
since it is documented in the user guide.
- Don't include `--decl-debug' in the help message,
since its documentation is commented out in the user guide.
Estimated hours taken: 2
Branches: main
tests/invalid/Mmakefile:
Only enable the `nonexistent_import' test when
--use-subdirs is enabled, because that test case gets
built with --make, which implies --use-subdirs, and
we run into problems if we try to run some tests with
--use-subdirs and some without.
doc/user_guide.texi:
compiler/options.m:
Document that --make implies --use-subdirs.
Estimated hours taken: 2
Branches: main
Make debug grades require tabling of I/O primitives, so that debugging
executables can do retries across I/O safely (if the user turns on I/O tabling
in mdb).
compiler/options.m:
Add an option, trace_table_io_all, whose semantics is that if it is
set, then all I/O primitives will be tabled. It is meant to be set in
debug grades. It is not meant to be used explicitly, even by
developers, except for benchmarking and to create consistency in tests.
compiler/handle_options.m:
Make debug grades imply trace_table_io_all.
compiler/table_gen.m:
Implement the new option.
tests/debugger/Mercury.options:
tests/debugger/declarative/Mercury.options:
Specify the new option, to avoid one source of differences between
the expected outputs in debug and non-debug grades.
Estimated hours taken: 2
Branches: main
Add a new grade component, .decldebug. It is as proposed on mercury-developers,
minus the implications about I/O tabling. Those will come later.
compiler/options.m:
Add a new option, --decl-debug, that switches on declarative debugging.
compiler/trace_params.m:
The procedure that converts strings representing trace levels to trace
levels themselves now has an extra argument, which gives the value of
the --decl-debug option. If set, it raises the minimum trace level,
and turn explicitly specifying trace levels `shallow' and `deep'
into errors (since they are not sufficient for declarative debugging).
compiler/handle_options.m:
Pass the value of the --decl-debug option to trace_params, and handle
the errors that may result. Handle the implications of --decl-debug
and the .decldebug grade component.
compiler/compile_target_code.m:
Define MR_DECL_DEBUG when invoking the C compiler if --decl-debug is
set.
runtime/mercury_conf_param.h:
Document MR_DECL_DEBUG, which is defined iff the grade is a .decldebug
grade.
runtime/mercury_grade.h:
Take MR_DECL_DEBUG into account when computing the grade component
related to debugging.
Update the list of places that need to be modified when adding new
grade components.
doc/user_guide.texi:
Document --decl-debug and the .decldebug grade component.
Document the events used by declarative debugging, since Mark didn't.
Fix some minor unrelated omissions.
scripts/init_grade.sh-subr:
scripts/parse_grade_options.sh-subr:
scripts/final_grade.sh-subr:
scripts/canonical_grade.sh-subr:
scripts/mgnuc.in:
scripts/ml.in:
Add a new shell variable, decl_debug, to represent the value of
MR_DECL_DEBUG, and handle it as appropriate.
tests/debugger/Mmakefile:
Do not execute shallow traced tests in .decldebug grades, since we
don't support shallow tracing in such grades.
Specify --trace decl instead of --trace deep in .decldebug grades
when compiling the other tests, since we don't support --trace deep
in .decldebug grades.
Estimated hours taken: 0.2
Branches: main
compiler/options.m:
My change to the installation of `.opt' files broke
backwards compatibility (installation doesn't work
if the dependencies are generated by an old compiler),
so add an option for use in configure.in.
Estimated hours taken: 0.5
Branches: main
compiler/options.m:
doc/user_guide.texi:
Fix a couple of places in the documentation where I had forgotten
to document the `.mps' grade modifier.
Estimated hours taken: 20
Branches: main
Add support for interfacing Mercury with the MPS garbage collector.
This change is broken into three parts:
1. Import version 1.100.1 of the MPS kit into the Mercury
CVS repository, in the directory `mps_gc'.
2. Make some changes to the MPS kit for Mercury,
to support fully-conservative collection and tagged pointers,
and to wrap it in an interface that is similar to that of
the Boehm collector.
3. Modify the rest of the Mercury implementation
to support linking with the MPS kit instead
of the Boehm collector. This involved defining
`mps' as a new GC method and a new grade component.
This is part 3 of 3.
Mmake.workspace:
Include the MPS directories in the header file and library search
paths.
tools/bootcheck:
Link the mps_gc directory into the stage2 and stage3 directories.
Mmake.workspace:
runtime/Mmakefile:
scripts/ml.in:
For *.mps grades, link in mps.a.
(XXX ml.in is linking in libmps.a, which is wrong.)
runtime/Mmakefile:
trace/Mmakefile:
In the rule for `check_headers', which checks macro namespace
cleanliness, allow names to start with `MPS_' or `mps_'.
runtime/RESERVED_MACRO_NAMES:
Add `mercury_mps_h', which is used by mps_gc/code/mercury_mps.h
for its header guard. (Normally it would be better to use
uppercase for header guard macro names, but that would be
inconsistent with the coding style used in mps_gc/code.)
scripts/canonical_grade.sh-subr:
scripts/init_grade_options.sh-subr:
scripts/parse_grade_options.sh-subr:
scripts/canonical_grade.sh-subr:
Handle the new `mps' GC method and grade component.
compiler/globals.m:
compiler/options.m:
doc/user_guide.texi:
Replace gc_method `conservative' with two alternatives
`boehm' and `mps'. ("--gc conservative" is still allowed,
and treated as equivalent to "--gc boehm".)
Add new function `gc_is_conservative' to globals.m.
compiler/mercury_compile.m:
compiler/handle_options.m:
Use `gc_is_conservative' rather than `= conservative'.
compiler/handle_options.m:
Handle the "mps" grade component.
(XXX need to document this in options.m and user_guide.texi)
compiler/compile_target_code.m:
Pass the appropriate C defines for the new GC methods.
compiler/mercury_compile.m:
Wrap the work-around for a Boehm GC bug inside `#ifndef MR_MPS_GC'.
library/array.m:
Use GC_FREE() rather than GC_free().
This is needed for two reasons:
- so that it works with MPS, which only defines GC_FREE
- so that it works with then Boehm collector when
GC debugging is enabled
library/benchmarking.m:
Output GC statistics for the MPS collector.
runtime/mercury.h:
runtime/mercury_heap.h:
runtime/mercury_init.h:
runtime/mercury_memory.h:
If MR_MPS_GC is defined, use mercury_mps.h rather than gc.h.
runtime/mercury_conf_param.h:
Add configuration macros MR_BOEHM_GC and MR_MPS_GC.
Set MR_CONSERVATIVE_GC if either of these is set.
Default to MR_BOEHM_GC if only MR_CONSERVATIVE_GC is set.
runtime/mercury_context.h:
runtime/mercury_deep_copy.h:
runtime/mercury_engine.h:
runtime/mercury_float.h:
runtime/mercury_heap.h:
Explictly #include "mercury_conf.h", so that
MR_CONSERVATIVE_GC will be set properly before it is tested.
runtime/mercury_grade.h:
Handle the .mps grade component.
runtime/mercury_memory.c:
runtime/mercury_wrapper.c:
runtime/mercury_memory_handlers.c:
Move the call to MR_setup_signals() earlier in the
initialization sequence, so that the MPS signal handlers
get installed after our signal handlers. This is needed
because our signal handlers assume that any signals that
they can't handle are fatal errors, which interfere's
with MPS's use of signal handlers for memory barriers.
runtime/mercury_wrapper.c:
Add code to initialize the MPS collector.
Put code which is specific to the Boehm collector inside
#ifdef MR_BOEHM_GC rather than #ifdef MR_CONSERVATIVE_GC.
runtime/mercury_wrapper.h:
Update a comment.
Estimated hours taken: 2
Branches: main
Fix quoting of arguments to commands invoked by mmc.
compiler/compile_target_code.m:
compiler/make.module_target.m:
Quote arguments passed to commands.
compiler/options_file.m:
Pass each word in the value of CFLAGS (MLFLAGS, etc) as a
separate `--cflag' option so it can be quoted correctly.
NEWS:
compiler/options.m:
doc/user_guide.texi:
For each `--Xflags' option, add a `--Xflag' option which
quotes its argument if necessary then adds it to
the `--Xflags' option.
Estimated hours taken: 10
Branches: main
Library installation with `mmc --make'.
compiler/make.m:
compiler/make.program_target.m:
Handle `mmc --make lib<module>.install'.
compiler/options.m:
Add an option `--use-grade-subdirs', which causes
all grade-dependenent files to be placed in
`Mercury/<grade>/<ext>s' subdirectories, even
those files that are intended for use by the user.
`--use-grade-subdirs' is not documented because it
is only intended for use in library installation
with `mmc --make' (it doesn't work at all with Mmake).
Documenting it would require documenting (and setting
in stone) the layout of the `Mercury' directory, which
is probably a bad idea.
Mmake.workspace:
compiler/handle_options.m:
scripts/Mmake.rules:
Header files are now always searched for using the plain
file name (not Mercury/mihs/module.mih), so add a
`--c-include-directory' option to search Mercury/mihs
in the current directory.
compiler/modules.m:
compiler/intermod.m:
compiler/make.module_dep_file.m:
compiler/mercury_compile.m:
compiler/mlds_to_c.m:
compiler/trans_opt.m:
Handle `--use-grade-subdirs' in module_name_to_file_name.
Add module_name_to_search_file_name, which should be
used to generate the names of files that might be part
of an installed library. This is needed because installation
and local directory hierarchies have a different layout,
A better long-term fix would be to change things so that
the installation and local directory layouts are the same.
compiler/make.util.m:
compiler/make.dependencies.m:
compiler/make.module_target.m:
Add an extra argument to get_target_timestamp and
get_file_name to specify whether the file should
be searched for.
compiler/options_file.m:
scripts/Mmake.vars.in:
Handle the LIBGRADES and INSTALL_PREFIX make variables.
doc/user_guide.texi:
Remove the statement that library installation is
not supported with `mmc --make'.
Estimated hours taken: 0.25
Branches: main
Add a new option that will be used to test whether the compiler is
recent enough to compile the changes to the library that require
foreign_import_module pragma to be handled correctly.
This will be needed by the configure test at a later date, when using a
foreign_type for io__stream is re-enabled.
compiler/options.m:
Add the option bug-foreign_import-2002-08-06.
Estimated hours taken: 10
Branches: main
Make the compiler bootstrap again in deep profiling grades, even with sanity
checks enabled. A few test cases still fail, and actually writing out profiling
data still trips a sanity check.
library/exception.m:
runtime/mercury_exception_catch_body.h:
Fix a bug: builtin_catch was not calling prepare_for_ho_call before
making a higher order call. This let the call port code in the called
predicate access memory through an uninitialized pointer.
library/private_builtin.m:
Fix the initialization code used in deep profiling grades, which
previously were misrepresenting internal labels as entry labels.
compiler/options.m:
Turn off the special handling of tail recursion by the deep profiling
transformation, since at the moment it doesn't work.
compiler/layout_out.m:
When outputing each call_site_static structure, include a comment
giving its offset in the array containing it. This makes it easier
to find the index you want in a large array of call_site_static
structures.
runtime/mercury_debug.[ch]:
Add an extra argument to MR_print_deep_prof_vars, to identify where it
is called from. This makes it easier to understand debugging output.
runtime/mercury_deep_call_port_body.h:
library/profiling_builtin.m:
trace/mercury_trace_internal.m:
Add the new argument to calls to MR_print_deep_prof_vars.
Make calls to MR_print_deep_prof_vars conditional on a runtime test,
to prevent huge amounts of unwanted output.
Estimated hours taken: 1.5
Branches: main
Fix the code to add extra initialization functions to library/mer_std.init.
compiler/options.m:
doc/user_guide.texi:
compiler/compile_target_code.m:
Rename the `--make-init-file-command' as `--extra-init-command'.
This should now only generated the extra entries in the `.init'
file, not the whole file.
scripts/Mmake.vars.in:
compiler/modules.m:
Allow $(EXTRA_INIT_COMMAND) as the Mmake equivalent
of `--extra-init-command'. Append the output of
$(EXTRA_INIT_COMMAND) to the `.init' file.
library/Mmakefile:
Set EXTRA_INIT_COMMAND rather than overriding the
libmer_std.init rule.
Estimated hours taken: 12
Branches: main
Until now, programmers could add `tabled_for_io' annotations to foreign_procs
that do I/O, which asks the compiler to make those foreign_procs idempotent,
i.e. ensures that they are performed at most once even in the presence of a
retry operation in the debugger. This change adds a compiler option,
--trace-table-io-require, which generates an error if a foreign_proc that does
I/O does not have this annotation. Specifying this option thus ensures
that all I/O done by the program is idempotent.
In the future, we may want to have this option turned on in all debugging
grades. Until we decide about, the new option is not yet documented.
compiler/options.m:
Add the new option --trace-table-io-require.
compiler/handle_options.m:
Make --trace-table-io-require imply --trace-table-io.
compiler/table_gen.m:
If --trace-table-io-require is enabled, require all I/O primitives
to have the tabled_for_io annotation.
compiler/mercury_compile.m:
Pass I/O states to table_gen.m, since it can now generate error
messages.
trace/mercury_trace_util.h:
trace/mercury_trace_vars.c:
When calling Mercury code from the trace directory, disable I/O
tabling, since any I/O actions executed by Mercury code in the browser
directory (or by library code called from there) should not be tabled,
not being part of the user program.
Due to the depth of nesting, make mercury_trace_vars.c use four-space
indentation.
browser/collect_lib.m:
browser/declarative_debugger.m:
browser/declarative_execution.m:
browser/dl.m:
browser/io_action.m:
browser/mdb.m:
browser/name_mangle.m:
browser/util.m:
compiler/gcc.m:
compiler/mercury_compile.m:
compiler/passes_aux.m:
compiler/process_util.m:
compiler/stack_layout.m:
library/io.m:
library/time.m:
tests/debugger/declarative/tabled_read_decl.m:
Add a whole lot of tabled_for_io annotations, to enable the compiler to
bootstrap with --trace-table-io-require enabled.
In many cases, this required turning old-style pragma c_code into
pragma foreign_proc. While doing that, I standardized the layouts
of pragma foreign_procs.
browser/util.m:
Turn an impure semidet predicate into a pure det predicate with I/O
states, to allow it to be tabled. Make it return a Mercury bool
to indicate success or failure.
library/bool.m:
Add functions that allow C code to get their hands on the constants
`yes' and `no', for communication with Mercury code.
library/table_builtin.m:
Add debugging code to the main primitive of I/O tabling. This is
controlled both by the macro for retry debugging and a boolean global.
library/mercury_trace_base.[ch]:
Add the boolean global variable to switch the new debugging code in
table_builtin.m on and off.
library/mercury_trace_internal.c:
When starting I/O tabling with retry debug enabled, turn on the switch.
tests/debugger/queens.exp3:
New expected output file that applies when the library is compiled with
--trace-table-io-require.
Estimated hours taken: 0.25
Branches: main
Allow one to test for a sufficiently recent compiler in configure.in
by testing whether an option exists. This is useful for when the test
cannot be easily done some other way.
compiler/options.m:
Add a new option compiler_sufficiently_recent which is
currently set by the command line option
`--bug-intermod-2002-06-13'.
Estimated hours taken: 2.5
Branches: main
Recently I changed the interactive query facility in the debugger
to use `mmc --make' to build the shared library containing the query.
There were two problems with this. The entire program was included in
the shared library, not just the query module. Also, invoking
`mmc --make query.realclean' cleaned up the user's files.
compiler/options.m:
compiler/compile_target_code.m:
Add an option `--compile-to-shared-lib', which causes
mmc to package the modules on the command line into
a shared library, not an executable. This option is
intended only for use by browser/interactive_query.m,
so it isn't documented.
browser/interactive_query.m:
Use `mmc --compile-to-shared-lib', not `mmc --make'
to build the query shared library.
Name the query source file mdb_query.m rather than query.m
to reduce the chance of overwriting a user's file.
tests/debugger/Mmakefile:
Use `lmc' to compile the query if `WORKSPACE' is set,
rather than using a Mercury.options file to set up
for the workspace.
tests/debugger/interactive.exp:
Update expected output.
Estimated hours taken: 1
Branches: main
Handle LDFLAGS and LD_LIBFLAGS with `mmc --make'.
compiler/options.m:
doc/user_guide.texi:
Add `--ml-flags' as a synonym for `--link-flags'.
Add `--ld-flags' and `--ld-libflags', which are the
options corresponding to the LDFLAGS and LD_LIBFLAGS
Mmake variables.
Add a comment that the `--output-file' option is
ignored with `mmc --make'.
compiler/options_file.m:
Handle LDFLAGS and LD_LIBFLAGS.
Handle MLLIBS correctly. MLLIBS contains `-l' options
(which can be handled by mmc), not flags for ml.
The value of LIBRARIES (which contains Mercury libraries
to link with) now comes before MLLIBS, because Mercury
libraries depend on C libraries, but C libraries usually
don't depend on Mercury libraries.
compiler/compile_target_code.m:
Pass the value `--ldflags' or `--ld-libflags' to ml.
scripts/Mmake.vars.in:
Add LDFLAGS and LD_LIBFLAGS to the options file
passed to the options file passed to `mmc --make'
on standard input.
Estimated hours taken: 3
Handle `mmc --make lib<module>' target, which builds all the files
required to use a library in the current grade.
compiler/make.m:
Check for `lib<module>' when attempting to classify a target.
compiler/make.program_target.m:
compiler/compile_target_code.m:
Make `.init' files when building the `.a' file.
Invoke the command given by `--pre-link-command' before linking.
compiler/make.module_target.m:
compiler/make.util.m:
Move find_oldest_timestamp into make.util.m for
use by make.program_target.m.
compiler/options.m:
doc/user_guide.texi:
Add an option `--make-init-file-command', to specify an
alternative command to make the `.init' file. This is needed
for the standard library.
Add an option `--pre-link-command', which specifies a
command to be run before linking. This is useful if there
are foreign files which depend on headers produced by
the Mercury compiler.
Estimated hours taken: 6 (+12 by fjh)
Branches: main
Read in the `.opt' files transitively, so that we get all the definitions
of equivalence types. This is needed to support --high-level-data
for the .NET / Java back-ends.
compiler/options.m:
Add an option `--read-opt-files-transitively' (on by default).
compiler/intermod.m:
Read in the `.opt' files transitively.
compiler/modules.m:
`mmake depend' now assumes the target code for a module
depends on the `.opt', `.int' and `.int2' files for all
transitively imported modules.
compiler/make.dependencies.m:
Handle the extra dependencies.
compiler/make_hlds.m:
Process `pragma termination_info' pragmas in pass 3,
*after* we've handled default modes for functions.
This avoids a problem where the compiler was reporting spurious
errors for the `pragma termination_info' pragmas for functions,
when the `.opt' file for that module was read in before the
`.int' file. I'm not sure if this problem was introduced by
the changes above or whether the changes above just exposed
an existing problem.
compiler/deep_profiling.m:
compiler/llds.m:
compiler/mercury_compile.m:
compiler/modes.m:
compiler/modules.m:
compiler/term_pass2.m:
Add module qualifiers to calls to `member' and `map'. These are
needed now that the equivalence `:- type set(T) == list(T)' is
exposed with inter-module optimization.
NEWS:
doc/user_guide.texi:
Document the change.
tests/invalid/Mmakefile:
Avoid reporting errors when creating the `.opt' file
for the `missing_parent_import' test case.
Estimated hours taken: 5
Branches: main
More changes to make `mmc --make' work with mmake.
scripts/Mmake.vars.in:
Pass MCFLAGS, CFLAGS, MLFLAGS, etc. to mmc in an options file
on standard input.
Don't add options for EXTRA_LIBRARIES to CFLAGS and MLFLAGS
when compiling with `mmc --make'. mmc handles those options
itself.
compiler/options.m:
compiler/options_file.m:
doc/user_guide.texi:
`--options-file -' now makes the compiler read an options
file from standard input.
Make `--options-file' behave as a standard accumulating option
rather than attempting to copy the behaviour of make's `-f' option.
s/--link_object/--link-object/
Mmake.workspace:
Put the `.a' files for the libraries in MLOBJS, not MLLIBS.
`mmc --make' will now relink when they change.
compiler/modules.m:
Link MLOBS into `module.split'.
tests/debugger/Mmakefile:
Create a Mercury.options file for use in compiling
the queries in interactive.m test.
Estimated hours taken: 2
Branches: main
Don't pass the default options twice when `mmc --make' invokes mmc.
compiler/options.m:
Add an option `--invoked-by-mmc-make', which is passed
to mmc by `mmc --make' to disable reading the default
options and generation of `.d' files.
Remove the `--generate-mmake-module-dependencies' option.
It's functionality is subsumed by `--invoked-by-mmc-make'.
compiler/make.util.m:
Pass `--invoked-by-mmc-make' to mmc.
compiler/mercury_compile.m:
compiler/handle_options.m:
Handle `--invoked-by-mmc-make'.
When computing the option arguments to pass to make__make_targets,
don't include the DEFAULT_MCFLAGS.
Estimated hours taken: 6
Branches: main
Allow alternative locations for the standard library files
to be specified using options to the various Mercury scripts
rather than environment variables. This change is necessary
to allow the compiler to be compiled using `mmc --make', because
`mmc --make' does not support the environment variables.
All of the Mercury scripts now accept an option
`--mercury-standard-library-directory' to specify the installed
library to use, or `--no-mercury-standard-library-directory' to
disable the use of the installed library. The location
of the alternate files to use can then be specified
using ordinary options to the scripts.
There is a new environment variable MERCURY_STDLIB_DIR, which has
the same effect as the `--mercury-standard-library-directory' option.
scripts/parse_ml_options.sh-subr.in:
scripts/mgnuc.in:
scripts/mmc.in:
scripts/mmake.in:
scripts/Mmake.vars.in:
scripts/Mmake.rules:
Handle MERCURY_STDLIB_DIR and `--mercury-standard-library-directory'.
Remove support for the MERCURY_C_INCL_DIR, MERCURY_MOD_LIB_DIRS
and MERCURY_TRACE_LIB_DIRS environment variables -- they aren't
used anywhere. MERCURY_C_INCL_DIR is being removed because the
assumption it makes (that all header files are installed into
a single directory) will not hold for much longer because the
generated header files for hl* grades are grade dependent.
compiler/options.m:
compiler/compile_target_code.m:
Add an option `--trace-init-file', used to specify `.init'
files which should only be used when tracing is enabled,
such as browser/mer_browse.init.
Allow `--mercury-stdlib-dir' as an abbreviation for
`--mercury-standard-library-directory'.
tools/lmc:
Use options rather than environment variables.
doc/user_guide.texi:
Document MERCURY_STDLIB_DIR, MERCURY_TRACE_LIB_MODS
and the `--trace-init-file' mmc option.
Remove documentation for the no longer used MERCURY_C_INCL_DIR,
MERCURY_MOD_LIB_DIRS, MERCURY_TRACE_LIB_DIRS and
MERCURY_NC_BUILTIN environment variables.
Estimated hours taken: 8
Branches: main
Allow arbitrary mappings from source file name to module name.
The mapping is created using the command `mmc -f *.m', which must
be run before `mmake depend'.
compiler/parse_tree.m:
compiler/source_file_map.m:
compiler/notes/compiler_design.html:
Add a new module to read, write and search the mapping.
compiler/modules.m:
Use the source file map when searching for source files.
Export `make_directory' for use by source_file_map.m.
Use the module name rather than the source file name to
generate the executable name. This matches the documentation
in the User's Guide, and it's needed to make the tests work.
compiler/prog_io.m:
Separate out the code to read the first item in a module to
find the module name into a new predicate, `find_module_name'.
compiler/handle_options.m:
Don't complain about the module name not matching the file
name when generating the Mercury.modules file -- the file
only needs to be generated when the module name doesn't
match the file name.
compiler/llds_out.m:
Remove a duplicate copy of `make_directory'.
compiler/options.m:
compiler/mercury_compile.m:
doc/user_guide.texi:
Add the `--generate-source-file-mapping' (-f) option
to generate the mapping.
NEWS:
Document the change.
tests/hard_coded/Mmakefile:
tests/hard_coded/source_file_map.m:
tests/hard_coded/mapped_module.exp:
Test case.
Estimated hours taken: 400
Branches: main
This diff implements stack slot optimization for the LLDS back end based on
the idea that after a unification such as A = f(B, C, D), saving the
variable A on the stack indirectly also saves the values of B, C and D.
Figuring out what subset of {B,C,D} to access via A and what subset to access
via their own stack slots is a tricky optimization problem. The algorithm we
use to solve it is described in the paper "Using the heap to eliminate stack
accesses" by Zoltan Somogyi and Peter Stuckey, available in ~zs/rep/stackslot.
That paper also describes (and has examples of) the source-to-source
transformation that implements the optimization.
The optimization needs to know what variables are flushed at call sites
and at program points that establish resume points (e.g. entries to
disjunctions and if-then-elses). We already had code to compute this
information in live_vars.m, but this code was being invoked too late.
This diff modifies live_vars.m to allow it to be invoked both by the stack
slot optimization transformation and by the code generator, and allows its
function to be tailored to the requirements of each invocation.
The information computed by live_vars.m is specific to the LLDS back end,
since the MLDS back ends do not (yet) have the same control over stack
frame layout. We therefore store this information in a new back end specific
field in goal_infos. For uniformity, we make all the other existing back end
specific fields in goal_infos, as well as the similarly back end specific
store map field of goal_exprs, subfields of this new field. This happens
to significantly reduce the sizes of goal_infos.
To allow a more meaningful comparison of the gains produced by the new
optimization, do not save any variables across erroneous calls even if
the new optimization is not enabled.
compiler/stack_opt.m:
New module containing the code that performs the transformation
to optimize stack slot usage.
compiler/matching.m:
New module containing an algorithm for maximal matching in bipartite
graphs, specialized for the graphs needed by stack_opt.m.
compiler/mercury_compile.m:
Invoke the new optimization if the options ask for it.
compiler/stack_alloc.m:
New module containing code that is shared between the old,
non-optimizing stack slot allocation system and the new, optimizing
stack slot allocation system, and the code for actually allocating
stack slots in the absence of optimization.
Live_vars.m used to have two tasks: find out what variables need to be
saved on the stack, and allocating those variables to stack slots.
Live_vars.m now does only the first task; stack_alloc.m now does
the second, using code that used to be in live_vars.m.
compiler/trace_params:
Add a new function to test the trace level, which returns yes if we
want to preserve the values of the input headvars.
compiler/notes/compiler_design.html:
Document the new modules (as well as trace_params.m, which wasn't
documented earlier).
compiler/live_vars.m:
Delete the code that is now in stack_alloc.m and graph_colour.m.
Separate out the kinds of stack uses due to nondeterminism: the stack
slots used by nondet calls, and the stack slots used by resumption
points, in order to allow the reuse of stack slots used by resumption
points after execution has left their scope. This should allow the
same stack slots to be used by different variables in the resumption
point at the start of an else branch and nondet calls in the then
branch, since the resumption point of the else branch is not in effect
when the then branch is executed.
If the new option --opt-no-return-calls is set, then say that we do not
need to save any values across erroneous calls.
Use type classes to allow the information generated by this module
to be recorded in the way required by its invoker.
Package up the data structures being passed around readonly into a
single tuple.
compiler/store_alloc.m:
Allow this module to be invoked by stack_opt.m without invoking the
follow_vars transformation, since applying follow_vars before the form
of the HLDS code is otherwise final can be a pessimization.
Make the module_info a part of the record containing the readonly data
passed around during the traversal.
compiler/common.m:
Do not delete or move around unifications created by stack_opt.m.
compiler/call_gen.m:
compiler/code_info.m:
compiler/continuation_info.m:
compiler/var_locn.m:
Allow the code generator to delete its last record of the location
of a value when generating code to make an erroneous call, if the new
--opt-no-return-calls option is set.
compiler/code_gen.m:
Use a more useful algorithm to create the messages/comments that
we put into incr_sp instructions, e.g. by distinguishing between
predicates and functions. This is to allow the new scripts in the
tool directory to gather statistics about the effect of the
optimization on stack frame sizes.
library/exception.m:
Make a hand-written incr_sp follow the new pattern.
compiler/arg_info.m:
Add predicates to figure out the set of input, output and unused
arguments of a procedure in several different circumstances.
Previously, variants of these predicates were repeated in several
places.
compiler/goal_util.m:
Export some previously private utility predicates.
compiler/handle_options.m:
Turn off stack slot optimizations when debugging, unless
--trace-optimized is set.
Add a new dump format useful for debugging --optimize-saved-vars.
compiler/hlds_llds.m:
New module for handling all the stuff specific to the LLDS back end
in HLDS goal_infos.
compiler/hlds_goal.m:
Move all the relevant stuff into the new back end specific field
in goal_infos.
compiler/notes/allocation.html:
Update the documentation of store maps to reflect their movement
into a subfield of goal_infos.
compiler/*.m:
Minor changes to accomodate the placement of all back end specific
information about goals from goal_exprs and individual fields of
goal_infos into a new field in goal_infos that gathers together
all back end specific information.
compiler/use_local_vars.m:
Look for sequences in which several instructions use a fake register
or stack slot as a base register pointing to a cell, and make those
instructions use a local variable instead.
Without this, a key assumption of the stack slot optimization,
that accessing a field in a cell costs only one load or store
instruction, would be much less likely to be true. (With this
optimization, the assumption will be false only if the C compiler's
code generator runs out of registers in a basic block, which for
the code we generate should be unlikely even on x86s.)
compiler/options.m:
Make the old option --optimize-saved-vars ask for both the old stack
slot optimization (implemented by saved_vars.m) that only eliminates
the storing of constants in stack slots, and the new optimization.
Add two new options --optimize-saved-vars-{const,cell} to turn on
the two optimizations separately.
Add a bunch of options to specify the parameters of the new
optimizations, both in stack_opt.m and use_local_vars.m. These are
for implementors only; they are deliberately not documented.
Add a new option, --opt-no-return-cells, that governs whether we avoid
saving variables on the stack at calls that cannot return, either by
succeeding or by failing. This is for implementors only, and thus
deliberately documented only in comments. It is enabled by default.
compiler/optimize.m:
Transmit the value of a new option to use_local_vars.m.
doc/user_guide.texi:
Update the documentation of --optimize-saved-vars.
library/tree234.m:
Undo a previous change of mine that effectively applied this
optimization by hand. That change complicated the code, and now
the compiler can do the optimization automatically.
tools/extract_incr_sp:
A new script for extracting stack frame sizes and messages from
stack increment operations in the C code for LLDS grades.
tools/frame_sizes:
A new script that uses extract_incr_sp to extract information about
stack frame sizes from the C files saved from a stage 2 directory
by makebatch and summarizes the resulting information.
tools/avg_frame_size:
A new script that computes average stack frame sizes from the files
created by frame_sizes.
tools/compare_frame_sizes:
A new script that compares the stack frame size information
extracted from two different stage 2 directories by frame_sizes,
reporting on both average stack frame sizes and on specific procedures
that have different stack frame sizes in the two versions.
Estimated hours taken: 0.1
Branches: main
compiler/options.m:
Turn on --optimize-reassign when optimizing for space, since this
optimization can only reduce executable sizes (usually by about 0.5%
to 1%).
The main aim of this change is to make the overall, high-level structure
of the compiler clearer, and to encourage better encapsulation of the
major components.
compiler/libs.m:
compiler/backend_libs.m:
compiler/parse_tree.m:
compiler/hlds.m:
compiler/check_hlds.m:
compiler/transform_hlds.m:
compiler/bytecode_backend.m:
compiler/aditi_backend.m:
compiler/ml_backend.m:
compiler/ll_backend.m:
compiler/top_level.m:
New files. One module for each of the major components of the
Mercury compiler. These modules contain (as separate sub-modules)
all the other modules in the Mercury compiler, except gcc.m and
mlds_to_gcc.m.
Mmakefile:
compiler/Mmakefile:
Handle the fact that the top-level module is now `top_level',
not `mercury_compile' (since `mercury_compile' is a sub-module
of `top_level').
compiler/Mmakefile:
Update settings of *FLAGS-<modulename> to use the appropriate
nested module names.
compiler/recompilation_check.m:
compiler/recompilation_version.m:
compiler/recompilation_usage.m:
compiler/recompilation.check.m:
compiler/recompilation.version.m:
compiler/recompilation.version.m:
Convert the `recompilation_*' modules into sub-modules of the
`recompilation' module.
compiler/*.m:
compiler/*.pp:
Module-qualify the module names in `:- module', `:- import_module',
and `:- use_module' declarations.
compiler/base_type_info.m:
compiler/base_type_layout.m:
Deleted these unused empty modules.
compiler/prog_data.m:
compiler/globals.m:
Move the `foreign_language' type from prog_data to globals.
compiler/mlds.m:
compiler/ml_util.m:
compiler/mlds_to_il.m:
Import `globals', for `foreign_language'.
Mmake.common.in:
trace/Mmakefile:
runtime/Mmakefile:
Rename the %.check.c targets as %.check_hdr.c,
to avoid conflicts with compiler/recompilation.check.c.
Estimated hours taken: 24
Branches: main
A new LLDS->LLDS transformation that optimizes instruction sequences such
as the following extract from tree234__search:
MR_r1 = MR_stackvar(3);
MR_r2 = MR_stackvar(4);
MR_r3 = MR_const_field(MR_mktag(1), MR_stackvar(1), (MR_Integer) 2);
MR_r4 = MR_stackvar(2);
MR_succip = (MR_Code *) MR_stackvar(5);
if ((MR_tag(MR_r3) != MR_mktag((MR_Integer) 1))) {
MR_GOTO_LABEL(mercury__x3__search_3_0_i1);
}
MR_stackvar(1) = MR_r3;
MR_stackvar(2) = MR_r4;
MR_stackvar(3) = MR_r1;
MR_stackvar(4) = MR_r2;
MR_r2 = MR_r4;
MR_r3 = MR_const_field(MR_mktag(1), MR_r3, (MR_Integer) 0);
MR_call_localret(...)
The code before the if-then-else is part of the procedure epilogue; the code
after it is the code from the initial part of the procedure that fulljump
optimization replaces the self-tail-call with.
The transformation deletes the redundant assignments to stackvars 2, 3 and 4.
It reduces both the size and the runtime of the compiler by about 0.5%.
compiler/reassign.m:
The new module that does the work.
compiler/optimize.m:
Invoke the new module if the optimization is enabled. Invoke it after
most other optimizations have been run, since they may create more
opportunities for it.
compiler/option.m:
Add a new option to control whether the new optimization is enabled.
Turn on the new optimization at optimization level 3.
doc/user_guide.texi:
Document the new option.
compiler/notes/compiler_design.html:
Document the new module.
Estimated hours taken: 500
Add an alternative implementation of Mmake as part of the compiler.
The advantages of this are
- more accurate dependencies
- no `mmake depend' step
- less process creation (no processes are created to
build interface files).
Still to do:
- handle --split-c-files
- handle the IL backend properly
- library installation
- allow the compiler to be built and the nightly tests
to be run with `mmc --make'
compiler/make.m:
Control the build process.
compiler/make.program_target.m:
Build executables and libraries.
compiler/make.module_target.m:
Build C files, object files, interface files etc.
compiler/make.dependencies.m:
Work out the depenendencies between targets.
compiler/make.module_dep_file.m:
Record the inter-module dependencies between invocations of mmc.
compiler/make.util.m:
Utility predicates used by `mmc --make'.
compiler/compile_target_code.m:
This module will eventually contain the predicates used
to compile the target code files generated by the compiler
which are now in mercury_compile.m. (That will be done
as a separate change for ease of reviewing).
For now compile_target_code.m
compiler/mercury_compile.m:
Export the predicates used to compile target code.
Call make.m.
Pass the name of the top-level module in the source file to modules.m.
It is needed when generating the `.module_dep' files.
Lookup the option defaults (which will eventually be stored in
DEFAULT_MCFLAGS by the mmc script) before compiling. Up until now
the option defaults have been passed on the command line by the
mmc script, but with `mmc --make' the default options need
to be overridden by the value of the MCFLAGS make variable, but
the MCFLAGS make variable is overridden by command line options.
Pass the value of `--link-flags' to c2init.
Remove some uninformative messages printed when a C, IL, etc.
compilation fails.
compiler/options_file.m:
Read files containing Make style variable assignments.
compiler/options.m:
doc/user_guide.texi:
Add a new options category: build system options.
Add some extra options:
--warn-undefined-options-variables - like mmake --warn-undefined-vars
--verbose-commands - print commands that the user might be
interested in, like C compilation, but not things
like mercury_update_interface.
--output-compile-error-lines - print the first n lines
of the error file generated by a command.
--generate-mmc-make-modules-dependencies - generate dependencies
for use by `mmc --make' even when using Mmake.
--il-assembler, --ilasm-flags, --mcpp-compiler, --mcpp-flags,
--csharp-compiler, --csharp-flags, --install-prefix,
--install-command, --libgrades, --options-files,
--options-search-directories.
compiler/modules.m:
Add fields to the `module_imports' type for use by make.*m.
Don't try to fill in fields of the module_imports structure
lazily. It's error prone, and probably doesn't save much
anyway.
Clean up the code to compute what foreign languages
are used by a list of item.
Simplify the handling of fact tables by recording that a module
containing fact tables has foreign code to implement them,
rather than requiring separate checks everywhere.
Generalise predicates like get_interface so that they
work even after the imported items have been read.
Fix the handling of header files with the LLDS backend.
Install the `.module_dep' files created for use by
`mmc --make'.
compiler/*.m:
Use record syntax rather than explicit deconstruction to
refer to fields of the `module_imports' type.
compiler/*.m:
Be more careful about where output goes.
mercury_compile.m sets the output stream to be io__stderr_stream
at the start of compilation, so remove all explicit writes to
io__stderr_stream (with `--make' the error output stream may be
a `.err' file, not io__stderr_stream).
Change all occurrences of io__tell/io__told to use
io__open_output/io__close_output (io__told restores the current
output stream to io__stdout_stream, not the previous value).
compiler/passes_aux.m:
Make the output from system commands go to the current
output stream, not C stdout and stderr.
Allow commands to be printed with `--verbose-commands'.
Remove uninformative error messages when a command fails.
compiler/timestamp.m:
Add functions oldest_timestamp and newest_timestamp.
compiler/llds_out.m:
Record the number of C files written with `--split-c-files'
in <module>.num_split.
compiler/prog_io.m:
compiler/*.m:
`search_for_file' now returns the directory in which the
file was found.
compiler/foreign.m:
Use sub-typing to make some calls to predicates in this
module `det' rather than `semidet'.
compiler/handle_options.m:
Return the option arguments.
compiler/Mmakefile:
make.util.m refers to kill() and `struct sigaction' which
are not exported from <signal.h> unless `--no-ansi' is
passed to gcc.
compiler/notes/compiler_design.html:
Document the new modules.
runtime/mercury_signal.h:
runtime/mercury_signal.c:
Add a function MR_signal_should_restart() which alters
whether a signal restarts or interrupts system calls.
In general restarting is the preferred behaviour, but
the wait() for a child process needs to be interruptible.
scripts/Mmake.vars.in:
Add subdirs for `.module_dep', `.err_date'
and `.num_split' files.
library/io.m:
Add a version of io_call_system which returns the signal
that killed the command rather than converting it into
an error message.
Add a predicate to interpret the result of system() or wait().
library/list.m:
Add list__map_foldl2 and a unique mode for list__foldl3.
NEWS:
Document the new library predicates.
configure.in:
runtime/mercury_conf.h.in:
Check for siginterrupt().
doc/user_guide.texi:
Document the new options.
Add a description of `mmc --make' to the "Using Mmake" chapter.
Estimated hours taken: 1
Branches: main
Add the --support-ms-clr option. This helps to make clear which parts
of the IL code generator are there to work around the MS CLR bugs and
which are there to generate correct IL.
compiler/options.m:
Add the --support-ms-clr option.
doc/user_guide.texi:
Document the --support-ms-clr option.
compiler/mlds_to_il.m:
Use the new option to work around a bug in the MS CLR
implementation where for non-verifiable code the tail call
return type must be compatible with the caller return type.
Estimated hours taken: 1
Branches: main
compiler/options.m:
Add a new option `--verbose-mlds-dump'.
compiler/mercury_compile.m:
When dumping the MLDS, only dump it to the .mlds_dump file if the
stage was specified with `--verbose-mlds-dump'. The `--mlds-dump'
now only controls dumping of the .c_dump and .h_dump files.
doc/user_guide.texi:
Document the new option.
Estimated hours taken: 0.25
Branches: main
compiler/options.m:
By default turn --separate-assemblies on, as
--no-separate-assemblies is currently broken.
Upgrade the default version of the .NET libraries to 1.0.3300
because that is what I am using now, and I am the most important
user of the .NET backend at the moment.
Estimated hours taken: 0.25
Branches: main
compiler/options.m:
Add the option `--dotnet-library-version'. This option is currently
unused and only being checked in too ease bootstraping of a future
change.
Estimated hours taken: 2.5
Branches: main
Add an option `--find-all-recompilation-reasons' which causes
smart recompilation to find all reasons why a module needs to
be recompiled, not just the first. This allows test cases in
tests/recompilation to contain multiple tests. Also,
tests/recompilation will now work with deep profiling.
compiler/options.m:
compiler/handle_options.m:
doc/user_guide.texi:
Add the new option
compiler/recompilation_check.m:
Collect all reasons for recompilation if
`--find-all-recompilation-reasons' is set.
tests/recompilation/Mmakefile:
Add `--find-all-recompilation-reasons' to EXTRA_MCFLAGS.
tests/recompilation/remove_type_re.err_exp.2:
Update expected output.
Estimated hours taken: 40
Branches: main
A large step towards declarative debugging of goals that do I/O. This step
does everything needed for that except modify the declarative debugger itself;
that is for Mark to do.
If you give the new option --trace-table-io-decl, the transformation performed
by the compiler on I/O primitives will preserve not just the output arguments
of the primitive, so that the primitive can be "reexecuted" without performing
any side-effects, but also the input arguments and the identity of the I/O
primitive itself. The I/O table therefore will contain a list of the I/O
primitives executed by the program after I/O tabling is started.
You can test this via the new debugger commands "print action <action-number>"
and "browse action <action-number>".
The new option is currently not documented, because the declarative debugger
does not yet use the information it provides. The new debugger commands are
not documented because they are meant only for implementors, at least for
now.
Since this change adds a field to proc_layout structures, any workspaces
compiled with debugging enabled will need to do a cvs update when this change
is installed.
compiler/options.m:
Add the option --trace-table-io-decl. When set, this causes the
compiler to transform I/O action primitives to allow declarative
debugging of I/O actions.
compiler/handle_options.m:
Make --trace-table-io-decl imply --trace-table-io.
compiler/table_gen.m:
Perform the transformation, which is similar to the existing
--trace-table-io transformation, but preserves the identity of all
non-io-state arguments (not just the outputs) and the identity
of the I/O primitive itself.
Provide better names for variables generated by tabling
transformations.
compiler/hlds_goal.m:
Add extra parameters to procedures whose job it is to create new
goals to name the variables in those goals.
compiler/layout.m:
Add a new layout structure to contain the information the runtime
system needs to interpret the information saved by the new
transformation.
compiler/layout_out.m:
Output the new layout structure.
compiler/continuation_info.m:
Add a field to proc_layouts to point to the declarative I/O tabling
structure, and another to identify the proc_layout without using LLDS
types.
compiler/code_gen.m:
Provide the definition of this field when appropriate.
compiler/hlds_pred.m:
Add a field to proc_infos to store the information from the tabling
transformation until code generation.
compiler/stack_layout.m:
Add a mechanism for transforming the high level description of I/O
action tabling data in proc_infos to the low level description we need
to generate C data structures.
compiler/hlds_data.m:
Add a new cons_id and a new cons_tag; they are used to refer to I/O
tabling structures in code generated by the new transformation.
compiler/*.m:
Handle the updates to global data types above.
library/table_builtin.m:
Modernize some old code.
Fix an old off-by-one error: make I/O tabling use the first slot
in the I/O action table.
library/varset.m:
Add a mechanism for creating a variable that is named iff the caller
has a name for it.
runtime/mercury_layout_util.[ch]:
Add a function for materializing type parameters from an answer block,
not from registers or a closure.
runtime/mercury_stack_layout.h:
Declare a C type for the data structure holding information about
I/O primitives transformed by --trace-table-io-decl, and add a field
to proc_layout structures to point to these new structures.
Add a new evaluation method for --trace-table-io-decl.
runtime/mercury_tabling_macros.h:
Add some conditionally-compiled debugging code to the primitive for
saving answers.
trace/mercury_trace_vars.[ch]:
Add functions for printing I/O action goals.
trace/mercury_trace_internal.c:
Add code for recognizing and implementing commands to print I/O
action goals.
trace/mercury_trace.c:
Add code for handling the new eval method.
tests/debugger/tabled_read.{m,inp,exp*}:
Add a polymorphic I/O action primitive, add calls to it, and test
the printing of both monomorphic and polymorphic action goals.
tests/debugger/tabled_read_decl.{m,inp,exp*,data}:
A new test case. It does the same things as the new version of
tabled_read, but it is compiled with --trace-table-io-decl, not
just --trace-table-io. It therefore can (and does) test the printing
of tabled I/O actions.
tests/debugger/Mmakefile:
Add the new test case.
Estimated hours taken: 1
Branches: main
Implement a new option `--warn-non-tail-recursion'.
compiler/ml_tailcall.m:
Add a pass to warn about directly recursive calls that are not
tail calls.
compiler/options.m:
doc/user_guide.texi:
Add a new option to enable the new pass.
compiler/mercury_compile.m:
Add code to invoke the new pass.
compiler/handle_options.m:
If --warn-non-tail-recursion is set, then report an error
if either --high-level-code or --optimize-tailcalls is not,
or if --error-check-only is set.
Estimated hours taken: 0.25
Branches: main
Improve documentation of --no-warn-inferred-erroneous.
compiler/options.m:
doc/user_guide.texi:
Reword documentation as suggest by fjh's review comments.
Estimated hours taken: 1
Branches: main
Add the option --no-warn-inferred-erroneous. This option means that the
compiler doesn't warn about determinism declarations which are too lax
because their inferred determinism is erroneous. This allows one to use
--halt-at-warn with programs with unimplemented predicates which throw
errors.
compiler/det_report.m:
compiler/options.m:
doc/user_guide.texi:
Add the --no-warn-inferred-erroneous option.
Estimated hours taken: 12
Branches: main
We have two ways to generate comparison predicates for du types. Suppose the
type has n function symbols. The quadratic method has n^2 clauses, one for each
combination of the bindings of the two arguments. The linear method creates an
index predicate for the type, calls it on each argument, and returns
immediately if the index values indicate a difference. If the index values
say the two arguments are bound to the same function symbol, the linear method
then has n cases, each comparing the arguments of a function symbol.
The quadratic method can be expected to be faster since it avoids function
calls and does fewer tests on the function symbol bound to each argument.
For small values of n, it can also be smaller, mainly due to the absence
of the index predicate. This change allows the user to select the use of
the quadratic method for all types whose value of n is up to a given limit,
whereas before there was a hardcoded limit requiring n <= 3.
compiler/unify_proc.m:
Generalize the code that generates comparison procedures that
explicitly compare each function symbol with every other, to
handle types with any number of function symbols. Rename some
predicates to make clearer the distinction between these predicates,
which generate comparison predicates whose size is quadratic in the
the number of function symbols in the type, from the predicates
which generate comparison predicates whose size is linear in the
the number of function symbols in the type.
compiler/handle_options.m:
Delete the code that limited the exploited value of the
--compare-specialization option, since the change to unify_proc.m
has removed the cause of the limitation.
Add code to set the value of --compare-specialization depending on the
back end if the user has not given a value.
compiler/options.m:
Make handle_options.m decide the default value of
--compare-specialization.
Move a misplaced comment.
Estimated hours taken: 10
Branches: main
Add a new MLDS->MLDS optimization option, --eliminate-local-variables.
The aim of this pass is to improve performance in cases where local
variables are costly -- for nondeterministic procedures,
for MLDS->C accurate GC, and for the .NET back-end.
compiler/ml_optimize.m:
Add a pass to eliminate local variables.
Also, don't optimize tail calls unless --optimize-tailcalls is set.
compiler/mercury_compile.m:
Invoke the ml_optimize pass once before ml_elim_nested
(with --optimize-tailcalls disabled), as well as once after it.
compiler/options.m:
doc/user_guide.texi:
Add an option --eliminate-local-variables to enable the new
optimization.
compiler/ml_elim_nested.m:
compiler/ml_util.m:
Move statement_contains_var and definition_contains_var
from ml_elim_nested.m to ml_util.m, for use by ml_optimize.m.
compiler/ml_elim_nested.m:
- Handle local variables with initializers; this is neccessary
now that ml_optimize gets run before ml_elim_nested.
- Don't allocate a stack frame struct and link it into the chain
if there are no local variables that contain pointers.
- In fixup_atomic_statement, handle foreign_proc_code more consistently.
- Add some comments.
Estimated hours taken: 2
Branches: main
Fix bugs in the handling of impurity which broke `solutions/2'
in grade asm_fast when compiled with `--optimize-duplicate-calls'.
compiler/purity.m:
Fix the handling of `foreign_proc' goals. Previously they
were always assumed to be pure. Now they have the purity
of the predicate they implement.
compiler/inlining.m:
Compare the purity of the old and new goals when
checking whether purity checking needs to be rerun,
rather than just checking for `promise_pure' markers.
compiler/options.m:
Re-enable `--optimize-duplicate-calls'.
tests/hard_coded/Mmakefile:
tests/hard_coded/impure_foreign.{m,exp}:
Test case.
Estimated hours taken: 0.1
Branches: main
compiler/options.m:
Don't enable `--optimize-duplicate-calls' at any optimization level.
It breaks solutions/2 due to bugs in the handling of impurity.
Estimated hours taken: 6
Branches: main
compiler/options.m:
Commented out the code enabling --optimize-duplicate-calls,
since it break most test cases using solutions/2 in grade asm_fast.