mirror of
https://github.com/Mercury-Language/mercury.git
synced 2025-12-15 22:03:26 +00:00
885fd4a387b44eb83cad744f11c05e495224a0bc
128 Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
885fd4a387 |
Remove almost all dependencies by the modules of parse_tree.m on the modules
Estimated hours taken: 12 Branches: main Remove almost all dependencies by the modules of parse_tree.m on the modules of hlds.m. The only such dependencies remaining now are on type_util.m. compiler/hlds_data.m: compiler/prog_data.m: Move the cons_id type from hlds_data to prog_data, since several parts of the parse tree data structure depend on it (particularly insts). Remove the need to import HLDS modules in prog_data.m by making the cons_ids that refer to procedure ids refer to them via a new type that contains shrouded pred_ids and proc_ids. Since pred_ids and proc_ids are abstract types in hlds_data, add predicates to hlds_data to shroud and unshroud them. Also move some other types, e.g. mode_id and class_id, from hlds_data to prog_data. compiler/hlds_data.m: compiler/prog_util.m: Move predicates for manipulating cons_ids from hlds_data to prog_util. compiler/inst.m: compiler/prog_data.m: Move the contents of inst.m to prog_data.m, since that is where it belongs, and since doing so eliminates a circular dependency. The separation doesn't serve any purpose any more, since we don't need to import hlds_data.m anymore to get access to the cons_id type. compiler/mode_util.m: compiler/prog_mode.m: compiler/parse_tree.m: Move the predicates in mode_util that don't depend on the HLDS to a new module prog_mode, which is part of parse_tree.m. compiler/notes/compiler_design.m: Mention prog_mode.m, and delete the mention of inst.m. compiler/mercury_to_mercury.m: compiler/hlds_out.m: Move the predicates that depend on HLDS out of mercury_to_mercury.m to hlds_out.m. Export from mercury_to_mercury.m the predicates needed by the moved predicates. compiler/hlds_out.m: compiler/prog_out.m: Move predicates for printing parts of the parse tree out of hlds_out.m to prog_out.m, since mercury_to_mercury.m needs to use them. compiler/purity.m: compiler/prog_out.m: Move predicates for printing purities from purity.m, which is part of check_hlds.m, to prog_out.m, since mercury_to_mercury.m needs to use them. compiler/passes_aux.m: compiler/prog_out.m: Move some utility predicates (e.g. for printing progress messages) from passes_aux.m to prog_out.m, since some predicates in submodules of parse_tree.m need to use them. compiler/foreign.m: compiler/prog_data.m: Move some types from foreign.m to prog_data.m to allow the elimination of some dependencies on foreign.m from submodules of parse_tree.m. compiler/*.m: Conform to the changes above, mostly by updating lists of imported modules and module qualifications. In some cases, also do some local cleanups such as converting predicate declarations to predmode syntax and fixing white space. |
||
|
|
7bf0cd03af |
Reduce the overhead of all forms of tabling by eliminating in many cases
Estimated hours taken: 32
Branches: main
Reduce the overhead of all forms of tabling by eliminating in many cases
the overhead of transferring data across the C/Mercury boundary. These
involve lots of control transfers as well as assignments to and from
Mercury abstract machine registers, which are not real machine registers
on x86 machines. Benchmarking in Uppsala revealed this overhead to be
a real problem.
The way we do that is by changing the tabling transformation so that instead
of generating sequences of calls to predicates from library/table_builtin.m,
we generate sequences of calls to C macros from runtime/mercury_tabling_pred.h,
and emit the resulting code string as the body of a foreign_proc goal.
(The old transformation is still available via a new option,
--no-tabling-via-extra-args.)
Since the number of inputs and outputs of the resulting C code sequences
are not always fixed (they can depend on the number of input or output
arguments of predicate being transformed), implementing this required
adding to foreign_procs a new field that allows the specification of extra
arguments to be passed to and from the given foreign code fragment. For now,
this mechanism is implemented only by the C backends, since it is needed
only by the C backends. (We don't support yet tabling on other backends.)
To simplify the new implementation of the field on foreign_procs, consolidate
three existing fields into one. Each of these fields was a list with one
element per argument, so turning them into a single list with a combined record
per argument should also improve reliability, since it reduces the likelyhood
of updates leaving the data structure inconsistent.
The goal paths of components of a tabled predicate depend on whether
-no-tabling-via-extra-args was specified. To enable the expected outputs
of the debugger test cases testing tabling, we add a new mdb command,
goal_paths, that controls whether goal paths are printed by the debugger
at events, and turn off the printing of events in the relevant test cases.
Also, prepare for a future change to optimize the trie structure for
user-defined types by handling type_infos (and once we support them,
typeclass_infos) specially.
compiler/table_gen.m:
Change the tabling transformation along the lines described above.
To allow us to factor out as much of the new code as possible,
we change the meaning of the call_table_tip variable for minimal
model subgoals: instead of the trie node at the end of the answer
table, it is not now the subgoal reachable from it. This change
has no effect as yet, because we use call_table_tip variables
only to perform resets across retries in the debugger, and we
don't do retries across calls to minimal model tabled predicates.
Put predicates into logical groups.
library/table_builtin.m:
runtime/mercury_tabling_preds.h:
When the new transformations in table_gen.m generate foreign_procs
with variable numbers of arguments, the interfaces of those
foreign_procs often do not match the interfaces of the existing
library predicates at their core: they frequently have one more
or one fewer argument. To prevent any possible confusion, in such
cases we add a new variant of the predicate. These predicates
have the suffix _shortcut in their name. Their implementations
are dummy macros that do nothing; they serve merely as placeholders
before or after which the macros that actually do the work are
inserted.
Move the definitions of the lookup, save and restore predicates
into mercury_tabling_preds.h. Make the naming scheme of their
arguments more regular.
runtime/mercury_minimal_model.c:
runtime/mercury_tabling_preds.h:
Move the definition of a predicate from mercury_minimal_model.c
to mercury_tabling_preds.h, since the compiler now needs to be
able to generate an inlined version of it.
compiler/hlds_goal.m:
Replace the three existing fields describing the arguments of
foreign_procs with one, and add a new field describing the extra
arguments that may be inserted by table_gen.m.
Add utility predicates for processing the arguments of foreign_procs.
Change the order of some existing groups of declarations make it
more logical.
compiler/hlds_pred.m:
runtime/mercury_stack_layout.h:
Extend the data structures recording the structure of tabling tries
to allow the representation of trie steps for type_infos and
typeclass_infos.
runtime/mercury_tabling_macros.c:
Fix a bug regarding the tabling of typeclass_infos, which is now
required for a clean compile.
compiler/pragma_c_gen.m:
compiler/ml_code_gen.m:
Modify the generation of code for foreign_procs to handle extra
arguments, and to conform to the new data structures for foreign_proc
arguments.
compiler/llds.m:
The tabling transformations can now generate significantly sized
foreign_procs bodies, which the LLDS code generator translates to
pragma_c instructions. Duplicating these by jump optimization
may lose more by worsening locality than it gains in avoiding jumps,
so we add an extra field to pragma_c instructions that tells jumpopt
not to duplicate code sequences containing such pragma_cs.
compiler/jumpopt.m:
Respect the new flag on pragma_cs.
compiler/goal_util.m:
Add a predicate to create foreign_procs with specified contents,
modelled on the existing predicate to create calls.
Change the order of the arguments of that existing predicate
to make it more logical.
compiler/polymorphism.m:
Conform to the new definition of foreign_procs. Try to simplify
the mechanism for generating the type_info and typeclass_info
arguments of foreign_proc goals, but it is not clear that this
code is even ever executed.
compiler/aditi_builtin_ops.m:
compiler/assertion.m:
compiler/bytecode_gen.m:
compiler/clause_to_proc.m:
compiler/code_gen.m:
compiler/code_info.m:
compiler/code_util.m:
compiler/constraint.m:
compiler/deep_profiling.m:
compiler/deforest.m:
compiler/delay_construct.m:
compiler/dependency_graph.m:
compiler/det_analysis.m:
compiler/det_report.m:
compiler/dnf.m:
compiler/dupelim.m:
compiler/equiv_type_hlds.m:
compiler/exprn_aux.m:
compiler/follow_code.m:
compiler/follow_vars.m:
compiler/frameopt.m:
compiler/goal_form.m:
compiler/goal_path.m:
compiler/higher_order.m:
compiler/higher_order.m:
compiler/hlds_module.m:
compiler/hlds_out.m:
compiler/inlining.m:
compiler/ite_gen.m:
compiler/layout_out.m:
compiler/livemap.m:
compiler/liveness.m:
compiler/llds_out.m:
compiler/loop_inv.m:
compiler/magic.m:
compiler/make_hlds.m:
compiler/mark_static_terms.m:
compiler/middle_rec.m:
compiler/modes.m:
compiler/modules.m:
compiler/opt_debug.m:
compiler/pd_cost.m:
compiler/prog_rep.m:
compiler/purity.m:
compiler/quantification.m:
compiler/reassign.m:
compiler/rl_exprn.m:
compiler/saved_vars.m:
compiler/simplify.m:
compiler/size_prof.m:
compiler/store_alloc.m:
compiler/stratify.m:
compiler/switch_detection.m:
compiler/term_pass1.m:
compiler/term_traversal.m:
compiler/termination.m:
compiler/trace.m:
compiler/typecheck.m:
compiler/unify_proc.m:
compiler/unique_modes.m:
compiler/unneeed_code.m:
compiler/unused_args.m:
compiler/use_local_vars.m:
Conform to the new definition of foreign_procs, pragma_cs and/or
table trie steps, or to changed argument orders.
compiler/add_heap_ops.m:
compiler/add_trail_ops.m:
compiler/cse_detection.m:
compiler/dead_proc_elim.m:
compiler/equiv_type.m:
compiler/intermod.m:
compiler/lambda.m:
compiler/lco.m:
compiler/module_util.m:
compiler/opt_util.m:
compiler/stack_opt.m:
compiler/trans_opt.m:
Conform to the new definition of foreign_procs.
Bring these modules up to date with our current code style guidelines,
using predmode declarations, state variable syntax and unification
expressions as appropriate.
compiler/mercury_compile.m:
Conform to the changed argument order of a predicate in trans_opt.m.
compiler/options.m:
Add the --no-tabling-via-extra-args option, but leave the
documentation commented out since the option is for developers only.
doc/user_guide.texi:
Document --no-tabling-via-extra-args option, though leave the
documentation commented out since the option is for developers only.
doc/user_guide.texi:
doc/mdb_categories:
Document the new goal_paths mdb command.
trace/mercury_trace_internals.c:
Implement the new goal_paths mdb command.
tests/debugger/completion.exp:
Conform to the presence of the goal_paths mdb command.
tests/debugger/mdb_command_test.inp:
Test the existence of documentation for the goal_paths mdb command.
tests/debugger/print_table.{inp,exp*}:
tests/debugger/retry.{inp,exp*}:
Use the goal_paths command to avoid having the expected output
depend on the presence or absence of --tabling-via-extra-args.
tests/tabling/table_foreign_output.{m,exp}:
Add a new test case to test the save/restore of arguments of foreign
types.
tests/tabling/Mmakefile:
Enable the new test case.
tests/tabling/test_tabling:
Make this script more robust.
Add an option for testing only the standard model forms of tabling.
|
||
|
|
cc508c83de |
Perform frame optimization on nondet predicates.
Estimated hours taken: 6 Branches: main Perform frame optimization on nondet predicates. The need for this was revealed by benchmarking in Uppsala, which initially showed Mercury to take three to five times as long as XSB on some tabling benchmarks. One major contributor was the fact that the predicate returning answers out of answer table was creating and destroying a nondet stack frame for every answer it returned. To make this change easier, make the representation of labels more reader friendly, classifying them primarily on whether they represent entry or internal labels, and only secondarily on the scope in which they represent valid references to the label. compiler/frameopt.m: Add a predicate to perform frame optimization on model_non predicates. This optimization involves separating the steps of creating the frame (done once) and setting the redoip (potentially done on every iteration). compiler/optimize.m: Invoke this new predicate. Reorder the arguments of predicates in this file, and the top level predicates of the optimizations it invokes, to allow the use of state variable notation. runtime/mercury_stacks.h: Provide macros for creating nondet stack frames that do not fill in the redoip slot. compiler/llds.m: Make the setting of redoip optional in mkframe operations. Make the representation of labels more reader friendly. compiler/layout_out.m: Change the representation of label layouts to enforce the invariant that these can refer only to internal labels. (The layout structures of entry labels are proc layout structures, whose design enforces the relevant invariant already.) compiler/jumpopt.m: Add an optimization that improves code that matches a new pattern: % Attempt to transform code such as % % if (Cond) L1 % goto L2 % % into % % if (! Cond) L2 % <code at L1> % % when we know the code at L1 and don't know the code at L2. The new frame optimization creates instances of this pattern, usually with L2 being do_fail. compiler/*.m: Minor diffs to conform to the changes above. |
||
|
|
642c902c90 |
Reduce the sizes of .c and .o files in debug grades by 8%.
Estimated hours taken: 4
Branches: main
Reduce the sizes of .c and .o files in debug grades by 8%.
Add to mdb the capability of putting breakpoints on unify, compare and index
predicates.
compiler/code_gen.m:
Since compiler-generated unify, index and compare pred can be presumed
to be correct, compile them with shallow tracing instead of deep
tracing even if the user asks for deep tracing of the rest of the
module. This saves disk space, compile time and run time.
Move the code for setting the trace level to generate_proc_code,
where it is executed whether we generate code by predicates or by
phases.
compiler/trace_params.m:
Provide a function for use by code_gen.m.
Consider unify and compare predicates to behave as if their address
were taken, since they may be called from builtin.unify or
builtin.compare.
compiler/jumpopt.m:
Do not replace jumps with the block being jumped to if the block
contains an instruction that represents a call to the debugger.
In such cases, the jump is a minor cost in runtime compared to the
call, and the locality benefit from not increasing the code size is
quite likely to exceed that cost.
compiler/llds.m:
Add field names to pragma_c instructions to make the change to jumpopt
easier.
tests/debugger/uci.{inp,exp}:
Update this test case. An update is required since we now generate
fewer events from unify and compare preds due to their now being
shallow traced.
To make this the update easier, use the new capability of putting
breakpoints on unify and compare predicates.
trace/mercury_trace_tables.[ch]:
Expand procedure specifications to allow the specification of unify,
compare and index predicates, and expand the function that checks for
matches between a procedure layout and a procedure specification
accordingly.
Fix two instances of a bug: if a procedure specification has no name,
represent it as NULL, not as a non-NULL pointer to a null character,
since the match function expects only the former.
doc/user_guide.texi:
Document the new definition of procedure specifications.
NEWS:
Mention the new definition of procedure specifications, and expand
on some previous additions to the debugger.
runtime/mercury_stack_trace.c:
Allow mdb breakpoint specifications on uci predicates to be saved.
Factor out some common data structure accesses.
runtime/mercury_proc_id.h:
Change the name of a macro from MR_PROC_ID_COMPILER_GENERATED to
MR_PROC_ID_IS_UCI, for consistency with other names dealing with
unify, compare and index predicates.
runtime/*.[ch]:
trace/*.[ch]:
Conform to the change in mercury_proc_id.h.
|
||
|
|
c80d143cc8 |
The following change is only 98% complete, not 100%.
Estimated hours taken: 120
Branches: main
The following change is only 98% complete, not 100%. I am committing it in
this state because (1) we pass many more test cases in deep profiling grade
with it than without it, and (2) the double maintanance involved in fixing
CVS conflicts is preventing me from doing the last 2%.
Get the deep profiler to work for code that sets up to catch exceptions,
which for the last year or more has included the compiler, and to get it
almost working for code that actually catching exceptions.
The basic problem is that code that throws exceptions will in general cause
several calls to "return" without executing the exit or fail port codes that
the deep profiling transformation inserted into their bodies, and this leaves
the data structure being built by the deep profiling inconsistent. The solution
uses the same approach as we have adopted for the debugger: have the code that
handles the throwing of exceptions simulate a return from each call between
the throw and the catch, updating the deep profiling data structures as needed.
This requires us to be able to walk the stack at runtime not just in debugging
grades but also in deep profiling grades. Since the debugger already has the
mechanisms required for this, we reuse them. The procedure layouts used by the
debugger were designed to have three segments: the procedure stack walk
information, the procedure id, and the execution tracing information. We now
modify this design to make the third segment contain two pointers: to the
execution tracing information (for use by the debugger), and to the procedure's
proc_static structure (for use by deep profiling). Each pointer will be null
unless the pointed-to structure is required by compile-time options.
This common use by the debugger and by deep profiling of the stack-walk
structure and the procedure id structure (which deep profiling used to
generate independently and possibly redundantly) required some rearrangement
of the compiler's version of these data structures.
To make this rearrangement simpler, this diff removes a capability that
we theoretically supported but never used: turning on stack traces without
turning on execution tracing and vice versa. After this diff, stack tracing
is enabled if and only if either execution tracing or deep profiling is
enabled.
The diff also includes improvements in the debugging infrastructure for
debugging deep profiling, which were necessary for the implementation of the
rest of the changes.
compiler/deep_profiling.m:
The code in exception.m needs to know the locations of the variables
that we would pass to the exit or fail port code, so it can simulate
leaving the procedure invocation through the exception port. Without
this information, throwing an exception leaves the deep profiling
data structures of the procedure invocations between throw and catch
in an inconsistent state.
Deep_profiling.m creates these variables, but it doesn't know where
they will be at runtime, so it records their identities; the code
generator will allocate them stack slots and record the numbers of
these stack slots for placement in the now expanded proc layout
structures. Deep profiling used to generate static data structures
separately from the HLDS, but since the code generator now needs
access to them, we store their information in proc_infos in the HLDS.
Instead of passing the addresses of proc_static structures to the deep
profiling port procedures, pass the address of proc_layout structures,
since the information about the identities of procedures are now stored
not in the proc_static structure, but in the proc_layout structure
that points to the proc_static structure.
compiler/hlds_pred.m:
compiler/layout.m:
Move the definitions of the static data structures generated by deep
profiling from layout.m to hlds_pred.m, to allow deep_profiling.m
to store them in proc_infos.
compiler/hlds_pred.m:
compiler/rtti.m:
Move the definition of rtti_proc_label from rtti.m to hlds_pred.m,
since some of the new data structures in hlds_pred.m need it. Despite
its name, the rtti_proc_label type doesn't contain any info that
doesn't belong in the HLDS.
Add some information to the rtti_proc_label type that is now needed
by deep profiling, e.g. record determinisms instead of just code
models. Record explicitly the outcome of some tests that used to be
duplicated in more than one place in the compiler, e.g. for whether
the procedure (as opposed to the predicate) is imported. Change some
of the field names to be more precise about the field's meaning.
compiler/code_gen.m:
Transmit the contents of the deep profiling data structures stored in
the proc_info by deep_profiling.m to continuation_info.m, together
with the layout structures created for execution tracing and the
identities of the variables needed for handling exceptions,
when code generation for a procedure is complete.
After the goal that generates these variables, save them to stack
for use by the exception handler.
compiler/hlds_goal.m:
Add a feature to mark the goal that generates the deep profiling
variables needed by the exception handler.
compiler/hlds_llds.m:
Add a utility predicate for new code in code_gen.m
compiler/continuation_info.m:
Hold the deep profiling information computed by code_gen.m for use by
stack_layout.m.
compiler/layout.m:
compiler/layout_out.m:
Update the definitions of the data structures describing procedure
layouts, and the code writing them out, to reflect the use of some
parts of procedure layouts by deep profiling as well as debugging.
Change the layout structures generated by deep profiling to use
rtti_proc_labels, which are backend independent, instead of
proc_labels, which are specific to the LLDS backend.
Conform to the changes in runtime/mercury_stack_layout.h.
compiler/stack_layout.m:
Generate the updated version of proc_layout structures.
compiler/mercury_compile.m:
compiler/global_data.m:
Conform to the fact that deep profiling no longer generates layout
structures separate from proc_infos.
compiler/llds_out.m:
Register proc_layout structures instead of proc_static structures
for use by runtime/mercury_deep_profiling.c.
compiler/options.m:
compiler/handle_options.m:
Rename the require_tracing option as exec_trace, since this more
directly reflects its meaning.
Instead of having --debug set both require_tracing and stack_trace,
make it set (be the user-visible name of) just exec_trace;
the value of stack_trace is implied.
Turn off the specialization of deep profiling for self-tail-recursive
procedures for now. Due to the changes made by this diff in the data
structures involved in debugging, it cannot be debugged until this
change has been installed. Handling the full language is more important
than a specialization that reduces only stack space overheads, not
runtime overheads.
compiler/compile_target_code.m:
Conform to the changes in options.m and runtime/mercury_grade.h.
compiler/hlds_data.m:
Replace the deep_profiling_proc_static cons_id, and its associated tag,
to deep_profiling_proc_layout, since we now generate addresses of proc
layout structures, not of proc_static structures.
compiler/code_util.m:
Simplify some code based on the new info in rtti_proc_labels.
compiler/bytecode_gen.m:
compiler/dependency_graph.m:
compiler/higher_order.m:
compiler/hlds_out.m:
compiler/mercury_to_mercury.m:
compiler/ml_code_util.m:
compiler/ml_unify_gen.m:
compiler/opt_debug.m:
compiler/proc_label.m:
compiler/prog_rep.m:
compiler/rl_exprn.m:
compiler/rtti_out.m:
compiler/rtti_to_mlds.m:
compiler/saved_vars.m:
compiler/switch_util.m:
compiler/unify_gen.m:
Minor changes to conform to the change from deep_profiling_proc_static
to deep_profiling_proc_layout, to the change in the structure of
rtti_proc_labels, to the changes in types of layout.m, and/or to the
new goal feature.
deep_profiler/measurements.m:
Reserve space for exception counts.
deep_profiler/html_format.m:
Add a column for exception counts.
deep_profiler/profile.m:
deep_profiler/read_profile.m:
Rename the data structures referring to compiler generated unify,
compare and index predicates to avoid misleading names: they are
not the only compiler generated predicates.
deep_profiler/read_profile.m:
runtime/mercury_deep_profiling.c:
Update the string that identifies deep profiling data files.
This is necessary because the format has changed: it now includes
information about exception port counts.
library/exception.m:
In deep profiling grades, execute the exception port code for every
procedure invocation between a throw and a catch, using the procedure
layout structures now generated by the compiler for every procedure.
Rename the function involved to reflect its new, more general purpose.
Update the definitions of the hand-written proc_static and proc_layout
structures for the procedures implemented via hand-written C code.
Indent C preprocessor directives and foreign_procs according to our
coding standards.
library/profiling_builtin.m:
Change the parameters of the call port code procedures from proc_static
to proc_layout. Reach the proc_static structure from the proc_layout
structure when needed. Include the proc_layout structure in any
messages from assertion failures.
Add some conditionally compiled debugging code.
Give some variables better names.
runtime/mercury_type_info.h:
runtime/mercury_builtin_types.c:
Move the macros required to create the proc_static structures
of unify and compare predicates from mercury_type_info.h
to mercury_builtin_types.c, since the latter is the only file
that needs them.
Use the same macros for creating the proc_static structures
of hand-written unify, compare and compare_reprentation predicates
as for user defined predicates. This required changing their naming
scheme.
runtime/mercury_unify_compare_body.h:
Conform to the new naming scheme.
runtime/mercury_ho_call.c:
Provide the mechanism for mercury_unify_compare_body.h to conform
to the new naming scheme.
Remove the definitions of the proc_static structures for
hand-written unify, compare and compare_reprentation predicates,
since these now have to be defined together with the corresponding
proc_layout structures in mercury_builtin_types.c.
runtime/mercury_builtin_types.[ch]:
Update the definitions of the hand-written proc_static and proc_layout
structures for the procedures implemented via hand-written C code,
and add the required declarations first.
Handle deep profiling of compare_representation as well as unify
and compare predicates on builtin types.
Handle deep profiling of compare_representation on user-defined types,
since this is done entirely in the runtime, not by compiler generated
predicates.
runtime/mercury_builtin_types_proc_layouts.h:
New header file containing the declarations of the proc layout
structures of the unify, compare and index predicates of builtin types.
Logically, these declarations belong in mercury_builtin_types.h,
but putting them there causes problems for the linker; the details
are explained in the file itself.
runtime/Mmakefile:
Add the new header file.
runtime/mercury_minimal_model.[ch]:
Update the definitions of the hand-written proc_static and proc_layout
structures for the procedures implemented via hand-written C code,
and add the required declarations first.
runtime/mercury_grade.h:
Replace the MR_REQUIRE_TRACING grade option with MR_EXEC_TRACING.
Besides being better named, the MR_EXEC_TRACING option implies
MR_STACK_TRACE.
Besides the overall binary compatibility version number, add subsidiary
version numbers for binary compatibility in deep profiling and
debugging grades. These will make it easier to bootstrap changes
(such as this) that affect binary compatibility only in such grades.
runtime/mercury_trace_base.c:
trace/mercury_trace.c:
Conform to the new names of the configuration parameters.
runtime/mercury_hand_compare_body.h:
runtime/mercury_hand_unify_body.h:
runtime/mercury_hand_unify_compare_body.h:
runtime/mercury_ho_call.c:
tools/make_port_code:
Pass proc_layout structures instead of proc_static structures
to deep profiling port routines.
runtime/mercury_conf_param.h:
Make MR_DEEP_PROFILING as well as MR_EXEC_TRACING imply MR_STACK_TRACE,
since deep profiling now needs stack tracing. (MR_STACK_TRACE needs
to be set in this file, because tests in this file depend on knowing
its value, and this file is among the first files included (in this
case indirectly) in mercury_imp.h.)
Document the macros controlling the debugging of deep profiling.
Enable printing of label names when the relevant deep profiling
debugging macro is set.
runtime/mercury_debug.c:
runtime/mercury_deep_rec_depth_actions.h:
runtime/mercury_deep_rec_depth_body.h:
runtime/mercury_exception_catch_body.h:
Get to proc_statics via proc_layouts.
runtime/mercury_deep_call_port_body.c:
runtime/mercury_deep_leave_port_body.c:
Get to proc_statics via proc_layouts.
Allow the debugger to disable deep profiling in Mercury code that is
part of the debugger, not of the user program being executed.
Add some more assertions.
runtime/mercury_engine.[ch]:
Add a new debugging flag that controls at runtime whether we generate
a human readable Deep.debug equivalent to the binary Deep.data files.
(We already had a mechanism for controlling this at compile time,
but this isn't flexible enough.)
runtime/mercury_wrapper.c:
Allow this new debugging flag to be set from MERCURY_OPTIONS.
runtime/mercury_deep_profiling.[ch]:
Respect this new debugging flag.
Update the hand-written proc_static structures representing the runtime
system.
Print out addresses of proc_layout as well as proc_static structures
when assertions fail.
Add a field to the measurement structure for exception port counts,
and write out this field with the other port counts.
Remove procedure id information from proc_static structures,
deep profiling now uses the procedure id in the proc_layout structure.
Add to proc_static structures fields that specify where, if anywhere,
the variables needed by exception.m to executed the exception port code
are in the procedure's stack frame.
Define a global flag that allows the debugger to disable deep
profiling in Mercury code that is part of the debugger, not of the
user program being executed.
Increase type safety by providing two versions of the function
for registering proc_layouts, one for the proc_layout structures
of user-defined predicates and one for unify, compare and index
predicates.
Fix a bug that occurs only if MR_DEEP_PROFILING_EXPLICIT_CALL_COUNTS is
defined (which it usually isn't): the initial call count was wrong.
runtime/mercury_deep_profiling_hand.h:
Fix a bug: the handwritten code saving deep profiling variables was
saving them in slots that didn't belong to the relevant stack frame.
Update to conform to the modified definitions of proc_static structures
and the fact that we now reach them via proc_layout structures.
runtime/mercury_exception_catch_body.h:
runtime/mercury_stacks.h:
Fix the other side of the bug in mercury_deep_profiling_hand.h
by reserving the right number of stack slots in the stack frames
of the various modes of exception__catch. Make it harder to make
the same bug in the future by getting the needed info from the
place in mercury_stacks.h that defines the structure of the relevant
stack frame.
runtime/mercury_proc_id.h:
Rename the procedure id structure fields referring to compiler
generated unify, compare and index predicates: they are not the only
compiler-generated predicates.
runtime/mercury_stack_layout.h:
Change procedure layout structures to allow them to be used for deep
profiling as well as for debugging, as described in the prologue above.
We don't need the capability to support label layout structures with
links to misnamed proc layout structures, and supporting it is
inconvenient, so delete the capability.
runtime/mercury_debug.c:
runtime/mercury_deep_profiling_hand.h:
runtime/mercury_layout_util.c:
runtime/mercury_ml_expand_body.h:
runtime/mercury_stack_trace.c:
runtime/mercury_types.h:
trace/mercury_trace_external.c:
Conform to the new names of the procedure id structure fields.
runtime/mercury_std.h:
Add some more arities for MR_PASTE for use in some of the modified
modules in the runtime.
trace/mercury_trace_internal.c:
Disable deep profiling actions in Mercury code that is part of the
debugger, not of the program being debugged.
scripts/init_grade_options.sh-subr:
scripts/parse_grade_options.sh-subr:
Make changes parallel to the ones in runtime/mercury_grade.h: delete
--stack-trace as an independent option, and make --debug set its
own option, not --require-tracing.
scripts/canonical_grade.sh-subr:
scripts/final_grade_options.sh-subr:
scripts/c2init.in:
scripts/mgnuc.in:
scripts/ml.in:
Conform to the changes in grade options for debugging and for deep
profiling.
tools/bootcheck:
If Mmake.stage.{browser,deep,library,runtime,trace}.params exist,
copy them to become the file Mmake.$dir.params in stage2/$dir
(where dir is derived from the name of the original file in the obvious
way). This allows more flexibility in the creation of the stage2;
for example, it allows some directories (e.g. runtime or library)
to be compiled with more debugging than other directories (e.g.
compiler). This may be required because compiling all directories
with lots of debugging may cause the linker to thrash.
Add an option, --disable-debug-libs, that clobbers the libraries
that should be linked in only in debugging grades.
To conserve disk space, remove Deep.data files created by the bootcheck
by default. Add an option, --keep-deep-data, to preserve these files.
Use a consistent mechanism (test -f) for testing the existence of
all files whose existence is tested.
When recording modification times, record the modification times
of some more files.
tests/hard_coded/Mmakefile:
In deep profiling grades, disable the test cases that we don't now
pass in such grades, and document the reasons for their failure.
Fix the misclassification of the write_binary test case.
|
||
|
|
bd1ea24cc3 |
Remove the dependence of this module on ll_backend.llds by defining
Estimated hours taken: 6 Branches: main compiler/hlds_llds.m: Remove the dependence of this module on ll_backend.llds by defining types using abstract descriptions of LLDS storage locations. These have the added advantage that they express the intent of the affected data structures more directly. For example, the stack slot type used to be able to map a variable to a register or to a field of a cell on the heap, which doesn't make sense. This is no longer the case. The cost of the conversion operations now required is partly paid for by our new ability to avoid some old sanity checks. compiler/llds.m: compiler/code_util.m: Add some utility predicates to operate on the new data structures. compiler/code_aux.m: compiler/code_gen.m: compiler/code_info.m: compiler/continuation_info.m: compiler/follow_vars.m: compiler/lookup_switch.m: compiler/par_conj_gen.m: compiler/stack_alloc.m: compiler/store_alloc.m: compiler/var_locn.m: Conform to the changes in hlds_llds.m. In some cases, improve the style of the affected predicates, e.g. by introducing state variable syntax. compiler/hlds_out.m: Conform to the changes in hlds_llds.m, and avoid importing ll_backend. |
||
|
|
ff60134ee9 |
Bring these modules up to our current coding standards.
Estimated hours taken: 8 Branches: main analysis/analysis.m: browser/browse.m: compiler/accumulator.m: compiler/assertion.m: compiler/atsort.m: compiler/c_util.m: compiler/check_typeclass.m: compiler/clause_to_proc.m: compiler/code_gen.m: compiler/code_model.m: compiler/const_prop.m: compiler/constraint.m: compiler/dead_proc_elim.m: compiler/delay_construct.m: compiler/dependency_graph.m: compiler/det_analysis.m: compiler/det_report.m: compiler/export.m: compiler/fact_table.m: compiler/follow_code.m: compiler/graph_colour.m: compiler/hlds_module.m: compiler/inlining.m: compiler/llds.m: compiler/make_hlds.m: compiler/mercury_to_mercury.m: compiler/ml_tailcall.m: compiler/ml_unify_gen.m: compiler/mmc_analysis.m: compiler/mode_errors.m: compiler/passes_aux.m: compiler/post_typecheck.m: compiler/size_prof.m: compiler/switch_util.m: compiler/table_gen.m: compiler/term_errors.m: compiler/transform_llds.m: compiler/type_util.m: compiler/unify_gen.m: compiler/unneeded_code.m: compiler/unused_args.m: Bring these modules up to our current coding standards. Use predmode declarations and state variable syntax where relevant. Reorder arguments where this is needed for the use state variables. Make the orders of predicate definitions correspond to the order of their declarations. Replace some overly large lambda expressions with named predicates. Convert some predicates to functions where this makes their use more convenient. Use field access notation where convenient. Fix any inconsistent indentation. Remove module prefixes on predicate names where this is necessary to allow sane indentation. In several places, use predicates from error_util.m to print error messages. Apart from this, there are no changes in algorithms. In some places, conform to the changes below. compiler/error_util.m: compiler/hlds_error_util.m: Add new variants of existing predicates for use in some of the changed modules above. compiler/hlds_out.m: Add some functions to convert values of some HLDS types as strings, for use in preparing the arguments of the new calls to predicates in error_util.m. Change the implementations of the predicates that print values of those types to call those functions instead of allowing code duplication. compiler/llds.m: Add some field names to allow use of field updates where relevant. tests/invalid/assert_in_interface.err_exp: tests/invalid/multisoln_func.err_exp: tests/invalid/tricky_assert1.err_exp: Update the expected outputs of these test cases to allow for them being generated by error_util.m, and hence being better formatted than before. |
||
|
|
5d6fd3bd6f |
Reduce the dependence of earlier parts of the compiler on the later ones.
Estimated hours taken: 4 Branches: main Reduce the dependence of earlier parts of the compiler on the later ones. Unnecessary import_module declarations in top level modules such as hlds.m cause unnecessary recompilations when adding new types in later modules, such as submodules of ll_backend.m. This change reduces the number of such unnecessary imports. There are no changes in algorithms, only functionality being moved around. compiler/code_model.m: Change this module from being a submodule of backend_libs.m to being a submodule of hlds.m, since nothing in it is dependent on any backend. compiler/arg_info.m: compiler/code_util.m: Change arg_info.m from being a submodule of ll_backend.m to being a submodule of hlds.m, since most of it is applicable to all current and foreseeable backends. Move the one exported predicate that is ll_backend dependent, and its support predicates, to code_util.m. compiler/backend_libs.m: compiler/ll_backend.m: compiler/hlds.m: Update include_module declarations in accordance with the above. compiler/prog_data.m: compiler/term_util.m: Instead of defining two separate types for holding argument size and termination information, one including HLDS-specific information (in term_util.m) and one not (in prog_data.m), use a polymorphic type defined in prog_data.m and two monomorphic instances. compiler/termination.m: compiler/mercury_to_mercury.m: Change the predicates for writing out argument size and termination information to handle the polymorphic type (we don't need special handling of the monomorphic versions), and move them from termination.m to mercury_to_mercury.m, since this allows us to avoid some undesirable dependencies. compiler/base_typeclass_info.m: compiler/hlds_code_util.m: Move the predicate make_instance_string from base_typeclass_info.m to hlds_code_util.m, again because it allows us to remove some undesirable dependencies. compiler/top_level.m: compiler/backend_libs.m: compiler/check_hlds.m: compiler/hlds.m: compiler/ll_backend.m: compiler/parse_tree.m: compiler/transform_hlds.m: Delete some import_module declarations of other top level modules in these top level modules. Some imports were totally unnecessary. Some imports were useful in only a small minority of submodules; those submodules now import the necessary top level modules directly. Move remaining import_module declarations to the implementation section where this is feasible. Where we still need to import modules we ideally shouldn't, note why. compiler/*.m: Update imports of code_util and arg_info. In some cases, import top level modules no longer imported by the parent module. In some cases, delete unnecessary imports. |
||
|
|
6ac84aac9f |
Bring these modules up to date with our current code style.
Estimated hours taken: 4 Branches: main compiler/code_util.m: compiler/fact_table.m: compiler/make_tags.m: compiler/type_ctor_info.m: compiler/unify_proc.m: Bring these modules up to date with our current code style. Use predmode declarations and state variable syntax where appropriate, and reorder arguments where this is needed to use state variable syntax. Break up excessively large and/or excessively indented predicates. Factor out common code and fix indentation. Use error_util to print error messages where appropriate. In fact_util.m, change predicates that took I/O state arguments to print error messages to return a list of error reports instead, to be printed by an ancestor. This makes it clearer which parts of the module actually have file I/O as part of their main job. compiler/special_pred.m: Shorten an excessively long predicate name, since without this some of the above modules cannot be indented properly. compiler/make_hlds.m: Use the new shorter predicate name. compiler/code_gen.m: compiler/ml_code_util.m: Fix indentation. compiler/hlds_out.m: Add a predicate for use by the new version of fact_table.m |
||
|
|
fa9ca36d03 |
This diff makes several files easier to read and to maintain (as well as
Estimated hours taken: 5 Branches: main This diff makes several files easier to read and to maintain (as well as more than 400 lines shorter), but contains no changes in algorithms whatsoever. compiler/deep_profiling.m: compiler/foreign.m: compiler/hlds_module.m: compiler/hlds_data.m: compiler/make_hlds.m: compiler/post_typecheck.m: compiler/prog_data.m: compiler/purity.m: compiler/type_util.m: Bring these modules into line with our current coding standards. Use predmode declarations and state variable syntax when appropriate. Reorder arguments of predicates where necessary for the use of state variable syntax, and where this improves readability. Replace predicates with functions where appropriate. Standardize indentation. compiler/*.m: Conform to the changes above. |
||
|
|
b39a3d855f |
This diff makes hlds_module.m and many callers of its predicates easier to read
Estimated hours taken: 6 Branches: main This diff makes hlds_module.m and many callers of its predicates easier to read and to maintain, but contains no changes in algorithms whatsoever. compiler/hlds_module.m: Bring (most of) this module into line with our current coding standards. Use predmode declarations, functions, and state variable syntax when appropriate. (The 'most of' is because I left the part of the module dealing with predicate tables alone, not wishing to cause a conflict for Pete.) Reorder arguments of predicates where necessary for the use of state variable syntax, and where this improves readability. Replace old-style lambdas with new-style lambdas or with partially applied named procedures. compiler/*.m: Conform to the changes in hlds_module.m. This mostly means using the new argument orders of predicates exported by hlds_module.m, and switching to state variable notation. Replace old-style lambdas with new-style lambdas or with partially applied named procedures in updated code. Replace unnecessary occurrences of four-space indentation with standard indentation in updated code. library/list.m: library/map.m: library/tree234.m: Add list__foldl4 and map__foldl3, since in some compiler modules, state variable notation is more convenient (and the code more efficient) if we don't have to bundle up several data structures into a tuple just to iterate over them. Change the fold predicates to use state variable notation. NEWS: Mention the new library functions. |
||
|
|
c8e4004825 |
This diff makes code_info.m and many callers of its predicates easier to read
Estimated hours taken: 4 Branches: main This diff makes code_info.m and many callers of its predicates easier to read and to maintain, but contains no changes in algorithms whatsoever. compiler/code_info.m: Bring this module into line with our current coding standards. Use predmode declarations, functions, and state variable syntax when appropriate. Reorder arguments of predicates where necessary for the use of state variable syntax, and where this improves readability. Where a predicate returned its input code_info unchanged, purely to allow the convenient use of DCG notation in the caller, delete the unnecessary output argument. This should make the caller somewhat more efficient, since it can avoid updating the stack slot holding the current code_info. Replace old-style lambdas with new-style lambdas or with partially applied named procedures. compiler/*.m: Conform to the changes in code_info.m. This mostly means using the new argument orders of predicates exported by hlds_pred.m, and using state variable notation. |
||
|
|
8693e293a2 |
This diff makes hlds_pred.m and many callers of its predicates easier to read
Estimated hours taken: 4 Branches: main This diff makes hlds_pred.m and many callers of its predicates easier to read and to maintain, but contains no changes in algorithms whatsoever. compiler/hlds_pred.m: Bring this module into line with our current coding standards. Use predmode declarations, functions, and state variable syntax when appropriate. Reorder arguments of predicates where necessary for the use of state variable syntax, and where this improves readability. Replace old-style lambdas with new-style lambdas or with partially applied named procedures. Standardize indentation. compiler/*.m: Conform to the changes in hlds_pred.m. This mostly means using the new argument orders of predicates exported by hlds_pred.m. Where this is now conveniently possible, change predicates to use state variable notation. In some modules, using state variable notation required changing the orders of arguments in the module's top predicate. compiler/passes_aux.m: Change the order of arguments in the calls this module makes to allow the callees to use state variable notation. Convert this module to state variable notation too. |
||
|
|
599ef915d9 |
Instead of being relied on all over the place, centralize the compiler's
Estimated hours taken: 16 Branches: main Instead of being relied on all over the place, centralize the compiler's knowledge of the names of unify, compare and index predicates in one place, special_pred.m. This should make it easy to change the naming scheme once we switch over to compiler-generated type_ctor_infos for builtin types, which will eliminate the runtime system's knowledge of the naming scheme. compiler/hlds_pred.m: Add a field to pred_infos that says whether the predicate is a unify, compare or index predicate, and if so, for which type constructor. Code that used to test the predicate's name for __Unify__ etc now tests this field instead. Similarly the code that used to employ devious tricks to find out the type the unify/compare/index predicate is for. compiler/rtti.m: Include this field in rtti_proc_labels as well as pred_infos. compiler/make_hlds.m: Fill in this field as appropriate. compiler/proc_label.m: Replace the predicate name with special_pred_id in the proc_labels of unify, index and compare preds. compiler/special_pred.m: Narrow the interface to prevent reliance on the naming scheme for compiler-generated unify, compare and index predicates, except when absolutely necessary, i.e. when creating names for them. Narrow the mechanism required to reverse-engineer the type constructor a unify/compare/index predicate is for from the types to the functionality required by higher_order.m. compiler/code_gen.m: compiler/det_report.m: compiler/higher_order.m: compiler/intermod.m: compiler/layout_out.m: compiler/magic_util.m: compiler/ml_code_util.m: compiler/name_mangle.m: compiler/opt_debug.m: compiler/opt_util.m: compiler/optimize.m: compiler/polymorphism.m: compiler/post_typecheck.m: compiler/proc_label.m: compiler/rl_exprn.m: compiler/rl_key.m: compiler/simplify.m: compiler/termination.m: compiler/typecheck.m: compiler/unify_proc.m: compiler/unused_args.m: Update code and comments to conform to the changes above. compiler/hlds_out.m: Don't refer to the 'type' that a unify, compare or index predicate is for; refer to the type *constructor*. compiler/mlds_to_java.m: Delete an unused predicate. tests/invalid/purity/purity.err_exp: Update this expected output for the change in hlds_out.m. |
||
|
|
6554ef7daa |
Replace "is" with "=".
Estimated hours taken: 2 Branches: main Replace "is" with "=". Add field names where relevant. Replace integers with counters where relevant. |
||
|
|
d63cd1d055 |
Fix test case failures in tests/tabling in asm_fast.gc.mm.
Estimated hours taken: 0.5 Branches: main Fix test case failures in tests/tabling in asm_fast.gc.mm. These were caused by the fact that my recent change to table_gen.m always stored the call table tip variable in proc_infos, not just when debugging was enabled; however we reserved a stack slot for this variable only when debugging was enabled. compiler/code_gen.m: Change the code to avoid relying the call table tip slot in proc_infos being set only when debugging is enabled. compiler/hlds_pred.m: Change the documentation of the slot to allow it to be set even if debugging is not enabled, since this may come in handy in the future. |
||
|
|
92045bdc78 |
Simplify the handling of static ground terms in the LLDS backend.
Estimated hours taken: 5 Branches: main Simplify the handling of static ground terms in the LLDS backend. Instead of creating code, rtti and layout structures all containing create rvals and then converting those rvals to static cells, create the static cells directly. compiler/llds.m: Remove the create alternative from rvals, and the types used only by create. Delete the code handling the global_data type, which has been moved to global_data.m. compiler/global_data.m: A new module handling static data structures for the LLDS backend. The basis of this module is the code that used to be in llds.m handling the global_data type, but this has been augmented to manage static cells as well as the data structures defined in rtti.m and layout.m. Also, rename the non_common_data field of global_data, which no longer makes sense, to refer to deep profiling, since it holds deep profiling data structures. compiler/llds_common.m: Delete this file, since it is no longer needed. The operative part is now in global data.m; the rest (including the code to traverse code and data structures looking for create rvals) is no longer needed. compiler/ll_backend.m: Delete the deleted module, and add the added module. XXX These changes should be also be documented in notes/compiler_design.html when Fergus finishes his changes to that file. compiler/code_info.m: Add the database of static cells to the code generator state. compiler/code_gen.m: compiler/ll_pseudo_type_info.m: compiler/lookup_switch.m: compiler/mercury_compile.m: compiler/stack_layout.m: compiler/static_term.m: compiler/string_switch.m: compiler/unify_gen.m: compiler/var_locn.m: Instead of creating create rvals, create static cells and return references to those cells. The static cell database ensures that we never create duplicate cells (unless --no-common-data forces us to do so). Pass around the static cell database. compiler/code_util.m: compiler/continuation_info.m: compiler/dupelim.m: compiler/exprn_aux.m: compiler/jumpopt.m: compiler/livemap.m: compiler/llds_out.m: compiler/middle_rec.m: compiler/opt_debug.m: compiler/opt_util.m: compiler/optimize.m: Minor changes to conform to the above, mostly consisting of the deletion of code that handled create rvals. |
||
|
|
9b0aa613c4 |
Delete the cell number field from create rvals, since we don't need
Estimated hours taken: 1 Branches: main compiler/llds.m: Delete the cell number field from create rvals, since we don't need it anymore. compiler/*.m: Conform to the change above, and simplify predicate interfaces by deleting arguments whose sole purpose was the allocation of cell numbers. |
||
|
|
f7dba9b8f8 |
Change "compiler_generated" in predicate names and field names
Estimated hours taken: 0.5 Branches: main compiler/*.m: Change "compiler_generated" in predicate names and field names to "is_unify_or_compare_pred", because that is the actual meaning of those predicates and fields. Delete the XXXs warning about the old misleading name. |
||
|
|
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. |