mirror of
https://github.com/Mercury-Language/mercury.git
synced 2025-12-15 13:55:07 +00:00
c4574c6db8b97ac386dc6d6a3923e1097ad59884
45 Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
c8e4004825 |
This diff makes code_info.m and many callers of its predicates easier to read
Estimated hours taken: 4 Branches: main This diff makes code_info.m and many callers of its predicates easier to read and to maintain, but contains no changes in algorithms whatsoever. compiler/code_info.m: Bring this module into line with our current coding standards. Use predmode declarations, functions, and state variable syntax when appropriate. Reorder arguments of predicates where necessary for the use of state variable syntax, and where this improves readability. Where a predicate returned its input code_info unchanged, purely to allow the convenient use of DCG notation in the caller, delete the unnecessary output argument. This should make the caller somewhat more efficient, since it can avoid updating the stack slot holding the current code_info. Replace old-style lambdas with new-style lambdas or with partially applied named procedures. compiler/*.m: Conform to the changes in code_info.m. This mostly means using the new argument orders of predicates exported by hlds_pred.m, and using state variable notation. |
||
|
|
f007b45df8 |
Implement the infrastructure for term size profiling.
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.
|
||
|
|
92045bdc78 |
Simplify the handling of static ground terms in the LLDS backend.
Estimated hours taken: 5 Branches: main Simplify the handling of static ground terms in the LLDS backend. Instead of creating code, rtti and layout structures all containing create rvals and then converting those rvals to static cells, create the static cells directly. compiler/llds.m: Remove the create alternative from rvals, and the types used only by create. Delete the code handling the global_data type, which has been moved to global_data.m. compiler/global_data.m: A new module handling static data structures for the LLDS backend. The basis of this module is the code that used to be in llds.m handling the global_data type, but this has been augmented to manage static cells as well as the data structures defined in rtti.m and layout.m. Also, rename the non_common_data field of global_data, which no longer makes sense, to refer to deep profiling, since it holds deep profiling data structures. compiler/llds_common.m: Delete this file, since it is no longer needed. The operative part is now in global data.m; the rest (including the code to traverse code and data structures looking for create rvals) is no longer needed. compiler/ll_backend.m: Delete the deleted module, and add the added module. XXX These changes should be also be documented in notes/compiler_design.html when Fergus finishes his changes to that file. compiler/code_info.m: Add the database of static cells to the code generator state. compiler/code_gen.m: compiler/ll_pseudo_type_info.m: compiler/lookup_switch.m: compiler/mercury_compile.m: compiler/stack_layout.m: compiler/static_term.m: compiler/string_switch.m: compiler/unify_gen.m: compiler/var_locn.m: Instead of creating create rvals, create static cells and return references to those cells. The static cell database ensures that we never create duplicate cells (unless --no-common-data forces us to do so). Pass around the static cell database. compiler/code_util.m: compiler/continuation_info.m: compiler/dupelim.m: compiler/exprn_aux.m: compiler/jumpopt.m: compiler/livemap.m: compiler/llds_out.m: compiler/middle_rec.m: compiler/opt_debug.m: compiler/opt_util.m: compiler/optimize.m: Minor changes to conform to the above, mostly consisting of the deletion of code that handled create rvals. |
||
|
|
9b0aa613c4 |
Delete the cell number field from create rvals, since we don't need
Estimated hours taken: 1 Branches: main compiler/llds.m: Delete the cell number field from create rvals, since we don't need it anymore. compiler/*.m: Conform to the change above, and simplify predicate interfaces by deleting arguments whose sole purpose was the allocation of cell numbers. |
||
|
|
9551640f55 |
Import only one compiler module per line. Sort the blocks of imports.
Estimated hours taken: 2 Branches: main compiler/*.m: Import only one compiler module per line. Sort the blocks of imports. This makes it easier to merge in changes. In a couple of places, remove unnecessary imports. |
||
|
|
d869c5505b |
Hide the events associated with the goals inserted by tabling transformations,
Estimated hours taken: 2 Branches: main Hide the events associated with the goals inserted by tabling transformations, since ordinary programmers shouldn't be exposed to the details of the transformation. (A later diff will adjust the goal paths of the events associated with the original code back to what they would have been without the transformation.) Add a new mdb command, unhide_events, that allows the programmer to expose hidden events. This is intended for implementors only. compiler/hlds_goal.m: Add a new goal feature, hide_debug_event. If a nonatomic goal has this feature, then the associated trace events will be hidden. compiler/trace.m: Respect the new goal feature. compiler/table_gen.m: Add the new goal feature to the compound goals created by tabling transformations. compiler/code_gen.m: compiler/dense_switch.m: compiler/disj_gen.m: compiler/ite_gen.m: compiler/string_switch.m: compiler/switch_gen.m: compiler/tag_switch.m: Pass the required goal_info to trace.m, to allow it to hide events as required. runtime/mercury_trace_base.[ch]: Add two global boolean variables. One says whether we are exposing hidden events, the other says whether we have ever exposed hidden events. trace/mercury_trace.c: Hide hidden events, unless the programmer has asked for them to be exposed. trace/mercury_trace_internal.c: Implement the unhide_events command. Make "dd" check whether we have ever exposed hidden events. Fix some unclear code in "print_optionals". doc/user_guide.texi: Doument the unhide_events command. doc/mdb_categories: Mention the unhide_events command. tests/debugger/mdb_command_test.inp: Test the documentation of the unhide_events command. |
||
|
|
189b9215ae |
This diff implements stack slot optimization for the LLDS back end based on
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.
|
||
|
|
7597790760 |
Use sub-modules to structure the modules in the Mercury compiler directory.
The main aim of this change is to make the overall, high-level structure of the compiler clearer, and to encourage better encapsulation of the major components. compiler/libs.m: compiler/backend_libs.m: compiler/parse_tree.m: compiler/hlds.m: compiler/check_hlds.m: compiler/transform_hlds.m: compiler/bytecode_backend.m: compiler/aditi_backend.m: compiler/ml_backend.m: compiler/ll_backend.m: compiler/top_level.m: New files. One module for each of the major components of the Mercury compiler. These modules contain (as separate sub-modules) all the other modules in the Mercury compiler, except gcc.m and mlds_to_gcc.m. Mmakefile: compiler/Mmakefile: Handle the fact that the top-level module is now `top_level', not `mercury_compile' (since `mercury_compile' is a sub-module of `top_level'). compiler/Mmakefile: Update settings of *FLAGS-<modulename> to use the appropriate nested module names. compiler/recompilation_check.m: compiler/recompilation_version.m: compiler/recompilation_usage.m: compiler/recompilation.check.m: compiler/recompilation.version.m: compiler/recompilation.version.m: Convert the `recompilation_*' modules into sub-modules of the `recompilation' module. compiler/*.m: compiler/*.pp: Module-qualify the module names in `:- module', `:- import_module', and `:- use_module' declarations. compiler/base_type_info.m: compiler/base_type_layout.m: Deleted these unused empty modules. compiler/prog_data.m: compiler/globals.m: Move the `foreign_language' type from prog_data to globals. compiler/mlds.m: compiler/ml_util.m: compiler/mlds_to_il.m: Import `globals', for `foreign_language'. Mmake.common.in: trace/Mmakefile: runtime/Mmakefile: Rename the %.check.c targets as %.check_hdr.c, to avoid conflicts with compiler/recompilation.check.c. |
||
|
|
befb329aaf |
Add type information to the array_index operator.
Estimated hours taken: 8 Branches: main Add type information to the array_index operator. This is needed for both the GCC back-end and the IL back-end. compiler/builtin_ops.m: In the array_index constructor for the unary_op type, add the array element type as a field. compiler/ml_string_switch.m: compiler/string_switch.m: compiler/mlds_to_java.m: When generating array_index operators, generate the new field. compiler/bytecode.m: compiler/llds.m: compiler/llds_out.m: compiler/mlds_to_c.m: compiler/mlds_to_java.m: When consuming array_index operators, ignore the new field. compiler/mlds_to_gcc.m: When consuming array_index operators, use the array element type, rather than wrongly assuming the element type is always 'MR_Integer'. compiler/mlds_to_il.m: Add code to handle the array_index operator, rather than calling `throw_unimplemented'. compiler/bytecode.m: Delete the reverse mode of binop_code. This was not used, it was just there to get the compiler to check that we didn't map two different binary operators to the same code. This mode no longer works, since we map array_index operators to the same code regardless of the the array element type. compiler/rtti_to_mlds.m: compiler/ml_string_switch.m: compiler/ml_code_util.m: To avoid code duplication, move ml_string_type, which was defined in both rtti_to_mlds.m and ml_string_switch.m, into ml_code_util.m. compiler/ml_string_switch.m: Minor changes to avoid some code duplication. compiler/mlds_to_java.m: Fix a bug where it was using the wrong type for the `args' variable. Add an XXX comment about what looks to me like another bug. |
||
|
|
4be69fa961 |
Eliminated a lot of the dependencies on the the `code_model' type,
Estimated hours taken: 6 Eliminated a lot of the dependencies on the the `code_model' type, and move that type from llds.m into a new module `code_model'. The aim of this change is to improve the modularity of the compiler by reducing the number of places in the compiler front-end that depend on back-end concepts and the number of places in the MLDS back-end which depend on the LLDS. compiler/code_model.m: New module. Contains the code_model type and associated procedures. compiler/llds.m: Move the code_model type into code_model.m. compiler/hlds_goal.m: Move the goal_info_get_code_model procedure into code_model.m, to avoid having the HLDS modules import code_model. compiler/hlds_out.m: Delete `hlds_out__write_code_model', since it wasn't being used. compiler/hlds_pred.m: Move the proc_info_interface_code_model procedure into code_model.m, to avoid having the HLDS modules import code_model. compiler/goal_path.m: When computing the `maybe_cut' field for `some' goals, compute it by comparing the determinism rather than by comparing the goal_infos. compiler/unique_modes.m: Use determinism and test for soln_count = at_most_many rather than using code_model and testing for model_non. compiler/inlining.m: Test for determinism nondet/multi rather than testing for code_model model_non. compiler/hlds_pred.m: compiler/det_report.m: Change valid_code_model_for_eval_method, which succeeded unless the eval_method was minimal_model and the code_model was model_det, to valid_determinism_for_eval_method, which succeeds unless the eval_method is minimal_model and the determinism cannot fail. As well as avoiding a dependency on code_model in the HLDS modules, this also fixes a bug where det_report could give misleading error messages, saying that `multi' was a valid determinism for `minimal_model' predicates, when in fact the compiler will always report a determinism error if you declare a `minimal_model' predicate with determinism `multi'. (Actually the code in which this bug occurs is in fact unreachable, but this is no doubt also a bug... I'll address that one in a separate change.) compiler/lookup_switch.m: Simplify the code a bit by using globals__lookup_*_option rather than globals__get_option and then getopt__lookup_option. compiler/*.m: Add `import_module' declarations for `code_model', and in some cases remove `import_module' declarations for `llds'. |
||
|
|
d9c0475e4a |
Reorganize the code for handling switches in the MLDS and
Estimated hours taken: 2 Reorganize the code for handling switches in the MLDS and LLDS back-ends to reduce code duplication. compiler/switch_util.m: New file. Contains stuff for switches that is shared between the MLDS and LLDS back-ends. compiler/ml_switch_gen.m: compiler/ml_string_switch.m: compiler/ml_tag_switch.m: compiler/switch_gen.m: compiler/string_switch.m: compiler/tag_switch.m: Move code that was duplicated in the LLDS and MLDS back-ends into string_util.m. Change some names and import_module declarations to match the new organization. compiler/notes/compiler_design.html: Document the new module switch_util.m. Also mention ml_tag_switch.m. |
||
|
|
3a26ad82d5 |
Add information required for structure reuse and compile time garbage
Estimated hours taken: 2 Add information required for structure reuse and compile time garbage collection to the LLDS. The code generator does not yet generate this information. This will be committed to the main branch to avoid CVS conflicts. compiler/llds.m: Add an LLDS instruction `free_heap(rval)', which applies the MR_free_heap macro to its argument. Add a `maybe(rval)' field to `create' rvals to hold the address of a cell to reuse. This field should always be `no' after code generation, because all non-constant creates are converted into lower-level operations during code generation. compiler/value_number.m: Don't reorder instructions around a `free_heap' instruction to avoid generating code which looks at deallocated memory. compiler/*.m: Handle the new instruction and field. |
||
|
|
773bd702cc |
Some more changes to minimize the complexity of the intermodule dependencies.
Estimated hours taken: 2.5 Some more changes to minimize the complexity of the intermodule dependencies. In particular, ensure that bytecode.m does not need to import llds.m. compiler/llds.m: compiler/builtin_ops.m: Move the definitions of the unary_op and binary_op types into a new module `builtin_ops'. These types are used by three of the different back-ends (bytecode, llds, and mlds) and therefore deserve to be in their own module. compiler/bytecode.m: Define a type `byte_reg_type' and use that instead of llds__reg_type. Delete the import of module llds. compiler/notes/compiler_design.html: Document the new module builtin_ops. compiler/rl_exprn.m: Add a comment explaining why we need to import llds (and builtin_ops). compiler/base_type_layout.m: compiler/bytecode.m: compiler/code_util.m: compiler/dense_switch.m: compiler/ite_gen.m: compiler/jumpopt.m: compiler/llds_out.m: compiler/lookup_switch.m: compiler/middle_rec.m: compiler/opt_debug.m: compiler/opt_util.m: compiler/rl_exprn.m: compiler/string_switch.m: compiler/tag_switch.m: compiler/transform_llds.m: compiler/unify_gen.m: compiler/value_number.m: compiler/vn_block.m: compiler/vn_cost.m: compiler/vn_flush.m: compiler/vn_type.m: compiler/vn_util.m: compiler/vn_verify.m: Add imports of module builtin_ops to lots of modules that imported llds. |
||
|
|
c2da42e6d0 |
Allow the compiler to handle create rvals whose arguments have a size
Estimated hours taken: 16 Allow the compiler to handle create rvals whose arguments have a size which is different from the size of a word. Use this capability to reduce the size of RTTI information, in two ways. The first way is by rearranging the way in which we represent information about the live values at a label. Instead of an array with an entry for each live value, the entry being a pair of Words containing a shape representation and a location description respectively, use an array of shape representations (still Words), followed by an array of 32-bit ints (which may be smaller than Word) describing locations whose descriptions don't fit into 8 bits, followed by an array of 8-bit ints describing locations whose descriptions do fit into 8 bits. The second way is by reducing the sizes of some fields in the C structs used for RTTI. Several of these had to be bigger than necessary in the past because their fields were represented by the args of a create rval. On cyclone, this reduces the size of the object file for queens.m by 2.8%. IMPORTANT Until this change is reflected in the installed compiler, you will not be able to use any modules compiled with debugging in your workspaces if the workspace has been updated to include this change. This is because the RTTI data structures generated by the old installed compiler will not be compatible with the new structure definitions. The workaround is simple: if your workspace contains modules compiled with debugging, don't do a cvs update until this change has been installed. configure.in: Check whether <stdint.h> is present. If not, autoconfigure types that are at least 16 and 32 bits in size. runtime/mercury_conf.h.in: Mention the macros used by the configure script, MR_INT_LEAST32_TYPE and MR_INT_LEAST16_TYPE. runtime/mercury_conf_param.h: Document the macros used by the configure script, MR_INT_LEAST32_TYPE and MR_INT_LEAST16_TYPE. runtime/mercury_types.h: If <stdint.h> is available, get the basic integer types (intptr_t, int_least8_t, etc) from there. Otherwise, get them from the autoconfigure script. Define types such as Word in terms of these (eventually) standard types. runtime/mercury_stack_layout.h: Add macros for manipulating short location descriptions, update the types and macros for manipulating long location descriptions. Modify the way the variable count is represented (since it now must count locations with long and short descriptions separately), and move it to the structure containing the arrays it describes. Reduce the size of the some fields in structs. This required some reordering of fields to avoid the insertion of padding by the compiler, and changes to the definitions of some types (e.g. MR_determinism). runtime/mercury_layout_util.[ch]: runtime/mercury_stack_trace.c: runtime/mercury_accurate_gc.c: trace/mercury_trace.c: trace/mercury_trace_external.c: trace/mercury_trace_internal.c: Update the code to conform to the changes to stack_layout.h. compiler/llds.m: Modify the create rval in two ways. First, add an extra argument to represent the types of the arguments, which used to always be implicit always a word in size, but may now be explicit and possibly smaller (e.g. uint_least8). Second, since the code generator would do the wrong thing with creates with smaller than wordsize arguments, replace the old must-be-unique vs may-be-nonunique bool with a three-valued marker, must_be_dynamic vs must_be_static vs can_be_either. Add uint_least8, uint_least16, uint_least32 (and their signed variants) and string as llds_types. Add a couple of utility predicates for checking whether an llds_type denotes a type whose size is the same as word. compiler/llds_out.m: Use explicitly given argument types when declaring and initializing the arguments of a cell, if they are given. compiler/llds_common.m: Don't conflate creates with identical argument values but different C-level argument types. The probability of a match is minuscule anyway. compiler/stack_layout.m: Use the new representation of creates to generate the new versions of RTTI data structures. compiler/code_exprn.m: If a create is marked must_be_static, don't inspect the arguments to decide whether it can be static or not. If it can't, we'll get an abort later on in llds_out or during C compilation anyway. compiler/base_type_layout.m: When creating pseudo typeinfos, return the llds_type of the resulting rval. Minor changes required by the change in create. compiler/base_type_info.m: compiler/base_typeclass_info.m.m: compiler/code_util.m: compiler/dupelim.m: compiler/exprn_aux.m: compiler/jumpopt.m: compiler/livemap.m: compiler/lookup_switch.m: compiler/middle_rec.m: compiler/opt_debug.m: compiler/opt_util.m: compiler/string_switch.m: compiler/unify_gen.m: compiler/vn_cost.m: compiler/vn_filter.m: compiler/vn_flush.m: compiler/vn_order.m: compiler/vn_type.m: compiler/vn_util.m: compiler/vn_verify.m: Minor changes required by the change in create. library/benchmarking.m: library/std_util.m: Use the new macros in hand-constructing proc layout structures. library/Mmakefile: Add explicit dependencies for benchmarking.o and std_util.o on ../runtime/mercury_stack_layout.h. Although this is only a subset of the truth (in reality, all library objects depend on most of the runtime headers), it is a good tradeoff between safety and efficiency. The other runtime header files tend not to change in incompatible ways. trace/Mmakefile: Add explicit dependencies for all the object files on ../runtime/mercury_stack_layout.h, for similar reasons. |
||
|
|
5c955626f2 |
These changes make var' and term' polymorphic.
Estimated hours taken: 20 These changes make `var' and `term' polymorphic. This allows us to make variables and terms representing types of a different type to those representing program terms and those representing insts. These changes do not *fix* any existing problems (for instance there was a messy conflation of program variables and inst variables, and where necessary I've just called varset__init(InstVarSet) with an XXX comment). NEWS: Mention the changes to the standard library. library/term.m: Make term, var and var_supply polymorphic. Add new predicates: term__generic_term/1 term__coerce/2 term__coerce_var/2 term__coerce_var_supply/2 library/varset.m: Make varset polymorphic. Add the new predicate: varset__coerce/2 compiler/prog_data.m: Introduce type equivalences for the different kinds of vars, terms, and varsets that we use (tvar and tvarset were already there but have been changed to use the polymorphic var and term). Also change the various kinds of items to use the appropriate kinds of var/varset. compiler/*.m: Thousands of boring changes to make the compiler type correct with the different types for type, program and inst vars and varsets. |
||
|
|
d1855187e5 |
Implement new methods of handling failures and the end points of branched
Estimated hours taken: 260
Implement new methods of handling failures and the end points of branched
control structures.
compiler/notes/failure.html:
Fix an omission about the handling of resume_is_known in if-then-elses.
(This omission lead to a bug in the implementation.)
Optimize cuts across multi goals when curfr is known to be equal
to maxfr.
Clarify the wording in several places.
compiler/code_info.m:
Completely rewrite the methods for handling failure.
Separate the fields of code_info into three classes: those which
do not change after initialization, those which record state that
depends on where in the HLDS goal we are, and those which contain
persistent data such as label and cell counters.
Rename grab_code_info and slap_code_info as remember_position
and reset_to_position, and add a wrapper around the remembered
code_info to make it harder to make mistakes in its use.
(Only the location-dependent fields of the remembered code_info
are used, but putting only them into a separate data structure would
result in more, not less, memory being allocated.)
Gather the predicates that deal with handling branched control
structures into a submodule.
Reorder the declarations and definitions of access predicates
to conform to the new order of fields.
Reorder the declarations and definitions of the failure handling
submodule to better reflect the separation of higher-level and
lower-level predicates.
compiler/code_gen.m:
Replace code_gen__generate_{det,semi,non}_goal_2 with a single
predicate, since for most HLDS constructs the code here is the same
anyway (the called preds check the code model when needed).
Move classification of the various kinds of unifications to unify_gen,
since that is where it belongs.
Move responsibility for initializing the code generator's trace
info to code_info.
Move the generation of code for negations to ite_gen, since the
handling of negations is a cut-down version of the handling of
negations. This should make the required double maintenance easier,
and more likely to happen.
compiler/disj_gen.m:
compiler/ite_gen.m:
These are the two modules that handle most failures; they have
undergone a significant rewrite. As part of this rewrite, factor
out the remaining common code between model_non and model_{det,semi}
goals.
compiler/unify_gen.m:
Move classification of the various kinds of unifications here from
code_gen. This allows us to keep several previously exported
predicates private.
compiler/call_gen.m:
Factor out some code that was common to ordinary calls, higher order
calls and method calls. Move the common code that checks whether
we are doing tracing to trace.m.
Replace call_gen__generate_{det,semi,nondet}_builtin with a single
predicate.
Delete the commented out call_gen__generate_complicated_unify,
since it will never be needed and in any case suffered from
significant code rot.
compiler/llds.m:
Change the mkframe instruction so that depending on one of its
arguments, it can create either ordinary frames, or the cut-down
frames used by the new failure handling algorithm (they have only
three fixed fields: prevfr, redoip and redofr).
compiler/llds_out.m:
Emit a #define MR_USE_REDOFR before including mercury_imp.h, to
tell the runtime we are using the new failure handling scheme.
This effectively changes the grade of the compiled module.
Emit MR_stackvar and MR_framevar instead of detstackvar and framevar.
This is a step towards cleaning up the name-space, and a step towards
making both start numbering at 0. For the time being, the compiler
internally still starts counting framevars at 0; the code in llds_out.m
adds a +1 offset.
compiler/trace.m:
Change the way trace info is initialized to fit in with the new
requirements of code_info.m.
Move the "are we tracing" check from the callers to the implementation
of trace__prepare_for_call.
compiler/*.m:
Minor changes in accordance with the major ones above.
compiler/options.m:
Introduce a new option, allow_hijacks, which is set to "yes" by
default. It is not used yet, but the idea is that when it is set to no,
the code generator will not generate code that hijacks the nondet
stack frame of another procedure invocation; instead, it will create
a new temporary nondet stack frame. If the current procedure is
model_non, it will have three fields: prevfr, redoip and redofr.
If the current procedure is model_det or model_semi, it will have
a fourth field that is set to the value of MR_sp. The idea is that
the runtime system, which will be able to distinguish between
ordinary frames (whose size is at least 5 words), 3-word and 4-word
temporary frames, will now be able to use the redofr slots of
all three kinds of frames and the fourth slot values of 4-word
temporary frames as the addresses relative to which framevars
and detstackvars respectively ought to be offset in stack layouts.
compiler/handle_options.m:
Turn off allow_hijacks if the gc method is accurate.
runtime/mercury_stacks.h:
Change the definitions for the nondet stack handling macros
to accommodate the new nondet stack handling discipline.
Define a new macro for creating temp nondet frames.
Define MR_based_stackvar and MR_based_framevar (both of which start
numbering slots at 1), and express other references, including
MR_stackvar and MR_framevar and backward compatible definitions of
detstackvar and framevar for hand-written C code, in terms of those
two.
runtime/mercury_stack_trace.[ch]:
Add a new function to print a dump of the fixed elements nondet stack,
for debugging my changes. (The dump does not include variable values.)
runtime/mercury_trace_internal.c:
Add a new undocumented command "D" for dumping the nondet stack
(users should not know about this command, since the output is
intelligible only to implementors).
Add a new command "toggle_echo" that can cause the debugger to echo
all commands. When the input to the debugger is redirected, this
echo causes the output of the session to be much more readable.
runtime/mercury_wrapper.c:
Save the address of the artificial bottom nondet stack frame,
so that the new function in mercury_stack_trace.c can find out
where to stop.
runtime/mercury_engine.c:
runtime/mercury_wrapper.c:
Put MR_STACK_TRACE_THIS_MODULE at the tops of these modules, so that
the labels they define (e.g. do_fail and global_success) are registered
in the label table when their module initialization functions are
called. This is necessary for a meaningful nondet stack dump.
runtime/mercury_grade.h:
Add a new component to the grade string that specifies whether
the code was compiled with the old or the new method of handling
the nondet stack. This is important, because modules compiled
with different nondet stack handling disciplines are not compatible.
This component depends on whether MR_USE_REDOFR is defined or not.
runtime/mercury_imp.h:
If MR_DISABLE_REDOFR is defined, undefine off MR_USE_REDOFR before
including mercury_grade.h. This is to allow people to continue
working on un-updated workspaces after this change is installed;
they should put "EXTRA_CFLAGS = -DMR_DISABLE_REDOFR" into
Mmake.stage.params. (This way their stage1 will use the new method
of handling failure, while their stage2 2&3 will use the old one.)
This change should be undone once all our workspaces have switched
over to the new failure handling method.
tests/hard_coded/cut_test.{m,exp}:
A new test case to tickle the various ways of handling cuts in the
new code generator.
tests/hard_coded/Mmakefile:
Enable the new test case.
|
||
|
|
67d8308260 | Same as previous message. | ||
|
|
11d8161692 |
Add support for nested modules.
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.
|
||
|
|
73131e8df3 |
Undo Zoltan's bogus update of all the copyright dates.
Estimated hours taken: 0.75 library/*.m: compiler/*.m: Undo Zoltan's bogus update of all the copyright dates. The dates in the copyright header should reflect the years in which the file was modified (and no, changes to the copyright header itself don't count as modifications). |
||
|
|
bb4442ddc1 |
Update copyright dates for 1998.
Estimated hours taken: 0.5 compiler/*.m: Update copyright dates for 1998. |
||
|
|
05267d2834 |
Add support for memory profiling.
Estimated hours taken: 40 (+ unknown time by Zoltan)
Add support for memory profiling.
(A significant part of this change is actuallly Zoltan's work. Zoltan
did the changes to the compiler and a first go at the changes to the
runtime and library. I rewrote much of Zoltan's changes to the runtime
and library, added support for the new options/grades, added code to
interface with mprof, did the changes to the profiler, and wrote the
documentation.)
[TODO: add test cases.]
NEWS:
Mention support for memory profiling.
runtime/mercury_heap_profile.h:
runtime/mercury_heap_profile.c:
New files. These contain code to record heap profiling information.
runtime/mercury_heap.h:
Add new macros incr_hp_msg(), tag_incr_hp_msg(),
incr_hp_atomic_msg(), and tag_incr_hp_atomic_msg().
These are like the non-`msg' versions, except that if
PROFILE_MEMORY is defined, they also call MR_record_allocation()
from mercury_heap_profile.h to record heap profiling information.
Also, fix up the indentation in lots of places.
runtime/mercury_prof.h:
runtime/mercury_prof.c:
Added code to dump out memory profiling information to files
`Prof.MemoryWords' and `Prof.MemoryCells' (for use by mprof).
Change the format of the `Prof.Counts' file so that the
first line says what it is counting, the units, and a scale
factor. Prof.MemoryWords and Prof.MemoryCells can thus have
exactly the same format as Prof.Counts.
Also cleaned up the interface to mercury_prof.c a bit, and did
various other minor cleanups -- indentation changes, changes to
use MR_ prefixes, additional comments, etc.
runtime/mercury_prof_mem.h:
runtime/mercury_prof_mem.c:
Rename prof_malloc() as MR_prof_malloc().
Rename prof_make() as MR_PROF_NEW() and add MR_PROF_NEW_ARRAY().
runtime/mercury_wrapper.h:
Minor modifications to reflect the new interface to mercury_prof.c.
runtime/mercury_wrapper.c:
runtime/mercury_label.c:
Rename the old `-p' (primary cache size) option as `-C'.
Add a new `-p' option to disable profiling.
runtime/Mmakefile:
Add mercury_heap_profile.[ch].
Put the list of files in alphabetical order.
Delete some obsolete stuff for supporting `.mod' files.
Mention that libmer_dll.h and libmer_globals.h are
produced by Makefile.DLLs.
runtime/mercury_imp.h:
Mention that libmer_dll.h is produced by Makefile.DLLs.
runtime/mercury_dummy.c:
Change a comment to refer to libmer_dll.h rather than
libmer_globals.h.
compiler/llds.m:
Add a new field to `create' and `incr_hp' instructions
holding the name of the type, for heap profiling.
compiler/unify_gen.m:
Initialize the new field of `create' instructions with
the appropriate type name.
compiler/llds_out.m:
Output incr_hp_msg() / tag_incr_hp_msg() instead of
incr_hp() / tag_incr_hp().
compiler/*.m:
Minor changes to most files in the compiler back-end to
accomodate the new field in `incr_hp' and `create' instructions.
library/io.m:
Add `io__report_full_memory_stats'.
library/benchmarking.m:
Add `report_full_memory_stats'. This uses the information saved
by runtime/mercury_heap_profile.{c,h} to print out a report
of memory usage by procedures and by types.
Also modify `report_stats' to print out some of that information.
compiler/mercury_compile.m:
If `--statistics' is enabled, call io__report_full_memory_stats
at the end of main/2. This will print out full memory statistics,
if the compiler was compiled with memory profiling enabled.
compiler/options.m:
compiler/handle_options.m:
runtime/mercury_grade.h:
scripts/ml.in:
scripts/mgnuc.in:
scripts/init_grade_options.sh-subr:
scripts/parse_grade_options.sh-subr:
Add new option `--memory-profiling' and new grade `.memprof'.
Add `--time-profiling' as a new synonym for `--profiling'.
Also add `--profile-memory' for more fine-grained control:
`--memory-profiling' implies both `--profile-memory' and
`--profile-calls'.
scripts/mprof_merge_runs:
Update to handle the new format of Prof.Counts and to
also merge Prof.MemoryWords and Prof.MemoryCells.
profiler/options.m:
profiler/mercury_profile.m:
Add new options `--profile memory-words' (`-m'),
`--profile memory-cells' (`-M') and `--profile time' (`-t').
Thes options make the profiler select a different count file,
Prof.MemoryWords or Prof.MemoryCells instead of Prof.Counts.
specific to time profiling.
profiler/read.m:
profiler/process_file.m:
profiler/prof_info.m:
profiler/generate_output.m:
Update to handle the new format of the counts file.
When reading the counts file, look at the first line of
the file to determine what is being profiled.
profiler/globals.m:
Add a new global variable `what_to_profile' that records
what is being profiled.
profiler/output.m:
Change the headings to reflect what is being profiled.
doc/user_guide.texi:
Document memory profiling.
Document new options.
doc/user_guide.texi:
compiler/options.m:
Comment out the documentation for `.proftime'/`--profile-time',
since doing time and call profiling seperately doesn't work,
because the code addresses change when you recompile with a
different grade. Ditto for `.profmem'/`--profile-memory'.
Also comment out the documentation for
`.profcalls'/`--profile-calls', since it is redundant --
`.memprof' produces the same information and more.
configure.in:
Build a `.memprof' grade. (Hmm, should we do this only
if `--enable-all-grades' is specified?)
Don't ever build a `.profcalls' grade.
|
||
|
|
07cc196858 |
When generating code that raises trace events at runtime, trace not just
Estimated hours taken: 5 When generating code that raises trace events at runtime, trace not just procedure calls, exits and failures, but also entries to switch arms, disjunction arms and to the then and else parts of if-then-elses. These new trace ports are exactly what is needed to let the trace analyzer figure out what path execution took inside a procedure. (This includes knowing at what point forward execution resumes after backtracking.) The new ports correspond to the UNIFY port in the Opium debugger, which signified entry to a clause. These new ports complete the set of ports required for generating traces whose information content is approximately equivalent to Opium (i.e. as close to Opium functionality as we can get in Mercury). compiler/trace.m: Add code to handle the new ports. compiler/hlds_goal.m: Add an extra slot to each hlds_goal_info structure. This slot holds information about the position of the goal within the procedure, in the form of a description of the path from the root of the main goal to this goal. This info is included in the new trace ports. It is likely that this info will also be used by optimizations (such as loop invariant removal) to be implemented later. compiler/goal_path.m: A new module whose job it is to fill the new goal_info slot; later it may also contain code to e.g. check whether one goal is before, after, or parallel to another. compiler/hlds_out.m: Include the new slot in HLDS dumps. compiler/mercury_compile.m: Invoke code in goal_path.m to fill in the new slot just before code generation when generating traces. compiler/dense_switch.m: compiler/disj_gen.m: compiler/ite_gen.m: compiler/string_switch.m: compiler/switch_gen.m: compiler/tag_switch.m: Emit code for invoking the new trace ports. runtime/mercury_trace.c: runtime/mercury_trace.h: Implement the new ports. |
||
|
|
04b720630b |
Update the copyright messages so that (a) they contain the correct years
and (b) they say "Copyright (C) ... _The_ University of Melbourne". |
||
|
|
27d156bbb5 |
Implemented a :- use_module directive. This is the same as
Estimated hours taken: 14 Implemented a :- use_module directive. This is the same as :- import_module, except all uses of the imported items must be explicitly module qualified. :- use_module is implemented by ensuring that unqualified versions of items only get added to the HLDS symbol tables if they were imported using import_module. Indirectly imported items (from `.int2' files) and items declared in `.opt' files are treated as if they were imported with use_module, since all uses of them should be module qualified. compiler/module_qual.m Keep two sets of type, mode and inst ids, those which can be used without qualifiers and those which can't. Renamed some predicates which no longer have unique names since '__' became a synonym for ':'. Made mq_info_set_module_used check whether the current item is in the interface, rather than relying on its caller to do the check. Removed init_mq_info_module, since make_hlds.m now uses the mq_info built during the module qualification pass. compiler/prog_data.m Added a pseudo-declaration `used', same as `imported' except uses of the following items must be module qualified. Added a type need_qualifier to describe whether uses of an item need to be module qualified. compiler/make_hlds.m Keep with the import_status whether current item was imported using a :- use_module directive. Use the mq_info structure passed in instead of building a new one. Ensure unqualified versions of constructors only get added to the cons_table if they can be used without qualification. compiler/hlds_module.m Added an extra argument to predicate_table_insert of type need_qualifier. Only add predicates to the name and name-arity indices if they can be used without qualifiers. Changed the structure of the module-name-arity index, so that lookups can be made without an arity, such as when type-checking module qualified higher-order predicate constants. This does not change the interface to the module_name_arity index. Factored out some common code in predicate_table_insert which applies to both predicates and functions. compiler/hlds_pred.m Removed the opt_decl import_status. It isn't needed any more since all uses of items declared in .opt files must now be module qualified. Added some documentation about when the clauses_info is valid. compiler/intermod.m Ensure that predicate and function calls in the `.opt' file are module qualified. Use use_module instead of import_module in `.opt' files. compiler/modules.m Handle use_module directives. Report a warning if both use_module and import_module declarations exist for the same module. compiler/mercury_compile.m Collect inter-module optimization information before module qualification, since it can't cause conflicts any more. This means that the mq_info structure built in module_qual.m can be reused in make_hlds.m, instead of building a new one. compiler/prog_out.m Add a predicate prog_out__write_module_list, which was moved here from module_qual.m. compiler/typecheck.m Removed code to check that predicates declared in `.opt' files were being used appropriately, since this is now handled by use_module. compiler/*.m Added missing imports, mostly for prog_data and term. NEWS compiler/notes/todo.html doc/reference_manual.texi Document `:- use_module'. tests/valid/intermod_lambda_test.m tests/valid/intermod_lambda_test2.m tests/invalid/errors.m tests/invalid/errors2.m Test cases. |
||
|
|
4c3b0ecb09 |
Replace calls to map__set with calls to either map__det_insert or
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. |
||
|
|
54bb1c4a67 |
Move the code that generates code for pragma_c_codes to a new module.
Estimated hours taken: 3 code_gen, pragma_c_code: Move the code that generates code for pragma_c_codes to a new module. llds: Change the representation of reg and temp lvals, in order to create the concept of a "register type" and to reduce memory requirements. Also add a comment indicating a possible future extension dealing with model_non pragma_c_codes. code_exprn, code_info: Add the ability to request registers of a given type, or a specific register, when acquiring registers. bytecode, bytecode_gen, call_gen, dupelim, exprn_aux, follow_vars, frameopt, garbage_out, jumpopt, llds_out, middle_rec, opt_debug, opt_util, store_alloc, string_switch, tag_switch, unify_gen, vn_block, vn_cost, vn_filter, vn_flush, vn_order, vn_temploc, vn_type, vn_util, vn_verify: Small changes to accommodate the new register representation. hlds_goal: Add a comment indicating a possible future extension dealing with model_non pragma_c_codes. inlining: Add a comment indicating a how to deal with a possible future extension dealing with model_non pragma_c_codes. |
||
|
|
08a5f48e2c |
Take the code generator a big step closer to notes/ALLOCATION.
Estimated hours taken: _____ Take the code generator a big step closer to notes/ALLOCATION. The new code generator emits code that is smaller and faster than the code we used to emit. Nondet liveness is no longer used; nondet live sets are always empty. In code that was being modified anyway, remove its handling. Other uses will be removed later (this keeps this change from being far too big; as it is it is merely too big). Similarly for cont-lives. In several places, clarify the code that gathers several code pieces together. call_gen: Unset the failure continuation and flush the resume vars to their stack slots before nondet calls. Move the code that decides whether a nondet call can be a tailcall to code_info. code_aux: Remove the code to handle resume points, since these are now handled in the specific constructs that need them. Replace it with a sanity check. code_exprn: Add a predicate to place multiple vars. code_gen: Remove the predicate code_gen__generate_forced_goal, since it packaged together some operations that should be executed at different times. Don't unset the failure continuation after every nondet goal; this is now done in the constructs that need it. Modify the handling of negation to use resume point info according to notes/ALLOCATION. Remove the predicate code_gen__ensure_vars_are_saved which was use to save all lives variables to the stack before nondet disjunctions and if-then-elses; we don't do that anymore. code_info: Significantly simplify and document the handling of failure continuations, and make the types involved abstract types. Factor out common code in the handling of det and semi commits. Keep track of "zombies", variables that are dead wrt forward execution but whose values we need because they may be needed at a resume point we can reach. Remove several now unneeded predicates, and introduce new predicates to help other modules. code_util: Add a couple of predicates to check whether ia goal cannot fail before flushing all variables to the stack, and whether a goal cannot flush any variables to the stack. These are used in liveness to decide which entry labels will be needed at resume points. disj_gen: Unify the handling of det and semi disjunctions. Model the code handling of nondet disjunctions on the code handling pruned disjunctions. It is possible that the handling of nondet and pruned disjunctions can also be unified; the new code should make this significantly easier. Make the code conform to notes/ALLOCATION. This means saving only the variables mentioned in the resume_point field, not flushing all live variables to the stack at the start of a nondet disjunction, handling zombies, and using the new method of flushing variables at the ends of branched structures. ite_gen: Unify the handling of det and semi if-then-elses. Model the code handling of nondet if-then-elses on the code handling det/semi if-then-elses. It is possible that the handling of nondet and pruned if-then-elses can also be unified; the new code should make this significantly easier. Make the code conform to notes/ALLOCATION. This means saving only the variables mentioned in the resume_point field, not flushing all live variables to the stack at the start of a nondet if-then-else, handling zombies, and using the new method of flushing variables at the ends of branched structures. Apply the new rules about liveness in if-then-elses, which say that the else part is parallel not to the then part but to the conjunction of the condition and the then part. dense_switch, lookup_switch, string_switch, switch_gen, tag_switch, middle_rec: Use the new method of flushing variables at the ends of branched structures. Don't call remake_with_store map; switch_gen will do so. Fix an old bug in lookup_switch. The code in switch_gen which looked for the special case of a two-way switch used to use a heuristic to decide which one was recursive and which one was a base case. We now check the codes of the cases. hlds_goal: Adjust the structure of the resume_point field to make it easier to use. Add a more convenient access predicate. hlds_out: Don't print the nondet liveness and cont live fields, since they are not used anymore. Comment out the printing of the context field, which is rarely useful. Modify the printing of the resume_point field to conform to its new definition. live_vars: Use the resume_point field, not the nondetlives field, to decide which variables may be needed on backward execution. Remove some code copied from liveness.m. liveness: Put the several pieces of information we thread through the traversal predicates into a single tuple. Don't put variables which are local to one branch of a branched structure into the post-birth sets of other branches. Apply the new rules about liveness in if-then-elses, which say that the else part is parallel not to the then part but to the conjunction of the condition and the then part. Variables that are needed in the else part but not in the condition or the then part now die in at the start of the condition (they will be protected by the resume point on the condition). We now treat pruned and non-pruned disjunctions the same way wrt deadness; the old way was too conservative (it had to be). We still mishandle branches which produce some variables but can't succeed. mercury_compile: Liveness now prints its own progress message with -V; support this. store_alloc: When figuring out what variables need to be saved across calls, make sure that we put in interference arcs between those variables and those that are required by enclosing resume points. Don't compute cont-lives, since they are not used anymore. livemap: Fix the starting comment. |
||
|
|
ee24e66a71 |
Switch from using a stack of store_maps in the code_info to govern what
Estimated hours taken: 2.5 Switch from using a stack of store_maps in the code_info to govern what goes where at the end of each branched structure to using the store map fields of the goal expressions of those structures. Fix variable names where they resembled the wrong kind of map(var, lval). code_info: Remove the operations on stacks of store maps. Modify the generate_forced_saves and remake_with_store_map operations to take a store_map parameter. When making variables magically live, pick random unused variables to hold them, since we can no longer use the guidance of the top store map stack entry. This may lead to the generation of some excess move instructions at non-reachable points in the code; this will be fixed later. code_gen: Remove the store map push and pop invocations. Modify the generate_forced_goal operation to take a store_map parameter. code_exprn: Export a predicate for use by code_info. middle_rec, disj_gen, ite_gen, switch_gen, dense_switch, lookup_switch, string_switch, tag_switch: Pass the store map around to get it to invocations of the primitives in code_gen and code_info that now need it. goal_util: Name apart the new follow_vars field in hlds__goal_infos. (This should have been in the change that introduced that field.) common, constraint, cse_detection, det_analysis, dnf, excess, follow_code, intermod, lambda, lco, liveness, make_hlds, mode_util, modes, polymorphism, quantification, simplify, switch_detection, typecheck, unique_modes, unused_args: Fix variable names. follow_vars, store_alloc: Add comments. |
||
|
|
8bd1aaa9de |
Rename address_const to code_addr_const, and add base_type_info_const
Estimated hours taken: 15 hlds_data: Rename address_const to code_addr_const, and add base_type_info_const as a new alternative in cons_id, and make corresponding changes to cons_tag. Make hlds_type__defn an abstract type. llds: Rename address_const to code_addr_const, and add data_addr_const as a new alternative in rval_const. Change type "label" to have four alternatives, not three: local/2 (for internal labels), c_local (local to a C module), local/1 (local a Mercury module but not necessarily to a C module, and exported. llds_out: Keep track of the things declared previously, and don't declare them again unnecessarily. Associate indentation with the following item rather than the previous item (the influence of 244); this results in braces being put in different places than previously, but should be easier to maintain. Handle the new forms of addresses and labels. Refer to c_local labels as STATIC when not using --split-c-files. code_info: Use a presently junk field to store a cell counter, which is used to allocate distinguishing numbers to create'd cells. Previously we used the label counter, which meant that label numbers changed when we optimized away some creates. Handle the new forms of addresses and labels. exprn_aux: Handle the new forms of addresses and labels. We are now more precise in figuring out what label address forms will be considered constants by the C compilers. others: Changes to handle the new forms of addresses and labels, and/or to access hlds_type__defn as an abstract type. |
||
|
|
40e727614d |
Add a boolean argument to the create rval, which should be set to true
Estimated hours taken: 2 llds.m: Add a boolean argument to the create rval, which should be set to true if the cell created must have a unique reference. vn_type.m: Add a corresponding argument to vn_create. others: Fix references to creates and vn_creates. |
||
|
|
a5a6fe26fb |
Fix a code generation bug: it called
Estimated hours taken: 0.5 hours for the fix, 8 hours debugging (plus a similar amount of Zoltan's time debugging) string_switch.m: Fix a code generation bug: it called code_info__generate_failure from the wrong spot, and so used the wrong exprn_info. This meant that the code generated by generate_failure contained incorrect register shuffling, since it thought the variables were in different locations to where they really were. |
||
|
|
2833bfffb7 |
Divided the old hlds.m into four files:
Estimated hours taken: 10
hlds, hlds_module, hlds_pred, hlds_goal, hlds_data:
Divided the old hlds.m into four files:
hlds_module.m defines the data structures that deal with issues
that are wider than a single predicate. These data structures are
the module_info structure, dependency_info, the predicate table
and the shape table.
hlds_pred.m defined pred_info and proc_info, pred_id and proc_id.
hlds_goal.m defines hlds__goal, hlds__goal_{expr,info}, and the
other parts of goal structures.
hlsd_data.m defines the HLDS types that deal with issues related
to data and its representation: function symbols, types, insts, modes.
It also defines the types related to determinism.
hlds.m is now an empty module. I have not removed it from CVS
because we may need the name hlds.m again, and CVS does not like
the reuse of a name once removed.
other modules:
Import the necessary part of hlds.
det_analysis:
Define a type that was up to now improperly defined in hlds.m.
prog_io:
Move the definition of type determinism to hlds_data. This decision
may need to be revisited when prog_io is broken up.
dnf, lambda:
Simplify the task of defining predicates.
llds:
Fix some comments.
mercury_compile:
If the option -d all is given, dump all HLDS stages.
shape, unused_args:
Fix formatting.
|
||
|
|
3224e94532 |
A new pass to remove unnecessary assignment unifications.
excess: A new pass to remove unnecessary assignment unifications. mercury_compile: Call the new excess assignment module. options: Add a new option, excess_assign, to control the new optimization. Add another, num-real-regs, to specify how many of r1, r2 etc are actually real registers. The default is now set to 5 for kryten; later it should be supplied by the mc script, with a value determined at configuration time. tag_switch: Use num-real-regs to figure out whether it is likely to be worthwhile to eliminate the common subexpression of taking the primary tag of a variable. Also fix an old performance bug: the test for when a jump table is worthwhile was reversed. value_number, vn_block: Do value numbering on extended basic blocks, not basic blocks. vn_debug: Modify an information message. labelopt: Clean up an export an internal predicate for value numbering. Replace bintree_set with set. middle_rec: Prepare for the generalization of middle recursion optimization to include predicates with an if-then-else structure. cse_detection: Fix a bug: when hoisting a common desconstruction X = f(Yi), create new variables for the Yi. This avoids problems with any of the Yis appearing in other branches of the code. goal_util: Add a new predicate for use by cse_detection. common: Fix a bug: recompute instmap deltas, since they may be affected by the optimization of common structures. code_info: Make an error message more explicit. det_analysis: Restrict import list to the needed modules. *.m: Import assoc_list. |
||
|
|
eef27b6a67 |
Removed the caller argument from the call, call_closure and goto LLDS
instructions, and the last argument from local labels. All these were placeholders for info put in there by prof.m and used when emitting C code. The set of labels that serve as return points are now calculated in llds.m just before each procedure has its C code generated. This set is passed to output_instruction along with the label at the start of the procedure. |
||
|
|
9dddf14a3f | OK, finally, everything should be back in order. | ||
|
|
fda56846cb |
With any luck, this should be the call_graph branch successfully
merged. Do not use --constraint-propagation, because it doesn't schedule conjunctions properly yet. |
||
|
|
6cc1f3e0b0 |
Changed the way the extra field in the label type is defined.
*.m: Changed the way the extra field in the label type is defined. Now all labels are initially assumed to be 'unknown' and a seperate profiling pass (to be implemented) will determine whether the label can be accessed externally. |
||
|
|
389599b337 |
Revamped the determinism system.
prog_io, hlds: Added the functor "multidet" to the type determinism. Added types and predicates to relate determinism to its two components, can_fail and soln_count. Removed the functor "unspecified" from the type determinism, substituting maybe(determinism) for determinism in proc_info. Replaced the type category with the type code_model, and added predicates to compute it from determinism. det_analysis: Redone the analyses to work with determinism, not category (or code_model). This should enable programmers to write their own erroneous (and failure) predicates. other files: Use the new and renamed types and access predicates. |
||
|
|
ac4f8ba0fb |
Add copyright messages.
compiler/*: Add copyright messages. Change all occurences of *.nl in comments to *.m. compiler/mercury_compile.pp: Change the output to the .dep files to use *.m rather than *.nl. (NOTE: this means that `mmake' will not work any more if you call your files *.nl!!!) |
||
|
|
56185418db |
a new module for manipulating rvals and lvals.
exprn_aux.nl: a new module for manipulating rvals and lvals. code_exprn.nl: the new bottom level of the new code generator. This replaces a large chunk of code_info. *code* & *gen*: various small changes to use the new bottom level of the code generator. |
||
|
|
d9865c2fc1 |
Introduced a new predicate which ignore's any whitespace in the input.
io.nl: Introduced a new predicate which ignore's any whitespace in the input. Needs to have all the whitespace character's added to it. *.nl and *.pp: Changed the implementation of time profiling. Now during a compile, the compiler identifies all the internal labels which can be accessed externally, and marks them. At the moment, these are the continuation labels of calls and the next disjunct in nondet disjunctions. Then at the .mod output, it places a macro 'update_prof_current_proc' to restore the profiling counter. |
||
|
|
fcc624ae6b |
Introduced an extra argument to the LLDS goto.
llds.nl: Introduced an extra argument to the LLDS goto. It is the label address of the Caller and is used for the profiling of tailcall's. *.nl and *.pp: Propagated the extra argument to all the appropiate files. |
||
|
|
1037569d6b |
Use "and" rather than "mod" to mask the hash value, since
string_switch.nl: Use "and" rather than "mod" to mask the hash value, since it may be negative. |
||
|
|
62fa8be865 |
Add new targets `mercury_compile.sicstus' (the Mercury compiler
Makefile.common: Add new targets `mercury_compile.sicstus' (the Mercury compiler compiled with Sicstus) and `mercury_compile.sicstus.debug' (debugging version of the above). *.nl: Use Sicstus-compatible char and string escapes. Avoid the use of explicit existential quantification. Various other hacks to get things to parse correctly under Sicstus. prog_io.nl: Don't allow (A -> B) in DCGs, since NU-Prolog and Mercury give it different semantics to Sicstus. sp_builtin.nl, sp_lib.nl: Split sp_builtin.nl into sp_builtin.nl and sp_lib.nl. sp_conv.sed: Add sed script which converts some character escapes so that they work with Sicstus. term_io.nl: Remove term_io__prefix_op etc. since they aren't used anymore. |
||
|
|
f5dfd6a643 |
Broke switch_gen into four pieces. The three optimized switch methods are
now in dense_switch, string_switch and tag_switch, with the original if-then-else implementation and the code that decides on optimizations still in switch_gen. Added options to replace the magic numbers governing the choice of switch method. Added comments to frameopt, jumpopt, labelopt and peephole. |