Estimated hours taken: 4
Branches: main
Fix problems with the `--search-library-files-directory <dir>' option
implementation:
- It did not work with the high level C backend because it did not add
`<dir>/Mercury/mihs' or `<dir>/Mercury/<grade>/<fullarch>/Mercury/mihs' to
be searched for `.mih' files.
- It did not work with intermodule optimisation and --use-grade-subdirs
because it did not add grade-dependent directories to be searched for
`.opt' and `.trans_opt' files.
Also, it relied on <dir> to contain (symlinks to) libraries of the correct
grade. When using --use-grade-subdirs, we now search for libraries in the
grade-dependent subdirectory under `<dir>/Mercury'.
To simplify things, we place both static and shared libraries into
`<dir>/Mercury/<grade>/<fullarch>/Mercury/lib' instead of separate
`<dir>/Mercury/<grade>/<fullarch>/Mercury/<ext>s' directories.
compiler/handle_options.m:
compiler/options.m:
Make the changes above.
Mark a couple of spots which will need to be updated for
grade-dependent `.init' files.
doc/user_guide.texi:
Update documentation for `--search-library-files-directory'.
Estimated hours taken: 32
Branches: main
The objective of this diff is to switch from a table of solver events built
into the compiler (and eventually the debugger) into a table of events
defined by a file provided by the user to the compiler, which the compiler
then records in the executable for use by the debugger.
The current design, for speed of implementation, uses temporary files parsed
by a bison-generated parser. Since the compiler needs to be able to invoke
the parser even if it is compiled in a non-debug grade, the parser is in
a new library, the eventspec library, that is always linked into the Mercury
compiler and is always linked into any Mercury program with debugging enabled
(but is of course linked only once into a Mercury compiler which has debugging
enabled).
Modify the debugger to give it the ability to print the attributes of
user-defined events (for now, only the non-synthesized attributes).
Implement a new debugger command, "user", which goes to the next user-defined
event.
configure.in:
Require flex and and bison to be available.
doc/user_guide.texi:
Document user defined events and the new debugger capabilities.
doc/mdb_categories:
Include "user" in the list of forward movement commands.
Fix some earlier omissions in that list.
runtime/mercury_stack_layout.h:
Include an event number in the user-defined event structure.
Include a string representing an event set specification in module
layout structures.
runtime/mercury_stack_layout.h:
runtime/mercury_trace_base.[ch]:
runtime/mercury_types.h
Switch from solver events to user events in names.
runtime/mercury_trace_term.[ch]:
Provide a representation of flat terms, for use in representing
the calls that generate synthesized attributes.
Ensure that exported field names have an MR_ prefix.
browser/cterm.m:
Conform to the change to runtime/mercury_trace_term.h.
scripts/c2init.in:
scripts/ml.in:
Include the eventspec library in programs compiled with debugging
enabled.
compiler/Mmakefile:
Include the eventspec library in the compiler.
compiler/options.m:
Add a new option, --event-spec-file-name, that allows the user to
specify the set of user-defined events the program may use.
compiler/handle_options.m:
Set this optimization from an environment variable (which may be
set by the mmc script) if the new option is not explicitly given.
compiler/prog_data.m:
Define the data structures for the compiler's representation of the
event set specification.
Move some definitions around to group them more logically.
compiler/hlds_module.m:
Include the event set specification as a new field in the module_info.
compiler/prog_event.m:
Add the code for invoking the parser in the eventspec library,
and for converting the simple term output by the parser to the
compiler own representation, which contains more information
(to wit, the types of the function attributes) and which has had
a whole bunch of semantic checks done on it (e.g. whether synthesized
attributes depend on themselves or on nonexistent attributes).
Provide a function to generate a canonicalized version of the event
specification file.
compiler/module_qual.m:
compiler/equiv_type.m:
Process event spec specifications as well as items, to module qualify
the names of the types of event arguments, and expanding out
equivalence types.
In equiv_type.m, rename some variables to make clear what kind of info
they represent.
compiler/mercury_compile.m:
Process the event set specification file if one has been selected:
read it in, module qualify it, expand its equivalence types, and add
to the module_info.
compiler/compile_target_code.m:
Include the event_spec library when linking debuggable executables.
compiler/call_gen.m:
compiler/continuation_info.m:
compiler/trace_gen.m:
compiler/trace_params.m:
mdbcomp/prim_data.m:
mdbcomp/trace_counts.m:
runtime/mercury_goto.h:
Generate user-defined events instead of solver events.
compiler/layout.m:
compiler/layout_out.m:
compiler/stack_layout.m:
Include a canonicalized version of the event specification file
in the module layout if the module has any user-defined events.
compiler/code_info.m:
compiler/llds_out.m:
compiler/modes.m:
compiler/modules.m:
compiler/opt_debug.m:
compiler/typecheck.m:
Conform to the changes above.
compiler/passes_aux.m:
Rename a predicate to avoid an ambiguity.
trace/Mmakefile:
Add the definition and rules required to build the eventspec library.
trace/mercury_event_scanner.l:
trace/mercury_event_parser.y:
A scanner and a parser for reading in event spec specifications.
trace/mercury_event_spec_missing.h:
Provide the declarations that should be (but aren't) provided by
flex and bison.
trace/mercury_event_spec.[ch]:
The main module of the eventspec library. Provides functions to read
in event set specifications from a file, and to write them out as a
Mercury term in the form needed by the compiler.
trace/mercury_trace_tables.c:
If the module layouts being registered include event set
specifications, then check their consistency. Make the specification
and the consistency indication available to other modules.
trace/mercury_trace_internal.c:
During initialization, if the modules contain a consistent set of event
set specifications, then read that specification into the debugger.
(We don't yet make use of this information.)
Add an extra mdb command, "user", which goes forward to the next
user-defined event.
trace/mercury_trace.[ch]:
trace/mercury_trace_cmd_forward.[ch]:
Implement the new mdb command.
trace/mercury_trace_vars.[ch]:
For user-defined events, include the attributes' values among the
values that can be printed or browsed.
trace/mercury_trace_cmd_browsing.c:
trace/mercury_trace_declarative.c:
Minor changes.
scripts/scripts/prepare_tmp_dir_grade_part:
Copy the .y and .l files to the tmp dir we use for installs.
tools/bootcheck:
Copy the .y and .l files of the trace directory to stage 2.
tools/lmc.in:
Include the eventspec library when linking debuggable executables.
tests/debugger/user_event.{m,inp,exp}:
tests/debugger/user_event_spec:
New test case to test the new functionality.
tests/debugger/Mercury.options:
tests/debugger/Mmakefile:
Enable the new test case.
tests/debugger/completion.exp:
Expect the new "user" mdb command in the completion output.
Estimated hours taken: 12
Branches: main
Add an optional pass that tries to avoid generating too many parallel goals.
The first transformation implemented by this pass is to transform parallel
conjunctions into goals of the form
( queues already contain lot of work ->
sequential version of parallel conjunction
;
parallel conjunction as before
)
if they contain recursive calls.
The effect of this transformation is to reduce the overhead of the new par_fib
test case from:
fib(35): sequential 189 vs parallel 5770
to
fib(35): sequential 189 vs parallel 1090
i.e. a speedup of more than a factor of five.
compiler/granularity.m:
New module that implements this transformation. I intend to add other,
more sophisticated transformations in the future.
compiler/transform_hlds.m:
Add granularity.m as one of the submodules of transform_hlds.m.
compiler/mercury_compile.m:
Invoke the new pass.
Invoke dep_par_conj only if needed.
Fix some stage numbers.
compiler/notes/compiler_design.html:
Document the new module.
Document some modules that should have been documented earlier.
Fix a hurried deletion of a reference to the Aditi backend.
compiler/goal_util.m:
Add some utility functions for use by the new module.
compiler/simplify.m:
Record the information mercury_compile.m needs in order to check
whether we have any parallelism for granularity.m and dep_par_conj.m
to process.
compiler/hlds_module.m:
Add a slot to the module_info to record the information from
simplify.m. Clean up some interfaces.
compiler/add_type.m:
Conform to the change to hlds_module.m.
compiler/dependency_graph.m:
Delete unnecessary module qualifications, and rename some predicates
to avoid potential ambiguities.
compiler/options.m:
Add the options required for controlling the new transformation.
Rename an option's internal name to avoid conflict with a language
keyword (the user-visible name remains unchanged).
Move some options around to put them in logical groups.
doc/user_guide.texi:
Document the new options.
Fix some omissions in some earlier options.
compiler/handle_options.m:
compiler/termination.m:
Conform to the option rename.
compiler/quantification.m:
Rename some predicates to avoid ambiguities.
library/par_builtin.m:
Add a predicate for use by the new transformation.
tests/par_conj/par_fib.{m,exp}:
A new test case: a version of fib for use in testing parallelism.
tests/par_conj/Mmakefile:
Enable the new test case.
Estimated hours taken: 24
Branches: main
Generate an XML representation of the du types in the current module.
The XML representation contains all the information about the type,
as well as associating with each type, data constructor and data field
any comments located near the comment.
The current strategy associates the comment starting on the same line
as the type declaration, and if there is none then the comment directly
above. At a later date, this strategy needs to be made more flexible.
This required two main changes to the compiler.
Change one was to associate with a term.variable the context
of that variable.
Then the constructor and constructor_arg types had to have their
context recorded.
compiler/xml_documentation.m:
Add a pass that generates an XML documentation
for the du types in the current module.
compiler/handle_options.m:
compiler/mercury_compile.m:
compiler/options.m:
Call the xml_documentation phase and stop afterwards.
compiler/error_utils.m:
Add a utitily predicate for reporting errors where
a file is unable to be opened.
library/term.m:
Add the term.context to term.variables.
Remove the backwards mode of var_list_to_term_list as it
no longer works.
Make the predicate version of term_list_to_var_list
semidet as we can no longer use the backwards version
var_list_to_term_list.
NEWS:
Mention the changes to the term module.
library/parser.m:
Fill in the term.context of term.variables while parsing.
compiler/prog_data.m:
Add the context to the constructor and constructor_arg types.
compiler/prog_io.m:
Fill in the context fields in the constructor and constructor_arg
types.
compiler/add_clause.m:
compiler/prog_io.m:
compiler/prog_io_typeclass.m:
compiler/typecheck.m:
Call the correct version of term_list_to_var_list,
to deal with the fact that we removed the reverse
mode of var_list_to_term_list.
compiler/notes/compiler_design.html:
doc/user_guide.texi:
Document the new module.
compiler/add_clause.m:
compiler/det_util.m:
compiler/fact_table.m:
compiler/hlds_out.m:
compiler/inst_graph.m:
compiler/intermod.m:
compiler/make_hlds_passes.m:
compiler/mercury_to_mercury.m:
compiler/prog_ctgc.m:
compiler/prog_io.m:
compiler/prog_io_dcg.m:
compiler/prog_io_goal.m:
compiler/prog_io_pragma.m:
compiler/prog_io_typeclass.m:
compiler/prog_io_util.m:
compiler/prog_io_util.m:
compiler/prog_util.m:
compiler/state_var.m:
compiler/superhomogeneous.m:
compiler/switch_detection.m:
compiler/typecheck_errors.m:
library/term_io.m:
library/varset.m:
Handle the context in the term.variable structure.
compiler/add_type.m:
compiler/check_typeclass.m:
compiler/equiv_type.m:
compiler/hhf.m:
compiler/hlds_out.m:
compiler/inst_check.m:
compiler/make_tags.m:
compiler/mercury_to_mercury.m:
compiler/ml_type_gen.m:
compiler/ml_unify_gen.m:
compiler/mode_util.m:
compiler/module_qual.m:
compiler/post_typecheck.m:
compiler/prog_io.m:
compiler/prog_mode.m:
compiler/prog_type.m:
compiler/recompilation.check.m:
compiler/recompilation.usage.m:
compiler/special_pred.m:
compiler/term_constr_build.m:
compiler/term_norm.m:
compiler/type_ctor_info.m:
compiler/type_util.m:
compiler/typecheck.m:
compiler/unify_proc.m:
compiler/untupling.m:
compiler/unused_imports.m:
Handle the context field in the constructor and constructor_arg
types.
compiler/check_hlds.m:
Add the xml_documentation module.
Estimated hours taken: 16
Branches: main
Support polymorphic instances of typeclasses with functional dependencies.
We do this by allowing type variables in the range arguments, which must be
distinct according to existing typeclass restrictions, to be determined
from type variables in the domain arguments by the functional dependencies
on the instance constraints.
compiler/check_typeclass.m:
Remove the range-restrictedness check and replace it with a coverage
check, which makes use of the instance constraints when determining
if a type variable is bound.
Explicitly pass the range tvars to get_unbound_tvars, so that it
can be used by the coverage pass as well as the
check_typeclass_constraints pass.
Rearrange the structure of the module, since multiple passes now
make use of the get_unbound_tvars predicate. Separate out the
error reporting code from the main logic.
Clarify the description at the top of this module. It now corresponds
more closely with the structure of the module.
Fix a bug in check_instance_pred_procs/12 whereby the wrong context
was being used in the new instance definition, leading to incorrect
error messages; use field update syntax to avoid this problem.
doc/reference_manual.texi:
Add an example to illustrate the relaxed restrictions.
tests/valid/Mmakefile:
tests/valid/fundeps_poly_instance.m:
Test the new feature.
tests/invalid/Mmakefile:
tests/invalid/fundeps_coverage.err_exp:
tests/invalid/fundeps_coverage.m:
Test the new error reporting.
tests/invalid/range_restrict.err_exp:
Update for the changed error message.
tests/invalid/typeclass_bogus_method.err_exp:
tests/invalid/typeclass_test_10.err_exp:
Update these expected outputs for the bugfix.
Estimated hours taken: 2
Branches: main
Cleanups for the rtree module.
There are no changes to any algorithms.
library/rtree.m:
Add a reference to the paper by Guttman that is the basis of this
implementation.
Conform more closely to our coding standards.
doc/Mmakefile:
Include the rtree documentation in the library reference guide.
Estimated hours taken: 1
Branches: main
doc/Mmakefile:
Fix an annoyance: if TEXI2DVI is autoconfigured to a command that
generates PDFs instead of dvi files, then every make in the doc
directory remakes a bunch of files, even if they are already up
to date, because make thinks the dvi files are missing. This diff
makes the Mmakefile care only about whether TEXI2DVI was run, not
whether it generates .dvi files.
Estimated hours taken: 2
Branches: main
Restrict the insts that are allowed to appear in mutable declarations.
In particular mutables are now no longer allowed to have the insts
(mostly-)unique or free.
doc/reference_manual.texi:
The inst in a mutable should not be, nor should it contain components
that are, unique, mostly_unique, free, dead or mostly_dead. For
most of these it doesn't actually make a lot of sense and for some
of them, e.g. mostly_unique mutables, the code we currently generate
for mutables ends up being mode incorrect.
XXX If we supported partial instantiation then it might make sense
for mutables to have insts that contain free components but we'll
cross that bridge when we come to it.
Reword the restriction on typeclass constraints on mutables; as
written it looks like the typeclass constraints are being applied to
the inst variables.
compiler/hlds_code_util.m:
s/hlds/HLDS in a comment.
Add a predicate that tests if an inst is valid inst for a mutable
declaration.
compiler/make_hlds_passes.m:
Check that the inst in a mutable declaration conforms to the above
rules and emit an error message if it does not.
Turn an if-then-else into a switch.
Fix an overlong line.
compiler/prog_mode.m:
Fix some formatting.
tests/invalid/Mmakefile:
tests/invalid/uniq_mutable.{m,err_exp}:
Test case for the above.
tests/invalid/bad_mutable.err_exp:
Conform to the above change.
XXX We shouldn't really complain about as in this case the real
error is the fact that the inst is undefined.
Estimated hours taken: 7
Branches: main
A common way to use parallel conjunction can cause a lot of Mercury contexts
to be allocated, e.g.
map([], []).
map([H0|T0], [H|T]) :-
( p(H0, H) % contains no parallel conjunctions
& map(T0, T)
).
When the left parallel conjunct completes, the engine that was executing it
must suspend the context in which it was run, waiting for the right conjunct
to finish. The engine is then idle and will attempt to find further work to
execute in a _new_ context. To avoid excessive memory consumption due to
contexts we currently limit the number of contexts we allocate. However,
that severely limits the parallelism we can exploit in this example (and
similar patterns of work distribution). There are a lot of contexts
allocated but most of them are simply suspended.
Assuming that most parallel conjuncts contain small sub-computations, we can
allow many contexts to be allocated without excessive memory consumption by
just giving them smaller stacks. This patch creates a simple variant of a
MR_Context structure which has smaller stacks than the initial MR_Context
structure and executes parallel conjuncts in the smaller contexts if
larger contexts are unavailable.
runtime/mercury_memory.c:
runtime/mercury_wrapper.c:
runtime/mercury_wrapper.h:
doc/user_guide.texi:
Add globals to hold the desired sizes of small det and nondet stacks.
Add `--small-detstack-size' and `--small-nondetstack-size'
options for the MERCURY_OPTIONS environment variable to set the
desired sizes.
runtime/mercury_context.h:
Add a MR_ctxt_size field to MR_Context to indicate whether it has
regular or small sized stacks.
runtime/mercury_context.c:
Add an argument to MR_create_context() specifying whether we want a
regular or small context.
Ask for small stacks when creating new contexts to begin execution
from a spark (i.e. parallel conjuncts).
Create a new free-list to hold unused small contexts.
extras/concurrency/spawn.m:
runtime/mercury_mm_own_stacks.c:
runtime/mercury_thread.c:
Match the interface change to MR_create_context(). We give the
initial context and contexts created due for explicit Mercury threads
regular-sized stacks.
Estimated hours taken: 6
Branches: main
Document my recent change implementing coverage testing. At the same time,
eliminate the old hack that allowed a file containing a list of file names to
be considered a trace count file. We haven't needed it since the addition of
mtc_union, and it can lead to incomprensible error messages. (The presence
of the old hack made documenting coverage testing harder.)
In the process, fix the tools code for rerunning failed test cases only.
doc/user_guide.texi:
Document my recent change implementing coverage testing, and the
elimination of the old hack.
mdbcomp/trace_counts.m:
Modify the predicates for reading in trace count files along the lines
above.
mdbcomp/slice_and_dice.m:
Modify the predicates for reading in slices and dices along the lines
above.
Rename some function symbols to avoid ambiguities.
compiler/tupling.m:
slice/mcov.m:
slice/mtc_diff.m:
slice/mtc_union.m:
trace/mercury_trace_declarative.c:
Conform to the changes above.
slice/mcov.m:
Fix the usage message, which referred to this program by its old name
mct.
Allow the output to be restricted to a set of named modules only.
This is to make testing easier.
slice/mtc_diff.m:
Rename the long form of the -o option from --out to --output-file,
to make it consistent with the other programs.
tests/run_one_test:
tools/bootcheck:
Modify the algorithm we use to gather trace counts for the Mercury
compiler from both passed and failed test cases to run mtc_union
periodically instead of gathering all the trace counts file and keeping
them to the end (which takes far too much disk space).
Fix an old bug: gather trace counts from executions of the Mercury
compiler only.
tests/debugger/Mmakefile:
tests/debugger/dice.passes:
Modify the dice test case to compute the union of the trace counts for
the passed versions of this test case to use mtc_union to create
dice.passes, instead of having dice.passes statically contain the list
of the names of the passed trace count files (since that capability
is deleted by this diff).
tools/bootcheck:
tests/Mmake.common:
Fix the code for rerunning failed tests only.
mdbcomp/prim_data.m:
Eliminate some ambiguities in predicate names.
compiler/*.m:
Conform to the change to prim_data.m.
compiler/error_util.m:
Add reading files as a phase in error messages.
compiler/mercury_compile.m:
Use the new facilities in error_util for printing an error message.
Estimated hours taken: 1
Branches: main
library/benchmarking.m:
Add a mechanism for dumping out trace counts at selected stages.
compiler/options.m:
doc/user_guide.texi:
Add an option, --dump-trace-counts, to dump out trace counts at
selected stages. The selection is indicated the same way as with
the --dump-hlds option.
compiler/handle_options.m:
Make --dump-trace-counts, as well as --dump-hlds, imply compilation by
phases. Without this, stage numbers referring to the code generator
would be ineffective (since the selected stage of the HLDS would
never exist for all procedures at once).
compiler/mercury_compile.m:
Dump the trace counts file when the option calls for it.
Estimated hours taken: 1
Branches: main
compiler/options.m:
doc/user_guide.texi:
Add `--search-library-files-directory <directory>',
`--search-lib-files-dir <directory>' options which are
equivalent to adding <directory> using all of the
`--search-directory', `--intermod-directory',
`--library-directory', `--init-file-directory' and
`--c-include-directory' options.
Estimated hours taken: 4
Branches: main
doc/reference_manual.texi:
Document trace goals.
NEWS:
Announce trace goals, now that they are documented.
compiler/prog_io_goal.m:
Fix a typo in their implementation.
Branch: main
Estimated hours: 24
Add an analysis which determines the set of modules which
are imported but are not used.
It also has a more precise analysis of those modules not needed
in the interface, as it reports more modules than the current
analysis.
compiler/unused_imports.m:
The module which does the analysis.
compiler/make_hlds_passes.m:
Record the parent used modules.
Factor out the code for adding the module specifiers.
compiler/hlds_module.m:
Add utility predicates for recording those modules
used in the parent modules of the current module and
those imports which are in the interface.
compiler/options.m:
Add the option --warn-unused-imports.
By default it's turned off because I have yet
to run this analysis on the compiler and fix
the modules.
compiler/check_hlds.m:
compiler/mercury_compile.m:
Add the analysis to the compiler.
doc/user_guide.texi:
Document the new option.
compiler/notes/compiler_design.html:
Document the new pass.
Estimated hours taken: 0.5
Branches: main
Merge late changes from the 0.13 branch onto the main branch.
BUGS:
Merge in additions from the 0.12(!) branch.
HISTORY:
Fix typos and be more consistent about the formatting of dates.
NEWS:
Move the news about checking inst declarations for consistency
with visible type constructors to the post-0.13 news where it belongs.
Merge changes to the 0.13 branch.
README.Solaris:
Merge changes from the 0.13 branch.
compiler/notes/todo.html:
Merge changes from the 0.13 branch.
doc/user_guide.texi:
Merge changes from 0.13 branch related to trace counts
documentation.
extras/curses/sample/smalltest.m:
extras/gator/genotype.m:
extras/references/tests/ref_test.m:
samples/rot13/rot13_ralph.m:
tests/mmc_make/complex_test.m:
tests/mmc_make/lib/complex.m:
Merge minor fixes from the 0.13 branch.
Estimated hours taken: 1.5
Branches: main, 0.13
doc/user_guide.texi:
Add a new section "Trace counts" to the debugging chapter.
Document the mtc, mslice, mdice and mtc_union tools.
mdbcomp/slice_and_dice.m:
Fix a comment.
slice/mtc_union.m:
Fix an incorrect usage message.
Estimated hours taken: 1
Branches: main, release
Prepare for the 0.13 release and fix/update documentation.
NEWS:
HISTORY:
Update the NEWS and HISTORY files for the 0.13 release.
RELEASE_NOTES:
s/0.12/0.13/
Add Linux/x86_64 to the list of architectures supported by this
release.
Remove Solaris 8/x86 from the same list.
.README.in:
extras/README:
Remove references to the clp(r) binding. We no longer support it.
bindist/bindist.README:
Update the year in the copyright message.
Fix the gc version; 0.13 uses 6.5.
BUGS:
README.DotNet:
README.Java:
README.gcc-backend:
doc/faq.texi:
doc/make_manpage:
doc/mercury.html.in:
doc/mercury.info.in:
s/.cs.mu.oz.au/.csse.unimelb.edu.au/
library/array.m:
library/builtin.m:
library/eqvclass.m:
library/graph.m:
samples/README:
Fix typos.
Estimated hours taken: 30
Branches: main
Add options to perform code generation and liveness detection for the low-level
backend using parallel threads. These are enabled with `--parallel-code-gen'
and `--parallel-liveness' options respectively, for compilers built in grades
supporting multiple engines, and running with multiple engines enabled.
Currently we only attempt to use two threads.
compiler/global_data.m:
Use a new type `type_num' instead of `int' everywhere for common cell
type numbers.
Add a function `bump_type_num_counter' which takes a global_data
structure and returns a global_data with the common cell type number
counter incremented by some amount. This is to allow multiple threads
to add new types to their own copies of the global_data structure
without type numbers clashing when we try to merge them later.
Add a predicate `merge_global_datas' which takes two global_datas and
merges their static cell information.
Add a predicate `remap_static_cell_references' which updates code using
the second global_data structure (passed to merge_global_datas) to
refer to static cells in the combined global_data structure.
compiler/layout_out.m:
compiler/llds.m:
compiler/llds_out.m:
compiler/opt_debug.m:
Conform to the type change of common cell type numbers.
compiler/options.m:
doc/user_guide.texi:
Add `--parallel-liveness' and `--parallel-code-gen' options.
The documentation is commented out for now.
compiler/handle_options.m:
Make the `--parallel-liveness' and `--parallel-code-gen' options imply
`--no-trad-passes'.
compiler/liveness.m:
Add parallel liveness detection support.
The sequential liveness detection code took I/O states in order to
output debugging information; make it take values of a typeclass
`debug_liveness_io' instead, and make io.state an instance of the
typeclass. In the parallel case we pass dummy values that don't try to
output debugging information.
compiler/mercury_compile.m:
Run parallel liveness detection if it is enabled and liveness debugging
is not enabled (see above).
compiler/proc_gen.m:
Add parallel code generation support. Run it if selected by the user
and `--very-verbose' is not enabled (as that would require I/O).
Estimated hours taken: 0
Branches: main, release
Fix a problem pointed out by Nick Nethercote.
doc/user_guide.texi:
Update a reference to mdb's set command.
Estimated hours taken: 3
Branches: main
Extend the mdb command "ambiguity" to report information about not just
ambiguous procedure names and type constructor names but also ambiguous
function symbols.
trace/mercury_trace_tables.[ch]:
Implement the new capability.
Declare some static functions at the top of the file before
their definitions.
trace/mercury_trace_cmd_developer.c:
Add new options -p, -t and -f that allow the user to select the
printing of ambiguity information about procedure names, type
names and/or function symbols.
doc/user_guide.texi:
Document the new functionality and options.
trace/mercury_trace_spy.c:
Minor style fix.
tests/debugger/ambiguity.{m,exp}:
Extend this test case to test the new functionality, and update the
expected output.
Estimated hours taken: 5
Branches: main
One of Hans Boehm's papers says that heap cells allocated by GC_MALLOC_ATOMIC
are grouped together into pages, and these pages aren't scanned during the
sweep phase of the garbage collector. I therefore modified the compiler
to use GC_MALLOC_ATOMIC instead of GC_MALLOC whereever possible, i.e
when the cell being allocated is guaranteed not to have any pointer to
GCable memory inside it.
My first benchmarking run showed a speedup of 4.5% in asm_fast.gc:
EXTRA_MCFLAGS = --use-atomic-cells
mercury_compile.01 average of 6 with ignore=1 18.30
EXTRA_MCFLAGS = --no-use-atomic-cells
mercury_compile.02 average of 6 with ignore=1 19.17
However, later benchmarks, after the upgrade to version 7.0 of boehm_gc,
show a less favourable and more mixed picture, with e.g. a 4% speedup
in hlc.gc at -O3, a 3% slowdown in asm_fast.gc at -O4, and little effect
otherwise:
EXTRA_MCFLAGS = -O1 --use-atomic-cells
GRADE = asm_fast.gc
mercury_compile.01 average of 6 with ignore=1 23.30
EXTRA_MCFLAGS = -O1 --no-use-atomic-cells
GRADE = asm_fast.gc
mercury_compile.02 average of 6 with ignore=1 23.28
EXTRA_MCFLAGS = -O2 --use-atomic-cells
GRADE = asm_fast.gc
mercury_compile.03 average of 6 with ignore=1 18.51
EXTRA_MCFLAGS = -O2 --no-use-atomic-cells
GRADE = asm_fast.gc
mercury_compile.04 average of 6 with ignore=1 18.66
EXTRA_MCFLAGS = -O3 --use-atomic-cells
GRADE = asm_fast.gc
mercury_compile.05 average of 6 with ignore=1 18.44
EXTRA_MCFLAGS = -O3 --no-use-atomic-cells
GRADE = asm_fast.gc
mercury_compile.06 average of 6 with ignore=1 18.48
EXTRA_MCFLAGS = -O4 --use-atomic-cells
GRADE = asm_fast.gc
mercury_compile.07 average of 6 with ignore=1 18.28
EXTRA_MCFLAGS = -O4 --no-use-atomic-cells
GRADE = asm_fast.gc
mercury_compile.08 average of 6 with ignore=1 17.70
EXTRA_MCFLAGS = -O1 --use-atomic-cells
GRADE = hlc.gc
mercury_compile.09 average of 6 with ignore=1 24.78
EXTRA_MCFLAGS = -O1 --no-use-atomic-cells
GRADE = hlc.gc
mercury_compile.10 average of 6 with ignore=1 24.69
EXTRA_MCFLAGS = -O2 --use-atomic-cells
GRADE = hlc.gc
mercury_compile.11 average of 6 with ignore=1 19.36
EXTRA_MCFLAGS = -O2 --no-use-atomic-cells
GRADE = hlc.gc
mercury_compile.12 average of 6 with ignore=1 19.26
EXTRA_MCFLAGS = -O3 --use-atomic-cells
GRADE = hlc.gc
mercury_compile.13 average of 6 with ignore=1 18.64
EXTRA_MCFLAGS = -O3 --no-use-atomic-cells
GRADE = hlc.gc
mercury_compile.14 average of 6 with ignore=1 19.38
EXTRA_MCFLAGS = -O4 --use-atomic-cells
GRADE = hlc.gc
mercury_compile.15 average of 6 with ignore=1 19.39
EXTRA_MCFLAGS = -O4 --no-use-atomic-cells
GRADE = hlc.gc
mercury_compile.16 average of 6 with ignore=1 19.41
runtime/mercury_heap.h:
Define atomic equivalents of the few heap allocation macros
that didn't already have one. These macros are used by the LLDS
backend.
runtime/mercury.h:
Define an atomic equivalent of the MR_new_object macro.
These macros are used by the MLDS backend.
Use MR_new_object_atomic instead of MR_new_object to box floats.
compiler/hlds_data.m:
compiler/llds.m:
compiler/mlds.m:
Modify the representations of the heap allocations constructs
to include a flag that says whether we should use the atomic variants
of the heap allocation macros.
compiler/llds_out.m:
compiler/mlds_to_c.m:
Respect this extract flag when emitting C code.
In mlds_to_c.m, also add some white space that makes the code easier
for humans to read.
compiler/type_util.m:
Add a mechanism for finding out whether we can put a value of a given
type into an atomic cell.
Put the definitions of functions and predicates in this module
in the same order as their declarations.
Turn some predicates into functions. Change the argument order of
some predicates to conform to our usual conventions.
compiler/unify_gen.m:
compiler/ml_unify_gen.m:
Use the new mechanism in type_util.m to generate code that creates
atomic heap cells if this is possible and is requested.
compiler/code_info.m:
compiler/var_locn.m:
Act on the information provided by unify_gen.m.
compiler/options.m:
doc/user_guide.texi:
Add an option to control whether the compiler should try to use
atomic cells.
compiler/dupelim.m:
compiler/dupproc.m:
compiler/exprn_aux.m:
compiler/higher_order.m:
compiler/jumpopt.m:
compiler/livemap.m:
compiler/middle_rec.m:
compiler/ml_code_util.m:
compiler/ml_elim_nested.m:
compiler/ml_optimize.m:
compiler/ml_util.m:
compiler/mlds_to_gcc.m:
compiler/mlds_to_il.m:
compiler/mlds_to_java.m:
compiler/modecheck_unify.m:
compiler/opt_debug.m:
compiler/opt_util.m:
compiler/par_conj_gen.m:
compiler/polymorphism.m:
compiler/reassign.m:
compiler/size_prof.m:
compiler/structure_sharing.domain.m:
compiler/use_local_vars.m:
Minor diffs to conform to the changes above.
compiler/structure_reuse.direct.choose_reuse.m:
Add an XXX comment about the interaction of the new capability
with structure reuse.
Estimated hours taken: 1
Branches: main, release
Get rid of the `thread_safe' mutable attribute, since this doesn't actually
make access to a mutable thread safe (in fact it makes them less thread
safe than the `not_thread_safe' version).
By extension this also removes support for the `not_thread_safe' mutable
attribute.
compiler/prog_io.m:
compiler/prog_item.m:
compiler/prog_mutable.m:
Remove support for the `thread_safe' mutable attribute.
compiler/make_hlds_passes.m:
Remove support for the `thread_safe' mutable attribute.
Mark the foreign clauses for `get' predicates for constant
mutables as thread safe.
doc/reference_manual.texi:
Delete the documentation for the `thread_safe' mutable attribute.
tests/hard_coded/mutable_decl.m:
tests/hard_coded/pure_mutable.m:
tests/hard_coded/trace_goal_env_1.m:
tests/hard_coded/trace_goal_env_2.m:
tests/hard_coded/unusual_name_mutable.m:
tests/hard_coded/sub-modules/mutable_child.m:
tests/hard_coded/sub-modules/mutable_grandchild.m:
tests/hard_coded/sub-modules/mutable_parent.m:
tests/invalid/bad_mutable.{err_exp,m}:
tests/invalid/not_in_interface.m:
Conform to the above change.
Estimated hours taken: 1
Branches: main
Add a new output option `--output-libgrades' that prints the list of grades
that the compiler will build libraries that are to be installed in. This is
useful for debugging problems Mercury.options files (and for Mercury
developers, problems with mmc --make.)
compiler/options.m:
Add the new option.
compiler/mercury_compile.m:
Implement the new option.
doc/user_guide.texi:
Document the new option.
Estimated hours taken: 6
Branches: main
Add escape sequences for encoding unicode characters in Mercury string
literals. The unicode characters are encoded in UTF-8 on the C backends and
in UTF-16 on the Java and IL backends.
NEWS:
Mention the changes.
doc/reference_manual.texi:
Document the new escape sequences.
Divide the section on string tokens up into multiple paragraphs.
library/lexer.m:
Convert unicode characters encoded with the new escape sequences to
UTF-8 on the C backends and UTF-16 on the Java and IL backends.
Some of the new predicates may be moved to a "unicode" module that I'm
intending to add to the standard library in a subsequent change.
library/list.m:
Fix the formatting of some comments.
tests/hard_coded/Mmakefile:
tests/hard_coded/unicode.exp:
tests/hard_coded/unicode.m:
tests/invalid/Mmakefile:
tests/invalid/unicode1.exp:
tests/invalid/unicode1.m:
tests/invalid/unicode2.exp:
tests/invalid/unicode2.m:
Test the new support for unicode.
Estimated hours taken: 0.1
Branches: main
doc/reference_manual.texi:
Shift the documentation on passing data to and from C from section 14
of the reference manual (the old C interface) to section 13 (the new
foreign language interface.) Place a pointer in section to 14 to the
new location of that documentation. (This change just reverses
the existing situation.)
Estimated hours taken: 6
Branches: main
Issue a warning message if a user defined bound inst is not consistent with
any of the types in scope.
The warning needs to be disabled by default until all the Mercury machines
have been updated. This is because we will need to disable the warning for
the array module, since the following inst triggers the warning:
:- inst array(I) == bound(array(I)).
The problem is that there is no type with a function symbol array/1. I think
if we allow insts to be annotated with a type (as Zoltan suggested), then this
problem would go away, since we needn't check insts that are for foreign types.
NEWS:
Mention the new warning.
compiler/check_hlds.m:
Include the new module check_hlds.inst_check.
compiler/inst_check.m:
Implement a predicate that checks that all user defined insts
are consistent with at least one type in scope. The predicate
issues a warning if no consistent types are found for an inst.
compiler/mercury_compile.m:
Check insts at stage 12, before type and mode checking.
compiler/options.m:
Add an option to turn the new warning on or off.
compiler/notes/compiler_design.html:
Document the new module and compilation stage.
doc/user_guide.texi:
Document the option to disable the new warning.
tests/warnings/Mmakefile:
tests/warnings/Mercury.options:
tests/warnings/inst_with_no_type.m:
tests/warnings/inst_with_no_type.exp:
tests/warnings/inst_with_no_type_2.m:
Test the new warning.
Estimated hours taken: 12
Branches: main
Implement `:- pragma foreign_export'. This is intended to be a replacement
for `:- pragma export'. The principle difference is that `:- pragma
foreign_export' allows you to restrict exports to a particular foreign
language. This language will usually be the target language but in the case
of backends that support multiple foreign languages, e.g. the IL backend, it
also allows us to restrict the exports to a subset of the available foreign
languages.
Add some support for exporting procedures in the Java backend. This is
currently undocumented because I cannot test it properly while the Java
backend is not working. (The reason for adding the support was to make sure
that all of the MLDS backends were handling foreign_export declarations
correctly.)
Make the compiler emit warnings about exports for Java, IL, C# and MC++ not
yet being implemented. For the latter two this is true. As mentioned above
this change adds some support for exports in the Java backend and there was
some pre-existing (but undocumented) support for exports to IL. (The warnings
can be deleted once exports for these languages are properly documented and/or
implemented.)
compiler/prog_item.m:
Rename the export item to foreign_export for consistency with the
rest of the items concerned with the foreign language interface.
Add an extra field to that item. The new field stores the foreign
language that the pragma applies to.
compiler/prog_io_pragma.m:
Parse foreign_export pragmas.
Implement `:- pragma export' declarations as a special case of
`:- pragma foreign_export' declarations.
compiler/add_pramga.m:
Rename some predicates.
Emit warnings about foreign_exports to languages that we do not
currently support.
compiler/export.m:
Rename some of the predicates in this module to make them more C
specific.
Handle foreign exports for the lowlevel C backend.
compiler/hlds_module.m:
Add an extra field to the pragma_exported_proc structure to hold the
name of the foreign language that the corresponding foreign_export
declaration is for.
compiler/mercury_to_mercury.m:
Add code to output foreign_export pragmas.
compiler/ml_code_gen.m:
Don't filter out exports for Java, C# and MC++. The Java exports
can now be passed down to mlds_to_java.m and the other two ought to
be caught by the frontend of the compiler.
compiler/mlds_to_java.m
Add a tentative implementation of pragma foreign_export for Java.
This is currently not documented in the reference manual because
it is (largely) untested.
compiler/mlds_to_c.m:
Change an if-then-else to a switch.
Add a sanity check. Exports for languages other than C should not
reach here.
compiler/mlds_to_il.m:
Update the TODO list at the head of this file.
Add a sanity check. Exports for languages other than IL should not
reach here.
compiler/dead_proc_elim.m:
compiler/det_analysis.m:
compiler/foreign.m:
compiler/handle_options.m:
compiler/make_hlds_passes.m:
compiler/mlds.m:
compiler/mlds_to_managed.m:
compiler/module_qual.m:
compiler/modules.m:
compiler/recompilation.version.m:
Conform to the above changes.
Minor formatting changes.
doc/reference_manual.texi:
Add a new section to the foreign language interface chapter
documenting the new pragma.
Update the descriptions of the language specific bindings to include
the new pragma.
tests/hard_coded/Mmakefile:
tests/hard_coded/pragma_foreign_export.{m,exp}:
Make sure that we can parse the new syntax and run a simple program
that uses exported procedures.
tests/invalid/invalid_export_detism.{m,err_exp}:
Update this test case to conform to the new pragma name.
Estimated hours taken: 6
Branches: main
In low-level, parallel grades which don't use gcc global registers, each
reference to a Mercury register (etc.) references a thread-specific Mercury
engine base address `MR_thread_engine_base'. This is either a thread-specific
variable or a call to pthread_getspecific(). This patch improves performance
in these grades by copying `MR_thread_engine_base' once at the start of each
basic block into a local variable, then using the local copy for the rest of
the basic block.
compiler/options.m:
doc/user_guide.texi:
Add `--local-thread-engine-base' option, enabled by default.
compiler/llds_out.m:
When `--local-thread-enabled-base' is enabled, emit code to redefine
`MR_maybe_local_thread_engine_base' to `MR_local_thread_engine_base'
before the code of a procedure, and undo it afterwards.
After each label instruction initialise a local variable
`MR_local_thread_engine_base' with a copy of `MR_thread_engine_base'.
runtime/mercury_engine.h:
If gcc global registers are not used then #define `MR_engine_base' in
terms of `MR_maybe_local_thread_engine_base', and initially #define
`MR_maybe_local_thread_engine_base' to `MR_thread_engine_base'.
Estimated hours taken: 0.5
Branches: main, release
Updates and fixes for the trailing documentation.
doc/reference_manual.texi:
Remove references to the clp(r) interface - we no longer support it.
Convert the trailing example code to use the new foreign language
interface and clean up its fromatting.
s/MR_current_choice_point_id()/MR_current_choicepoint_id()/
Estimated hours taken: 32
Branches: main
Add the possibility of annotating foreign code with sharing information.
The sharing information is part of the foreign_proc pragmas, and must be
of the following format:
no_sharing % meaning that the procedure does not
% create any sharing.
unknown_sharing % meaning that the procedure creates any
% possible sharing;
sharing(MaybeTypeInformation, SharingList)
% meaning that the procedure creates at most
% the listed sharing.
where
MaybeTypes =
yes(Types)
no
where Types corresponds to the type-signature of the foreign proc (i.e. they
must be unifiable). The types are only needed when the typeselectors used in
specifying the sharing make use of type variables.
and
SharingList = list of SharingPair
and
SharingPair = cel(Var1, Typeselectors1) - cel(Var2, Typeselectors2)
where
Var1, Var2 correspond to head variables from the foreign proc;
Typeselectors1, Typeselectors2 correspond to a list of typeselectors,
i.e., a list of types possibly in terms of the types given in
MaybeTypes.
Example:
:- pred array.init_2(int::in, T::in, array(T)::array_uo) is det.
:- pragma foreign_proc("C",
array.init_2(Size::in, Item::in, Array::array_uo),
[will_not_call_mercury, promise_pure, thread_safe, will_not_modify_trail,
sharing(yes(int, T, array(T)), [cel(Item,[]) - cel(Array,[T])])],
"
ML_alloc_marray(Array, Size + 1, MR_PROC_LABEL);
ML_init_marray(Array, Size, Item);
").
The meaning: a call init_2(Size, Item, Array) may create
sharing between Item, and any terms of Array with the type T (i.e. the elements
of the array).
compiler/add_pragma.m:
compiler/prog_ctgc.m:
compiler/prog_io_pragma.m:
Parsing/Renaming routines for the user annotated sharing.
compiler/ctgc.util.m:
BUGFIX. The definition of "get_type_substitution" was actually doing
the wrong thing, as it was creating a substitution with which to
rename two type-lists "away" from each other... while the analysis
needs the substitution resulting from unifying the type-lists.
compiler/module_qual.m:
Module qualify the types that are part of the sharing declaration.
compiler/prog_data.m:
Types for recording user annotated sharing.
Change the definition of the public representation for
structure sharing.
compiler/structure_reuse.direct.detect_garbage.m:
compiler/structure_reuse.indirect.m:
compiler/structure_sharing.analysis.m:
compiler/structure_sharing.domain.m:
Use foreign_proc sharing information when computing the overall
sharing.
compiler/equiv_type.m:
compiler/recompilation.m:
compiler/recompilation.usage.m:
Expand equivalence types.
I left an XXX comment in recompilation.usage.m, as I don't know what
exactly should be found at that place in the case of such a
sharing foreign_proc declaration.
doc/reference_manual.texi:
Document the sharing foreign_proc pragmas. (Commented out).
Add entries for documenting structure sharing analysis, and
compile-time garbage collection. (Commented out).
Estimated hours taken: 0.5
Branches: main, release
doc/reference_manual.texi:
Fix the description of the foreign_name mutable attribute. For the
high-level C backend the C type of the mutable will not always be
MR_Word.
s/preceeding/preceding/
Estimated hours taken: 10
Branches: main, release
Do not allow discriminated unions with a single zero-arity constructor to have
user-defined equality or comparison. Defining such types causes an assertion
failure in the compiler because the types are considered to be dummy types and
the runtime currently doesn't support (and probably won't ever) d.u. dummy
types with user-defined equality or comparison.
Fix another bug where the compiler was not printing out the `recompile with
-E' prompt at the appropriate time. The bug was caused by the fact that there
were several copies of the globals structure and the one that was being
checked at the time the prompt was being printed out was not the one that had
been updated during the rest of compilation.
compiler/add_types.m:
Emit an error message if an attempt is made to define a d.u. dummy
type with user-defined equality or comparison.
compiler/globals.m:
Remove the extra_error_info field from the globals structure and turn
it into a mutable. Export access predicates for this mutable. The
reason for doing this is that the compiler was sometimes looking at
the wrong copy of the globals structure when checking the value of
this flag - this meant that sometimes the recompile with `-E' prompt
was not being displayed. Turning this flag into a mutable avoids the
problem because now there is only one copy.
compiler/make_hlds.m:
s/__/./ in a few spots.
doc/reference_manual.texi:
Mention the new restrictions on discriminated union types with
user-defined equality or comparison.
tests/invalid/exported_unify2.m:
tests/invalid/exported_unify3.m:
Change some types with user-defined equality or comparison so that
they are no longer dummy types. These test cases have not been
triggering the assertion failure in the compiler because they are only
error checked and the assertion that is failing occurs further along
in the compilation process.
tests/invalid/user_eq_dummy.{m,err_exp}:
Test the new error message for dummy types with user-defined equality
or comparison.
tests/invalid/extra_info_prompt.{m,err_exp}:
Test that the recompile with `-E' prompt is being displayed when it
should.
tests/invalid/Mercury.options:
tests/invalid/Mmakefile:
Include the new test cases.
Where there is a verbose version of the error message compile with
`-E'.
tests/recompilation/add_type_re.err_exp.2:
tests/invalid/*.err_exp:
Update expected outputs to conform to the above.
Estimated hours taken: 5
Branches: main
Add a new mdb command, 'shell', that allows users to execute shell commands
from within the debugger.
Allow the user to give up to nine additional arguments to the 'source' command.
Occurrences of the strings "$1" through "$9" in the sourced file are replaced
by the corresponding additional arguments, allowing for parameterised scripts.
Use the two new features mentioned above to add two more mdb commands: one
to open a term, goal or exception in an external editor another command
to perform a grep on a term, goal or exception (useful for seeing if a value
occurs in a big map, for example).
NEWS
Mention the new commands.
doc/mdb_categories:
doc/user_guide.texi:
Document the new commands.
scripts/Mmakefile:
scripts/mdb_open:
scripts/mdb_vim:
Add scripts for the new commands.
scripts/mdbrc.in:
Add aliases for the new shell, emacs, grep and vim commands.
tests/debugger/completion.exp:
tests/debugger/mdb_command_test.inp:
Adjust for new commands.
tests/debugger/save.exp:
tests/debugger/save.exp2:
Adjust for new commands. Replace system dependent strings
with ZZZ instead of XXX.
tests/debugger/Mmakefile:
tests/debugger/shell.exp:
tests/debugger/shell.inp:
tests/debugger/shell.m:
tests/debugger/shell_test_script:
Test the shell and source commands.
trace/mercury_trace_cmd_misc.c:
Check if there are extra arguments to the source mdb command
and pass them to MR_trace_source if there are.
trace/mercury_trace_cmd_misc.h:
Add shell command handling function prototype.
trace/mercury_trace_declarative.c:
Call MR_trace_call_system_display_error_on_failure instead
of system when displaying benchmarking statistics for the
declarative debugger.
trace/mercury_trace_internal.c:
trace/mercury_trace_internal.h:
Implement the shell command and extend the source command
to handle the optional extra arguments.
trace/mercury_trace_readline.c:
trace/mercury_trace_readline.h:
Add a new function to read a line and replace all the
occurrences of "$[1-9]" with the corresponding value from an array.
Delete comments in the .c file that are duplicated in the .h file.
trace/mercury_trace_util.c:
trace/mercury_trace_util.h:
Implement MR_trace_call_system_display_error_on_failure that
executes a system call and displays an error message if the system
call terminates abnormally.
Estimated hours taken: 3
Branches: main, release
Fix the failure of debugger/declarative/sort.m. The problem was that the
depth command in the declarative debugger did not affect the depth to which
I/O actions were printed. This was because printing I/O actions uses the
`print all' configuration parameters and the `depth' command in the
declarative debugger only affects the `print' configuration parameters. The
solution is to add four new formatting commands to the declarative debugger
(really just variants of the existing commands.) These are `depth io', `size
io', `lines io' and `width io'. These function identically to the `depth',
`size', `lines' and `width' commands except that they affect the `print all'
configuration parameters, rather the ones for `print'.
browser/declarative_user.m:
Add the four new commands described above.
doc/user_guide.texi:
Document the new commands.
browser/declarative_debugger.m:
Fix some formatting.
tests/debugger/declarative/sort.inp:
tests/debugger/declarative/sort.exp:
Use the new commands set the depth to which I/O actions are printed in
the declarative debugger to an appropriate level for this test - it
needs to be deep enough to print out the strings returned by
read_line_as_string_2.
tests/debugger/declarative/dd_params.exp:
tests/debugger/declarative/dd_params.inp:
Extend this test to cover the new commands.
Estimated hours taken: 60
Branches: main
Provide a mechanism for collecting statistics about tabling operations,
and provide a much more convenient mechanism for resetting tables.
Since it would too complex to do this while preserving the capability
of setting --tabling-via-extra-args to no, eliminate that capability
and the option. That option was useful only for measurements of the
performance boost from setting --tabling-via-extra-args to yes in any case,
so users lose no functionality.
Previously, the only way to debug the low level details of the tabling
mechanism was to build a runtime with a specific C macro (MR_TABLE_DEBUG)
and link with that runtime; this was cumbersome. Change that so that
every one of the debuggable tabling macros has a bool argument that says
whether debugging is enabled or not. The compiler can then set this to
MR_TRUE if the new option --table-debug is given, and to MR_FALSE otherwise.
If set to MR_FALSE, the C compiler should optimize away the debug code,
with zero impact on program size or speed.
Since these changes to macros require nontrivial bootstrapping, which we don't
want to do unnecessarily, modify the interface of the tabling macros as
required to support size limits on tables. This diff also implements the
parsing of size limit specifications on tables, but does not implement them
yet; that is for a future change.
To make the syntax simpler, this diff deletes the free-standing fast_loose_memo
pragma. The same functionality is now available with a fast_loose annotation
on an ordinary memo pragma.
Make a bunch of changes to improve readability and maintainability
in the process. These mostly take the form of renaming ambiguous and/or
not sufficiently expressive function symbols.
runtime/mercury_stack_layout.h:
runtime/mercury_tabling.h:
Move the description of structure of tables from mercury_stack_layout.h
to mercury_tabling.h, since we now need it for statistics even if
execution tracing is not enabled.
Modify those data structures to have room for the statistics.
Don't distinguish "strict", "fast_loose" and "specified" memoing
as separate eval methods; treat them as just different kinds
of the same eval method: "memo".
Remove underscores from the names of some types that the style guide
says shouldn't be there.
runtime/mercury_tabling_preds.h:
runtime/mercury_tabling_macros.h:
Modify the approach we use for macros that implement the predicates
of library/table_builtin.m. Instead of selecting between debug and
nondebug based on whether MR_TABLE_DEBUG is defined or not, add
an explicit argument controlling this to each debuggable macro.
The advantage of the new arrangement is that it scales. Another
argument controls whether we are computing statistics (and if yes,
where do we put it), and a third argument controls whether we maintain
back links in the tries and hash tables (this last argument is present
but is ignored for now).
Since the values of the arguments will be known when the .c files
containing calls to these macros are compiled, we pay the space and
time cost of debugging, statistics gathering and the maintenance of
back links if and only we need the revelant functionality.
Provide macros for limited backward compatibility with the old set
of macros; these allow workspaces created by old compilers to work
with the new macros in the runtime. The old macros followed the
naming scheme MR_table_*, the new ones are named MR_tbl_*.
runtime/mercury_table_int_fix_index_body.h:
runtime/mercury_table_int_start_index_body.h:
runtime/mercury_table_type_body.h:
New files containing parts of the old mercury_tabling.c. Each of these
files contains the body of the functions that used to be in
mercury_tabling.c. The new mercury_tabling.c #includes each of these
files more than once, to provide more than one variant of the old
function. These variants differ in aspects such as whether debugging
is enabled or statistics is being collected. Each variant therefore
incurs only the time costs it needs to. (We pay the space cost of
having all these variants all the time of course, but this cost
is negligible.)
runtime/mercury_tabling_stats_defs.h:
runtime/mercury_tabling_stats_nodefs.h:
runtime/mercury_tabling_stats_undefs.h:
New files that serve as wrappers around the newly #included files,
controlling how they handle statistics.
runtime/mercury_tabling.c:
Delete functions now in the new files, and #include them instead.
Delete the data structures that used to contain summary statistics;
the new approach keeps statistics in compiler-generated,
procedure-specific data structures.
runtime/mercury_trace_base.c:
Use the new versions of the tabling macros to access the I/O table.
runtime/mercury_type_info.h:
Update some documentation for the movement of code out of
mercury_tabling.c.
runtime/mercury_types.h:
Provide forward declarations of the identifiers denoting the new types
in mercury_tabling.h.
runtime/mercury_grade.h:
Increment the exec trace version number, since we have changed
a part of the exec trace structure.
runtime/mercury_bootstrap.h:
Fix some temporary issues that arise from some renames above.
runtime/mercury_hash_lookup_or_add_body.h:
Fix comment.
runtime/Mmakefile:
Mention the new files and the dependencies that involve them.
library/table_builtin.m:
Provide a type for representing statistics and a predicate for
printing statistics.
Use the updated versions of the macros in
runtime/mercury_tabling_preds.h.
compiler/prog_item.m:
Change representation of tabling pragmas to allow room for the new
attributes.
Allow an item to be marked as being generated by the compiler
as a result of a pragma memo attribute. We use this for the reset
and statistics predicates.
compiler/mercury_to_mercury.m:
Write out the new attributes of the tabling pragma.
compiler/prog_data.m:
compiler/hlds_data.m:
Change the cons_id that used to refer to a procedure's call table root
to refer to the entirety of the new data structure now containing it.
The compiler now needs a way to refer to the other components of this
new data structure, since it contains the statistics.
As in the runtime, don't distinguish "strict", "fast_loose" and
"specified" memoing as separate eval methods; treat them as just
different kinds of the same eval method: "memo".
Rename some of the uses of the function symbols "c", "java", "il".
compiler/hlds_pred.m:
Add an extra field in proc_infos for storing any tabling attributes.
Change the existing proc_info field that records information about
the kinds of arguments of tabled procedures to record the information
needed by the debugger too. This was needed to allow us to shift all
the RTTI for procedure-specific tables (as opposed to the RTTI for
the global I/O table) from mercury_stack_layout.h to mercury_tabling.h
without duplicating the data (which would be a maintenance problem).
Reformat some comments to make them easier to read.
compiler/layout.m:
compiler/layout_out.m:
Delete the part of the exec trace information that used to record
RTTI for tables, since this information is not generated only as
part of the debugger data structures anymore.
compiler/prog_io_pragma.m:
Recognize the updated syntax for tabling pragmas.
compiler/add_pragma.m:
When processing tabling pragmas for inclusion in the HLDS, create
any reset and statistics predicates they ask for.
compiler/make_hlds_passes.m:
Export a predicate now needed by add_pragma.m.
Handle the new attributes on tabling pragmas
compiler/globals.m:
Change the function symbols of the types describing backends and
foreign languages to say what they are. Previously, both types (as well
as several others) included the function symbol "c"; now, they are
target_c and lang_c respectively.
compiler/table_gen.m:
Implement the changes described at the top.
When passing around varsets and vartypes, pass the arguments in the
standard order.
compiler/goal_util.m:
compiler/hlds_goal.m:
When passing around varsets and vartypes, pass the arguments in the
standard order.
compiler/rtti.m:
Provide types for representing the runtime's data structures for
tabling (which are now significantly more complex than a single word)
and predicates for manipulating them, for use by both the ml and ll
backends.
compiler/llds.m:
Replace the comp_gen_c_var type with the tabling_info_struct type,
which contains the information needed to create the per-procedure
tabling data structures.
Replace references to call tables with references to the various
components of the new tabling data structures.
compiler/llds_out.m:
Add code to write out tabling_info_structs.
Delete the code required for the old, hacky way of resetting tables.
Reorder some code more logically.
compiler/proc_gen.m:
Generate tabling_info_structs.
compiler/stack_layout.m:
Don't generate the information now generated in proc_gen.m.
compiler/mlds.m:
Give mlds_proc_labels their own function symbols, instead of using
a pair. Rename some other function symbols to avoid ambiguity and add
expressiveness.
Provide for the representation of references to the various components
of the new tabling data structures, and for the representation of their
types.
compiler/ml_code_gen.m:
When generating code for a tabled procedure, generate also the data
structures required for its table.
compiler/rtti_to_mlds.m:
compiler/ml_util.m:
Move some predicates from rtti_to_mlds.m to ml_util.m, since we
now also want to call them from ml_code_gen.m.
compiler/name_mangle.m:
Add some utility predicates.
compiler/options.m:
Delete the old --allow-table-reset option.
Add the new --table-debug option.
Comment out an implementor-only option.
compiler/add_pred.m:
compiler/add_solver.m:
compiler/add_trail_ops.m:
compiler/add_type.m:
compiler/bytecode_gen.m:
compiler/code_gen.m:
compiler/compile_target_code.m:
compiler/complexity.m:
compiler/dependency_graph.m:
compiler/det_report.m:
compiler/export.m:
compiler/fact_table.m:
compiler/foreign.m:
compiler/global_data.m:
compiler/globals.m:
compiler/handle_options.m:
compiler/higher_order.m:
compiler/hlds_code_util.m:
compiler/hlds_data.m:
compiler/hlds_goal.m:
compiler/hlds_out.m:
compiler/inlining.m:
compiler/intermod.m:
compiler/make.dependencies.m:
compiler/make.module_target.m:
compiler/make.program_target.m:
compiler/make.util.m:
compiler/make_hlds_passes.m:
compiler/mercury_compile.m:
compiler/ml_call_gen.m:
compiler/ml_closure_gen.m:
compiler/ml_code_gen.m:
compiler/ml_code_util.m:
compiler/ml_elim_nested.m:
compiler/ml_optimize.m:
compiler/ml_switch_gen.m:
compiler/ml_tailcall.m:
compiler/ml_type_gen.m:
compiler/ml_unify_gen.m:
compiler/mlds_to_c.m:
compiler/mlds_to_gcc.m:
compiler/mlds_to_il.m:
compiler/mlds_to_ilasm.m:
compiler/mlds_to_java.m:
compiler/mlds_to_managed.m:
compiler/modes.m:
compiler/module_qual.m:
compiler/modules.m:
compiler/opt_debug.m:
compiler/opt_util.m:
compiler/polymorphism.m:
compiler/pragma_c_gen.m:
compiler/proc_label.m:
compiler/prog_data.m:
compiler/prog_foreign.m:
compiler/prog_item.m:
compiler/prog_mutable.m:
compiler/prog_out.m:
compiler/prog_rep.m:
compiler/prog_util.m:
compiler/recompilation.version.m:
compiler/size_prof.m:
compiler/special_pred.m:
compiler/switch_util.m:
compiler/transform_llds.m:
compiler/tupling.m:
compiler/type_ctor_info.m:
compiler/unify_gen.m:
Conform to the changes above, and/or improve some comments.
mdbcomp/prim_data.m:
Make the names of the function symbols of the proc_label type more
expressive and less ambiguous.
mdbcomp/prim_data.m:
mdbcomp/mdbcomp.m:
mdbcomp/program_representation.m:
mdbcomp/rtti_access.m:
mdbcomp/slice_and_dice.m:
mdbcomp/trace_counts.m:
Use . instead of __ as module qualifier.
Conform to the change to prim_data.m.
browser/declarative_execution.m:
browser/declarative_oracle.m:
browser/declarative_tree.m:
Conform the change to mdbcomp/prim_data.m.
tests/debugger/Mercury.options:
Don't specify --allow-table-reset for fib.m, since that option
doesn't exist anymore.
tests/debugger/fib.m:
Use the new mechanism for resetting the table.
tests/debugger/print_table.m:
Use the new syntax for pragma memo attributes.
tests/invalid/specified.{m,err_exp}:
Use to the new syntax and reset method for pragma memo attributes.
Test the handling of errors in the new attribute syntax.
tests/tabling/Mercury.options:
Don't specify --allow-table-reset for specified.m, since that option
doesn't exist anymore.
tests/tabling/specified.m:
Use the new syntax for pragma memo attributes, and use the new
mechanism for resetting tables. We could also use this test case
for testing the printing of statistics, but the format of that
output is still not final.
tests/tabling/fast_loose.m:
Use the new syntax for pragma memo attributes, and use the new
mechanism for resetting tables.
trace/mercury_trace.c:
trace/mercury_trace_cmd_developer.c:
Conform to the changes in the RTTI data structures regarding tabling.
Remove underscores from the names of some types that the style guide
says shouldn't be there.
library/robdd.m:
Comment out the tabling pragma until this change is bootstrapped.
Without this, the conflict between the old calls to macros generated
by the existing compiler and the new definition of those macros
in the runtime would cause errors from the C compiler.
Estimated hours taken: 12
Branches: main, release
Use functional dependencies on superclasses (in addition to the class itself)
to relax the restrictions on method constraints.
compiler/check_typeclass.m:
Derive induced dependencies from the class_fundep_ancestors field,
after renaming apart the ancestors and substituting parameters.
doc/reference_manual.texi:
Document the change.
tests/hard_coded/typeclasses/Mmakefile:
tests/hard_coded/typeclasses/fundeps_6.exp:
tests/hard_coded/typeclasses/fundeps_6.m:
tests/hard_coded/typeclasses/fundeps_7.exp:
tests/hard_coded/typeclasses/fundeps_7.m:
New test cases.
Estimated hours taken: 0
Branches: main, release
doc/mdb_categories:
Remove a reference to the dd_dd command. That command has not existed
for a while now.
Estimated hours taken: 12
Branches: main
Add an analysis that determines what goals might call code that uses minimal
model tabling. We use this information to avoid emitting redundant pneg
context wrappers. This reduces the overhead of minimal model tabling.
Add two new foreign_proc attributes: `may_call_mm_tabled' and
`will_not_call_mm_tabled' that allow users to annotate foreign_procs that may
call Mercury with information about whether they call minimal model tabled
procedures.
compiler/tabling_analysis.m:
New file. This module contains code for the new analysis.
It is similar to trail usage analysis.
compiler/transform_hlds.m:
Include the new module.
compiler/options.m:
Add a new option `--analyse-mm-tabling' that enables the new analysis
and optimization.
Delete a now-redundant comment about the `--optimize-trail-usage'
option.
Fix some bad indentation.
compiler/mercury_compile.m:
Add the analysis.
Rearrange the stage numbers after stage 190 as we are running out of
room between 190-200.
compiler/hlds_module.m:
Add a slot in the HLDS to store information about which procedures
might call minimal model tabled procedures.
compiler/prog_data.m:
Add support for the new foreign_proc attributes: `may_call_mm_tabled'
and `will_not_call_mm_tabled'.
compiler/mmc_analysis.m:
Allow the new analysis to be use within the intermodule-analysis
framework.
compiler/prog_item.m:
compiler/add_pragma.m:
compiler/prog_io_pragma.m:
compiler/mercury_to_mercury.m:
compiler/trans_opt.m:
Add a new pragma, mm_tabling_info, for use in .opt and .trans_opt
files.
compiler/hlds_goal.m:
Add a new goal feature that indicates that a goal does not call
minimal model tabled procedures.
compiler/ite_gen.m:
Do not emit pneg context wrappers for goals that cannot call minimal
model tabled procedures.
compiler/module_qual.m:
compiler/modules.m:
compiler/recompilation.version.m:
compiler/saved_vars.m:
Minor changes to conform to the above.
compiler/notes/compiler_design.html:
Mention the new module.
Fix a typo: s/qualication/qualification/
doc/user_guide.texi:
doc/reference_manual.texi:
Document the foreign code attributes and compiler options.
Estimated hours taken: 1
Branches: main
Add a new option `--profile-optimized' that enables inlining with deep
profiling. Inlining is usually disabled in deep profiling grades because it
distorts the profile by not gathering counts for inlined procedures.
In other circumstances the lack of inlining can also distort the profile.
This is happening with the G12 finite domain solver where a number of small
procedures implemented in foreign code are being called a lot. Since they
are not being inlined the profiler ends up measuring the cost of crossing
the foreign language interface rather than telling us anything useful.
compiler/options.m:
compiler/handle_options.m:
Add a new option `--profile-optimized' that enables inlining with
deep profiling.
doc/user_guide.texi:
Document the new option.