mirror of
https://github.com/Mercury-Language/mercury.git
synced 2026-04-22 04:43:53 +00:00
b357a3dadcdf29c8d8ca184d65f7634a1a94de36
2 Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
8b9d436cbb |
More improvements for minimal model tabling.
Estimated hours taken: 12
Branches: main
More improvements for minimal model tabling.
runtime/mercury_engine.[ch]:
Provide a debug flag to control the printing of debug stack slots
in nondet stack dumps.
runtime/mercury_stack_trace.[ch]:
Provide a mechanism that allows a dump of the nondet stack to print
the principal debugging stack slots of the stack frames of procedures
that were compiled with debugging, to help debug problems where
these are overwritten during stack segment saves/restores.
Add a mechanism for limiting the output of a nondet stack trace
to a segment of the nondet stack.
runtime/mercury_minimal_model.[ch]:
Limit the output of a diagnostic nondet stack trace to just the
segment being saved or restored.
Provide a label layout structure for the entry point of the suspend
predicate, since this is necessary for correct nondet stack traces
at suspensions and resumptions.
Store the layout structure of the top nondet stack frame with each
saved state, to allow the saved nondet stack segment to be dumped
at resumptions as well as suspensions.
Fix an old bug: when extending a saved stack segment, use the same
algorithm for determining its lower bound as when the stack segment
was created in the first place.
Factor out some repeated definitions.
Note problems to be fixed later.
Improve debugging output.
runtime/mercury_stacks.[ch]:
Move the documentation of the generator stack, the cut stack and the
pneg stack from the source file to the header file, and expand it
considerably.
Make the routines for printing entries of these stacks generate more
consistently formatted output.
Simplify some code.
runtime/mercury_stack_layout.h:
Provide a macro for use by mercury_minimal_model.c.
runtime/mercury_trace_base.[ch]:
Save and restore the global variables holding event numbers,
call sequence numbers and call depths across debugging Mercury code.
We already used to do this for Mercury code invoked by the debugger,
but now that we can invoke Mercury code to print the values of
variables as diagnostics from within the suspend and resume predicates
*outside* the debugger, we need to do it more generally.
trace/mercury_trace.c:
Fix a bug: provide the layout structure of the current procedure
to the diagnostic routines for minimal model tabling even if the
debugger doesn't stop at that procedure.
trace/mercury_trace_internal.c:
Add two new mdb commands to help debug minimal model tabling.
The "mm_stack" command has the same effect as the existing commands
"gen_stack", "cut_stack" and "pneg_stack" executed in sequence.
The "debug_vars" command prints the counters for event numbers,
call sequence numbers and call depths, both from their global variables
and their saved copies, for debugging problems where they are
overwritten, such as the one fixed by the changes to
mercury_trace_base.[ch] above.
Reorder some code for consistency.
trace/mercury_trace_util.[ch]:
Add a function to implement the "debug_vars" command.
doc/user_guide.texi:
Document the new mdb commands.
doc/mdb_categories:
Add the new mdb commands to the list of developer commands, as well
some others previously left out.
tests/debugger/mdb_command_test.inp:
Test the documentation of the new mdb commands.
tests/tabling/combine.m:
Change the code of this test case to what was intended, so that it now
matches the old expected output.
tests/tabling/completed_consumer_in_solutions.{m,exp}:
New test case, an easier version of consumer_in_solutions.
tests/tabling/consumer_in_commit.{m,exp}:
Extend this test case and update the expected output; we can execute
both the original code and the extension without runtime exceptions.
tests/tabling/seq2.m:
Fix Kostis's new test case.
tests/tabling/seq4.exp:
Fix the expected output of Kostis's new test case.
tests/tabling/Mmakefile:
Enable the new test cases, and some old test cases that we now pass.
|
||
|
|
dc03496d06 |
Rewrite significant parts of minimal model tabling so that it works
Estimated hours taken: 130
Rewrite significant parts of minimal model tabling so that it works
in a much wider variety of situations, including coups. Also, clean up
the tabling implementation to make it more maintainable, and introduce
a new grade component, .mm, that enables minimal model tabling.
(Minimal model tabling requires distributed fat, and we don't want to
incur such costs unless necessary.)
compiler/options.m:
Add a new option --use-minimal-model, which for now is documented
as "not for general use". This option is a grade option, and is
required if minimal model tabling is to work.
compiler/handle_options.m:
When --use-minimal-model is given, do not allow nondet frame hijacks,
since minimal model tabling cannot cope with hijacks.
Make --use-minimal-model a grade component.
compiler/code_info.m:
When --use-minimal-model is given, insert calls to MR_commit_{mark,cut}
around goals being committed across. This is now necessary, so that we
can detect and handle sitations where a goal being committed across
starts but does not complete a tabled goal.
compiler/table_gen.m:
Rename many of the tabling helper predicates, using a naming scheme
that separates predicates used for model_non procedures from those
used to implement simpler forms of tabling, while bringing out
the parallels between these two sets of predicates.
When calls to two tabling helper predicates always occur
one after the other, merge the two into one.
Generate and use more meaningful variable names; having all of the
several variables inserted by this transformation named TableVar
was quite confusing.
library/private_builtin.m:
Reorganize this file, to separate out the different sections.
The contents of the non-tabling sections were not modified, only
moved around.
Rename the predicates referred to by table_gen.m.
Move most of the type declarations and complex code out of here,
into runtime/mercury_tabling.c. This makes it easier to debug them,
since (a) creating a new executable is quicker, since you don't have
to wait for lots of mercury compiler invocations, and (b) gdb doesn't
get confused by #line directives. It also makes it easier to write
them, since you don't have to !&(*U&( remember to double all your
double quotes and to backslash all your backslashes.
runtime/mercury_grade.h:
Include a grade component reflecting whether MR_USE_MINIMAL_MODEL
is defined.
runtime/mercury_conf_param.h:
Document MR_USE_MINIMAL_MODEL.
runtime/mercury_stacks.[ch]:
The changes to tabling require the addition of two new stacks,
the generator stack and the cut stack. This module defines the
structures of the frames of these stacks and provides the
operations on these stacks.
The header file also contains some additional macros that return
the addresses of fixed nondet stack slots, not their contents,
for use by tabling code.
runtime/mercury_context.[ch]:
runtime/mercury_memory.[ch]:
runtime/mercury_wrapper.[ch]:
Declare and set up the two new stacks, both in saved contexts and in
the active context, if MR_USE_MINIMAL_MODEL is defined.
runtime/mercury_regorder.h:
Add four new global virtual machine registers to hold pointers
to the memory areas of the two new stacks and the current offsets
within them. These are defined whether MR_USE_MINIMAL_MODEL is defined
or not, since the cost is minimal and the potential bugs we avoid
would be hard to track down.
runtime/mercury_engine.h:
runtime/mercury_wrapper.c:
Add support for a new debugging flag, -dS, which prints the contents
of the nondet stack at several points during tabling.
runtime/mercury_tabling.[ch]:
The implementation of the new tabling system. Much of the new code here
is stuff moved from library/private_builtin.m, but in a significantly
rewritten form. There is also substantial new code, e.g. to handle
the extension of saved stack segments, and to manage dependencies
between subgoals in general.
Improve the documentation considerably.
Replace lists stored as Mercury data structures with lists stored
as linked structures in the usual C fashion. This allows us to use
debuggers such as ddd on these data structures, whose complexity
requires this.
Ensure that global names start with MR_.
runtime/mercury_init.h:
Explicitly include mercury_regs.h at the start. Without this,
we get an error, because now mercury_wrappers.h, which mercury_init.h
includes, also includes mercury_regs.h, but not before functions
have been declared.
runtime/Mmakefile:
Refer to the new file mercury_stacks.c (mercury_stacks.h already
existed, but the module consisted entirely of macros.)
Fix a sorting error.
scripts/{init,parse,final}_grade_options.sh-subr:
scripts/mgnuc.in:
Handle the new grade component.
tests/tabling/*
Add several new test cases that we now pass, most of which we couldn't
pass before. Also add some new test cases that we don't pass yet,
due to interactions between tabling and negated contexts.
trace/mercury_trace_internal.c:
If MR_USE_MINIMAL_MODEL is defined, add a new command to print
the generator stack. (The new command is deliberately not documented
in doc/mdb_doc yet, since (a) it is intended for developers only,
and (b) there is no way to test MR_USE_MINIMAL_MODEL in mdb_doc.)
|