Estimated hours taken: 0.5
compiler/polymorphism.m:
Fix a bug in my previous bug fix: it was calling
map__apply_to_list to apply the type-info variable map to a
list of type variables, but not every type variable has a type
info.
Estimated hours taken: 1
compiler/simplify.m
compiler/higher_order.m
Fix some places where goal_info fields were not being filled
in correctly.
compiler/hlds_goal.m
Added goal_info_init/4 which takes the nonlocals, instmap_delta
and determinism of the goal. All goal_info_inits after determinism
analysis should probably use this version.
compiler/common.m
compiler/polymorphism.m
Use goal_info_init/4.
tests/general/prune_switch.m
Test case.
Estimated hours taken: 0.5
compiler/polymorphism.m:
Fix a bug: it was over-approximating the non-locals, which
caused the generated HLDS to be mode-incorrect, because it
could contain a construction for a type_info variable which was
(spuriously) non-local to the condition of the if-then-else in
which it occurred. That's not legal because you can't bind
non-local variables in the condition of an if-then-else.
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: 5
Allow the names of higher order types to be generated.
LIMITATIONS:
Document limitations introduced by this change.
compiler/polymorphism.m:
Map higher order predicates to pred/0 and functions to func/0.
library/mercury_builtin.m:
Move base_type_* for pred/0 out of library (into runtime).
library/std_util.m:
Check for pred/0 and func/0 when comparing type infos.
Create different ctor_infos for higher order preds, decode them
correctly for args and functors when needed.
Print functions nicely (eg func(foo) = bar).
Fix ML_create_type_info so it works correctly with higher order
types.
runtime/type_info.h:
Define macros to deal with new representation of higher order
ctor_infos.
runtime/deep_copy.c:
Fix make_type_info so it works correctly with higher order
types.
runtime/Mmakefile:
runtime/type_info.mod:
Add definitions for pred/0 and func/0 in runtime, they are
needed by deep copy.
tests/hard_coded/Mmake:
tests/hard_coded/higher_order_type_manip.exp:
tests/hard_coded/higher_order_type_manip.m:
Test case for this change.
Estimated hours taken: 1
compiler/polymorphism.m:
Fix a bug in polymorphism__fixup_preds: in the case of a predicate
with no modes, it wasn't doing the recursive call to fix up
the remaining predicates.
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: 10
Fix a bug in compilation in accurate GC grades.
compiler/polymorphism.m:
Add any introduced typeinfo variables to the typevar map.
Without this unbound type variables won't not occur in the
typevar map, and the liveness calculations won't be able to
make sure the typeinfos for the unbound type variables are
kept live when they should be. (that is, the map lookups would
fail looking in the typevar map).
Estimated hours taken: 3
Fix a bug in inlining of polymorphic pragma c_code procedures.
The bug was that if the actual argument type has a specific type
of say `float', then the C variable for the corresponding formal
parameter will be declared to have type `Float', whereas without
inlining the argument type would have been polymorphic and so
the C variable would have been declared to have type `Word'.
Hence we need to keep track of the original argument types,
before any inlining or specialization has occurred, and use
these original argument types to determine how to declare
the C variables, rather than using the actual argument types
for this particular specialization.
compiler/hlds_goal.m:
Add a new field to pragma_c_code goals, holding the
original argument types (before any inlining or specialization)
of the pragma_c_code procedure.
compiler/make_hlds.m:
Initialize this field with the declared argument types for
the pragma c_code procedure.
compiler/polymorphism.m:
Update this field to account for the inserted type_info variables.
compiler/code_gen.m:
Pass this field to pragma_c_gen.m.
compiler/pragma_c_gen.m:
Use the original argument types field for the pragma variable
declarations, rather than looking up the actual types of the
arguments.
compiler/*.m:
Trivial changes to handle new field.
compiler/live_vars.m:
Comment out some code to avoid a warning about `fail'
in the condition of an if-then-else.
Estimated hours taken: 1.5
Fix the (long-time) temporary hack to generate NULL pointers as
type_infos for unbound type variables.
compiler/polymorphism.m:
- Generate references to void directly, rather than generating
NULL pointers.
library/std_util.m:
- Remove special case code in mercury_compare_type_info, and
create_type_info to handle unbound type variables represented
as NULLs. Since they are now represented as a normal
type_info, there doesn't need to be any special code.
Estimated hours taken: 3
Replace calls to map__set with calls to either map__det_insert or
map__det_update. In some cases this required a small amount of code
reorganization.
Estimated hours taken: 7
Making the types pred_id and proc_id (almost) abstract.
compiler/code_util.m:
Changed the type of several predicates:
code_util__make_uni_label/4 (arg 3 was int, now proc_id)
code_util__inline_builtin/4 (arg 3 was proc_id, now int)
Added predicate code_util__translate_builtin_2/6.
compiler/hlds_module.m:
Moved invalid_pred_id/1 to hlds_pred.m
compiler/hlds_pred.m:
Types pred_id/0 and proc_id are now abstract.
Added predicates:
hlds_pred__initial_pred_id/1, hlds_pred__initial_proc_id/1,
hlds_pred__next_pred_id/2, hlds_pred__next_proc_id/2,
pred_id_to_int/2, proc_id_to_int/2,
hlds_pred__in_in_unification_proc_id/1
Moved predicate invalid_pred_id/1 (from hlds_module.m).
compiler/*.m:
Miscellaneous minor changes to cast pred/proc_ids to ints
where appropriate.
Estimated hours taken: 0.25
compiler/polymorphism.m:
Add a reminder to change run the #defines in runtime/type_info.h
if the documentation here is changed, and vice versa.
Also a few other minor improvements to the documentation.
Estimated hours taken: 8
Enable the code to treat `__' as an alternative syntax for module
qualification, after fixing various places in the compiler where
we use `__' in ways that are incompatible with this.
compiler/prog_io.m:
compiler/prog_io_goal.m:
Uncomment the code to handle `__' as module qualification.
compiler/intermod.m:
compiler/hlds_module.m:
compiler/modecheck_unify.m:
Fix bugs in the handling of module qualified higher-order terms.
compiler/*.m:
s/hlds__/hlds_/g
compiler/passes_aux.m:
s/process__/process_/g
compiler/pragma_c_gen.m:
compiler/code_gen.m:
s/code_gen__/pragma_c_gen__/ for the predicates defined in
pragma_c_gen.m (this ought to have been done when the code
was first moved from code_gen.m to pragma_c_gen.m).
compiler/llds.m:
s/llds__proc_id/llds_proc_id/g
The reason for this was to avoid ambiguity between proc_id
in hlds_pred.m and llds__proc_id in llds.m.
compiler/quantification.m:
compiler/make_hlds.m:
compiler/mercury_to_c.m:
s/goal_vars/quantification__goal_vars/g
The reason for this was to avoid ambiguity between goal_vars
in quantification.m and goal_util__goal_vars in goal_util.m.
compiler/dupelim.m:
compiler/optimize.m:
s/dupelim__main/dupelim_main/g
The reason for this change is that a program can only
have one main/2 predicate.
compiler/prog_io_dcg.m:
Remove the old "temporary hack" to strip off and ignore
io__gc_call/1, since the new handling of `__' broke it.
It was only useful for optimizing NU-Prolog performance,
which we don't care about anymore.
compiler/mercury_compile.m:
compiler/modules.m:
compiler/intermod.m:
compiler/prog_io.m:
Remove occurrences of io__gc_call.
compiler/llds_out.m:
compiler/base_type_info.m:
Ensure that we properly handle the special hacks in mercury_builtin
where predicates from other modules (e.g. term__context_init)
are defined in mercury_builtin because they are needed for
type_to_term and term_to_type. llds_out.m: don't put
`mercury_builtin' in the mangled names for those symbols.
base_type_info.m: handle types whose status is "imported"
in their own module.
Estimated hours taken: 0.5
Update and improve documentation of polymorphism.
compiler/polymorphism.m:
- Update documentation and examples to talk about
base_type_functors
- Add some missing documentation of type names
- Remove some incorrect references to base_type_layouts in
one-cell type_infos.
- Add information about runtime initialization of shared
base_type_infos.
- Give subsections of the documentation headings.
Estimated hours taken: 0.3
Added code to store type names in the base type info.
By storing type names in the base type info we can now give more
helpfull debugging messages. i.e. we can actualy say what type the
error etc... happend in.
compiler/base_type_info.m :
Added code to place the type name at the end of base type
info's.
compiler/polymorphism.m :
Documented change to base type info structure.
Estimated hours taken: 15
Module qualification of constructors.
compiler/modes.m
compiler/unique_modes.m
compiler/modecheck_unify.m
compiler/modecheck_call.m
Enable propagate_type_info_into_modes.
Use type information to module qualify cons_ids.
compiler/mode_util.m
Use propagate_type_information_into_modes to module qualify cons_ids
in bound insts.
typed_ground/2 and free/1 insts are not yet generated, since they
are not yet used anywhere.
Avoid expanding insts when propagating type information, since
that is not yet useful.
I still need to fix the handling of
inst_matches_{initial, final, binding}(
ground(_, _), bound(_, [all_functors_in_the_type]))
compiler/typecheck.m
Don't assume a module qualified cons_id is a function call
or higher-order pred constant.
compiler/modes.m
compiler/unique_modes.m
compiler/modecheck_unify.m
compiler/instmap.m
compiler/inst_match.m
Remove some unnecessary conversion between cons_ids and consts.
compiler/typecheck.m
compiler/mode_errors.m
Strip builtin qualifiers from cons_ids.
compiler/mercury_to_mercury.m
Output module qualified cons_ids.
compiler/prog_io.m
compiler/prog_io_util.m
Module qualify constructors in type definitions.
Parse qualified cons_ids in bound insts.
compiler/hlds_data.m
Remove cons_id_to_const/3, since it doesn't make much sense any more.
Add cons_id_arity/2 and cons_id_and_args_to_term/3.
compiler/make_hlds.m
Add both qualified and unqualified versions of each cons_id to
the cons_table.
compiler/det_util.m
Handle module qualified cons_ids in det_util__interpret_unify.
compiler/code_util.m
Remove some dead code in code_util__cons_id_to_tag to do with
tags for higher-order terms. Don't assume module qualified
cons_ids are higher-order pred constants.
compiler/polymorphism.m
Module qualify type_info cons_ids.
Estimated hours taken: 25
Implement shared-one-or-two-cell type_infos for grades without static
code addresses. This allows us to use functor, arg, expand, deep_copy,
etc without changes in all grades.
compiler/base_type_info.m:
- If static code addresses are not available, eliminate the
special procedures, and output the constant 0 instead of a
code address.
- We now keep the `eliminated' predicates in the base_gen_info
structure, so that dead_proc_elim knows they are referenced
from the base_type_info.
compiler/dead_proc_elim.m:
- For the moment, don't eliminate any special preds - the
analysis to so this safely is quite complex so we take a
conservative approach - base_type_infos are always needed, and
hence the special preds are always referenced.
- Also, fix a bug in the handling of eliminated procs - if they
are eliminated elsewhere, any eliminated here should be added
find the total number. (this bug doesn't occur presently due
to the conservative approach we now make).
compiler/globals.m:
compiler/handle_options.m:
- Change the handling of type_info_method option - we no longer
need static addresses to do shared-one-or-two-cell.
- Add predicate globals__have_static_code_addresses/2 to check
for this feature.
- Make shared-one-or-two-cell the default type_info method.
compiler/llds_out.m:
- Output initialisation code for the base_type_infos in this
module as part of the module initialisation.
- Don't declare base_type_infos as const if the don't have
static code addresses, because we'll have to initialise them
at runtime.
- Don't make decls of base_type_infos `const' if we don't have
static code addresses.
compiler/polymorphism.m:
- Update examples of transformed code to include
base_type_layouts, clarify difference between shared and
non-shared one-or-two-cell.
library/mercury_builtin.m:
- Conditionally reference entry labels of builtin special preds,
using `MR_MAYBE_STATIC_CODE()' macro.
- Replace `const' in handwritten base_type_info structs with
`MR_STATIC_CODE_CONST'.
- Add initialisation code to fill in the code addresses.
runtime/type_info.h:
- Conditionally define MR_STATIC_CODE_ADDRESSES.
- Define macros to initialise base_type_infos:
mercury_init_builtin_base_type_info, and
mercury_init_base_type_info
- Define `MR_STATIC_CODE_CONST' (which is `const' if static code
addresses are available, and blank otherwise).
_ Define MR_MAYBE_STATIC_CODE(X) which is X if static code
addresses are available, and 0 otherwise.
- Make shared-one-or-two-cell the default setting, don't require
static code addresses for one-or-two-cell.
- Create versions of make_typelayout_for_all_tags for 0, 1, 2
and 3 tagbits, so as to save space, add error message if we
try to use more than 3 tagbits.
- Improve layout and commenting, break file up into sections.
- Fix typos.
Estimated hours taken: 4
Confirm, and fix an XXX in polymorphism.
univ_to_type couldn't check the arguments of higher order
types correctly, so one could circumvent the run-time type
check.
compiler/polymorphism.m:
compiler/base_type_layout.m:
Add the real arity into type_info (and pseudo-type-infos) for
higher order preds.
Also, document recent changes to the structure of type_infos,
fix a typo, and remove the XXX.
library/std_util.m:
Fix the implementation of mercury_compare_type_info so that the
arity and argument type_infos of higher-order types are checked.
runtime/deep_copy.c:
Update offset of the arguments of higher-order type_infos
as they have been shifted along one.
runtime/type_info.h:
Add new #defines for the offset of the arity and arguments for
higher order types, to avoid magic numbers in future.
tests/hard_coded/Mmake:
tests/hard_coded/.cvsignore:
tests/hard_coded/ho_univ_to_type.m:
tests/hard_coded/ho_univ_to_type.exp:
Test case for conversions - tries to do an illegal conversion.
The runtime type-check now detects this.
Estimated hours taken: 12
The first half of a change to introduce nondet pragma C goals.
This half makes the necessary modifications to the HLDS; the next
half will modify the LLDS and emit it.
prog_data:
Add a new pragma type for nondet pragma c_codes; these specify
the names of a a bunch of variables to save across backtracking,
and a list of label names to which backtracking may take place.
Rename is_recursive to may_call_mercury, since this is a more
direct expression of the meaning.
prog_io:
Move much of the functionality to new files.
prog_io_dcg, prog_io_goal, prog_io_pragma, prog_io_util:
New files, made up of pieces of prog_io.
hlds_goal:
Add an extra argument to the pragma_c_goals to store the extra
information present in the new type of pragma c_codes.
det_analysis:
Take into account that the new type of pragma_c goal may have
more than one solution.
goal_util:
Rename variables in the new field of pragma_cs.
live_vars:
Allocate stack slots to the saved variables in the new type of pragma_c
goals.
make_hlds:
Handle the new type of pragma_c goals.
mercury_output, hlds_out:
Output the new type of pragma_c goals.
garbage_out:
Rename type "det" to "frame_type".
others:
Ignore one more arg of pragma_c goals or import prog_io_util.
Estimated hours taken: 32
Implement deep_copy.
Implement solutions for asm_fast, using deep_copy.
compiler/base_type_layout.m:
List all uses of handwritten base_type_layouts.
For higher-order types, construct type_infos without
arity, but with argument types.
compiler/polymorphism.m:
For higher-order types, construct type_infos with argument types.
library/std_util.m:
Move definition of UNIV_OFFSET_FOR_TYPEINFO and UNIV_OFFSET_FOR_DATA
to runtime.
runtime/Mmake:
Add deep_copy.h and deep_copy.c to runtime library.
runtime/memory.c:
runtime/memory.h:
runtime/wrapper.mod:
Add, and initialize solutions_heap_zone, and solutions_heap_pointer.
runtime/solutions.mod:
Implement solutions in non-conservative gc grades, using deep_copy,
and a copy twice algorithm.
runtime/type_info.h:
Add univ definitions, add offset for type_layout simple args.
Estimated hours taken: 2
hlds_goal:
Change the definition of is_builtin to use less space.
bytecode_gen, code_aux, code_gen, code_util, dependency_graph, follow_code,
higher_order, inlining, live_vars, make_hlds, modecheck_unify, modes,
polymorphism, stratify, unused_args:
Fixes to accommodate the change to is_builtin.
Estimated hours taken: 0.1
polymorphism:
Add a unique identifying number to the names of the variables
holding typeinfos. This makes HLDS dumps easier to read.
Estimated hours taken: 0.75
Fix a bug that caused the test case hard_coded/curry.m to fail when
compiling with -O2, because of a link error.
compiler/polymorphism.m:
Refer to unqualified pred/0 rather than mercury_builtin:pred/0
since it is the former that is defined in mercury_builtin,
and other builtins are treated this way.
Estimated hours taken: 2.5
Switch from using a stack of store_maps in the code_info to govern what
goes where at the end of each branched structure to using the store map
fields of the goal expressions of those structures.
Fix variable names where they resembled the wrong kind of map(var, lval).
code_info:
Remove the operations on stacks of store maps.
Modify the generate_forced_saves and remake_with_store_map operations
to take a store_map parameter.
When making variables magically live, pick random unused variables
to hold them, since we can no longer use the guidance of the top
store map stack entry. This may lead to the generation of some
excess move instructions at non-reachable points in the code;
this will be fixed later.
code_gen:
Remove the store map push and pop invocations.
Modify the generate_forced_goal operation to take a store_map parameter.
code_exprn:
Export a predicate for use by code_info.
middle_rec, disj_gen, ite_gen, switch_gen,
dense_switch, lookup_switch, string_switch, tag_switch:
Pass the store map around to get it to invocations of the primitives
in code_gen and code_info that now need it.
goal_util:
Name apart the new follow_vars field in hlds__goal_infos.
(This should have been in the change that introduced that field.)
common, constraint, cse_detection, det_analysis, dnf, excess, follow_code,
intermod, lambda, lco, liveness, make_hlds, mode_util, modes, polymorphism,
quantification, simplify, switch_detection, typecheck, unique_modes,
unused_args:
Fix variable names.
follow_vars, store_alloc:
Add comments.
Estimated hours taken: 2
Fix a `map__lookup failed' error in which occurs
in polymorphism.m for third-order functions.
compiler/polymorphism.m:
In polymorphism__make_var, when creating a type_info
variable, check for higher-order types such as
`func(...) = ...' and handle them specially, rather
than attempting to look up the (bogus) type '='/2.
Estimated hours taken: 12
The main changes are
1 associating a name with the arguments of constructors
2 removing the follow_vars field from calls, higher-order calls
and complicated unifications, since they are not used
3 merging the follow_vars and store_alloc passes, since they logically
belong together
4 add a new module, lco, for detecting opportunities for last
call optimization modulo constructor application; it won't
actually apply the optimization until the mode system becomes
expressive enough to handle it (this module detects 529 opportunities
in the compiler and library)
5 make "-O3 --optimize-value-number" do the right thing; previously,
it used not to apply value numbering because the vnrepeat option
defaulted to zero
6 don't refer to .err2 files anymore; use .err instead.
prog_data:
The list associated with each value of type "constructor" now
contains not only the types of the arguments but their names as well.
equiv_type, hlds_data, hlds_out, make_hlds, mercury_to_{goedel,mercury},
mode_util, module_qual, shapes, type_util, unify_proc:
Modify the traversal of type definitions to account for the names
in the lists inside values of type "constructor".
prog_io:
Parse argument names. An unrelated change is that we now
check whether :- pred declarations give modes to some of their
arguments but not to all, in which case we return an error.
hlds_goal:
Remove the follow_vars field from calls, higher-order calls
and complicated unifications.
*.m:
Handle the new arities of calls, higher order calls and complicated
unifications.
mercury_compile:
Don't call follow_vars directly anymore, but do call lco if its option
is set. Also flush the main output before a call to maybe_report_stats
to prevent ugly output.
store_alloc:
Call follow_vars directly.
follow_vars:
Expose the initialization and traversal predicates for store_alloc.
lco:
Find opportunities for last call optimization modulo constructor
application.
passes_aux:
Add a HLDS traversal type for lco.
optimize:
Consider the vnrepeat count to be zero unless value numbering is on.
options:
Set the default value of vnrepeat to 1.
modules:
Don't refer to .err2 files.
Estimated hours taken: 1
Since NU-Prolog hasn't been capable of executing the compiler for a long time
now, I have removed the .pp files and replaced them with .m files.
code_gen, mercury_compile, optimize:
Remove NU-Prolog specific code.
Mmake:
Don't refer to the .pp files.
dnf:
Add the capability of transforming all procedures regardless of
markers. This will be useful when generating idiomatic Prolog code.
mercury_to_goedel, polymorphism:
Fix comments.
Estimated hours taken: 2
llds_out:
Fix the printing of comments by adding a newline at the end.
The bug only occurred when --auto-comments was given.
middle_rec:
Under certain rare circumstances, middle_rec could generate code
that had two copies of some labels. This fix prevents that problem.
polymorphism:
Put back part of Simon's last change that I accidentally omitted
earlier. The symptom fixed by this change is an internal error
in dumping HLDS after the polymorphism stage due to a qualified
function symbol the dumping code can't handle.
Estimated hours taken: 15
polymorphism.m:
Depending on option settings, generate code that uses the new
one-or-two-cell representation of typeinfos.
base_type_info.m:
Generate the base_type_info structures used by the new representation.
dead_proc_elim.m:
Handle base_gen_infos (a HLDS-level representation of base_type_info
structures) the same way as predicates. They may be exported (if their
type is), so if they point to a procedure that procedure must not be
eliminated, but base_gen_infos that are not exported or otherwise
needed should themselves be eliminated.
inlining.m:
Accommodate the changed data structure used by dead_proc_elim.m.
make_tags.m:
Avoid applying the no_tag optimization to the functor base_type_info/1
as well as type_info/1 (since both lie about their arity).
mercury_compile.pp:
Call base_type_info.m to generate first base_gen_infos and then
base_type_infos.
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.
Estimated hours taken: 3
Some fixes Fergus suggested for my previous sets of changes.
Give error messages for circular equivalence types.
compiler/equiv_type.m
Detect and report circular equivalence types.
Previously the unification preds for circular equivalence
types looped.
compiler/typecheck.m
Fixed printing of constants in write_functor_name
- foo instead of foo/0
compiler/code_aux.m
Undid my previous change to code_aux__contains_only_builtins,
which made the code less general than it could be.
compiler/inlining.m
Changed inlining__simple_goal to disregard complicated_unify.
compiler/polymorphism.m
Make sure bound insts are not module qualified.
Estimated hours taken: 6
Module qualification of function calls and higher-order predicate constants.
compiler/hlds_data.m
Changed the cons(string, arity) constructor of cons_id to
cons(sym_name, arity). A module qualified cons_id is assumed to
be a function or higher-order pred constant, since we don't
yet support module qualification of constructors (Explicit
type qualification is much more useful anyway, but that doesn't
work yet either).
compiler/hlds_goal.m
Changed the functor(const, list(var)) constructor of unify_rhs
to functor(cons_id, list(var)) to allow the storing of a module
qualifier.
compiler/make_hlds.m
Parse qualified function calls and higher-order pred constants.
compiler/modes.m
compiler/intermod.m
Take module qualifiers into account when resolving function
overloading.
compiler/*.m
Updated unify_rhs's and cons_id's everywhere.
Estimated hours taken: 15
hlds_data:
Rename address_const to code_addr_const, and add base_type_info_const
as a new alternative in cons_id, and make corresponding changes
to cons_tag.
Make hlds_type__defn an abstract type.
llds:
Rename address_const to code_addr_const, and add data_addr_const
as a new alternative in rval_const.
Change type "label" to have four alternatives, not three:
local/2 (for internal labels), c_local (local to a C module),
local/1 (local a Mercury module but not necessarily to a C module,
and exported.
llds_out:
Keep track of the things declared previously, and don't declare them
again unnecessarily. Associate indentation with the following item
rather than the previous item (the influence of 244); this results
in braces being put in different places than previously, but should be
easier to maintain. Handle the new forms of addresses and labels.
Refer to c_local labels as STATIC when not using --split-c-files.
code_info:
Use a presently junk field to store a cell counter, which is used
to allocate distinguishing numbers to create'd cells. Previously
we used the label counter, which meant that label numbers changed
when we optimized away some creates. Handle the new forms of
addresses and labels.
exprn_aux:
Handle the new forms of addresses and labels. We are now more
precise in figuring out what label address forms will be considered
constants by the C compilers.
others:
Changes to handle the new forms of addresses and labels, and/or to
access hlds_type__defn as an abstract type.
Estimated hours taken: 2.5
Fixed a bug in the C interface.
The names of C variables were indexed by the corresponding Mercury variable.
The problem arose when the same Mercury variable was passed in to a
C code in two separate arguments, as in string__append(X, X, Y).
If the procedure was inlined, excess assignments removed the assignment
introduced in make_hlds to put the clause into super-homogeneous form,
so a declaration for one C variable did not appear, and a declaration for
the other was repeated.
compiler/hlds_goal.m
compiler/*.m
Change the method of storing C variable names from a map(var, string)
to a list(maybe(string)), with one element for each argument to
the C code.
Estimated hours taken: 0.25
compiler/polymorphism.m:
A minor simplification to the code:
call type_list_subsumes rather than type_unify_list,
since it is a higher-level subroutine that requires
less mucking around with type substitutions.
Estimated hours taken: 40
(including testing)
These changes comprise
* some configuration changes for accurate GC (setting -DNATIVE_GC,
working out dependencies for accurate GC, new .agc grade)
* liveness changes for supporting polymorphism in accurate GC
* some support of polymorphism for GC (mostly consisting of keeping
the typevar -> typinfo_var mappings (eg T in list(T) is
stored in TypeInfo_For_T) and corresponing mappings into
lvals at continuation labels.
* changes required to data structures so that above changes could
work.
* cut down on the number of abstract exports handled by checking
types to see whether they are imported (duh...)
* don't use '-I' directories when searching for '.m' files.
(since this will wrecks dependency generation in some situations).
* don't lookup and create shape information when not doing accurate
GC. (instead we just give back dummy values).
Estimated hours taken: 45
Module qualification of types, insts and modes.
Added a new interface file - <module>.int3. This contains the
short interface qualified as much as possible given the information
in the current module.
When producing the .int and .int2 files for a module, the compiler uses
the information in the .int3 files of modules imported in the interface
to fully module qualify all items. The .int2 file is just a fully
qualified version of the .int3 file. The .int3 file cannot be overwritten
by the fully qualified version in the .int2 file because then mmake would
not be able to tell when the interface files that depend on that .int3
file really need updating.
The --warn-interface-imports option can be used to check whether
a module imported in the interface really needs to be imported in
the interface.
compiler/module_qual.m
Module qualify all types, insts and modes. Also checks for modules
imported in the interface of a module that do not need to be.
compiler/modules.m
The .int file for a module now depends on the .int3 files of imported
modules. Added code to generate the make rule for the .int file in the
.d file. There is now a file .date2 which records the last time the
.int2 file was updated.
The .int3 files are made using the --make-short-interface option
introduced a few weeks ago.
compiler/options.m
Added option --warn-interface-imports to enable warning about interface
imports which need not be in the interface. This is off by default
because a lot of modules in the library import list.m when they only
need the type list, which is defined in mercury_builtin.m.
Removed option --builtin-module, since the mercury_builtin name is wired
into the compiler in a large number of places.
compiler/prog_util.m
Added a predicates construct_qualified_term/3 and construct_qualfied_term/4
which take a sym_name, a list of argument term and a context for the /4
version and give a :/2 term.
compiler/type_util.m
Modified type_to_type_id to handle qualified types. Also added predicates
construct_type/3 and construct_type/4 which take a sym_name and a list of
types and return a type by calling prog_util:construct_qualified_term.
compiler/modes.m
On the first iteration of mode analysis, module qualify the modes of
lambda expressions.
compiler/mode_info.m
Added field to mode_info used to decide whether or not to module qualify
lambda expressions.
compiler/mode_errors.m
Added dummy mode error for when module qualification fails so that mode
analysis will stop.
Added code to strip mercury_builtin qualifiers from error messages to
improve readability.
compiler/typecheck.m
Strip builtin qualifiers from error messages.
compiler/llds.m
compiler/llds_out.m
compiler/opt_util.m
compiler/opt_debug.m
Change the format of labels produced for the predicates to use the
qualified version of the type name.
compiler/mercury_compile.pp
Call module_qual__module_qualify_items and make_short_interface.
Remove references to undef_modes.m and undef_types.m
compiler/undef_modes.m
compiler/undef_types.m
Removed, since their functionality is now in module_qual.m.
compiler/prog_io.m
Changed to qualify the subjects of type, mode and inst declarations.
compiler/*.m
Changes to stop various parts of the compiler from throwing away
module qualifiers.
Qualified various mercury_builtin builtins, e.g. in, out, term etc.
where they are wired in to the compiler.
compiler/hlds_data.m
The mode_table and user_inst_table are now abstract types each
storing the {mode | inst}_id to hlds__{mode | inst}_defn maps
and a list of mode_ids or inst_ids. This was done to improve the
efficiency of module qualifying the modes of lambda expressions
during mode analysis.
module_info_optimize/2 now sorts the lists of ids.
The hlds_module interface to the mode and inst tables has not changed.
compiler/hlds_module.m
Added yet another predicate to search the predicate table.
predicate_table_search_pf_sym_arity searches for predicates or
functions matching the given sym_name, arity and pred_or_func.
compiler/higher_order.m
Changed calls to solutions/2 to list__filter/3. Eliminated unnecessary
requantification of goals.
compiler/unused_args.m
Improved abstraction slightly.
Estimated hours taken: 4
Implement `recursive' and `non_recursive' pragma c_code declarations.
This allows the compiler to optimize cases when the C code
is known to not call Mercury code. It's also necessary
to allow C code which modifies the hp register to work
(such code must be declared `non_recursive', otherwise
the registers will be saved and restored over it).
To make things bootstrap OK, the old pragma c_code declarations
default to `non_recursive'.
prog_data.m, hlds_goal.m:
Add new field c_is_recursive to pragma c_code goals.
prog_io.m:
Parse the new `recursive' and `non_recursive' pragma c_code
declarations.
make_hlds.m:
Pass the c_is_recursive field from the parse tree to the HLDS.
live_vars.m:
For non-recursive C code, don't save variables on the stack.
code_gen.pp:
For non-recursive C code, don't save variables on the stack,
don't mark the succip as needing to be saved, and don't
call save_registers() and restore_registers().
*.m:
Change c_code/5 to c_code/6.
Estimated hours taken: 6
Fixup the way we handle the symbol table for predicates and functions
so that the compiler doesn't confuse the two, so that you can now define
a function of arity N and a predicate of arity N+1 in the same module
without giving the compiler heartburn.
hlds_module.m:
In the predicate_table, split the three maps used to index on name,
name/arity, and module:name/arity into two sets of three, one
for predicates and one for functions. Make sure that only predicates
get inserted into the pred indices and only functions get inserted
into the function indices. Add lots of new access predicates
for searching for just predicates or functions.
code_util.m, make_hlds.m, typecheck.m, modes.m, polymorphism.m:
Change the calls to predicate_table_search_* to make sure we
don't confuse functions with predicates.
code_util.m:
Change some error messages that said "pred" to say "pred or func".
make_hlds.m:
Change some warnings for bogus `pragma(export)' declarations
into errors, and clean up the code a little. Do a small part
of the work necessary to get `pragma(export)' to work for
functions.
typecheck.m:
Print a helpful error message in the case when a goal
contains a function call rather than a predicate call.
polymorphism.m:
Make sure that when it looks up `unify/2' and `builtin_*'
in the symbol table, it only for them in module mercury_builtin.
make_hlds.m, modes.m:
Call hlds_out__pred_or_func_to_str rather than converting
a pred_or_func to the string "pred" or "func" manually.
hlds_out.m:
Add new predicate pred_or_func_to_str.
Estimated hours taken: 12
Implement higher-order functions.
Add higher-order function terms
(function lambda expressions, e.g. `Func = (func(X) = Y :- Y is 2 * X)'
and higher-order function calls (apply/N, e.g. `Z = apply(Func, 42)').
Add higher-order function insts and modes.
hlds_goal.m:
Add a new field pred_or_func to lambda_goal.
prog_data.m:
Add a new field pred_or_func to pred_inst_info.
prog_io.m:
Add support for parsing higher-order function terms and
higher-order function insts and modes.
make_hlds.m:
Add support for parsing higher-order function terms.
typecheck.m:
Add support for type-checking higher-order function calls
and higher-order function terms.
modes.m, mode_errors.m:
Add support for mode-checking higher-order function calls
and higher-order function terms.
higher_order.m:
Handle higher-order function types and insts.
hlds_pred.m:
Add new predicate pred_args_to_func_args, for extracting the
function arguments and function return from the arguments
of a predicate that is really a function.
*.m:
Minor changes to handle new pred_or_func field in lambda_goals
and pred_inst_infos.
Estimated hours taken: 24
Treat higher-order predicate calls as a new sort of goal,
rather than as calls to the special predicate call/N, in order to
remove the fixed limit on the number of arguments and on the modes
for call/N.
Also, remove the restriction on output arguments preceding input arguments
in lambda expressions.
hlds_goal.m:
Add new functor higher_order_call/6 to the hlds__goal type.
*.m:
Handle new functor higher_order_call/6.
arg_info.m:
Abstract things a bit more: the argument passing convention
for a procedure may be affected by that procedure's types,
modes, and code_model, as well as the arg_method.
follow_vars.m:
Pass down the args_method, since it is now needed for figuring
out the arg_info for unifications and higher-order calls.
follow_code.m:
Treat complicated unifications in the same way as calls.
lambda.m:
When creating lambda predicates, permute the arguments so
that all input arguments come before all output arguments.
call_gen.m:
When generating higher-order predicate calls, don't abort
if outputs precede inputs; instead, generate code assuming
that the called predicate's args have been permuted so that
the inputs to come before all the outputs.
Estimated hours taken: 8
options.m:
Rename branch_delay_slot to have_delay_slot.
Set optimize_delay_slot in -O2 only if have_delay_slot was set earlier.
This is possible now because the default optimization level is now
set in mc.
mercury_compile:
Change verbose output a bit to be more consistent.
dead_proc_elim:
Export the predicates that will eventually be needed by inlining.m.
inlining.m:
Use the information about the number of times each procedure is called
to inline local nonrecursive procedures that are called exactly once.
EXCEPT that this is turned off at the moment, since the inlining of
parse_dcg_goal_2 in prog_io, which this change enables, causes the
compiler to emit incorrect code.
prog_io:
Moved the data type definitions to prog_data. (Even though prog_io.m
is ten times the size of prog_data.m, the sizes of the .c files are
not too dissimilar.)
Estimated hours taken: 3
options:
Add a new option, --branch-delay-slot, intended for use by mc on
the basis of the configuattion script. It says whether the machine
architecture has delays slots on branches.
The setting of option should affect whether we set
--optimize-delay-slots at -O2, but this doesn't work yet.
hlds_goal:
Add an extra field to hold follow_vars infromation to disjunctions,
switches and if-then-elses. I intend to use this information to
generate better code.
*.m:
Changes to accommodate the extra field.
Estimated hours taken: 3
A bunch of cleanups: improve error messages, tidy up the code.
Also, do some work towards supporting higher-order functions.
type_util.m:
Add new predicate type_is_higher_order/3 for checking
whether a type is a higher-order type. This recognizes
both higher-order predicate types and also higher-order
function types.
code_info.m, modes.m, polymorphism.m, shapes.m:
Use type_is_higher_order/3.
make_hlds.m:
Fix another error message to do the right thing when
reporting errors for functions.
mercury_to_mercury:
List `func' in the table of operators, so that it gets
parenthesized correctly.
modes.m, mode_errors.m:
Improve the error message for attempted higher-order unifications:
spit out some context, and if verbose_errors is enabled, spit
out a long description.