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
Fix some of the bugs with the handling of partial qualifiers
for nested modules. With this change, we now handle partial
qualifiers correctly for types, insts, modes, and type classes,
which are handled by module_qual.m. We still don't get it quite
right for constructors, functions, and predicates, for which
module qualification is handled by other modules (make_hlds.m,
hlds_module.m, typecheck.m, post_typecheck.m, and modecheck_unify.m).
compiler/module_qual.m:
Keep track of which modules are visible.
When looking up a qualified symbol, check that the specified module
is visible.
tests/hard_coded/sub-modules/nested.m:
tests/hard_coded/sub-modules/nested3.m:
tests/hard_coded/sub-modules/parent.m:
Uncomment parts of these test cases which were previously
commented out because they were not yet supported.
Estimated hours taken: 9
Provide a more uniform interface to the test directories. Before this
change, the tests directory as well as direct descendents had `runtests'
scripts to execute the tests. These would run `mmake', which in turn
would recursively run `mmake' in any subdirectories. The subdirectories
did not have their own `runtests' scripts.
This change adds a `runtests' script to those subdirectories that did
not have them before. The scripts have the same meaning as they did
previously---run all tests in the current directory and below, and
return a status of 0 only if all tests pass.
The rationale for this change is so that each directory in the tests
is treated the same, regardless of whether it is a top-level
directory or not. This means, for example, that any test directory can
be used as an argument to the `--test-dir' option to tools/bootcheck.
This change also links tests/general/accumulator into the automated
testing suite.
tests/README:
Update comments.
tests/Mmake.common:
Introduce new target dependencies. Targets of the form
`foo' depend on the targets `foo_local' and `foo_subdirs'.
tests/subdir_runtests:
New script to recursively call runtests scripts in subdirectories.
Most of the code for this script originally came from
tests/runtests.
tests/shutdown:
tests/startup:
Use `realclean_local' as a target instead of `realclean', since
the subdirectories will be handled by other runtests scripts.
tests/runtests:
tests/debugger/runtests:
tests/general/runtests:
tests/hard_coded/runtests:
Use the new script to run tests in the subdirectories, rather
than doing a recursive mmake. Make sure that non-zero return
values are propagated upwards where appropriate.
tests/debugger/declarative/runtests:
tests/hard_coded/typeclasses/runtests:
tests/hard_coded/sub-modules/runtests:
New scripts to handle running tests in the subdirectories.
tests/debugger/Mmakefile:
tests/general/Mmakefile:
tests/hard_coded/Mmakefile:
Add `*_subdirs' targets that do a recursive Mmake. Change the
existing targets to `*_local' ones.
tests/warnings/Mmakefile:
Manually add the extra dependencies, since this Mmakefile does
not include tests/Mmake.common.
Estimated hours taken: 2
compiler/typecheck.m:
Set the head_type_params field of class methods properly. (ie. add
the existentially quantified tvars as well).
compiler/hard_coded/typeclasses/typeclass_exist_method.m:
A test case for this.
compiler/hard_coded/typeclasses/Mmakefile:
Turn this test case on.
Estimated hours taken: 0.5
tests/hard_coded/boyer.m:
tests/hard_coded/curry.m:
tests/hard_coded/higher_order_func_test.m:
Rename some things to avoid name clashes with functions recently
added to the standard library. The name clashes resulted in
ambiguity errors during type checking.
Estimated hours taken: 6
Allow construction unifications for existentially typed functors,
using the syntax "X = 'new foo'(Y)" rather than the usual "X = foo(Y)".
We need to use a special syntax for exisentially typed constructions
because type analysis and polymorphism need to know which occurrences
of existentially typed functors are constructors and which are deconstructors.
Note that we still don't yet support RTTI for existentially typed data types.
compiler/typecheck.m:
For existentially typed functors, allow the functor to have
a "new " prefix, and if so, make the quantifiers and constraints
universal rather than existential.
compiler/polymorphism.m:
For unifications with existentially typed functors,
check for a "new " prefix on the functor.
If the functor has such a prefix, strip off the prefix,
and treat the unification as a construction rather than
treating it as a deconstruction.
compiler/type_util.m:
Define a new predicate `remove_new_prefix', for use by typecheck.m
and polymorphism.m.
compiler/modecheck_unify.m:
For construction unifications, check that all the type_info
and typeclass_info arguments introduced by polymorphism.m
are ground.
tests/hard_coded/typeclasses/existential_data_types.m:
Change the test case to use this new feature,
rather than hacking it using the C interface.
doc/reference_manual.texi:
Document the new features.
Estimated hours taken: 30 (including debugging)
Add MR_TYPECTOR_REP_* to the type_ctor_info to describe the
representation of this type.
We want to do this because it allows us to check quickly to see
what kind of data representation is being used. Previously this
information was spread throughout the type_ctor_layout and
type_ctor_functors data structures. It was complex to interpret
and contained a lot of unnecessary duplication.
We can now omit data structures such as the type_ctor_layout in many
cases (it is only necessary for discriminated unions). Because we rule
out some of the possible alternatives, the encodings used in the
type_ctor_layout can be simplified. Also, the functors indicator in
type_ctor_functors can be removed, as it subsumed by this data
structure.
Use this representation in code that uses RTTI.
compiler/base_type_info.m:
Add a missing alternative to the type_ctor_rep (this was a
bug).
library/array.m:
library/builtin.m:
library/private_builtin.m:
runtime/mercury_bootstrap.c:
Use MR_TYPECTOR_REP_* in the type_ctor_infos for builtin types.
library/std_util.m:
runtime/mercury_deep_copy_body.h:
runtime/mercury_tabling.c:
Use MR_TYPECTOR_REP_* and MR_DISCUNION_TAG_* to dispatch on
data representations.
Also, fix a bug in deep_copy when copying floating point values.
I'm not sure when this stopped working, or if this is exactly
the right fix, but it is more correct than the previous code.
runtime/mercury_type_info.c:
runtime/mercury_type_info.h:
Update code to use MR_TYPECTOR_REP_*.
Use a struct for type_ctor_info.
tests/hard_coded/Mmakefile:
tests/hard_coded/deep_copy.m:
tests/hard_coded/deep_copy.exp:
Add a test case for deep_copy.
Estimated hours taken: 4
Merge in the changes from the existential_types_2 branch.
This change adds support for mode re-ordering of code involving
existential types. The change required modifying the order of the
compiler passes so that polymorphism comes before mode analysis,
so that mode analysis can check the modes of the `type_info' or
`typeclass_info' variables that polymorphism introduces, so that
it can thus re-order the code accordingly.
This change also includes some more steps towards making existential data
types work. In particular, you should be able to declare existentially
typed data types, the compiler will generate appropriate unification
and compare/3 routines for them, and deconstruction unifications for them
should work OK. However, currently there's no way to construct them
except via `pragam c_code', and we don't generate correct RTTI for them,
so you can't use `io__write' etc. on them.
library/private_builtin.m:
compiler/accumulator.m:
compiler/bytecode_gen.m:
compiler/check_typeclass.m:
compiler/clause_to_proc.m:
compiler/code_util.m:
compiler/common.m:
compiler/dead_proc_elim.m:
compiler/dependency_graph.m:
compiler/det_analysis.m:
compiler/det_report.m:
compiler/follow_code.m:
compiler/follow_vars.m:
compiler/goal_util.m:
compiler/higher_order.m:
compiler/hlds_goal.m:
compiler/hlds_out.m:
compiler/hlds_pred.m:
compiler/intermod.m:
compiler/lambda.m:
compiler/live_vars.m:
compiler/magic.m:
compiler/make_hlds.m:
compiler/mercury_compile.m:
compiler/mercury_to_c.m:
compiler/mode_errors.m:
compiler/mode_info.m:
compiler/mode_util.m:
compiler/modecheck_call.m:
compiler/modecheck_unify.m:
compiler/modes.m:
compiler/pd_cost.m:
compiler/polymorphism.m:
compiler/post_typecheck.m:
compiler/purity.m:
compiler/quantification.m:
compiler/rl_exprn.m:
compiler/rl_key.m:
compiler/simplify.m:
compiler/table_gen.m:
compiler/term_traversal.m:
compiler/type_util.m:
compiler/typecheck.m:
compiler/unify_gen.m:
compiler/unify_proc.m:
compiler/unique_modes.m:
compiler/unused_args.m:
compiler/notes/compiler_design.html:
doc/reference_manual.texi:
tests/hard_coded/typeclasses/Mmakefile:
tests/hard_coded/typeclasses/existential_data_types.m:
tests/hard_coded/typeclasses/existential_data_types.exp:
tests/warnings/simple_code.exp:
tests/hard_coded/Mmakefile:
tests/term/arit_exp.trans_opt_exp:
tests/term/associative.trans_opt_exp:
tests/term/pl5_2_2.trans_opt_exp:
tests/term/vangelder.trans_opt_exp:
tests/term/arit_exp.trans_opt_exp:
tests/term/associative.trans_opt_exp:
tests/term/pl5_2_2.trans_opt_exp:
tests/term/vangelder.trans_opt_exp:
tests/invalid/errors2.err_exp2:
tests/invalid/prog_io_erroneous.err_exp2:
tests/invalid/type_inf_loop.err_exp2:
tests/invalid/types.err_exp2:
tests/invalid/polymorphic_unification.err_exp:
tests/invalid/Mmakefile:
tests/warnings/simple_code.exp:
tests/debugger/queens.exp:
tests/hard_coded/Mmakefile:
tests/hard_coded/existential_reordering.m:
tests/hard_coded/existential_reordering.exp:
Merge in the changes from the existential_types_2 branch.
Estimated hours taken: 8
Various changes to fix test case failures in the existential_types_2
branch.
compiler/simplify.m:
Delete a bogus sanity check that I had added, since the check
was failing even in cases which made perfect sense.
(This one was stopping the compiler from bootstrapping.)
Delete an obsolete XXX comment about something that has already
been fixed.
When converting polymorphic complicated unifications into
calls to unification procedures, we need to insert the
type_info variables into the goal_info non-locals set.
compiler/simplify.m:
compiler/det_report.m:
Fix a couple of old XXXs: issue warnings when optimizing away
goals with determinism failure or det goals that have no outputs.
This is needed to ensure that we still issue a warning for several
of the goals in tests/warnings/simple_code.m. The previous
warnings were no longer being issued because this optimization was
optimization away the relevant code before it could be warned about.
tests/warnings/simple_code.exp:
Update to reflect the new warnings.
compiler/dependency_graph.m:
Don't include imported modes of pseudo_imported predicates
(i.e. (in,in) modes of unification predicates) in the dependency
graph. The treatment of pseudo_imported predicates in
dependency_graph.m needs to match the way they are treated
by polymorphism.m and other parts of the compiler.
compiler/polymorphism.m:
Update the headvars field of the proc_info for imported procedures
to include the type_info variables. This is necessary because
some parts of the compiler (e.g. unused_args.m) depend on the
headvars field being valid even for imported procedures.
Also fix a bug introduced in my changes to polymorphism.m -- I was
passing down the wrong HeadVars to polymorphism__produce_existq_tvars.
compiler/post_typecheck.m:
compiler/purity.m:
Ensure that we always bind any unbound type variables to `void'
before running polymorphism, even if there were type errors.
This avoids some internal errors in polymorphism.m.
compiler/mercury_compile.m:
Fix a formatting error in one of the progress messages.
compiler/modes.m:
compiler/unique_modes.m:
Ensure that mode analysis always stops analysing things once the
instmap becomes unreachable. It already did this for conjunctions,
most of the time, but there were several other cases
(if-then-elses and switches) where it did not.
The aim of this change is to stop mode inference from creating
modes for procedures with initial insts `not_reached'.
compiler/modecheck_unify.m:
Handle the case where an unification is initially inferred as
a non-complicated unification, and then gets re-modechecked
with the instmap being unreachable. The code here was assuming
that a non-complicated unification can never get turned into
a complicated unification on re-modechecking, but `not_reached'
unifications where being classified as complicated.
The above change to modes.m and unique_modes.m should avoid this
situation, but I thought it was safest to fix the code here too,
just in case.
compiler/modes.m:
compiler/modecheck_call.m:
compiler/mode_util.m:
Pass the type down to normalise_inst and ensure that for type_info
types, it never return a unique inst. The aim is to stop mode
inference from inferring unique modes for the type_info arguments
introduce by polymorphism.m, since unique modes are never useful
for those arguments, and allowing mode inference to infer
unique modes for them leads to it inferring unnecessarily many modes.
(Without this change, the test case tests/valid/uniq_mode_inf_bug.m
fails, due to a bug in the existing mode inference stuff unrelated
to my polymorphism / existential types changes. The bug is that
modecheck_queued_procs needs to run ordinary mode analysis to a
fixpoint before running determinism analysis, etc.)
tests/hard_coded/Mmakefile:
Fix a bug: compile lp.m with the same options as bigtest.m.
Without this, bigtest was getting link errors due to unsatisfied
symbols in lp.m. The problem was due to bigtest.m being compiled
with intermodule optimization, and lp.m being compiled without
intermodule optimization. This lead to bigtest.o containing
inlined references to local routines in lp.m, but lp.o not exporting
those symbols because intermodule optimization had not been enabled
when it was compiled.
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: 1.5
Perform some minor simplifications in mode analysis,
so as to provide more information to unique mode analysis.
Previously unique_modes.m was reporting spurious errors
for tests/hard_coded/bidirectional.m, because modes.m
produced output containing a subgoal of the form
`disj([Goal, conj([disj([])]])' instead of just `Goal',
and the presence of a disjunction then caused unique mode
analysis to make overly conservative assumptions.
compiler/modes.m:
Ensure that we do not produce singleton conjunctions or disjunctions.
Also, if the result of mode checking a disjunct is a (nested)
disjunction, then merge it with the containing disjunction.
If the nested disjunction is the empty disjunction (fail),
then this means it will be deleted.
tests/hard_coded/Mmakefile:
Re-enable the test case bidirectional.m, since the compiler now
accepts it, due to the above change.
tests/warnings/simple_code.m:
tests/warnings/simple_code.exp:
Update this test case, because the above change meant that the
compiler no longer issues the warning about "this disjunct can
never succeed" in cases like this -- mode analysis will already
have optimized it away, before we even get to simplify.m (which
handles those kinds of warnings). This warning is not as
important as allowing bidirectional code.
Estimated hours taken: 4
Fix a bug in unique mode checking.
compiler/unique_modes.m:
Fix a bug reported by Serge Varennes
<serge.varennes@detexis.thomson-csf.com>:
we need to mark variables as `mostly_unique' rather
than `unique' at all disjunctions, not just at model_non
disjunctions, because model_semi and even model_det
disjunctions can still have backtracking from one failing
disjunct into the next disjunct.
Also add a couple of comments.
tests/invalid/Mmakefile:
tests/invalid/uniq_modes.m:
tests/invalid/uniq_modes.err_exp:
Add a regression test for this change.
tests/hard_coded/purity.m:
tests/hard_coded/cc_nondet_disj.m:
Fix code that the compiler now rejects, due to the above change.
The compiler is being a bit conservative to reject these cases,
because the code won't actually violate unique-mode-correctness,
but the conservatism here with disjunctions is similar to unique
mode analysis's already existing conservatism with regard to
if-then-elses, and the work-around for cases like this is easy,
so I don't consider that to be a significant problem.
The conservatism in question is that if it sees
`{ test }, io__write_string("blah")' in a model_det/model_semi
disjunct or in the condition of an if-then-else, it will report
a unique mode error, since it doesn't realize that destructive
update only occurs _after_ we have committed to this branch.
tests/hard_coded/Mmakefile:
Disable the test case bidirectional.m, since the compiler now
rejects it, due to the above change to unique_modes.m.
The compiler is again being overly conservative in its analysis.
The problem is similar to that in the two test cases above,
unfortunately there is no easy work-around in this case.
The compiler really ought to support this style of bidirectional
code using unique modes, so I do consider this to be a significant
problem, but the fix is a fair bit of work, so I will deal with
that as a separate change.
Estimated hours taken: 36
Switch to a closure representation that includes runtime type and procedure id
information, so that closures can be copied, garbage collected, printed, etc.
This RTTI information is not yet used. Adding code to use it would be futile
until Tyson finishes his changes to the other RTTI data structures.
Note also that this change provides the information required for solving the
problem of trying to deep copy closures only for grades that include
--typeinfo-liveness. Providing this info for other grades is future work.
configure.in:
Find out what the right way to refer to a variable-sized array
at the end of a struct is.
runtime/mercury_ho_call.h:
New file to define the structure of closures and macros for accessing
closures.
runtime/Mmakefile:
Add the new header file.
runtime/mercury_ho_call.c:
Add an entry point to handle calls to new-style closures. The code
to handle old-style closures, which was unnecessarily duplicated for
each code model, stays until all the installed compilers use the new
closure representation.
Until that time, the new entry point will contain code to detect
the use of old-style closures and invoke the old code instead.
This allows stage1s compiled with old compilers to use the old style
and stage2 to use the new style without any special tricks anywhere
else.
Add a new entry point to handle method calls of all code models.
The old entry points, which had the same code, will also be deleted
after this change has been bootstrapped.
runtime/mercury_calls.h:
Remove the macros that call closures. Their interface sucked, they
were not used, and their implementation is now out of date.
runtime/mercury_stack_layout.h:
Add a new type, MR_Type_Param_Locns, for use by the C type
representing closures. Since MR_Stack_Layout_Vars has a field,
MR_slvs_tvars, which references a data structure identical
in every way to MR_Type_Param_Locns, change the type of that field
to this new type, instead of the previous cheat.
runtime/mercury_layout_util.h:
Minor update to conform to the new type of the MR_slvs_tvars field.
(This is the only use of that field in the system.)
runtime/mercury_type_info.h:
Add new types MR_TypeInfo and MR_PseudoTypeInfo. For now, they
are just Word, but later we can make them more accurate.
In the meantime, we can refer to them instead of to Word,
making code clearer. One such reference is now in mercury_ho_call.h.
compiler/notes/release_checklist.html:
Add a reminder to remove the redundant code from mercury_ho_call.c
after bootstrapping.
compiler/llds.m:
Replace three code addresses for calling closures and another three
for calling methods with one each.
compiler/call_gen.m:
compiler/dupelim.m:
compiler/opt_debug.m:
compiler/opt_util.m:
compiler/llds_out.m:
Trivial updates in accordance with the change to llds.m
compiler/code_info.m:
Move the code to handle layouts to continuation_info.m,
since that's where it belongs. Leave only the code for picking
up parameters from code_infos and for putting results back in there.
Remove the redundant arguments of code_info__init, and extract
them from ProcInfo, to make clear that they are related.
compiler/code_gen.m:
Since we pass ProcInfo to code_info__init, don't pass its components.
compiler/continuation_info.m:
Add the code moved from code_info.m, in a form which takes explicit
arguments for things that used be hidden in the code_info.
Add new code, closely related to the moved code, that creates
layout info from a procedure's argument info, rather than from a
(part of) the current code generator state. This way, it can be
invoked from places that don't have a code_info for the procedure
for which they want to generate layouts. This is the case when
we generate layouts for closures.
compiler/par_conj_gen.m:
compiler/trace.m:
Minor changes required by the move of stuff from code_info to
continuation_info.
compiler/stack_layout.m:
Export some predicates for use by unify_gen.
compiler/unify_gen.m:
Switch to creating new style closures, complete with layout info.
Optimize the code for extending closures a bit. By copying the
fixed words of the closure outside the loop, we avoid incurring
the loop overhead twice.
compiler/code_util.m:
Add a couple of utility predicates for continuation_info.m and
unify_gen.m
library/benchmarking.m:
library/std_util.m:
Refer to the new entry point for handling closures.
browser/dl.m:
Use the new closure representation.
Note that extras/dynamic_linking/dl.m, which is supposed to be
the same as browser/dl.m but is not, should also be updated, but
this will be handled later by Fergus.
tests/hard_coded/closure_extension.{m,exp}:
A new test case to exercise the code for extending closures.
tests/hard_coded/Mmakefile:
Enable the new test case.
Estimated hours taken: 1
Fix a bug in nondet pragma C codes.
compiler/pragma_c_gen.m:
Fix an off-by-one error that caused the C struct we define
(to hold the items that must be saved from one success of a
nondet pragma C code to the next) to start with the top word
in the next lower nondet stack frame, instead of the word
immediately after that. Therefore an assignment to the first
field of the struct was clobbering the previous stack frame.
tests/hard_coded/nondet_c.{m,exp}:
A new test case to check for this bug.
tests/hard_coded/Mmakefile:
Enable the new test case.
Estimated hours taken: 2
Fix a bug where copy/2 was returning bogus data when copying string literals.
runtime/mercury_deep_copy_body.h:
Change the code so that it doesn't assume that string literals
must be aligned, since currently they aren't.
tests/hard_coded/Mmakefile:
tests/hard_coded/string_alignment_bug.m:
tests/hard_coded/string_alignment_bug.exp:
Add a regression test.
Estimated hours taken: 1
Change the bit shift functions to perform checking to avoid
implementation defined behaviour.
library/int.m:
Add checking to `int:<<' and `int:>>'.
Add `int:unchecked_left_shift' and `int:unchecked_right_shift'
which do not perform any checking.
compiler/code_util.m:
Replace `int:<<' and `int:>>' with `int:unchecked_left_shift' and
`int:unchecked_right_shift' in the builtin table.
NEWS:
Mention the changes to int.m.
tests/hard_coded/Mmakefile:
tests/hard_coded/shift_test.m:
tests/hard_coded/shift_test.exp:
Test the shift functions.
Estimated hours taken: 2
Fix a bug with typeclasses where the compiler would sometimes
generate code that called the wrong method.
compiler/make_hlds.m:
Ensure that the list(pred_proc_id) in the hlds_class_defn
is sorted, to match the way that check_typeclass.m generates
the corresponding list(pred_proc_id) for the hlds_instance_defn.
tests/hard_coded/typeclasses/Mmakefile:
tests/hard_coded/typeclasses/func_default_mode_bug.m:
tests/hard_coded/typeclasses/func_default_mode_bug.exp:
tests/hard_coded/typeclasses/mode_decl_order_bug.m:
tests/hard_coded/typeclasses/mode_decl_order_bug.exp:
Add a couple of regression tests for problems fixed by
the above change.
Estimated hours taken: 25
Fix a bug whereby the @#$!% typeclass-infos nested inside another
typeclass-info (ie. from the constraints on an instance decl) were being
inserted in the reverse order. This caused the code to jump to the wrong
type class method.
compiler/polymorphism.m:
Reverse the list of argument variables that we get back from
polymorphism__make_typeclass_info_vars_2 because they are built
up in reverse.
Also fix a buggy comment about the order that the extra arguments
are added in by this pass.
tests/hard_coded/typeclasses/implied_instance_multi_constraint.{m, exp}:
A test case for this bug fix.
tests/hard_coded/typeclasses/Mmakefile:
Add this test case.
Estimated hours taken: 9
Implement abstract instance declarations.
compiler/prog_data.m:
Rename the `instance_interface' type as `instance_body',
and make it a discriminated union: either `abstract',
or `concrete(Methods)'.
compiler/prog_io_typeclass.m:
compiler/hlds_data.m:
compiler/hlds_out.m:
compiler/equiv_type.m:
compiler/check_typeclass.m:
Change the code to reflect the new name and representation
of `instance_interface'.
compiler/prog_io_typeclass.m:
Parse abstract instance declarations.
compiler/make_hlds.m:
Clean up the code a bit, and make sure that it detects some errors
which previously we didn't detect: duplicate or overlapping
instance declarations, and instance declarations with methods for
classes with no methods.
compiler/check_typeclass.m:
If an instance is abstract, then we don't need to check
that the methods in the instance body match those in the class.
compiler/base_typeclass_info.m:
Only generate base_typeclass_infos for concrete instance
declarations, not for abstract ones.
doc/reference_manual.texi:
Document the change.
tests/hard_coded/typeclasses/Mmakefile:
tests/hard_coded/typeclasses/abstract_instance.m:
tests/hard_coded/typeclasses/use_abstract_instance.m:
tests/hard_coded/typeclasses/use_abstract_instance.exp:
tests/invalid/Mmakefile:
tests/invalid/typeclass_test_9.m:
tests/invalid/typeclass_test_9.err_exp:
Some test cases.
tests/hard_coded/typeclasses/Mmakefile:
Uncomment typeclass_test_5.m, since we pass that now
(and have done so for quite some time).
tests/invalid/typeclass_test_[3-5].err_exp:
Update to reflect additional error messages produced
by the improved error checking in compiler/make_hlds.m.
Estimated hours taken: 0.25
tests/hard_coded/Mmakefile:
tests/hard_coded/factt.m:
tests/hard_coded/factt_examples:
tests/hard_coded/factt.exp:
Add a regression test to test three recently-fixed bugs
related to fact tables:
- duplicate C labels,
- incorrect dependencies with --use-subdirs, and
- undefined symbols due to passing the wrong arguments
to c2init.
Estimated hours taken: 0.1
This set of changes was posted a while ago by Zoltan
but not committed.
tests/debugger/interpreter.exp:
tests/hard_coded/construct.exp:
tests/hard_coded/deep_copy_bug.exp:
tests/hard_coded/expand.exp:
tests/hard_coded/write.exp:
tests/hard_coded/write_reg1.exp:
Update the expected outcomes to reflect the changes
to vars and varsets.
tests/debugger/interpreter.exp2 will need to be updated later.
Estimated hours taken: 0.25
Fix some spurious test cases failures for the debugging test cases.
tests/debugger/*.exp2:
Add alternative expected outputs for the test cases that
produce different results when built in debug grades (i.e.
when linked with a library was built with debugging enabled).
Estimated hours taken: 0.25
tests/hard_coded/term_io_test.m:
Add this file; conway forgot to `cvs add' it before he committed
his recent change which was supposed to add it.
Estimated hours taken: 0.2
tests/hard_coded/Mmakefile:
mention the new test case.
tests/hard_coded/term_io_test.{m,inp,exp}:
A new test case that reads terms from term_io_test.inp and
writes them to stdout. At the moment this only tests a single
bug[fix]: that pred expressions get quoted correctly when
they contain commas in their RHS, but by adding cases to the
.inp and .exp files, can be used to test various quoting/
term_io features.
Estimated hours taken: 0.25
tests/hard_coded/Mmakefile:
Disable the `var_not_found' test case, since we don't pass it --
dgj's recent change to polymorphism.m means that the compiler
now reports `sorry, not implemented' for this test case.
Previously it used to generated incorrect code that
just coincidentally happened to work.
Estimated hours taken: 0.25
tests/hard_coded/quoting_bug_test.exp:
Update the expected output for this test case to
reflect my recent change to the quoting code
in library/term_io.m and library/io.m.
Estimated hours taken: 0.05
tests/hard_coded/Mmakefile:
Fix a bug in my previous change: the new subdirectory is
named `sub-modules', not `nested_mods'.
Estimated hours taken: 1
Change the documentation and test cases to reflect the fact that we
currently don't support parallel makes for nested modules.
(The comments in the write_depenency_file predicate in compiler/modules.m
explain why not.)
doc/reference_manual.texi:
Update the list of bugs and limitations in the sub-modules chapter
to say that we don't support parallel makes for nested modules.
tests/hard_coded/Mmakefile:
tests/hard_coded/nested*.m:
tests/hard_coded/parent*.m:
tests/hard_coded/sub-modules/Mmakefile:
tests/hard_coded/sub-modules/nested*:
tests/hard_coded/sub-modules/parent*:
Move the sub-module test cases to a new subdirectory
`tests/hard_coded/sub-modules'. One reason for this is just
to separate out the test cases for this feature, just as
we do with the typeclass test cases.
But the other reason is to ensure that the nested module test
cases won't get built in parallel, since currently there are
some problems with the Mmake rules for building nested modules
that cause race conditions if you use parallel makes.
Estimated hours taken: 0.75
Fix a bug reported by Tom Conway where term_io__write_term, io__write
and io__write_binary were not properly quoting graphic tokens.
library/term_io.m:
library/io.m:
Change term_io__write_term and io__write to quote graphic
tokens where necessary, so that the output will parse correctly
when followed by ".\n".
tests/hard_coded/write.m:
tests/hard_coded/write.exp:
Add a new test to test the changes to io__write,
and update the expected output for one of the existing tests.
Estimated hours taken: 0.5
tests/Mmake.common:
Allow test cases to have more than one expected output.
tests/general/string_format_test_2.exp2:
tests/general/string_format_test_3.exp2:
tests/hard_coded/no_fully_strict.exp2:
Add alternative expected output for these
test cases, since the output is different
depending on whether or not the program is
compiled in a grade that supports stack traces.
Estimated hours taken: 20
Fix a bug with intermodule optimization of nested modules.
Previously, the compiler used to just label any
predicates defined in a module containing sub-modules
as `exported', since they may be needed by the separately-compiled
sub-modules. However, this is a little bit of a lie,
and it turns out that it doesn't work. The fix is
to use a new status `exported_to_submodules' for this case.
compiler/prog_data.m:
Add a new pseudo-declaration ":- private_interface",
used to mark items in an ":- implementation" section
that will be exported to submodules.
compiler/modules.m:
Put declarations from modules containing sub-modules into
`private_interface' sections rather than into `interface' sections.
compiler/hlds_pred.m:
Add a new alternative `exported_to_submodules' to the
`import_status' data type. Add several new procedures
for testing particular aspects of this type.
compiler/module_qual.m:
Set the import_status of items in a `private_interface'
section to `exported_to_submodules'.
compiler/intermod.m:
Handle procedures with status `exported_to_submodules'
specially. Also reorganize the code here a bit to make
it more maintainable.
compiler/base_type_info.m:
compiler/base_type_info.m:
compiler/base_typeclass_info.m:
compiler/code_util.m:
compiler/dead_proc_elim.m:
compiler/hlds_out.m:
compiler/make_hlds.m:
compiler/termination.m:
compiler/unused_args.m:
Minor changes to reflect the above changes to data-structures;
in particular, use the new procedures defined in hlds_pred.m
instead of hard-coded tests. In termination.m, the changes
included deleting some error-checking code that didn't make
much sense anymore when using the new procedures rather than
using hard-coded tests.
tests/hard_coded/Mmakefile:
tests/hard_coded/nested_intermod.m:
tests/hard_coded/nested_intermod_main.m:
tests/hard_coded/nested_intermod_main.exp:
Add a regression test for the bug mentioned above.
Estimated hours taken: 0.75
Test passing typeclass_infos to C code.
tests/hard_coded/typeclasses/existential_type_classes.m:
tests/debugger/existential_type_classes.m:
Add some code to test passing typeclass_infos to C code.
tests/debugger/existential_type_classes.inp:
Change the mdb input for this test case so that that
output will match what happened previously.
tests/hard_coded/typeclasses/existential_type_classes.exp:
tests/debugger/existential_type_classes.exp:
Modify the expected output for these test cases to reflect
what mdb now outputs for them.
Estimated hours taken: 1
Change the syntax for existential type class constraints to use
`=>' instead of `&'.
We eventually decided that `=>' was better, even though semantically
speaking it's more like conjunction than implication, because of the
symmetry with `<=' for universal type class constraints, and because
the precedence of `=>' matches what we want.
[However, the associativity might not.]
compiler/prog_io.m:
Update the code that parses existential type class constraints.
compiler/mercury_to_mercury.m:
Update the code that prints existential type class constraints.
tests/hard_coded/typeclasses/existential_type_classes.m:
tests/debugger/existential_type_classes.m:
Update the test case that tests existential type class constraints.
Also add a test of passing typeclass_infos to C code.
Estimated hours taken: 6
Fix a bug which caused an internal compiler error for disjunctions
in single-solution contexts with e.g. the first two disjuncts `det'
and third disjunct `cc_multi'.
compiler/det_analysis.m:
In det_infer_disj, replace `at_most_many' with `at_most_many_cc'
if in a single-solution context. This is also done by det_infer_goal,
but it needs to be done here too, to avoid calling error/1 in
det_disjunction_maxsoln.
tests/hard_coded/Mmakefile:
tests/hard_coded/cc_multi_bug.m:
tests/hard_coded/cc_multi_bug.exp:
Test case for the above-mentioned bug.
Estimated hours taken: 6
Fix a bug which caused an internal compiler error for disjunctions
in single-solution contexts with e.g. the first two disjuncts `det'
and third disjunct `cc_multi'.
compiler/det_analysis.m:
In det_infer_disj, replace `at_most_many' with `at_most_many_cc'
if in a single-solution context. This is also done by det_infer_goal,
but it needs to be done here too, to avoid calling error/1 in
det_disjunction_maxsoln.
tests/hard_coded/Mmakefile:
tests/hard_coded/cc_multi_bug.m:
tests/hard_coded/cc_multi_bug.exp:
Test case for the above-mentioned bug.
Estimated hours taken: 16
Extend the layout scheme to handle typeinfos inside typeclass infos,
and thus enable the debugger (and later native gc) to work with programs
that use type classes and existential types.
compiler/llds.m:
Change the data structure that holds information about the locations
of the typeinfo variables of the tvars active at call return sites
from set(pair(tvar, lval)) to map(tvar, set(layout_locn)).
The change from set to map avoids the possibility of inadvertently
duplicating the info for a give type variable.
The change to explicitly keep a set of locations in which the typeinfo
var may be found allows us to use set intersection on those sets if
(a) the program point may be reached via more than one path, and
(b) not all paths have the same sets. Both of these can happen in
programs that use type classes.
The change from lval to layout_locn (which encodes either an lval,
or an lval representing a typeclass info and an (indirect) offset
inside that typeclass info) is necessary support programs with
type classes.
compiler/continuation_info.m:
Change the data structure that holds information about the locations
of the typeinfo variables of the tvars active at a particular program
point the same way and for the same reasons as in llds.m.
Take set intersections of typeinfo var locations whenever we find
multiple live variable info records for the same label.
compiler/call_gen.m:
Delay the construction of the return live variable information
until the code generator state has been updated to reflect where
things will be on return, instead of trying to cobble up this
info into the code generator state that reflects the point just
before the call. Apart from being cleaner, this is necessary
to avoid compiler aborts for programs that use existential types.
The old compiler could not find the typeinfos of any existentially
quantified type vars, since they do not exist before the call.
compiler/code_info.m:
Rewrite and generalize the code for generating live value information.
compiler/trace.m:
Remove the specialized code for generating live value information;
call code_info instead.
compiler/stack_layout.m:
Pick one of several possible locations for a typeinfo var.
Generate the new indirect layout location descriptions.
Reduce the number of tag bits used to describe different kinds of
lvals, to leave more room for the indirect information.
compiler/*.m:
Conform to the above data structure changes.
compiler/hlds_pred.m:
Clarify the documentation of type_info_locn.
runtime/mercury_stack_layout.h:
Update the section that deals with MR_Live_Lval to take
indirect typeinfo locations into account.
runtime/mercury_layout_util.c:
Handle indirect typeinfo locations when interpreting layout structures.
runtime/mercury_layout_util.c:
trace/mercury_trace_internal.c:
Ignore variables whose names start with TypeClassInfo.
runtime/mercury_accurate_gc.c:
runtime/mercury_agc_debug.c:
Add markers to remind Tyson to handle indirect typeinfo locations.
tests/debugger/implied_instance.{m,inp,exp}:
tests/debugger/multi_paramster.{m,inp,exp}:
tests/debugger/existential_type_classes.{m,inp,exp}:
Copies of the tests in tests/hard_coded/typeclasses, modified to
avoid or delay I/O, so that the calls to I/O preds that may or may
not be traced to do not affect the output.
tests/debugger/Mmakefile:
Add the new test cases.
Remove references to the *_lib variants of the old test cases.
They are not necessary if I/O is delayed until after the last
reported trace event.
tests/hard_coded/typeclasses/Mmakefile:
Remove --trace deep from existential_type_classes, since that
aspect of the test case is now covered in the debugger directory.
Estimated hours taken: 1.5
Fix a couple of bugs related to pruning of impure goals with no output
variables.
compiler/det_analysis.m:
Fix a bug: the compiler was automatically inserting pruning
across impure goals with no output variables. That should
happen only for pure or semipure goals. To prevent pruning
in those cases, I changed it so that impure goals with no
output variables are not considered single-solution contexts.
doc/reference_manual.texi:
Document the above-mentioned change.
compiler/clause_to_proc.m:
Fix a bug: when converting a bunch of clauses into a disjunction,
clause_to_proc.m was not computing the proper purity annotation
on the goal_info for the disjunction.
tests/hard_coded/Mmakefile:
tests/hard_coded/impure_prune.m:
tests/hard_coded/impure_prune.exp:
A test case for the above-mentioned changes to det_analysis.m
and clause_to_proc.m.
Estimated hours taken: 240
This checkin has several major purposes, set out in the sections below,
all connected with the implementation of the new debugger command set.
DOCUMENT NEW DEBUG COMMAND SET
doc/user_guide.texi:
Add a new section on the debugger. The description of the commands
is complete, but some of the background sections, and the section
about how to build debuggable executables, are not yet done.
Update the documentation of the tracing options.
doc/generate_mdb_doc:
A new shell script that automatically converts some of the new
sections of the user guide into the online documentation of the
debugger.
doc/mdb_categories:
The fixed initial part of the online documentation.
doc/Mmakefile:
Add rules for creating mdb_doc, the file that is the online
documentation of the debugger, and for installing it together
with mdbrc.
Mmake.common.in:
Define INSTALL_DOC_DIR for doc/Mmakefile.
scripts/mdbrc.in:
A debugger command script that reads in the online documentation
and then defines some standard aliases.
configure.in:
Define the variable that scripts/mdb.in and scripts/mdbrc.in use
to find the right files, and get configure to perform the
substitutions.
configure.in:
scripts/mdb:
scripts/mdb.in:
Replace mdb with mdb.in. Mdb is now created during configuration
from mdb.in, filling in the name of the file that contains the default
debugger initialization commands.
util/info_to_mdb.c:
A program that does most of the work involved in automatically
converting user guide sections into online documentation.
(This couldn't easily be written in sh, because sh's read
command has no notion of pushback.)
util/Mmakefile:
Add info_to_mdb to the list of targets.
tools/bootcheck:
Make sure that the tests in tests/debugger are executed with an
initialization setup that is equivalent to what users will see
by default.
REORGANIZE TRACING OPTIONS
compiler/globals.m:
compiler/handle_options.m:
compiler/options.m:
compiler/trace.m:
Reorganize the handling of trace levels around the new options
--trace-internal, --trace-redo, and --trace-return.
compiler/*.m:
Use the new ways of getting at trace levels.
tests/hard_coded/typeclasses/Mmakefile:
s/--trace all/--trace deep/
SUPPORT RETRY
compiler/trace.m:
After every call to MR_trace(), emit code that checks whether it
should jump away, and if yes, performs the jump. This is used to
implement retry. (The debugger cannot execute the jump itself
because it is in the wrong C stack frame.)
compiler/llds.m:
compiler/continuation_info.m:
compiler/stack_layout.m:
Modify the data structures that record information about live
value at program points, to record the identity of each variable.
This is necessary for the implementation of the restart command,
since we do not want to confuse two distinct variables just because
they have the same name. For example, a variable whose name is X
and number is 5 is now recorded in the name array as "5:X".
Clean up the data structure a bit, so that we don't have to store
dummy names for values that are not variables.
compiler/*.m:
Minor changes to conform to the data structure changes.
runtime/mercury_stack_layout.h:
Redefine an existing macro to strip away the initial number: prefix
from the "name" of a variable (keeping its original function on
changed data), and add a new one to access the raw unstripped data.
runtime/mercury_init.h:
runtime/mercury_wrapper.h:
Update the prototype of MR_trace_{fake,real}, and the type of the
global that points to them.
runtime/mercury_layout_util.h:
Add an extra function, MR_get_register_number, for use by retry.
USE FIXED STACK SLOTS FOR TRACE INFO
compiler/code_gen.m:
compiler/code_info.m:
compiler/live_vars.m:
compiler/trace.m:
If execution tracing is enabled, reserve the first few stack slots
to hold the event number of the call event, the call number, the
call depth, the redo layout structure address (if generating redo
events) and the from_full flag at the time of call (if we are doing
shallow tracing). By allocating the first four of these to fixed stack
slots, the debugger knows where to look for them without having
to be told. It finds out the location of the fifth, if needed,
from a new slot in the proc layout structure. (It is not possible
to allocate all five to fixed stack slots without wasting stack space
in some cases.)
compiler/trace.m:
Remove from the call to MR_trace the parameters that are now in fixed
stack slots, since MR_trace can now look them up itself.
compiler/continuation_info.m:
compiler/stack_layout.m:
Add an extra field to the proc_layout_info. If the module is shallow
traced, this field says which stack slot holds the saved value of
MR_from_full. If it is not shallow traced, this field says that
there is no such stack slot.
runtime/mercury_stack_layout.h:
Add macros for accessing the fixed stack slots holding the event
number of the call event, the call number, the call depth, and,
at a redo event, the redo layout structure address.
Support the new field in proc layouts that gives the location of the
from-full flag (if any).
runtime/mercury_trace_base.[ch]:
trace/mercury_trace.[ch]:
Remove the call number and call depth arguments from MR_trace
and its avatars, since this info is now in fixed stack slots
in every procedure that can call MR_trace. This should reduce
the size of the executable significantly, since there are lots
of calls to MR_trace.
runtime/mercury_init.h:
runtime/mercury_wrapper.h:
Update the prototype of MR_trace_{fake,real}, and the type of the
global that points to them.
START NUMBERING FRAMEVARS FROM ONE
compiler/code_info.m:
compiler/live_vars.m:
compiler/llds_out.m:
compiler/trace.m:
Start numbering framevars from 1 internally to the compiler;
the runtime already starts from 1. This simplifies several tasks.
ADD REDO EVENTS
compiler/trace.m:
compiler/code_gen.m:
Before the code that executes "succeed()", emit code to push a
a temp nondet frame whose redoip points to a label in the runtime
that calls MR_trace for a REDO event and then fails, provided
--trace-redo is set.
compiler/llds.m:
Add a new code address constant, do_trace_redo_fail, which stands
for the address in the trace system to which calls MR_trace for
the redo event and then fails.
compiler/trace.m:
compiler/llds_out.m:
Provided we are doing redo tracing, fill in the slot that holds
the layout information for the REDO event.
compiler/*.m:
Minor changes to conform to handle the new code address constant.
browser/debugger_interface.m:
Add redo to trace_port_type.
runtime/mercury_trace_base.[ch]:
Add a C module containing the code that calls MR_trace for REDO
events.
ENSURE THAT INPUT ARGUMENTS ARE ALWAYS VISIBLE
compiler/trace.m:
When generating the set of live variables at internal ports,
the variables that are in the pre-death set of the goal into which
we are entering may not be available. However, the variables in the
pre-death set that are also in the resume vars set will be available,
so now include info about them in the layout structure for the event.
Since with tracing the non-clobbered input args are in all resume vars
sets, this ensures that these input args will be available from all
internal events.
compiler/code_info.m:
Export a previously internal predicate (current_resume_point_vars)
to make this possible.
BUG FIX: WANT RETURN LAYOUTS
compiler/globals.m:
compiler/call_gen.m:
compiler/code_info.m:
compiler/mercury_compile.m:
Add a new pred globals__want_return_layouts, which says whether the
compiler should generate layout structures for call returns. This pred
centralizes the several previous copies of the test. One of those
copies (the one in call_gen) was faulty, leading to a bug: in the
presence of execution tracing but the absence of accurate gc,
information about the variables that are live at the call return
wasn't being gathered properly.
BUG FIX: #include mercury_trace_base.h
compiler/llds_out.m:
#include mercury_trace_base.h, not mercury_trace.h, since now
mercury_trace_base.h defines everything directly accessible from
modules compiled with tracing.
RECAST MERCURY_TRACE_UTIL AS MERCURY_LAYOUT_UTIL
runtime/mercury_trace_util.[ch]:
runtime/mercury_layout_util.[ch]:
Rename this module from trace_util to layout_util, since it is also
used by the native garbage collector. Remove "trace" from the names
of functions.
Get rid of the global variable MR_saved_regs, and instead thread
a pointer to this data structure through the relevant functions
as an extra argument.
Add a lot more documentation in the header file.
runtime/Mmakefile:
Reflect the module rename.
runtime/*.c:
Refer to the new module.
DELETE EASY-TO-MISUSE MACROS
runtime/mercury_stacks.h:
Delete the based_framevar and based_detstackvar macros, since their
continued use can lead to off-by-one errors, and the saved_framevar
and saved_detstackvar macros, since they are no longer used.
runtime/*.c
Update any references to any macros removed from mercury_stacks.h.
MISC RUNTIME CHANGES
runtime/mercury_trace_base.[ch]:
trace/mercury_trace*.[ch]:
Make typedef'd names conform to the naming convention.
Make MR_trace_call_{seqno,depth} consistently Unsigned, rather than
sometimes Word and sometimes Unsigned.
FIX BUG: MAKE THE DEBUGGER PRINT TO STDOUT, NOT THE CURRENT STREAM
library/io.m:
Export to C code the predicates that return the identities and types
of stdin, stdout and stderr, as well as io__print/[34].
library/std_util.m:
Export to C code a predicate that returns the type_info for the
type stdutil:type_info. This type_info is required if C code
wants to invoke make_permanent on any type_info structure,
as the debugger does.
runtime/mercury_init.h:
Add extern declarations for the C functions now exported from io.m.
runtime/mercury_wrapper.[ch]:
Add new global variables to hold the addresses of these C functions.
runtime/mercury_layout_util.c:
Use indirect calls through these global variables to print Mercury
values, instead of lower-level code.
util/mkinit.c:
Assign the addresses of the functions exported from io.m to the
global variables defined in mercury_wrapper.h.
BUG FIX: STACK TRACE FUNCTIONS DEPEND ON THE LABEL TABLE
runtime/mercury_stack_trace.c:
On entry to any of the functions exported from this module,
ensure that the label table is loaded by calling do_init_modules.
Without a filled-in label table, the stack trace will not be able to
find any stack layout info.
BUG FIX: REMOVE BROWSER/*.C
configure.in:
When removing .c files generated by the C compiler, remove those
in the browser directory as well as the compiler, library and
profiler directories.
IMPLEMENT NEW DEBUGGER COMMAND SET
runtime/mercury_stack_trace.[ch]:
Factor out the code that prints the id of a procedure into a function
of its own, so that it can also be used from the debugger, ensuring
appearance commonality.
Add more documentation in the header file.
trace/mercury_trace_internal.c:
Implement the proposed command set. Command names are now words,
and several commands now have options allowing the user to override
the default print level or strictness of the command, or the
invocation conditions or action of a break point. Allows control
over command echoing and the scrolling of sequences of event reports.
Supports aliases, command file sourcing etc. Implements the retry
command, using the info in the fixed stack slots.
trace/mercury_trace.[ch]:
Extend the trace controls to support the new functionalities
required by the new debugger language, which are print levels,
variable-strictness commands, a more flexible finish command,
and the retry command.
Pass the command structure to MR_trace_event_report, since
the user can now forcibly terminate the scrolling of reports.
trace/mercury_trace_alias.[ch]:
New module to manage aliases for the debugger.
trace/mercury_trace_help.[ch]:
New module to interface to browser/help.m.
trace/mercury_trace_spy.[ch]:
New module to manage break points. The test of whether an event
matches a break point is now much more efficient than before.
The new module also allows several breakpoints with different
actions and different invocation conditions (e.g. all ports,
entry port, interface ports or specific (possibly internal) port)
to be defined on the same procedure.
trace/mercury_trace_tables.[ch]:
New module to manage a table of the debuggable modules, in which
each such module is linked to the list of the layouts of all the
procedures defined in that module. This information allows the
debugger to turn the name of a predicate/function (possibly together
with its arity and mode number) into the procedure layout structure
required by the spy point module. Eventually it may also be useful
in supplying lists of identifiers for command line completion.
Modules for which no stack layout information is available will
not be included in the table, since do_init_modules will not
register any labels for them in the label table.
trace/Mmakefile:
Mention the new files.
runtime/mercury_array_macros.h:
A new file holding macros that can be useful in more than one module.
runtime/Mmakefile:
Mention the new file.
runtime/mercury_conf.h.in:
Mention a new configuration macro, MR_CANNOT_USE_STRUCTURE_ASSIGNMENT,
used by runtime/mercury_array_macros.h.
configure.in:
Find out whether we need to define MR_CANNOT_USE_STRUCTURE_ASSIGNMENT.
ADD TRACE DEPTH HISTOGRAMS
runtime/mercury_conf_param.h:
Document MR_TRACE_HISTOGRAM.
runtime/mercury_trace_base.[ch]:
Define the data structures for the histogram, and print the histogram
when a traced program exits if MR_TRACE_HISTOGRAM is set.
trace/mercury_trace.[ch]:
If MR_TRACE_HISTOGRAM is defined, record a count of the number of
events at each depth. This information can help us evaluate space-time
tradeoffs.
FACTOR OUT SHELL CODE HANDLING GRADE IMPLICATIONS
scripts/final_grade_options.sh-subr:
A new file to contain any code that implements implications between
grade flags; currently implements the implication debug -> use trail.
scripts/mgnuc.in:
scripts/ml.in:
Replace the code that is now in final_grade_options.sh-subr with
an inclusion of final_grade_options.sh-subr.
configure.in:
Handle final_grade_options.sh-subr as {init,parse}_grade_options.sh-subr
are handled.
SIMPLIFY THE MAINTAINANCE OF CONSISTENCY BETWEEN DEBUGGER CODE AND DOCUMENTATION
doc/Mmakefile:
Add rules for creating mdb_command_list, a C code fragment
that can included manually in trace/mercury_trace_internal.c
to supply the list of valid commands, and mdb_command_test.inp,
which is a list of invalid invocations of debugger commands,
which tests whether the help message for such invocations
can be located as expected.
doc/generate_mdb_command_list:
doc/generate_mdb_command_test:
Awk scripts to create mdb_command_list and mdb_command_test.inp
respectively from mdb_doc.
tools/bootcheck:
Copy mdb_command_test.inp from doc to tests/debugger.
tests/debugger/Mmakefile:
Add a new test that checks whether we get an internal error, unable
to locate the right help node, for each invalid command invocation in
mdb_command_test.inp.
UPDATE TEST CASES
tests/debugger/Mmakefile:
Reenable queens. Conform to the new set of options.
tests/debugger/*.inp:
tests/debugger/*.exp:
Update the inputs and expected outputs of the debugger test cases
to use the new command set and output formats.
Estimated hours taken: 7
Add existential type-infos and typeclass-infos to the appropriate location
maps. With --trace all on, this caused a software error in some cases.
compiler/polymorphism.m:
Add code to put the type-info and typeclass-info locations into the
appropriate maps in several spots. Also delete some code which was
deliberately throwing away exisential type-info locations.
tests/hard_coded/typeclasses/Mmakefile:
Turn "--trace all" on for a test case which triggers this bug.
Estimated hours taken: 0.5
tests/hard_coded/Mmakefile:
tests/hard_coded/var_not_found.m:
tests/hard_coded/var_not_found.exp:
Add a regression test for a mode analysis bug that resulted
in a var_not_found error during code generation.
I don't if the bug was ever fixed, it just happened to
go away for some unknown reason.
Estimated hours taken: 0.5
tests/hard_coded/Mmakefile:
tests/hard_coded/bigtest.m:
tests/hard_coded/lp.m:
tests/hard_coded/bigtest.exp:
Add a regression test for a bug that conway reported,
which appears to have already been fixed.
Estimated hours taken: 0.2
hard_coded/existential_bound_tvar.m:
A test case for the exist_q_tvar bug
hard_coded/existential_bound_tvar.exp:
The expected output for the test case.
hard_coded/Mmakefile:
Add the new test case.
Estimated hours taken: 0.5
general/Mmakefile:
general/merge_and_remove_dups.exp:
general/merge_and_remove_dups.m:
hard_coded/Mmakefile:
hard_coded/merge_and_remove_dups.exp:
hard_coded/merge_and_remove_dups.m:
Move merge_and_remove_dups from general to hard_coded, because
NU-Prolog thinks the list of ints is a list of ASCII characters,
and so outputs a different result.
Estimated hours taken: 0.5
general/Mmakefile:
general/merge_and_remove_dups.exp:
general/merge_and_remove_dups.m:
hard_coded/Mmakefile:
hard_coded/merge_and_remove_dups.exp:
hard_coded/merge_and_remove_dups.m:
Move merge_and_remove_dups from general to hard_coded, because
NU-Prolog thinks the list of ints is a list of ASCII characters,
and so outputs a different result.
Estimated hours taken: 50
Rework the handling of types in higher_order.m.
- Fix bugs in higher_order.m that stopped it working with --typeinfo-liveness.
- Perform type and typeclass specialisation.
compiler/polymorphism.m:
Previously the type of typeclass_infos variables did not contain
any information about the constraint about which the variable contains
information. Now the type of a typeclass_info is
`private_builtin:typeclass_info(
private_builtin:constraint([ClassName, ConstrainedTypes]))'.
This allows predicates such as type_list_subsumes to check that
the class constraints match.
Note that `private_builtin:constraint' has no declaration, so
a lookup in the type definition map will fail. That's OK, because
type_to_type_id will fail on it, so it will be treated as a type
variable by any code which doesn't manipulate types directly.
Added polymorphism__typeclass_info_class_constraint to get the
class_constraint from a typeclass_info's type. This isn't used yet.
Also, fix a bug in extract_type_info: an entry in the typeinfo_var_map
was being overwritten using an entry from a dummy typevarset. Actually
the optimization to overwrite the location of the type_info after
extracting it from a typeclass_info was wrong because the type_info
won't be in that location in other branches.
compiler/higher_order.m:
Rework the handling of type substitutions. Now the types of the
called procedure are `inlined' into the calling procedure, rather
than building up the types of the specialised version using the
higher-order arguments. The advantage of this is that the code is
a bit simpler and handles extra type_infos properly. The disadvantage
is that the argument types for specialised versions may be more
specific than they need to be, so in some cases more specialised
versions will be created than before.
Also, don't actually rebuild the higher-order terms in the specialised
versions - just pass the terms through in case they are needed.
Handle the extra typeinfos required for --typeinfo-liveness.
Specialize calls to unify/2, index/2 and compare/3.
Specialize class_method_calls.
Specialize calls to the predicates in private_builtin.m which
manipulate typeclass_infos.
compiler/type_util.m:
type_to_type_id now fails on the dummy `constraint' type.
Remove typeinfos for non-variable types from the typeinfo_varmap
after inlining and higher-order specialisation.
compiler/inlining.m:
Factor out some common code to handle type substitutions
for use by higher_order.m.
compiler/hlds_pred.m:
Return the list of extra type_info variables added to the
argument list.
compiler/goal_util.m:
Take a set of non-locals as an argument to
goal_util__extra_nonlocal_typeinfos rather than extracting
them from a goal.
compiler/special_pred.m:
Handle unmangled unify/compare/index in special_pred_get_type.
compiler/base_type_layout.m:
Don't generate references to the typeinfo for
`private_builtin:constraint' - it doesn't exist.
compiler/unused_args.m:
Don't barf on specialised unification predicate names.
compiler/options.m:
Added options:
`--type-specialization' (default off).
`--higher-order-size-limit' - restrict the size of specialized
versions produced by higher_order.m.
`--disable-opt-for-trace' (default on) - where possible don't
change the options to make the trace match the source code.
compiler/handle_options.m:
Don't disable higher_order.m when --typeinfo-liveness is set.
Handle `--disable-opt-for-trace'.
compiler/hlds_data.m:
compiler/*.m:
Add the instance number to `base_typeclass_info_const' cons_ids,
so that higher_order.m can easily index into the list of instances
for a class to find the methods.
compiler/hlds_out.m:
Use the correct varset when printing out the constraint proofs.
Write the typeclass_info_varmap for each procedure.
compiler/mercury_to_mercury.m:
Print type variables with variable numbers.
library/private_builtin.m:
Add the argument to the typeclass_info type to hold the representation
of the constraint.
runtime/mercury_ho_call.c:
Semidet and nondet class_method_calls where
(0 < num_arg_typeclass_infos < 4) were aborting at runtime
because arguments were being placed starting at r1 rather
than at r(1 + num_arg_typeclass_infos).
doc/user_guide.texi
Document the new options.
compiler/notes/compiler_design.html:
Update the role of higher_order.m.
tests/hard_coded/typeclasses/extra_typeinfo.m:
Test case for the mercury_ho_call.c bug and the polymorphism.m
extract_typeinfo bug and for updating the typeclass_info_varmap
for specialised versions.