Estimated hours taken: 3 + unknown by Ralph
Branches: main
Fix a bug I detected and Ralph tracked down. It was the result of an
interaction of the state variable transformation, mode analysis and
(lack of) quantification.
Sometimes, the final value of a state variable introduced with "some [!X]"
notation is not used along some paths of computation. In some of those cases,
a second pass of mode checking (usually unique mode checking) could delete the
unification building the final version of the state variable in one branch
of e.g. a switch while not being able to delete a procedure call building
that same final version transformation in another branch. Later compiler passes
then get errors because the branches bind different sets of variables.
The fix is to rerun quantification when this happens, to delete the final
version of the state variable from the switch's nonlocal set and thus from
the nonlocal set of any non-eliminated goals that bind it.
compiler/mode_info.m:
Add a field to the mode info that records the need for a
requantification.
compiler/modecheck_unify.m:
When eliminating a unification, set the flag if the unification was
inserted by the state variable transformation and may contain a
singleton variable (such as the final version of the variable in the
example above).
compiler/modes.m:
Requantify the procedure at the end of mode analysis if the flag
is set.
tests/valid/state_var_mode_bug.m:
New test case, a very cut down and abstracted version of the original
code the bug was detected in.
tests/valid/Mmakefile:
Enable the new test case.
Estimated hours taken: 8
Branches: main
Add optional support for generating a pure interface to mutables. This is
done by adding a new mutable attribute, `attach_to_io_state'. If this
attribute is specified in the mutable declaration then in addition to the
usual non-pure access predicates, the compiler will also add a pair of access
predicates that take the IO state.
compiler/prog_data.m:
Add the `attach_to_io_state' mutable attribute.
Add the necessary access predicates for the mutable_var_attributes
structure.
compiler/prog_io.m:
Parse the `attach_to_io_state' attribute.
compiler/prog_mutable.m:
Shift some of the code for constructing items related to mutables to
this module from make_hlds_passes. This reduces unnecessary clutter in
the latter.
Remove the XXX comment about needing to mangle the names of the
globals - we now do that.
compiler/make_hlds_passes.m:
If a mutable has the `attach_to_io_state' attribute specified then
create pure access predicates that take the IO state in addition
to the non-pure ones.
compiler/modules.m:
If we are generating the pure access predicates then output the
declarations for these predicates in private interfaces.
compiler/type_util.m:
Replace the use of ':' as a module qualifier in some comments.
doc/reference_manual.texi:
Document the `attach_to_io_state' mutable attribute.
vim/syntax/mercury.vim:
Highlight various mutable attributes appropriately.
tests/hard_coded/Mmakefile:
tests/hard_coded/pure_mutable.m:
tests/hard_coded/pure_mutable.exp:
Test mutables with pure access predicates.
tests/hard_coded/ppc_bug.m:
Unrelated change: update the comments in this test case so
they describe what the cause of the bug and the fix were.
Estimated hours taken: 0.2
Branches: main
compiler/unify_gen.m:
Loosen an overly strict sanity check that prevented compilation in term
size profiling grades.
Estimated hours taken: 1
Branches: main
compiler/jumpopt.m:
compiler/labelopt.m:
Make the main predicates of these optimizations tail recursive in order
to allow them to handle procedures with 50,000 instructions, such as
the one reported by Michael Day.
Estimated hours taken: 30
Branches: main
Consider types of the form
:- type x ---> f.
to be dummy types, since they contain no information. Optimize them the same
way we currently optimize io.state and store.store.
runtime/mercury_type_info.h:
Add a new type_ctor_rep for dummy types.
runtime/mercury_tabling.h:
Add a representation for "tabled" dummy types, which don't actually
have a level in the trie, so that the runtime system can handle that
fact.
runtime/mercury_ml_expand_body.h:
When deconstructing a value of a dummy type, ignore the actual value
(since it will contain garbage) and instead return the only possible
value of the type.
runtime/mercury_construct.c:
runtime/mercury_deconstruct.c:
runtime/mercury_deep_copy_body.c:
runtime/mercury_tabling.c:
runtime/mercury_unify_compare_body.h:
library/rtti_implementation.m:
Handle the type_ctor_rep of dummy types.
runtime/mercury_builtin_types.c:
Provide a place to record profiling information about unifications and
comparisons for dummy types.
runtime/mercury_mcpp.h:
java/runtime/TypeCtorRep.java:
library/private_builtin.m:
Add a new type_ctor_rep for dummy types, and fix some previous
discrepancies in type_ctor_reps.
mdbcomp/prim_data.m:
Move a bunch of predicates for manipulating special_pred_ids here from
the browser and compiler directories.
Rename the function symbols of the special_pred_id type to avoid the
need to parenthesize the old `initialise' function symbol.
Convert to four-space indentation.
mdbcomp/rtti_access.m:
Don't hardcode the names of special preds: use the predicates in
prim_data.m.
Convert to four-space indentation.
browser/declarative_execution.m:
Delete some predicates whose functionality is now in
mdbcomp/prim_data.m.
compiler/hlds_data.m:
Replace the part of du type that says whether a type an enum, which
used to be a bool, with something that also says whether the type is a
dummy type.
Convert to four-space indentation.
compiler/make_tags.m:
Compute the value for the new field of du type definitions.
compiler/hlds_out.m:
Write out the new field of du type definitions.
compiler/rtti.m:
Modify the data structures we use to create type_ctor_infos to allow
for dummy types.
Convert to four-space indentation.
compiler/type_ctor_info.m:
Modify the code that generates type_ctor_infos to handle dummy types.
compiler/type_util.m:
Provide predicates for recognizing dummy types.
Convert to four-space indentation.
compiler/unify_proc.m:
Generate the unify and compare predicates of dummy types using a new
code scheme that avoids referencing arguments that contain garbage.
When generating code for unifying or comparing other types, ignore
any arguments of function symbols that are dummy types.
Don't use DCG style access predicates.
compiler/higher_order.m:
Specialize the unification and comparison of values of dummy types.
Break up an excessively large predicate, and factor out common code
from the conditions of a chain of if-then-elses.
compiler/llds.m:
For each input and output of a foreign_proc, include a field saying
whether the value is of a dummy type.
compiler/pragma_c_gen.m:
Fill in the new fields in foreign_proc arguments.
compiler/hlds_goal.m:
Rename some predicates for constructing unifications to avoid
unnecessary ad-hoc overloading. Clarify their documentation.
Rename a predicate to make clear the restriction on its use,
and document the restriction.
Add a predicate for creating simple tests.
Add a utility predicate for setting the context of a goal directly.
compiler/modules.m:
Include dummy types interface files, even if they are private to the
module. This is necessary because with the MLDS backend, the generated
code inside the module and outside the module must agree whether a
function returning a value of the type returns a real value or a void
value, and this requires them to agree on whether the type is dummy
or not.
The impact on interface files is minimal, since very few types are
dummy types, and changing a type from a dummy type to a non-dummy type
or vice versa is an ever rarer change.
compiler/hlds_pred.m:
Provide a representation in the compiler of the trie step for dummy
types.
compiler/layout_out.m:
Print the trie step for dummy types.
compiler/table_gen.m:
Don't table values of dummy types, and record the fact that we don't
by including a dummy trie step in the list of trie steps.
compiler/add_pragma.m:
compiler/add_special_pred.m:
compiler/add_type.m:
compiler/aditi_builtin_ops.m:
compiler/bytecode.m:
compiler/bytecode_gen.m:
compiler/code_gen.m:
compiler/code_info.m:
compiler/continuation_info.m:
compiler/cse_detection.m:
compiler/det_report.m:
compiler/exception_analysis.m:
compiler/inst_match.m:
compiler/livemap.m:
compiler/llds_out.m:
compiler/llds_out.m:
compiler/middle_rec.m:
compiler/ml_call_gen.m:
compiler/ml_closure_gen.m:
compiler/ml_code_gen.m:
compiler/ml_code_util.m:
compiler/ml_type_gen.m:
compiler/ml_unify_gen.m:
compiler/mlds_to_c.m:
compiler/mlds_to_gcc.m:
compiler/mlds_to_il.m:
compiler/mlds_to_il.m:
compiler/modecheck_unify.m:
compiler/modes.m:
compiler/opt_util.m:
compiler/post_term_analysis.m:
compiler/post_typecheck.m:
compiler/qual_info.m:
compiler/rl.m:
compiler/rl_exprn.m:
compiler/rl_key.m:
compiler/rtti_out.m:
compiler/simplify.m:
compiler/size_prof.m:
compiler/term_constr_initial.m:
compiler/term_constr_util.m:
compiler/term_norm.m:
compiler/termination.m:
compiler/trace.m:
compiler/typecheck.m:
compiler/unify_gen.m:
Conform to the changes above.
compiler/export.m:
compiler/exprn_aux.m:
compiler/foreign.m:
compiler/polymorphism.m:
compiler/proc_label.m:
compiler/rtti_to_mlds.m:
compiler/special_pred.m:
compiler/stack_alloc.m:
compiler/stack_layout.m:
compiler/state_var.m:
compiler/switch_util.m:
compiler/trace_params.m:
Conform to the changes above.
Convert to four-space indentation.
compiler/mlds_to_java.m:
compiler/var_locn.m:
Conform to the changes above, which requires threading the module_info
through the module.
Convert to four-space indentation.
compiler/mercury_compile.m:
Pass the module_info to mlds_to_java.m.
compiler/ml_util.m:
compiler/polymorphism.m:
compiler/type_ctor_info.m:
compiler/type_util.m:
Delete some previously missed references to the temporary types used
to bootstrap the change to the type_info type's arity.
compiler/polymorphism.m:
Turn back on an optimization that avoids passing parameters (such as
type_infos) to foreign_procs if they are not actually referred to.
compiler/prog_data.m:
Convert to four-space indentation.
library/svvarset.m:
Add a missing predicate.
trace/mercury_trace.c:
Delete the unused function that used to check for dummy types.
tests/debugger/field_names.{m,inp,exp}:
Add to this test case a test of the handling of dummy types. Check that
their values can be printed out during normal execution, and that the
debugger doesn't consider them live nondummy variables, just as it
doesn't consider I/O states live nondummy variables.
Estimated hours taken: 2
Branches: main
Fix an optimization that tries to turn MR_succeed() into MR_succeed_discard(),
which throws away nondet stack frames at the last success of the relevant
procedure.
compiler/opt_util.m:
Fix the overly conservative approximation here that prevented
peephole.m from applying that optimization. It was considering
livevals() instructions as potentially affecting redoip slots,
which cannot be farther from the truth.
Change the relevant predicate from an if-then-else with a default
to a switch, to prevent similar problems in future.
compiler/peephole.m:
Don't apply the existing transformation pattern unless we find an
assertion that no other stack frame exists on top of the current one,
since it isn't valid then.
compiler/code_util.m:
Include that assertion in the comment of the instruction that assigns
to the redoip slot, which is where peephole.m looks for it.
We could store the assertion in an extra slot to assignment statements
in the LLDS, but that would require changes in lots of places and lead
to significant space overhead. This way is simpler, and has no overhead
to speak of. Any LLDS transformation that modifies the comment may
destroy the assertion, but the chance that it will incorrectly add or
even keep the assertion is about zero.
Estimated hours taken: 4
Branches: main
Support impure initialise and finalise predicates in user code. In order to
support this the arity of the initialise or finalise predicate can no longer be
optionally omitted from the declaration. Supporting impure arity zero
initialise/finalise declarations removes the restriction that every module that
has an initialise/finalise declaration must import the io module.
Allow initialize/finalize to be used as synonyms for initialise/finalise.
Improve the documentation of initialise/finalise declarations.
In particular:
- mention the above changes.
- mention that they may be cc_multi.
- specify the order in which they invoked with respect to
standard library initialisation/finalisation.
- mention that these declarations are not currently available
on non-C backends.
compiler/make_hlds_passes.m:
Support impure user initialise/finalise predicates.
compiler/mercury_to_mercury.m:
Write out the arities of the predicates specified in
initialise and finalise declarations.
compiler/prog_data.m:
Add an arity field to the initialise and finalise items.
compiler/prog_io.m:
Don't allow the arity to be omitted in initialise and finalise
declarations.
compiler/module_qual.m:
compiler/modules.m:
compiler/recompilation.check.m:
compiler/recompilation.version.m:
Conform to the changes in the initialise and finalise items.
library/ops.m:
Add the alternate spellings of initialise and finalise to the ops
table.
doc/reference_manual.texi:
Update the ops table.
Mention that initialise and finalise predicates may be cc_multi.
Document impure initialisation and finalisation predicates.
Add some disclaimers: mutable, initialise and finalise declarations
are not implemented for the non-C backends.
tests/hard_coded/Mmakefile:
tests/hard_coded/impure_init_and_final.m:
tests/hard_coded/impure_init_and_final.exp:
Test impure initialise and finalise declarations.
tests/hard_coded/finalise_decl.m:
tests/hard_coded/intialise_decl.m:
Conform to the above changes. Also test the versions of the
declarations that use the -ize ending.
tests/hard_coded/sub-modules/finalise_parent.m:
tests/hard_coded/sub-modules/initialise_child.m:
tests/hard_coded/sub-modules/initialise_parent.m:
Conform to the above changes.
tests/invalid/bad_finalise.m:
tests/invalid/bad_finalise.err_exp:
tests/invalid/bad_initialise.m:
tests/invalid/bad_initialise.err_exp:
Extend these tests to check for missing or bad arities
in intialise or finalise declarations.
vim/syntax/mercury.vim:
Highlight recently added syntax appropriately.
Estimated hours taken: 0.2
Branches: main
.README.in:
Update the version of the boehm collector being used.
compiler/notes/upgrade_boehm_gc.html:
Add a step saying to update .README.in.
Estimated hours taken: 1
Branches: main
Fix a problem with mutables and intermodule-optimization.
This was causing tests/hard_coded/sub-modules/mutable_parent to fail on
saturn.
compiler/modules.m:
Fix the handling of mutable, initialise and finalise declarations with
respect to foreign code. The problem is that these three declarations
all expand to various types of foreign pragma but at the time
modules.m processes the item list this expansion hasn't yet been done
(it's done when the items are added to the HLDS). Consequently
various foreign language dependencies are not being correctly set,
which in turn is causing problems when compiling programs that use
mutables with intermodule-optimization enabled.
Fix a bit of formatting.
compiler/intermod.m:
Position a section heading according to our current coding standards.
Estimated hours taken: 0.5
Branches: main
tools/subst:
A simple tool for performing substitutions on the source files of the
compiler.
compiler/*.m:
Change the names of the get predicates operating on module_infos to
include "get" in the name, for uniformity. This was done mostly by
the following sed script, with some manual cleanup afterwards to reduce
excessive line lengths.
s/module_info_types/module_info_get_type_table/
s/module_info_set_types/module_info_set_type_table/
s/module_info_insts/module_info_get_inst_table/
s/module_info_set_insts/module_info_set_inst_table/
s/module_info_modes/module_info_get_mode_table/
s/module_info_set_modes/module_info_set_mode_table/
s/module_info_ctors/module_info_get_cons_table/
s/module_info_set_ctors/module_info_set_cons_table/
s/module_info_classes/module_info_get_class_table/
s/module_info_set_classes/module_info_set_class_table/
s/module_info_instances/module_info_get_instance_table/
s/module_info_set_instances/module_info_set_instance_table/
s/module_info_superclasses/module_info_get_superclass_table/
s/module_info_set_superclasses/module_info_set_superclass_table/
s/module_info_assertion_table/module_info_get_assertion_table/
s/module_info_exclusive_table/module_info_get_exclusive_table/
s/module_info_ctor_field_table/module_info_get_ctor_field_table/
s/module_info_name/module_info_get_name/
s/module_info_globals/module_info_get_globals/
s/module_info_contains_foreign_types/module_info_get_contains_foreign_types/
s/module_info_num_errors/module_info_get_num_errors/
s/module_info_type_ctor_gen_infos/module_info_get_type_ctor_gen_infos/
s/module_info_stratified_preds/module_info_get_stratified_preds/
s/module_info_unused_arg_info/module_info_get_unused_arg_info/
s/module_info_exception_info/module_info_get_exception_info/
s/module_info_type_spec_info/module_info_get_type_spec_info/
s/module_info_no_tag_types/module_info_get_no_tag_types/
s/module_info_analysis_info/module_info_get_analysis_info/
s/module_info_aditi_top_down_procs/module_info_get_aditi_top_down_procs/
Estimated hours taken: 8
Branches: main
Add language and compiler support for finalise declarations.
NEWS:
Mention finalise declarations.
compiler/prog_data.m:
Add a new item type for finalise declarations.
Add a new kind of item origin - items can now be introduced as part of
the source-to-source transformation that implements finalise
declarations.
compiler/prog_io.m:
Parse finalise declarations.
compiler/modules.m:
Don't write out finalise declarations in private interfaces.
compiler/hlds_module.m:
Add a slot to the HLDS that stores the names of the predicates in
finalise declarations.
Add access predicates for the above.
compiler/add_pragma.m:
compiler/make_hlds_passes.m:
Fix in incorrect comment: we add initialise declarations on third, not
second, pass.
Restore the code that use the enhanced switch detection capability.
Implement the source-to-source transformation that implements finalise
declarations. This is almost identical to that for intitialise
declarations.
compiler/llds.m:
compiler/llds_out.m:
compiler/transform_llds.m:
Add a slot to the LLDS to hold the name of the predicates specified in
the finalise declarations.
Emit the necessary code to call these predicates after main has finished.
compiler/mlds.m:
compiler/ml_code_gen.m:
compiler/ml_elim_nested.m:
compiler/ml_optimize.m:
compiler/ml_tailcall.m:
compiler/mlds_to_c.m:
compiler/mlds_to_gcc.m:
compiler/mlds_to_il.m:
compiler/mlds_to_ilasm.m:
compiler/mlds_to_java.m:
compiler/mlds_to_managed.m:
As above, but for the MLDS.
compiler/mercury_compile.m:
Conform to changes in the MLDS.
XXX This module probably shouldn't manipulating the MLDS directly.
compiler/module_qual.m:
compiler/mercury_to_mercury.m:
compiler/recompilation.check.m:
compiler/recompilation.version.m:
Conform to the above changes.
library/ops.m:
Add `finalise' as an operator.
runtime/mercury_wrapper.c:
Call any user specified finalise predicates from
mercury_runtime_terminate.
doc/reference_manual.texi:
Document finalise declarations.
tests/hard_coded/Mmakefile:
tests/hard_coded/finalise_decl.m:
tests/hard_coded/finalise_decl.exp:
Tests finalise declarations.
tests/hard_coded/sub-modules/Mmakefile:
tests/hard_coded/sub-modules/finalise_child.m:
tests/hard_coded/sub-modules/finalise_parent.m:
tests/hard_coded/sub-modules/finalise_parent.{exp,exp2}:
Test finalise declarations and sub-modules. There are two expected
outputs because the order of execution between a parent module and its
children of any finalisers is arbitrary.
tests/invalid/Mmakefile:
tests/invalid/bad_finalise_decl.m:
tests/invalid/bad_finalise_decl.err_exp:
Test error messages associated with finalise declarations.
Estimated hours taken: 8
Branches: main
Make the declarations for the globals variables used to implement mutables
visible across module boundaries. Not doing so means that we cannot inline
the access predicates across module boundaries (this is currently causing
the tests for mutables and sub-modules to fail on that compile with
--intermodule-optimization).
Doing so requires us to module qualify the globals in the generated code, this
diff also fixes an earlier XXX about not mangling the names of mutables.
Add another mutable attribute, foreign_name, that allows the user to override
the compiler's choice of name for the global variable. This is useful where
foreign code needs also needs to access the mutable, e.g. in library
bindings. Currently, we only support this facility in the C backends.
(Actually, it's almost implemented for the other backends as well, but
there's no way to test it at the moment).
Support `trailed' and `not_thread_safe' as mutable attributes. These are
the defaults so in practice they will probably rarely be used.
compiler/make_hlds_passes.m:
If there is a foreign_name attribute for a mutable, then use that name
rather than a compiler generated one.
Make sure that there is a declaration for the global variable in the
module's .mh file.
Emit an error message if an attempt is made to use a trailed mutable
in a non-trailing grade.
compiler/prog_mutable.m:
Append the module name to the name of the global variable used to
implement the mutable.
compiler/prog_data.m:
Make the set of mutable attributes into an abstract type. Handle this
in a similar fashion to foreign code attributes.
Add access predicates for the above type.
Fix the positioning of comments and section headings in this module.
Unrelated change: add a comment explaining why the intermediate
form of the constraints in the termination2_info pragmas is necessary.
compiler/prog_io.m:
Parse the new mutable attributes.
Update the description of the source-to-source transformation used to
implement mutable variables.
compiler/prog_io_pragma.m:
Export the predicate parse_foreign_language/2. It is now needed
by the code that parses mutable declarations.
compiler/globals.m:
Add a function that returns the compilation target as a string.
doc/reference_manual.m:
Document the new attributes.
tests/invalid/Mmakefile:
tests/invalid/Mercury.options:
tests/invalid/trailed_mutable.m:
tests/invalid/trailed_mutable.err_exp:
Test the error message that results if a trailed mutable is used in a
non-trailing grade.
tests/hard_coded/bad_mutable.{m,err_exp}:
Extend this test case to cover the new attributes.
tests/hard_coded/Mmakefile:
tests/hard_coded/foreign_name_mutable.{m,exp}:
tests/hard_coded/unusual_name_mutable.{m,exp}:
Further test for mutable variables.
Estimated hours taken: 0.5
Branches: main
Add a developer-only option '--trace-prof' that causes the deep profiling
service predicates to show up in the execution trace.
compiler/mercury_compile.m:
If '--trace-prof' is specified and tracing is enabled then
trace the profiling builtin predicates.
compiler/options.m:
Add the '--trace-prof' option.
Estimated hours taken: 4
Branches: main
Speed up the compilation of predicates with lots of disjuncts dramatically.
With this change, the time to compile the transitive closure tabling benchmark
with an 8000 clause "edge" predicate falls from 230 seconds to 14, a 94%
reduction. The time to compile the six largest compiler modules is unaffected.
Previously, I added the mode_check_clauses pragma to accomplish a similar
reduction in compilation time for such predicates. (Actually, that pragma
gets an even bigger speedup, since a fast merging of instmaps still takes
more time than not merging instmaps at all.) However, this solution is better,
since the user doesn't have to remember to use a pragma, it works even on
if-then-elses and non-outermost disjunctions, and it avoids losing the
information that mode_check_clauses loses about the final insts of the
affected variables.
compiler/instmap.m:
Replace the old algorithms for merging the insts of a variable at the
ends of the arms of branched control structures, whose complexity was
N^2, with algorithms whose complexity is N log N.
compiler/mode_util.m:
Instead of writing explicit N^2 code to merge the insts of variables
at the ends of the arms of branched control structures when recomputing
instmap_deltas, call the new N log N algorithm in instmap.m.
compiler/inst_util.m:
Fix incorrect documentation, and delete redundant documentation.
compiler/modes.m:
Minor style fixes.
Estimated hours taken: 4
Branches: main
This is step 3 of eliminating the arguments of the type_ctor_info, type_info,
base_typeclass_info and typeclass_info type constructors. This step eliminates
the temporary replacement types with the zero_ prefixes on their names.
library/private_builtin.m:
Remove the temporary replacement type constructors and the predicates
that operate on them.
runtime/mercury_builtin_types.[ch]:
Remove the unify and compare predicates of the temporary replacement
type constructors.
runtime/mercury_type_info.h:
runtime/mercury_grade.h:
Increase binary compatibility version numbers to reflect the
requirement on the compiler to generate references to arity-0 variants
of type_ctor_info, type_info, base_typeclass_info and typeclass_info.
runtime/mercury_type_info.h:
runtime/mercury_make_type_info_body.h:
compiler/rtti.m:
Remove support for fake_arity types, since there aren't any anymore.
trace/mercury_trace_vars.c:
Remove references to the temporary replacement type constructors.
Estimated hours taken: 0.1
Branches: main, release
compiler/modules.m:
Ensure that mmake realclean always cleans up .mih files.
It wasn't doing so in the situation where a library was
built in one of the low-level grades, installed in a
high-level grade and then mmake realclean was run in
the source directory.
Estimated hours taken: 2
Branches: main
Make ':' into an infix type qualification operator, equivalent to `with_type`.
compiler/prog_io.m:
Handle type qualifications in pred and func declarations that use ':'.
compiler/superhomogeneous.m:
Handle type qualifications using ':' in clauses.
library/ops.m:
Change the precedence of ':' so that it is identical to `with_type`.
doc/reference_manual.texi:
Update the list of operators.
Update the section on explicit type qualification expressions.
tests/hard-coded/type_qual.m:
Use the new syntax in this test case.
(There are lots of other test cases that exercise the old syntax.)
NEWS:
Mention that ':' is now the type qualification operator.
Estimated hours taken: 0.5
Branches: main
compiler/assertion.m:
compiler/magic.m:
compiler/mercury_compile.m:
compiler/ml_code_gen.m:
compiler/modes.m:
compiler/modules.m:
compiler/options_file.m:
compiler/recompilation.check.m:
compiler/recompiltaion.usage.m:
Use promise_equivalent_solutions scopes in place of
promise_only_solution and promise_only_solution_io in the compiler.
Estimated hours taken: 1
Branches: main
compiler/llds_out.m:
We already have an optimization in llds_out.m which tries to turn
Mercury abstract machine gotos, whose potential cross-module scope
results in lots of overheads in none.gc and non-negligible overhead
even in asm_fast.gc, into gotos that the C compiler knows are local,
by making them the continue statements of while loops.
This diff extends this optimization by making it work even when the
goto being optimized is inside a block instruction introduced as part
of the --use-local-vars optimization. Previously, that optimization
and the one in llds_out.m stepped on each other's toes; that is no
longer the case.
This diff improves the compiler's speed by about 0.5% with
-O2 --use-local-vars.
Estimated hours taken: 0.3
Branches: main
compiler/llds_out.m:
Some style fixes. Make some predicates into functions, and delete
redundant llds_out__ prefixes to eliminate some excessively long lines.
There are no algorithmic changes.
compiler/opt_debug.m:
compiler/fact_table.m:
Conform to the changes in llds_out.m.
compiler/rtti_out.m:
Conform to the changes in llds_out.m.
Convert to four-space indentation.
Estimated hours taken: 8
Branches: main
This is step 2 of eliminating the arguments of the type_ctor_info, type_info,
base_typeclass_info and typeclass_info type constructors. This step changes
the arity of those type constructors from 1 to 0, and starts generating
references to them again. Due to bootstrapping issues, we can't delete the
zero_type_ctor_info, zero_type_info, zero_base_typeclass_info and
zero_typeclass_info types yet; that will be step 3.
library/private_builtin.m:
Change the arity of those type constructors.
runtime/mercury_builtin_types.m:
Update the unify and compare predicates of the old type constructors
for their new arity.
compiler/polymorphism.m:
compiler/size_prof.m:
compiler/type_util.m:
Generate references to the newly arity-0 old type constructions.
compiler/type_ctor_info.m:
compiler/type_util.m:
trace/mercury_trace_vars.c:
Update references to the old types to reflect their new arities.
compiler/type_ctor_info.m:
There are no more fake arities.
library/io.m:
library/rtti_implementation.m:
library/string.m:
library/table_builtin.m:
Update references to the old types for their new arities.
Estimated hours taken: 0.2
Branches: main
compiler/mercury_compile.m:
When asked to do a HLDS dump that is the same as the previous HLDS
dump, instead of creating a potentially large file, just note the fact.
Delete the mercury_compile__ prefixes to avoid excessively long lines.
Estimated hours taken: 0.3
Branches: main
compiler/add_heap_ops.m:
compiler/add_trail_ops.m:
compiler/ml_unify_gen.m:
Convert these modules to four-space indentation.
Estimated hours taken: 0.3
Branches: main
Reduce even further the clutter of boring command line arguments.
scripts/mgnuc.in:
If a file named .mgnuc_opts exists in the current directory,
read mgnuc options from it. This mechanism is very similar to the
mechanism I added a while ago to get C compiler options from a
file named .mgnuc_copts.
Convert to four-space indentation.
scripts/mgnuc_file_opts.sh-subr:
New file containing most of the option handling code that used to be
in mgnuc.in. Now, it is is included in mgnuc twice: once for handling
options from the command line, once for handling options from
.mgnuc_opts files.
configure.in:
Set up configure to insert mgnuc_file_opts.sh-subr into mgnuc.
*/.mgnuc_opts:
New files specifying the --no-mercury-stdlibdir mgnuc option.
Mmake.workspace:
Don't pass --no-mercury-stdlibdir on command lines anymore, since this
is now taken care of by the .mgnuc_opts files.
Estimated hours taken: 0.2
Branches: main
compiler/dupelim.m:
Factor out some common code using the new capability of switch
detection.
configure.in:
Require the installed compiler to have this capability.
Unrelated: also add a test for posix_memalign.
Estimated hours taken: 8
Branches: main
This is step 1 of eliminating the arguments of the type_ctor_info, type_info,
base_typeclass_info and typeclass_info type constructors. This step doesn't
delete those arity-1 type constructors yet; that will be done in step 2.
This delay due to bootstrapping issues: installed compilers still generate
references to those type constructors. However, after this change, compilers
will instead generate references to arity-0 versions of those types named
zero_type_ctor_info, zero_type_info, zero_base_typeclass_info and
zero_typeclass_info.
library/private_builtin.m:
Add the new type constructors.
For each predicate that operates on the old arity-1 type constructors,
add a version that operates on the new type arity-0 onstructors,
and whose implementation is identical.
runtime/mercury_builtin_types.m:
Add the unify and compare predicates of the new type constructors.
runtime/mercury_wrapper.[ch]:
runtime/mercury_init.h:
util/mkinit.c:
Change the C type of the variable that holds the types of type_infos
and pseudo_type_infos, since their representation is now simpler
(no dummy argument).
trace/mercury_trace_vars.c:
Modify data structures that recognize the four old types to recognize
their new variants as well.
compiler/higher_order.m:
compiler/polymorphism.m:
Generate references to the new versions of predicates that manipulate
type_infos and typeclass_infos.
compiler/hlds_pred.m:
compiler/ml_code_util.m:
compiler/type_ctor_info.m:
Modify predicates that recognize the four old types to recognize their
new variants as well.
compiler/type_util.m:
Modify the predicates that construct the types of type_infos
to create references to the new arity-0 type constructors.
Modify predicates that recognize the four old types to recognize their
new variants as well.
Delete the predicate whose job was to replace the dummy arguments
of the arity-1 type constructors with the void type, since it is not
needed anymore.
Delete the unused predicate cell_type_name.
compiler/stack_layout.m:
Fix comment.
compiler/size_prof.m:
Conform to the changes in type_util.
compiler/pseudo_type_info.m:
Conform to the changes in type_util.
Convert to four-space indentation.
Estimated hours taken: 3
Branches: main and 0.12
Make the I/O tabling transformation respect :- pragma no_inline directives
by creating a copy of the predicate to be transformed and calling the
copy, instead of duplicating the body, if :- pragma no_inline is
given. This is necessary to avoid duplicate label errors from the C compiler
when the I/O tabled foreign proc uses labels.
compiler/hlds_pred.m:
Add a new functor to the pred_creation type to indicate that a pred
was created by the I/O tabling transformation.
Fix some formatting.
compiler/table_gen.m:
If the predicate to be I/O tabled has a no_inline pragma attached to
it, then create a copy of the predicate and call the new predicate in
the transformed version.
compiler/trace_params.m:
Do not trace the copy of the I/O tabled predicate.
doc/reference_manual.texi
Document the tabled_for_io attribute.
tests/debugger/Mercury.options:
tests/debugger/Mmakefile:
tests/debugger/io_tab_goto.data:
tests/debugger/io_tab_goto.exp:
tests/debugger/io_tab_goto.inp:
tests/debugger/io_tab_goto.m:
Test that foreign C code with labels is I/O tabled correctly.
tests/debugger/declarative/Mmakefile:
tests/debugger/declarative/tabled_read_decl_goto.data:
tests/debugger/declarative/tabled_read_decl_goto.exp:
tests/debugger/declarative/tabled_read_decl_goto.inp:
tests/debugger/declarative/tabled_read_decl_goto.m:
Test declarative debugging of I/O tabled foreign predicates with
gotos.
Estimated hours taken: 11
Branches: main
Fix the problems with mutable declarations and sub-modules by making
sure that the relevant information is written out in the private interface
files.
Fix a bug where mutable variables were not being initialised with their
declared intial value. The problem was that the compiler was optimizing away
the body of the automatically generated predicate that was setting the initial
value. We now make such predicates impure to prevent this.
In order to support the above, accept `:- intialise' declarations that specify
impure predicates, provided that the declaration in question was generated by the
compiler. It is still an error for the user to specify such declarations.
Fix some other problems with mutable declarations.
compiler/modules.m:
Do not write `:- mutable' declarations out to private interface
files, instead write out the predicate and mode declarations for
the access predicates.
Remove some old XXX comments about mutables that are no longer
relevant.
compiler/make_hlds_passes.m:
Don't add the export pragmas for initialise declarations during pass
2. For some reason we were doing this during pass 2 and again during
pass 3.
Make the intialise predicates for mutable variables impure in order to
prevent the compiler from optimizing them away
Fix origin fields that were being set incorrectly during the mutable
transformation.
compiler/prog_mutable.m:
New module. Shift some code from make_hlds_passes to here, since
modules.m also needs access to it.
compiler/parse_tree.m:
Include the new module.
compiler/notes/compiler_design.html:
Mention the new module.
tests/hard_coded/sub-modules/Mmakefile:
tests/hard_coded/sub-modules/mutable_parent.m:
tests/hard_coded/sub-modules/mutable_child.m:
tests/hard_coded/sub-modules/mutable_grandchild.m:
tests/hard_coded/sub-modules/mutable_parent.exp:
Test case for mutables and sub-modules.
tests/hard_coded/not_in_interface.m:
tests/hard_coded/not_in_interface.err_exp:
Test for ordering problems between mutable and initialise
declarations when emitting errors about items that should
not occur in module interfaces. This can happen if the
item's origin field is incorrectly set.
Estimated hours taken: 1.5
Branches: main
Do not display the `For more information try recompiling with `-E'' prompt
unless we really mean it, i.e. there is actually more information available.
XXX This change is incomplete for the mode_errors module because that
module requires more substantial changes to make this work - I'll do
that as a separate diff.
compiler/globals.m
Add a new global (and access predicates) that keeps track of whether
we have any verbose error information that could be displayed if we
recompiled with `-E'.
compiler/mercury_compile.m
Check the new global flag before prompting the user to recompile with
`-E'.
compiler/mode_errors.m
Add an XXX comment about needing to respect the extra error info flag
properly.
compiler/accumulator.m
compiler/add_clause.m
compiler/add_pred.m
compiler/add_type.m
compiler/assertion.m
compiler/check_typeclass.m
compiler/det_report.m
compiler/magic_util.m
compiler/make_hlds_error.m
compiler/modes.m
compiler/module_qual.m
compiler/modules.m
compiler/post_typecheck.m
compiler/purity.m
compiler/stratify.m
compiler/typecheck_errors.m
Set the new global flag when we come across an error
for which we have a verbose error message.
tests/recompilation/*:
tests/invalid/*:
Update expected error files.
Estimated hours taken: 3
Branches: main
When returning from det and semidet predicates, load the return address into a
local C variable instead of the succip abstract machine "register" before
popping the stack frame and returning. This gives the C compiler more freedom
to reorder instructions.
This diff gets a 1.4% speed increase on the compiler.
runtime/mercury_stacks.h:
Provide a new macro, MR_decr_sp_and_return, to do the combined job that
its name describes.
compiler/llds.m:
Add a new LLDS instruction that corresponds to the new macro.
compiler/llds_out.m:
Output the new LLDS instruction.
compiler/peephole.m:
Add a predicate that looks for and exploits opportunities for using
the new instruction.
compiler/optimize.m:
Invoke the new peephole predicate as the next-to-last optimization
pass. (The last is wrapping up blocks created by --use-local-vars.)
compiler/*.m:
Minor changes to handle the new instruction.
Estimated hours taken: 0.2
Branches: main
compiler/builtin_ops.m:
Make int.plus, int.minus and int.times builtin operations, with
the same implementations as int.+, int.- and int.*.
Estimated hours taken: 24
Branches: main
Introduce a mechanism for extending the det and nondet stacks when needed.
The mechanism takes the form of a new grade component, .exts ("extend stacks").
While the new mechanism may be useful in its own right, it is intended mainly
to support a new implementation of minimal model tabling, which will use a
separate Mercury context for each distinct subgoal. Each context has its own
det and nondet stack. Clearly, we can't have hundreds of contexts each with
megabyte sized det stacks. The intention is that the stacks of the subgoals
will start small, and be expanded when needed.
The runtime expansion of stacks doesn't work yet, but it is unnecessarily
hard to debug without an installed compiler that understands the new grade
component, which is why this diff will be committed before that is fixed.
compiler/handle_options.m:
compiler/options.m:
runtime/mercury_grade.h:
scripts/canonical_grade.sh-subr
scripts/init_grade_options.sh-subr
scripts/parse_grade_options.sh-subr
scripts/mgnuc.in
Handle the new grade component.
runtime/mercury_memory_zones.h:
Add MR_ prefixes to the names of the fields of the zone structure.
Record not just the actual size of each zone, which includes various
kinds of buffers, but also the desired size of the zone exclusive of
buffers.
Format the documentation of the zone structure fields more
comprehensibly.
runtime/mercury_memory_zones.c:
Instead of implementing memalign if it is not provided by the operating
system, implement a function that allows us to reallocate the returned
area of memory.
Provide a prototype implementation of memory zone extension. It doesn't
work yet.
Factor out the code for setting up redzones, since it is now needed
in more than place.
Convert to four space indentation.
Make the debugging functions a bit more flexible.
runtime/mercury_wrapper.c:
Conform to the improved interface of the debugging functions.
runtime/mercury_overflow.h:
runtime/mercury_std.h:
Move a generally useful macro from mercury_overflow.h to mercury_std.h.
runtime/mercury_stacks.c:
Add functions to extend the stacks.
runtime/mercury_stacks.h:
Add the tests required to invoke the functions that extend the stacks.
Add the macros needed by the change to compiler/llds.m.
Convert to four space indentation.
runtime/mercury_conf.h.in:
Prepare for the use of the posix_memalign function, which is the
current replacement of the obsolete memalign library function.
We don't yet use it.
runtime/mercury_context.h:
Format the documentation of the context structure fields more
comprehensibly.
Put MR_ prefixes on the names of the fields of some structures
that didn't previously have them.
Conform to the new names of the fields of the zone structure.
runtime/mercury_context.c:
runtime/mercury_debug.c:
runtime/mercury_deep_copy.c:
runtime/mercury_engine.c:
runtime/mercury_memory_handlers.c:
library/benchmarking.m:
library/exception.m:
Conform to the new names of the fields of the zone structure.
In some cases, add missing MR_ prefixes to function names
and/or convert to four space indentation.
runtime/mercury_engine.h:
Add a new low level debug flag for debugging stack extensions.
Format the documentation of the engine structure fields more
comprehensibly.
Convert to four space indentation.
runtime/mercury_conf_param.h:
Document a new low level debug flag for debugging stack extensions.
compiler/compile_target_code.m:
compiler/handle_options.m:
compiler/options.m:
Handle the new grade component.
compiler/llds.m:
Add two new kinds of LLDS instructions, save_maxfr and restore_maxfr.
These are needed because the nondet stack may be relocated between
saving and the restoring of maxfr, and the saved maxfr may point to
the old stack. In .exts grades, these instructions will save not a
pointer but the offset of maxfr from the start of the nondet stack,
since offsets are not affected by the movement of the nondet stack.
compiler/code_info.m:
Use the new instructions where relevant. (Some more work may be
needed on this score; the relevant places are marked with XXX.)
compiler/dupelim.m:
compiler/dupproc.m:
compiler/exprn_aux.m:
compiler/jumpopt.m:
compiler/livemap.m:
compiler/llds_out.m:
compiler/middle_rec.m:
compiler/opt_debug.m:
compiler/opt_util.m:
compiler/reassign.m:
compiler/use_local_vars.m:
Handle the new LLDS instructions.
tools/bootcheck:
Provide a mechanism for setting the initial stack sizes for a
bootcheck.
Estimated hours taken: 40
Branches: main
Optimize calls that would be tail calls in Prolog but are followed by
construction unifications in Mercury: last call modulo construction.
For now, the optimization is available only for the LLDS backend.
compiler/lco.m:
Turn this module from a placeholder to a real implementation
of the optimization.
compiler/hlds_goal.m:
Allow lco.m to attach to construction unifications a note that says
that certain arguments, instead of being filled in by the unification,
should have their addresses taken and stored in the corresponding
variables.
Group this note together with the note that asks for term size
profiling to avoid an increase in the sizes of goals in the compiler
in most cases.
compiler/hlds_pred.m:
Provide a predicate for setting the name of a predicate after its
creation. This functionality is used by lco.m.
Extend the pred_transformation part of the pred_origin type to allow
it to express that a procedure was created by lco.m.
List the new primitive store_at_ref as a no-typeinfo builtin.
Fix some problems with indentation.
compiler/layout_out.m:
Handle the new pred_transformation.
compiler/unify_gen.m:
When processing construction unifications that have the new feaure
turned on, perform the requested action.
Fix some departures from coding style. Shorten lines by deleting
unnecessary module qualifications. Add some auxiliary predicates
to make the code easier to read.
compiler/var_locn.m:
Fix an earlier oversight: when materializing variables inside rvals
and lvals, look inside memory references too. Previously, the omission
didn't matter, since we didn't generate such references, but now we do.
Fix some departures from coding style.
compiler/llds_out.m:
Fix some old XXXs in code handling memory references. We didn't use to
generate such references, but now we do.
Move some functionality here from code_aux.m.
compiler/code_info.m:
Provide some primitive operations needed by the new code in var_locn.m.
Delete an unneeded predicate.
compiler/options.m:
Rename the existing option optimize_constructor_last_call as
optimize_constructor_last_call_accumulator, since that optimization
is done by accumulator.m.
Make optimize_constructor_last_call be the option that calls for the
new optimization.
compiler/handle_options.m:
Handle the implications of the new option.
compiler/mercury_compile.m:
Invoke the lco module by its new interface.
librrary/private_builtin.m:
Add a new primitive operation, store_at_ref, for use by the new
optimization.
Switch the module to four-space indentation.
compiler/add_clause.m:
Comment out the warning for clauses for builtin, since this is needed
to bootstrap the addition of the new builtin.
compiler/term_constr_initial.m:
Handle the new builtin.
compiler/accumulator.m:
Conform to the change in options.
compiler/builtin_ops.m:
Provide a third template for builtins, for use by store_at_ref.
Convert the file to four-space indentation.
compiler/call_gen.m:
Generate code following the new builtin template.
compiler/rl_exprn.m:
Minor changes to conform to the changes in builtin templates.
compiler/quantification.m:
Minor changes to conform to the changes in construct unifications.
Don't make the "get" predicates operating on quantification_infos
to return the "new" quantification_info: it is always the same
as the old one.
compiler/aditi_builtin_ops.m:
compiler/common.m:
compiler/deep_profiling.m:
compiler/higher_order.m:
compiler/hlds_out.m:
compiler/lambda.m:
compiler/magic_util.m:
compiler/ml_unify_gen.m:
compiler/modecheck_unify.m:
compiler/polymorphism.m:
compiler/size_prof.m:
Minor changes to conform to the changes in construct unifications.
compiler/dependency_graph.m:
Add a new predicate to recompute the dependency information,
even if a previous (and possibly now inaccurate) version is present.
Change the interface to make it clearer, by changing bools into types
specific to the situation.
Convert the file to four-space indentation.
compiler/mode_constraints.m:
Minor changes to conform to the changes in dependency_graph.m.
compiler/code_aux.m:
Delete this module. Half its functionality has been moved into
llds_out.m, half to middle_rec.m (its only user).
compiler/goal_form.m:
Move the predicates in this module that are used only by middle_rec.m
to middle_rec.m.
Convert the file to four-space indentation.
compiler/goal_util.m:
compiler/det_util.m:
Move update_instmap from det_util to goal_util, since it is usefulness
extends beyond determinism analysis.
Convert det_util.m to four-space indentation.
compiler/middle_rec.m:
Move here the code required only here from code_aux and goal_form.
Update the moved code for the changes in construct unifications.
The updates are specific to middle_rec.m: they wouldn't be of use
to other modules. They basically say that any code that takes the
addresses of fields cannot be handled by middle_rec.m.
compiler/code_gen.m:
compiler/det_analysis.m:
compiler/live_vars.m:
compiler/ll_backend.m:
compiler/loop_inv.m:
compiler/switch_detection.m:
compiler/switch_gen.m:
compiler/notes/compiler_design.html:
Minor changes to conform to the deletion of code_aux.m and/or the
movement of code from det_util to goal_util.m.
compiler/opt_debug.m:
Print info for vars in rvals.
compiler/hlds_module.m:
Convert a lambda to an explicit predicate to make some code easier to
read.
Switch the module to four-space indentation.
Estimated hours taken: 4
Branches: main
Allow subterms to be tracked through partial unifications in the
declarative debugger.
This involves adding new types of atomic goals to the program representation
stored with the executable of programs compiled with `--trace rep'.
Remove the ``unsafe'' from the cast goal representation to bring the program
representation up to date with Mark's recent change.
browser/declarative_execution.m:
Read partial unification atomic goals from bytecode.
browser/declarative_tree.m:
Handle partial unifications when tracking a subterm.
compiler/prog_rep.m:
If a construction or deconstruction unification is a partial
unification then generate a partial construction or deconstruction
goal type.
Make atomic_goal_info_to_byte_list return the list of variables bound
by the atomic goal so we can check if a deconstruction is a
partial unification (the LHS will be in the list of bound variables).
Wrap the arguments of the RHS of the partial unification in a maybe
type, so that we can tell which were input.
mdbcomp/program_representation.m:
Add a new atomic goal `unify_partial_rep' to represent partial
unifications.
tests/debugger/declarative/Mmakefile:
tests/debugger/declarative/partial.exp:
tests/debugger/declarative/partial.inp:
tests/debugger/declarative/partial.m:
Test tracking of subterms through partial unifications.
Estimated hours taken: 0.2
Branches: main
HISTORY:
NEWS:
RELEASE_NOTES:
compiler/notes/work_in_progress.html:
Update compiler documentation on the main branch to take account of
the 0.12 release.
scripts/mercury_config.in:
When reconfiguring don't abort because files need by the .NET and Java
runtime aren't present.
Estimated hours taken: 1
Branches: main
Remove support for old-style lambda expressions. These have been deprecated
for a long time now. Mercury 0.12 issues a warning if you try to use this
syntax.
compiler/prog_io_goal.m:
compiler/superhomogeneous.m
Do not support parsing old style lambda expressions.
Do not issue a warning about old-style lambdas being deprecated.
library/ops.m:
Delete 'lambda' from the operator table.
doc/reference_manual.texi:
Delete references to the old style lambda expressions.
tests/hard_coded/typeclasses/constrained_lambda.m:
tests/hard_coded/typeclasses/extra_typeinfo.m:
Update the syntax for lambda expressions.
Estimated hours taken: 2
Branches: main
compiler/ml_*.m:
Convert these modules to four space indentation, and clean up
departures from our coding standards.
Estimated hours taken: 0.3
Branches: main
Enable more meaningful experimentation with inlining parameters. We haven't
changed the defaults since 1996, and I want to experiment to find out what
the new defaults should be.
compiler/options.m:
Add a new option, --inline-call-cost, that gives the assumed cost of
a call.
compiler/hlds_pred.m:
Have separate markers for inlining requested by the user versus
inlining proposed by the compiler itself.
compiler/inlining.m:
When calculating the size increase from a proposed inlining operation,
subtract the assumed size cost of the call from the size cost of the
inlined predicate.
Always respect user-requested inline markers, even if doing so would
breach the number-of-vars threshold. That threshold is not very
relevant now; it was set before tree234.m maintained balanced trees!
Rename apart two predicates that differed only in arity.
compiler/add_pragma.m:
compiler/add_pred.m:
compiler/hlds_out.m:
compiler/intermod.m:
compiler/table_gen.m:
Conform to the new set of markers.
Estimated hours taken: 0.5
Branches: main
Remove supported for deprecated syntax. The syntax removed is:
- ':' as a module qualifier.
- '::' and '->' for mode definitions.
- the old-style pragma syntax.
The 0.12 release issues warnings for uses of this syntax.
XXX This also needs to be mentioned in the news file, but since I need to
clean up the main branch news file I'll do that as a separate change.
compiler/prog_io.m:
compiler/prog_io_pragma.m:
compiler/prog_io_util.m:
Remove support for the syntax mentioned above.
Break up an overlong line.
doc_reference_manual.texi:
Remove the documentation for the above syntax.
compiler/recompilation.m:
compiler/rl_info.m:
compiler/fact_table.m:
Remove deprecated syntax from these modules.
Estimated hours taken: 30
Branches: main
Change the representation of types in the compiler.
We also add some support for handling kinds, which will be used later when we
have a kind system. There are a number of places where kinds are not yet
handled correctly -- we assume that all kinds will be `star'. Each of these
locations is flagged with a comment that contains "XXX kind inference:".
compiler/prog_data.m:
Implement the new version of type (type).
Change the definition of type_param to be a variable instead of a
term, since all parameters must be variables anyway.
Implement versions of varset.merge_* which work with tvarsets and
produce renamings instead of substitutions. Renamings are more
convenient than substitutions because we don't need to know the
kinds of type variables in order to build the renaming, and in any
case the substitutions shouldn't have anything other than variables
in the range so renamings will be more efficient and safe.
Define the type of kinds, and provide a couple of utility predicates
to operate on them.
compiler/prog_io.m:
Parse type definition heads as a sym_name and list of type_params,
rather than a functor. Handle this change in other predicates.
Allow parse errors to be returned by get_with_type/3, and handle
these errors.
Remove parse_type/2. This predicate didn't do any processing, it
just forwarded handling to convert_type/2.
compiler/prog_io_typeclass.m:
Change type_is_functor_and_vars to handle the new representation
of types. In doing so, we retain the old behaviour that pure
predicates pass this test, but no other pred or func types. This
behaviour is arguably incorrect, but there is little point changing
the behaviour at the moment. Instead we should remove these kind of
restrictions entirely, but that should be done later.
compiler/prog_io_util.m:
Provide predicates to both parse and unparse types. We need to
unparse types before printing them out, since we do a lot of special
case handling when printing out terms and we don't want to duplicate
this functionality for types.
compiler/module_qual.m:
Remove report_invalid_type. We now report ill-formed types during
parsing.
compiler/superhomogeneous.m:
Handle errors from the parsing of type expressions.
compiler/prog_out.m:
Provide a predicate to convert builtin_types to their string names,
and vice-versa.
compiler/prog_type.m:
Add a bunch of simple tests to use on types which may have kind
annotations present. In such cases, types do not have a canonical
representation so the simple handling of these tests is not what we
want. (Note that these are only required in early phases. The kind
annotations -- when they are implemented -- will be removed before
type checking.)
Consistently handle the application of renamings, substitutions and
recursive substitutions to various data structures.
compiler/mercury_to_mercury.m:
Implement mercury_output_type, mercury_format_type and
mercury_type_to_string. These convert the type to a term before
formatting -- the reason for this is so that appropriate parentheses
are used when formatting operators. This results in some slight
changes to error messages, which are reflected in changes to the
expected output files in the tests.
Remove the old version of mercury_type_to_string.
Change the argument ordering of mercury_format_var to be consistent
with mercury_format_type. (Other predicates in this module should
probably be changed in a similar way, since this argument ordering
is more amenable to higher-order programming. But that can be left
for another change.)
compiler/type_util.m:
Implement type unification. The behaviour is much the same as the
previous behaviour, except that we now handle apply/N types properly,
and we also allow for kind annotations.
Implement an occurs check for types.
Remove the example definition of replace_eqv_type. It isn't used and
would no longer work anyway even if it would have worked before.
Add a tvar_kind_map field to ctor_defn.
The functions type_info_type and type_ctor_info_type now return
types with `void' as their argument, rather than the type that the
type_info or type_ctor_info was for.
Remove type_util.real_vars/2, since it no longer does anything
different from prog_type.vars/2.
Remove the commented out implementation of type_to_ctor_and_args/3.
Its implementation is in prog_type.m, and has changed significantly
in any case.
compiler/add_clause.m:
Move parse_purity_annotation/3 to prog_io_util.m.
compiler/check_typeclass.m:
Remove apply_substitution_to_var_list/3, since we now have predicates
in prog_type.m to handle such things.
compiler/continuation_info.m:
compiler/trace.m:
Use prog_type.vars/2 instead of type_util.real_vars/2. The two
predicates have the same meaning now since type_infos don't contain
any type variables.
compiler/hlds_data.m:
Add tvar_kind_map fields to hlds_type_defn and hlds_class_defn.
compiler/hlds_pred.m:
Add a tvar_kind_map field to pred_info.
compiler/polymorphism.m:
Add a tvar_kind_map field to poly_info.
Remove unify_corresponding_types, which is no longer used.
compiler/hlds_out.m:
Use mercury_output_type/5 instead of term_io__write_term/4 and
mercury_output_term/5.
compiler/post_typecheck.m:
Build the void substitution directly rather than building intermediate
lists.
compiler/recompilation.version.m:
Use term__list_subsumes instead of type_list_subsumes, which now
operates only on types. This follows up on what was suggested in
an XXX comment.
compiler/typecheck_errors.m:
Use unparse_type/2 to format error messages.
compiler/typecheck_info.m:
Don't export write_type_with_bindings/5. It is no longer used
outside of this module.
compiler/*.m:
Conform to the above changes.
library/rtti_implementation.m:
Fix a syntax error that went undetected in our previous
implementation, and amazingly enough was compiled correctly anyway.
library/term.m:
Move the versions of term__unify, term__unify_list and
term__list_subsumes that were implemented specifically for types
to here. The version of term_unify that takes a list of bound
variables (i.e., variables that should not be bound any further)
is used by the subsumption check, which in turn is used by
recompilation.version.m.
tests/invalid/kind.err_exp:
tests/invalid/tc_err1.err_exp:
tests/invalid/tc_err2.err_exp:
tests/misc_tests/pretty_print_test.exp:
Update the expected output of these tests to match what we now do.
Estimated hours taken: 0.1
Branches: main
compiler/add_pragma.m:
compiler/make_hlds_passes.m:
Back up to my recent use of enhanced switches because it
is not yet installed on all of our machines.