Estimated hours taken: 12
Branches: main
Remove almost all dependencies by the modules of parse_tree.m on the modules
of hlds.m. The only such dependencies remaining now are on type_util.m.
compiler/hlds_data.m:
compiler/prog_data.m:
Move the cons_id type from hlds_data to prog_data, since several parts
of the parse tree data structure depend on it (particularly insts).
Remove the need to import HLDS modules in prog_data.m by making the
cons_ids that refer to procedure ids refer to them via a new type
that contains shrouded pred_ids and proc_ids. Since pred_ids and
proc_ids are abstract types in hlds_data, add predicates to hlds_data
to shroud and unshroud them.
Also move some other types, e.g. mode_id and class_id, from hlds_data
to prog_data.
compiler/hlds_data.m:
compiler/prog_util.m:
Move predicates for manipulating cons_ids from hlds_data to prog_util.
compiler/inst.m:
compiler/prog_data.m:
Move the contents of inst.m to prog_data.m, since that is where it
belongs, and since doing so eliminates a circular dependency.
The separation doesn't serve any purpose any more, since we don't
need to import hlds_data.m anymore to get access to the cons_id type.
compiler/mode_util.m:
compiler/prog_mode.m:
compiler/parse_tree.m:
Move the predicates in mode_util that don't depend on the HLDS to a new
module prog_mode, which is part of parse_tree.m.
compiler/notes/compiler_design.m:
Mention prog_mode.m, and delete the mention of inst.m.
compiler/mercury_to_mercury.m:
compiler/hlds_out.m:
Move the predicates that depend on HLDS out of mercury_to_mercury.m
to hlds_out.m. Export from mercury_to_mercury.m the predicates needed
by the moved predicates.
compiler/hlds_out.m:
compiler/prog_out.m:
Move predicates for printing parts of the parse tree out of hlds_out.m
to prog_out.m, since mercury_to_mercury.m needs to use them.
compiler/purity.m:
compiler/prog_out.m:
Move predicates for printing purities from purity.m, which is part
of check_hlds.m, to prog_out.m, since mercury_to_mercury.m needs to use
them.
compiler/passes_aux.m:
compiler/prog_out.m:
Move some utility predicates (e.g. for printing progress messages) from
passes_aux.m to prog_out.m, since some predicates in submodules of
parse_tree.m need to use them.
compiler/foreign.m:
compiler/prog_data.m:
Move some types from foreign.m to prog_data.m to allow the elimination
of some dependencies on foreign.m from submodules of parse_tree.m.
compiler/*.m:
Conform to the changes above, mostly by updating lists of imported
modules and module qualifications. In some cases, also do some local
cleanups such as converting predicate declarations to predmode syntax
and fixing white space.
Estimated hours taken: 1
Branches: main
Update coding standards for interfaces in the
standard library. The intent is to improve the
library reference guide.
compiler/notes/coding_standards.html:
Modify the coding standards to specify how descriptive
comments for library procedures should be placed.
By fixing a style (hopefully) the library reference guide
should have a more consistent appearance.
Specify that predmode syntax should be used in preference
to a separate mode declaration if a predicates has only
one mode.
Specify that descriptive comments for procedures should
ideally state under which conditions the procedure can
fail (if it can) or throw an exception.
Estimated hours taken: 0.2
Branches: main
compiler/notes/compiler_design.html:
Update the documentation of the module structure after the movement
of two submodule between toplevel modules.
Estimated hours taken: 8
Branches: main
compiler/modules.m:
compiler/compile_target_code.m:
compiler/handle_options.m:
compiler/bytecode_data.m:
compiler/prog_io_util.m:
Bring these modules up to date with our current coding style. Use
predmode declarations and state variable syntax where appropriate.
Fix inconsistent indentation. Print more error messages using
error_util.m for printing error messages.
compiler/trace_param.m:
Add a new predicate for use by the updated code in handle_options.m.
compiler/error_util.m:
compiler/hlds_error_util.m:
Make error_util.m to be a submodule of parse_tree.m, not hlds.m.
Most of its predicates are not dependent on HLDS data structures.
Move the ones that are into a new module, hlds_error_util, that
is a submodule of hlds.m. Overall, this reduces the dependence
of submodules of parse_tree.m, including modules.m, on submodules
of hlds.m.
compiler/notes/compiler_design.html:
Update the documentation of compiler modes to account for
hlds_error_util.m.
compiler/hlds.m:
compiler/parse_tree.m:
Update the list of included submodules.
compiler/*.m:
Update module imports and module qualifications as needed for the
change above.
tests/invalid/*.{exp,exp2}:
Update the expected outputs of a bunch of test cases to reflect the new
format of some warning messages due to the user error_util; they now
observe line length limits, and print contexts in some cases where they
were previously missing.
Estimated hours taken: 0.3
Branches: main
compiler/notes/type_class_transformation.html:
Undo Fergus's recent addition of a request for a pointer to the
documentation of the proposed replacement for base_typeclass_infos,
since that pointer already exists a few lines above.
Document the mechanisms we use or should use for detecting duplicate
instance declarations.
Estimated hours taken: 0.1
Branches: main
compiler/notes/Mmakefile:
w3/information/include/developer.inc:
Delete references to the recently deleted module_system.html.
Estimated hours taken: 0.25
Branches: main
compiler/notes/coding_standards.html:
Document that "++" should be used for string literals that don't
fit on a single line.
Estimated hours taken: 100
Branches: main
Make definitions of abstract types available when generating
code for importing modules. This is necessary for the .NET
back-end, and for `:- pragma export' on the C back-end.
compiler/prog_data.m:
compiler/modules.m:
compiler/make.dependencies.m:
compiler/recompilation.version.m:
Handle implementation sections in interface files.
There is a new pseudo-declaration `abstract_imported'
which is applied to items from the implementation
section of an interface file. `abstract_imported'
items may not be used in the error checking passes
for the curent module.
compiler/equiv_type_hlds.m:
compiler/notes/compiler_design.html:
New file.
Go over the HLDS expanding all types fully after
semantic checking has been run.
compiler/mercury_compile.m:
Add the new pass.
Don't write the `.opt' file if there are any errors.
compiler/instmap.m:
Add a predicate instmap_delta_map_foldl to apply
a procedure to all insts in an instmap.
compiler/equiv_type.m:
Export predicates for use by equiv_type_hlds.m
Reorder arguments so state variables and higher-order
programming can be used.
compiler/prog_data.m:
compiler/prog_io_pragma.m:
compiler/make_hlds.m:
compiler/mercury_to_mercury.m:
Handle `:- pragma foreign_type' as a form of type
declaration rather than a pragma.
compiler/hlds_data.m:
compiler/*.m:
Add a field to the type_info_cell_constructor cons_id
to identify the type_ctor, which is needed by
equiv_type_hlds.m.
compiler/module_qual.m:
Donn't allow items from the implementation section of
interface files to match items in the current module.
compiler/*.m:
tests/*/*.m:
Add missing imports which only became apparent with
the bug fixes above.
Remove unnecessary imports which only became apparent with
the bug fixes above.
tests/hard_coded/Mmakefile:
tests/hard_coded/export_test2.{m,exp}:
Test case.
tests/invalid/Mmakefile:
tests/invalid/missing_interface_import2.{m,err_exp}:
Test case.
Estimated hours taken: 0.25
Branches: main
compiler/notes/coding_standards.html:
w3/information/developers/c_coding_standard.html:
Specify that code should generally be ordered top-down, not bottom-up.
Estimated hours taken: 0.1
Branches: main
compiler/notes/Mmakefile:
w3/information/include/developer.inc:
Delete references to the recently deleted module_system.html.
Estimated hours taken: 0.25
Branches: main
compiler/notes/index.html:
New file. Contains links to the other files in this directory,
organized into some vaguely coherent categories.
compiler/notes/.nocopyright:
Add index.html.
Estimated hours taken: 0.25
Branches: main
compiler/notes/module_system.html:
Remove. This file documented a proposed module system
which is fairly different to the one that Mercury actually
supports, and we have no plans to actually implement this
system, so it will not be of interest to most people reading the
Mercury sources.
Estimated hours taken: 10
Branches: main
Split the existing browser library into two libraries, by making the
program_representation module into its own library. This is useful because
the compiler refers to program_representation.m, whose code thus needs to be
linked into compiler executables even if the compiler isn't compiled with
debugging enabled. By creating a new library for this module, we avoid any
chance of the linker dragging in the rest of the modules in the browser
library. (This is a problem with an upcoming diff.).
The name of the new library is "mdbcomp", because the intention is that it
contain code that is shared between the debugger and the compiler. This means
mostly the definitions of data structures that the compiler generates for the
debugger, and the predicates that operate on them.
Mmake.common.in:
Allow MDB_COMP_ as a prefix for symbol names in the browser directory.
Mmake.workspace:
Add a make variable holding for the name of the new library, and
add the name to the relevant lists of libraries.
Avoid duplicating the lists of filenames that need to be updated
when adding new libraries or changing their names.
Mmakefile:
Use make variables to refer to library names.
browser/mdbcomp.m:
browser/mer_mdbcomp.m:
Add these files as the top modules of the new library.
browser/program_representation.m:
Make program_representation.m a submodule of mdbcomp, not mdb.
browser/program_representation.m:
browser/browser_info.m:
Move a predicate from program_representation.m to browser_info.m
to avoid the mdbcomp library depend on the browser library, since
this would negate the point of the exercise.
browser/mdb.m:
Delete program_representation.m from the list of submodules.
browser/Mmakefile:
Update this file to handle the new module.
browser/Mercury.options:
Mention the new module.
browser/*.m:
Update the lists of imported modules. Import only one browser module
per line.
compiler/notes/overall_design.html:
Document the new library.
compiler/compile_target_code.m:
Add the mdbcomp library to the list of libraries we need to link with.
compiler/prog_rep.m:
trace/mercury_trace_internal.c:
Import program_representation.m by its new name.
scripts/c2init.in:
Centralize knowledge about which files need to be updated when the list
of libraries changes here.
scripts/c2init.in:
scripts/ml.in:
tools/binary:
tools/binary_step:
tools/bootcheck:
tools/linear:
tools/lml:
Update the list of libraries programs are linked with.
Estimated hours taken: 0.1
Branches: main
compiler/notes/failure.html:
compiler/notes/allocation.html:
Clarify that these describe the LLDS back-end only.
Estimated hours taken: 32
Branches: main
Move toward the proposed structures for representing type class information at
runtime by adding code for generating the structures corresponding to
base_typeclass_infos. The structures corresponding to typeclass_infos will
be added in a later change.
Register the new data structures in a table at runtime.
Add four new mdb developer commands for checking the contents of the new
type class table, as well as the contents of the existing type constructor
table: class_decl, type_ctor, all_class_decls and all_type_ctors.
compiler/rtti.m:
Add the data types required to represent the new runtime data
structures that will eventually replace base_typeclass_infos
inside the compiler.
Add the required function symbols to the data types representing both
the new RTTI data structures themselves and those representing
references to them.
Make the required changes to the predicates operating on the modified
data types, and add some required new predicates.
compiler/rtti_out.m:
Add code to write out the new data structures for the LLDS backend.
Make some changes in existing predicates to allow them to be used
in the new code.
compiler/layout_out.m:
Factor out some code that is now common with rtti_out.m.
compiler/type_class_info.m:
A new module to generate the new RTTI data structures.
compiler/backend_libs.m:
Include the new module.
compiler/options.m:
Add a new option, --new-type-class-rtti, to control whether we
invoke the top level predicate of type_class_info.m to generate
the new type class RTTI structures. We still generate and use
base_typeclass_infos regardless of the value of this option.
compiler/mercury_compile.m:
Invoke the code of the new module if --new-type-class-rtti is given.
compiler/opt_debug.m:
Add code to dump descriptions of the new rtti_ids.
compiler/mlds_to_gcc.m:
compiler/rtti_to_mlds.m:
Handle the new alternatives in the rtti data types, mostly by throwing
exceptions. The actual code should be written later by Fergus.
compiler/pseudo_type_info.m:
Module qualify the names of builtin types when generating
pseudo-typeinfos for them. This makes the naming scheme more regular.
compiler/base_typeclass_info.m:
compiler/notes/type_class_transformation.html:
Document the impending obsolescence of these files.
compiler/notes/work_in_progress.html:
List type class RTTI as work in progress.
library/list.m:
Add a utility predicate for use by compiler/rtti_out.m.
runtime/mercury_typeclass_info.h:
Make some changes in the C data types representing type class
information that I discovered to be necessary or advantageous
in the process of generating values of those types automatically.
Rename some types to make their names be better documentation.
Change some arrays of pointers to structures into arrays of structures,
where the structures at different array indexes are the same size.
Removing consts that rtti_out.m supplies automatically avoids
duplicate const errors from the C compiler.
Add #includes to make the file namespace clean.
Protect against multiple inclusion.
runtime/mercury_typeclass_info_example.c:
Remove this file. After the changes to mercury_typeclass_info.h, its
contents are no longer correct examples of the structures in
mercury_typeclass_info.h, and since the compiler can now generate
those structures automatically, hand-written examples no longer serve
any useful pupose.
runtime/mercury_types.h:
Add a new type, MR_CodePtr, for use in mercury_typeclass_info.h.
The compiler predicate tc_rtti_name_type wants single-word names
for types.
runtime/mercury_imp.h:
#include mercury_typeclass_info.h.
runtime/mercury_type_tables.[ch]:
Add functions to register and to look up type class declarations and
type class instances.
Add the functions and data structures required to look up all type
constructors and all type classes. The debugger uses these to support
the commands that let the programmer check the contents of these
tables.
Eventually, we should be able to use the type class tables to test
whether a vector of types is a member of a given type class.
runtime/mercury_wrapper.c:
runtime/mercury_type_info.[ch]:
Move the array of type_ctor_rep names from the mercury_wrapper module
to the mercury_type_info module, and make it always-defined and public;
the debugger also needs access to it now.
runtime/Mmakefile:
Add mercury_typeclass_info.h to the list of header files that other
files depend on.
trace/mercury_trace_internal.c:
Add four new mdb commands: class_decl, type_ctor, all_class_decls
and all_type_ctors.
Make some existing code follow our coding conventions.
doc/user_guide.texi:
doc/mdb_categories:
Document the four new mdb commands.
doc/reference_manual.texi:
Document (in a comment) the compiler's reliance on each type in an
instance declaration containing exactly one type constructor.
tests/debugger/class_decl.{m,inp,exp}:
A new test case to test the new mdb commands.
tests/debugger/Mmakefile:
tests/debugger/Mercury.options:
Add the new test case.
tests/debugger/completion.exp:
Expect the new commands to appear in the command name completion.
tests/debugger/mdb_command_test.inp:
Test the documentation of the new mdb commands.
Expect the new commands to appear in the command name completion.
Estimated hours taken: 400
Branches: main
Implement the infrastructure for term size profiling. This means adding two
new grade components, tsw and tsc, and implementing them in the LLDS code
generator. In grades including tsw (term size words), each term is augmented
with an extra word giving the number of heap words it contains; in grades
including tsc (term size cells), each term is augmented with an extra word
giving the number of heap cells it contains. The extra word is at the start,
at offset -1, to leave almost all of the machinery for accessing the heap
unchanged.
For now, the only way to access term sizes is with a new mdb command,
"term_size <varspec>". Later, we will use term sizes in conjunction with
deep profiling to do experimental complexity analysis, but that requires
a lot more research. This diff is a necessary first step.
The implementation of term size profiling consists of three main parts:
- a source-to-source transform that computes the size of each heap cell
when it is constructed (and increments it in the rare cases when a free
argument of an existing heap cell is bound),
- a relatively small change to the code generator that reserves the extra
slot in new heap cells, and
- extensions to the facilities for creating cells from C code to record
the extra information we now need.
The diff overhauls polymorphism.m to make the source-to-source transform
possible. This overhaul includes separating type_ctor_infos and type_infos
as strictly as possible from each other, converting type_ctor_infos into
type_infos only as necessary. It also includes separating type_ctor_infos,
type_infos, base_typeclass_infos and typeclass_infos (as well as voids,
for clarity) from plain user-defined type constructors in type categorizations.
This change needs this separation because values of those four types do not
have size slots, but they ought to be treated specially in other situations
as well (e.g. by tabling).
The diff adds a new mdb command, term_size. It also replaces the proc_body
mdb command with new ways of using the existing print and browse commands
("print proc_body" and "browse proc_body") in order to make looking at
procedure bodies more controllable. This was useful in debugging the effect
of term size profiling on some test case outputs. It is not strictly tied
to term size profiling, but turns out to be difficult to disentangle.
compiler/size_prof.m:
A new module implementing the source-to-source transform.
compiler/notes/compiler_design.html:
Mention the new module.
compiler/transform_hlds.m:
Include size_prof as a submodule of transform_hlds.
compiler/mercury_compile.m:
If term size profiling is enabled, invoke its source-to-source
transform.
compiler/hlds_goal.m:
Extend construction unifications with an optional slot for recording
the size of the term if the size is a constant, or the identity of the
variable holding the size, if the size is not constant. This is
needed by the source-to-source transform.
compiler/quantification.m:
Treat the variable reference that may be in this slot as a nonlocal
variable of construction unifications, since the code generator needs
this.
compiler/compile_target_code.m:
Handle the new grade components.
compiler/options.m:
Implement the options that control term size profiling.
doc/user_guide.texi:
Document the options and grade components that control term size
profiling, and the term_size mdb command. The documentation is
commented out for now.
Modify the wording of the 'u' HLDS dump flag to include other details
of unifications (e.g. term size info) rather than just unification
categories.
Document the new alternatives of the print and browse commands. Since
they are for developers only, the documentation is commented out.
compiler/handle_options.m:
Handle the implications of term size profiling grades.
Add a -D flag value to print HLDS components relevant to HLDS
transformations.
compiler/modules.m:
Import the new builtin library module that implements the operations
needed by term size profiling automatically in term size profiling
grades.
Switch the predicate involved to use state var syntax.
compiler/prog_util.m:
Add predicates and functions that return the sym_names of the modules
needed by term size profiling.
compiler/code_info.m:
compiler/unify_gen.m:
compiler/var_locn.m:
Reserve an extra slot in heap cells and fill them in in unifications
marked by size_prof.
compiler/builtin_ops.m:
Add term_size_prof_builtin.term_size_plus as a builtin, with the same
implementation as int.+.
compiler/make_hlds.m:
Disable warnings about clauses for builtins while the change to
builtin_ops is bootstrapped.
compiler/polymorphism.m:
Export predicates that generate goals to create type_infos and
type_ctor_infos to add_to_construct.m. Rewrite their documentation
to make it more detailed.
Make orders of arguments amenable to the use of state variable syntax.
Consolidate knowledge of which type categories have builtin unify and
compare predicates in one place.
Add code to leave the types of type_ctor_infos alone: instead of
changing their types to type_info when used as arguments of other
type_infos, create a new variable of type type_info instead, and
use an unsafe_cast. This would make the HLDS closer to being type
correct, but this new code is currently commented out, for two
reasons. First, common.m is currently not smart enough to figure out
that if X and Y are equal, then similar unsafe_casts of X and Y
are also equal, and this causes the compiler do not detect some
duplicate calls it used to detect. Second, the code generators
are also not smart enough to know that if Z is an unsafe_cast of X,
then X and Z do not need separate stack slots, but can use the same
slot.
compiler/type_util.m:
Add utility predicates for returning the types of type_infos and
type_ctor_infos, for use by new code in polymorphism.m.
Move some utility predicates here from other modules, since they
are now used by more than one module.
Rename the type `builtin_type' as `type_category', to better reflect
what it does. Extend it to put the type_info, type_ctor_info,
typeclass_info, base_typeclass_info and void types into categories
of their own: treating these types as if they were a user-defined
type (which is how they used to be classified) is not always correct.
Rename the functor polymorphic_type to variable_type, since types
such as list(T) are polymorphic, but they fall into the user-defined
category. Rename user_type as user_ctor_type, since list(int) is not
wholly user-defined but falls into this category. Rename pred_type
as higher_order_type, since it also encompasses functions.
Replace code that used to check for a few of the alternatives
of this type with code that does a full switch on the type,
to ensure that they are updated if the type definition ever
changes again.
compiler/pseudo_type_info.m:
Delete a predicate whose updated implementation is now in type_util.m.
compiler/mlds_to_c.m:
compiler/mlds_to_gcc.m:
compiler/mlds_to_il.m:
compiler/mlds_to_java.m:
Still treat type_infos, type_ctor_infos, typeclass_infos and
base_typeclass_infos as user-defined types, but prepare for when
they won't be.
compiler/hlds_pred.m:
Require interface typeinfo liveness when term size profiling is
enabled.
Add term_size_profiling_builtin.increase_size as a
no_type_info_builtin.
compiler/hlds_out.m:
Print the size annotations on unifications if HLDS dump flags call
for unification details. (The flag test is in the caller of the
modified predicate.)
compiler/llds.m:
Extend incr_hp instructions and data_addr_consts with optional fields
that allow the code generator to refer to N words past the start of
a static or dynamic cell. Term size profiling uses this with N=1.
compiler/llds_out.m:
When allocating memory on the heap, use the macro variants that
specify an optional offset, and specify the offset when required.
compiler/bytecode_gen.m:
compiler/dense_switch.m:
compiler/dupelim.m:
compiler/exprn_aux.m:
compiler/goal_form.m:
compiler/goal_util.m:
compiler/higher_order.m:
compiler/inst_match.m:
compiler/intermod.m:
compiler/jumpopt.m:
compiler/lambda.m:
compiler/livemap.m:
compiler/ll_pseudo_type_info.m:
compiler/lookup_switch.m:
compiler/magic_util.m:
compiler/middle_rec.m:
compiler/ml_code_util.m:
compiler/ml_switch_gen.m:
compiler/ml_unify_gen.m:
compiler/mlds.m:
compiler/mlds_to_c.m:
compiler/mlds_to_gcc.m:
compiler/mlds_to_il.m:
compiler/mlds_to_java.m:
compiler/modecheck_unify.m:
compiler/opt_debug.m:
compiler/opt_util.m:
compiler/par_conj_gen.m:
compiler/post_typecheck.m:
compiler/reassign.m:
compiler/rl.m:
compiler/rl_key.m:
compiler/special_pred.m:
compiler/stack_layout.m:
compiler/static_term.m:
compiler/string_switch.m:
compiler/switch_gen.m:
compiler/switch_util.m:
compiler/table_gen.m:
compiler/term_util.m:
compiler/type_ctor_info.m:
compiler/unused_args.m:
compiler/use_local_vars.m:
Minor updates to conform to the changes above.
library/term_size_prof_builtin.m:
New module containing helper predicates for term size profiling.
size_prof.m generates call to these predicates.
library/library.m:
Include the new module in the library.
doc/Mmakefile:
Do not include the term_size_prof_builtin module in the library
documentation.
library/array.m:
library/benchmarking.m:
library/construct.m:
library/deconstruct.m:
library/io.m:
library/sparse_bitset.m:
library/store.m:
library/string.m:
Replace all uses of MR_incr_hp with MR_offset_incr_hp, to ensure
that we haven't overlooked any places where offsets may need to be
specified.
Fix formatting of foreign_procs.
Use new macros defined by the runtime system when constructing
terms (which all happen to be lists) in C code. These new macros
specify the types of the cell arguments, allowing the implementation
to figure out the size of the new cell based on the sizes of its
fields.
library/private_builtin.m:
Define some constant type_info structures for use by these macros.
They cannot be defined in the runtime, since they refer to types
defined in the library (list.list and std_util.univ).
util/mkinit.c:
Make the addresses of these type_info structures available to the
runtime.
runtime/mercury_init.h:
Declare these type_info structures, for use in mkinit-generated
*_init.c files.
runtime/mercury_wrapper.[ch]:
Declare and define the variables that hold these addresses, for use
in the new macros for constructing typed lists.
Since term size profiling can refer to a memory cell by a pointer
that is offset by one word, register the extra offsets with the Boehm
collector if is being used.
Document the incompatibility of MR_HIGHTAGS and the Boehm collector.
runtime/mercury_tags.h:
Define new macros for constructing typed lists.
Provide macros for preserving the old interface presented by this file
to the extent possible. Uses of the old MR_list_cons macro will
continue to work in grades without term size profiling. In term
size profiling grades, their use will get a C compiler error.
Fix a bug caused by a missing backslash.
runtime/mercury_heap.h:
Change the basic macros for allocating new heap cells to take
an optional offset argument. If this is nonzero, the macros
increment the returned address by the given number of words.
Term size profiling specifies offset=1, reserving the extra
word at the start (which is ignored by all components of the
system except term size profiling) for holding the size of the term.
Provide macros for preserving the old interface presented by this file
to the extent possible. Since the old MR_create[123] and MR_list_cons
macros did not specify type information, they had to be changed
to take additional arguments. This affects only hand-written C code.
Call new diagnostic macros that can help debug heap allocations.
Document why the macros in this files must expand to expressions
instead of statements, evn though the latter would be preferable
(e.g. by allowing them to declare and use local variables without
depending on gcc extensions).
runtime/mercury_debug.[ch]:
Add diagnostic macros to debug heap allocations, and the functions
behind them if MR_DEBUG_HEAP_ALLOC is defined.
Update the debugging routines for hand-allocated cells to print the
values of the term size slot as well as the other slots in the relevant
grades.
runtime/mercury_string.h:
Provide some needed variants of the macro for copying strings.
runtime/mercury_deconstruct_macros.h:
runtime/mercury_type_info.c:
Supply type information when constructing terms.
runtime/mercury_deep_copy_body.h:
Preserve the term size slot when copying terms.
runtime/mercury_deep_copy_body.h:
runtime/mercury_ho_call.c:
runtime/mercury_ml_expand_body.h:
Use MR_offset_incr_hp instead of MR_incr_hp to ensure that all places
that allocate cells also allocate space for the term size slot if
necessary.
Reduce code duplication by using a now standard macro for copying
strings.
runtime/mercury_grade.h:
Handle the two new grade components.
runtime/mercury_conf_param.h:
Document the C macros used to control the two new grade components,
as well as MR_DEBUG_HEAP_ALLOC.
Detect incompatibilities between high level code and profiling.
runtime/mercury_term_size.[ch]:
A new module to house a function to find and return term sizes
stored in heap cells.
runtime/mercury_proc_id.h:
runtime/mercury_univ.h:
New header files. mercury_proc_id.h contains the (unchanged)
definition of MR_Proc_Id, while mercury_univ.h contains the
definitions of the macros for manipulating univs that used to be
in mercury_type_info.h, updated to use the new macros for allocating
memory.
In the absence of these header files, the following circularity
would ensue:
mercury_deep_profiling.h includes mercury_stack_layout.h
- needs definition of MR_Proc_Id
mercury_stack_layout.h needs mercury_type_info.h
- needs definition of MR_PseudoTypeInfo
mercury_type_info.h needs mercury_heap.h
- needs heap allocation macros for MR_new_univ_on_hp
mercury_heap.h includes mercury_deep_profiling.h
- needs MR_current_call_site_dynamic for recording allocations
Breaking the circular dependency in two places, not just one, is to
minimize similar problems in the future.
runtime/mercury_stack_layout.h:
Delete the definition of MR_Proc_Id, which is now in mercury_proc_id.h.
runtime/mercury_type_info.h:
Delete the macros for manipulating univs, which are now in
mercury_univ.h.
runtime/Mmakefile:
Mention the new files.
runtime/mercury_imp.h:
runtime/mercury.h:
runtime/mercury_construct.c:
runtime/mercury_deep_profiling.h:
Include the new files at appropriate points.
runtime/mercury.c:
Change the names of the functions that create heap cells for
hand-written code, since the interface to hand-written code has
changed to include type information.
runtime/mercury_tabling.h:
Delete some unused macros.
runtime/mercury_trace_base.c:
runtime/mercury_type_info.c:
Use the new macros supplying type information when constructing lists.
scripts/canonical_grade_options.sh-subr:
Fix an undefined sh variable bug that could cause error messages
to come out without identifying the program they were from.
scripts/init_grade_options.sh-subr:
scripts/parse_grade_options.sh-subr:
scripts/canonical_grade_options.sh-subr:
scripts/mgnuc.in:
Handle the new grade components and the options controlling them.
trace/mercury_trace_internal.c:
Implement the mdb command "term_size <varspec>", which is like
"print <varspec>", but prints the size of a term instead of its value.
In non-term-size-profiling grades, it prints an error message.
Replace the "proc_body" command with optional arguments to the "print"
and "browse" commands.
doc/user_guide.tex:
Add documentation of the term_size mdb command. Since the command is
for implementors only, and works only in grades that are not yet ready
for public consumption, the documentation is commented out.
Add documentation of the new arguments of the print and browse mdb
commands. Since they are for implementors only, the documentation
is commented out.
trace/mercury_trace_vars.[ch]:
Add the functions needed to implement the term_size command, and
factor out the code common to the "size" and "print"/"browse" commands.
Decide whether to print the name of a variable before invoking the
supplied print or browse predicate on it based on a flag design for
this purpose, instead of overloading the meaning of the output FILE *
variable. This arrangement is much clearer.
trace/mercury_trace_browse.c:
trace/mercury_trace_external.c:
trace/mercury_trace_help.c:
Supply type information when constructing terms.
browser/program_representation.m:
Since the new library module term_size_prof_builtin never generates
any events, mark it as such, so that the declarative debugger doesn't
expect it to generate any.
Do the same for the deep profiling builtin module.
tests/debugger/term_size_words.{m,inp,exp}:
tests/debugger/term_size_cells.{m,inp,exp}:
Two new test cases, each testing one of the new grades.
tests/debugger/Mmakefile:
Enable the two new test cases in their grades.
Disable the tests sensitive to stack frame sizes in term size profiling
grades.
tests/debugger/completion.exp:
Add the new "term_size" mdb command to the list of command completions,
and delete "proc_body".
tests/debugger/declarative/dependency.{inp,exp}:
Use "print proc_body" instead of "proc_body".
tests/hard_coded/nondet_c.m:
tests/hard_coded/pragma_inline.m:
Use MR_offset_incr_hp instead of MR_incr_hp to ensure that all places
that allocate cells also allocate space for the term size slot if
necessary.
tests/valid/Mmakefile:
Disable the IL tests in term size profiling grades, since the term size
profiling primitives haven't been (and probably won't be) implemented
for the MLDS backends, and handle_options causes a compiler abort
for grades that combine term size profiling and any one of IL, Java
and high level C.
Estimated hours taken: 3.5
Branches: main
compiler/notes/compiler_design.html:
Update to reflect the fact that we are now using sub-modules.
this required a bit of reorganization in some places.
Also, document some modules that were previously not mentioned.
Estimated hours taken: 3
Branches: main
Delete the old, lazy LLDS code generator, since we won't be maintaining it
anymore. Its deletion speeds up the compiler by 0.2% when using the LLDS
back end.
compiler/code_exprn.m:
Delete the module.
compiler/ll_backend.m:
Delete code_exprn from the list of submodules of this module.
compiler/notes/compiler_design.html:
Delete the documentation of code_exprn.m, and update the documentation
of var_locn.m.
compiler/options.m:
Delete the --lazy-code option that used to select code_exprn over
var_locn.
Delete the follow_vars option, since the LLDS backend now always
executes the follow_vars pass.
compiler/handle_options.m:
Delete the code setting the follow_vars option.
Make the setting of static_ground_terms conditional on the use of the
LLDS backend (which now implies the eager code generator).
compiler/code_info.m:
Delete lots of code that switches between code_exprn.m and var_locn.m.
Simplify the data structures accordingly.
compiler/store_alloc.m:
Delete the code and data structures required to cater for the case
where the follow_vars pass isn't run.
compiler/pragma_c_gen.m:
compiler/var_locn.m:
compiler/hlds_goal.m:
compiler/lookup_switch.m:
Update a comment.
doc/user_guide.texi:
Delete the documentation of --follow-vars. --lazy-code was already
undocumented.
tests/valid/Mercury.options:
Delete a setting of --no-follow-vars.
Estimated hours taken: 80
Branches: main
Make Aditi work with `--highlevel-code'.
(Note that this doesn't work with the current CVS version
of Aditi. The Aditi developers have rewritten the Aditi client
API, and haven't maintained the old version of the API, so Mercury
queries don't work at the moment. extras/aditi will be updated to
use the new interface as a separate change.)
extras/aditi/aditi_private_builtin.m:
extras/aditi/aditi.m:
Move code to implement Aditi calls and updates into
a aditi_private_builtin.m. These operations are now
implemented using ordinary Mercury foreign procedures,
rather than hand-coded C modules.
compiler/magic.m:
Use calls to ordinary calls to predicates defined in
extras/aditi/aditi_private_builtin.m to implement the
procedures which interface between top-down Mercury
code and Aditi procedures.
compiler/aditi_backend.pp:
compiler/aditi_builtin_ops.m:
compiler/mercury_compile.m:
compiler/notes/compiler_design.html:
Add a pass to convert Aditi builtins (calls and updates)
into ordinary calls to predicates defined in
extras/aditi/aditi_private_builtin.m.
compiler/hlds_goal.m:
compiler/hlds_pred.m:
Add a new generic_call type -- `unsafe_cast'.
aditi_builtin_ops.m needs to be able to cast
closures from one type and inst to another.
Delete the `aditi_call' alternative for `aditi_builtin',
which is not needed after the change to magic.m described
above.
Add predicates `construct_tuple' and `deconstruct_tuple'.
compiler/*hlds.*.m:
compiler/call_gen.m:
compiler/ml_call_gen.m:
Handle unsafe cast goals.
compiler/common.m:
compiler/higher_order.m:
compiler/unify_proc.m:
Generate unsafe_cast goals instead of calls to
private_builtin.unsafe_type_cast.
compiler/purity.m:
compiler/notes/compiler_design.html:
Convert calls to private_builtin.unsafe_type_cast into
unsafe_cast goals.
compiler/ml_code_gen.m:
Don't attempt to generate code for Aditi procedures.
Remove special case handling of calls to
private_builtin.unsafe_type_cast -- such
calls are now transformed away.
compiler/mlds_to_c.m:
compiler/mlds_to_gcc.m:
compiler/maybe_mlds_to_gcc.m:
Add the RL code to the generated C file.
compiler/llds_out.m:
compiler/c_util.m:
compiler/compile_target_code.m:
Move code to generate a `.rlo' file and work out the
name of the RL constant embeeded in the C file for
a module into c_util.m, for use by the MLDS backend.
compiler/modules.m:
Automatically import aditi_private_builtin when compiling
with `--aditi'.
We generate a C constant for the RL code for each module,
so modules compiled with `--aditi' need to be treated
by the build system as if they contain foreign code.
compiler/polymorphism.m:
Tuple insertion and deletion no longer need special treatment.
compiler/llds.m:
compiler/ll_backend.*.m:
Delete the Aditi alternatives of the `code_addr' type.
compiler/mode_util.m:
Add function versions of in_mode, out_mode, etc.
compiler/prog_util.m:
Add aditi_public_builtin_module (returns `aditi') and
aditi_private_builtin_module (returns `aditi_private_builtin').
tests/valid/aditi_private_builtin.m:
tests/invalid/aditi_private_builtin.m:
tests/valid/Mercury.options:
tests/invalid/Mercury.options:
Add a cut down version of extras/aditi/aditi_private_builtin.m
for use in running the tests.
Estimated hours taken: 2
Branches: main
compiler/mercury_compile.m:
compiler/notes/compiler_design.html:
Perform loop invariant hoisting after inlining, since inlining
can create opportunities for loop invariant hoisting.
library/string.m:
Implement string__index in Mercury, in terms of string__length,
string__unsafe_index, and a new procedure string__index_check,
rather than implementing in C. string__index_check contains
just the index checking code from the old string__index implementation.
Implementing string__index in Mercury like this should allow the
Mercury compiler to do loop invariant hoisting on the calls to
string__length.
Declare the output argument for string__unsafe_index
and string__index_det with mode `uo', to match string__index.
For unsafe__index, this change was needed now that string__index is
implemented in terms of string__unsafe_index.
Estimated hours taken: 8
Branches: main
Add an option `--no-inline-builtins', which causes builtins to
be generated as calls to out-of-line procedures. This is done
by default when debugging, as without this option the execution
of builtins is not traced.
On earth, a compiler built in grade asm_fast.gc.tr.debug
takes 36.8s to run `mmc -C -I ../analysis/ hlds.make_hlds'.
When the compiler is built with `--no-inline-builtins',
this is increased to 38.6s.
The size of the compiler built in grade asm_fast.gc.tr.debug
increases from 45.0MB to 46.6MB.
compiler/options.m:
Add the option.
compiler/code_util.m:
Work out whether builtins should be generated inline.
compiler/handle_options.m:
Disable inlining of builtins when debugging.
compiler/simplify.m:
compiler/higher_order.m:
compiler/modes.m:
code_util__builtin_state now needs to know where the
builtin is being called from to know whether a particular
call should be treated as an inline builtin. The "recursive"
calls from the automatically generated procedures for each
builtin should always be generated inline, or else we would
generate an infinite loop.
NEWS:
doc/user_guide.texi:
compiler/notes/todo.html:
Document the change.
tests/debugger/Mmakefile:
tests/debugger/no_inline_builtins.{m,exp,inp}:
Test case.
tests/debugger/*.{inp,exp,exp2}:
tests/debugger/declarative/*.{inp,exp,exp2}:
Update due to changed event numbers.
tests/debugger/lval_desc_array.inp:
Use a less brittle method for stepping to the point in
the program where the test needs to display variables.
tests/debugger/declarative/library_forwarding.m:
tests/debugger/declarative/*.m:
Add forwarding predicates for some library predicates
and functions so that the declarative debugger doesn't
ask different questions depending on whether or not
the library was compiled with debugging enabled.
Estimated hours taken: 0.1
Branches: main
mercury/compiler/notes/reviews.html:
Fix a couple of HTML errors:
- Replace angled brackets in text with < and >
- Replace an </ol> with a </ul> so it correctly ends the
corresponding begin unordered list tag.
Estimated hours taken: 0.25
Branches: main
Trivial comment changes.
compiler/inst_match.m:
Update some obsolete comments to match the current interface.
Add a comment about contravariance/covariance in
pred_inst_argmodes_matches.
compiler/java_util.m:
compiler/notes/compiler_design.html:
Fix typos.
Estimated hours taken: 16
Branches: main, release
Fix a bug where the compiler was going into an infinite loop for
insts and modes that are infinitely recursive at the top level,
e.g. `:- inst foo == foo.' or `:- mode foo == foo'.
compiler/make_hlds.m:
Check for circular insts and modes, and report an error if any occur.
Also, pass back a boolean from pass 1 indicating whether or not
any cyclic insts and modes. Rename the "UndefModes" argument
for parse_tree_to_hlds as "InvalidModes", and set it to yes
if there were any circular insts or modes, to ensure that
mercury_compile.m will not run mode analysis. This is needed
to avoid infinite loops in mode analysis when processing
circular
compiler/notes/compiler_design.html:
Mention that make_hlds.m checks for circular insts and modes.
Also mention that it expands state variable syntax.
compiler/mercury_compile.m:
Add a comment about circular insts and modes to the list of
reasons why we might need to stop before running mode analysis.
tests/invalid/circ_inst2.m:
Fix a misleading comment.
tests/invalid/Mmakefile:
tests/invalid/circ_inst.err_exp:
tests/invalid/circ_inst2.err_exp:
tests/invalid/circ_inst3.err_exp:
tests/invalid/circ_inst4.err_exp:
tests/invalid/circ_mode.err_exp:
tests/invalid/circ_mode2.err_exp:
tests/invalid/circ_mode3.err_exp:
tests/invalid/circ_mode4.err_exp:
Enable these test cases, and add expected output files for them.
tests/invalid/Mmakefile:
tests/invalid/circ_type3.m:
tests/invalid/circ_type3.err_exp:
Add another test for circular equivalence types.
Estimated hours taken: 0.5
Branches: main, release
compiler/notes/work_in_progress.html:
- Delete the entry for the native code back-end,
since that is mentioned in NEWS file;
instead, just mention the gcc_3_3 branch work.
- Provide a bit more information on a couple of the other entries.
Estimated hours taken: 0.25
Branches: main, release
HISTORY:
Fix incorrect ordering.
compiler/notes/release_checklist.html:
Update the instructions about maintenance of the HISTORY file
to avoid this problem in future.
Estimated hours taken: 0.1
Branches: main
compiler/notes/release_checklist.html:
Update the list of directories which need to be tagged when
making a new release: s/gcc/mercury-gcc/
Estimated hours taken: 900
Branches: main
Added loop-invariant hoisting optimization.
liveness.m:
Improved the debugging output to show HLDS before and after
liveness analysis.
loop_inv.m:
New module containing the implementation of the loop invariant
hoisting optimization.
mercury_compile.m:
Added loop_inv at step 34, moving inlining to step 35.
options.m:
Added bool option --loop-invariants (default `no').
This optimization is set at -O4.
passes_aux.m:
Minor changes to support introduction of the loop
invariant hoisting optmimization.
follow_code.m:
Updated to reflect the new interface to passes_aux.m.
transform_hlds.m:
Added include_module declaration for loop_inv.
Estimated hours taken: 1
Branches: main
Update the todo list in preparation for the release.
compiler/notes/todo.html:
Delete some entries for things which have been done.
Mention the .NET, Java and native-code back-ends.
Add pointers to the todo lists in
compiler/ml_code_gen.m (High-level C back-end),
compiler/mlds_to_il.m (.NET back-end)
compiler/ml_elim_nested.m (accurate GC).
Estimated hours taken: 0.5
Branches: main
Make the "work in progress" file appear on the web site.
compiler/notes/work_in_progress.html:
compiler/notes/Mmakefile:
Add a a htmlized version of WORK_IN_PROGRESS.
WORK_IN_PROGRESS:
Removed.
Mmakefile:
Generate WORK_IN_PROGRESS and TODO from the files
in compiler/notes.
w3/information/include/developer.inc:
Add the "work in progress" file to the developer documentation.
Estimated hours taken: 3
tools/generate_index_html:
Improve the index.html files generated for the download
area of the web site so that the files are grouped
by release, rather than just listed in alphabetical order.
compiler/notes/release_checklist.html:
generate_index_html now needs to be updated on each release
so that the current release is listed first.
The source distribution is now built on earth, not murlibobo.
Estimated hours taken: 8
Branches: main
Allow arbitrary mappings from source file name to module name.
The mapping is created using the command `mmc -f *.m', which must
be run before `mmake depend'.
compiler/parse_tree.m:
compiler/source_file_map.m:
compiler/notes/compiler_design.html:
Add a new module to read, write and search the mapping.
compiler/modules.m:
Use the source file map when searching for source files.
Export `make_directory' for use by source_file_map.m.
Use the module name rather than the source file name to
generate the executable name. This matches the documentation
in the User's Guide, and it's needed to make the tests work.
compiler/prog_io.m:
Separate out the code to read the first item in a module to
find the module name into a new predicate, `find_module_name'.
compiler/handle_options.m:
Don't complain about the module name not matching the file
name when generating the Mercury.modules file -- the file
only needs to be generated when the module name doesn't
match the file name.
compiler/llds_out.m:
Remove a duplicate copy of `make_directory'.
compiler/options.m:
compiler/mercury_compile.m:
doc/user_guide.texi:
Add the `--generate-source-file-mapping' (-f) option
to generate the mapping.
NEWS:
Document the change.
tests/hard_coded/Mmakefile:
tests/hard_coded/source_file_map.m:
tests/hard_coded/mapped_module.exp:
Test case.
Estimated hours taken: 15
Branches: main
Make inter-module optimization work properly with sub-modules.
compiler/intermod.m:
Write `exported_to_submodules' predicates to the `.opt' file.
Read `.int0' files needed by the `.opt' files.
compiler/make.dependencies.m:
compiler/modules.m:
Handle dependencies on the extra `.int0' files when compiling
with `--intermodule-optimization'.
compiler/modules.m:
compiler/prog_io.m:
compiler/*.m:
Handle partially qualified file names when searching for
the `.m' file for a module when checking whether there
should be a dependency on the `.opt' file for the module.
Separate out the code to find for the source file for a module
from the code to read the source file for a module.
Remove an unnecessary argument from prog_io__read_opt_file
(`.opt' files are always searched for).
compiler/modules.m:
Export process_module_private_interfaces, for use by intermod.m.
Remove process_module_indirect_imports, which isn't used anywhere.
Change get_ancestors from a predicate to a function.
compiler/make_hlds.m:
Don't report duplicate declaration errors for items imported
for inter-module optimization. Sometimes both the `.int' and
`.int0' file for a module are read, and the `.int0' file contains
everything in the `.int' file..
compiler/modes.m:
compiler/post_typecheck.m:
Don't report errors for duplicate mode declarations for imported
predicates when performing inter-module optimization. If the
`.int' and `.int0' files for a module are both read, the mode
declarations for a predicate can be read twice.
Where there are duplicate mode declarations, remove the
duplicate procedures.
Move the code to check for indistinguishable modes into
post_typecheck.m. It only needs to be done once, not
on every iteration of mode inference.
compiler/hlds_pred.m:
Add a predicate pred_info_remove_procid, for use by post_typecheck.m.
compiler/mercury_to_mercury.m:
Improve the comment generated for module_defn items which shouldn't
appear in Mercury source.
compiler/notes/compiler_design.html:
Improve the documentation of post_typecheck.m.
tests/invalid/qualified_cons_id2.err_exp:
Update expected output.
Estimated hours taken: 400
Branches: main
This diff implements stack slot optimization for the LLDS back end based on
the idea that after a unification such as A = f(B, C, D), saving the
variable A on the stack indirectly also saves the values of B, C and D.
Figuring out what subset of {B,C,D} to access via A and what subset to access
via their own stack slots is a tricky optimization problem. The algorithm we
use to solve it is described in the paper "Using the heap to eliminate stack
accesses" by Zoltan Somogyi and Peter Stuckey, available in ~zs/rep/stackslot.
That paper also describes (and has examples of) the source-to-source
transformation that implements the optimization.
The optimization needs to know what variables are flushed at call sites
and at program points that establish resume points (e.g. entries to
disjunctions and if-then-elses). We already had code to compute this
information in live_vars.m, but this code was being invoked too late.
This diff modifies live_vars.m to allow it to be invoked both by the stack
slot optimization transformation and by the code generator, and allows its
function to be tailored to the requirements of each invocation.
The information computed by live_vars.m is specific to the LLDS back end,
since the MLDS back ends do not (yet) have the same control over stack
frame layout. We therefore store this information in a new back end specific
field in goal_infos. For uniformity, we make all the other existing back end
specific fields in goal_infos, as well as the similarly back end specific
store map field of goal_exprs, subfields of this new field. This happens
to significantly reduce the sizes of goal_infos.
To allow a more meaningful comparison of the gains produced by the new
optimization, do not save any variables across erroneous calls even if
the new optimization is not enabled.
compiler/stack_opt.m:
New module containing the code that performs the transformation
to optimize stack slot usage.
compiler/matching.m:
New module containing an algorithm for maximal matching in bipartite
graphs, specialized for the graphs needed by stack_opt.m.
compiler/mercury_compile.m:
Invoke the new optimization if the options ask for it.
compiler/stack_alloc.m:
New module containing code that is shared between the old,
non-optimizing stack slot allocation system and the new, optimizing
stack slot allocation system, and the code for actually allocating
stack slots in the absence of optimization.
Live_vars.m used to have two tasks: find out what variables need to be
saved on the stack, and allocating those variables to stack slots.
Live_vars.m now does only the first task; stack_alloc.m now does
the second, using code that used to be in live_vars.m.
compiler/trace_params:
Add a new function to test the trace level, which returns yes if we
want to preserve the values of the input headvars.
compiler/notes/compiler_design.html:
Document the new modules (as well as trace_params.m, which wasn't
documented earlier).
compiler/live_vars.m:
Delete the code that is now in stack_alloc.m and graph_colour.m.
Separate out the kinds of stack uses due to nondeterminism: the stack
slots used by nondet calls, and the stack slots used by resumption
points, in order to allow the reuse of stack slots used by resumption
points after execution has left their scope. This should allow the
same stack slots to be used by different variables in the resumption
point at the start of an else branch and nondet calls in the then
branch, since the resumption point of the else branch is not in effect
when the then branch is executed.
If the new option --opt-no-return-calls is set, then say that we do not
need to save any values across erroneous calls.
Use type classes to allow the information generated by this module
to be recorded in the way required by its invoker.
Package up the data structures being passed around readonly into a
single tuple.
compiler/store_alloc.m:
Allow this module to be invoked by stack_opt.m without invoking the
follow_vars transformation, since applying follow_vars before the form
of the HLDS code is otherwise final can be a pessimization.
Make the module_info a part of the record containing the readonly data
passed around during the traversal.
compiler/common.m:
Do not delete or move around unifications created by stack_opt.m.
compiler/call_gen.m:
compiler/code_info.m:
compiler/continuation_info.m:
compiler/var_locn.m:
Allow the code generator to delete its last record of the location
of a value when generating code to make an erroneous call, if the new
--opt-no-return-calls option is set.
compiler/code_gen.m:
Use a more useful algorithm to create the messages/comments that
we put into incr_sp instructions, e.g. by distinguishing between
predicates and functions. This is to allow the new scripts in the
tool directory to gather statistics about the effect of the
optimization on stack frame sizes.
library/exception.m:
Make a hand-written incr_sp follow the new pattern.
compiler/arg_info.m:
Add predicates to figure out the set of input, output and unused
arguments of a procedure in several different circumstances.
Previously, variants of these predicates were repeated in several
places.
compiler/goal_util.m:
Export some previously private utility predicates.
compiler/handle_options.m:
Turn off stack slot optimizations when debugging, unless
--trace-optimized is set.
Add a new dump format useful for debugging --optimize-saved-vars.
compiler/hlds_llds.m:
New module for handling all the stuff specific to the LLDS back end
in HLDS goal_infos.
compiler/hlds_goal.m:
Move all the relevant stuff into the new back end specific field
in goal_infos.
compiler/notes/allocation.html:
Update the documentation of store maps to reflect their movement
into a subfield of goal_infos.
compiler/*.m:
Minor changes to accomodate the placement of all back end specific
information about goals from goal_exprs and individual fields of
goal_infos into a new field in goal_infos that gathers together
all back end specific information.
compiler/use_local_vars.m:
Look for sequences in which several instructions use a fake register
or stack slot as a base register pointing to a cell, and make those
instructions use a local variable instead.
Without this, a key assumption of the stack slot optimization,
that accessing a field in a cell costs only one load or store
instruction, would be much less likely to be true. (With this
optimization, the assumption will be false only if the C compiler's
code generator runs out of registers in a basic block, which for
the code we generate should be unlikely even on x86s.)
compiler/options.m:
Make the old option --optimize-saved-vars ask for both the old stack
slot optimization (implemented by saved_vars.m) that only eliminates
the storing of constants in stack slots, and the new optimization.
Add two new options --optimize-saved-vars-{const,cell} to turn on
the two optimizations separately.
Add a bunch of options to specify the parameters of the new
optimizations, both in stack_opt.m and use_local_vars.m. These are
for implementors only; they are deliberately not documented.
Add a new option, --opt-no-return-cells, that governs whether we avoid
saving variables on the stack at calls that cannot return, either by
succeeding or by failing. This is for implementors only, and thus
deliberately documented only in comments. It is enabled by default.
compiler/optimize.m:
Transmit the value of a new option to use_local_vars.m.
doc/user_guide.texi:
Update the documentation of --optimize-saved-vars.
library/tree234.m:
Undo a previous change of mine that effectively applied this
optimization by hand. That change complicated the code, and now
the compiler can do the optimization automatically.
tools/extract_incr_sp:
A new script for extracting stack frame sizes and messages from
stack increment operations in the C code for LLDS grades.
tools/frame_sizes:
A new script that uses extract_incr_sp to extract information about
stack frame sizes from the C files saved from a stage 2 directory
by makebatch and summarizes the resulting information.
tools/avg_frame_size:
A new script that computes average stack frame sizes from the files
created by frame_sizes.
tools/compare_frame_sizes:
A new script that compares the stack frame size information
extracted from two different stage 2 directories by frame_sizes,
reporting on both average stack frame sizes and on specific procedures
that have different stack frame sizes in the two versions.