Estimated hours taken: 4
Branches: main
Add new fields to the goal_info structure for region based memory management.
The fields are currently unused, but (a) Quan will add the code to fill them
in, and then (b) I will modify the code generator to use the filled in fields.
compiler/hlds_goal.m:
Make the change described above.
Group all the procedures that access goal_info components together.
Some of the getters were predicates while some were functions, so
this diff changes them all to be functions. (The setters remain
predicates.)
compiler/*.m:
Trivial changes to conform to the change in hlds_goal.m.
In simplify.m, break up a huge (800+ line) predicate into smaller
pieces.
Estimated hours taken: 10
Branches: main
This diff changes a few types from being defined as equivalent to a pair
to being discriminated union types with their own function symbol. This
was motivated by an error message (one of many, but the one that broke
the camel's back) about "-" being used in an ambiguous manner. It will
reduce the number of such messages in the future, and will make compiler
data structures easier to inspect in the debugger.
The most important type changed by far is hlds_goal, whose function symbol
is now "hlds_goal". Second and third in importance are llds.instruction
(function symbol "llds_instr") and prog_item.m's item_and_context (function
symbol "item_and_context"). There are some others as well.
In several places, I rearranged predicates to factor the deconstruction of
goals into hlds_goal_expr and hlds_goal_into out of each clause into a single
point. In many places, I changed variable names that used "Goal" to refer
to just hlds_goal_exprs to use "GoalExpr" instead. I also changed variable
names that used "Item" to refer to item_and_contexts to use "ItemAndContext"
instead. This should make reading such code less confusing.
I renamed some function symbols and predicates to avoid ambiguities.
I only made one algorithmic change (at least intentionally).
In assertion.m, comparing two goals for equality now ignores goal_infos
for all kinds of goals, whereas previously it ignored them for most kinds
of goals, but for shorthand goals it was insisting on them being equal.
This seemed to me to be a bug. Pete, can you confirm this?
Estimated hours taken: 2
Branches: main
Treat trace goals as quantifying the variables that occur in their io() and/or
state() components.
compiler/hlds_goal.m:
Extend trace scopes with a field for recording the set of quantified
variables.
compiler/add_clause.m:
Record the list of quantified variables.
compiler/quantification.m:
Treat the list of quantified variables as for other scopes.
compiler/hlds_out.m:
Write out the new field.
compiler/mercury_to_mercury.m:
Reorder the arguments of some predicates to make them easier to curry,
e.g. for the new code in hlds_out.m.
Rename some predicates to avoid ambiguities.
compiler/*.m:
Conform to the changes in hlds_goal.m and/or mercury_to_mercury.m.
tests/hard_coded/trace_goal_3.{m,exp}:
New test case to test the new functionality.
tests/hard_coded/Mmakefile:
Enable the new test case.
Estimated hours taken: 6
Branches: main
browser/*.m:
compiler/*.m:
Rename a bunch of predicates and function symbols to eliminate
ambiguities.
The only real change is factoring out some common code in the mlds
and llds code generators, replacing them with single definitions
in switch_util.m.
Estimated hours taken: 18
Branches: main
Move the univ, maybe, pair and unit types from std_util into their own
modules. std_util still contains the general purpose higher-order programming
constructs.
library/std_util.m:
Move univ, maybe, pair and unit (plus any other related types
and procedures) into their own modules.
library/maybe.m:
New module. This contains the maybe and maybe_error types and
the associated procedures.
library/pair.m:
New module. This contains the pair type and associated procedures.
library/unit.m:
New module. This contains the types unit/0 and unit/1.
library/univ.m:
New module. This contains the univ type and associated procedures.
library/library.m:
Add the new modules.
library/private_builtin.m:
Update the declaration of the type_ctor_info struct for univ.
runtime/mercury.h:
Update the declaration for the type_ctor_info struct for univ.
runtime/mercury_mcpp.h:
runtime/mercury_hlc_types.h:
Update the definition of MR_Univ.
runtime/mercury_init.h:
Fix a comment: ML_type_name is now exported from type_desc.m.
compiler/mlds_to_il.m:
Update the the name of the module that defines univs (which are
handled specially by the il code generator.)
library/*.m:
compiler/*.m:
browser/*.m:
mdbcomp/*.m:
profiler/*.m:
deep_profiler/*.m:
Conform to the above changes. Import the new modules where they
are needed; don't import std_util where it isn't needed.
Fix formatting in lots of modules. Delete duplicate module
imports.
tests/*:
Update the test suite to confrom to the above changes.
Estimated hours taken: 20
Branches: main
Fix several performance bugs that showed up when the compiler was invoked on
Douglas Auclair's training_cars example. Also fix some minor problems that
made it harder to find the information needed to localize those problems.
training_cars.m is hard to compile quickly because it is big in two dimensions:
it has lots of clauses, and each clause has big terms.
My laptop still tries to swap itself to death on the full version of
training_cars.m (it has only 512 Mb), but the compiler now works fine
on a version containing about 20% of its clauses, whereas previously
it couldn't compile it at all.
In most cases, the changes convert N^2 algorithms to NlogN algorithms.
They probably have higher constant factors and may yield small slowdowns
for small N, but this is probably not noticeable. Avoiding bad worst case
behavior is more important.
compiler/superhomogeneous.m:
Record the number of goals inserted in each goal being converted
to superhomogeneous form. If this exceeds a threshold, wrap a
from_ground_term scope around it.
Put the predicates into a more cohesive sequence.
compiler/field_access.m:
Work with the code in superhomogeneous to record the number of inserted
goals. Reorder the arguments of some performances to be consistent
with the predicates in superhomogeneous.m.
compiler/modes.m:
Use the from_ground_term scope to reverse the list of inserted
unifications if necessary. It is much more efficient to do this here
than to let it happen by sequences of delays and wakeups. That would
have quadratic complexity; this is linear.
This is what I originally introduced from_ground_term scopes for.
Then, the overhead was too high, because I added one scope per function
symbol. This version should be fine, since there is at most one scope
added per argument of an atom (clause head or call).
compiler/modes.m:
compiler/unique_modes.m:
When we are processing goals inside a from_ground_term scope, record
this fact.
compiler/mode_info.m:
Make it possible to record this fact.
compiler/modecheck_unify.m:
When we are inside a from_ground_term scope, don't try to update the
insts of vars on the right hand sides of construction unifications.
Since these variables came from expansion to superhomogeneous form,
those variables won't occur in any following code, so updating their
state is useless, and the algorithm we used to do so is linear in the
size of the inst. Since the size of an inst of a variable that results
from superhomogeneous expansion is itself on average proportional to
the size of the original term, this change turns a quadratic algorithm
into a linear one.
compiler/inst_match.m:
Use balanced trees instead of ordered lists to represents sets of
expansions, since these sets can be large.
Note an opportunity for further improvement.
compiler/inst_util.m:
Note another opportunity for further improvement.
compiler/instmap.m:
Rename several predicates to avoid ambiguities.
compiler/cse_detection.m:
We used to print statistics for the processing of each procedure
without saying which procedure it is for; fix this.
compiler/switch_detection.m:
Don't print progress messages for predicates with no procedures,
since they would be misleading.
compiler/higher_order.m:
Change an algorithm that was quadratic in the number of arms
for merging the information from the different arms of disjunctions
and switches to an NlogN algorithm.
Change the algorithm for merging the info from two branches
that quadratic in the number of variables per arm to an NlogN
algorithm.
Changed some type equivalences to notag types to aid robustness.
compiler/quantification.m:
Rename several predicates to avoid ambiguities.
The sets of variables in different arms of disjunctions and switches
tend to have relatively small intersections. Yet the algorithms we
used to compute the set of variables free in the disjunction or switch
included the variables from the already processed arms in the sets
being accumulated when processing later arms, leading to the quadratic
behavior. This diff changes the algorithm to process each arm
independently, and then use a more balanced algorithm to summarize
the result.
Specialize the predicates that compute sets of free vars in various
HLDS fragments to work either with ordinary_nonlocals or
code_gen_nonlocals without making the same decision repeatedly.
Move some code out of large predicates into predicates of their own.
compiler/Mercury.options:
Specify the compiler option that can exploit this specialization
to make the code run faster.
compiler/simplify.m:
Use a more efficient data structure for recording the parameters
of an invocation of simplification.
Change some predicate names and function symbol names to avoid
ambiguity.
compiler/common.m:
compiler/deforest.m:
compiler/deforest.m:
compiler/make_hlds_warn.m:
compiler/mercury_compile.m:
compiler/pd_util.m:
compiler/stack_opt.m:
compiler/term_constr_build.m:
Conform to the changes in simplify.m and/or instmap.m.
compiler/mercury_compile.m:
Fix a bug in progress messages for polymorphism.m.
compiler/equiv_type_hlds.m:
Most of the time, substitutions inside insts have no effect, because
very few insts include any reference to a types. Instead of the old
approach of building new insts and then throwing them away if they
are the same as the old ones, don't build new insts at all if the
old inst contains no types.
compiler/common.m:
Change some predicate names to make them clearer.
compiler/hlds_clauses.m:
Record the number of clauses so far, to allow a more informative
progress message to be printed.
compiler/add_clause.m:
Print this more informative progress message.
Conform to the changes in superhomogeneous.m.
compiler/code_gen.m:
Use the context of the predicate's first clause (which will be the
context of the first clause head) as the context of the predicate's
interface events. Unlike the context of the body goal, this won't
be affected by program transformations such as wrapping a
from_ground_term scope around some goals. It is better for users
anyway, since the old policy lead to contexts in the middle of
procedure bodies if the top level goal was a disjunction, switch or
if-then-else.
tests/debugger/*.exp:
Update the expected outputs to conform to the change to code_gen.m.
Estimated hours taken: 0.1
Branches: main
compiler/hlds_clauses.m:
compiler/hlds_pred.m:
Rename all the get access predicates in these modules that don't
already have put "get" in their name. (The names of the set access
predicates were OK already.)
compiler/*.m:
Conform to the above.
All this was done by this sed script:
s/clauses_info_varset/clauses_info_get_varset/
s/clauses_info_explicit_vartypes/clauses_info_get_explicit_vartypes/
s/clauses_info_vartypes/clauses_info_get_vartypes/
s/clauses_info_headvars/clauses_info_get_headvars/
s/clauses_info_clauses_rep/clauses_info_get_clauses_rep/
s/clauses_info_rtti_varmaps/clauses_info_get_rtti_varmaps/
s/pred_info_import_status/pred_info_get_import_status/
s/pred_info_arg_types/pred_info_get_arg_types/
s/pred_info_typevarset/pred_info_get_typevarset/
s/pred_info_tvar_kinds/pred_info_get_tvar_kinds/
s/pred_info_procedures/pred_info_get_procedures/
s/proc_info_context/proc_info_get_context/
s/proc_info_varset/proc_info_get_varset/
s/proc_info_vartypes/proc_info_get_vartypes/
s/proc_info_headvars/proc_info_get_headvars/
s/proc_info_inst_varset/proc_info_get_inst_varset/
s/proc_info_maybe_declared_argmodes/proc_info_get_maybe_declared_argmodes/
s/proc_info_argmodes/proc_info_get_argmodes/
s/proc_info_maybe_arglives/proc_info_get_maybe_arglives/
s/proc_info_declared_determinism/proc_info_get_declared_determinism/
s/proc_info_inferred_determinism/proc_info_get_inferred_determinism/
s/proc_info_goal/proc_info_get_goal/
s/proc_info_can_process/proc_info_get_can_process/
s/proc_info_rtti_varmaps/proc_info_get_rtti_varmaps/
s/proc_info_eval_method/proc_info_get_eval_method/
s/proc_info_is_address_taken/proc_info_get_is_address_taken/
s/proc_info_stack_slots/proc_info_get_stack_slots/
s/proc_info_liveness_info/proc_info_get_liveness_info/
s/proc_info_context/proc_info_get_context/
s/proc_info_context/proc_info_get_context/
s/proc_info_context/proc_info_get_context/
s/proc_info_context/proc_info_get_context/
s/proc_info_context/proc_info_get_context/
s/proc_info_context/proc_info_get_context/
s/proc_info_context/proc_info_get_context/
Estimated hours taken: 1.5
Branches: main
Move the stuff currently in hlds_pred.m that deals with clauses into a new
module, hlds_clauses.m.
Move the stuff currently in hlds_pred.m that deals with RTTI into a new
module, hlds_rtti.m.
Move the stuff currently in hlds_module.m that deals with predicate tables
into a new module, pred_table.m.
These changes make hlds_pred.m and hlds_module.m much more cohesive, but there
are no changes in algorithms.
compiler/hlds_clauses.m:
compiler/hlds_rtti.m:
compiler/pred_table.m:
New modules as described above. In some cases, fix mixleading or
ambiguous predicate names in the process, and convert a few predicates
to functions.
compiler/hlds_pred.m:
compiler/hlds_module.m:
Delete the stuff moved to other modules.
compiler/*.m:
In modules that need the functionality moved a new module, import
the new module. It is rare for all the new modules to be needed,
and many modules don't need any of the new modules at all. (For
example, of the 200+ modules that import hlds_module.m, only about 40
need pred_table.m.)
Conform to the few minor changes to e.g. predicate names.
compiler/notes/compiler_design.html:
Document the new modules.
Estimated hours taken: 6
Branches: main
compiler/*.m:
Convert almost all the compiler modules to use . instead of __ as
the module qualifier.
In some cases, change the names of predicates and types to make them
meaningful without the module qualifier. In particular, most of the
types that used to be referred to with an "mlds__" prefix have been
changed to have a "mlds_" prefix instead of changing the prefix to
"mlds.".
There are no algorithmic changes.
Estimated hours taken: 8
Branches: main
Improve the error messages generated for determinism errors involving committed
choice contexts. Previously, we printed a message to the effect that e.g.
a cc pred is called in context that requires all solutions, but we didn't say
*why* the context requires all solutions. We now keep track of all the goals
to the right that could fail, since it is these goals that may reject the first
solution of a committed choice goal.
The motivation for this diff was the fact that I found that locating the
failing goal can be very difficult if the conjunction to the right is
a couple of hundred lines long. This would have been a nontrivial problem,
since (a) unifications involving values of user-defined types are committed
choice goals, and (b) we can expect uses of user-defined types to increase.
compiler/det_analysis.m:
Keep track of goals to the right of the current goal that could fail,
and include them in the error representation if required.
compiler/det_report.m:
Include the list of failing goals to the right in the representations
of determinism errors involving committed committed choice goals.
Convert the last part of this module that wasn't using error_util
to use error_util. Make most parts of this module just construct
error message specifications; print those specifications (using
error_util) in only a few places.
compiler/hlds_out.m:
Add a function for use by the new code in det_report.m.
compiler/error_util.m:
Add a function for use by the new code in det_report.m.
compiler/error_util.m:
compiler/compiler_util.m:
Error_util is still changing reasonably often, and yet it is
included in lots of modules, most of which need only a few simple
non-parse-tree-related predicates from it (e.g. unexpected).
Move those predicates to a new module, compiler_util.m. This also
eliminates some undesirable dependencies from libs to parse_tree.
compiler/libs.m:
Include compiler_util.m.
compiler/notes/compiler_design.html:
Document compiler_util.m, and fix the documentation of some other
modules.
compiler/*.m:
Import compiler_util instead of or in addition to error_util.
To make this easier, consistently use . instead of __ for module
qualifying module names.
tests/invalid/det_errors_cc.{m,err_exp}:
Add this new test case to test the error messages for cc contexts.
tests/invalid/det_errors_deet.{m,err_exp}:
Add this new test case to test the error messages for unifications
inside function symbols.
tests/invalid/Mmakefile:
Add the new test cases.
tests/invalid/det_errors.err_exp:
tests/invalid/magicbox.err_exp:
Change the expected output to conform to the change in det_report.m,
which is now more consistent.
Estimated hours taken: 4
Branches: main
compiler/*.m:
Convert a bunch of modules to four-space indentation.
In the process, fix departures from our coding standards.
In some cases, do minor other cleanups such as changing argument orders
to be friendly to state variables.
There are no algorithmic changes.
Estimated hours taken: 10
Branches: main
This diff cleans up a bunch of modules. It has no algorithmic changes
other than in the formatting of error messages.
compiler/error_util.m:
Delete the obsolete predicate append_punctuation, since the suffix
format component can now do more, and do it more easily.
compiler/goal_util.m:
compiler/hlds_goal.m:
compiler/hlds_llds.m:
compiler/instmap.m:
compiler/const_prop.m:
Change the argument order of some the predicates exported by these
modules to make them easier to use with state variable syntax.
compiler/*.m:
Convert a bunch of these modules to four space indentation, and fix
departures from our coding style.
Conform to the changed argument order above.
Use suffixes instead of append_punctuation.
library/string.m:
Add string.foldl2.
tests/invalid/circ_*.err_exp:
tests/warnings/unused_args_*.exp:
Expect the updated error messages, which format sym_names consistently
the same way as other messages.
Estimated hours taken: 4
Branches: main
compiler/*.m:
Change a bunch of modules to import only one module per line, even
from the library.
compiler/mlds_to_il.m:
compiler/mlds_to_managed.m:
Convert these modules to our current coding style. Use state variables
where appropriate. Use predmode declarations where possible.
Estimated hours taken: 6
Branches: main
Fix the failures of the tabling/loopcheck_nondet test case at optimization
levels that enabled --local-constraint-propagation. The problem was that
constraint propagation reran determinism analysis. This changed the
determinism of an impure disjunction from multi to det. This prevented
backtracking into the second disjunct, and this in turn caused the
transformation not to detect the infinite loop in the program.
compiler/table_gen.m:
Attach the preserve_backtrack_info goal feature to all goals of
determinism failure we construct, since we don't construct any goals
we don't mean to execute.
Also add some missing variables to nonlocal sets in goal_infos.
compiler/constraint.m:
Preserve the context and all features of goals as far as possible.
Before this change, the constraint propagation transformation deleted
the hide_debug_event annotations from some goals, which could alter
what events an mdb user could see with --trace-optimized.
compiler/pd_debug.m:
Fix a bug in my previous cleanup that caused an infinite loop when
using --debug-pd.
Estimated hours taken: 3
Branches: main
compiler/deforest.m:
compiler/pd_cost.m:
compiler/pd_debug.m:
compiler/pd_info.m:
compiler/pd_term.m:
compiler/pd_util.m:
Bring these modules up to date with our current code style guidelines.
Use predmode declarations, field notation and state variable syntax
as appropriate. In some cases, change the order of predicates'
arguments to allow the use of state variables. Change the arity of
get predicates on pd_info from 3 to 2. In some cases, fix indentation
problems.
Separate the I/O state from the rest of the pd_info structure, to
enable the use of simple in/out modes for pd_info.
Estimated hours taken: 12
Branches: main
Remove almost all dependencies by the modules of parse_tree.m on the modules
of hlds.m. The only such dependencies remaining now are on type_util.m.
compiler/hlds_data.m:
compiler/prog_data.m:
Move the cons_id type from hlds_data to prog_data, since several parts
of the parse tree data structure depend on it (particularly insts).
Remove the need to import HLDS modules in prog_data.m by making the
cons_ids that refer to procedure ids refer to them via a new type
that contains shrouded pred_ids and proc_ids. Since pred_ids and
proc_ids are abstract types in hlds_data, add predicates to hlds_data
to shroud and unshroud them.
Also move some other types, e.g. mode_id and class_id, from hlds_data
to prog_data.
compiler/hlds_data.m:
compiler/prog_util.m:
Move predicates for manipulating cons_ids from hlds_data to prog_util.
compiler/inst.m:
compiler/prog_data.m:
Move the contents of inst.m to prog_data.m, since that is where it
belongs, and since doing so eliminates a circular dependency.
The separation doesn't serve any purpose any more, since we don't
need to import hlds_data.m anymore to get access to the cons_id type.
compiler/mode_util.m:
compiler/prog_mode.m:
compiler/parse_tree.m:
Move the predicates in mode_util that don't depend on the HLDS to a new
module prog_mode, which is part of parse_tree.m.
compiler/notes/compiler_design.m:
Mention prog_mode.m, and delete the mention of inst.m.
compiler/mercury_to_mercury.m:
compiler/hlds_out.m:
Move the predicates that depend on HLDS out of mercury_to_mercury.m
to hlds_out.m. Export from mercury_to_mercury.m the predicates needed
by the moved predicates.
compiler/hlds_out.m:
compiler/prog_out.m:
Move predicates for printing parts of the parse tree out of hlds_out.m
to prog_out.m, since mercury_to_mercury.m needs to use them.
compiler/purity.m:
compiler/prog_out.m:
Move predicates for printing purities from purity.m, which is part
of check_hlds.m, to prog_out.m, since mercury_to_mercury.m needs to use
them.
compiler/passes_aux.m:
compiler/prog_out.m:
Move some utility predicates (e.g. for printing progress messages) from
passes_aux.m to prog_out.m, since some predicates in submodules of
parse_tree.m need to use them.
compiler/foreign.m:
compiler/prog_data.m:
Move some types from foreign.m to prog_data.m to allow the elimination
of some dependencies on foreign.m from submodules of parse_tree.m.
compiler/*.m:
Conform to the changes above, mostly by updating lists of imported
modules and module qualifications. In some cases, also do some local
cleanups such as converting predicate declarations to predmode syntax
and fixing white space.
Estimated hours taken: 100
Branches: main
Make definitions of abstract types available when generating
code for importing modules. This is necessary for the .NET
back-end, and for `:- pragma export' on the C back-end.
compiler/prog_data.m:
compiler/modules.m:
compiler/make.dependencies.m:
compiler/recompilation.version.m:
Handle implementation sections in interface files.
There is a new pseudo-declaration `abstract_imported'
which is applied to items from the implementation
section of an interface file. `abstract_imported'
items may not be used in the error checking passes
for the curent module.
compiler/equiv_type_hlds.m:
compiler/notes/compiler_design.html:
New file.
Go over the HLDS expanding all types fully after
semantic checking has been run.
compiler/mercury_compile.m:
Add the new pass.
Don't write the `.opt' file if there are any errors.
compiler/instmap.m:
Add a predicate instmap_delta_map_foldl to apply
a procedure to all insts in an instmap.
compiler/equiv_type.m:
Export predicates for use by equiv_type_hlds.m
Reorder arguments so state variables and higher-order
programming can be used.
compiler/prog_data.m:
compiler/prog_io_pragma.m:
compiler/make_hlds.m:
compiler/mercury_to_mercury.m:
Handle `:- pragma foreign_type' as a form of type
declaration rather than a pragma.
compiler/hlds_data.m:
compiler/*.m:
Add a field to the type_info_cell_constructor cons_id
to identify the type_ctor, which is needed by
equiv_type_hlds.m.
compiler/module_qual.m:
Donn't allow items from the implementation section of
interface files to match items in the current module.
compiler/*.m:
tests/*/*.m:
Add missing imports which only became apparent with
the bug fixes above.
Remove unnecessary imports which only became apparent with
the bug fixes above.
tests/hard_coded/Mmakefile:
tests/hard_coded/export_test2.{m,exp}:
Test case.
tests/invalid/Mmakefile:
tests/invalid/missing_interface_import2.{m,err_exp}:
Test case.
Estimated hours taken: 4
Branches: main
This diff contains no changes in algorithms whatsoever.
browser/*.m:
compiler/*.m:
library/*.m:
Replace old-style lambdas with new-style lambdas or with named
procedures.
Estimated hours taken: 2
Branches: main
compiler/*.m:
Import only one compiler module per line. Sort the blocks of imports.
This makes it easier to merge in changes.
In a couple of places, remove unnecessary imports.
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: 50
Branches: main
Allow the debugger to print higher order values and typeinfos, mainly by
making the committed choice modes of the predicates in deconstruct.m to
deconstruct higher order values and typeinfos. (The non committed choice
versions will continue to return only placeholders.)
Having the debugger print typeinfos is occasionally useful but more often
it is just distracting. This change therefore adds a new debugger command,
"print_optionals", that toggles the printing of optional values. For now,
the only optional values are typeinfos.
NEWS:
Mention the new capability and the new predicates in the library.
Mention the predicates added previously that allow the caller to
specify how non-canonical terms should be handled, since the change
in their semantics that we anticipated when they were added has now
happened, and their semantics should now be more stable.
browser/browser_info.m:
Use the predicates in the deconstruct.m instead of std_util,
to make the choice of noncanonical term method handling explicit.
browser/browse.m:
When writing small terms using io__write_univ, explicitly use
the same noncanonical term handling method as browser_info.m
library/io.m:
Add predicates to retrieve the current input and output streams.
Add versions of io__write_univ that specify the stream and maybe
the method of handling noncanonical terms.
Add a mode to io__write_list that allows the closure that prints the
list elements to be cc_multi.
All of these are for the new functionality in the browser.
runtime/mercury_ml_expand_body.h:
In committed choice contexts, deconstruct closures as if they were
ordinary terms, with the function symbol being the name of the
predicate/function and the arguments being the terms stored in
the closure.
In committed choice contexts, deconstruct typeinfos as if they were
ordinary terms, with the function symbol being the name of the type
constructor and the arguments being the type constructor's arguments.
runtime/mercury_type_info.[ch]:
Add a new function, MR_collapse_ctor_equivalences, for use by
mercury_ml_expand_body.h.
Delete a redundant function comment.
library/deconstruct.m:
Document the changes in the behavior of the predicates defined in this
module as a result of the change to mercury_ml_expand_body.h.
runtime/mercury_ho_call.h:
runtime/mercury_stack_layout.h:
Add prefixes on structure field names that did not have them.
browser/dl.m:
Add prefixes where needed by the changes to mercury_ho_call.h.
runtime/mercury_layout_util.[ch]:
Remove the first argument of MR_materialize_closure_typeinfos, since
its correct value is always the same part of the second argument.
runtime/mercury_deep_copy_body.h:
Do not pass the first argument of MR_materialize_closure_typeinfos.
Add field name prefixes where necessary.
compiler/modules.m:
The mercury_builtin module is no longer part of the library.
compiler/pd_debug.m:
compiler/rl_analyze.m:
Minor updates to avoid trying to take the address of io__write_list,
since it now has more than one mode.
runtime/mercury_init.h:
runtime/mercury_wrapper.[ch]:
trace/mercury_trace_vars.[ch]:
Add a parameter to MR_trace_browse_all_on_level that specifies
whether we should print values of type type_info.
trace/mercury_trace_vars.c:
Do not ignore predicates and functions anymore.
runtime/mercury_stack_trace.c:
trace/mercury_trace.c:
trace/mercury_trace_declarative.c:
trace/mercury_trace_external.c:
Pass the new parameter of MR_trace_browse_all_on_level.
trace/mercury_trace_internal.c:
Implement the "print_optionals" command.
doc/user_guide.texi:
Document the "print_optionals" command.
tests/debugger/mdb_command_test.inp:
Test the documentation of "print_optionals".
tests/debugger/higher_order.{m,inp,exp,exp2}:
A new test case to exercise the ability to print higher order values.
Note that the format of the predicate names in the output should be
improved, but that is a separate change since doing it the right way
requires bootstrapping.
tests/debugger/Mmakefile:
Enable the new test case.
tests/debugger/nondet_stack.exp*:
Update the expected output to reflect the fact that nondet stack dumps,
being intended for debugging, include type_infos.
tests/debugger/tabled_read_decl.exp*:
Update the expected output to reflect the fact that for maximum
usefulness, the printing of I/O action atoms prints meaningful
type_infos.
tests/hard_coded/deconstruct_arg.*:
tests/hard_coded/write_reg1.*:
Expand these tests to check that we handle higher order values
correctly not just when canonicalizing but also in committed choice
modes.
Estimated hours taken: 90
Constraint propagation.
compiler/constraint.m:
Push constraints left and inwards as much as possible
within a goal. This module has been completely rewritten.
compiler/deforest.m:
Push constraints within a goal before processing it.
Make specialized versions for calls with constrained outputs.
Rerun determinism inference on specialized versions
when constraint propagation has been run, because the
determinism can change from nondet to semidet.
compiler/pd_util.m:
Add pd_util__propagate_constraints, which uses constraint.m
to push constraints within a goal.
Add some documentation for the exported predicates.
compiler/pd_term.m:
Add support for checking termination of the optimization process
for constraint propagation, which differs from deforestation
in that the conjunctions selected for optimization don't
necessarily have a call at both ends.
compiler/pd_debug.m:
Print some extra information when `--debug-pd' is enabled.
compiler/mercury_compile.m:
Check whether constraint propagation should be performed when
working out whether to run the deforestation pass.
compiler/make_hlds.m:
Add `no_inline' markers to the "recursive" procedures
introduced for builtins to stop constraint propagation
attempting to specialize such procedures.
compiler/hlds_pred.m:
Don't fill in the declared determinism field of the predicates
introduced by `hlds_pred__define_new_pred', so that rerunning
determinism inference will compute a more accurate determinism.
compiler/inlining.m:
Requantify before recomputing instmap_deltas, not after.
compiler/det_report.m:
Add predicates to disable warnings when rerunning
determinism analysis after constraint propagation.
compiler/options.m:
Add documentation for `--constraint-propagation'.
Add option `--local-constraint-propagation', which makes
deforestation call constraint.m to move constraints within
a goal, but does not create specialized versions of procedures
for which there are calls with constrained outputs.
compiler/handle_options.m:
`--constraint-propagation' implies `--local-constraint-propagation'.
compiler/notes/compiler_design.html:
Change the documentation to show that constraint.m is now part
of the deforestation pass.
NEWS:
Announce the new transformation.
doc/user_guide.texi:
Document the new options.
tests/hard_coded/Mmakefile:
tests/hard_coded/constraint.{m,exp}:
tests/hard_coded/constraint_order.{m,exp}:
Test cases.
Estimated hours taken: 4
Fix some old problems with HLDS dumps, including blank lines between goals
(using vi's paragraph commands to move between predicates now works),
unescaped characters in strings and chars in unifications, and extra dots
in type definitions.
compiler/hlds_out.m:
Make the above fixes. To fix the problem of blank lines between goals,
we reinterpret the meaning of the Follow arguments of several
predicates that print goals, which say what to print after the
goal, to include the newline to print after the goal. This avoids
lots of separate calls to io__write_string("\n").
Document the meanings of the arguments of many predicates.
compiler/prog_out.m:
Modify prog_out__write_sym_name to escape any special characters
(e.g. newlines) in the symbols written. (Strings, as cons_ids,
are printed as symbols.)
Add a new predicate for printing a symbol with single forward quotes
around it.
compiler/mercury_to_mercury:
When printing cons_id, quote strings.
compiler/constraint.m:
compiler/mode_errors.m:
compiler/pd_debug.m:
compiler/rl_dump.m:
compiler/saved_vars.m:
Conform to the new meaning of the Follow arguments in hlds_out.m.
Estimated hours taken: 20
These changes make `var' and `term' polymorphic. This allows us to make
variables and terms representing types of a different type to those
representing program terms and those representing insts.
These changes do not *fix* any existing problems (for instance
there was a messy conflation of program variables and inst variables,
and where necessary I've just called varset__init(InstVarSet) with
an XXX comment).
NEWS:
Mention the changes to the standard library.
library/term.m:
Make term, var and var_supply polymorphic.
Add new predicates:
term__generic_term/1
term__coerce/2
term__coerce_var/2
term__coerce_var_supply/2
library/varset.m:
Make varset polymorphic.
Add the new predicate:
varset__coerce/2
compiler/prog_data.m:
Introduce type equivalences for the different kinds of
vars, terms, and varsets that we use (tvar and tvarset
were already there but have been changed to use the
polymorphic var and term).
Also change the various kinds of items to use the appropriate
kinds of var/varset.
compiler/*.m:
Thousands of boring changes to make the compiler type correct
with the different types for type, program and inst vars and
varsets.
Estimated hours taken: 400
Deforestation.
This increases the code size of the compiler by ~80k when compiling
with --intermodule-optimization --deforestation.
The improvement from deforestation is not measurable for mmc -C make_hlds.m.
Compile time for make_hlds.m increased from 50.7 seconds to 52.2 seconds
when running deforestation.
compiler/simplify.m
compiler/common.m
Provide a nicer interface for simplifying a goal,
not an entire procedure.
Rework the interface to avoid manipulating lots of booleans.
Return an estimate of the improvement in cost from simplification.
Remove failing cases and disjuncts.
Add an option to optimize common structures even across calls.
Remove code to merge branched goals, since that is now
done by deforestation.
Fix a bug: the code to collect instmap_deltas for cases was not
including the switched-on variable in the instmap_delta,
which caused an abort in merge_instmap_delta if the switched
on variable was further instantiated in the switch.
This came up while compiling the compiler with --deforestation.
compiler/det_report.
Output duplicate call warnings even if --warn-simple-code is not set.
XXX fix the same problem with `:- pragma obsolete'.
compiler/code_aux.m
Update code_aux__cannot_loop to use termination information.
compiler/hlds_pred.m
compiler/dnf.m
Pass the type_info_varmap and typeclass_info_varmap
into hlds_pred__define_new_pred.
Restrict the variables of the new procedure onto the variables
of the goal.
Make sure all relevant type_infos are passed into the new
procedure if --typeinfo-liveness is set.
compiler/modes.m
compiler/unique_modes.m
compiler/mode_info.m
compiler/modecheck_unify.m
Put `how_to_check_goal' into the mode_info, rather
than passing it around.
Add a field to the `check_unique_modes' case which
controls whether unique modes is allowed to choose
a different procedure. For deforestation, this is
not allowed, since it could result in choosing a less
efficient procedure after generalisation.
compiler/options.m
New options:
--deforestation
--deforestation-depth-limit
Safety net for termination of the algorithm.
--deforestation-cost-factor
Fudge factor for working out whether deforestation
was worthwhile.
--deforestation-vars-threshold
Like --inline-vars-threshold.
Enable deforestation at -O3.
Removed an unnecessary mode for option_defaults_2, since it
resulted in a warning about disjuncts which cannot succeed.
compiler/handle_options.m
--no-reorder-conj implies --no-deforestation.
compiler/inlining.m
Separate code to rename goals into inlining__do_inline_call.
compiler/hlds_goal.m
Added predicates goal_list_nonlocals, goal_list_instmap_delta
and goal_list_determinism to approximate information about
conjunctions.
compiler/hlds_module.m
Added module_info_set_pred_proc_info to put an updated
pred_info and proc_info back into the module_info.
compiler/hlds_out.m
Exported hlds_out__write_instmap for debugging of deforestation.
Bracket module names on constructors where necessary.
compiler/mercury_compile.m
Call deforestation.
Use the new interface to simplify.m.
compiler/intermod.m
Put recursive predicates with a top-level branched goal
into `.opt' files.
goal_util.m
Added goal_calls_pred_id to work out if a predicate is
recursive before mode analysis.
Export goal_util__goals_goal_vars for use by deforestation.
Give a better message for a missing variable in a substitution.
compiler/instmap.m
Give a better message for inst_merge failing.
compiler/notes/compiler_design.m
Document the new modules.
library/varset.m
Add varset__select to project a varset's names and values
onto a set of variables.
doc/user_guide.texi
Document deforestation.
Remove a reference to a non-existent option, --no-specialize.
util/mdemangle.c
profiler/demangle.m
tests/misc_tests/mdemangle_test.{exp,inp}
Handle the `DeforestationIn__' predicate names introduced by
deforestation, similar to the `IntroducedFrom__' for lambda goals.
New files:
deforest.m Deforestation.
pd_cost.m Cost estimation.
pd_debug.m Debugging output.
pd_info.m State type and version control.
pd_term.m Termination checking.
pd_util.m Utility predicates