compiler/polymorphism.m:
When building the type-infos to be packaged inside a typeclass-info,
apply the variable type bindings first.
tests/valid/instance_unconstrained_tvar.m:
Test case for this.
tests/valid/Mmakefile:
Turn this test on. Also turn another test on which I mistakenly
turned off in my previous commit (because the test was failing).
Estimated hours taken: 4
Fix a bug where polymorphism.m was erroneously applying a type substition
recursively, causing an infinite loop in certain situations.
compiler/polymorphism.m:
Change a call to term__apply_rec_substitution_to_list into
term__apply_substitution_to_list.
Also put the goals to initialise the superclass type-infos *before*
the construction unification for the sub-class.
configure.in:
Add a test to find the number of words needed to represent a
synchronization term.
boehm_gc/gc.h:
fix a declaration by replacing the args () with (void).
boehm_gc/solaris_pthreads.c:
add a missing include
check the return values of pthread calls.
compiler/*.m:
Add handling for the new HLDS goal type par_conj.
Add handling for the four new LLDS instructions:
init_sync_term
fork
join_and_terminate
join_and_continue
compiler/code_info.m:
add a new alternative for slot_contents - sync_term.
compiler/handle_options.m:
add .par as part of the grade
compiler/hlds_goal.m:
add the new goal type par_conj.
compiler/instmap.m:
add instmap__unify which takes a list of instmaps
and abstractly unifies them.
add unify_instmap_delta which tajes two instmap deltas
and abstractly unifies them.
compiler/llds.m:
add the new llds instructions.
compiler/mode_info.m:
add par_conj as a lock reason.
library/Makefile:
work around a bug in the solaris version pthread.h
library/benchmarking.m:
reference the stack zones from the engine structure
rather than from global variables.
library/{nc,sp}_builtin.nl:
add an op declaration for &.
library/std_util.m:
change references to global variables to references inside
the engine structure.
runtime/Mmakefile:
add mercury_thread.{c,h}
add THREADLIBS to the libraries
runtime/*.{c,h}
Remove some old junk from the previous processes/shrd-mem
changes that found their way into the repository.
Add MR_ prefixes to lots of names.
runtime/mercury_context.c:
Add init_thread_stuff for creating and initializing a
context structure for the current thread.
runtime/mercury_context.h:
add a field to the mercury context which stores the thread id
of the thread where this context originated.
add various macros for implementing the new llds instructions.
runtime/mercury_engine.c:
initialize the engine structure, rather than a bunch of globals.
runtime/mercury_engine.h:
declare the mercury_engine structure.
runtime/mercury_regorder.h:
if MR_THREAD_SAFE, and there is at least one global register
then use mr0 as a pointer to the mercury engine structure.
scripts/init_grade_options.sh-subr
add thread_safe
scripts/mgnuc.in
add THREAD_OPTS
scripts/ml.in:
add THREAD_LIBS
Estimated hours taken: 20
Fergus's recent change to the handling of some builtins broke the tracing
of those builtins. The following changes are a fix for this.
compiler/polymorphism.m:
Export the predicate that checks whether a predicate is a builtin
that lacks the usually necessary typeinfos.
Comment out a misleading and in any case not very useful progress
message.
compiler/liveness.m:
Turn off type_info liveness for builtins without typeinfos.
Since these builtins establish no gc points and shouldn't be
execution traced, this is OK.
Make type_info liveness part of live_info, since it can now be
incorrect to look up the value of the option. (This may yield
a speedup.)
compiler/live_vars.m:
compiler/store_alloc.m:
Pass the pred_id to initial_liveness to liveness.m can do the test.
compiler/passes_aux.m:
Add a new traversal type that passes along the pred_id.
compiler/mercury_compile.m:
Turn off execution tracing for the modules builtin.m and
private_builtin.m. The latter contains the interface predicates
for the builtins without typeinfos. Since the interface predicates
also lack the typeinfos, the compiler would get an internal abort
if we left execution tracing on.
In any case, these two modules contain stuff that users should
consider language builtins, which means they should not be execution
traced (they can still be stack traced in the right grade).
Use the new traversal type for the modules that now need the pred_id.
compiler/globals.m:
Allow the trace level to be set from outside, in this case
mercury_compile.m.
The next batch of changes have to do with adding a stack dump command
to the debugger. Since debugging is possible even in non-debug grades,
this in turn requires allowing stack tracing to work in non-debug grades,
on programs in which only some modules are compiled with execution
(and hence stack) tracing.
compiler/llds_out.m:
compiler/mercury_compile.m:
runtime/mercury_conf_param.h:
Llds_out used to output "#include <mercury_imp.h>" as the first
substantive thing in the generated C file. The set of #define
parameters in effect when mercury_imp.h is processed determines
whether the macros that optionally register stack layouts for label
actually do so or not. The values of these parameters are derived
from the grade, which means that with this setup it is not possible
for a non-debug grade program to register its stack layouts in the
label table.
The new version of llds_out looks up the option that says whether
this module is compiled with execution tracing or not, and if it is,
it generates a #define MR_STACK_TRACE_THIS_MODULE *before* the #include
of mercury_imp.h. This causes mercury_conf_param.h, included from
mercury_imp.h, to define the macros MR_USE_STACK_LAYOUTS and
and MR_INSERT_LABELS, which in turn cause stack layouts for labels
in this module to be generated and to be inserted into the label
table, *without* changing the grade string (this last part is why
we do not simply define MR_STACK_TRACE).
Use the same mechanism to #include mercury_trace.h when doing
execution tracing, since it is simpler than the mechanism we
used to use (mercury_compile.m including the #include in a list
of C header file fragments).
compiler/mercury_compile.m:
runtime/mercury_conf_param.h:
Split the MR_NEED_INITIALIZATION_CODE macro into two parts.
The first, MR_MAY_NEED_INITIALIZATION, now controls whether
initialization code makes it into the object file of a module.
The second, MR_NEED_INITIALIZATION_AT_START, determines whether
the initialization code is called before main/2.
When a module is compiled with execution tracing, the macro
MR_INSERT_LABELS turns on MR_MAY_NEED_INITIALIZATION but not
MR_NEED_INITIALIZATION_AT_START. The debugger will make sure
that the initialization code has been called before it tries
to do a stack dump (which needs the initialization code to have
been executed, because it needs labels to have been put into the label
table so that from a return address it can find the layout of the
proc to which it belongs).
Define MR_NEED_INITIALIZATION_AT_START if PROFILE_TIME is defined,
since if PROFILE_TIME is defined mercury_wrapper.c calls init_modules.
The fact that MR_NEED_INITIALIZATION_CODE didn't used to be defined
when PROFILE_TIME was defined was, I believe, a bug, which was
not detected because we do not turn on PROFILE_TIME without also
turning on PROFILE_CALLS.
runtime/mercury_stack_trace.[ch]:
Change the way stack dumps are done, to make it possible to
print stack dumps from the debugger and to use trivial run-length
encoding on the output (so that 100 consecutive calls to p
yield the line "p * 100", rather than 100 lines of "p").
The stack routine now returns an indication of whether the stack dump
was fully successful, and if not, a description of the reason why not.
This requires knowing when we have found the end of the stack dump,
so we provide a global variable, MR_stack_trace_bottom, which
mercury_wrapper.c will set to global_success, the address main/2
goes to on success.
s/multidet/multi/
runtime/mercury_wrapper.c:
Set MR_stack_trace_bottom to the address of globals_success.
Use MR_NEED_INITIALIZATION_AT_START to decide whether to call
do_init_modules.
runtime/mercury_stacks.h:
Provide variants of detstackvar(n) and framevar(n) that look up sp and
curfr in an array of saved regs, for use by the debugger.
runtime/mercury_trace_util.c:
Use the new variants of detstackvar(n) and framevar(n). This fixes
an old bug on SPARCs.
runtime/mercury_trace_internal.c:
Completely reorganize the way debugger commands are handled.
Centralize reading in command lines, and the breaking up of command
lines into words. The command names are the same as they were,
but command syntax is now much easier to change.
Add a new command "d" to dump as much of the stack as the available
information will allow.
runtime/mercury_goto.h:
Cosmetic changes to avoid the use of two different conditional
compilation layout styles.
util/mkinit.c:
Since we cannot know when we generate the _init.c file whether any
modules will be compiled with execution tracing and will thus need
stack tracing, we must now include in the generated _init.c file the
code to call the initialization functions in all the modules, even if
MR_NEED_INITIALIZATION_AT_START is not set, since init_modules
can be called later, from the debugger. (We should be able to
use the same approach with the accurate collector.)
Estimated hours taken: 6
Fix various invasions of the user's namespace by `mercury_builtin.m',
by splitting mercury_builtin.m into two modules, called builtin.m and
private_builtin.m, and ensuring that the latter is imported as if
by `:- use_module' rather than `:- import_module'.
library/builtin.m:
library/private_builtin.m:
Split mercury_builtin.m into two modules, builtin.m,
which contains stuff intended to be public,
and private_builtin.m, which contains implementation
details that are not supposed to be public.
library/mercury_builtin.m:
Add a comment saying that this module is no longer used, and
should eventually be removed. I have not removed it yet, since
that would prevent bootstrapping with the current compiler. It
will be removed as a seperate change later, once all the
changes have propagated.
compiler/prog_util.m:
Change the definition of mercury_private_builtin_module/1 and
mercury_public_builtin_module so that instead of automatically
importing mercury_builtin.m as if by `import_module', the
copiler will now automatically import builtin.m as if by
`import_module' and private_builtin.m as if by `use_module'.
compiler/polymorphism.m:
Change a call to mercury_private_builtin_module/1 for
unsafe_promise_unique to instead call mercury_public_builtin_module/1.
compiler/unify_proc.m:
Avoid hard-coding "mercury_builtin" by instead
calling one of mercury_{private,public}_builtin_module/1.
runtime/mercury_type_info.[ch]:
library/term.m:
library/std_util.m:
compiler/code_util.m:
Change a few hard-coded instances of "mercury_builtin"
to "builtin" or "private_builtin" as appropriate.
runtime/mercury_trace_util.c:
runtime/mercury_trace_internal.c:
library/prolog.m:
compiler/*.m:
Update comments that refer to "mercury_builtin" to instead
refer to either "builtin" or "private_builtin".
doc/Mmakefile:
Don't include the interface to private_builtin.m in the
library reference manual.
tools/bootcheck:
Add `-p'/`--copy-profiler' option. This is needed to get
the above changes to bootstrap.
tools/test_mercury:
Pass `-p' to tools/bootcheck.
tests/term/*.trans_opt_exp:
s/mercury_builtin/builtin/g
Estimated hours taken: 12
Fix some bugs in the handling of "non-simple" type class constraints
(ones for which the types being constrained are not just type variables).
compiler/prog_io_typeclass.m:
Ensure that constraints on type class declarations must be "simple".
This is needed the ensure termination of type checking.
(We already did this for instance declarations, but not for
superclass constraints on type class declarations.)
compiler/prog_data.m:
Document the invariant that the types in a type class constraint
must not contain any information in their term__context fields.
compiler/type_util.m:
compiler/equiv_type.m:
compiler/polymorphism.m:
compiler/prog_io_typeclass.m:
Enforce the above-mentioned invariant.
compiler/typecheck.m:
Allow the declared constraints to be a superset of the
inferred constraints.
When performing context reduction, eliminate declared
constraints at each step rather than only at the end.
Remove declared constraints and apply superclass rules
before applying instance rules.
When applying instance rules, make sure that it is a type
error if there is no matching instance rule for a ground
constraint.
If context reduction results in an error, restore the
original type assign set, to avoid repeating the same
error message at every subsequent call to perform_context_reduction.
compiler/check_typeclass.m:
Change the way we superclass conformance for instance declarations
to take advantage of the new "DeclaredConstraints" argument to
typecheck__reduce_context_by_rule_application.
Estimated hours taken: 0.5
compiler/mercury_compile.m:
compiler/polymorphism.m:
Include some verbose progress messages in the polymorphism pass.
runtime/mercury_memory.h:
runtime/mercury_memory.c:
runtime/mercury_misc.h:
runtime/mercury_misc.c:
Move checked_malloc() to mercury_memory.c, add checked_realloc().
Estimated hours taken: 50
Add support for nested modules.
- module names may themselves be module-qualified
- modules may contain `:- include_module' declarations
which name sub-modules
- a sub-module has access to all the declarations in the
parent module (including its implementation section).
This support is not yet complete; see the BUGS and LIMITATIONS below.
LIMITATIONS
- source file names must match module names
(just as they did previously)
- mmc doesn't allow path names on the command line any more
(e.g. `mmc --make-int ../library/foo.m').
- import_module declarations must use the fully-qualified module name
- module qualifiers must use the fully-qualified module name
- no support for root-qualified module names
(e.g. `:parent:child' instead of `parent:child').
- modules may not be physically nested (only logical nesting, via
`include_module').
BUGS
- doesn't check that the parent module is imported/used before allowing
import/use of its sub-modules.
- doesn't check that there is an include_module declaration in the
parent for each module claiming to be a child of that parent
- privacy of private modules is not enforced
-------------------
NEWS:
Mention that we support nested modules.
library/ops.m:
library/nc_builtin.nl:
library/sp_builtin.nl:
compiler/mercury_to_mercury.m:
Add `include_module' as a new prefix operator.
Change the associativity of `:' from xfy to yfx
(since this made parsing module qualifiers slightly easier).
compiler/prog_data.m:
Add new `include_module' declaration.
Change the `module_name' and `module_specifier' types
from strings to sym_names, so that module names can
themselves be module qualified.
compiler/modules.m:
Add predicates module_name_to_file_name/2 and
file_name_to_module_name/2.
Lots of changes to handle parent module dependencies,
to create parent interface (`.int0') files, to read them in,
to output correct dependencies information for them to the
`.d' and `.dep' files, etc.
Rewrite a lot of the code to improve the readability
(add comments, use subroutines, better variable names).
Also fix a couple of bugs:
- generate_dependencies was using the transitive implementation
dependencies rather than the transitive interface dependencies
to compute the `.int3' dependencies when writing `.d' files
(this bug was introduced during crs's changes to support
`.trans_opt' files)
- when creating the `.int' file, it was reading in the
interfaces for modules imported in the implementation section,
not just those in the interface section.
This meant that the compiler missed a lot of errors.
library/graph.m:
library/lexer.m:
library/term.m:
library/term_io.m:
library/varset.m:
compiler/*.m:
Add `:- import_module' declarations to the interface needed
by declarations in the interface. (The previous version
of the compiler did not detect these missing interface imports,
due to the above-mentioned bug in modules.m.)
compiler/mercury_compile.m:
compiler/intermod.m:
Change mercury_compile__maybe_grab_optfiles and
intermod__grab_optfiles so that they grab the opt files for
parent modules as well as the ones for imported modules.
compiler/mercury_compile.m:
Minor changes to handle parent module dependencies.
(Also improve the wording of the warning about trans-opt
dependencies.)
compiler/make_hlds.m:
compiler/module_qual.m:
Ignore `:- include_module' declarations.
compiler/module_qual.m:
A couple of small changes to handle nested module names.
compiler/prog_out.m:
compiler/prog_util.m:
Add new predicates string_to_sym_name/3 (prog_util.m) and
sym_name_to_string/{2,3} (prog_out.m).
compiler/*.m:
Replace many occurrences of `string' with `module_name'.
Change code that prints out module names or converts
them to strings or filenames to handle the fact that
module names are now sym_names intead of strings.
Also change a few places (e.g. in intermod.m, hlds_module.m)
where the code assumed that any qualified symbol was
fully-qualified.
compiler/prog_io.m:
compiler/prog_io_goal.m:
Move sym_name_and_args/3, parse_qualified_term/4 and
parse_qualified_term/5 preds from prog_io_goal.m to prog_io.m,
since they are very similar to the parse_symbol_name/2 predicate
already in prog_io.m. Rewrite these predicates, both
to improve maintainability, and to handle the newly
allowed syntax (module-qualified module names).
Rename parse_qualified_term/5 as `parse_implicit_qualified_term'.
compiler/prog_io.m:
Rewrite the handling of `:- module' and `:- end_module'
declarations, so that it can handle nested modules.
Add code to parse `include_module' declarations.
compiler/prog_util.m:
compiler/*.m:
Add new predicates mercury_public_builtin_module/1 and
mercury_private_builtin_module/1 in prog_util.m.
Change most of the hard-coded occurrences of "mercury_builtin"
to call mercury_private_builtin_module/1 or
mercury_public_builtin_module/1 or both.
compiler/llds_out.m:
Add llds_out__sym_name_mangle/2, for mangling module names.
compiler/special_pred.m:
compiler/mode_util.m:
compiler/clause_to_proc.m:
compiler/prog_io_goal.m:
compiler/lambda.m:
compiler/polymorphism.m:
Move the predicates in_mode/1, out_mode/1, and uo_mode/1
from special_pred.m to mode_util.m, and change various
hard-coded definitions to instead call these predicates.
compiler/polymorphism.m:
Ensure that the type names `type_info' and `typeclass_info' are
module-qualified in the generated code. This avoids a problem
where the code generated by polymorphism.m was not considered
type-correct, due to the type `type_info' not matching
`mercury_builtin:type_info'.
compiler/check_typeclass.m:
Simplify the code for check_instance_pred and
get_matching_instance_pred_ids.
compiler/mercury_compile.m:
compiler/modules.m:
Disallow directory names in command-line arguments.
compiler/options.m:
compiler/handle_options.m:
compiler/mercury_compile.m:
compiler/modules.m:
Add a `--make-private-interface' option.
The private interface file `<module>.int0' contains
all the declarations in the module; it is used for
compiling sub-modules.
scripts/Mmake.rules:
scripts/Mmake.vars.in:
Add support for creating `.int0' and `.date0' files
by invoking mmc with `--make-private-interface'.
doc/user_guide.texi:
Document `--make-private-interface' and the `.int0'
and `.date0' file extensions.
doc/reference_manual.texi:
Document nested modules.
util/mdemangle.c:
profiler/demangle.m:
Demangle names with multiple module qualifiers.
tests/general/Mmakefile:
tests/general/string_format_test.m:
tests/general/string_format_test.exp:
tests/general/string__format_test.m:
tests/general/string__format_test.exp:
tests/general/.cvsignore:
Change the `:- module string__format_test' declaration in
`string__format_test.m' to `:- module string_format_test',
because with the original declaration the `__' was taken
as a module qualifier, which lead to an error message.
Hence rename the file accordingly, to avoid the warning
about file name not matching module name.
tests/invalid/Mmakefile:
tests/invalid/missing_interface_import.m:
tests/invalid/missing_interface_import.err_exp:
Regression test to check that the compiler reports
errors for missing `import_module' in the interface section.
tests/invalid/*.err_exp:
tests/warnings/unused_args_test.exp:
tests/warnings/unused_import.exp:
Update the expected diagnostics output for the test cases to
reflect a few minor changes to the warning messages.
tests/hard_coded/Mmakefile:
tests/hard_coded/parent.m:
tests/hard_coded/parent.child.m:
tests/hard_coded/parent.exp:
tests/hard_coded/parent2.m:
tests/hard_coded/parent2.child.m:
tests/hard_coded/parent2.exp:
Two simple tests case for the use of nested modules with
separate compilation.
Estimated hours taken: 5
Fix a bug in the optimization where polymorphism.m passes a
base_type_info in place of a type_info for non-polymorphic types.
The type of the variable was `base_type_info' not `type_info'.
This caused inlining.m to be unable to compute a type substitution,
and code_util__cons_id_to_tag aborted on an unsubstituted type
variable.
compiler/mercury_builtin.m
compiler/code_util.m
Add a new builtin, unsafe_type_cast/2, used by common.m
to preserve type correctness.
Make unsafe_promise_unique/2 a builtin, since it is basically
the same as unsafe_type_cast/2.
compiler/polymorphism.m
Set the type of a `base_type_info' passed where a `type_info'
is expected to `type_info'.
Don't add the type_info argument for unsafe_type_cast, since it is
not needed and would make the code in common.m more complicated.
compiler/common.m
Generate a call to unsafe_type_cast rather than an assignment
unification when the assignment would not be type correct.
tests/valid/inlining_bug.m
Regression test.
tests/general/common_type_cast.m
tests/general/common_type_cast.exp
Test of type casts.
Estimated hours taken: 0.5
compiler/polymorphism.m:
Add an explicit type qualification, to work around a
bug with intermodule optimization that causes a spuriou
ambiguity errors when the compiler is bootstapped with
`-O4 --intermodule-optimization'.
Estimated hours taken: 45
Assorted changes to make the HLDS type and mode correct
after lambda expansion. The HLDS is still not unique mode
correct after common structure elimination.
compiler/det_analysis.m
Make sure the inferred_determinism field of the proc_info is filled
in correctly for imported procedures and class methods.
compiler/mode_util.m
Fix a bug in recompute_instmap_delta_call to do with unreachable
instmaps. This caused an abort a couple of months ago when
compiling with --deforestation (not yet committed), but
can't currently be reproduced.
compiler/hlds_pred.m
compiler/lambda.m
Add a field to the proc_info to record which args_method
should be used for this procedure. Procedures directly
called by do_call_*_closure must be compiled with
the `compact' argument convention to avoid the need to permute
the arguments so inputs come before outputs.
compiler/lambda.m
compiler/higher_order.m
Remove permutation of argument variables of lambda expressions
so the HLDS is type and mode correct and mode analysis can
be rerun. Otherwise, rerunning mode analysis will fail on
tests/hard_coded/ho_order.m.
compiler/arg_info.m
Added arg_info__ho_call_args_method which returns
an args_method which can always be directly called by
do_call_*_closure (`compact').
Added arg_info__args_method_is_ho_callable to check that
a given args_method can be directly called.
compiler/unify_gen.m
Abort if a closure is created for a procedure compiled
with the simple argument convention.
compiler/hlds_goal.m
compiler/lambda.m
Mode analysis was not storing the non-locals list on which the
uni_modes field of the construction of a lambda goal was computed.
If the nonlocals were renamed, the sort order could change, and
the non-locals could be incorrectly matched with the arguments
of the introduced lambda expression, causing a mode error. The
argument list is now stored.
This caused rerunning mode-checking on tests/valid/lazy_list.m
after polymorphism to fail.
compiler/*.m
Fill in the args_method field of proc_infos with the value
from the globals.
Handle the extra argument to the lambda_goal unify_rhs.
compiler/follow_vars.m
Remove code to handle complicated unifications, since
they should be removed by polymorphism.m.
compiler/special_pred.m
library/mercury_builtin.m
Make the uniqueness of the comparison_result argument
of builtin_compare_* and the automatically generated
comparison procedures match that of compare/3. Unique mode
errors will still be introduced if polymorphism.m specializes
calls to any of the unique modes of compare/3 and then mode analysis
is rerun, since the compiler-generated comparison procedures
only implement the (uo, in, in) mode. (This is not yet a problem
because currently we don't rerun mode analysis.)
runtime/mercury_ho_call.c
Remove code in do_call_*_closure to deal with the
`simple' args_method. Since the output arguments no longer
need to be moved, the closure call is now a tailcall.
Remove some magic numbers.
compiler/modecheck_unify.m
Avoid some aborts and mode errors when rerunning mode analysis,
especially those resulting from not_reached insts being treated
as bound.
Avoid aborting on higher-order predicate constants with multiple
modes if lambda expansion has already been run.
tests/valid/higher_order.m
Add a test case for an abort in mode analysis when
compiling with --deforestation (not yet committed),
due to a predicate constant for a procedure with multiple
modes.
tests/valid/unreachable_code.m
Add a test case for bogus higher-order unification
mode errors in unreachable code.
Estimated hours taken: 1
Disable the specialisation of class methods, since it did not work in the
presence of implied instances. The problem is that where there is a constraint
on the instance decl, the methods for that instance need an extra typeclass
info, which did not get passed during specialisation.
compiler/polymorphism.m:
Disable class method specialisation until a fix is found.
Estimated hours taken: 3 (plus 1 from dgj)
compiler/polymorphism.m:
For calls to class methods, if the particular class instance is
known at the call site, then specialize the code by generating
a direct call to the method for that instance.
tests/invalid/Mmakefile:
tests/invalid/typeclass_test_{1,2,3,4}.m:
tests/invalid/typeclass_test_{1,2,3,4}.err_exp:
tests/hard_coded/Mmakefile:
tests/hard_coded/typeclass_test_{5,6}.m:
tests/hard_coded/typeclass_test_{5,6}.exp:
Some test cases for type classes, including one for the above change.
Estimated hours taken: 0.5
compiler/options.m:
compiler/handle_options.m:
compiler/globals.m:
compiler/polymorphism.m:
runtime/mercury_type_info.h:
Remove the last vestiges of support for type_info representations
other than "shared-one-or-two-cell".
Estimated hours taken: 40
Implement nondet pragma C codes.
runtime/mercury_stacks.h:
Define a new macro, mkpragmaframe, for use in the implementation
of nondet pragma C codes. This new macro includes space for a
struct with a given sruct tag in the nondet stack frame being created.
compiler/{prog_data.m,hlds_goal.m}:
Revise the representation of pragma C codes, both as the item and
in the HLDS.
compiler/prog_io_pragma.m:
Parse nondet pragma C declarations.
Fix the indentation in some places.
compiler/llds.m:
Include an extra argument in mkframe instructions. This extra argument
gives the details of the C structure (if any) to be included in the
nondet stack frame to be created.
Generalize the LLDS representation of pragma C codes. Instead of a
fixed sequence of <assign from inputs, user c code, assign to outputs>,
let the sequence contain these elements, as well as arbitrary
compiler-generated C code, in any order and possibly with repetitions.
This flexibility is needed for nondet pragma C codes.
Add a field to pragma C codes to say whether they can call Mercury.
Some optimizations can do a better job if they know that a pragma C
code cannot call Mercury.
Add another field to pragma C codes to give the name of the label
they refer to (if any). This is needed to prevent labelopt from
incorrectly optimizing away the label definition.
Add a new alternative to the type pragma_c_decl, to describe the
declaration of the local variable that points to the save struct.
compiler/llds_out.m:
Output mkframe instructions that specify a struct as invoking the new
mkpragmaframe macro, and make sure that the struct is declared just
before the procedure that uses it.
Other minor changes to keep up with the changes to the representation
of pragma C code in the LLDS, and to make the output look a bit nicer.
compiler/pragma_c_gen.m:
Add code to generate code for nondet pragma C codes. Revise the utility
predicates and their data structures a bit to make this possible.
compiler/code_gen.m:
Add code for the necessary special handling of prologs and epilogs
of procedures defined by nondet pragma C codes. The prologs need
to be modified to include a programmer-defined C structure in the
nondet stack frame and to communicate the location of this structure
to the pragma C code, whereas the functionality of the epilog is
taken care of by the pragma C code itself.
compiler/make_hlds.m:
When creating a proc_info for a procedure defined by a pragma C code,
we used to insert unifications between the headvars and the vars of
the pragma C code into the body goal. We now perform substitutions
instead. This removes a factor that would complicate the generation
of code for nondet pragma C codes.
Pass a moduleinfo down the procedures that warn about singletons
(and other basic scope errors). When checking whether to warn about
an argument of a pragma C code not being mentioned in the C code
fragment, we need to know whether the argument is input or output,
since input variables should appear in some code fragments in a
nondet pragma C code and must not appear in others. The
mode_is_{in,out}put checks need the moduleinfo.
(We do not need to check for any variables being mentioned where
they shouldn't be. The C compiler will fail in the presence of any
errors of that type, and since those variables could be referred
to via macros whose definitions we do not see, we couldn't implement
a reliable test anyway.)
compiler/opt_util.m:
Recognize that some sorts of pragma_c codes cannot affect the data
structures that control backtracking. This allows peepholing to
do a better job on code sequences produced for nondet pragma C codes.
Recognize that the C code strings inside some pragma_c codes refer to
other labels in the procedure. This prevents labelopt from incorrectly
optimizing away these labels.
compiler/dupelim.m:
If a label is referred to from within a C code string, then do not
attempt to optimize it away.
compiler/det_analysis.m:
Remove a now incorrect part of an error message.
compiler/*.m:
Minor changes to conform to changes to the HLDS and LLDS data
structures.
Estimated hours taken: 8
Clean up the handling of unbound type variables.
Fix a bug with unbound type variables in lambda expressions.
Run purity analysis, modechecking etc. even if there were type errors.
compiler/mercury_compile.m:
Run purity analysis, modechecking etc. even if there were type
errors. This fixes a bug (inconsistency between the code and
the comments) that seems to have been introduced in stayl's
change to mercury_compile.m (revision 1.25) to add intermodule
unused argument elimination: the comment said "continue,
even if type checking found errors", but the code did not
continue.
This change was needed to ensure that we still report a warning
message about unused type variables for tests/invalid/error2.m;
without it, we stop after type checking and don't do purity
analysis, and so don't report the warning.
compiler/typecheck.m:
compiler/purity.m:
Move the code for checking for unbound type variables
from typecheck.m to purity.m. It needs to be done
*after* type inference has been completed, so it
can't be done in the ordinary type checking/inference
passes. Add code to purity.m to bind the
unbound type variables to the builtin type `void'.
compiler/polymorphism.m:
Comment out old code to bind unbound type variables
to `void'; the old code was incomplete, and this
is now done in purity.m.
compiler/notes/compiler_design.html:
Document the above changes.
tests/valid/Mmakefile:
tests/valid/unbound_tvar_in_lambda.m:
Regression test for the above-mentioned bug with unbound type
variables in lambda expressions.
tests/warnings/singleton_test.exp:
tests/invalid/errors2.err_exp:
Change the expected warning message for unbound type variables.
The error context is not as precise as it used to be, I'm afraid:
we only know which function/predicate the error occurred in,
not which clause. Also it now comes out in a different order
relative to the other error messages.
tests/invalid/errors2.err_exp:
tests/invalid/funcs_as_preds.err_exp:
Add some new error/warning messages that are output now that
we run mode and determinism analysis even if there are type errors.
Estimated hours taken: 60
A rewrite of termination analysis to make it significantly easier to modify,
and to extend its capabilities.
compiler/error_util.m:
A new file containing code that makes it easier to generate
nicely formatted error messages.
compiler/termination.m:
Updates to reflect the changes to the representation of termination
information.
Instead of doing pass 1 on all SCCs and then pass 2 on all SCCs,
we now do both pass 1 and 2 on an SCC before moving on to the next.
Do not insist that either all procedures in an SCC are
compiler-generated or all are user-written, since this need not be
true in the presence of user-defined equality predicates.
Clarify the structure of the code that handles builtins and compiler
generated predicates.
Concentrate all the code for updating module_infos in this module.
Previously it was scattered in several places in several files.
Put all the code for writing out termination information at the
end of the module in a logical order.
compiler/term_traversal.m:
A new file containing code used by both pass 1 and pass 2 to
traverse procedure bodies.
compiler/term_pass1.m:
Use the new traversal module.
Clarify the fixpoint computation on the set of output supplier
arguments.
Remove duplicates from the list of equations given to the solver.
This avoids a det stack overflow in lp.m when doing termination
analysis on options.m.
If an output argument of a predicate makes sense only in the absence
of errors, then return it only in the absence of errors.
compiler/term_pass2.m:
Use the new traversal module. Unlike the previous code, this allows us
to ignore recursive calls with input arguments bigger than the head
if those calls occur after goals that cannot succeed (since those
calls will never be reached).
Implement a better way of doing single argument analysis, which
(unlike the previous version) works in the presence of mutual recursion
and other calls between the recursive call and the start of the clause.
Implement a more precise way of checking for recursions that don't
cause termination problems. We now allow calls from p to q in which
the recursive input supplier arguments can grow, provided that on
any path on which q can call p, directly or indirectly, the recursive
input supplier arguments shrink by a greater amount.
If an output argument of a predicate makes sense only in the absence
of errors, then return it only in the absence of errors.
compiler/term_util.m:
Updates to reflect the changes to the representation of termination
information.
Reorder to put related code together.
Change the interface of several predicates to better reflect the
way they are used.
Add some more utility predicates.
compiler/term_errors.m:
Small changes to the set of possible errors, and major changes in
the way the messages are printed out (we now use error_util).
compiler/options.m:
Change --term-single-arg from being a bool to an int option,
whose value indicates the maximum size of an SCC in which we try
single argument analysis. (Large SCCs can cause single-arg analysis
to require a lot of iterations.)
Add an (int) option that controls the max number of paths
that we are willing to analyze (analyzing too many paths can cause
det stack overflow).
Add an (int) option that controls the max number of causes of
nontermination that we print out.
compiler/hlds_pred.m:
Use two separate slots in the proc_info to hold argument size data
and termination info, instead of the single slot used until now.
The two kinds of information are produced and used separately.
Make the layout of the get and set procedures for proc_infos more
regular, to facilitate later updates.
The procedures proc_info_{,set_}variables did the same work as
proc_info_{,set_}varset. To eliminate potential confusion, I
removed the first set.
compiler/*.m:
Change proc_info_{,set_}variables to proc_info_{,set_}varset.
compiler/hlds_out.m:
compiler/make_hlds.m:
compiler/mercury_to_mercury.m:
Change the code to handle the arg size data and the termination
info separately.
compiler/prog_data.m:
Change the internal representation of termination_info pragmas to
hold the arg size data and the termination info separately.
compiler/prog_io_pragma.m:
Change the external representation of termination_info pragmas to
group the arg size data together with the output supplier data,
to which it is logically connected.
compiler/module_qual.m:
compiler/modules.m:
Change the code to accommodate the change to the internal
representation of termination_info pragmas.
compiler/notes/compiler_design.html:
Fix some documentation rot, and clarify some points.
Document termination analysis.
doc/user_guide.texi:
Document --term-single-arg and the new options.
Remove spaces from the ends of lines.
library/bag.m:
Add a new predicate, bag__least_upper_bound.
Fix code that would do the wrong thing if executed by Prolog.
Remove spaces from the ends of lines.
library/list.m:
Add a new predicate, list__take_upto.
library/set{,_ordlist}.m:
Add a new predicate, set{,_ordlist}__count.
tests/term/*:
A bunch of new test cases to test the behaviour of termination
analysis. They are the small benchmark suite from our paper.
tests/Mmakefile:
Enable the new test case directory.
Estimated hours taken: 500 or so
This change implements typeclasses. Included are the necessary changes to
the compiler, runtime and library.
compiler/typecheck.m:
Typecheck the constraints on a pred by adding constraints for each
call to a pred/func with constraints, and eliminating constraints
by applying context reduction.
While reducing the constraints, keep track of the proofs so that
polymorphism can produce the tyepclass_infos for eliminated
constraints.
compiler/polymorphism.m:
Perform the source-to-source transformation which turns code with
typeclass constraints into code without constraints, but with extra
"typeclass_info", or "dictionary" parameters.
Also, rather than always having a type_info directly for each type
variable, sometimes the type_info is hidden inside a typeclass_info.
compiler/bytecode*.m:
Insert some code to abort if bytecode generation is used when
typeclasses are used.
compiler/call_gen.m:
Generate code for a class_method_call, which forms the body of a class
method (by selecting the appropriate proc from the typeclass_info).
compiler/dead_proc_elim.m:
Don't eliminate class methods if they are potentially used outside
the module
compiler/hlds_data.m:
Define data types to store:
- the typeclass definitions
- the instances of a class
- "constraint_proof". ie. the proofs of redundancy of a
constraint. This info is used by polymorphism to construct the
typeclass_infos for a constraint.
- the "base_tyepclass_info_constant", which is analagous the
the base_type_info_constant
compiler/hlds_data.m:
Define the class_method_call goal. This goal is inserted into the
body of class method procs, and is responsible for selecting the
appropriate part of the typeclass_info to call.
compiler/hlds_data.m:
Add the class table and instance table to the module_info.
compiler/hlds_out.m:
Output info about base_typeclass_infos and class_method_calls
compiler/hlds_pred.m:
Change the representation of the locations of type_infos from "var"
to type_info_locn, which is either a var, or part of a typeclass_info,
since now the typeclass_infos contain the type_infos for the type that
they constrain.
Add constraints to the pred_info.
Add constraint_proofs to the pred_info (so that typeclass.m can
annotate the pred_info with the reasons that constraints were
eliminated, so that polymorphism.m can in turn generate the
typeclass_infos for the constraints).
Add the "class_method" marker.
compiler/lambda.m:
A feable attempt at adding class ontexts to lambda expressions,
untested and almost certainly not working.
compiler/llds_out.m:
Output the code addresses for do_*det_class_method, and output
appropriately mangled symbol names for base_typeclass_infos.
compiler/make_hlds.m:
Add constraints to the types on pred and func decls, and add
class and instance declarations to the class_table and instance_table
respectively.
compiler/mercury_compile.m:
Add the check_typeclass pass.
compiler/mercury_to_mercury.m:
Output constraints of pred and funcs, and output typeclass and instance
declarations.
compiler/module_qual.m:
Module qualify typeclass names in pred class contexts, and qualify the
typeclass and instance decls themselves.
compiler/modules.m:
Output typeclass declarations in the short interface too.
compiler/prog_data.m:
Add the "typeclass" and "instance" items. Define the types to store
information about the declarations, including class contexts on pred
and func decls.
compiler/prog_io.m:
Parse constraints on pred and func declarations.
compiler/prod_out.m:
Output class contexts on pred and func decls.
compiler/type_util.m:
Add preds to apply a substitution to a class_constraint, and to
a list of class constraints. Add type_list_matches_exactly/2. Also
add typeclass_info and base_typeclass_info as types which should not
be optimised as no_tag types (seeing that we cheat a bit about their
representation).
compiler/notes/compiler_design.html:
Add notes on module qualification of class contexts. Needs expansion
to include more stuff on typeclasses.
compiler/*.m:
Various minor changes.
New Files:
compiler/base_typeclass_info.m:
Produce one base_typeclass_info for each instance declaration.
compiler/prog_io_typeclass.m:
Parse typeclass and instance declarations.
compiler/check_typeclass.m:
Check the conformance of an instance declaration to the typeclass
declaration, including building up a proof of how superclass
constraints are satisfied so that polymorphism.m is able to construct
the typeclass_info, including the superclass typeclass_infos.
library/mercury_builtin.m:
Implement that base_typeclass_info and typeclass_info types, as
well as the predicates type_info_from_typeclass_info/3 to extract
a type_info from a typeclass_info, and superclass_from_typeclass_info/3
for extracting superclasses.
library/ops.m:
Add "typeclass" and "instance" as operators.
library/string.m:
Add a (in, uo) mode for string__length/3.
runtime/mercury_ho_call.c:
Implement do_call_*det_class_method, which are the pieces of code
responsible for extracting the correct code address from the
typeclass_info, setting up the arguments correctly, then executing
the code.
runtime/mercury_type_info.h:
Macros for accessing the typeclass_info structure.
Estimated hours: 0.5
Minor efficiency improvment.
compiler/type_util.m:
compiler/polymorphism.m:
compiler/switch_gen.m:
Change the type category `user_type(Type)' to just `user_type';
pass the type as well as the type category, if needed.
Estimated hours taken: 1
Fix a bug for the case of a higher-order function call in code
with common sub-expression; mercury 0.7 failed this test, reporting
"Software Error: modecheck fails when repeated", due to confusion
between h.o. _function_ call and h.o. _predicate_ call.
compiler/hlds_goal.m:
Add `pred_or_func' field to HLDS higher_order_calls.
compiler/modes.m:
compiler/modecheck_call.m:
compiler/hlds_out.m:
compiler/*.m:
Add code to handle new field for higher_order_call goals.
tests/valid/Mmake:
tests/valid/ho_func_call.m:
Regression test for the above-mentioned bug.
Estimated hours taken: 1.5
Profiling code with lots of lambda goals was painful, because the names
of the predicates contained no information about which piece of the source
they correspond to. This change corrects this problem by enabling the
profiler to produce output such as:
... 0.00 0.00 <pred/func goal from lp:'pivot', line 362> [10]
... 0.00 0.00 <pred/func goal from lp:'pivot', line 356> [11]
... 0.00 0.00 <pred/func goal from lp:'simplex', line 262> [12]
compiler/lambda.m:
compiler/polymorphism.m:
construct more meaningful predicate names for lambda predicates.
this required adding the name of the predicate that contained the
lambda goal to the info structures that gets threaded through
these modules.
profiler/demangle.m:
util/mdemangle.c:
demangle the names for lambda goals.
Estimated hours taken: 2
compiler/polymorphism.m:
Fix another bug in the recalculation of the non-local variables:
we need to requantify if we have added any type variables,
not just if we have added type variables that are non-local
at the top level.
std_util:type_name/1.
compiler/base_type_info.m:
compiler/polymorphism.m:
library/mercury_builtin.m:
Add module names to base_type_infos.
library/io.m:
library/term.m:
Check module names as well as type names for special cases.
Add module qualifiers to terms that represent types
(That is, when converting type_infos to terms).
library/std_util.m:
Add type_ctor_module_name/1, add an argument to
type_ctor_name_and_arity for the module name.
Add module qualifiers to the name returned by type_name.
runtime/type_info.h:
Define the offset fo type module names, add
MR_TYPECTOR_GET_HOT_MODULE_NAME and
MR_BASE_TYPEINFO_GET_TYPE_MODULE_NAME
tests/hard_coded/higher_order_type_manip.exp:
tests/hard_coded/write.exp:
tests/hard_coded/write_.exp:
Update test case expected output with module qualifiers where needed.
Estimated hours taken: 0.5
compiler/polymorphism.m:
Fix a bug in my previous bug fix: it was calling
map__apply_to_list to apply the type-info variable map to a
list of type variables, but not every type variable has a type
info.
Estimated hours taken: 1
compiler/simplify.m
compiler/higher_order.m
Fix some places where goal_info fields were not being filled
in correctly.
compiler/hlds_goal.m
Added goal_info_init/4 which takes the nonlocals, instmap_delta
and determinism of the goal. All goal_info_inits after determinism
analysis should probably use this version.
compiler/common.m
compiler/polymorphism.m
Use goal_info_init/4.
tests/general/prune_switch.m
Test case.
Estimated hours taken: 0.5
compiler/polymorphism.m:
Fix a bug: it was over-approximating the non-locals, which
caused the generated HLDS to be mode-incorrect, because it
could contain a construction for a type_info variable which was
(spuriously) non-local to the condition of the if-then-else in
which it occurred. That's not legal because you can't bind
non-local variables in the condition of an if-then-else.
Estimated hours taken: 20
Reorganisation of modules to do with the inst data type.
This is actually the first installment of the alias tracking mode
checker in disguise. A very good disguise. The rationale for
this reorganisation is to reduce coupling in the part of the mode
checker which is _not_ in this change (ie most of it).
Alias tracking requires a new kind of inst, alias(inst_key), where
an inst_key is a handle on some other sub-inst. With it goes a
data structure in which to store dereferenced insts and all the
operations which go with it. This code will go in the new module
inst.m so that it doesn't have to go in prog_data.m. (I briefly
considered putting it in instmap.m however this introduces some
bad coupling since instmap.m imports hlds_module.m. Putting it
in prog_data.m would cause hlds_*.m to depend on prog_data.m,
but we have designed things so that the dependencies go in the
other direction.)
The remainder of the reorganisation is a general cleanup: the
inst testing predicates (inst_is_*) have been moved out of
mode_util because they are not actually operations on modes at
all, and have been moved into inst_match. inst_match has then
been split because otherwise it would be 2000 lines long and
will get significantly bigger when aliasing is added. Roughly
speaking, any operations which create new insts from old ones
have been moved into a new module, inst_util while any operations
which test the values of insts remain in inst_match.
Also included are the removal of some NU-Prologisms since the
NU-Prolog version of the compiler is no longer supported. Two
changes here:
- Removal of some when declarations.
- A gross hack in inst_is_*_2, where two copies of
the same inst were passed into the predicate so that
one could be switched on. Thank NU-Prolog's lack of
common subexpression elimination.
compiler/inst.m:
New module which contains the data types inst, uniqueness,
pred_inst_info, bound_inst.
compiler/inst_util.m:
New module which contains predicates which perform mode
checking-like operations on insts.
Moved in:
abstractly_unify_inst, abstractly_unify_inst_functor,
inst_merge, make_mostly_uniq_inst (from inst_match.m)
compiler/inst_match.m:
Moved out:
inst_merge, make_mostly_uniq_inst,
abstractly_unify_inst, abstractly_unify_inst_functor
(to inst_util.m)
Moved in:
inst_is_*, inst_list_is_*, bound_inst_list_is_*
(from mode_util.m)
Now exported:
unique_matches_initial/2, unique_matches_final/2
inst_contains_instname/3, pred_inst_matches/3
(They are required by inst_util.m, and they are
useful in their own right.)
compiler/instmap.m:
instmap_delta_lookup_var/3 reincarnated as
instmap_delta_search_var/3. The reason for this change is
that previously, instmap_delta_lookup_var simply returned
`free' if the searched-for var did not occur in the
instmap_delta. This is somewhat non-obvious behaviour.
instmap_delta_search_var/3 fails in such a situation.
compiler/mode_util.m:
Moved out:
inst_is_*, inst_list_is_*, bound_inst_list_is_*
(to inst_match.m)
(These are not really operations on modes.)
compiler/modecheck_call.m:
Moved in modecheck_higher_order_func_call/5, from modecheck_unify.m
compiler/modecheck_unify.m:
Moved out modecheck_higher_order_func_call/5, to modecheck_call.m
where it should have been all along.
compiler/prog_data.m:
Moved out the types inst, uniqueness, pred_inst_info,
bound_inst (to inst.m).
compiler/common.m:
compiler/cse_detection.m:
compiler/fact_table.m:
compiler/higher_order.m:
compiler/hlds_data.m:
compiler/hlds_goal.m:
compiler/hlds_out.m:
compiler/intermod.m:
compiler/liveness.m:
compiler/llds.m:
compiler/make_hlds.m:
compiler/mercury_to_mercury.m:
compiler/mode_debug.m:
compiler/mode_errors.m:
compiler/mode_info.m:
compiler/modes.m:
compiler/module_qual.m:
compiler/polymorphism.m:
compiler/prog_io.m:
compiler/prog_io_util.m:
compiler/prog_util.m:
compiler/simplify.m:
compiler/switch_detection.m:
compiler/unify_proc.m:
compiler/unique_modes.m:
Miscellaneous minor changes to cope with the above changes.
compiler/notes/compiler_design.html:
Document the new modules.
Estimated hours taken: 5
Allow the names of higher order types to be generated.
LIMITATIONS:
Document limitations introduced by this change.
compiler/polymorphism.m:
Map higher order predicates to pred/0 and functions to func/0.
library/mercury_builtin.m:
Move base_type_* for pred/0 out of library (into runtime).
library/std_util.m:
Check for pred/0 and func/0 when comparing type infos.
Create different ctor_infos for higher order preds, decode them
correctly for args and functors when needed.
Print functions nicely (eg func(foo) = bar).
Fix ML_create_type_info so it works correctly with higher order
types.
runtime/type_info.h:
Define macros to deal with new representation of higher order
ctor_infos.
runtime/deep_copy.c:
Fix make_type_info so it works correctly with higher order
types.
runtime/Mmakefile:
runtime/type_info.mod:
Add definitions for pred/0 and func/0 in runtime, they are
needed by deep copy.
tests/hard_coded/Mmake:
tests/hard_coded/higher_order_type_manip.exp:
tests/hard_coded/higher_order_type_manip.m:
Test case for this change.
Estimated hours taken: 1
compiler/polymorphism.m:
Fix a bug in polymorphism__fixup_preds: in the case of a predicate
with no modes, it wasn't doing the recursive call to fix up
the remaining predicates.
Estimated hours taken: 5
Remove support for term_to_type and type_to_term implemented as special
preds. Remove support for one-cell and one-or-two-cell type_infos (now
shared-one-or-two-cell type_infos). Move definitions that were in
mercury_builtin.m back to where they belong.
This code has been removed because it is no longer used, and was no
longer being maintained but was still quite complex.
compiler/globals.m:
compiler/handle_options.m:
compiler/mercury_compile.m:
compiler/options.m:
Remove one_cell and one_or_two_cell from type_info methods.
compiler/polymorphism.m:
Remove term_to_type and type_to_term support.
Remove one_cell and one_or_two_cell from type_info methods.
Fix documentation to reflect the new situation.
compiler/special_pred.m:
compiler/unify_proc.m:
Remove term_to_type and type_to_term support.
library/list.m:
Put the definition of `list' back into list.m
library/mercury_builtin.m:
Take the definitions of `list', `term', `var', `var__supply',
etc, out of this module.
Remove type_to_term, term_to_type, det_term_to_type,
term__init_var_supply, term__create_var, term__var_to_int
and term__context_init.
Remove references to USE_TYPE_TO_TERM and #ifdefs around
SHARED_ONE_OR_TWO_CELL_TYPE_INFO.
library/std_util.m:
Remove references ONE_OR_TWO_CELL_TYPE_INFO, and code that
handles one-cell typeinfo comparisons.
library/term.m:
Add type_to_term, term_to_type, det_term_to_type,
term__init_var_supply, term__create_var, term__var_to_int
and term__context_init back to term.m.
Add new implementation of type_to_term/2.
library/uniq_array.m:
Fix a typo in a comment - term_to_type/3 instead of term_to_type/2.
runtime/call.mod:
Remove special case code for unify, compare, index for
one-cell typeinfos.
Remove code for type_to_term/2.
runtime/type_info.h:
Remove references to ONE_CELL_TYPE_INFO or ONE_OR_TWO_CELL_TYPE_INFO.
Make sure only SHARED_ONE_OR_TWO_CELL_TYPE_INFO.
Remove references to USE_TYPE_TO_TERM.
compiler/base_type_layout.m:
compiler/bytecode_gen.m:
compiler/code_util.m:
compiler/delay_slot.m:
compiler/det_util.m:
compiler/fact_table.m:
compiler/hlds_data.m:
compiler/hlds_goal.m:
compiler/mode_debug.m:
compiler/tree.m:
library/bag.m:
library/queue.m:
Import module `list' or `term' (or both).
Estimated hours taken: 10
Fix a bug in compilation in accurate GC grades.
compiler/polymorphism.m:
Add any introduced typeinfo variables to the typevar map.
Without this unbound type variables won't not occur in the
typevar map, and the liveness calculations won't be able to
make sure the typeinfos for the unbound type variables are
kept live when they should be. (that is, the map lookups would
fail looking in the typevar map).
Estimated hours taken: 3
Fix a bug in inlining of polymorphic pragma c_code procedures.
The bug was that if the actual argument type has a specific type
of say `float', then the C variable for the corresponding formal
parameter will be declared to have type `Float', whereas without
inlining the argument type would have been polymorphic and so
the C variable would have been declared to have type `Word'.
Hence we need to keep track of the original argument types,
before any inlining or specialization has occurred, and use
these original argument types to determine how to declare
the C variables, rather than using the actual argument types
for this particular specialization.
compiler/hlds_goal.m:
Add a new field to pragma_c_code goals, holding the
original argument types (before any inlining or specialization)
of the pragma_c_code procedure.
compiler/make_hlds.m:
Initialize this field with the declared argument types for
the pragma c_code procedure.
compiler/polymorphism.m:
Update this field to account for the inserted type_info variables.
compiler/code_gen.m:
Pass this field to pragma_c_gen.m.
compiler/pragma_c_gen.m:
Use the original argument types field for the pragma variable
declarations, rather than looking up the actual types of the
arguments.
compiler/*.m:
Trivial changes to handle new field.
compiler/live_vars.m:
Comment out some code to avoid a warning about `fail'
in the condition of an if-then-else.
Estimated hours taken: 1.5
Fix the (long-time) temporary hack to generate NULL pointers as
type_infos for unbound type variables.
compiler/polymorphism.m:
- Generate references to void directly, rather than generating
NULL pointers.
library/std_util.m:
- Remove special case code in mercury_compare_type_info, and
create_type_info to handle unbound type variables represented
as NULLs. Since they are now represented as a normal
type_info, there doesn't need to be any special code.
Estimated hours taken: 3
Replace calls to map__set with calls to either map__det_insert or
map__det_update. In some cases this required a small amount of code
reorganization.
Estimated hours taken: 7
Making the types pred_id and proc_id (almost) abstract.
compiler/code_util.m:
Changed the type of several predicates:
code_util__make_uni_label/4 (arg 3 was int, now proc_id)
code_util__inline_builtin/4 (arg 3 was proc_id, now int)
Added predicate code_util__translate_builtin_2/6.
compiler/hlds_module.m:
Moved invalid_pred_id/1 to hlds_pred.m
compiler/hlds_pred.m:
Types pred_id/0 and proc_id are now abstract.
Added predicates:
hlds_pred__initial_pred_id/1, hlds_pred__initial_proc_id/1,
hlds_pred__next_pred_id/2, hlds_pred__next_proc_id/2,
pred_id_to_int/2, proc_id_to_int/2,
hlds_pred__in_in_unification_proc_id/1
Moved predicate invalid_pred_id/1 (from hlds_module.m).
compiler/*.m:
Miscellaneous minor changes to cast pred/proc_ids to ints
where appropriate.
Estimated hours taken: 0.25
compiler/polymorphism.m:
Add a reminder to change run the #defines in runtime/type_info.h
if the documentation here is changed, and vice versa.
Also a few other minor improvements to the documentation.
Estimated hours taken: 8
Enable the code to treat `__' as an alternative syntax for module
qualification, after fixing various places in the compiler where
we use `__' in ways that are incompatible with this.
compiler/prog_io.m:
compiler/prog_io_goal.m:
Uncomment the code to handle `__' as module qualification.
compiler/intermod.m:
compiler/hlds_module.m:
compiler/modecheck_unify.m:
Fix bugs in the handling of module qualified higher-order terms.
compiler/*.m:
s/hlds__/hlds_/g
compiler/passes_aux.m:
s/process__/process_/g
compiler/pragma_c_gen.m:
compiler/code_gen.m:
s/code_gen__/pragma_c_gen__/ for the predicates defined in
pragma_c_gen.m (this ought to have been done when the code
was first moved from code_gen.m to pragma_c_gen.m).
compiler/llds.m:
s/llds__proc_id/llds_proc_id/g
The reason for this was to avoid ambiguity between proc_id
in hlds_pred.m and llds__proc_id in llds.m.
compiler/quantification.m:
compiler/make_hlds.m:
compiler/mercury_to_c.m:
s/goal_vars/quantification__goal_vars/g
The reason for this was to avoid ambiguity between goal_vars
in quantification.m and goal_util__goal_vars in goal_util.m.
compiler/dupelim.m:
compiler/optimize.m:
s/dupelim__main/dupelim_main/g
The reason for this change is that a program can only
have one main/2 predicate.
compiler/prog_io_dcg.m:
Remove the old "temporary hack" to strip off and ignore
io__gc_call/1, since the new handling of `__' broke it.
It was only useful for optimizing NU-Prolog performance,
which we don't care about anymore.
compiler/mercury_compile.m:
compiler/modules.m:
compiler/intermod.m:
compiler/prog_io.m:
Remove occurrences of io__gc_call.
compiler/llds_out.m:
compiler/base_type_info.m:
Ensure that we properly handle the special hacks in mercury_builtin
where predicates from other modules (e.g. term__context_init)
are defined in mercury_builtin because they are needed for
type_to_term and term_to_type. llds_out.m: don't put
`mercury_builtin' in the mangled names for those symbols.
base_type_info.m: handle types whose status is "imported"
in their own module.
Estimated hours taken: 0.5
Update and improve documentation of polymorphism.
compiler/polymorphism.m:
- Update documentation and examples to talk about
base_type_functors
- Add some missing documentation of type names
- Remove some incorrect references to base_type_layouts in
one-cell type_infos.
- Add information about runtime initialization of shared
base_type_infos.
- Give subsections of the documentation headings.
Estimated hours taken: 0.3
Added code to store type names in the base type info.
By storing type names in the base type info we can now give more
helpfull debugging messages. i.e. we can actualy say what type the
error etc... happend in.
compiler/base_type_info.m :
Added code to place the type name at the end of base type
info's.
compiler/polymorphism.m :
Documented change to base type info structure.
Estimated hours taken: 15
Module qualification of constructors.
compiler/modes.m
compiler/unique_modes.m
compiler/modecheck_unify.m
compiler/modecheck_call.m
Enable propagate_type_info_into_modes.
Use type information to module qualify cons_ids.
compiler/mode_util.m
Use propagate_type_information_into_modes to module qualify cons_ids
in bound insts.
typed_ground/2 and free/1 insts are not yet generated, since they
are not yet used anywhere.
Avoid expanding insts when propagating type information, since
that is not yet useful.
I still need to fix the handling of
inst_matches_{initial, final, binding}(
ground(_, _), bound(_, [all_functors_in_the_type]))
compiler/typecheck.m
Don't assume a module qualified cons_id is a function call
or higher-order pred constant.
compiler/modes.m
compiler/unique_modes.m
compiler/modecheck_unify.m
compiler/instmap.m
compiler/inst_match.m
Remove some unnecessary conversion between cons_ids and consts.
compiler/typecheck.m
compiler/mode_errors.m
Strip builtin qualifiers from cons_ids.
compiler/mercury_to_mercury.m
Output module qualified cons_ids.
compiler/prog_io.m
compiler/prog_io_util.m
Module qualify constructors in type definitions.
Parse qualified cons_ids in bound insts.
compiler/hlds_data.m
Remove cons_id_to_const/3, since it doesn't make much sense any more.
Add cons_id_arity/2 and cons_id_and_args_to_term/3.
compiler/make_hlds.m
Add both qualified and unqualified versions of each cons_id to
the cons_table.
compiler/det_util.m
Handle module qualified cons_ids in det_util__interpret_unify.
compiler/code_util.m
Remove some dead code in code_util__cons_id_to_tag to do with
tags for higher-order terms. Don't assume module qualified
cons_ids are higher-order pred constants.
compiler/polymorphism.m
Module qualify type_info cons_ids.
Estimated hours taken: 25
Implement shared-one-or-two-cell type_infos for grades without static
code addresses. This allows us to use functor, arg, expand, deep_copy,
etc without changes in all grades.
compiler/base_type_info.m:
- If static code addresses are not available, eliminate the
special procedures, and output the constant 0 instead of a
code address.
- We now keep the `eliminated' predicates in the base_gen_info
structure, so that dead_proc_elim knows they are referenced
from the base_type_info.
compiler/dead_proc_elim.m:
- For the moment, don't eliminate any special preds - the
analysis to so this safely is quite complex so we take a
conservative approach - base_type_infos are always needed, and
hence the special preds are always referenced.
- Also, fix a bug in the handling of eliminated procs - if they
are eliminated elsewhere, any eliminated here should be added
find the total number. (this bug doesn't occur presently due
to the conservative approach we now make).
compiler/globals.m:
compiler/handle_options.m:
- Change the handling of type_info_method option - we no longer
need static addresses to do shared-one-or-two-cell.
- Add predicate globals__have_static_code_addresses/2 to check
for this feature.
- Make shared-one-or-two-cell the default type_info method.
compiler/llds_out.m:
- Output initialisation code for the base_type_infos in this
module as part of the module initialisation.
- Don't declare base_type_infos as const if the don't have
static code addresses, because we'll have to initialise them
at runtime.
- Don't make decls of base_type_infos `const' if we don't have
static code addresses.
compiler/polymorphism.m:
- Update examples of transformed code to include
base_type_layouts, clarify difference between shared and
non-shared one-or-two-cell.
library/mercury_builtin.m:
- Conditionally reference entry labels of builtin special preds,
using `MR_MAYBE_STATIC_CODE()' macro.
- Replace `const' in handwritten base_type_info structs with
`MR_STATIC_CODE_CONST'.
- Add initialisation code to fill in the code addresses.
runtime/type_info.h:
- Conditionally define MR_STATIC_CODE_ADDRESSES.
- Define macros to initialise base_type_infos:
mercury_init_builtin_base_type_info, and
mercury_init_base_type_info
- Define `MR_STATIC_CODE_CONST' (which is `const' if static code
addresses are available, and blank otherwise).
_ Define MR_MAYBE_STATIC_CODE(X) which is X if static code
addresses are available, and 0 otherwise.
- Make shared-one-or-two-cell the default setting, don't require
static code addresses for one-or-two-cell.
- Create versions of make_typelayout_for_all_tags for 0, 1, 2
and 3 tagbits, so as to save space, add error message if we
try to use more than 3 tagbits.
- Improve layout and commenting, break file up into sections.
- Fix typos.
Estimated hours taken: 4
Confirm, and fix an XXX in polymorphism.
univ_to_type couldn't check the arguments of higher order
types correctly, so one could circumvent the run-time type
check.
compiler/polymorphism.m:
compiler/base_type_layout.m:
Add the real arity into type_info (and pseudo-type-infos) for
higher order preds.
Also, document recent changes to the structure of type_infos,
fix a typo, and remove the XXX.
library/std_util.m:
Fix the implementation of mercury_compare_type_info so that the
arity and argument type_infos of higher-order types are checked.
runtime/deep_copy.c:
Update offset of the arguments of higher-order type_infos
as they have been shifted along one.
runtime/type_info.h:
Add new #defines for the offset of the arity and arguments for
higher order types, to avoid magic numbers in future.
tests/hard_coded/Mmake:
tests/hard_coded/.cvsignore:
tests/hard_coded/ho_univ_to_type.m:
tests/hard_coded/ho_univ_to_type.exp:
Test case for conversions - tries to do an illegal conversion.
The runtime type-check now detects this.
Estimated hours taken: 12
The first half of a change to introduce nondet pragma C goals.
This half makes the necessary modifications to the HLDS; the next
half will modify the LLDS and emit it.
prog_data:
Add a new pragma type for nondet pragma c_codes; these specify
the names of a a bunch of variables to save across backtracking,
and a list of label names to which backtracking may take place.
Rename is_recursive to may_call_mercury, since this is a more
direct expression of the meaning.
prog_io:
Move much of the functionality to new files.
prog_io_dcg, prog_io_goal, prog_io_pragma, prog_io_util:
New files, made up of pieces of prog_io.
hlds_goal:
Add an extra argument to the pragma_c_goals to store the extra
information present in the new type of pragma c_codes.
det_analysis:
Take into account that the new type of pragma_c goal may have
more than one solution.
goal_util:
Rename variables in the new field of pragma_cs.
live_vars:
Allocate stack slots to the saved variables in the new type of pragma_c
goals.
make_hlds:
Handle the new type of pragma_c goals.
mercury_output, hlds_out:
Output the new type of pragma_c goals.
garbage_out:
Rename type "det" to "frame_type".
others:
Ignore one more arg of pragma_c goals or import prog_io_util.
Estimated hours taken: 32
Implement deep_copy.
Implement solutions for asm_fast, using deep_copy.
compiler/base_type_layout.m:
List all uses of handwritten base_type_layouts.
For higher-order types, construct type_infos without
arity, but with argument types.
compiler/polymorphism.m:
For higher-order types, construct type_infos with argument types.
library/std_util.m:
Move definition of UNIV_OFFSET_FOR_TYPEINFO and UNIV_OFFSET_FOR_DATA
to runtime.
runtime/Mmake:
Add deep_copy.h and deep_copy.c to runtime library.
runtime/memory.c:
runtime/memory.h:
runtime/wrapper.mod:
Add, and initialize solutions_heap_zone, and solutions_heap_pointer.
runtime/solutions.mod:
Implement solutions in non-conservative gc grades, using deep_copy,
and a copy twice algorithm.
runtime/type_info.h:
Add univ definitions, add offset for type_layout simple args.
Estimated hours taken: 2
hlds_goal:
Change the definition of is_builtin to use less space.
bytecode_gen, code_aux, code_gen, code_util, dependency_graph, follow_code,
higher_order, inlining, live_vars, make_hlds, modecheck_unify, modes,
polymorphism, stratify, unused_args:
Fixes to accommodate the change to is_builtin.
Estimated hours taken: 0.1
polymorphism:
Add a unique identifying number to the names of the variables
holding typeinfos. This makes HLDS dumps easier to read.