Estimated hours taken: 250
Add support for tabling.
This change allows for model_det, model_semidet and model_non memoing,
minimal model and loop detection tabling.
compiler/base_type_layout.m:
Update comments to reflect new runtime naming standard.
compiler/det_analysis.m:
Allow tabling to change the result of det analysis. This is
necessary in the case of minimal model tabling which can
turn a det procedure into a semidet one.
compiler/det_report.m:
compiler/hlds_data.m:
Add code to report error messages for various non compatible
tabling methods and determinism.
compiler/hlds_out.m:
compiler/modules.m:
Remove reference to the old memo marker.
compiler/hlds_pred.m:
Create new type (eval_method) to define which of the available
evaluation methods should be used each procedure.
Add new field to the proc_info structure.
Add several new predicates relating to the new eval_method type.
compiler/inlining.m:
compiler/intermod.m:
Make sure only procedures with normal evaluation are inlined.
compiler/make_hlds.m:
Add code to process new tabling pragmas.
compiler/mercury_compile.m:
Call the tabling transformation code.
compiler/modes.m:
Make sure that all procedures with non normal evaluation have
no unique/partially instantiated modes. Produce error messages
if they do. Support for partially instantiated modes is currently
missing as it represents a large amount of work for a case that
is currently not used.
compiler/module_qual.m:
compile/prog_data.m:
compiler/prog_io_pragma.m:
Add three new pragma types:
`memo'
`loop_check'
`minimal_model'
and code to support them.
compiler/simplify.m:
Don't report infinite recursion warning if a procedure has
minimal model evaluation.
compiler/stratify.m:
Change the stratification analyser so that it reports cases of
definite non-stratification. Rather than reporting warnings for
any code that is not definitely stratified.
Remove reference to the old memo marker.
compiler/switch_detection.m:
Fix a small bug where goal were being placed in reverse order.
Call list__reverse on the list of goals.
compiler/table_gen.m:
New module to do the actual tabling transformation.
compiler/notes/compiler_design.html:
Document addition of new tabling pass to the compiler.
doc/reference_manual.texi:
Fix mistake in example.
library/mercury_builtin.m:
Add many new predicates for support of tabling.
library/std_util.m:
library/store.m:
Move the functions :
ML_compare_type_info
ML_collapse_equivalences
ML_create_type_info
to the runtime.
runtime/mercury_deep_copy.c:
runtime/mercury_type_info.h:
runtime/mercury_type_info.c:
Move the make_type_info function into the mercury_type_info module
and make it public.
runtime/Mmakefile:
runtime/mercury_imp.h:
Add references to new files added for tabling support.
runtime/mercury_string.h:
Change hash macro so it does not cause a name clash with any
variable called "hash".
runtime/mercury_type_info.c:
runtime/mercury_type_info.h:
Add three new functions taken from the library :
MR_compare_type_info
MR_collapse_equivalences
MR_create_type_info.
runtime/mercury_table_any.c:
runtime/mercury_table_any.h:
runtime/mercury_table_enum.c:
runtime/mercury_table_enum.h:
runtime/mercury_table_int_float_string.c:
runtime/mercury_table_int_float_string.h:
runtime/mercury_table_type_info.c:
runtime/mercury_table_type_info.h:
runtime/mercury_tabling.h:
New modules for the support of tabling.
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
Estimated hours taken: 24
Add support to the Mercury tracer for interacting with an external
Opium-style debugger via a socket.
TODO: currently there is no way for the debugger to specify
constraints on the arguments for a `forward_move' query.
The current code for doing that doesn't work.
(However, the reporting of arguments to the debugger
for an `output_current' query works fine.)
runtime/mercury_trace.c:
Add code to MR_trace() to open a socket connection to
an external debugger, and to process requests from that
debugger, and send responses back.
runtime/mercury_trace.h:
runtime/mercury_wrapper.c:
Call MR_trace_end() from mercury_runtime_terminate() so that
the external debugger gets notified when the program does
a (normal) exit.
runtime/mercury_stack_layout.h:
Fix a bug where the structures here did not match
the output produced by compiler/stack_layout.m.
library/debugger_interface.m:
New file. Declares the Mercury types used for the debugger
socket interface and defines support routines used by
runtime/mercury_trace.c.
library/io.m:
runtime/mercury_types.h:
Move the definition of MercuryFile from library/io.m to
runtime/mercury_types.h, for use by runtime/mercury_trace.c.
library/io.m:
When printing out values of type `c_pointer', print out
the "<<c_pointer>>" string in single quotes, to ensure
that it has valid syntax for a Prolog or Mercury term.
This is necessary because otherwise c_pointers in procedure
arguments could lead to the Mercury process sending a
syntactically invalid term down the socket to the debugger,
which would then be unable to parse it.
library/library.m:
Add reference to debugger_interface.m, so that it gets
include in libmercury.a.
doc/Mmakefile:
Make sure that the library/debugger_interface.m does *not*
get included in the Mercury library reference manual.
runtime/mercury_wrapper.h:
runtime/mercury_wrapper.c:
runtime/mercury_init.h:
util/mkinit.c:
Declare, define, and initialize pointers to the C functions
exported by library/debugger_interface.m.
(This is to avoid having a circular dependency where the
runtime depends on the library.)
compiler/notes/authors.html:
Add Erwan Jahier.
Estimated hours taken: 0.25
compiler/notes/compiler_design.html:
Document why the first `simplify' pass is considered part of the
semantic analysis phase, not the high-level transformation phase
(the answer is because it can report warnings).
Estimated hours taken: 20
Add support for `pragma import', which is a simplified form of
`pragma c_code'. With `pragma import', the user specifies only
the C function name, rather than a C code fragment, and the
Mercury compiler handles the argument-passing automatically.
TODO
- add documentation to doc/reference_manual.texi.
WISHLIST
- change `pragma import' and `pragma export'
to take an additional parameter indicating the language
(e.g. C, Prolog, Ada, Fortran, etc.) and/or calling
convention
compiler/prog_data.m:
Add `pragma import' to the parse tree data structure.
compiler/prog_io_pragma.m:
Add code to parse `pragma import' declarations.
compiler/mercury_to_mercury.m:
Add code to pretty-print `pragma import' declarations.
compiler/module_qual.m:
Add code to module-qualify `pragma import' declarations.
compiler/make_hlds.m:
Add code to process `pragma import' declarations,
by converting them to clauses with HLDS `c_code' instructions.
compiler/export.m:
Declare `export__exclude_argument_type' in the interface,
for use by the code for handling `pragma import' in make_hlds.m.
Change the documentation to say that this procedure is used for
both exported and imported procedures.
compiler/notes/compiler_design.html:
Document how the compiler handles `pragma import' declarations.
tests/hard_coded/Mmakefile:
tests/hard_coded/pragma_import.m:
tests/hard_coded/pragma_import.exp:
Add some test cases for `pragma import'.
Estimated hours taken: 1/2
A few minor changes, including fixing the syntax of a typeclass declaration.
The methods inside a typeclass declaration no longer have a ":-" at the start.
compiler/make_hlds.m:
Give an error message is a typeclass is multiply defined.
compiler/prog_io.m:
Export parse_decl, and make the output a maybe_item_and_context so
that it is more useful to prog_io_typeclass.
compiler/prog_io_typeclass.m:
Use parse_decl rather than parse_item to parse the class methods. This
way the ":-" is left off.
compiler/notes/compiler_design.html:
Document why check_typeclass is the final semantic analysis pass.
Estimated hours taken: 8
Clean up the handling of unbound type variables.
Fix a bug with unbound type variables in lambda expressions.
Run purity analysis, modechecking etc. even if there were type errors.
compiler/mercury_compile.m:
Run purity analysis, modechecking etc. even if there were type
errors. This fixes a bug (inconsistency between the code and
the comments) that seems to have been introduced in stayl's
change to mercury_compile.m (revision 1.25) to add intermodule
unused argument elimination: the comment said "continue,
even if type checking found errors", but the code did not
continue.
This change was needed to ensure that we still report a warning
message about unused type variables for tests/invalid/error2.m;
without it, we stop after type checking and don't do purity
analysis, and so don't report the warning.
compiler/typecheck.m:
compiler/purity.m:
Move the code for checking for unbound type variables
from typecheck.m to purity.m. It needs to be done
*after* type inference has been completed, so it
can't be done in the ordinary type checking/inference
passes. Add code to purity.m to bind the
unbound type variables to the builtin type `void'.
compiler/polymorphism.m:
Comment out old code to bind unbound type variables
to `void'; the old code was incomplete, and this
is now done in purity.m.
compiler/notes/compiler_design.html:
Document the above changes.
tests/valid/Mmakefile:
tests/valid/unbound_tvar_in_lambda.m:
Regression test for the above-mentioned bug with unbound type
variables in lambda expressions.
tests/warnings/singleton_test.exp:
tests/invalid/errors2.err_exp:
Change the expected warning message for unbound type variables.
The error context is not as precise as it used to be, I'm afraid:
we only know which function/predicate the error occurred in,
not which clause. Also it now comes out in a different order
relative to the other error messages.
tests/invalid/errors2.err_exp:
tests/invalid/funcs_as_preds.err_exp:
Add some new error/warning messages that are output now that
we run mode and determinism analysis even if there are type errors.
Estimated hours taken: 60
A rewrite of termination analysis to make it significantly easier to modify,
and to extend its capabilities.
compiler/error_util.m:
A new file containing code that makes it easier to generate
nicely formatted error messages.
compiler/termination.m:
Updates to reflect the changes to the representation of termination
information.
Instead of doing pass 1 on all SCCs and then pass 2 on all SCCs,
we now do both pass 1 and 2 on an SCC before moving on to the next.
Do not insist that either all procedures in an SCC are
compiler-generated or all are user-written, since this need not be
true in the presence of user-defined equality predicates.
Clarify the structure of the code that handles builtins and compiler
generated predicates.
Concentrate all the code for updating module_infos in this module.
Previously it was scattered in several places in several files.
Put all the code for writing out termination information at the
end of the module in a logical order.
compiler/term_traversal.m:
A new file containing code used by both pass 1 and pass 2 to
traverse procedure bodies.
compiler/term_pass1.m:
Use the new traversal module.
Clarify the fixpoint computation on the set of output supplier
arguments.
Remove duplicates from the list of equations given to the solver.
This avoids a det stack overflow in lp.m when doing termination
analysis on options.m.
If an output argument of a predicate makes sense only in the absence
of errors, then return it only in the absence of errors.
compiler/term_pass2.m:
Use the new traversal module. Unlike the previous code, this allows us
to ignore recursive calls with input arguments bigger than the head
if those calls occur after goals that cannot succeed (since those
calls will never be reached).
Implement a better way of doing single argument analysis, which
(unlike the previous version) works in the presence of mutual recursion
and other calls between the recursive call and the start of the clause.
Implement a more precise way of checking for recursions that don't
cause termination problems. We now allow calls from p to q in which
the recursive input supplier arguments can grow, provided that on
any path on which q can call p, directly or indirectly, the recursive
input supplier arguments shrink by a greater amount.
If an output argument of a predicate makes sense only in the absence
of errors, then return it only in the absence of errors.
compiler/term_util.m:
Updates to reflect the changes to the representation of termination
information.
Reorder to put related code together.
Change the interface of several predicates to better reflect the
way they are used.
Add some more utility predicates.
compiler/term_errors.m:
Small changes to the set of possible errors, and major changes in
the way the messages are printed out (we now use error_util).
compiler/options.m:
Change --term-single-arg from being a bool to an int option,
whose value indicates the maximum size of an SCC in which we try
single argument analysis. (Large SCCs can cause single-arg analysis
to require a lot of iterations.)
Add an (int) option that controls the max number of paths
that we are willing to analyze (analyzing too many paths can cause
det stack overflow).
Add an (int) option that controls the max number of causes of
nontermination that we print out.
compiler/hlds_pred.m:
Use two separate slots in the proc_info to hold argument size data
and termination info, instead of the single slot used until now.
The two kinds of information are produced and used separately.
Make the layout of the get and set procedures for proc_infos more
regular, to facilitate later updates.
The procedures proc_info_{,set_}variables did the same work as
proc_info_{,set_}varset. To eliminate potential confusion, I
removed the first set.
compiler/*.m:
Change proc_info_{,set_}variables to proc_info_{,set_}varset.
compiler/hlds_out.m:
compiler/make_hlds.m:
compiler/mercury_to_mercury.m:
Change the code to handle the arg size data and the termination
info separately.
compiler/prog_data.m:
Change the internal representation of termination_info pragmas to
hold the arg size data and the termination info separately.
compiler/prog_io_pragma.m:
Change the external representation of termination_info pragmas to
group the arg size data together with the output supplier data,
to which it is logically connected.
compiler/module_qual.m:
compiler/modules.m:
Change the code to accommodate the change to the internal
representation of termination_info pragmas.
compiler/notes/compiler_design.html:
Fix some documentation rot, and clarify some points.
Document termination analysis.
doc/user_guide.texi:
Document --term-single-arg and the new options.
Remove spaces from the ends of lines.
library/bag.m:
Add a new predicate, bag__least_upper_bound.
Fix code that would do the wrong thing if executed by Prolog.
Remove spaces from the ends of lines.
library/list.m:
Add a new predicate, list__take_upto.
library/set{,_ordlist}.m:
Add a new predicate, set{,_ordlist}__count.
tests/term/*:
A bunch of new test cases to test the behaviour of termination
analysis. They are the small benchmark suite from our paper.
tests/Mmakefile:
Enable the new test case directory.
Estimated hours taken: 20
Give duplicate code elimination more teeth in dealing with similar arguments
of different function symbols. For the source code
:- type t1 ---> f(int)
; g(int, int).
:- pred p1(t1::in, int::out) is det.
p1(f(Y), Y).
p1(g(Y, _), Y).
we now generate the C code
Define_entry(mercury__xdup__p1_2_0);
r1 = const_mask_field(r1, (Integer) 0);
proceed();
thus avoiding the cost of testing the function symbol.
runtime/mercury_tags.h:
Add two new macros, mask_field and const_mask_field, that behave
just like field and const_field except that instead of stripping
off a known tag from the pointer, they strip (mask) off an unknown
tag.
compiler/llds.m:
Change the first argument of the lval field/3 from tag to maybe(tag).
Make the comments on some types more readable.
compiler/llds_out.m:
If the first arg of the lval field/3 is no, emit a (const_)mask_field
macro; otherwise, emit a (const_)field macro.
compiler/basic_block.m:
New module to convert sequences of instructions to sequences of
basic blocks and vice versa. Used in the new dupelim.m.
compiler/dupelim.m:
Complete rewrite to give duplicate code elimination more teeth.
Whereas previously we eliminated blocks of code only if they exactly
duplicated other blocks of code, we now look for blocks that can be
"anti-unified". For example, the blocks
r1 = field(mktag(0), r2, 0)
goto L1
and
r1 = field(mktag(1), r2, 0)
<fall through to L1>
anti-unify, with the most specific common generalization being
r1 = mask_field(r2, 0)
goto L1
If several basic blocks antiunify, we replace one copy with the
antiunified block and try to eliminate the others. We do not
eliminate blocks that can be fallen into, since eliminating them
would require introducing a goto, which would slow the code down.
compiler/peephole,m:
If a conditional branch to a label is followed by that label or
by an unconditional branch to that label, eliminate the branch.
Dupelim produces this kind of code.
compiler/{code_exprn,exprn_aux,lookup_switch,opt_debug,unify_gen}.m:
Minor changes required by the change to field/3.
compiler/{frameopt,jumpopt,labelopt,mercury_compile,optimize,value_number}.m:
s/__main/_main/ in predicate names.
compiler/jumpopt.m:
Add some documentation.
compiler/unify_gen.m:
Fix a module qualified predicate name reference that would not
work in Prolog.
compiler/notes/compiler_design.html:
Document the new file basic_block.m.
Estimated hours taken: 500 or so
This change implements typeclasses. Included are the necessary changes to
the compiler, runtime and library.
compiler/typecheck.m:
Typecheck the constraints on a pred by adding constraints for each
call to a pred/func with constraints, and eliminating constraints
by applying context reduction.
While reducing the constraints, keep track of the proofs so that
polymorphism can produce the tyepclass_infos for eliminated
constraints.
compiler/polymorphism.m:
Perform the source-to-source transformation which turns code with
typeclass constraints into code without constraints, but with extra
"typeclass_info", or "dictionary" parameters.
Also, rather than always having a type_info directly for each type
variable, sometimes the type_info is hidden inside a typeclass_info.
compiler/bytecode*.m:
Insert some code to abort if bytecode generation is used when
typeclasses are used.
compiler/call_gen.m:
Generate code for a class_method_call, which forms the body of a class
method (by selecting the appropriate proc from the typeclass_info).
compiler/dead_proc_elim.m:
Don't eliminate class methods if they are potentially used outside
the module
compiler/hlds_data.m:
Define data types to store:
- the typeclass definitions
- the instances of a class
- "constraint_proof". ie. the proofs of redundancy of a
constraint. This info is used by polymorphism to construct the
typeclass_infos for a constraint.
- the "base_tyepclass_info_constant", which is analagous the
the base_type_info_constant
compiler/hlds_data.m:
Define the class_method_call goal. This goal is inserted into the
body of class method procs, and is responsible for selecting the
appropriate part of the typeclass_info to call.
compiler/hlds_data.m:
Add the class table and instance table to the module_info.
compiler/hlds_out.m:
Output info about base_typeclass_infos and class_method_calls
compiler/hlds_pred.m:
Change the representation of the locations of type_infos from "var"
to type_info_locn, which is either a var, or part of a typeclass_info,
since now the typeclass_infos contain the type_infos for the type that
they constrain.
Add constraints to the pred_info.
Add constraint_proofs to the pred_info (so that typeclass.m can
annotate the pred_info with the reasons that constraints were
eliminated, so that polymorphism.m can in turn generate the
typeclass_infos for the constraints).
Add the "class_method" marker.
compiler/lambda.m:
A feable attempt at adding class ontexts to lambda expressions,
untested and almost certainly not working.
compiler/llds_out.m:
Output the code addresses for do_*det_class_method, and output
appropriately mangled symbol names for base_typeclass_infos.
compiler/make_hlds.m:
Add constraints to the types on pred and func decls, and add
class and instance declarations to the class_table and instance_table
respectively.
compiler/mercury_compile.m:
Add the check_typeclass pass.
compiler/mercury_to_mercury.m:
Output constraints of pred and funcs, and output typeclass and instance
declarations.
compiler/module_qual.m:
Module qualify typeclass names in pred class contexts, and qualify the
typeclass and instance decls themselves.
compiler/modules.m:
Output typeclass declarations in the short interface too.
compiler/prog_data.m:
Add the "typeclass" and "instance" items. Define the types to store
information about the declarations, including class contexts on pred
and func decls.
compiler/prog_io.m:
Parse constraints on pred and func declarations.
compiler/prod_out.m:
Output class contexts on pred and func decls.
compiler/type_util.m:
Add preds to apply a substitution to a class_constraint, and to
a list of class constraints. Add type_list_matches_exactly/2. Also
add typeclass_info and base_typeclass_info as types which should not
be optimised as no_tag types (seeing that we cheat a bit about their
representation).
compiler/notes/compiler_design.html:
Add notes on module qualification of class contexts. Needs expansion
to include more stuff on typeclasses.
compiler/*.m:
Various minor changes.
New Files:
compiler/base_typeclass_info.m:
Produce one base_typeclass_info for each instance declaration.
compiler/prog_io_typeclass.m:
Parse typeclass and instance declarations.
compiler/check_typeclass.m:
Check the conformance of an instance declaration to the typeclass
declaration, including building up a proof of how superclass
constraints are satisfied so that polymorphism.m is able to construct
the typeclass_info, including the superclass typeclass_infos.
library/mercury_builtin.m:
Implement that base_typeclass_info and typeclass_info types, as
well as the predicates type_info_from_typeclass_info/3 to extract
a type_info from a typeclass_info, and superclass_from_typeclass_info/3
for extracting superclasses.
library/ops.m:
Add "typeclass" and "instance" as operators.
library/string.m:
Add a (in, uo) mode for string__length/3.
runtime/mercury_ho_call.c:
Implement do_call_*det_class_method, which are the pieces of code
responsible for extracting the correct code address from the
typeclass_info, setting up the arguments correctly, then executing
the code.
runtime/mercury_type_info.h:
Macros for accessing the typeclass_info structure.
The purpose of this diff is to allow Mercury programs to contain
impure Mercury code without the compiler changing its behavior
inappropriately, while still allowing the compiler to aggressively
optimize pure code. To do this, we require impure predicates to be so
declared, and calls to impure predicates to be flagged as such. We
also allow predicates implemented in terms of impure predicates to be
promised to be pure; lacking such a promise, any predicate that calls
an impure predicate is assumed to be impure.
At the moment, we don't allow impure functions (only predicates),
though some of the work necessary to support them has been done.
Note that to make the operators work properly, the precedence of the
`pred' and `func' operators has been changed from 1199 to 800.
Estimated hours taken: 150
compiler/purity.m:
New compiler pass for purity checking.
compiler/hlds_goal.m:
Add `impure' and `semipure' to the goal_feature enum.
compiler/hlds_out.m:
compiler/typecheck.m:
compiler/special_pred.m:
Fixed code that prints predicate name to write something more
helpful for special (compiler-generated) predicates. Added
code to print new markers. Added purity argument to
mercury_output_pred_type. New public predicate
special_pred_description/2 provides an english description for
each compiler-generated predicate.
compiler/hlds_pred.m:
Add `impure' and `semipure' to marker enum. Added new
public predicates to get predicate purity and whether or not
it's promised to be pure.
compiler/prog_data.m:
compiler/mercury_to_mercury.m:
compiler/prog_io.m:
compiler/prog_io_goal.m:
compiler/prog_io_pragma.m:
compiler/prog_io_dcg.m:
compiler/prog_util.m:
compiler/equiv_type.m:
compiler/intermod.m:
compiler/mercury_to_c.m:
compiler/module_qual.m:
Add purity argument to pred and func items. Add new `impure'
and `semipure' operators. Add promise_pure pragma. Add
purity/2 wrapper to goal_expr type.
compiler/make_hlds.m:
compiler/mercury_to_goedel.m:
Added purity argument to module_add_{pred,func},
clauses_info_add_pragma_c_code, and to pred and func items.
Handle promise_pure pragma. Handle purity/2 wrapper used to
handle user-written impurity annotations on goals.
compiler/mercury_compile.m:
Add purity checking pass between type and mode checking.
compiler/mode_errors.m:
Distinguish mode errors caused by impure goals preventing
goals being delayed.
compiler/modes.m:
Don't delay impure goals, and ensure before scheduling an
impure goal that no goals are delayed. Actually, we go ahead
and try to schedule goals even if impurity causes a problem,
and then if it still doesn't mode check, then we report an
ordinary mode error. Only if the clause would be mode correct
except for an impure goal do we report it as an impurity problem.
compiler/simplify.m:
Don't optimize away non-pure duplicate calls. We could do
better and still optimize duplicate semipure goals without an
intervening impure goal, but it's probably not worth the
trouble. Also don't eliminate impure goals on a failing branch.
compiler/notes/compiler_design.html:
Documented purity checking pass.
doc/reference_manual.texi:
Document purity system.
doc/transition_guide.texi:
library/nc_builtin.nl:
library/ops.m:
library/sp_builtin.nl:
New operators and new precdence for `pred' and `func'
operators.
tests/hard_coded/purity.m
tests/hard_coded/purity.exp
tests/hard_coded/Mmakefile:
tests/invalid/purity.m
tests/invalid/purity_nonsense.m
tests/invalid/purity.err_exp
tests/invalid/purity_nonsense.err_exp
tests/invalid/Mmakefile:
Test cases for purity.
Estimated hours taken: 0.3
Update the review procedures to reflect what we are doing now, which
seems to be working well.
compiler/notes/reviews.html:
Add different subjects ("for review" "diff" and "trivial diff"
for different classes of reviewing).
Allow second round diffs to be committed before second review,
if there were few problems at the first review.
Estimated hours taken: 0.5
compiler/notes/release_checklist.html:
Update release checklist with how to upload to sunsite, post to
comp.os.linux.announce, and update the webpage with a new
release.
Estimated hours taken: 50
Generate stack layouts for accurate garbage collection.
compiler/base_type_layout.m:
Change the order of some arguments so that threaded data
structures are more often in the final two arguments (allows
easy use of higher order predicates).
Simplify some code using higher order preds.
Export base_type_layout__construct_pseudo_type_info, as
stack_layout.m needs to be able to generate pseudo_type_infos
too.
Fix problems with cell numbers being re-used -- get the next
cell number from module_info, and update module_info
after processing base_type_layouts.
compiler/code_gen.m:
Add information about each procedure to the continuation info.
Handle new field in c_procedure.
compiler/continuation_info.m:
Redesign most of this module to deal with labels
that are continuation points for multiple calls.
Change the order of some arguments so that threaded data
structures are in the final two arguments.
Cleaned up and documented code.
compiler/dupelim.m:
compiler/exprn_aux.m:
Handle new label_entry data type.
compiler/export.m:
compiler/opt_debug.m:
Handle new label_entry and general data types.
compiler/llds_out.m:
Add an argument to get_proc_label to control whether a
"mercury_" prefix is wanted.
Handle new label_entry and general data types.
compiler/llds.m:
Add a new alternative for data_const - a label_entry.
Add a new alternative for data_name - general, which
allows any sort of data, with names generated elsewhere.
Add the pred_proc_id as a field of c_procedure.
compiler/optimize.m:
compiler/llds_common.m:
compiler/optimize.m:
Handle new field in c_procedure.
compiler/mercury_compile.m:
Generate layout information after code has been generated,
and output stack layouts.
compiler/notes/compiler_design.html:
Document new stack_layout module.
compiler/stack_layout.m:
New file - generates the LLDS code that defines
global constants to hold the stack_layout structures.
compiler/options.m:
compiler/handle_options.m:
Add --stack-layout option which outputs stack layouts.
Make accurate gc imply stack_layout.
Estimated hours taken: 12
failure.html:
A new file that describes a new way of handling failure.
The advantages of the proposed new approach are:
- it is significantly simpler than the existing approach, which
makes it easier to get it correct
- it will create temporary nondet frames significantly less frequently
- commits inside nondet code do not need to use the det stack, which
makes gc easier, and results in faster commits
- it should make it easier to eventually delay the setting of
redoip slots in disjuncts, instead of setting them on entry to
each nonlast disjunct the way we do now
The disadvantage is that nondet stack frames have an extra fixed slot,
which has to be filled in and referenced.
Estimated hours taken: 10
Add constant propagation within modules. This occurs during simplification
and simply attempts to evaluate "known" calls that have all their inputs
bound to constants and replaces the call with constructions of the outputs.
Currently the "known" calls are (most) of the arithmetic predicates, and
the comparison of ints and floats.
compiler/instmap.m:
add merge_instmap_deltas which merges a list of intmap deltas
rather than just two of them.
compiler/mercury_compile.m:
compiler/options.m:
add (and use) the option --optimize-constant-propagation
compiler/simplify.m:
add a bool to the simplify struct to turn on/off constant
propagation.
in the simplification of calls, check to see if all the inputs
are bound to constants. If we know how to evaluate this call
at compile time, then do so. This may change the instmap delta.
For branched goals, we merge the instmap deltas to recompute the
instmap delta for the goal as a whole so that we know when every
branch binds a variable to the same constant.
compiler/notes/compiler_design.html:
mention constant propagation.
doc/user_guide.texi:
mention constant propagation.
compiler/const_prop.m:
code that attempts to evaluate calls at compile time.
It contains tables of calls that we know how to evaluate.
Automate the building of releases, including daily "rotd"
(release-of-the-day) releases.
VERSION:
New file, defines the version number.
Also document the general scheme for assigning version numbers.
Mmake.common.in:
Add `include VERSION'.
Mmakefile:
bindist/Mmakefile:
configure.in:
Use the version number in VERSION rather than hard-coding it
in multiple places.
Mmakefile:
README:
.README.in:
INSTALL:
.INSTALL.in:
Change things so that README and INSTALL are automatically
generated from .README.in and .INSTALL.in respectively, using
the version number defined in VERSION.
BUGS:
Remove an unnecessary reference to the version number.
RELEASE_NOTES:
Change this file so that the version number is only mentioned
in one place. Bump the version number here to 0.7 in preparation
for the next release.
library/Mmakefile:
library/library.m:
library/library.m.in:
Change things so that library.m is automatically generated from
library.m.in using the version number in VERSION.
Also change it so that library__version says which architecture
it was configured for.
tools/test_mercury:
Override the version specified in the VERSION file in the CVS
repository with either `rotd-YYYY-MM-DD' or (when making a release)
with a specified $RELEASE_VERSION.
When running on murliboobo, if the version built passes all its
tests, copy it to the /pub/mercury/beta-releases directory on
ftp://turiel.cs.mu.oz.au.
compiler/notes/release_checklist.m:
Change the release checklist to say that you only need to
update the version number in VERSION rather than in 6 different
places. Also change the procedure for building the final
tar file to reflect the above changes to the `test_mercury' script.
Estimated hours taken: 0.05
Update compiler design notes.
compiler/notes/compiler_design.html:
Update design notes with regard to continutation_info.m, and
remove mention of garbage_out.m and shapes.m.
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: 0.2
todo.html:
Removed "being done by jammb", since he isn't working on Mercury
anymore. Added a note that petdr is supposed to be working on
data type specialization. Clarified a point about attribute grammars.
Estimated hours taken: 0.25
compiler/notes/compiler_design.html:
Mention that common.m also does elimination of duplicate procedure
calls, not just of common structs.
Estimated hours taken: 1
compiler/notes/todo.html:
Update the todo list to reflect things that have been done.
Move some items from the TODO section to the WISHLIST section.
Change the indentation slightly to make it easier to read
the ASCII source.
Estimated hours taken: 0.1
[This was stayl's change to COMPILER_DESIGN that somehow didn't get
incorporated when COMPILER_DESIGN became compiler_desing.html.]
compiler/notes/compiler_design.html:
Added some more documentation on module qualification.
Estimated hours taken: 0.1
Change the filenames of the .html files to lowercase.
This is essentially a gratuitous aesthetic change. 8^)
compiler/notes/Mmakefile
Estimated hours taken: 0.2
Added target for creating plain text equivalents of the HTML documents.
We use the file extension .text for the plain text documents.
All these docs are installed on the web pages.
Also added a target to clean away the generated plain text files.
mercury/compiler/notes/Mmakefile:
Estimated hours taken: 0.1
Removed the original plain text documents in this directory since they've
now been translated into HTML. In order to produce plain text from
the HTML docs, we can use the facilities of the text browser Lynx:
lynx -dump file.html > file.text
compiler/notes/
ALLOCATION
AUTHORS
CODING_STANDARDS
COMPILER_DESIGN
GC_AND_C_CODE
GLOSSARY
MODULE_SYSTEM
RELEASE_CHECKLIST
REVIEWS
TODO
Estimated hours taken: 4
Translated plain text docs to HTML. This obviously creates
a dual update problem. We should solve this by putting
the plain text docs in the attic and retaining the HTML.
Also added the HTML files to the Mmakefile so they are installed
on the web pages.
The other documents in compiler/notes will be HTMLized soon.
compiler/notes/
Mmakefiles
ALLOCATION.html
AUTHORS.html
CODING_STANDARDS.html
COMPILER_DESIGN.html
GC_AND_C_CODE.html
GLOSSARY.html
MODULE_SYSTEM.html
RELEASE_CHECKLIST.html
REVIEWS.html
TODO.html
Estimated hours taken: 0.1
Cut-n-paste error.
mercury/compiler/notes/Mmakefile:
I copied another Mmakefile and accidentally left some rubbish in it.
Why did I not test the Mmakefile before checkeding it in?
It is not possible to test changes to this Mmakefile without
first checking in, since the install_webpage script checks
out the latest version of the Mmakefile when installing the
web pages. This problem should be fixed.
Estimated hours taken: 0.3
Added Mmakefile for installing web docs.
mercury/compiler/notes/Mmakefile:
We need an Mmakefile to install these developer documents
into the webpages in the `developer' directory.
Estimated hours taken: 0.05
Add two new items to the TODO list.
compiler/notes/TODO:
- Add extended DCGs to wish list, and removing limitation on
monomorphic higher order terms to TODO list.
Estimated hours taken: 0.2
COMPILER_DESIGN:
Document modules mode_debug, modecheck_call and modecheck_unify.
Changed references to *.pp files since we don't use them any more.
Estimated hours taken: 2.5
Rewrite and clarify review policy.
compiler/notes/CODING_STANDARDS:
Remove most of the text on reviews, move it into REVIEWS.
Put in a reference to REVIEWS.
compiler/notes/REVIEWS:
New document, describes review procedures and policies.
Estimated hours taken: 0.25
compiler/notes/COMPILER_DESIGN
Updated now that common.m and excess.m are no longer separate passes.
compiler/notes/TODO
Remove duplicate call warning.