Estimated hours taken: 0.1
compiler/mode_debug.m:
compiler/typecheck.m
Use the globals stored in the module_info rather than in the
io__state to look up the --debug-modes or --debug-types options.
This saves memory by avoiding updating the io__state in the
mode_info or typecheck_info.
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: 0.75
library/*.m:
compiler/*.m:
Undo Zoltan's bogus update of all the copyright dates.
The dates in the copyright header should reflect the years
in which the file was modified (and no, changes to the
copyright header itself don't count as modifications).
Estimated hours taken: 20
Reorganisation of modules to do with the inst data type.
This is actually the first installment of the alias tracking mode
checker in disguise. A very good disguise. The rationale for
this reorganisation is to reduce coupling in the part of the mode
checker which is _not_ in this change (ie most of it).
Alias tracking requires a new kind of inst, alias(inst_key), where
an inst_key is a handle on some other sub-inst. With it goes a
data structure in which to store dereferenced insts and all the
operations which go with it. This code will go in the new module
inst.m so that it doesn't have to go in prog_data.m. (I briefly
considered putting it in instmap.m however this introduces some
bad coupling since instmap.m imports hlds_module.m. Putting it
in prog_data.m would cause hlds_*.m to depend on prog_data.m,
but we have designed things so that the dependencies go in the
other direction.)
The remainder of the reorganisation is a general cleanup: the
inst testing predicates (inst_is_*) have been moved out of
mode_util because they are not actually operations on modes at
all, and have been moved into inst_match. inst_match has then
been split because otherwise it would be 2000 lines long and
will get significantly bigger when aliasing is added. Roughly
speaking, any operations which create new insts from old ones
have been moved into a new module, inst_util while any operations
which test the values of insts remain in inst_match.
Also included are the removal of some NU-Prologisms since the
NU-Prolog version of the compiler is no longer supported. Two
changes here:
- Removal of some when declarations.
- A gross hack in inst_is_*_2, where two copies of
the same inst were passed into the predicate so that
one could be switched on. Thank NU-Prolog's lack of
common subexpression elimination.
compiler/inst.m:
New module which contains the data types inst, uniqueness,
pred_inst_info, bound_inst.
compiler/inst_util.m:
New module which contains predicates which perform mode
checking-like operations on insts.
Moved in:
abstractly_unify_inst, abstractly_unify_inst_functor,
inst_merge, make_mostly_uniq_inst (from inst_match.m)
compiler/inst_match.m:
Moved out:
inst_merge, make_mostly_uniq_inst,
abstractly_unify_inst, abstractly_unify_inst_functor
(to inst_util.m)
Moved in:
inst_is_*, inst_list_is_*, bound_inst_list_is_*
(from mode_util.m)
Now exported:
unique_matches_initial/2, unique_matches_final/2
inst_contains_instname/3, pred_inst_matches/3
(They are required by inst_util.m, and they are
useful in their own right.)
compiler/instmap.m:
instmap_delta_lookup_var/3 reincarnated as
instmap_delta_search_var/3. The reason for this change is
that previously, instmap_delta_lookup_var simply returned
`free' if the searched-for var did not occur in the
instmap_delta. This is somewhat non-obvious behaviour.
instmap_delta_search_var/3 fails in such a situation.
compiler/mode_util.m:
Moved out:
inst_is_*, inst_list_is_*, bound_inst_list_is_*
(to inst_match.m)
(These are not really operations on modes.)
compiler/modecheck_call.m:
Moved in modecheck_higher_order_func_call/5, from modecheck_unify.m
compiler/modecheck_unify.m:
Moved out modecheck_higher_order_func_call/5, to modecheck_call.m
where it should have been all along.
compiler/prog_data.m:
Moved out the types inst, uniqueness, pred_inst_info,
bound_inst (to inst.m).
compiler/common.m:
compiler/cse_detection.m:
compiler/fact_table.m:
compiler/higher_order.m:
compiler/hlds_data.m:
compiler/hlds_goal.m:
compiler/hlds_out.m:
compiler/intermod.m:
compiler/liveness.m:
compiler/llds.m:
compiler/make_hlds.m:
compiler/mercury_to_mercury.m:
compiler/mode_debug.m:
compiler/mode_errors.m:
compiler/mode_info.m:
compiler/modes.m:
compiler/module_qual.m:
compiler/polymorphism.m:
compiler/prog_io.m:
compiler/prog_io_util.m:
compiler/prog_util.m:
compiler/simplify.m:
compiler/switch_detection.m:
compiler/unify_proc.m:
compiler/unique_modes.m:
Miscellaneous minor changes to cope with the above changes.
compiler/notes/compiler_design.html:
Document the new modules.
Estimated hours taken: 14
Implemented a :- use_module directive. This is the same as
:- import_module, except all uses of the imported items
must be explicitly module qualified.
:- use_module is implemented by ensuring that unqualified versions
of items only get added to the HLDS symbol tables if they were imported
using import_module.
Indirectly imported items (from `.int2' files) and items declared in `.opt'
files are treated as if they were imported with use_module, since all uses
of them should be module qualified.
compiler/module_qual.m
Keep two sets of type, mode and inst ids, those which can
be used without qualifiers and those which can't.
Renamed some predicates which no longer have unique names since
'__' became a synonym for ':'.
Made mq_info_set_module_used check whether the current item is in
the interface, rather than relying on its caller to do the check.
Removed init_mq_info_module, since make_hlds.m now uses the
mq_info built during the module qualification pass.
compiler/prog_data.m
Added a pseudo-declaration `used', same as `imported' except uses of
the following items must be module qualified.
Added a type need_qualifier to describe whether uses of an item
need to be module qualified.
compiler/make_hlds.m
Keep with the import_status whether current item was imported
using a :- use_module directive.
Use the mq_info structure passed in instead of building a new one.
Ensure unqualified versions of constructors only get added to the
cons_table if they can be used without qualification.
compiler/hlds_module.m
Added an extra argument to predicate_table_insert of type
need_qualifier.
Only add predicates to the name and name-arity indices if they
can be used without qualifiers.
Changed the structure of the module-name-arity index, so that
lookups can be made without an arity, such as when type-checking
module qualified higher-order predicate constants. This does not
change the interface to the module_name_arity index.
Factored out some common code in predicate_table_insert which
applies to both predicates and functions.
compiler/hlds_pred.m
Removed the opt_decl import_status. It isn't needed any more
since all uses of items declared in .opt files must now be
module qualified.
Added some documentation about when the clauses_info is valid.
compiler/intermod.m
Ensure that predicate and function calls in the `.opt' file are
module qualified. Use use_module instead of import_module in
`.opt' files.
compiler/modules.m
Handle use_module directives.
Report a warning if both use_module and import_module declarations
exist for the same module.
compiler/mercury_compile.m
Collect inter-module optimization information before module
qualification, since it can't cause conflicts any more. This means
that the mq_info structure built in module_qual.m can be reused in
make_hlds.m, instead of building a new one.
compiler/prog_out.m
Add a predicate prog_out__write_module_list, which was moved
here from module_qual.m.
compiler/typecheck.m
Removed code to check that predicates declared in `.opt' files
were being used appropriately, since this is now handled by
use_module.
compiler/*.m
Added missing imports, mostly for prog_data and term.
NEWS
compiler/notes/todo.html
doc/reference_manual.texi
Document `:- use_module'.
tests/valid/intermod_lambda_test.m
tests/valid/intermod_lambda_test2.m
tests/invalid/errors.m
tests/invalid/errors2.m
Test cases.
Estimated hours taken: 3
Enable --warn-interface-imports by default. This was turned off while
list and term were defined in mercury_builtin.m, since it caused many
warnings.
Fix all the unused interface imports that have been added since then.
compiler/options.m:
Enable --warn-interface-imports by default.
compiler/module_qual.m:
Fix formatting inconsistencies with module names in warning
messages. (".m" was not appended to module names if there was
only one module).
compiler/*.m:
library/*.m:
tests/invalid/type_loop.m:
tests/warnings/*.m:
Remove usused interface imports, or move them into
implementation (mostly bool, list and std_util).
Estimated hours taken: 5
Remove support for term_to_type and type_to_term implemented as special
preds. Remove support for one-cell and one-or-two-cell type_infos (now
shared-one-or-two-cell type_infos). Move definitions that were in
mercury_builtin.m back to where they belong.
This code has been removed because it is no longer used, and was no
longer being maintained but was still quite complex.
compiler/globals.m:
compiler/handle_options.m:
compiler/mercury_compile.m:
compiler/options.m:
Remove one_cell and one_or_two_cell from type_info methods.
compiler/polymorphism.m:
Remove term_to_type and type_to_term support.
Remove one_cell and one_or_two_cell from type_info methods.
Fix documentation to reflect the new situation.
compiler/special_pred.m:
compiler/unify_proc.m:
Remove term_to_type and type_to_term support.
library/list.m:
Put the definition of `list' back into list.m
library/mercury_builtin.m:
Take the definitions of `list', `term', `var', `var__supply',
etc, out of this module.
Remove type_to_term, term_to_type, det_term_to_type,
term__init_var_supply, term__create_var, term__var_to_int
and term__context_init.
Remove references to USE_TYPE_TO_TERM and #ifdefs around
SHARED_ONE_OR_TWO_CELL_TYPE_INFO.
library/std_util.m:
Remove references ONE_OR_TWO_CELL_TYPE_INFO, and code that
handles one-cell typeinfo comparisons.
library/term.m:
Add type_to_term, term_to_type, det_term_to_type,
term__init_var_supply, term__create_var, term__var_to_int
and term__context_init back to term.m.
Add new implementation of type_to_term/2.
library/uniq_array.m:
Fix a typo in a comment - term_to_type/3 instead of term_to_type/2.
runtime/call.mod:
Remove special case code for unify, compare, index for
one-cell typeinfos.
Remove code for type_to_term/2.
runtime/type_info.h:
Remove references to ONE_CELL_TYPE_INFO or ONE_OR_TWO_CELL_TYPE_INFO.
Make sure only SHARED_ONE_OR_TWO_CELL_TYPE_INFO.
Remove references to USE_TYPE_TO_TERM.
compiler/base_type_layout.m:
compiler/bytecode_gen.m:
compiler/code_util.m:
compiler/delay_slot.m:
compiler/det_util.m:
compiler/fact_table.m:
compiler/hlds_data.m:
compiler/hlds_goal.m:
compiler/mode_debug.m:
compiler/tree.m:
library/bag.m:
library/queue.m:
Import module `list' or `term' (or both).
Estimated hours taken: 1.5
mercury_to_mercury:
Add predicates for printing out insts in a structured form.
The resulting printed insts are not fully syntactically valid,
but they are much better for debugging than the output of the
existing predicates.
mode_info:
Add an extra field to the mode_info structure. This field, which
is set and used only when --debug-modes was given, holds the binding
of each variable at the last mode checkpoint.
mode_debug:
At each mode checkpoint, print full insts only for the variables
whose inst has changed since the last checkpoint. Print these insts
using the new predicates in mercury_to_mercury.
This change also introduces tabs in many places in the code
where the original code used groups of eight spaces.
Estimated hours taken: 10
This change fixes two bugs, in quantification and liveness. I made the changes
to the other files while trying to find them; they ought to be useful in
trying to find similar bugs in the future.
The compiler now bootstraps with agressive inlining enabled.
quantification:
Fix a bug that switched two different accumulators of the same type
when processing pragma_c_codes.
liveness:
Fix a bug that could cause a variable to end up in both the post-death
and post-birth set of the same goal.
options:
Reenable inlining.
hlds_out, mercury_to_mercury:
If -D v is given, include the number of each variable at the end of
its name (e.g. Varname_20).
The predicates involved (a few from mercury_to_mercury and many from
hlds_out) now have an extra argument that says whether this should be
done or not. (It is not done when printing clauses e.g. for .opt
files.)
The bug in quantification was causing the improper substitution of
one variable for another, but both had the same name; such bugs would
be very difficult to find without this change.
constraint, det_report, intermod, make_hlds, mercury_to_c, mode_debug,
mode_errors, module_qual, typecheck:
Call predicates in hlds_out or mercury_to_mercury with the extra
argument.
saved_vars:
Thread the io__state through this module to allow debugging.
mercury_compile:
Call saved_vars via its new interface.
Fix an inadvertent use of an out-of-date ModuleInfo.
goal_util, hlds_goal:
Minor formatting cleanup.
code_gen:
Clean up the import sequence.
Estimated hours taken: 20
Mode analyser reorganisation.
compiler/mode_util.m:
Removed: instmap_init/1, apply_instmap_delta/3, instmap_lookup_var/3,
instmapping_lookup_var/3, instmap_restrict/3, map_restrict/3 (all
moved to instmap.m).
compiler/hlds_goal.m:
Removed the declarations of instmap_delta, instmap and instmapping.
compiler/mode_errors.m:
Added report_mode_errors/2 (was modecheck_report_errors, from
modes.m).
compiler/modes.m:
Predicates now exported:
modecheck_goal/4
modecheck_goal_expr/5 (previously named modecheck_goal_2/5)
handle_extra_goals/8
mode_context_to_unify_context/3
Moved to mode_errors.m:
modecheck_report_errors/2
Moved to instmap.m:
compute_instmap_delta/4
instmap_merge/3
instmap_lookup_vars (was instmap_lookup_arg_list/3)
compute_instmap_delta/4
Moved to mode_debug.m:
Type port/0
mode_checkpoint/4
Moved to modecheck_call.m:
modecheck_call_pred/7
modecheck_higher_order_call/10
modecheck_higher_order_pred_call/4
modecheck_higher_order_func_call/7
Moved to modecheck_unify.m:
modecheck_unification/9
categorize_unify_var_var/12
categorize_unify_var_functor/11
categorize_unify_var_lambda/9
Moved to mode_info.m:
mode_info_error/4
mode_info_add_error/3
compiler/code_gen.pp, compiler/code_info.m, compiler/constraint.m,
compiler/cse_detection.m, compiler/det_analysis.m, compiler/det_util.m,
compiler/dnf.m, compiler/goal_util.m, compiler/higher_order.m,
compiler/hlds_out.m, compiler/hlds_pred.m, compiler/live_vars.m,
compiler/liveness.m, compiler/lookup_switch.m, compiler/polymorphism.m,
compiler/simplify.m, compiler/store_alloc.m, compiler/switch_detection.m,
compiler/transform.m, compiler/unused_args.m:
Imported instmap.m
New files:
compiler/instmap.m:
Handle operations associated with instmaps.
compiler/modecheck_unify.m:
Handle mode checking of unifications.
compiler/modecheck_call.m:
Handle mode checking of calls
compiler/mode_debug.m:
Code to trace the actions of the mode checker.