Estimated hours taken: 4
(a) Move the tabling builtins, which are currently in private_builtin.m,
into a different module which is only imported if the source contains
a tabling pragma.
(b) Improve the infrastructure for automatically importing modules to
make it easy to automatically import a module only if a certain option
is set. The idea is to eventually use this to put the simplified HLDS
representation used for declarative debugging in a module which is
only imported if the appropriate declarative debugging option is
enabled.
compiler/modules.m:
Change add_implicit_imports so that it takes the list of
items, for (a) above, and an io__state pair, for (b) above.
Change its callers to pass the new parameters.
Add a new predicate get_implicit_dependencies
(implemented using add_implicit_imports).
compiler/hlds_module.m:
compiler/module_qual.m:
Call get_implicit_dependencies rather than duplicating the code.
compiler/make_hlds.m:
compiler/hlds_module.m:
Pass the item_list to module_info_init, since it's needed by
get_implicit_dependencies.
compiler/prog_util.m:
Add new predicates mercury_table_builtin_module/1 (which
returns the name of the "table_builtin" module) and
any_mercury_builtin_module (which checks whether any of
mercury_{table,public,private}_builtin_module hold).
compiler/termination.m:
Call any_mercury_builtin_module rather than checking
for mercury_{public,private}_builtin_module.
compiler/table_gen.m:
Change the module for tabling builtins from private_builtin to
table_builtin.
compiler/hlds_pred.m:
Add table_builtin to the builtin_mod enumeration,
and change the module for tabling builtins from
private_builtin to table_builtin.
compiler/dead_proc_elim.m:
Add a comment about the treatment of builtin modules.
compiler/mode_util.m:
When stripping out builtin module qualifiers, only strip
qualifiers from "builtin:", not from "private_builtin:".
library/table_builtin.m:
library/private_builtin.m:
Move the tabling builtins from private_builtin.m
into a new module table_builtin.m.
library/library.m:
Add table_builtin.m to the list of imported modules.
(Likewise for builtin.m and private_builtin.m; it's not
strictly necessary for those, since they're implicitly
imported anyway, but importing them explicitly is clearer.)
library/io.m:
Change private_builtin to table_builtin in the call to
private_builtin__report_tabling_stats.
doc/Mmakefile:
Don't include the documentation for table_builtin.m
in the library reference manual.
Estimated hours taken: 30
Add impure functions to Mercury, clean up the purity module somewhat,
fix some bugs in purity, update and expand the purity documentation,
and re-organize the purity checks.
Impure functions can be declared just like impure preds.
However, they can only be called in an explicit unification preceeded
by a purity level:
impure X = some_impure_func(Y, Z)
The bug fixed was the fact that closures of impure predicates
were only being detected when using lambda syntax. Purity information
was discarded and impure closures could be created like this:
Pred = some_impure_pred
You could then use this predicate anywhere you like without any purity
declarations.
compiler/hlds_module.m:
Add get_pred_id pred which will return the pred_id of a
predicate matching a given type. This is like
get_pred_and_proc_id, but only gets the information we are
interested in, and is semidet.
We need a semidet version to handle cases where type inference
cannot infer a type before the limit is reached, but we try to
purity check this code. (The bug mentioned above was stopping
us from purity checking the test case for this before).
compiler/make_hlds.m:
Check for "impure" unifications with expressions that are not
function calls and issue appropriate error messages.
When unravelling impure function call unifications, put the input
parameter unifications (if any) before the actual call.
Only mark the goal_info for the function call as impure.
compiler/mercury_to_goedel.m:
compiler/mercury_to_mercury.m:
compiler/module_qual.m:
compiler/prog_data.m:
compiler/prog_io.m:
compiler/prog_io_dcg.m:
compiler/prog_io_goal.m:
compiler/prog_util.m:
Add purity information to unify goals.
Don't assume unify goals are pure.
compiler/purity.m:
Allow impure functions.
Check unification goals for purity (not just lambda unification).
Check unifications that are transformed into calls to make sure
the call is purity correct.
Put purity checking logic into separate predicates.
Use an enum to return different errors and warnings.
(The last two changes make it much easier to see the
similarities between checking goals and checking predicates for
purity correctness).
Give different error messages for impure functions (highlight
that you need to use them in an explicit unification).
Handle unknown predicate lookups (can occur when unifying with
a higher order term whose type could not be inferred).
Add a few comments delineating where changes might need to be
made to make foreign code impure by default in future.
compiler/notes/authors.html:
Add Peter Schachte to the authors list.
doc/reference_manual.texi:
Document impure functions.
Expand more on what impure predicates/functions can do.
Explain the concept of worst purity, and use it to explain the
"inferred purity"/"declared purity" concepts.
Make it more explicit that only impure goals obey
strict-sequential like semantics.
tests/invalid/type_inf_loop.err_exp2:
Fix this test case to reflect the new error message new that we
check the purity of this code correctly (or rather, we correctly
fail to be able to purity check this code).
tests/hard_coded/Mmakefile:
tests/hard_coded/purity.exp:
tests/hard_coded/purity.m:
tests/hard_coded/purity/Mmakefile:
tests/hard_coded/purity/impure_func_t1.m:
tests/hard_coded/purity/purity.m:
tests/hard_coded/purity/runtests:
Remove purity tests from the hard_coded directory, give it a
sub-directory of its own.
tests/invalid/Mmakefile:
tests/invalid/purity.err_exp:
tests/invalid/purity.m:
tests/invalid/purity_nonsense.err_exp:
tests/invalid/purity_nonsense.m:
tests/invalid/purity/Mmakefile:
tests/invalid/purity/impure_func_t2.err_exp:
tests/invalid/purity/impure_func_t2.m:
tests/invalid/purity/impure_func_t3.err_exp:
tests/invalid/purity/impure_func_t3.m:
tests/invalid/purity/impure_func_t4.err_exp:
tests/invalid/purity/impure_func_t4.m:
tests/invalid/purity/impure_func_t5.err_exp:
tests/invalid/purity/impure_func_t5.m:
tests/invalid/purity/impure_pred_t1.err_exp:
tests/invalid/purity/impure_pred_t1.m:
tests/invalid/purity/impure_pred_t2.err_exp:
tests/invalid/purity/impure_pred_t2.m:
tests/invalid/purity/purity.err_exp:
tests/invalid/purity/purity.m:
tests/invalid/purity/purity_nonsense.err_exp:
tests/invalid/purity/purity_nonsense.m:
tests/invalid/purity/runtests:
Remove purity tests from the invalid directory, give it a
sub-directory of its own.
Estimated hours taken: 12
Allow functions to be declared by supplying the determinism but not the
modes (we assume the default modes).
compiler/make_hlds.m:
Assume default modes if determinism is declared without modes
in the :- func declaration.
compiler/prog_io.m:
Don't give an error message for determinism without modes for
function.
compiler/prog_io_goal.m:
Update documentation to reflect default mode syntax.
Assume default modes if determinism is declared without modes
in lambda expressions.
compiler/prog_util.m:
Mention that declaring modes for some but not all of the
arguments of a function will be noticed in prog_io, so shouldn't
be a concern in this code.
doc/reference_manual.texi:
Document the new syntax.
tests/valid/Mmakefile:
tests/valid/func_default_modes.m:
A test case for the new syntax.
Estimated hours taken: 70
Implement syntax for getting and setting fields of constructors.
compiler/make_hlds.m:
Add information about field definitions to the module_info.
Check that user-defined field access functions for exported
fields are also exported, otherwise predicates in other modules
could use a different method to access a field than predicates
in module defining the field.
Add a `predicate preds_add_implicit_report_error' to allow that check
to be performed for functions which are added to the module_info
by some means other than a `:- func' declaration.
Parse field access goals and expressions.
Add predicates `insert_arg_unifications_with_supplied_contexts',
and `append_arg_unification', which allow more control over
the contexts given to the added unifications. These are
useful because the field value for an update is really an
argument of the inner-most update function call, while the
input term is an argument of the outer-most function call.
compiler/prog_io_dcg.m:
Allow DCG goals of the form `:=(DCGArg)', which unifies `DCGArg'
with the output DCG argument, ignoring the input DCG argument.
The rationale for this change is that if we have convenient syntax
for updating parts of a DCG argument, we should also have convenient
syntax for updating the whole DCG argument.
compiler/typecheck.m:
Add a default clause for field access functions for which
the user has supplied type and mode declarations but no
clauses.
Typecheck field access function calls.
Use `io__write_list' to remove some duplication of code
to write out comma separated lists of error descriptions.
compiler/post_typecheck.m:
Expand field accessor goals into the equivalent unifications.
They are expanded inline rather than generating new get and set
predicates for field name to avoid having to work out how to mode
the generated predicates.
Remove an unnecessary goal traversal to qualify function
calls and constructors. That code is now called from purity.m.
compiler/prog_data.m:
compiler/prog_io.m:
compiler/mercury_to_goedel.m:
compiler/mercury_to_mercury.m:
Store field names as `sym_name's rather than strings.
Use a `maybe' type rather than an empty string to designate
an unlabelled field.
compiler/hlds_data.m:
Define data structures to hold information about
the field names visible in a module.
compiler/hlds_module.m:
Add a field to type module_info to hold information
about the fields visible in a module.
compiler/hlds_pred.m:
Add predicates to identify field access function names,
and to handle the arguments of field access functions.
compiler/make_hlds.m:
compiler/hlds_goal.m:
compiler/modecheck_call.m:
compiler/higher_order.m:
compiler/purity.m:
compiler/polymorphism.m:
compiler/dnf.m:
compiler/cse_detection.m:
compiler/lambda.m:
Move `create_atomic_unification' from make_hlds.m to hlds_goal.m
because it is used by several other modules.
compiler/hlds_goal.m:
Add a version of goal_info_init which takes the context of
the goal, for use by make_hlds.m.
compiler/type_util.m:
Add a predicate `type_util__get_type_and_cons_defn' to
get the hlds_type_defn and hlds_cons_defn for a user-defined
constructor.
compiler/prog_util.m:
Add predicates to add and remove prefixes or suffixes
from the unqualified part of a sym_name.
compiler/prog_out.m:
Add a predicate to convert a `sym_name/arity' to a string.
compiler/hlds_out.m:
Add `hlds_out__simple_call_id_to_string' to convert a
`pred_or_func - sym_name/arity' to a string for use in
error messages.
compiler/purity.m:
Thread through the pred_info so that the expansion of field accessor
goals can add new variables.
compiler/mercury_to_mercury.m:
library/ops.m:
Reduce precedence of `^/2' for use as a field name separator.
Add operator `^'/1 to designate which side of the `:=' is
the field name in a DCG field access goal.
Add operator `:=/2' for field update expressions.
doc/reference_manual.texi:
Document the new syntax.
doc/transition_guide.texi:
Document the new operators.
tests/hard_coded/Mmakefile:
tests/hard_coded/record_syntax.m:
tests/hard_coded/record_syntax.exp:
tests/invalid/Mmakefile:
tests/invalid/record_syntax_errors.m:
tests/invalid/record_syntax_errors.err_exp:
Test cases.
Estimated hours taken: 10
Fix the remaining bugs with the handling of partial qualifiers
for nested modules.
compiler/module_qual.m:
Define a new abstract type partial_qualifier_info, and a predicate
mq_info_get_partial_qualifier_info to get this type from the mq_info.
Define a new predicate get_partial_qualifiers/3 in module_qual.m
which is like the old get_partial_qualifiers/2 predicate from
modules.m except that it takes a partial_qualifier_info and
uses the information in this to return only the partial qualifiers
for modules which are visible, rather than returning all partial
qualifier regardless of whether the modules that they refer to
are in scope or not.
compiler/prog_util.m:
Export the `insert_module_qualifier' predicate, for use in the
definition of get_partial_qualifiers/3.
compiler/hlds_module.m:
compiler/make_hlds.m:
Change the code for make_hlds__ctors_add and
hlds_module__pred_table_insert/5 so that they handles partial
qualifiers properly, computing the partial qualifiers by
calling get_partial_qualifiers/3 rather than by checking the
NeedQual variable and calling get_partial_qualifiers/2.
compiler/modules.m:
Delete the old get_partial_qualifiers/2 predicate.
compiler/hlds_module.m:
Add a new field to the HLDS containing the partial_qualifier_info.
Add a partial_qualifier_info parameter to pred_table_insert/5.
compiler/check_typeclass.m:
compiler/make_hlds.m:
When calling pred_table_insert/5, get the partial_qualifier_info
from the HLDS and pass it as an extra argument.
tests/hard_coded/sub-modules/nested.m:
tests/hard_coded/sub-modules/nested3.m:
tests/hard_coded/sub-modules/parent.m:
tests/hard_coded/sub-modules/nested.exp:
tests/hard_coded/sub-modules/nested3.exp:
tests/hard_coded/sub-modules/parent.exp:
Uncomment parts of these test cases which were previously
commented out because they were not yet supported.
doc/reference_manual.texi:
Delete the description of this bug.
Estimated hours taken: 4
Move some declarations around and make some other minor changes in order
to reduce the number and complexity of the intermodule dependencies.
In particular, ensure that prog_data.m does not need to import
hlds*.m, purity.m, rl.m, or term_util.m.
Since we expect to have only one input language, but potentially many
different target languages, the general design principle that we have adopted
in order to minimize the number of dependencies, particularly cyclic ones,
is that modules which belong to an earlier stage of compilation should
not depend on modules which belong to a later stage of compilation.
However, that design principle has not been adhered to in many cases.
This change reduces the number of such cases.
compiler/prog_data.m:
compiler/hlds_pred.m:
Move definition of the types `eval_method' and `pred_or_func'
from hlds_pred.m to prog_data.m.
Add new type `mode_num' to prog_data.m, defined by
`type mode_num == int', and change the proc_id argument of
the `unused_args' pragma to instead use this type instead of proc_id.
Delete the import of module hlds_pred from prog_data.m.
compiler/prog_data.m:
compiler/hlds_data.m:
Move the definition of the type `determinism' from hlds_data.m to
prog_data.m. Delete the import of module hlds_data from prog_data.m.
compiler/prog_data.m:
compiler/purity.m:
Move the definition of the type `purity' from purity.m to prog_data.m.
Add import of module prog_data to purity.m.
Delete the import of module purity from prog_data.m.
This is needed because purity.m imports hlds*.m and so by
importing purity.m, prog_data.m was indirectly importing hlds*.m.
(An possible alternative here would be to split purity.m into two
parts, called say purity.m and check_purity.m; of these, only the
second would import hlds*.m. But that would be a significantly
more complicated change.)
compiler/prog_data.m:
compiler/rl.m:
Move the definition of the `index_spec' and `index_type' types from
rl.m to prog_data.m. Delete the import of module rl from prog_data.m.
compiler/prog_data.m:
Add new types `pragma_arg_size_info' and `pragma_termination_info'
to prog_data.m. These are similar to the existing types
`arg_size_info' and `termination_info' defined in term_util.m,
except that they correspond more directly to what is actually
used in `pragma termination_info' declarations.
compiler/term_util.m:
Add new predicates `add_context_to_arg_size_info' and
`add_context_to_pragma_termination_info' for converting
the prog_data types to their corresponding term_util types.
compiler/make_hlds.m:
compiler/mercury_to_mercury.m:
compiler/prog_io_pragma.m:
compiler/unused_args.m:
Minor modifications to handle the change in the type of the
mode number argument in `unused_args' pragmas, and in the types
of the arg_size_info and termination_info arguments in
`termination_info' pragmas.
compiler/mercury_to_mercury.m:
compiler/prog_io_pragma.m:
compiler/inst.m:
compiler/make_hlds.m:
compiler/call_gen.m:
compiler/common.m:
compiler/continuation_info.m:
compiler/det_report.m:
compiler/hlds_pred.m:
compiler/lambda.m:
compiler/magic_util.m:
compiler/modecheck_call.m:
compiler/prog_io_goal.m:
compiler/prog_io_util.m:
compiler/prog_util.m:
compiler/termination.m:
Delete imports of modules purity, rl, and hlds_pred, or
move them from the interface section to the implementation section.
compiler/inst.m:
compiler/prog_io_util.m:
Add an XXX comment explaining why we need to import hlds_data.m.
Estimated hours taken: 0.25
compiler/prog_util.m:
Undo the part of my previous change to make_pred_name_with_context
which reordered some elements of the generated name.
Estimated hours taken: 60
User-guided type specialization.
compiler/prog_data.m:
compiler/prog_io_pragma.m:
compiler/modules.m:
compiler/module_qual.m:
compiler/mercury_to_mercury.m:
Handle `:- pragma type_spec'.
compiler/prog_io_pragma.m:
Factor out some common code to parse predicate names with arguments.
compiler/hlds_module.m:
Added a field to the module_sub_info to hold information about
user-requested type specializations, filled in by make_hlds.m
and not used by anything after higher_order.m.
compiler/make_hlds.m:
For each `:- pragma type_spec' declaration, introduce a new predicate
which just calls the predicate to be specialized with the
specified argument types. This forces higher_order.m to produce
the specialized versions.
compiler/higher_order.m:
Process the user-requested type specializations first to ensure
that they get the correct names.
Allow partial matches against user-specified versions, e.g.
map__lookup(map(int, list(int)), int, list(int)) matches
map__lookup(map(int, V), int, V).
Perform specialization where a typeclass constraint matches a
known instance, but the construction of the typeclass_info is
done in the calling module.
Give slightly more informative progress messages.
compiler/dead_proc_elim.m:
Remove specializations for dead procedures.
compiler/prog_io_util.m:
Change the definition of the `maybe1' and `maybe_functor' types
to avoid the need for copying to convert between `maybe1'
and `maybe1(generic)'.
Changed the interface of `make_pred_name_with_context' to allow
creation of predicate names for type specializations which describe
the type substitution.
compiler/make_hlds.m:
compiler/prog_io_pragma.m:
Make the specification of pragma declarations in error
messages consistent. (There are probably some more to
be fixed elsewhere for termination and tabling).
compiler/intermod.m:
Write type specialization pragmas for predicates declared
in `.opt' files.
compiler/mercury_to_mercury.m:
Export `mercury_output_item' for use by intermod.m.
compiler/options.m:
Add an option `--user-guided-type-specialization' enabled
with `-O2' or higher.
compiler/handle_options.m:
`--type-specialization' implies `--user-guided-type-specialization'.
compiler/hlds_goal.m:
Add predicates to construct constants. These are duplicated
in several other places, I'll fix that as a separate change.
compiler/type_util.m:
Added functions `int_type/0', `string_type/0', `float_type/0'
and `char_type/0' which return the builtin types.
These are duplicated in several other places,
I'll fix that as a separate change.
library/private_builtin.m:
Added `instance_constraint_from_typeclass_info/3' to extract
the typeclass_infos for a constraint on an instance declaration.
This is useful for specializing class method calls.
Added `thread_safe' to various `:- pragma c_code's.
Added `:- pragma inline' declarations for `builtin_compare_*', which
are important for user-guided type specialization. (`builtin_unify_*'
are simple enough to go in the `.opt' files automatically).
compiler/polymorphism.m:
`instance_constraint_from_typeclass_info/3' does not need type_infos.
Add `instance_constraint_from_typeclass_info/3' to the
list of `typeclass_info_manipulator's which higher_order.m
can interpret.
NEWS:
doc/reference_manual.texi:
doc/user_guide.texi
Document the new pragma and option.
tests/invalid/Mmakefile:
tests/invalid/type_spec.m:
tests/invalid/type_spec.err_exp:
Test error reporting for invalid type specializations.
tests/hard_coded/Mmakefile:
tests/invalid/type_spec.m:
tests/invalid/type_spec.exp:
Test type specialization.
Estimated hours taken: 20
These changes make `var' and `term' polymorphic. This allows us to make
variables and terms representing types of a different type to those
representing program terms and those representing insts.
These changes do not *fix* any existing problems (for instance
there was a messy conflation of program variables and inst variables,
and where necessary I've just called varset__init(InstVarSet) with
an XXX comment).
NEWS:
Mention the changes to the standard library.
library/term.m:
Make term, var and var_supply polymorphic.
Add new predicates:
term__generic_term/1
term__coerce/2
term__coerce_var/2
term__coerce_var_supply/2
library/varset.m:
Make varset polymorphic.
Add the new predicate:
varset__coerce/2
compiler/prog_data.m:
Introduce type equivalences for the different kinds of
vars, terms, and varsets that we use (tvar and tvarset
were already there but have been changed to use the
polymorphic var and term).
Also change the various kinds of items to use the appropriate
kinds of var/varset.
compiler/*.m:
Thousands of boring changes to make the compiler type correct
with the different types for type, program and inst vars and
varsets.
configure.in:
Add a test to find the number of words needed to represent a
synchronization term.
boehm_gc/gc.h:
fix a declaration by replacing the args () with (void).
boehm_gc/solaris_pthreads.c:
add a missing include
check the return values of pthread calls.
compiler/*.m:
Add handling for the new HLDS goal type par_conj.
Add handling for the four new LLDS instructions:
init_sync_term
fork
join_and_terminate
join_and_continue
compiler/code_info.m:
add a new alternative for slot_contents - sync_term.
compiler/handle_options.m:
add .par as part of the grade
compiler/hlds_goal.m:
add the new goal type par_conj.
compiler/instmap.m:
add instmap__unify which takes a list of instmaps
and abstractly unifies them.
add unify_instmap_delta which tajes two instmap deltas
and abstractly unifies them.
compiler/llds.m:
add the new llds instructions.
compiler/mode_info.m:
add par_conj as a lock reason.
library/Makefile:
work around a bug in the solaris version pthread.h
library/benchmarking.m:
reference the stack zones from the engine structure
rather than from global variables.
library/{nc,sp}_builtin.nl:
add an op declaration for &.
library/std_util.m:
change references to global variables to references inside
the engine structure.
runtime/Mmakefile:
add mercury_thread.{c,h}
add THREADLIBS to the libraries
runtime/*.{c,h}
Remove some old junk from the previous processes/shrd-mem
changes that found their way into the repository.
Add MR_ prefixes to lots of names.
runtime/mercury_context.c:
Add init_thread_stuff for creating and initializing a
context structure for the current thread.
runtime/mercury_context.h:
add a field to the mercury context which stores the thread id
of the thread where this context originated.
add various macros for implementing the new llds instructions.
runtime/mercury_engine.c:
initialize the engine structure, rather than a bunch of globals.
runtime/mercury_engine.h:
declare the mercury_engine structure.
runtime/mercury_regorder.h:
if MR_THREAD_SAFE, and there is at least one global register
then use mr0 as a pointer to the mercury engine structure.
scripts/init_grade_options.sh-subr
add thread_safe
scripts/mgnuc.in
add THREAD_OPTS
scripts/ml.in:
add THREAD_LIBS
Estimated hours taken: 6
Fix various invasions of the user's namespace by `mercury_builtin.m',
by splitting mercury_builtin.m into two modules, called builtin.m and
private_builtin.m, and ensuring that the latter is imported as if
by `:- use_module' rather than `:- import_module'.
library/builtin.m:
library/private_builtin.m:
Split mercury_builtin.m into two modules, builtin.m,
which contains stuff intended to be public,
and private_builtin.m, which contains implementation
details that are not supposed to be public.
library/mercury_builtin.m:
Add a comment saying that this module is no longer used, and
should eventually be removed. I have not removed it yet, since
that would prevent bootstrapping with the current compiler. It
will be removed as a seperate change later, once all the
changes have propagated.
compiler/prog_util.m:
Change the definition of mercury_private_builtin_module/1 and
mercury_public_builtin_module so that instead of automatically
importing mercury_builtin.m as if by `import_module', the
copiler will now automatically import builtin.m as if by
`import_module' and private_builtin.m as if by `use_module'.
compiler/polymorphism.m:
Change a call to mercury_private_builtin_module/1 for
unsafe_promise_unique to instead call mercury_public_builtin_module/1.
compiler/unify_proc.m:
Avoid hard-coding "mercury_builtin" by instead
calling one of mercury_{private,public}_builtin_module/1.
runtime/mercury_type_info.[ch]:
library/term.m:
library/std_util.m:
compiler/code_util.m:
Change a few hard-coded instances of "mercury_builtin"
to "builtin" or "private_builtin" as appropriate.
runtime/mercury_trace_util.c:
runtime/mercury_trace_internal.c:
library/prolog.m:
compiler/*.m:
Update comments that refer to "mercury_builtin" to instead
refer to either "builtin" or "private_builtin".
doc/Mmakefile:
Don't include the interface to private_builtin.m in the
library reference manual.
tools/bootcheck:
Add `-p'/`--copy-profiler' option. This is needed to get
the above changes to bootstrap.
tools/test_mercury:
Pass `-p' to tools/bootcheck.
tests/term/*.trans_opt_exp:
s/mercury_builtin/builtin/g
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: 50
Add support for nested modules.
- module names may themselves be module-qualified
- modules may contain `:- include_module' declarations
which name sub-modules
- a sub-module has access to all the declarations in the
parent module (including its implementation section).
This support is not yet complete; see the BUGS and LIMITATIONS below.
LIMITATIONS
- source file names must match module names
(just as they did previously)
- mmc doesn't allow path names on the command line any more
(e.g. `mmc --make-int ../library/foo.m').
- import_module declarations must use the fully-qualified module name
- module qualifiers must use the fully-qualified module name
- no support for root-qualified module names
(e.g. `:parent:child' instead of `parent:child').
- modules may not be physically nested (only logical nesting, via
`include_module').
BUGS
- doesn't check that the parent module is imported/used before allowing
import/use of its sub-modules.
- doesn't check that there is an include_module declaration in the
parent for each module claiming to be a child of that parent
- privacy of private modules is not enforced
-------------------
NEWS:
Mention that we support nested modules.
library/ops.m:
library/nc_builtin.nl:
library/sp_builtin.nl:
compiler/mercury_to_mercury.m:
Add `include_module' as a new prefix operator.
Change the associativity of `:' from xfy to yfx
(since this made parsing module qualifiers slightly easier).
compiler/prog_data.m:
Add new `include_module' declaration.
Change the `module_name' and `module_specifier' types
from strings to sym_names, so that module names can
themselves be module qualified.
compiler/modules.m:
Add predicates module_name_to_file_name/2 and
file_name_to_module_name/2.
Lots of changes to handle parent module dependencies,
to create parent interface (`.int0') files, to read them in,
to output correct dependencies information for them to the
`.d' and `.dep' files, etc.
Rewrite a lot of the code to improve the readability
(add comments, use subroutines, better variable names).
Also fix a couple of bugs:
- generate_dependencies was using the transitive implementation
dependencies rather than the transitive interface dependencies
to compute the `.int3' dependencies when writing `.d' files
(this bug was introduced during crs's changes to support
`.trans_opt' files)
- when creating the `.int' file, it was reading in the
interfaces for modules imported in the implementation section,
not just those in the interface section.
This meant that the compiler missed a lot of errors.
library/graph.m:
library/lexer.m:
library/term.m:
library/term_io.m:
library/varset.m:
compiler/*.m:
Add `:- import_module' declarations to the interface needed
by declarations in the interface. (The previous version
of the compiler did not detect these missing interface imports,
due to the above-mentioned bug in modules.m.)
compiler/mercury_compile.m:
compiler/intermod.m:
Change mercury_compile__maybe_grab_optfiles and
intermod__grab_optfiles so that they grab the opt files for
parent modules as well as the ones for imported modules.
compiler/mercury_compile.m:
Minor changes to handle parent module dependencies.
(Also improve the wording of the warning about trans-opt
dependencies.)
compiler/make_hlds.m:
compiler/module_qual.m:
Ignore `:- include_module' declarations.
compiler/module_qual.m:
A couple of small changes to handle nested module names.
compiler/prog_out.m:
compiler/prog_util.m:
Add new predicates string_to_sym_name/3 (prog_util.m) and
sym_name_to_string/{2,3} (prog_out.m).
compiler/*.m:
Replace many occurrences of `string' with `module_name'.
Change code that prints out module names or converts
them to strings or filenames to handle the fact that
module names are now sym_names intead of strings.
Also change a few places (e.g. in intermod.m, hlds_module.m)
where the code assumed that any qualified symbol was
fully-qualified.
compiler/prog_io.m:
compiler/prog_io_goal.m:
Move sym_name_and_args/3, parse_qualified_term/4 and
parse_qualified_term/5 preds from prog_io_goal.m to prog_io.m,
since they are very similar to the parse_symbol_name/2 predicate
already in prog_io.m. Rewrite these predicates, both
to improve maintainability, and to handle the newly
allowed syntax (module-qualified module names).
Rename parse_qualified_term/5 as `parse_implicit_qualified_term'.
compiler/prog_io.m:
Rewrite the handling of `:- module' and `:- end_module'
declarations, so that it can handle nested modules.
Add code to parse `include_module' declarations.
compiler/prog_util.m:
compiler/*.m:
Add new predicates mercury_public_builtin_module/1 and
mercury_private_builtin_module/1 in prog_util.m.
Change most of the hard-coded occurrences of "mercury_builtin"
to call mercury_private_builtin_module/1 or
mercury_public_builtin_module/1 or both.
compiler/llds_out.m:
Add llds_out__sym_name_mangle/2, for mangling module names.
compiler/special_pred.m:
compiler/mode_util.m:
compiler/clause_to_proc.m:
compiler/prog_io_goal.m:
compiler/lambda.m:
compiler/polymorphism.m:
Move the predicates in_mode/1, out_mode/1, and uo_mode/1
from special_pred.m to mode_util.m, and change various
hard-coded definitions to instead call these predicates.
compiler/polymorphism.m:
Ensure that the type names `type_info' and `typeclass_info' are
module-qualified in the generated code. This avoids a problem
where the code generated by polymorphism.m was not considered
type-correct, due to the type `type_info' not matching
`mercury_builtin:type_info'.
compiler/check_typeclass.m:
Simplify the code for check_instance_pred and
get_matching_instance_pred_ids.
compiler/mercury_compile.m:
compiler/modules.m:
Disallow directory names in command-line arguments.
compiler/options.m:
compiler/handle_options.m:
compiler/mercury_compile.m:
compiler/modules.m:
Add a `--make-private-interface' option.
The private interface file `<module>.int0' contains
all the declarations in the module; it is used for
compiling sub-modules.
scripts/Mmake.rules:
scripts/Mmake.vars.in:
Add support for creating `.int0' and `.date0' files
by invoking mmc with `--make-private-interface'.
doc/user_guide.texi:
Document `--make-private-interface' and the `.int0'
and `.date0' file extensions.
doc/reference_manual.texi:
Document nested modules.
util/mdemangle.c:
profiler/demangle.m:
Demangle names with multiple module qualifiers.
tests/general/Mmakefile:
tests/general/string_format_test.m:
tests/general/string_format_test.exp:
tests/general/string__format_test.m:
tests/general/string__format_test.exp:
tests/general/.cvsignore:
Change the `:- module string__format_test' declaration in
`string__format_test.m' to `:- module string_format_test',
because with the original declaration the `__' was taken
as a module qualifier, which lead to an error message.
Hence rename the file accordingly, to avoid the warning
about file name not matching module name.
tests/invalid/Mmakefile:
tests/invalid/missing_interface_import.m:
tests/invalid/missing_interface_import.err_exp:
Regression test to check that the compiler reports
errors for missing `import_module' in the interface section.
tests/invalid/*.err_exp:
tests/warnings/unused_args_test.exp:
tests/warnings/unused_import.exp:
Update the expected diagnostics output for the test cases to
reflect a few minor changes to the warning messages.
tests/hard_coded/Mmakefile:
tests/hard_coded/parent.m:
tests/hard_coded/parent.child.m:
tests/hard_coded/parent.exp:
tests/hard_coded/parent2.m:
tests/hard_coded/parent2.child.m:
tests/hard_coded/parent2.exp:
Two simple tests case for the use of nested modules with
separate compilation.
Estimated hours taken: 0.75
library/*.m:
compiler/*.m:
Undo Zoltan's bogus update of all the copyright dates.
The dates in the copyright header should reflect the years
in which the file was modified (and no, changes to the
copyright header itself don't count as modifications).
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: 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: 4
passes_aux:
Flesh out the code already here for traversing module_infos,
making it suitable to handle all the passes of the back end.
mercury_compile:
Use the traversal code in passes_aux to invoke the back end passes
over each procvedure in turn. Print a one-line message for each
predicate if -v is given (this fixes a long-standing bug).
excess.m, follow_code.m, follow_vars.m, live_vars.m, lveness.m, store_alloc.m:
Remove the code to traverse module_infos, since it is now unnecessary.
export.m:
Remove an unused argument from export__produce_header_file_2.
others:
Move imports from interfaces to implementations, or in some cases
remove them altogether.
Estimated hours taken: 0.75
prog_util.m, equiv_type.m:
Split the expansion of equivlance types from prog_util.m
into a new file equiv_type.m. Use slightly clearer predicate
names, starting with equiv_type__ rather than prog_util__ of course.
mercury_compile.pp, mercury_to_goedel.m:
Changed to use equiv_type rather than prog_util.
mercury_to_goedel.m:
Move some import_module declarations from the interface to
the implementation section, since they weren't needed by the
interface.
Estimated hours taken: 1
compiler/prog_util.m:
Recommit my earlier (buggy) change to avoid looping during the
expansion of equivalence types for `:- type foo == bar(foo)',
with the bug fixed this time.
(The bug was that I was passing down the wrong set of type ids
when processing the arguments - since we process things bottom-up,
the current type-id has not yet been expanded when processing the
arguments, and it shouldn't be included in the set at that point.)
Estimated hours taken: 0.5
compiler/prog_util.m:
Back out my previous change to avoid looping for
`:- type foo == bar(foo)', since my change was buggy ---
it meant that we failed to expand some equivalence types
that we should have.
Estimated hours taken: 2
compiler/prog_util.m:
Fix a bug in the expansion of equivalence types:
the loop detection code was not quite right, and
so it looped for `:- type foo == bar(foo)'.
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: 1
prog_util:
Add a predicate to rename variables in the kinds of goals we have in
items. (We already have similar predicates for terms and for
hlds_goals).
prog_io:
We used to expand ( p ; q ) in DCG clauses to become
( p(DCG1, DCG2) ; q(DCG1, DCG3), DCG2 = DCG3 ). These extra
unifications can pile up rather badly; in the new version of lexer.m,
two 128-way switches each ended up with 90 unifications in the last
arm. This is very bad for performance. Instead of adding unifications
to make sure that both arms of a disjunction put the final stream value
in the same variable, we now use renaming when possible.
Estimated hours taken: 0.5
compiler/prog_util.m:
Fix a bug (caused by a cut-and-paste variable numbering error) in
the expansion of equivalence types in `:- func' declarations.
(Thanks to Tyson for the bug report.)
Estimated hours taken: 4
prog_util.m:
Change the expansion of equivalence types to use an O(N log N)
algorithm rather than an O(N * N) one. This change cuts
the compilation time for live_vars.m (a bad case as far as
equivalence types are concerned, since it imports so many
modules) by more than 15%.
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: 12
Implement functional syntax. You can now use `:- func' in a similar manner
to `:- pred'. For example, `:- func foo(int, int) = int.' declares a function,
and `:- mode foo(in, in) = out.' defines a mode for it. You can write clauses
for functions, such as `foo(X, Y) = Z :- Z is 2*X + Y.' Any term in the
head or body of a clause can be a function call, e.g. `bar(X, Y, foo(X, Y))'.
Until we have implemented a proper Mercury debugger, this syntax
should not be used (except that I might reimplement the functions
provided by Prolog's is/2 predicate using this syntax, rather than
the current special-case hack in the parser).
prog_io.m:
Add syntax for declaring and defining functions.
Disallow the use of `=' to define modes, as in `:- mode foo = bar.'
(Instead, you should use `::'. `==' is also allowed.)
Also, use higher-order predicates to simplify some of the rather
repetitious parsing code.
mercury_to_mercury.m, mercury_to_goedel.m, make_hlds.m, modules.m:
Handle new functional syntax.
typecheck.m:
Add support for functions, function types such as `func(int) = int',
and currying. (But there's currently no equivalent to call/N for
functions, so function types and currying aren't very useful yet.)
undef_types.m:
Add support for function types.
modes.m:
Convert function calls into predicate calls.
(This must be done after typechecking is complete,
so I put it in mode analysis.)
hlds.m:
Add new field `pred_or_func' to the pred_info.
hlds_out.m:
Print out the `pred_or_func' field.
higher_order.m, unused_args.m, lambda.m, dnf.m:
Pass extra pred_or_func argument to pred_info_init to specify that
the thing being created is a predicate, not a function.
constraint.m, dependency_graph.m, hlds_out.m:
`mercury_output_mode_subdecl' has been renamed
`mercury_output_pred_mode_subdecl'.
prog_util.m:
Add new predicate split_type_and_mode/3.
llds.m:
Print out
/* code for predicate '*'/3 in mode 0 */
rather than
/* code for predicate */3 in mode 0 */
to avoid a syntax error in the generated C code.
Estimated hours taken: 1.5
Undo dylan's changes in the names of some library entities,
by applying the following sed script
s/term_atom/term__atom/g
s/term_string/term__string/g
s/term_integer/term__integer/g
s/term_float/term__float/g
s/term_context/term__context/g
s/term_functor/term__functor/g
s/term_variable/term__variable/g
s/_term__/_term_/g
s/std_util__bool_/bool__/g
to all the `.m' and `.pp' files in the compiler and library directories.
The reason for undoing these changes was to minimize incompatibilities
with 0.4 (and besides, the changes were not a really good idea in the first
place).
I also moved `bool' to a separate module.
The main reason for that change is to ensure that the `__' prefix is
only used when it genuinely represents a module qualifier.
(That's what dylan's changes were trying to acheive, but `term__'
does genuinely represent a module qualifier.)
compiler/*.m:
Apply sed script above;
where appropriate, add `bool' to the list of imported modules.
Estimated hours taken: _2___
Change names with badly placed double underscores (ie where the part of
a name before a double underscore is not the same as the module name.)
Reflect changes in the library interface.
compiler/*:
Use the newer, more correct form of the term and bool names.
Predicates "bool__" are now "std_util__bool" and labels of
the term ADT are now "term_" instead of "term__".
compiler/vn*.m:
change all names "vn__*" to a correct module prefix. All the
names remain qualified.
compiler/hlds.m:
s/\<is_builtin__/hlds__is_builtin_/g
s/\<dependency_info__/hlds__dependency_info_/g
compiler/unify_proc.m:
s/\<unify_proc_info__/unify_proc__info_/g
compiler/transform.m:
s/\<reschedule__conj/transform__reschedule_conj/g
frameopt:
Look inside blocks introduced by value numbering when looking
restorations of succip.
value_number, opt_util:
If we are using conservative garbage collection, disable value
numbering for blocks that allocate more than one cell on the heap.
This allows value numbering of most blocks to work in the absence
of -DALL_INTERIOR_POINTERS.
all other source files:
Clean up "blank" lines that nevertheless contain space or tab
characters.
compiler/*:
Add copyright messages.
Change all occurences of *.nl in comments to *.m.
compiler/mercury_compile.pp:
Change the output to the .dep files to use *.m rather than *.nl.
(NOTE: this means that `mmake' will not work any more if you
call your files *.nl!!!)
code_util.nl:
Fix bug in make_proc_label: for unification predicates,
look at the _last_ argument to determine the type for
name mangling, not the first, since we introduce extra
higher-order arguments at the start.
make_hlds.nl, hlds.nl:
Ensure that the proc_info head_vars has the right length even for
imported predicates. This fixes a problem with --polymorphism.
make_hlds, unify_proc.nl, prog_util.nl:
Output unification procedures for equivalence types.
polymorphism.nl:
Ensure that this works even for unification procedures for
equivalence types, which are a bit wierd since they are not
quite type correct.
typecheck.nl:
Don't attempt to typecheck unification predicates, since
they are already type-correct when we construct them.
In particular don't typecheck unification procedures for
equivalence types, since it would report a spurious error.
mercury_to_mercury.nl:
Remove a superfluous duplicate clause.
term.nl:
In term__create_var, use bit reversals rather than random numbers
to ensure that the binary trees remain balanced.
call_gen.nl:
For polymorphic unifications, generate a call to fatal_error().
code_gen.nl, hlds.nl, make_hlds.nl, modes.nl, unify_proc.nl:
Move the unify_request data structure from code_info to the HLDS,
and move the unify_request handling from code_gen.nl to modes.nl.
This is because we now generate HLDS code rather than LLDS code
for complicated unifications.
code_util.nl, hlds_out.nl:
Do some special name mangling for =/2.
float.nl, typecheck.nl, undef_types.nl, term.nl, hlds.nl:
Until we implement `float' properly, define it as an abstract type
in float.nl.
hlds.nl, make_hlds.nl:
Rename `local_pred, imported_pred, exported_pred' to just
`local, imported, exported' since they also apply to types, etc.,
not just to preds.
mercury_compile.pp, mercury_to_goedel.nl, prog_util.nl:
Replace to goedel__ prefixes in prog_util.nl with prog_util__.
std_util.nl:
Change the code for semidet_succeed to avoid determinism warning.
Makefile.mercury:
Override the MERCURY_LIB_OBJS variable when invoking ml.
This avoids some bootstrapping problems.
Also, add mercury_compile.nu.
Makefile.common:
Bump NU-Prolog's -u option up to 2000 (8M), to avoid some memory
problems.
array.nl, bintree.nl, char.nl, dir.nl, globals.nl, list.nl, map.nl, modes.nl,
prog_util.nl, stack.nl, std_util.nl, string.nl, term.nl:
Avoid the use of implied modes.
code_info.nl, bimap.nl, make_hlds.nl, mercury_compile.nl,
mercury_to_mercury.nl, unify_proc.nl:
Fix determinism errors which had previously not been discovered
because of either implied modes or running out of memory.
(Note that I had to change the interface to bimap__lookup, since
it's not possible to make it bidirectional.)
code_util.nl, llds.nl, opt_debug.nl, value_number.nl:
Rename `operator' as `binary_op'.
hlds.nl, code_info.nl, unify_gen.nl, llds.nl, opt_debug.nl, switch_gen.nl:
*** Handle simple cases of higher-order pred terms. ***
(We don't yet handle taking the address of an overloaded
predicate or a predicate with multiple modes.
We don't handle closures. call/1 and call/N are not yet implemented.
This has not yet been tested.)
make_hlds.nl:
Modify the mode priority ordering so that semidet modes get
selected before det ones.
llds.nl:
Don't include the priority part of the mode number in the mangled
label name. *** Note: this will break some things! ***
mercury_compile.nl:
Move the NU-Prolog hacks into mercury_compile.nu.nl.
switch_gen.nl:
Fix a simple logic bug in handling the grab/slap of the code_info.
prog_io.nl, builtins.nl, int.nl:
Fix bugs and omissions with handling of the new arithmetic operators.
prog_io.nl:
As a quick hack, strip off calls to io__gc_call
(this avoids spurious error messages which are due to
the fact that we don't get mode analysis right in those cases).
bintree.nl, map.nl, varset.nl:
Remove map__search_insert; it's not needed and it's not
really useful.
bintree.nl:
Fix determinism problem in bintree__from_list_2.
options.nl, det_analysis.nl, make_hlds.nl:
Add options to suppress determinism warnings.
det_analysis.nl, hlds.nl, modes.nl:
Allow the delta-instmap to be `unreachable'.
hlds_out.nl:
Output the delta-instmap.
Output conjunctions differently in verbose mode.
llds.nl:
Fix determinism problem.
Change GOTO(LABEL(...)) into GOTO_LABEL(...) which can be
more efficient.
map.nl:
Add map__overlay/3.
typecheck.nl, modes.nl, mode_errors.nl, options.nl, hlds_out.nl.
Split the old `debug' option into debug-types and debug-modes.
Change the default for the `modecheck' option to `yes'.
Add a new verbose-dump-hlds option, and use that instead
of the very-verbose option in hlds_out.nl.
mode_util.nl:
Export mode_get_insts/4.
Add instmap_lookup_var (moved from modes.nl).
Add apply_instmap_delta.
modes.nl, term.nl, prog_util.nl:
Add determinism annotations.
term.nl, prog_io.nl:
Fix bugs in when declarations.
std_util.nl, prog_io.nl:
Add a maybe(T) type to std_util.nl.
Rename the maybe(T) type in prog_io.nl as maybe1(T).
mercury_builtin.nl:
Use det_pred(...), semidet_pred(...), nondet_pred(...)
rather than call_pred(...) for the higher-order predicate modes.
prog_io.nl, io.nl, varset.nl, etc.
Add determinism annotations.
hlds.nl, make_hlds.nl, LOTS of other files:
Reorganize the way the predicate table works.
Make hlds.nl a bit more modular.
Change call/4 to call/5.
Remove all/2 from the hlds.
Changed pred_id to an integer.
Added pred_call_id which is similar to the old pred_id.
Makefile:
Add a rule for creating *.hlds_dump.
array.nl:
Fix determinism error.
det_analysis.nl:
Fix a bug in printing determinism warnings.
fix_errors.sed:
Modify this so it allows all the `inferred nondet' determinism
errors but none of the `inferred semidet' ones.
llds.nl:
Rename llds__pred_mode_id as llds__proc_id.
mode_errors.nl:
Finally got around to implementing Zoltan's suggestions
about the error messages from the mode analysis.
If an error occurs in a conjunction, only one error message
is printed out - the first error which doesn't relate to
a head unification.
modes.nl:
Handle X = f(X) properly. NB: determinism analysis and code
generation still get it wrong!
undef_modes, undef_insts:
I've broken the error message code, since it's not easy
to print pred_ids. I just changed it so that it didn't
print the pred_ids out. Should fix this properly at some stage...
modes.nl, mode_errors.nl, delay_info.nl, mode_info.nl, undef_modes.nl:
Break modes.nl up into separate modules.
toplevel.nl (plus LOTS of other files):
Change the way module imports are handled. Fix the resulting missing
import problems found in most of the modules.
mode_util.nl:
Add predicate inst_is_bound_to_functors/3.
switch_detection.nl:
New file. Still very incomplete.
meta.nl:
Remove. This file was old junk.
make_hlds.nl:
Fix bugs in the implicit quantification.
Makefile, doit.nl:
Add stack.nl.
det_analysis.nl:
Fix minor bug in the error message.
interpreter.nl:
Print out the answers to the query.
mercury_to_mercury:
Added mercury_output_hlds_goal.
Also export mercury_output_vars.
modes.nl:
Handle reordering of conjunctions.
Handle variable locking in all cases.
(Complete, but probably needs some bug fixes.)
prog_util.nl:
Fix another goddamned bug in the type-checker - I thought
we'd killed the last of those! This one was a problem
in the expansion of equivalence types - failed for map(map(...)).
prog_io.nl:
An error message was omitting the file name & line number.
Also ensure that all error messages start with "error:".
codegen.nl, interpreter.nl, bintree.nl, list.nl:
Fix stuff detected by nit.
make_hlds.nl:
Transform to `semi-homogeneous' form (still need to expand
unifications).
prog_util.nl:
Fix bug.
mercury_builtin.nl:
Add call/1.
hlds.nl:
Add a count of the number of errors and warnings to the module_info
data structure.
toplevel.nl:
Continue processing after syntax errors.
varset.nl:
Added predicate varset__vars.
term.nl:
Added predicate term__vars_list.
typecheck.nl:
Implement two previously unimplemented parts of the typechecker:
detect attempts to instantiate type variables which occur in
the predicate's type declaration, and detect any failure to
bind all other type variables. (That was the last two;
apart from
prog_util.nl:
Fix problem where the expansion of equivalence types was
introducing fresh variables into the type varset, which caused
problems in relation to the above changes to typecheck.nl.
hlds_out.nl:
Fix typo in type declaration (found by above fixes to typechecker).
options.nl:
Fix bug in type definition introduced by last change.
make_hlds.nl:
Add a missing pred & mode declaration.
modes.nl:
Don't display the verbose messages unless the very-verbose
flag was specified.
prog_util.nl:
Changed if-then-else to -> ;
string.nl:
Changed if-then-else to -> ;
term.nl:
Changed if-then-else to -> ; and added an XXX in term__context_init
varset.nl:
Changed if-then-else to -> ;