mirror of
https://github.com/Mercury-Language/mercury.git
synced 2025-12-16 22:35:41 +00:00
4954da84ccce720c50f99265556138d2eadca87f
109 Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
4954da84cc |
Reduce the dependence of the MLDS backend on the LLDS backend by moving
Estimated hours taken: 2 Branches: main Reduce the dependence of the MLDS backend on the LLDS backend by moving functionality dealing with proc_labels from the LLDS backend (code_util.m) to a new module, proc_label.m, which is part of backend_libs. compiler/code_util.m: compiler/proc_label.m: Move a type and some code from code_util to the new module. Convert predicates to functions as relevant. (The old code was written before functions were available). compiler/backend_libs.m: Add proc_label to the list of submodules. compiler/rtti.m: Rename a function to avoid a name clash with a function in proc_label.m. compiler/*.m: Conform to the changes above. Ensure that all imports of modules in the compiler directory are on lines of their own, to make CVS merges easier. Sort the imports. |
||
|
|
9aeb2516ec |
Avoid dependencies on ll_backend.code_util in *hlds.*.
Estimated hours taken: 1 Branches: main Avoid dependencies on ll_backend.code_util in *hlds.*. compiler/code_util.m: compiler/hlds_pred.m: Move the predicates to identify builtins into hlds_pred.m. compiler/*.m: Update calls and remove unnecessary imports. |
||
|
|
a8ffd3680c |
Change the compiler and tools so that .' and not :' is now used as the
Estimated hours taken: 14 Branches: main Change the compiler and tools so that `.' and not `:' is now used as the module separator in all output. Infix `.' now has associativity yfx and priority 10. NEWS: Report the change. configure.in: Amend the test for an up-to-date Mercury compiler to check whether it recognises `.' as a module qualifier. compiler/code_gen.m: compiler/error_util.m: compiler/hlds_out.m: compiler/prog_out.m: compiler/prog_util.m: compiler/rl_exprn.m: compiler/rl_gen.m: compiler/source_file_map.m: compiler/unused_args.m: library/io.m: library/rtti_implementation.m: library/type_desc.m: runtime/mercury_debug.c: runtime/mercury_deconstruct.c: runtime/mercury_stack_trace.c: Change `:' to `.' as module separator for output. compiler/mercury_to_mercury.m: compiler/prog_io_typeclass.m: As above. Fixed a bug where `.' was not being recognised as a module separator. doc/reference_manual.texi: Report the change. library/term_io.m: Ensure that infix `.' is written without surrounding spaces. tests/hard_coded/dot_separator.m: tests/hard_coded/dot_separator.exp: tests/hard_coded/Mmakefile: Test case added. |
||
|
|
2bef47ce85 |
Extend the information we record about procedures when debugging is enabled
Estimated hours taken: 20
Branches: main (for now, after more testing, on release branch too)
Extend the information we record about procedures when debugging is enabled
to include information about the tabling transformation, if the procedure
in question is tabled. This is useful to developers in debugging the tabling
mechanism, and can be useful to general users by helping them understand the
space (and hence time) costs of tabling.
Add a new mdb command "table" that uses this information to print
programmer-selected subsets of the tables of a tabled procedure.
compiler/hlds_pred.m:
Generalize the existing field in procedures that used to hold
information about I/O tabling to contain information about tabling
in general, including forms other than I/O tabling.
compiler/continuation_info.m:
compiler/code_gen.m:
compiler/stack_layout.m:
Conform to the changes in hlds_pred.m.
compiler/layout.m:
Provide Mercury parallels for the new data structures in
mercury_stack_layout.h.
compiler/layout_out.m:
Generate the new data structures in mercury_stack_layout.h.
compiler/table_gen.m:
Generate the new data structures in hlds_pred.m.
compiler/llds_common.m:
compiler/opt_debug.m:
Conform to the changes in layout.m
compiler/llds_out.m:
Abstract out existing code into a new procedure to make it available
to layout_out.m.
Make tabling pointer variables their natural type.
compiler/modules.m:
Fix an old bug: implicitly import table_builtin.m in .mm grades.
doc/mdb_categories:
doc/user_guide.texi:
Document the new mdb command "table".
runtime/mercury_types.h:
Move some type definitions here from mercury_tabling.h and
mercury_stack_layout.h. This was necessary to avoid problems with
circular #includes, in which a.h #includes b.h to get access to a
definition, but b.h #includes a.h, which is prevented by the macro
guarding against duplicate definition, which causes syntax errors
in the rest of b.h because the rest of b.h depends on typedefs in
a.h that occur in a.h *after* the #include of b.h.
runtime/mercury_label.h:
Adjust the list of #includes after the change to mercury_types.h.
runtime/mercury_stack_layout.h:
Extend the debugging data structures with constructs that describe
the call tables, answer tables and answer blocks of tabled procedures.
Delete typedefs that are now in mercury_types.h.
runtime/mercury_tabling.[ch]:
Add new functions to allow lookups without insertions in hash tables
containing ints, floats and strings.
Add new functions to return the entire contents of these hash tables.
Change to four-space indentation where this wasn't done previously.
runtime/mercury_grade.h:
Increment the binary compatbility version number, partially to
account for the change to mercury_stack_layout.h in this diff, but
mostly to account for all the other diffs to mercury_stack_layout.h
since the last released version.
trace/mercury_trace_tables.[ch]:
Rename MR_print_proc_id_for_debugger as MR_print_proc_id_and_nl,
since this better describes what the function does.
trace/mercury_trace_util.[ch]:
Add a new function MR_trace_is_integer that reads in signed integers.
Rename MR_trace_is_number as MR_trace_is_natural_number, since the
former would now be ambiguous.
Add a new function MR_trace_is_float that reads in floating point
values.
library/string.m:
Document that MR_trace_is_float uses the same logic as
MR_trace_is_float.
trace/mercury_trace_browse.c:
trace/mercury_trace_vars.c:
Update calls to MR_trace_is_number.
trace/mercury_trace_internal.c:
Implement the new mdb command "table".
Update calls to MR_trace_is_number and to
MR_print_proc_id_for_debugger.
tests/debugger/print_table.{m,inp,exp}:
New test case to test the new mdb command.
tests/debugger/Mmakefile:
Enable the new test case.
Disable the sensitive test cases in .mm grades.
tests/debugger/completion.exp:
Update the expected output to include the new mdb command.
tests/debugger/mdb_command_test.inp:
Update this automatically generated file to include the new mdb
command.
|
||
|
|
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. |
||
|
|
d531fc48d5 |
Fix a bug that prevented the tools/extract_incr_sp script from working.
Estimated hours taken: 0.1 Branches: main Fix a bug that prevented the tools/extract_incr_sp script from working. compiler/code_gen.m: Add a missing space in the comments attached to incr_sp operations. library/builtin.m: Add a missing pred/func indication to the comment of an incr_sp operation. |
||
|
|
ed83fe4623 |
Optimize shallow traced modules by not adding calls to MR_trace to shallow
Estimated hours taken: 12
Branches: main
Optimize shallow traced modules by not adding calls to MR_trace to shallow
traced procedures which cannot be called from a deep traced environment.
A shallow traced procedure can be optimized in this way if it is neither
exported from its defining module nor has its address taken.
The main purpose of this optimization is not the avoidance of the cost of the
MR_trace calls as much as it is the restoration of tail recursion optimization.
Previously, compiling a program in a debug grade would disable all tail
recursion in the program (since debug grades require at least shallow tracing
every module). This was a problem because it limited the sizes of the inputs
the debugged program could process before running out of memory. As long as
the procedures that recurse on the input are in the implementation section
of a shallow traced module, this should no longer happen.
compiler/trace_params.m:
Introduce the concept of a procedure's effective trace level. This is
identical to the global trace level, except if the procedure is not
exported and doesn't have its address taken, and the global trace level
is shallow. In that case, we say that the procedure's effective trace
level is none.
Computing a procedure's effective trace level requires its proc_info
and its parent pred_info, so require callers to supply these as
parameters.
compiler/code_info.m:
Store the current pred_info as well as the current proc_info, for
trace parameter lookups.
compiler/continuation_info.m:
compiler/code_gen.m:
Record the required trace parameters of a procedure in its layout
structure, since it can no longer be computed from the global trace
level.
compiler/stack_layout.m:
Use the trace parameters in procedures' layout structures, instead of
trying to compute them from the global trace level.
compiler/inlining.m:
compiler/liveness.m:
compiler/stack_alloc.m:
compiler/store_alloc.m:
compiler/trace.m:
Use procedures' effective trace level instead of the global trace level
where relevant.
compiler/llds.m:
Record the required trace parameter of a procedure in its c_procedure
representation, since it can no longer be computed from the global
trace level.
Delete an obsolete field.
compiler/optimize.m:
compiler/jumpopt.m:
Use a required trace parameter of a procedure in its c_procedure
representation, since it can no longer be computed from the global
trace level.
compiler/compile_target_code.m:
compiler/handle_options.m:
compiler/llds_out.m:
compiler/mercury_compile.m:
Trivial changes to conform to updated interfaces.
compiler/stack_opt.m:
Use the option opt_no_return_calls, instead of approximating it
with the trace level. (The old code was a holdover from before the
creation of the option.)
tests/debugger/shallow.m:
tests/debugger/shallow2.m:
tests/debugger/shallow.{inp,exp*}:
Divide the old test case in shallow.m in two. The top level predicates
stay in shallow.m and continue to be shallow traced. The two bottom
predicates move to shallow2.m and are now deep traced.
The new test input checks whether the debugger can walk across the
stack frames of procedures in shallow traced modules whose effective
trace level is "none" (such as queen/2).
|
||
|
|
d6fbaa2161 |
Add two pieces of information that will be needed to an upcoming change
Estimated hours taken: 2 Branches: main Add two pieces of information that will be needed to an upcoming change to the representation of procedure bodies in the declarative debugger. The first piece is the full list of head vars. This is needed now because the debugger no longer ignores variables of type type_info, and thus the Nth headvar is no longer guaranteed to be variable number N. The second piece is a cut/no_cut indicator in `some' goals. This is needed to allow us to reconstruct goal paths exactly as we traverse goal representations. browser/program_representation.m: Make the two data structure changes described above. browser/*.m: Trivial changes to conform to the new data structures. compiler/prog_rep.m: Create the updated data procedure representation. compiler/*.m: Record and transmit the information needed by the updated procedure representation. runtime/mercury_stack_layout.h: Update the documentation of the relevant field in proc_layouts. |
||
|
|
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. |
||
|
|
13f0e7610a |
A large step towards declarative debugging of goals that do I/O.
Estimated hours taken: 40
Branches: main
A large step towards declarative debugging of goals that do I/O. This step
does everything needed for that except modify the declarative debugger itself;
that is for Mark to do.
If you give the new option --trace-table-io-decl, the transformation performed
by the compiler on I/O primitives will preserve not just the output arguments
of the primitive, so that the primitive can be "reexecuted" without performing
any side-effects, but also the input arguments and the identity of the I/O
primitive itself. The I/O table therefore will contain a list of the I/O
primitives executed by the program after I/O tabling is started.
You can test this via the new debugger commands "print action <action-number>"
and "browse action <action-number>".
The new option is currently not documented, because the declarative debugger
does not yet use the information it provides. The new debugger commands are
not documented because they are meant only for implementors, at least for
now.
Since this change adds a field to proc_layout structures, any workspaces
compiled with debugging enabled will need to do a cvs update when this change
is installed.
compiler/options.m:
Add the option --trace-table-io-decl. When set, this causes the
compiler to transform I/O action primitives to allow declarative
debugging of I/O actions.
compiler/handle_options.m:
Make --trace-table-io-decl imply --trace-table-io.
compiler/table_gen.m:
Perform the transformation, which is similar to the existing
--trace-table-io transformation, but preserves the identity of all
non-io-state arguments (not just the outputs) and the identity
of the I/O primitive itself.
Provide better names for variables generated by tabling
transformations.
compiler/hlds_goal.m:
Add extra parameters to procedures whose job it is to create new
goals to name the variables in those goals.
compiler/layout.m:
Add a new layout structure to contain the information the runtime
system needs to interpret the information saved by the new
transformation.
compiler/layout_out.m:
Output the new layout structure.
compiler/continuation_info.m:
Add a field to proc_layouts to point to the declarative I/O tabling
structure, and another to identify the proc_layout without using LLDS
types.
compiler/code_gen.m:
Provide the definition of this field when appropriate.
compiler/hlds_pred.m:
Add a field to proc_infos to store the information from the tabling
transformation until code generation.
compiler/stack_layout.m:
Add a mechanism for transforming the high level description of I/O
action tabling data in proc_infos to the low level description we need
to generate C data structures.
compiler/hlds_data.m:
Add a new cons_id and a new cons_tag; they are used to refer to I/O
tabling structures in code generated by the new transformation.
compiler/*.m:
Handle the updates to global data types above.
library/table_builtin.m:
Modernize some old code.
Fix an old off-by-one error: make I/O tabling use the first slot
in the I/O action table.
library/varset.m:
Add a mechanism for creating a variable that is named iff the caller
has a name for it.
runtime/mercury_layout_util.[ch]:
Add a function for materializing type parameters from an answer block,
not from registers or a closure.
runtime/mercury_stack_layout.h:
Declare a C type for the data structure holding information about
I/O primitives transformed by --trace-table-io-decl, and add a field
to proc_layout structures to point to these new structures.
Add a new evaluation method for --trace-table-io-decl.
runtime/mercury_tabling_macros.h:
Add some conditionally-compiled debugging code to the primitive for
saving answers.
trace/mercury_trace_vars.[ch]:
Add functions for printing I/O action goals.
trace/mercury_trace_internal.c:
Add code for recognizing and implementing commands to print I/O
action goals.
trace/mercury_trace.c:
Add code for handling the new eval method.
tests/debugger/tabled_read.{m,inp,exp*}:
Add a polymorphic I/O action primitive, add calls to it, and test
the printing of both monomorphic and polymorphic action goals.
tests/debugger/tabled_read_decl.{m,inp,exp*,data}:
A new test case. It does the same things as the new version of
tabled_read, but it is compiled with --trace-table-io-decl, not
just --trace-table-io. It therefore can (and does) test the printing
of tabled I/O actions.
tests/debugger/Mmakefile:
Add the new test case.
|
||
|
|
b7c4a317e9 |
Add MR_ prefixes to the remaining non-prefixed symbols.
Estimated hours taken: 4 Branches: main Add MR_ prefixes to the remaining non-prefixed symbols. This change will require all workspaces to be updated The compiler will start generating references to MR_TRUE, MR_bool, etc., which are not defined in the old runtime header files. runtime/mercury_std.h: Add MR_ prefixes to bool, TRUE, FALSE, max, min, streq, strdiff, strtest, strntest, strneq, strndiff, strntest, NO_RETURN. Delete a commented out definition of `reg'. runtime/mercury_tags.h: Add an MR_ prefix to TAGBITS. configure.in: runtime/mercury_goto.h: runtime/machdeps/i386_regs.h/mercury_goto.h: Add an MR_ prefix to PIC. runtime/mercury_conf_param.h: Allow non-prefixed PIC and HIGHTAGS to be defined on the command line. runtime/mercury_bootstrap.h: Add backwards compatibility definitions. RESERVED_MACRO_NAMES: Remove the renamed macros. compiler/export.m: compiler/ml_code_gen.m: Use MR_bool rather than MR_Bool (MR_Bool is meant to be for references to the Mercury type bool__bool). runtime/mercury_types.h: Add a comment the MR_Bool is for references to bool__bool. */*.c: */*.h: */*.m: Add MR_ prefixes. |
||
|
|
9c58f97e3b |
Add a new optimization, --use-local-vars, to the LLDS backend.
Estimated hours taken: 20 Branches: main Add a new optimization, --use-local-vars, to the LLDS backend. This optimization is intended to replace references to fake registers and stack slots with references to temporary variables in C code, since accessing these should be cheaper. With this optimization and one for delaying construction unifications, the eager code generator should generate code at least good as that produced by the old value numbering pass. This should make it possible to get rid of value numbering, which is much harder to maintain. compiler/use_local_vars.m: New module containing the optimization. compiler/notes/compiler_design.html: Mention the new module. compiler/exprn_aux.m: Add new utility predicates for use by use_local_vars. If --debug-opt is specified, do not dump instruction sequences to standard output. Instead, put them in separate files, where they can be compared more easily. compiler/options.m: Add the --use-local-vars option to control whether the use_local_vars pass gets run. compiler/llds.m: Add liveness information to the c_code and pragma_foreign_code LLDS instructions, in order to allow use_local_vars to work in the presence of automatically-generated C code (e.g. by debugging). compiler/livemap.m: Use the new liveness information to generate useful livemap information even in the presence of automatically generated C code. compiler/code_gen.m: compiler/code_info.m: compiler/dupelim.m: compiler/frameopt.m: compiler/llds_common.m: compiler/llds_out.m: compiler/middle_rec.m: compiler/opt_debug.m: compiler/opt_util.m: compiler/pragma_c_gen.m: compiler/trace.m: compiler/vn_block.m: compiler/vn_cost.m: compiler/vn_filter.m: compiler/vn_verify.m: Provide and/or ignore this additional liveness information. compiler/wrap_block.m: The post_value_number pass wraps LLDS instruction sequences using temporaries in a block instruction which actually declares those temporaries. It used to be used only by value numbering; it is now also used by use_local_vars. It has therefore been renamed and put in its own file. compiler/optimize.m: Invoke use_local_vars if required, and call wrap_blocks instead of post_value_number. compiler/value_number.m: Since the value numbering pass still cannot handle automatically generated C code, check for it explicitly now that livemap carries out only a weaker check. compiler/basic_block.m: Add a module qualification. library/set.m: library/set_bbbtree.m: library/set_ordlist.m: library/set_unordlist.m: Add a new predicate, union_list, to each implementation of sets, for use by some of the new code above. tests/general/array_test.m: Print out the result of each operation as soon as it is done, so that if you get a seg fault, you know which operations have completed and which haven't. |
||
|
|
1c65d003f7 |
Add the shorthand_goal_expr wrapper type to ease hlds->hlds transformations.
Estimated hours taken: 4.5
Branches: main
Add the shorthand_goal_expr wrapper type to ease hlds->hlds transformations.
compiler/hlds_goal.m
Create a new type, the `shorthand_goal_expr', for goals kinds that
are implemented by a (ordinary_hlds + shorthand) -> (ordinary_hlds)
transformation. At present, bi_implication is the only kind of
of goal that is implemented in this way.
Moved bi_implication functor from the type goal_expr to the new
shorthand_goal_expr type.
Added the functor shorthand to the goal_expr type.
compiler/*.m
Change switches on hlds_goal_expr that call error when they recognise
`bi_implication' from calling error when they recognise
`bi_implication' to calling error when they recognise `shorthand'.
For all predicates K that
a) switch on hlds_goal_expr and
b) perform non-trivial processing when they recognise
`bi_implication'
change K such that it now calls K_shorthand upon recognising the
functor `shorthand'. Define K_shorthand to switch on
shorthand_goal_expr, where the code for the `bi_implication' case
formerly contained in K is now contained in K_shorthand.
|
||
|
|
711da78188 |
Rename foreign_code as foreign_proc where appropriate in the compiler.
Estimated hours taken: 4.0 Branches: main Rename foreign_code as foreign_proc where appropriate in the compiler. The rationale for this change is that it makes maintaining the code much simpler because it is clear whether `foreign' refers to a slab of code (foreign_code) or a procedure (foreign_proc). :- type pragma_foreign_code_attributes :- type pragma_foreign_proc_attributes The functors for pragma_type foreign(Lang, BodyCode) foreign(Attributes, Name, PredOrFunc, Vars, Varset, Impl) become foreign_code(Lang, BodyCode) foreign_proc(Attributes, Name, PredOrFunc, Vars, Varset, Impl) And the HLDS goal `pragma_foreign_code' becomes `foreign_proc'. compiler/*.m: Update the compiler to use the new names. |
||
|
|
0921310ca5 |
More work on the bytecode interpreter.
With these changes, it now passes all tests/general/* test cases
except those with floats.
Changes to the compiler:
- Added extra argument to test instruction (string comparisons were
being treated as integer comparisons; properly deals with different
atomic type unifications now)
- Changed bytecode stub functions
Changes to the bytecode interpreter:
- Cleaned up comments
- Forked part of mb_machine to mb_exec
- Added support for submodules
- Added support for nondet procedures
- Added support for cc_xxx procedures
- Finished higher order calls
- Added (very basic) debug interface
- Added support for type information
- Added memory corruption checking
- Changed machine state dump formatting
- Fixed bug in nested switches
- Resolved builtin__unify and builtin_compare failures
- Modified bytecode tags generation so .c & .m tag files are separate
- Header usage rationalised
Changes to test suite:
- Added test cases for the bytecode interpreter.
- More work on the bytecode interpreter.
bytecode/Mmakefile:
Modified bytecode tags generation so .c & .m tag files are separate.
mb_machine split into mb_exec.
test file renamed to simple.m (copy over tests/simple??.m to test).
bytecode/TODO:
Updated.
bytecode/mb_basetypes.h:
Removed redundant MB_WORD_BITS (use MR_WORDBITS instead).
bytecode/mb_bytecode.h:
bytecode/mpb_bytecode.c:
Formatting changes
Third test instruction argument added.
bytecode/mb_disasm.h:
bytecode/mb_disasm.c:
Formatting changes.
Third test instruction argument added.
Added MB_FMT_INTWIDE.
bytecode/mb_exec.h:
bytecode/mb_exec.c:
bytecode/mb_machine.h:
bytecode/mb_machine.c:
mb_machine* split into mb_exec* and mb_machine*.
Almost all instructions now work (see important changes above).
bytecode/mb_interface.h:
bytecode/mb_interface.c:
Added nondet stub functions.
Added functions to lookup builtin compiler procedures:
do_redo, do_fail, __unify, __compare.
Removed old debugging code.
Stack layout changed to support nondet procedures.
bytecode/mb_interface_stub.c:
bytecode/mb_interface_stub.h:
Split off bare minimum of includes for bytecode stubs.
Added nondet stubs.
bytecode/mb_machine_show.c:
Made code cleaner (added subfunctions for MB_show_state).
Added variable names to machine state dump.
bytecode/mb_mem.h:
bytecode/mb_mem.c:
Added limited memory corruption checking.
bytecode/mb_module.h:
bytecode/mb_module.c:
Swapped order of temps & vars on stack.
Fixed nested switches causing random crashes.
Added nested module support.
bytecode/test/simple??.m:
Various test files - just to check that it doesn't crash.
(Most do not output anything & must be verified by stepping through
manually).
compiler/bytecode.m:
compiler/bytecode_gen.m:
Added extra argument to test instruction (otherwise
string comparisons would be treated as integer comparisons).
compiler/code_gen.m:
Changed call structure name in bytecode stub to resolve
issues with illegal characters in C structure names.
Changed bytecode stub header file name.
|
||
|
|
cfd7bd279a |
Changed code generator to output bytecode stubs as needed
Estimated hours taken: 4
Changed code generator to output bytecode stubs as needed
Will not output stubs for compiler generated procedures
or for procedures with foreign code
bytecode/code_gen.m:
Changed code generator to output bytecode call stub if
procedure contains no foreign code and procedure was
not automatically generated by the compiler
bytecode/hlds_util.m:
Added predicates to determine if a goal tree contains
any foreign code.
bytecode/llds_out.m:
Added a #include to modules generating bytecode
|
||
|
|
2498d9d3fd |
Instead of generating the layout structures of labels, procs and modules
Estimated hours taken: 36 Instead of generating the layout structures of labels, procs and modules as rvals, generate them almost entirely as C structures. This will make future modifications much easier, since mismatches between what the runtime expects and what the compiler generates will now be pointed out by the C compiler. (It also reduces the size of the C source files generated with debugging enabled by about 5%.) Layout structures contain a few components that are not well-typed in C; we continue to generate these as rvals. Closure layout structures used to have a well-typed part and a non-well-typed part. We now generate the well-typed part as a separate structure, pointed to from the other. We also extend the well-typed part, so that instead of just giving the name the called procedure, it also identifies the source location where the closure was constructed. This could be useful for the debugger and for deep profiling. This diff also includes a change to get the compiler to bootstrap with lcc in grade none.gc.debug.tr: initializing the string tables in module layouts not as a string but as an array of characters. runtime/mercury_stack_layout.h: Reorganize the definitions of layout structures. Rename Stack_Layout_Entry structures as Proc_Layout structures, and Stack_Layout_Label structures as Label_Layout structures. (The debugger paper refers to the structures by the new names.) Fold the Stack_Layout_Vars structure into the structure that contains it, the Label_Layout structure. Add a Closure_Id structure that contains a Proc_Id structure as well as extra information identifying the source location where the closure was created. Create "short" versions of the Proc_Layout structures, which contain only the first one or two of the three groups of fields. Previously, the Mercury compiler would define new C types when it generated such short structures. Since we are not defining new C types anymore, there must be a C type for every kind of structure the Mercury compiler can generate. We now also have separate variants for the layouts of user-defined and compiler-generated procedures, since the format of their procedure id information is different. While the runtime system refers to their procedure id information through a union, the C types of the structures generated by the Mercury compiler do not use a union, since a union cannot be initialized through its second member. Make the constant fields of structures const, since we now generate values of those structure types, and initialize them with constant data. Move the documentation of layout structures here from stack_layout.m. runtime/mercury_ho_call.h: Instead of bodily including an MR_Proc_Id structure in closures, include a pointer to the more detailed MR_Closure_Id structure. runtime/mercury_accurate_gc.c: runtime/mercury_agc_debug.c: runtime/mercury_init.h: runtime/mercury_label.[ch]: runtime/mercury_layout_util.[ch]: Minor updates to conform to changes in mercury_stack_layout.h. runtime/mercury_goto.h: Use separate naming schemes for label layout structures and proc layout structures. library/exception.m: Minor updates to conform to changes in mercury_stack_layout.h. compiler/layout.m: A new module that defines data structures for label, proc and module layout structures and for closure id structures. compiler/layout_out.m: A new module that converts the Mercury data structures of layout.m into declarations and definitions of C data structures. compiler/stack_layout.m: Generate the new layout structures instead of rvals. Move the documentation of layout structures from here to runtime/mercury_stack_layout.h, since this module is no longer aware of some of their details. compiler/llds.m: Make layout structures a separate kind of compiler-generated data. compiler/llds_out.m: Remove the code for the output of layout structures; call layout_out.m instead. compiler/llds_out.m: compiler/rtti_out.m: Turn some predicates into functions. compiler/code_gen.m: compiler/code_info.m: compiler/llds.m: compiler/mercury_compile.m: compiler/unify_gen.m: Instead of handling closure layouts like other static data, handle them separately. Add a counter to the code_info structure in order to allow closure id structures to be identified uniquely by a pair consisting of the id of the procedure that generates them and a closure sequence number within that procedure. compiler/llds_common.m: Look for common rvals among the rvals in layout structures. compiler/opt_debug.m: Generate developer-friendly names for layout structure references. browser/dl.m: Update the code for constructing closure layouts. |
||
|
|
8ba2487901 |
Fix a bug in my previous change: it was generating duplicate label names.
Estimated hours taken: 0.5 compiler/code_gen.m: Fix a bug in my previous change: it was generating duplicate label names. |
||
|
|
b782090418 |
Fix a bug reported by Warwick Harvey: the code that we
Estimated hours taken: 2 compiler/code_gen.m: Fix a bug reported by Warwick Harvey: the code that we generated for procedures compiled with `--trace shallow' was allocating ticket counters conditionally (iff MR_trace_from_full was true on entry), but was deallocating them unconditionally. The fix was to only deallocate them if they were allocated. |
||
|
|
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'. |
||
|
|
477ecb18f6 |
Implement pragma foreign_code for Managed C++.
Estimated hours taken: 60 Implement pragma foreign_code for Managed C++. Currently you can only write MC++ code if your backend is capable of generating use MC++ as its "native" foreign language. The IL backend is the only backend that does this at the moment (the other backends have C as their "native" foreign language). Most of the machinery is in place to call from C to (normal) C++ but there is little work done on actually spitting out the C++ code into a separate file. The IL backend does this step already with managed C++. The intention is to turn foreign_code for C++ into a pragma import (which imports the C++ function from a separate file) and foreign_code for C (which calls the imported function). The C++ code will be inserted into a separate file that is compiled using C linkage. The important improvement this change gives is that you can write a module with a C and a MC++ implementations side-by-side. The target backend will select the most appropriate foreign language to use. You can override its choice using --use-foreign-language. Later on we will probably want more flexibility than just a single language selection option). This change also implements :- pragma foreign_decl, which allows header file style declarations to be written in languages other than C. compiler/code_gen.m: Reject code that is not C when generating LLDS. compiler/export.m: Start renaming C as foreign. Reject code that is not C when generating exports. compiler/foreign.m: A new module to handle foreign language interfacing. The bulk of the code for pragma import has been moved here from make_hlds. compiler/globals.m: Convert foreign language names to foreign_language. This code has been moved closer to the similar conversion we do for target language names. Add globals__io_lookup_foreign_language_option to make it easier to deterministically lookup the options relating to foreign languages. compiler/hlds_module.m: Move module_add_foreign_decl and module_add_foreign_body_code from make_hlds.m (where they were called module_add_c_header and module_add_c_code). compiler/hlds_out.m: Write the foreign language out in HLDS dumps. compiler/llds.m: Change foreign_header_info to foreign_decl_info. Change definitions of foreign_decl_code and foreign_body_code to include the language. compiler/llds_out.m: Reject code that is not C when writing out LLDS. compiler/make_hlds.m: Add foreign language information to the bodys and decls when creating them. Update error messages to refer to foreign code instead of C code. Use foreign.m to generate interfaces from the backend language to the foreign language. Hardcode C as the language for fact tables. compiler/mercury_compile.m: Collect the appropriate foreign language code together for output to the backend. compiler/intermod.m: compiler/mercury_to_mercury.m: Output the foreign language string. Change a few names to foreign_code instead of c_code. compiler/ml_code_gen.m: Filter the foreign language bodys and decls so that we only get the ones we are in (given by the use-foreign-language option). compiler/mlds_to_c.m: Abort if we are given non C foreign language code to output (we might handle it here in future, or we might handle it elsewhere). compiler/mlds_to_ilasm.m: Abort if we are given non MC++ foreign language code to output (we might handle it here in future, or we might handle it elsewhere). compiler/options.m: compiler/handle_options.m: Add --use-foreign-language as a user option to control the preferred foreign language to use as the implementation of this module. Add backend_foreign_language as an internal option which stores the foreign language that the compiler will use as a default (e.g. the natural foreign language for the backend to use). Set the preferred backend foreign language depending on the target. compiler/prog_data.m: Add managedcplusplus as a new alternative for the foreign_language type. Make c_header_code into foreign_decl. Give the foreign language for foreign_code as an attribute of the code. Write code to turn attributes into a list of strings (suitable for writing out by mercury_to_mercury). This fixes what appears to be a bug in tabled_for_io -- the tabled_for_io attribute was not being written out. Structure the code so this bug is difficult to repeat in future. compiler/prog_io_pragma.m: Parse foreign_decl. Turn c_header_code into a special case of foreign_decl. compiler/*.m: Remove the language field from pragma_foreign_code, it is now an attribute of the code. Various type and variable renamings. tests/invalid/pragma_c_code_and_clauses1.err_exp: tests/invalid/pragma_c_code_dup_var.err_exp: tests/warnings/singleton_test.exp: Update the tests to reflect the new error messages talking about :- pragma foreign_code rather than :- pragma c_code. |
||
|
|
82378c381b |
Allow polymorphic ground insts. This change assumes that all inst
Estimated hours taken: 80 Allow polymorphic ground insts. This change assumes that all inst parameters in the mode declaration for a predicate or function are constrained to be ground-shared. This is a temporary measure until we work out a nice syntax to allow the programmer to tell the compiler that certain inst parameters may be treated as ground insts. Since we don't currently support unconstrained inst parameters anyway, this shouldn't cause a problem. TODO: - Add syntax, something like `:- mode p(in(I)) <= ground(I).', to specify that an inst parameter represents a ground inst. - Allow abstract ground insts that are treated in a similar way to what we've done here with ground inst parameters. - Make mode checking more efficient (i.e. rewrite the mode system). compiler/inst.m: Add a new alternative for ground insts: `constrained_inst_var(inst_var)'. Define the type `inst_var_sub'. compiler/inst_match.m: Change inst_matches_initial so that it: - handles constrained_inst_vars correctly; - returns the inst_var substitutions necessary for the call; - handles inst_matches_initial(ground(...), bound(...), ...) properly (this requires knowing the type of the variable). The last change has also been made for inst_matches_final and inst_matches_binding. However, the check is disabled for now because, without alias tracking, the mode checker becomes too conservative. compiler/hlds_pred.m: compiler/mode_info.m: compiler/simplify.m: compiler/det_util.m: Include the inst_varset in the proc_info, mode_info and simplify_info. Add a vartypes field to the det_info. Remove the vartypes field from the simplify_info since it is now in the det_info. Use record syntax for these data structures and their access predicates to make future changes easier. compiler/prog_io.m: When processing pred and func mode declarations, convert all inst_var(V) insts to ground(shared, constrained_inst_var(V)). compiler/prog_data.m: compiler/hlds_data.m: compiler/make_hlds.m: compiler/mode_util.m: Use inst_vars instead of inst_params. compiler/modes.m: compiler/modecheck_call.m: compiler/unique_modes.m: compiler/mode_util.m: When checking or recomputing initial insts of a call, build up an inst_var substitution (using the modified inst_matches_initial) and apply this to the final insts of the called procedure before checking/recomputing them. compiler/mode_util.m: Make sure that recompute_instmap_delta recomputes the instmap_deltas for lambda_goals even when RecomputeAtomic = no. compiler/type_util.m: Add a new predicate, type_util__cons_id_arg_types which nondeterministically returns the cons_ids and argument types for a given type. Add a new predicate type_util__get_consid_non_existential_arg_types which is the same as type_util__get_existential_arg_types except that it fails rather than aborting for existenially typed arguments. compiler/accumulator.m: compiler/check_typeclass.m: compiler/clause_to_proc.m: compiler/common.m: compiler/continuation_info.m: compiler/deforest.m: compiler/det_analysis.m: compiler/det_report.m: compiler/det_util.m: compiler/dnf.m: compiler/follow_code.m: compiler/goal_store.m: compiler/goal_util.m: compiler/higher_order.m: compiler/inst_util.m: compiler/instmap.m: compiler/lambda.m: compiler/magic.m: compiler/magic_util.m: compiler/mercury_to_mercury.m: compiler/modecheck_unify.m: compiler/module_qual.m: compiler/pd_info.m: compiler/pd_util.m: compiler/polymorphism.m: compiler/post_typecheck.m: compiler/prog_io_util.m: compiler/prog_rep.m: compiler/saved_vars.m: compiler/stack_layout.m: compiler/table_gen.m: compiler/unify_proc.m: compiler/unneeded_code.m: compiler/unused_args.m: Pass inst_varsets and types where needed. Changes to reflect change in definition of the inst data type. compiler/inlining.m: Recompute the instmap deltas for a procedure after inlining. This bug showed up compiling tests/hard_coded/lp.m with inlining and deforestation turned on: deforestation was getting incorrect instmap deltas from inlining, causing the transformation to break mode-correctness. It has only just shown up because of the added call to `inst_matches_initial' from within `recompute_instmap_delta'. tests/invalid/Mmakefile: tests/invalid/unbound_inst_var.m: tests/invalid/unbound_inst_var.err_exp: tests/valid/Mmakefile: tests/valid/unbound_inst_var.m: Move the `unbound_inst_var' test case from `invalid' to `valid' and extend its coverage a bit. |
||
|
|
fdccd65e30 |
The debugger's retry command at the moment works only from a final port for
Estimated hours taken: 60
The debugger's retry command at the moment works only from a final port for
the call to be retried, the reason being that the RTTI does not have the
information required to make sure that the state of the stacks is reset
correctly. If you invoke retry from a non-final port, the current
implementation skips forward to a final port and then does the retry;
this does not work if you get a core dump or a infinite loop during the forward
skip. This change adds the required info to the RTTI and thus enables
direct retries from the middle of calls.
The information added has two components. First, if a procedure that lives on
the nondet stack allocates any temporary nondet stack frames, then it must
record the old value of maxfr in a stack slot so that retry can restore it.
Second, if a procedure is tabled, then it must record the call table tip node
corresponding to the actual input arguments, so we can reset this node to
uninitialized (if we don't, then the retried call will find the active call
marker and report an infinite loop error).
The support for retries across minimal model calls is not finished yet.
Finding out what the right thing to do in such cases is a research project,
one that cannot even be started until minimal model tabling works reliably
in the *absence* of retries. However, such retries do grossly wrong things
at the moment; this change is a definite improvement. It attempts to perform
the retry from the fail port, since that is the only time when the minimal
model tabling data structures are quiescent. The "fail" command I added to
the debugger command set to let this be done is not complete yet and is
therefore undocumented; the problem is that a call to a model_non predicate
in a committed choice context will not get to the fail port. I added goal paths
to return layouts so that we will eventually be able to tell when execution
leaves a committed choice context surrounding an ancestor of a model_non
predicate call, but this functionality is not yet implemented.
compiler/stack_layout.m:
Generate the three new fields: the evaluation method, (maybe) the id
of the stack slot containing the saved value of maxfr, and (maybe)
the id of the stack slot containing the call table tip.
compiler/continuation_info.m:
Record the information about the new fields for later use by
stack_layout.m.
Add a new field to record the goal path of calls for their return
layouts.
Fix a screwed comment for the continuation_info data structure.
compiler/llds.m:
Add a new field to call() instructions to hold the goal path of the
call.
Add a utility function for use by trace.m.
compiler/call_gen.m:
Fill in this new field.
compiler/trace.m:
compiler/live_vars.m:
Reserve the fixed stack slot for the saved maxfr if necessary,
and if the call table tip node is needed, make sure that the variable
holding its address is allocated a low-numbered stack slot (otherwise,
its number may not fit into the MR_int_least8_t field in the
proc_layout).
compiler/trace.m:
If necessary, fill in the saved maxfr slot.
If necessary, initialize the call table tip slot.
compiler/hlds_goal.m:
Add a goal feature which marks its goal as defining the variable
representing the call table tip node.
Add a field to the goal path step representing quantification;
the field says whether the quantification changes the determinism of
the goal (i.e. whether it cuts away solutions).
compiler/hlds_pred.m:
compiler/hlds_out.m:
Add two fields to proc_infos which (a) record which variable, if any,
holds the call table tip node, and (b) record whether the procedure's
layout structure needs to reserve a slot for the saved value of maxfr.
compiler/table_gen.m:
Put this feature on the appropriate goal.
Also, rename a predicate to make it reflect its purpose better.
compiler/code_gen.m:
Generate code to put the call table tip variable in its stack slot
immediately after it has been generated.
Add a sanity check to ensure that if a procedure that lives on the det
stack can create a temporary nondet frame, and debugging is enabled,
then it did have a stack slot reserved for the saved maxfr.
compiler/code_util.m:
Add a predicate to make a conservative prediction of whether a
procedure may allocate a temporary nondet stack frame. We cannot
just generate the code and see, because the code generator needs to
know which variables live in which stack slots, and we cannot decide
that until we know whether we need a stack slot for the saved value of
maxfr.
Make an unrelated predicate semidet procedure use a det helper, in
order to make it more robust in the face of changes to the HLDS
(e.g. it was missing code for handling bi_implications).
compiler/code_info.m:
Record whether a procedure has in fact created a temporary nondet stack
frame.
compiler/handle_options.m:
Disable hijacks if debugging is enabled. The code we now use to
restore the stacks for direct retries works only if the retry does not
"backtrack" over a hijacked nondet stack frame whose hijack has not
been undone. Note that code compiled without debugging may still hijack
nondet stack frames. Execution may reemerge from the nondebugged region
in one of two ways. If the nondebugged code returns, then it will have
undone hijack, and the retry code will work. If the nondebugged code
calls debugged code, there will be a region on the stacks containing
no debugging information, and the retry command will refuse to perform
retries that go into or beyond this region. Both cases preserve
correctness.
compiler/*.m:
Trivial changes to conform to changes in data structures.
runtime/mercury_stack_layout.h:
Add three new fields to proc layouts: the numbers of the stack slots
(if any) storing the saved maxfr and the call table tip, and a
representation of the procedure's evaluation method.
runtime/mercury_stack_trace.[ch]:
Now that return layouts contain goal paths, print them in stack dumps
only if the include_trace_data flag is set (in mdb, this requires the
-d flag of the "stack" command).
Pass this flag around directly, instead of encoding its value in
the NULL vs non-NULL values of sp and curfr.
runtime/mercury_regorder.h:
Provide a mechanism to access the values of the first few rN registers
from a save area, for use in debugging low-level C code in the runtime
and the trace directories.
trace/mercury_trace.[ch]:
Reimplement MR_trace_retry to allow retries from the middle.
If the stack segment being retried over contains minimal model
procedures, we must still arrange to skip to the end of the retried
call. If this call is a minimal model generator, skipping to just any
final port is not sufficient to guarantee correctness on retry; to
ensure that subgoal is complete, we must skip to a fail port.
trace/mercury_trace.[ch]:
trace/mercury_trace_internal.c:
Implement a debugger command, "fail", which skips to the fail port or
the exception port of the specified ancestor. Since procedures that are
not model_non are not guaranteed to get to such a port, this
command reports an error if the specified call is not model_non.
Actually, even calls to model_non procedures may not get to the fail
port, as explained above; this is why the command is not yet
documented.
trace/mercury_trace.c:
trace/mercury_trace_util.[ch]:
Move some functions to print parts of the Mercury abstract machine
state from mercury_trace to mercury_trace_util, so that they are
available for use in debugging e.g. mercury_trace_declarative.
trace/mercury_trace_internal.c:
trace/mercury_trace_external.c:
trace/mercury_trace_declarative.c:
Use the new implementation of retries. At the moment, only the
internal debugger implements the full functionality. The declarative
debugger issues retry commands only from situations where the missing
functionality is not (yet) needed. The external debugger should
continue to work correctly, but Erwan may wish to update it to
exploit the availability of the fail command.
trace/mercury_trace*.[ch]:
Fix MR_prefixes, and a signed/unsigned mismatch.
doc/user_guide.texi:
Document the new "fail" command, but comment it out for now.
tests/debugger/retry.{m,inp,exp,exp2}:
A new test case for exercising retry.
tests/debugger/Mmakefile:
Enable the new test case.
tests/debugger/*.exp:
Update the expected output, given the extra info now output e.g. for
exception events and detailed stack traces.
|
||
|
|
07d6517521 |
Implement a general mechanism for suppressing selected aspects of execution
Estimated hours taken: 8 Implement a general mechanism for suppressing selected aspects of execution tracing. compiler/trace_params.m: This new file contains two abstract data types that define the parameters of the execution tracing system, and the operations on them. The two ADTs are the trace level (moved from globals.m) and a new one, trace_suppress_items, which replaces --no-trace-internal, --no-trace-redo and --no-trace-return, and provides additional capabilities requested by Erwan. Basically any given port can now be suppressed, with the exception of call (because the call event's layout structure is needed for implementing redo from any other event) and excp (because they are created on the fly by exception.m, and are not put into object code in the first place). compiler/globals.m: Delete the stuff now migrated to trace_params.m. Make trace_suppress_items part of the globals structure. compiler/code_gen.m: compiler/trace.m: Allow the suppression of individual ports. compiler/stack_layout.m: Allow the suppression of parts of layout structures. compiler/*.m: Minor changes, mainly importing trace_params, to conform to the main modifications. compiler/options.m: Delete --no-trace-internal, --no-trace-redo and --no-trace-return. Add --suppress-trace, but do not document it, since it is really intended only for implementors. doc/user_guide.texi: Delete the documentation of --no-trace-internal, --no-trace-redo and --no-trace-return. Do not document it --suppress-trace, since it is really intended only for implementors. (The only reason why other three were documented is that most consumers of the users' guide then *were* implementors.) |
||
|
|
36fc174bed |
Make declarative debugging a trace level, not a separate option.
Estimated hours taken: 2 Make declarative debugging a trace level, not a separate option. compiler/globals.m: Make trace_level an abstract data type. Define and export several functions that check whether the current trace level requires particular kinds of treatment. compiler/options.m: Remove --trace-decl as an option. compiler/*.m: Instead of checking for particular values of the trace level, use the functions now exported by globals.m. tests/debugger/declarative/Mmakefile: Use the trace level to ask for declarative debugging. |
||
|
|
3ce3b14c84 |
Make procedure bodies available to the declarative debugger.
Estimated hours taken: 20 Make procedure bodies available to the declarative debugger. browser/program_representation.m: Add _rep suffixes to the function symbols, to make iit easier to distinguish HLDS goals and goal representations. compiler/static_layout.m: If --trace-decl is specified, include a representation of the procedure body in the procedure's layout structure. compiler/prog_rep.m: A new module, containing the code that converts goals from HLDS to a term in the format we want to put in the layout structure. compiler/static_term.m: A new module, containing the code that converts Mercury terms to the LLDS rval we need to give to llds_out.m. compiler/code_gen.m: compiler/continuation_info.m: Preserve the information needed by prog_rep compiler/Mmakefile: Extend the search path to the browser directory, since the new file prog_rep.m imports one of the submodules of mdb.m stored there. compiler/notes/compiler_desigm.html: Document the new modules. library/std_util.m: Add a mechanism for static_term.m to use in converting terms into rvals. This mechanism uses RTTI information to deconstruct terms, and return not only their arguments, but also information about how the term can be constructed from its arguments. runtime/mercury_type_info.h: Add a couple of macros to make construction and deconstruction of univs easier, for use in std_util.m. trace/mercury_trace_internal.c: Add a new command, "proc_body", that prints out the representation of the body of the current procedure. This is meant only for developers to use to check that the procedure body representation is OK; it is deliberately not documented. Also fix a bug: make sure that we do not pass a NULL pointer to fputs when echoing a line of input that isn't there (because we got EOF). |
||
|
|
c014e2a20b |
Store the offsets leading to the names of variables in a central location.
Estimated hours taken: 8 Store the offsets leading to the names of variables in a central location. Previously, each label layout included offsets for the variables live at that label; now we store the offsets of variables in the proc layout. The new data structure will soon be required by the declarative debugger for displaying contours through representations of HLDS goals. compiler/code_gen.m: Preserve the varset of every procedure for use by stack_layout.m. compiler/continuation_info.m: Add a field to the cell from which proc layouts are derived to hold the varset. compiler/stack_layout.m: Delete the offsets from label layouts and add them to proc layouts. The var name offsets array will always contain meaningful offsets for every variable that is live at a label with a label layout; with --trace-decl, it will also contain meaningful offsets for all the other variables in the procedure body. runtime/mercury_stack_layout.h: Reflect the change in the types of the label and proc layout structures. trace/mercury_trace.c: trace/mercury_trace_vars.c: Look up variable names using the new location of the offsets leading to them. |
||
|
|
dd7f3e80d1 |
Unify the code that performs the three kinds of data movements
Estimated hours taken: 20
Unify the code that performs the three kinds of data movements
required for calls:
(1) putting forward live variables to be saved across the call
into their stack slots
(2) putting variables protected by enclosing resumption points
into their stack slots
(3) putting input arguments into their registers
By using the same code (code_info__setup_call) for all three, we gain
two benefits:
(1) This code can also compute the live lval set we must put into
a livevals LLDS instruction before the call to describe the
locations that must be preserved by value numbering. Previously,
this set was computed by other algorithms, raising the possibility
of a discrepancy. Such discrepancies would cause value numbering
to generate incorrect code.
(2) The eager back end is more efficient when given a single list
of data placements to perform instead of three lists, because
it can reorder operations more freely when required.
compiler/call_gen.m:
Make the change described above.
Factor out more code that is common between ordinary and generic calls.
compiler/code_info.m:
Provide the infrastructure for the change above.
compiler/arg_info.m:
Concentrate predicates dealing with arg_infos and parameter passing
conventions in general in this module. Previously, call_gen.m and
code_util.m also contained such code.
compiler/bytecode_gen.m:
compiler/pragma_c_gen.m:
compiler/disj_gen.m:
compiler/follow_vars.m:
compiler/middle_rec.m:
Small changes to conform to changes in interfaces of the modules above.
compiler/code_util.m:
Remove a now redundant predicate.
|
||
|
|
a1f326f4e9 |
Add an alternative to code_exprn that does eager code generation (code_exprn
Estimated hours taken: 140 Add an alternative to code_exprn that does eager code generation (code_exprn always does lazy code generation). Its main advantages are that the new code is significantly simpler, and that it does not generate unnecessary shuffling code. Its main disadvantage, which is that it does not eliminate the creation of unneeded cells, can be eliminated by switching on --unneeded-code. For now, you can select the use of the new code generator with the --no-lazy-code option (which was previously present but unused). This will be made the default later, after I do more performance tests. Var_locn contains stricter self-checks than code_exprn does. This required modifications to some other parts of the code generator to ensure that the self-checks do not fail unnecessarily. (This mostly took the form of explicitly killing off dead variables before calling code_info__clear_all_registers, which would complain about losing the last record of the value of a variable that was alive as far as it knew.) To make my changes simpler, also took the opportunity to simplify parts of the code generator which were handing around rvals that in fact had to be wrappers around lvals, by handing around the lvals directly. Testing this change also required fixing an old bug which prevented compiling the library with -O1 --trace deep, together with the usual intermodule optimization. The bug is that a library module reads predicates from builtin.opt or private_builtin.opt, does not eliminate them because of the -O1, and then tries to generate traced code for them. However, this fails because the builtin modules contain some predicates that cannot be made to conform to typeinfo-liveness, which is required by tracing. compiler/var_locn.m: The new module that implements eager code generation. compiler/follow_vars.m: Improve the follow_vars pass, since eager code generation requires better follow_vars information. We now generate correct information for generic calls, and record not only where some vars (e.g. those which appear as input arguments of following calls) should be put, but also which registers are not reserved for those variables and are thus available for other variables. compiler/hlds_goal.m: Modify the follow_vars field of the goal_info to record the number of the first non-reserved register. compiler/code_info.m: Replace the general-purpose predicate code_info__cache_exprn, which associated a variable with an rval without generating code, with a set of special-purpose predicates such as code_info__assign_const_to_var and code_info__assign_cell_to_var, some of which can generate code. These new predicates and some older ones (e.g. code_info__setup_call) now choose at runtime whether to call code_exprn or var_locn. The basis for the decision is checking whether the code_info structure contains an exprn_info or a var_locn_info. This is decided in code_info__init based on the value of the lazy_code option, and maintained unchanged from then on. Rename some predicates to better reflect their current possible behaviors. compiler/unify_gen.m: Call the new special-purpose predicates in code_info instead of code_info__cache_exprn. Replace an incorrect clause with a call to error, since that clause could never be invoked. compiler/call_gen.m: Hand over the task of generating the args of generic calls to code_info, since it already has code to do the right thing, which includes reserving the registers to be used for the input args. Notify the rest of the code generator after the last use of non-forward-live variables, in order to avoid spurious calls to error (it is an error to clobber the last location of a live variable). Notify the rest of the code generator when generic calls overwrite registers, to allow the proper consistency checks to be made. If an output variable is singleton, then do not make it known to the code generator. It never will never become dead, and may thus cause a spurious compiler abort if its storage is ever clobbered. Export a predicate for use by follow_vars. Factor out some common code. Call the new preds in code_info where necessary. compiler/pragma_c_gen.m: Notify the rest of the code generator after the last use of non-forward-live variables, in order to avoid spurious calls to error (it is an error to clobber the last location of a live variable). If an output variable is singleton, then do not make it known to the code generator. It never will never become dead, and may thus cause a spurious compiler abort if its storage is ever clobbered. When using var_locn, ensure that none of the input arguments of a model_semi pragma_c_code is assigned to r1. If we did, and the last reference to the value of that argument was after an assignment to SUCCESS_INDICATOR, the C compiler would be forced to generate code to shuffle the value of the argument out of the way. compiler/code_exprn.m: Minor changes to return lvals directly instead of lvals wrapped inside rvals and to conform the new format of follow_vars. Do not include the registers reserved by follow_vars in the search for a spare register. compiler/lookup_switch.m: compiler/switch_gen.m: Fix an old bug that did not matter with code_exprn but does matter with var_locn: the branch end structure was being computed in the wrong place. compiler/disj_gen.m: At the ends of non-last disjuncts, kill off the variables that we needed to know inside the disjunct but won't need to know after the disjunct, in order to avoid error messages about throwing away their state. The variables affected are those which are needed only by the resumption point of the next disjunct, not by enclosing resumption points or forward execution. compiler/arg_info.m: Associate an lval, not an rval, with each argument. compiler/*.m: Minor changes to conform to (a) the new format of follow_vars, (b) the replacement of rvals containing lvals by lvals. compiler/code_util.m: Add some utility predicates for var_locn.m. compiler/exprn_aux.m: Add some utility functions for var_locn.m. Export a predicate for var_locn.m. compiler/handle_options.m: If --no-lazy-code is set, switch on the "optimizations" on whose presence it depends. compiler/mercury_compile.m: compiler/code_gen.m: Turn off tracing for predicates that don't obey typeinfo liveness for backend_by_preds and backend_by_phases respectively. Look up options in the globals structure in the module_info, not in the globals structure in the I/O state, since this is where we turn off tracing. (We should later make sure that other parts of the compiler are also consistent on this issue.) compiler/stack_layout.m: Throw away any continuation_info structures that belong to predicates that don't obey typeinfo liveness. |
||
|
|
12af7b3793 |
Consistently use counters to allocate label numbers and cell numbers
Estimated hours taken: 12 Consistently use counters to allocate label numbers and cell numbers throughout the LLDS backend. compiler/hlds_module.m: Change the module_info structure to store a counter instead of an integer for cell numbers. compiler/llds.m: Change the c_procedure structure to include a proc_label and a counter, to allow LLDS to LLDS optimizations to use this counter to allocate new label numbers. (The labels also include the proc_label.) compiler/code_info.m: Change the code_info structure to store counters instead of integers for both label numbers and cell numbers. compiler/code_gen.m: When creating the c_procedure, copy the final value of the counter from code_info to the c_procedure. compiler/opt_util.m: Delete the existing, inefficient procedure for allocating label numbers, and modify the interface of the get_prologue predicate to no longer return the proc_label (since it can now be looked up more directly). compiler/*.m: Minor changes to conform to the new data structures and to use counters instead of direct addition. |
||
|
|
c192d50143 |
Add preliminary support for a new pragma:
Estimated hours taken: 15 Add preliminary support for a new pragma: :- pragma foreign_code(LanguageString, .... <same args as c_code>). This is intended to be the eventual replacement of pragma c_code. Presently the only valid language is "C". The existing pragma c_code is simply turned into pragma foreign_code. pragma foreign_code is not a supported pragma at the moment. There are several other changes that are intended (for example, foreign_code will be impure by default). This change also changes the HLDS goal pragma_c_code/7 to pragma_foreign_code/8 where the extra argument is the foreign language. Any code currently generating output for pragma C code simply checks that the foreign language is set to "c". Since this is the only alternative of the type foreign_language, it will always succeed. However when new alternatives are added it should be fairly easy to find where the changes need to be made. Some type names and predicate names have also been updated, however there are many more that haven't yet been touched. compiler/prog_io_pragma.m: Accept the new syntax. Turn the old syntax into the new item. compiler/hlds_goal.m: Change pragma_c_code/7 to pragma_foreign_code/8. Define the foreign_language type. compiler/llds.m: Change user_c_code/2 to user_foreign_code/3. compiler/*.m: Update the rest of the compiler to handle these types. Make a few small changes to update variable names, predicate names and type names. |
||
|
|
78e4768104 |
Fix a bug that was causing the compiler to output bogus declarations
Estimated hours taken: 4 Fix a bug that was causing the compiler to output bogus declarations of nonexistent layout structures, using undefined C structure tags. For some reason, gcc accepted these declarations on all our platforms except taifun. compiler/llds.m: We used to have one field in pragma_c instructions that could name a label that cannot be renamed by optimizations. In some instructions, this label had a layout structure, in others it didn't. We now have two fields, one for labels that have layout structures and one for labels that don't. compiler/llds_out.m: Declare the C global variable holding the layout structure of a fixed (non-renamable) label referred to by a pragma_c instruction only if that label does have a layout structure. compiler/*.m: Minor changes to conform to the changes to pragma_c instructions. |
||
|
|
e46e2d5eb1 |
Remove calls to !.
Estimated hours taken: 0.5 library/*.m: compiler/*.m: Remove calls to !. |
||
|
|
84c8146d0d |
Fix several bugs in the trail handling.
Estimated hours taken: 20
Fix several bugs in the trail handling.
Also improve the documentation of trailing, and add a new macro
MR_choicepoint_newer() to the public trailing interface.
The bugs which this change fixes are:
- choice point ids were being reused after commits,
rather than only after backtracking;
- for if-then-elses with nondet conditions, the generated code was
using MR_commit rather than MR_solve as the MR_untrail_reason;
- for semidet disjunctions, when committing to a particular disjunct
the generated code was not calling MR_reset_ticket(..., MR_commit)
to invoke function trail entries, and was also leaking a trail ticket
- the all-solutions predicates in std_util.m were leaking trail
tickets (i.e. allocating them but not pruning or discarding them).
runtime/mercury_trail.h:
runtime/mercury_regorder.h:
runtime/mercury_regs.h:
runtime/mercury_wrapper.c:
runtime/mercury_context.h:
runtime/mercury_engine.h:
A bunch of changes to add a new virtual register
`MR_ticket_high_water':
- in mercury_trail.h, add MR_ticket_high_water_var variable;
- in mercury_regorder.h, add MR_ticket_high_water macro;
- in mercury_regs.h, add MR_TICKET_HIGH_WATER_RN macro;
- in mercury_wrapper.c, change
print_register_usage_counts() to handle
MR_TICKET_HIGH_WATER_RN.
- in mercury_context.h and mercury_engine.h,
add code to save/restore this new register when
appropriate.
runtime/mercury_trail.h:
- Change MR_store_ticket() so that it does
`MR_ticket_counter = ++MR_ticket_high_water'
rather than just `MR_ticket_counter++'.
- Add new macros MR_prune_ticket() and MR_prune_tickets_to(),
which only reset MR_ticket_counter, not MR_ticket_high_water.
- Change the old macros MR_discard_ticket() and MR_discard_tickets_to()
so that they reset both MR_ticket_high_water and MR_ticket_counter.
- Add new macro MR_choicepoint_newer().
- Enclose macro arguments in parentheses.
- Some minor changes to the documentation.
doc/reference_manual.texi:
Document MR_choicepoint_newer().
Update the documentation to reflect the fact that exceptions
are now a standard part of Mercury.
Clarify the documentation in the "Avoiding Redundant Trailing"
section, and add a longish example.
compiler/notes/trailing.html:
Add some documentation on the trail and how we manage it.
compiler/llds.m:
compiler/mlds.m:
Add new `prune_ticket' and `prune_tickets_to' instructions,
corresponding to the new macros defined in runtime/mercury_trail.h.
Comment out the `discard_tickets_to' instruction, since it
is no longer used in the compiler (the MR_discard_tickets_to()
macro is only used by library/exception.m and the debugger's
retry command).
Replace the duplicated documentation in mlds.m with a pointer
to llds.m.
compiler/ite_gen.m:
compiler/code_gen.m:
compiler/code_info.m:
Change the trail handling code generated after commits
so that the ticket is pruned rather than discarded.
compiler/ite_gen.m:
When generating the reset_ticket instruction for
if-then-elses with nondet conditions, use `solve'
rather than `commit' as the reset_trail_reason.
compiler/disj_gen.m:
Add code to generate a reset_ticket(..., commit)
instruction at the end of every non-last disjunct
in semidet disjunctions.
compiler/dupelim.m:
compiler/livemap.m:
compiler/llds_common.m:
compiler/llds_out.m:
compiler/ml_elim_nested.m:
compiler/middle_rec.m:
compiler/opt_debug.m:
compiler/opt_util.m:
compiler/value_number.m:
compiler/vn_*.m:
Trivial modifications to handle the changes to the
trailing instructions.
library/exception.m:
Change the trail handling code so that when the goal in an
exception handler succeeds (rather than failing or throwing an
exception), the trail ticket we created on entry to the
handler is pruned rather than discarded.
library/std_util.m:
Add a new impure predicate `discard_trail_ticket', which calls
MR_discard_ticket(), and call it in `builtin_aggregate' and
`do_while' to discard the ticket that gets allocated by the
call to MR_store_ticket() in `get_registers'.
|
||
|
|
6feb0b95f2 |
Make a separate enquiry function for each possible semantic test on
Estimated hours taken: 1 Make a separate enquiry function for each possible semantic test on eval_methods. The answers are the same now, but will be different when tabled I/O is implemented. compiler/hlds_pred.m: Make a separate enquiry function for each possible semantic test on eval_methods. compiler/code_gen.m: compiler/ml_code_gen.m: compiler/make_hlds.m: compiler/modes.m: compiler/table_gen.m: Use the new functions. |
||
|
|
17c24d9cf9 |
Restrict value numbering on procedures containing reconstructions.
Estimated hours taken: 1 Restrict value numbering on procedures containing reconstructions. Without this change, value numbering could reorder instructions which extract fields from a cell with the instructions which update the values of those fields. compiler/llds.m: Add a field to each `c_procedure' to record whether the procedure contains a reconstruction. compiler/code_gen.m: Fill in the field. compiler/value_number.m: Wrap labels around all field assignments in procedures which contain reconstructions. compiler/*.m: Handle the extra field of the `c_procedure' constructor. |
||
|
|
d43750667c |
Add a new function eval_method_uses_table/1.
Estimated hours taken: 0.75 compiler/hlds_pred.m: Add a new function eval_method_uses_table/1. compiler/code_gen.m: compiler/ml_code_gen.m: compiler/modes.m: compiler/table_gen.m: Use eval_method_uses_table, rather than just assuming that every eval method other than eval_normal uses a table. |
||
|
|
0642a10ff8 |
Reduce the number of arguments of MR_trace() to one.
Estimated hours taken: 24 WARNING: this change affects binary compatibility for debuggable code; the debuggable modules of the program and the runtime linked into the executable must either all come from before this change, or they must all come from after this change. However, this change does *not* affect binary compatibility for non-debuggable executables. Reduce the number of arguments of MR_trace() to one. Two of the arguments, the port and the goal path, move into the label layout structure, as 16-bit numbers; the port as a simple enumeration type, and the goal path as an index into the module-wide string table. (The latter will eventually allow the debugger to support the placement of breakpoints on labels with specific goal paths.) The third argument, the number of the highest-numbered rN register in use at the label, has been moved into the proc layout structure. In theory, this will require more register saves and restores, since the number in the proc layout is conservative (it is the max of the numbers that would be required at the individual labels). However, this is not important, for two reasons. First, we always save and restore all the rM registers that appear in the mrM array before the last special-purpose register, and in most cases this dictates how many registers we save/restore. Second, we save/restore registers only when the debugger starts interaction, so save/restore is a time critical activity only for the external debugger. This change reduces the execution time of debuggable executables by about 4-5% when executing outside mdb and 3-4% when executing under mdb. It also reduces executable sizes, but only by about 0.7% on x86. This change eliminates the --trace-just-in-case compiler option, since we now have the best of both --trace-just-in-case and --no-trace-just-in-case. The drawback of this scheme is slightly increased executable size with the accurage garbage collector, but that seems a small enough price to pay. compiler/code_gen.m: compiler/code_info.m: Record the number of the highest numbered rN register live at a trace label. compiler/continuation_info.m: Record the number of the highest numbered rN register live at a trace label, and the port and goal path associated with the labels of trace events. compiler/stack_layout.m: Put the number of the highest numbered rN register live at a trace label into proc layouts, and the port and goal path into label layouts. Since we are breaking binary compatibility with old debuggable modules anyway, compress the procedure id parts of proc layouts by using only 16 bits to store the procedure's arity and mode number, instead of 32 or 64. compiler/trace.m: Update the handling of ports, goal paths and max live register numbers, so that instead of being passed as MR_trace arguments, they are recorded in data structures. Generate separate labels and layouts for the fail and redo events. Although they still have the same layout information, they now record different ports. compiler/llds.m: Since trace.m now generates a label layout structure for the redo event, we must include redo events in the llds goal path type. compiler/hlds_goal.m: Since the code for handling the port type for nondet pragma events has moved from the nondet-pragma-specific to the generic part of trace.m, we must now include their event types in the hlds goal path type. compiler/llds_out.m: Add a predicate for converting ports into numbers, now that we must store ports in static data. Using their symbolic names would be better, but that would require complications in the llds type system, which would be inadvisable just before the release. compiler/options.m: compiler/handle_options.m: doc/user_guide.texi: Eliminate --trace-just-in-case. compiler/llds.m: compiler/llds_common.m: compiler/llds_out.m: Eliminate the data structure needed by --trace-just-in-case. compiler/optimize.m: Trivial update to conform to data structure changes. library/exception.m: Update the call to MR_trace. runtime/mercury_stack_layout.h: Update the C structure declarations for the layout structures as discussed above. runtime/mercury_init.h: Update the declarations of MR_trace_real and MR_trace_fake to use only one argument. runtime/mercury_wrapper.[ch]: Update the declaration of MR_trace_func to use only one argument. runtime/mercury_trace_base.[ch]: Update the declarations of MR_trace, MR_trace_real and MR_trace_fake to use only one argument. Delete MR_trace_struct(); since we deleted --trace-just-in-case, there will not be calls to it anymore. Since we are breaking binary compatibility anyway, move the exception port to be with the other interface ports. This should speed up a frequently executed test in the debugger. Update the handling of redo events. trace/mercury_trace.h: Simplify and speed up the macro that tests a port for being an interface port, now that exceptions are grouped with other interface events. trace/mercury_trace.c: Update the definition of MR_trace_real to use only one argument. The port is pulled out of the label layout structure only when needed to perform the termination tests for the current debugger command, and the goal path and the max live register number are looked up only when the termination test succeeds. |
||
|
|
f0964815a3 |
Support line numbers in the debugger. You now get contexts (filename:lineno
Estimated hours taken: 40
Support line numbers in the debugger. You now get contexts (filename:lineno
pairs) printed in several circumstances, and you can put breakpoints on
contexts, when they correspond to trace events or to calls. The latter are
implemented as breakpoints on the label layouts of the return sites.
This required extending the debugging RTTI, so that associated with each
module there is now a new data structure listing the source file names that
contribute labels with layout structures to the code of the module. For each
such source file, this table gives a list of all such labels arising from
that file. The table entry for a label gives the line number within the file,
and the pointer to the label layout structure.
compiler/llds.m:
Add a context field to the call instruction.
compiler/continuation_info.m:
Instead of the old division of continuation info about labels into
trace ports and everything else, divide them into trace ports, resume
points and return sites. Record contexts with trace ports, and record
contexts and called procedure information with return sites.
compiler/code_info.m:
Conform to the changes in continuation_info.m.
compiler/options.m:
Add a new option that allows us to disable the generation of line
number information for size benchmarking (it has no other use).
compiler/stack_layout.m:
Generate the new components of the RTTI, unless the option says not to.
compiler/code_gen.m:
compiler/pragma_c_gen.m:
compiler/trace.m:
Include contexts in the information we gather for the layouts
associated with the events we generate.
compiler/call_gen.m:
Include contexts in the call LLDS instructions, for association
with the return site's label layout structure (which is done after
code generation is finished).
compiler/handle_options.m:
Delete the code that tests or sets the deleted options.
compiler/mercury_compile.m:
Delete the code that tests the deleted options.
compiler/basic_block.m:
compiler/dupelim.m:
compiler/frameopt.m:
compiler/livemap.m:
compiler/llds_common.m:
compiler/llds_out.m:
compiler/middle_rec.m:
compiler/opt_debug.m:
compiler/opt_util.m:
compiler/value_number.m:
compiler/vn_*.m:
Trivial changes to conform to the changes to llds.m.
compiler/jumpopt.m:
Do not optimize away jumps to labels with layout structures.
The jumps we are particularly concerned about now are the jumps
that return from procedure calls. Previously, it was okay to redirect
returns from several calls so that all go to the same label, since
the live variable information associated with the labels could be
merged. However, we now also associate line numbers with calls, and
these cannot be usefully merged.
compiler/optimize.m:
Pass the information required by jumpopt to it.
doc/user_guide.texi:
Document that you can now break at line numbers.
Document the new "context" command, and the -d or --detailed option
of the stack command and the commands that set ancestor levels.
runtime/mercury_stack_layout.h:
Extend the module layout structure definition with the new tables.
Remove the conditional facility for including label numbers in label
layout structures. It hasn't been used in a long time, and neither
Tyson or me expect to use it to debug either gc or the debugger itself,
so it has no uses left; the line numbers have superseded it.
runtime/mercury_stack_trace.[ch]:
Extend the code to print stack traces to also optionally print
contexts.
Add some utility predicates currently used by the debugger that could
also be use for debugging gc or for more detailed stack traces.
trace/mercury_trace_internal.c:
Implement the "break <context>" command, the "context" command, and
the -d or --detailed option of the stack command and the commands
that set ancestor levels.
Conditionally define a conditionally used variable.
trace/mercury_trace_external.c:
Minor changes to keep up with the changes to stack traces.
Delete an unused variable.
trace/mercury_trace_spy.[ch]:
Check for breakpoints on contexts.
trace/mercury_trace_tables.[ch]:
Add functions to search the RTTI data structures for labels
corresponding to a given context.
trace/mercury_trace_vars.[ch]:
Remember the context of the current environment.
tests/debugger/queen.{inp,exp}:
Test the new capabilities of the debugger.
tests/debugger/*.{inp,exp}:
Update the expected output of the debugger to account for contexts.
In some cases, modify the input script to put contexts where they don't
overflow lines.
|
||
|
|
89065f0a1e |
Fix a bug in frameopt reported by Serge Varennes on April 15, 1999.
Estimated hours taken: 8
Fix a bug in frameopt reported by Serge Varennes on April 15, 1999.
The bug was that frameopt recognized that a procedure did not need a
stack frame, and deleted the frame setup code, but did not redirect the
failure branches inside inlined model_semi pragma_c instructions,
so that they still led to code that deallocated the (now nonexistent)
stack frame. This meant that calls to this procedure violated the
invariant which says that calls leave MR_sp unchanged.
compiler/llds.m:
Add a new pragma C component (pragma_c_fail_to) that represents the
branch to a label on failure of a model_semi piece of C code, instead
of handling this by generating a string containing the C code that
branches to this label. Record the failure label as a new field
in pragma_c instructions.
The point of this change is that it makes it possible to substitute
the failure label in frameopt.
Add also a pragma_c_noop component to make the generated code somewhat
better optimizable.
compiler/pragma_c_gen.m:
Generate the new LLDS components.
compiler/llds_out.m:
Output the new LLDS components.
Move a predicate declaration away from the middle of another predicate.
compiler/frameopt.m:
Perform substitutions on pragma C code labels that occur only
in pragma_c_fail_to components.
If a pragma_c instruction has any other references to labels, we now
assume that the block containing the instruction needs a stack frame,
since those labels can't be substituted with their non-teardown
parallels if this block is moved to a context without a stack frame.
compiler/basic_block.m:
compiler/dupelim.m:
compiler/frameopt.m:
compiler/opt_util.m:
Both basic_block.m and dupelim.m had code that substantially
duplicated code in frameopt.m. This change factors out the differences
among the versions and moves the unified predicates to opt_util.m.
compiler/code_gen.m:
compiler/code_info.m:
compiler/dupelim.m:
compiler/livemap.m:
compiler/llds_common.m:
compiler/middle_rec.m:
compiler/opt_debug.m:
compiler/trace.m:
compiler/value_number.m:
compiler/vn_*.m:
Trivial updates to conform to the changes in llds.m.
tests/hard_coded/frameopt_pragma_redirect.{m,exp}:
A new test case that exhibits the problem. (It is not the original
test cases submitted by Serge Varennes, because that code depended
on non-standard functions in ieeefp.h.)
tests/hard_coded/Mmakefile:
Enable the new test case.
|
||
|
|
d551dd1dc9 |
Handle quantification analysis of bi-implication (`<=>') goals correctly.
Estimated hours taken: 10
Handle quantification analysis of bi-implication (`<=>') goals correctly.
Previously we used to expand bi-implications before doing quantification
analysis, which stuffed up the results of quantification analysis for
those goals. We need to do quantification analysis first, and only
then can we expand bi-implications. In addition, elimination of double
negation needs to come after expansion of bi-implication, so I moved
that from make_hlds.m to purity.m.
compiler/hlds_goal.m:
Add a new alternative to the HLDS goal type for bi-implications.
Also add a new predicate negate_goal, for use by purity.m.
compiler/make_hlds.m:
Don't expand bi-implication here, instead just use the new
bi_implication/2 HLDS goal type.
Don't eliminated double negation here.
compiler/quantification.m:
Handle quantification for bi-implications.
Expand bi-implications.
compiler/purity.m:
Eliminate double negation.
compiler/hlds_out.m:
Add code to print out bi-implication goals.
compiler/*.m:
Trivial changes to handle the new bi_implication/2
alternative in the HLDS goal type.
compiler/notes/compiler_design.html:
Document the above changes.
tests/hard_coded/Mmakefile:
tests/hard_coded/quantifier2.m:
tests/hard_coded/quantifier2.exp:
A regression test for the above change.
|
||
|
|
466c844964 |
Make the retry command work in trailing grades (e.g. for HAL).
Estimated hours taken: 18 Make the retry command work in trailing grades (e.g. for HAL). compiler/trace.m: In trailing grades, reserve two stack slots to hold (a) the trail pointer on entry, and (b) a new ticket obtained on entry. Arrange to put the numbers of these stack slots in the proc layout. compiler/stack_layout.m: Put the number of the first of these stack slots in the proc layout. compiler/code_info.m: Arrange the default: there are no such slots if debugging is not enabled. compiler/code_gen.m: Insert code to discard the allocated ticket, in the success epilog of model_det procedures, the success and failure epilogs of model_semi procedures, and the failure epilogs of model_non procedures. (Model_det procedures don't have failure epilogs, and discarding the ticket in the success epilog of a model_non procedure would be premature.) compiler/llds.m: Add two new alternatives to the type describing stack slots: a stack slot may contain a trail pointer or a ticket. Add a new reason for resetting the trail: a retry in the debugger. compiler/llds_out.m: Minor changes to conform to llds.m, and to make diagnostic output less misleading. library/builtin.m: Add the type_ctor_info for the new "types" describing stored trail pointers and tickets. Bring up to date the type_ctor_infos of other "types" used only for describing stack slots. library/std_util.m: Add the missing code to handle the type_ctor_infos of trail pointers, tickets and other "types" used only for describing stack slots. runtime/mercury_type_info.h: Add a new type_ctor representation value for stored trail pointers, tickets, and for other "types" used only for describing stack slots. runtime/mercury_deep_copy_body.h: runtime/mercury_tabling.c: Add the missing code to handle the type_ctor_infos of trail pointers, tickets and other "types" used only for describing stack slots. runtime/mercury_stack_layout.h: Add a field to proc layouts to hold either the number of the first of the two stack slots holding trail info, or -1. runtime/mercury_trail.h: Add the new reason why the trail may be reset. trace/mercury_trace.c: In trailing grades, reset the trail, with the reason being given as retry, when the debugger's retry command is executed. extras/references/scoped_update.m: extras/trailed_update/var.m: clpr/cfloat.m: extras/trailed_update/tests/func_trail_test.m: extras/trailed_update/tests/func_trail_test_2.m: Handle MR_retry as a reason for unwinding the trail. |
||
|
|
2725b1a331 |
Aditi update syntax, type and mode checking.
Estimated hours taken: 220
Aditi update syntax, type and mode checking.
Change the hlds_goal for constructions in preparation for
structure reuse to avoid making multiple conflicting changes.
compiler/hlds_goal.m:
Merge `higher_order_call' and `class_method_call' into a single
`generic_call' goal type. This also has alternatives for the
various Aditi builtins for which type declarations can't
be written.
Remove the argument types field from higher-order/class method calls.
It wasn't used often, and wasn't updated by optimizations
such as inlining. The types can be obtained from the vartypes
field of the proc_info.
Add a `lambda_eval_method' field to lambda_goals.
Add a field to constructions to identify which RL code fragment should
be used for an top-down Aditi closure.
Add fields to constructions to hold structure reuse information.
This is currently ignored -- the changes to implement structure
reuse will be committed to the alias branch.
This is included here to avoid lots of CVS conflicts caused by
changing the definition of `hlds_goal' twice.
Add a field to `some' goals to specify whether the quantification
can be removed. This is used to make it easier to ensure that
indexes are used for updates.
Add a field to lambda_goals to describe whether the modes were
guessed by the compiler and may need fixing up after typechecking
works out the argument types.
Add predicate `hlds_goal__generic_call_id' to work out a call_id
for a generic call for use in error messages.
compiler/purity.m:
compiler/post_typecheck.m:
Fill in the modes of Aditi builtin calls and closure constructions.
This needs to know which are the `aditi__state' arguments, so
it must be done after typechecking.
compiler/prog_data.m:
Added `:- type sym_name_and_arity ---> sym_name/arity'.
Add a type `lambda_eval_method', which describes how a closure
is to be executed. The alternatives are normal Mercury execution,
bottom-up execution by Aditi and top-down execution by Aditi.
compiler/prog_out.m:
Add predicate `prog_out__write_sym_name_and_arity', which
replaces duplicated inline code in a few places.
compiler/hlds_data.m:
Add a `lambda_eval_method' field to `pred_const' cons_ids and
`pred_closure_tag' cons_tags.
compiler/hlds_pred.m:
Remove type `pred_call_id', replace it with type `simple_call_id',
which combines a `pred_or_func' and a `sym_name_and_arity'.
Add a type `call_id' which describes all the different types of call,
including normal calls, higher-order and class-method calls
and Aditi builtins.
Add `aditi_top_down' to the type `marker'.
Remove `aditi_interface' from type `marker'. Interfacing to
Aditi predicates is now handled by `generic_call' hlds_goals.
Add a type `rl_exprn_id' which identifies a predicate to
be executed top-down by Aditi.
Add a `maybe(rl_exprn_id)' field to type `proc_info'.
Add predicate `adjust_func_arity' to convert between the arity
of a function to its arity as a predicate.
Add predicates `get_state_args' and `get_state_args_det' to
extract the DCG state arguments from an argument list.
Add predicate `pred_info_get_call_id' to get a `simple_call_id'
for a predicate for use in error messages.
compiler/hlds_out.m:
Write the new representation for call_ids.
Add a predicate `hlds_out__write_call_arg_id' which
replaces similar code in mode_errors.m and typecheck.m.
compiler/prog_io_goal.m:
Add support for `aditi_bottom_up' and `aditi_top_down' annotations
on pred expressions.
compiler/prog_io_util.m:
compiler/prog_io_pragma.m:
Add predicates
- `prog_io_util:parse_name_and_arity' to parse `SymName/Arity'
(moved from prog_io_pragma.m).
- `prog_io_util:parse_pred_or_func_name_and_arity to parse
`pred SymName/Arity' or `func SymName/Arity'.
- `prog_io_util:parse_pred_or_func_and_args' to parse terms resembling
a clause head (moved from prog_io_pragma.m).
compiler/type_util.m:
Add support for `aditi_bottom_up' and `aditi_top_down' annotations
on higher-order types.
Add predicates `construct_higher_order_type',
`construct_higher_order_pred_type' and
`construct_higher_order_func_type' to avoid some code duplication.
compiler/mode_util.m:
Add predicate `unused_mode/1', which returns `builtin:unused'.
Add functions `aditi_di_mode/0', `aditi_ui_mode/0' and
`aditi_uo_mode/0' which return `in', `in', and `out', but will
be changed to return `di', `ui' and `uo' when alias tracking
is implemented.
compiler/goal_util.m:
Add predicate `goal_util__generic_call_vars' which returns
any arguments to a generic_call which are not in the argument list,
for example the closure passed to a higher-order call or
the typeclass_info for a class method call.
compiler/llds.m:
compiler/exprn_aux.m:
compiler/dupelim.m:
compiler/llds_out.m:
compiler/opt_debug.m:
Add builtin labels for the Aditi update operations.
compiler/hlds_module.m:
Add predicate predicate_table_search_pf_sym, used for finding
possible matches for a call with the wrong number of arguments.
compiler/intermod.m:
Don't write predicates which build `aditi_top_down' goals,
because there is currently no way to tell importing modules
which RL code fragment to use.
compiler/simplify.m:
Obey the `cannot_remove' field of explicit quantification goals.
compiler/make_hlds.m:
Parse Aditi updates.
Don't typecheck clauses for which syntax errors in Aditi updates
are found - this avoids spurious "undefined predicate `aditi_insert/3'"
errors.
Factor out some common code to handle terms of the form `Head :- Body'.
Factor out common code in the handling of pred and func expressions.
compiler/typecheck.m:
Typecheck Aditi builtins.
Allow the argument types of matching predicates to be adjusted
when typechecking the higher-order arguments of Aditi builtins.
Change `typecheck__resolve_pred_overloading' to take a list of
argument types rather than a `map(var, type)' and a list of
arguments to allow a transformation to be performed on the
argument types before passing them.
compiler/error_util.m:
Move the part of `report_error_num_args' which writes
"wrong number of arguments (<x>; expected <y>)" from
typecheck.m for use by make_hlds.m when reporting errors
for Aditi builtins.
compiler/modes.m:
compiler/unique_modes.m:
compiler/modecheck_call.m:
Modecheck Aditi builtins.
compiler/lambda.m:
Handle the markers for predicates introduced for
`aditi_top_down' and `aditi_bottom_up' lambda expressions.
compiler/polymorphism.m:
Add extra type_infos to `aditi_insert' calls
describing the tuple to insert.
compiler/call_gen.m:
Generate code for Aditi builtins.
compiler/unify_gen.m:
compiler/bytecode_gen.m:
Abort on `aditi_top_down' and `aditi_bottom_up' lambda
expressions - code generation for them is not yet implemented.
compiler/magic.m:
Use the `aditi_call' generic_call rather than create
a new procedure for each Aditi predicate called from C.
compiler/rl_out.pp:
compiler/rl_gen.m:
compiler/rl.m:
Move some utility code used by magic.m and call_gen.m into rl.m.
Remove an XXX comment about reference counting being not yet
implemented - Evan has fixed that.
library/ops.m:
compiler/mercury_to_mercury.m:
doc/transition_guide.texi:
Add unary prefix operators `aditi_bottom_up' and `aditi_top_down',
used as qualifiers on lambda expressions.
Add infix operator `==>' to separate the tuples in an
`aditi_modify' call.
compiler/follow_vars.m:
Thread a `map(prog_var, type)' through, needed because
type information is no longer held in higher-order call goals.
compiler/table_gen.m:
Use the `make_*_construction' predicates in hlds_goal.m
to construct constants.
compiler/*.m:
Trivial changes to add extra fields to hlds_goal structures.
doc/reference_manual.texi:
Document Aditi updates.
Use @samp{pragma base_relation} instead of
@samp{:- pragma base_relation} throughout the Aditi documentation
to be consistent with other parts of the reference manual.
tests/valid/Mmakefile:
tests/valid/aditi_update.m:
tests/valid/aditi.m:
Test case.
tests/valid/Mmakefile:
Remove some hard-coded --intermodule-optimization rules which are
no longer needed because `mmake depend' is now run in this directory.
tests/invalid/*.err_exp:
Fix expected output for changes in reporting of call_ids
in typecheck.m.
tests/invalid/Mmakefile
tests/invalid/aditi_update_errors.{m,err_exp}:
tests/invalid/aditi_update_mode_errors.{m,err_exp}:
Test error messages for Aditi updates.
tests/valid/aditi.m:
tests/invalid/aditi.m:
Cut down version of extras/aditi/aditi.m to provide basic declarations
for Aditi compilation such as `aditi__state' and the modes
`aditi_di', `aditi_uo' and `aditi_ui'. Installing extras/aditi/aditi.m
somewhere would remove the need for these.
|
||
|
|
d66c8481ae |
Some more changes to minimize the complexity of the intermodule dependencies.
Estimated hours taken: 4 Some more changes to minimize the complexity of the intermodule dependencies. In particular, ensure that hlds_module.m does not need to import llds.m. compiler/hlds_module.m: compiler/llds.m: Move the definition of the c_interface_info type (and the types used for all its fields) from llds.m into hlds_module.m, since this type contains high-level information about the user-level C interface stuff that is not directly related to the LLDS and is needed by other back-ends. compiler/hlds_module.m: compiler/llds.m: compiler/mercury_compile.m: compiler/code_gen.m: compiler/stack_layout.m: compiler/table_gen.m: Move the `global_data' type from hlds_module.m into llds.m, since this type contains low-level stuff that is dependent on the LLDS. Delete the `global_data' field of the module_info, instead passing it around as a separate argument where needed. Move the code for inserting llds__tabling_pointer_vars into the global_data from table_gen.m to code_gen.m, since this is dependent on the LLDS and table_gen.m should be a pure HLDS->HLDS transformation, so that it can work with other back-ends. compiler/continuation_info.m: Update some comments which this change makes obsolete. compiler/optimize.m: Delete the import of module hlds_data, since it is no longer needed. |
||
|
|
ca0b3b7c6b |
Add an option that causes the compiler to pass information to the
Estimated hours taken: 8 Add an option that causes the compiler to pass information to the execution tracing system in one struct, rather than four separate arguments. Two of these arguments are pointers, which each require two instructions to set up on SPARC, MIPS and other RISCs that do not use a global pool. The other two arguments are small constants. Therefore on 32-bit RISCs, replacing MR_trace/4 with MR_trace_struct/1 will probably replace six instructions with two, which saves four instructions' worth of time and 16 bytes of code, at the cost of 12 bytes of data, and possibly the cost of some instructions later loading the info from the struct into registers. However, this loading cost does not have to be paid if tracing is not enabled, and other optimizations may reduce the cost even if tracing is enabled. For example, I strongly suspect that on out-of-order machines, which means most CPUs you can buy today, the load instructions are effectively free, because they happen while the indirect jump to MR_trace_real takes place. I intend to benchmark this option on our various platforms, and have autoconfigure set it on the machines in which it is beneficial. doc/user_guide.texi: Document the new --call-trace-struct option, and say it is not for general use. compiler/options.m: Add the new option. compiler/trace.m: If the option is set, call MR_trace_struct instead of MR_trace, and create a new kind of static (in both senses) global data structure to hold the arguments. Move the definition of trace_port to llds.m, and the procedure to convert it to string to llds_out.m compiler/code_info.m: Add an extra code_info slot to hold this new kind of global data, and its access predicates. compiler/code_gen.m: Transfer this new kind of global data from code_info to the global_data part of module_info. compiler/hlds_module.m: Add a new field to the global_data data structure to hold this data. compiler/mercury_compile.m: Include the new global data in the list of things we give to llds_out. compiler/llds.m: Add a new kind of comp_gen_c_data to hold MR_trace_struct arguments. Also move the definition of trace_port from trace.m to here, since the new kind of comp_gen_c_data refers to this type. compiler/llds_out.m: Add code to print the new kind of comp_gen_c_data. Move the code to print trace_ports from trace.m to here. compiler/llds_common.m: Ignore the new kind of comp_gen_c_data, since by construction its contents are never common with anything else. runtime/mercury_trace_base.[ch]: Add a new variant of MR_trace, MR_trace_struct, that consolidates the arguments into a single MR_Trace_Call_Info struct. Fix a bad variable name: the int argument to MR_trace is a max r register number, not a max mr register number. |
||
|
|
3bf462e0b7 |
Switch to a closure representation that includes runtime type and procedure id
Estimated hours taken: 36
Switch to a closure representation that includes runtime type and procedure id
information, so that closures can be copied, garbage collected, printed, etc.
This RTTI information is not yet used. Adding code to use it would be futile
until Tyson finishes his changes to the other RTTI data structures.
Note also that this change provides the information required for solving the
problem of trying to deep copy closures only for grades that include
--typeinfo-liveness. Providing this info for other grades is future work.
configure.in:
Find out what the right way to refer to a variable-sized array
at the end of a struct is.
runtime/mercury_ho_call.h:
New file to define the structure of closures and macros for accessing
closures.
runtime/Mmakefile:
Add the new header file.
runtime/mercury_ho_call.c:
Add an entry point to handle calls to new-style closures. The code
to handle old-style closures, which was unnecessarily duplicated for
each code model, stays until all the installed compilers use the new
closure representation.
Until that time, the new entry point will contain code to detect
the use of old-style closures and invoke the old code instead.
This allows stage1s compiled with old compilers to use the old style
and stage2 to use the new style without any special tricks anywhere
else.
Add a new entry point to handle method calls of all code models.
The old entry points, which had the same code, will also be deleted
after this change has been bootstrapped.
runtime/mercury_calls.h:
Remove the macros that call closures. Their interface sucked, they
were not used, and their implementation is now out of date.
runtime/mercury_stack_layout.h:
Add a new type, MR_Type_Param_Locns, for use by the C type
representing closures. Since MR_Stack_Layout_Vars has a field,
MR_slvs_tvars, which references a data structure identical
in every way to MR_Type_Param_Locns, change the type of that field
to this new type, instead of the previous cheat.
runtime/mercury_layout_util.h:
Minor update to conform to the new type of the MR_slvs_tvars field.
(This is the only use of that field in the system.)
runtime/mercury_type_info.h:
Add new types MR_TypeInfo and MR_PseudoTypeInfo. For now, they
are just Word, but later we can make them more accurate.
In the meantime, we can refer to them instead of to Word,
making code clearer. One such reference is now in mercury_ho_call.h.
compiler/notes/release_checklist.html:
Add a reminder to remove the redundant code from mercury_ho_call.c
after bootstrapping.
compiler/llds.m:
Replace three code addresses for calling closures and another three
for calling methods with one each.
compiler/call_gen.m:
compiler/dupelim.m:
compiler/opt_debug.m:
compiler/opt_util.m:
compiler/llds_out.m:
Trivial updates in accordance with the change to llds.m
compiler/code_info.m:
Move the code to handle layouts to continuation_info.m,
since that's where it belongs. Leave only the code for picking
up parameters from code_infos and for putting results back in there.
Remove the redundant arguments of code_info__init, and extract
them from ProcInfo, to make clear that they are related.
compiler/code_gen.m:
Since we pass ProcInfo to code_info__init, don't pass its components.
compiler/continuation_info.m:
Add the code moved from code_info.m, in a form which takes explicit
arguments for things that used be hidden in the code_info.
Add new code, closely related to the moved code, that creates
layout info from a procedure's argument info, rather than from a
(part of) the current code generator state. This way, it can be
invoked from places that don't have a code_info for the procedure
for which they want to generate layouts. This is the case when
we generate layouts for closures.
compiler/par_conj_gen.m:
compiler/trace.m:
Minor changes required by the move of stuff from code_info to
continuation_info.
compiler/stack_layout.m:
Export some predicates for use by unify_gen.
compiler/unify_gen.m:
Switch to creating new style closures, complete with layout info.
Optimize the code for extending closures a bit. By copying the
fixed words of the closure outside the loop, we avoid incurring
the loop overhead twice.
compiler/code_util.m:
Add a couple of utility predicates for continuation_info.m and
unify_gen.m
library/benchmarking.m:
library/std_util.m:
Refer to the new entry point for handling closures.
browser/dl.m:
Use the new closure representation.
Note that extras/dynamic_linking/dl.m, which is supposed to be
the same as browser/dl.m but is not, should also be updated, but
this will be handled later by Fergus.
tests/hard_coded/closure_extension.{m,exp}:
A new test case to exercise the code for extending closures.
tests/hard_coded/Mmakefile:
Enable the new test case.
|
||
|
|
18430aaef1 |
Aditi compilation.
Estimated hours taken: 1200
Aditi compilation.
compiler/options.m:
The documentation for these is commented out because the Aditi
system is not currently useful to the general public.
--aditi: enable Aditi compilation.
--dump-rl: write the intermediate RL to `<module>.rl_dump'.
--dump-rl-bytecode: write a text version of the bytecodes
to `<module>.rla'
--aditi-only: don't produce a `.c' file.
--filenames-from-stdin: accept a list of filenames to compile
from stdin. This is used by the query shell.
--optimize-rl, --optimize-rl-cse, --optimize-rl-invariants,
--optimize-rl-index, --detect-rl-streams:
Options to control RL optimization passes.
--aditi-user:
Default owner of any Aditi procedures,
defaults to $USER or "guest".
--generate-schemas:
write schemas for base relations to `<module>'.base_schema
and schemas for derived relations to `<module>'.derived_schema.
This is used by the query shell.
compiler/handle_options.m:
Handle the default for --aditi-user.
compiler/hlds_pred.m:
compiler/prog_data.m:
compiler/prog_io_pragma.m:
compiler/make_hlds.m:
Add some Aditi pragma declarations - `aditi', `supp_magic', `context',
`naive', `psn' (predicate semi-naive), `aditi_memo', `aditi_no_memo',
`base_relation', `owner' and `index'.
Separate out code to parse a predicate name and arity.
compiler/hlds_pred.m:
Add predicates to identify Aditi procedures.
Added markers `generate_inline' and `aditi_interface', which
are used internally for Aditi code generation.
Add an `owner' field to pred_infos, which is used for database
security checks.
Add a field to pred_infos to hold the list of indexes for a base
relation.
compiler/make_hlds.m:
Some pragmas must be exported if the corresponding predicates
are exported, check this.
Make sure stratification of Aditi procedures is checked.
Predicates with a mode declaration but no type declaration
are no longer assumed to be local.
Set the `do_aditi_compilation' field of the module_info if there
are any local Aditi procedures or base relations.
Check that `--aditi' is set if Aditi compilation is required.
compiler/post_typecheck.m:
Check that every Aditi predicate has an `aditi__state' argument,
which is used to ensure sequencing of updates and that Aditi
procedures are only called within transactions.
compiler/dnf.m:
Changed the definition of disjunctive normal form slightly
so that a call followed by some atomic goals not including
any database calls is considered atomic. magic.m can handle
this kind of goal, and it results in more efficient RL code.
compiler/hlds_module.m:
compiler/dependency_graph.m:
Added dependency_graph__get_scc_entry_points which finds
the procedures in an SCC which could be called from outside.
Added a new field to the dependency_info, the
aditi_dependency_ordering. This contains all Aditi SCCs of
the original program, with multiple SCCs merged where
possible to improve the effectiveness of differential evaluation
and the low level RL optimizations.
compiler/hlds_module.m:
Add a field to record whether there are any local Aditi procedures
in the current module.
Added versions of module_info_pred_proc_info and
module_info_set_pred_proc_info which take a pred_proc_id,
not a separate pred_id and proc_id.
compiler/polymorphism.m:
compiler/lambda.m:
Make sure that predicates created for closures in Aditi procedures
have the correct markers.
compiler/goal_util.m:
Added goal_util__switch_to_disjunction,
goal_util__case_to_disjunct (factored out from simplify.m)
and goal_util__if_then_else_to_disjunction. These are
require because supplementary magic sets can't handle
if-then-elses or switches.
compiler/type_util.m:
Added type_is_aditi_state/1.
compiler/mode_util.m:
Added partition_args/5 which partitions a list of arguments
into inputs and others.
compiler/inlining.m:
Don't inline memoed procedures.
Don't inline Aditi procedures into non-Aditi procedures.
compiler/intermod.m:
Handle Aditi markers.
Clean up handling of markers which should not appear in `.opt' files.
compiler/simplify.m:
Export a slightly different interface for use by magic.m.
Remove explicit quantifications where possible.
Merge multiple nested quantifications.
Don't report infinite recursion warnings for Aditi procedures.
compiler/prog_out.m:
Generalised the code to output a module list to write any list.
compiler/code_gen.m:
compiler/arg_info.m:
Don't process Aditi procedures.
compiler/mercury_compile.m:
Call magic.m and rl_gen.m.
Don't perform the low-level annotation passes on Aditi procedures.
Remove calls to constraint.m - sometime soon a rewritten version
will be called directly from deforestation.
compiler/passes_aux.m:
Add predicates to process only non-Aditi procedures.
compiler/llds.m:
compiler/llds_out.m:
Added new `code_addr' enum members, do_{det,semidet,nondet}_aditi_call,
which are defined in extras/aditi/aditi.m.
compiler/call_gen.m:
Handle generation of do_*_aditi_call.
compiler/llds_out.m:
Write the RL code for the module as a constant char array
in the `.c' file.
compiler/term_errors.m:
compiler/error_util.m:
Move code to describe predicates into error_util.m
Allow the caller to explicitly add line breaks.
Added error_util:list_to_pieces to format a list of
strings.
Reordered some arguments for currying.
compiler/hlds_out.m:
Don't try to print clauses if there are none.
runtime/mercury_init.h:
util/mkinit.c:
scripts/c2init.in:
Added a function `mercury__load_aditi_rl_code()' to the generated
`<module>_init.c' file which throws all the RL code for the program
at the database. This should be called at connection time by
`aditi__connect'.
Added an option `--aditi' which controls the output
`mercury__load_aditi_rl_code()'.
compiler/notes/compiler_design.html:
Document the new files.
Mmakefile:
bindist/Mmakefile:
Don't distribute extras/aditi yet.
New files:
compiler/magic.m:
compiler/magic_util.m:
Supplementary magic sets transformation. Report errors
for constructs that Aditi can't handle.
compiler/context.m:
Supplementary context transformation.
compiler/rl_gen.m:
compiler/rl_relops.m:
Aditi code generation.
compiler/rl_info.m:
Code generator state.
compiler/rl.m:
Intermediate RL representation.
compiler/rl_util:
Predicates to collect information about RL instructions.
compiler/rl_dump.m:
Print out the representation in rl.m.
compiler/rl_opt.m:
Control low-level RL optimizations.
compiler/rl_block.m:
Break a procedure into basic blocks.
compiler/rl_analyse.m:
Generic dataflow analysis for RL procedures.
compiler/rl_liveness.m:
Make sure all relations are initialised before used, clear
references to relations that are no longer required.
compiler/rl_loop.m:
Loop invariant removal.
compiler/rl_block_opt.m:
CSE and instruction merging on basic blocks.
compiler/rl_key.m:
Detect upper/lower bounds for which a goal could succeed.
compiler/rl_sort.m:
Use indexing for joins and projections.
Optimize away unnecessary sorting and indexing.
compiler/rl_stream.m:
Detect relations which don't need to be materialised.
compiler/rl_code.m:
RL bytecode definitions. Automatically generated from the Aditi
header files.
compiler/rl_out.m:
compiler/rl_file.m:
Output the RL bytecodes in binary to <module>.rlo (for use by Aditi)
and in text to <module>.rla (for use by the RL interpreter).
Also output the schema information if --generate-schemas is set.
compiler/rl_exprn.m:
Generate bytecodes for join conditions.
extras/aditi/Mmakefile:
extras/aditi/aditi.m:
Definitions of some Aditi library predicates and the
interfacing and transaction processing code.
|
||
|
|
27f024b2e9 |
Reorganize the handling of global data structures, and expose the table
Estimated hours taken: 16 Reorganize the handling of global data structures, and expose the table pointers for tabled predicates to allow the tables to be reset to empty by hand-written C code for benchmarking purposes. compiler/hlds_module.m: Introduce a new submodule for dealing with global data. At the moment it deals with (a) layout structures and (b) tabling pointers. compiler/continuation_info.m: Remove the data structures and predicates whose equivalents are now in hlds_module. compiler/llds.m: Introduce a new kind of item, that of compiler-generated variables whose value is not defined by rvals. At the moment, the only such item is a tabling pointer variable. compiler/mercury_compile.m: Include the new kind of item in the generated LLDS. compiler/table_gen.m: Use the new kind of item instead of a static variable declaration in pragma C code to hold the tabling pointer. Remove lots of spaces at ends of lines, since many of these screw up paragraph commands in vi. compiler/base_type_layout.m: compiler/bytecode_gen.m: compiler/code_gen.m: compiler/code_util.m: compiler/dependency_graph.m: compiler/hlds_out.m: compiler/llds_out.m: compiler/mercury_to_mercury.m: compiler/switch_gen.m: compiler/transform_llds.m: compiler/unify_gen.m: Handle the changes in the data structures. library/private_builtin.m: Remove the predicate get_table, which is no longer used after the changes to table_gen.m. |
||
|
|
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. |