mirror of
https://github.com/Mercury-Language/mercury.git
synced 2025-12-19 07:45:09 +00:00
270c12e80e64c84b5725c44cd1618ff145f5899b
67 Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
8a0ceb49aa |
This checkin has several major purposes, set out in the sections below,
Estimated hours taken: 240
This checkin has several major purposes, set out in the sections below,
all connected with the implementation of the new debugger command set.
DOCUMENT NEW DEBUG COMMAND SET
doc/user_guide.texi:
Add a new section on the debugger. The description of the commands
is complete, but some of the background sections, and the section
about how to build debuggable executables, are not yet done.
Update the documentation of the tracing options.
doc/generate_mdb_doc:
A new shell script that automatically converts some of the new
sections of the user guide into the online documentation of the
debugger.
doc/mdb_categories:
The fixed initial part of the online documentation.
doc/Mmakefile:
Add rules for creating mdb_doc, the file that is the online
documentation of the debugger, and for installing it together
with mdbrc.
Mmake.common.in:
Define INSTALL_DOC_DIR for doc/Mmakefile.
scripts/mdbrc.in:
A debugger command script that reads in the online documentation
and then defines some standard aliases.
configure.in:
Define the variable that scripts/mdb.in and scripts/mdbrc.in use
to find the right files, and get configure to perform the
substitutions.
configure.in:
scripts/mdb:
scripts/mdb.in:
Replace mdb with mdb.in. Mdb is now created during configuration
from mdb.in, filling in the name of the file that contains the default
debugger initialization commands.
util/info_to_mdb.c:
A program that does most of the work involved in automatically
converting user guide sections into online documentation.
(This couldn't easily be written in sh, because sh's read
command has no notion of pushback.)
util/Mmakefile:
Add info_to_mdb to the list of targets.
tools/bootcheck:
Make sure that the tests in tests/debugger are executed with an
initialization setup that is equivalent to what users will see
by default.
REORGANIZE TRACING OPTIONS
compiler/globals.m:
compiler/handle_options.m:
compiler/options.m:
compiler/trace.m:
Reorganize the handling of trace levels around the new options
--trace-internal, --trace-redo, and --trace-return.
compiler/*.m:
Use the new ways of getting at trace levels.
tests/hard_coded/typeclasses/Mmakefile:
s/--trace all/--trace deep/
SUPPORT RETRY
compiler/trace.m:
After every call to MR_trace(), emit code that checks whether it
should jump away, and if yes, performs the jump. This is used to
implement retry. (The debugger cannot execute the jump itself
because it is in the wrong C stack frame.)
compiler/llds.m:
compiler/continuation_info.m:
compiler/stack_layout.m:
Modify the data structures that record information about live
value at program points, to record the identity of each variable.
This is necessary for the implementation of the restart command,
since we do not want to confuse two distinct variables just because
they have the same name. For example, a variable whose name is X
and number is 5 is now recorded in the name array as "5:X".
Clean up the data structure a bit, so that we don't have to store
dummy names for values that are not variables.
compiler/*.m:
Minor changes to conform to the data structure changes.
runtime/mercury_stack_layout.h:
Redefine an existing macro to strip away the initial number: prefix
from the "name" of a variable (keeping its original function on
changed data), and add a new one to access the raw unstripped data.
runtime/mercury_init.h:
runtime/mercury_wrapper.h:
Update the prototype of MR_trace_{fake,real}, and the type of the
global that points to them.
runtime/mercury_layout_util.h:
Add an extra function, MR_get_register_number, for use by retry.
USE FIXED STACK SLOTS FOR TRACE INFO
compiler/code_gen.m:
compiler/code_info.m:
compiler/live_vars.m:
compiler/trace.m:
If execution tracing is enabled, reserve the first few stack slots
to hold the event number of the call event, the call number, the
call depth, the redo layout structure address (if generating redo
events) and the from_full flag at the time of call (if we are doing
shallow tracing). By allocating the first four of these to fixed stack
slots, the debugger knows where to look for them without having
to be told. It finds out the location of the fifth, if needed,
from a new slot in the proc layout structure. (It is not possible
to allocate all five to fixed stack slots without wasting stack space
in some cases.)
compiler/trace.m:
Remove from the call to MR_trace the parameters that are now in fixed
stack slots, since MR_trace can now look them up itself.
compiler/continuation_info.m:
compiler/stack_layout.m:
Add an extra field to the proc_layout_info. If the module is shallow
traced, this field says which stack slot holds the saved value of
MR_from_full. If it is not shallow traced, this field says that
there is no such stack slot.
runtime/mercury_stack_layout.h:
Add macros for accessing the fixed stack slots holding the event
number of the call event, the call number, the call depth, and,
at a redo event, the redo layout structure address.
Support the new field in proc layouts that gives the location of the
from-full flag (if any).
runtime/mercury_trace_base.[ch]:
trace/mercury_trace.[ch]:
Remove the call number and call depth arguments from MR_trace
and its avatars, since this info is now in fixed stack slots
in every procedure that can call MR_trace. This should reduce
the size of the executable significantly, since there are lots
of calls to MR_trace.
runtime/mercury_init.h:
runtime/mercury_wrapper.h:
Update the prototype of MR_trace_{fake,real}, and the type of the
global that points to them.
START NUMBERING FRAMEVARS FROM ONE
compiler/code_info.m:
compiler/live_vars.m:
compiler/llds_out.m:
compiler/trace.m:
Start numbering framevars from 1 internally to the compiler;
the runtime already starts from 1. This simplifies several tasks.
ADD REDO EVENTS
compiler/trace.m:
compiler/code_gen.m:
Before the code that executes "succeed()", emit code to push a
a temp nondet frame whose redoip points to a label in the runtime
that calls MR_trace for a REDO event and then fails, provided
--trace-redo is set.
compiler/llds.m:
Add a new code address constant, do_trace_redo_fail, which stands
for the address in the trace system to which calls MR_trace for
the redo event and then fails.
compiler/trace.m:
compiler/llds_out.m:
Provided we are doing redo tracing, fill in the slot that holds
the layout information for the REDO event.
compiler/*.m:
Minor changes to conform to handle the new code address constant.
browser/debugger_interface.m:
Add redo to trace_port_type.
runtime/mercury_trace_base.[ch]:
Add a C module containing the code that calls MR_trace for REDO
events.
ENSURE THAT INPUT ARGUMENTS ARE ALWAYS VISIBLE
compiler/trace.m:
When generating the set of live variables at internal ports,
the variables that are in the pre-death set of the goal into which
we are entering may not be available. However, the variables in the
pre-death set that are also in the resume vars set will be available,
so now include info about them in the layout structure for the event.
Since with tracing the non-clobbered input args are in all resume vars
sets, this ensures that these input args will be available from all
internal events.
compiler/code_info.m:
Export a previously internal predicate (current_resume_point_vars)
to make this possible.
BUG FIX: WANT RETURN LAYOUTS
compiler/globals.m:
compiler/call_gen.m:
compiler/code_info.m:
compiler/mercury_compile.m:
Add a new pred globals__want_return_layouts, which says whether the
compiler should generate layout structures for call returns. This pred
centralizes the several previous copies of the test. One of those
copies (the one in call_gen) was faulty, leading to a bug: in the
presence of execution tracing but the absence of accurate gc,
information about the variables that are live at the call return
wasn't being gathered properly.
BUG FIX: #include mercury_trace_base.h
compiler/llds_out.m:
#include mercury_trace_base.h, not mercury_trace.h, since now
mercury_trace_base.h defines everything directly accessible from
modules compiled with tracing.
RECAST MERCURY_TRACE_UTIL AS MERCURY_LAYOUT_UTIL
runtime/mercury_trace_util.[ch]:
runtime/mercury_layout_util.[ch]:
Rename this module from trace_util to layout_util, since it is also
used by the native garbage collector. Remove "trace" from the names
of functions.
Get rid of the global variable MR_saved_regs, and instead thread
a pointer to this data structure through the relevant functions
as an extra argument.
Add a lot more documentation in the header file.
runtime/Mmakefile:
Reflect the module rename.
runtime/*.c:
Refer to the new module.
DELETE EASY-TO-MISUSE MACROS
runtime/mercury_stacks.h:
Delete the based_framevar and based_detstackvar macros, since their
continued use can lead to off-by-one errors, and the saved_framevar
and saved_detstackvar macros, since they are no longer used.
runtime/*.c
Update any references to any macros removed from mercury_stacks.h.
MISC RUNTIME CHANGES
runtime/mercury_trace_base.[ch]:
trace/mercury_trace*.[ch]:
Make typedef'd names conform to the naming convention.
Make MR_trace_call_{seqno,depth} consistently Unsigned, rather than
sometimes Word and sometimes Unsigned.
FIX BUG: MAKE THE DEBUGGER PRINT TO STDOUT, NOT THE CURRENT STREAM
library/io.m:
Export to C code the predicates that return the identities and types
of stdin, stdout and stderr, as well as io__print/[34].
library/std_util.m:
Export to C code a predicate that returns the type_info for the
type stdutil:type_info. This type_info is required if C code
wants to invoke make_permanent on any type_info structure,
as the debugger does.
runtime/mercury_init.h:
Add extern declarations for the C functions now exported from io.m.
runtime/mercury_wrapper.[ch]:
Add new global variables to hold the addresses of these C functions.
runtime/mercury_layout_util.c:
Use indirect calls through these global variables to print Mercury
values, instead of lower-level code.
util/mkinit.c:
Assign the addresses of the functions exported from io.m to the
global variables defined in mercury_wrapper.h.
BUG FIX: STACK TRACE FUNCTIONS DEPEND ON THE LABEL TABLE
runtime/mercury_stack_trace.c:
On entry to any of the functions exported from this module,
ensure that the label table is loaded by calling do_init_modules.
Without a filled-in label table, the stack trace will not be able to
find any stack layout info.
BUG FIX: REMOVE BROWSER/*.C
configure.in:
When removing .c files generated by the C compiler, remove those
in the browser directory as well as the compiler, library and
profiler directories.
IMPLEMENT NEW DEBUGGER COMMAND SET
runtime/mercury_stack_trace.[ch]:
Factor out the code that prints the id of a procedure into a function
of its own, so that it can also be used from the debugger, ensuring
appearance commonality.
Add more documentation in the header file.
trace/mercury_trace_internal.c:
Implement the proposed command set. Command names are now words,
and several commands now have options allowing the user to override
the default print level or strictness of the command, or the
invocation conditions or action of a break point. Allows control
over command echoing and the scrolling of sequences of event reports.
Supports aliases, command file sourcing etc. Implements the retry
command, using the info in the fixed stack slots.
trace/mercury_trace.[ch]:
Extend the trace controls to support the new functionalities
required by the new debugger language, which are print levels,
variable-strictness commands, a more flexible finish command,
and the retry command.
Pass the command structure to MR_trace_event_report, since
the user can now forcibly terminate the scrolling of reports.
trace/mercury_trace_alias.[ch]:
New module to manage aliases for the debugger.
trace/mercury_trace_help.[ch]:
New module to interface to browser/help.m.
trace/mercury_trace_spy.[ch]:
New module to manage break points. The test of whether an event
matches a break point is now much more efficient than before.
The new module also allows several breakpoints with different
actions and different invocation conditions (e.g. all ports,
entry port, interface ports or specific (possibly internal) port)
to be defined on the same procedure.
trace/mercury_trace_tables.[ch]:
New module to manage a table of the debuggable modules, in which
each such module is linked to the list of the layouts of all the
procedures defined in that module. This information allows the
debugger to turn the name of a predicate/function (possibly together
with its arity and mode number) into the procedure layout structure
required by the spy point module. Eventually it may also be useful
in supplying lists of identifiers for command line completion.
Modules for which no stack layout information is available will
not be included in the table, since do_init_modules will not
register any labels for them in the label table.
trace/Mmakefile:
Mention the new files.
runtime/mercury_array_macros.h:
A new file holding macros that can be useful in more than one module.
runtime/Mmakefile:
Mention the new file.
runtime/mercury_conf.h.in:
Mention a new configuration macro, MR_CANNOT_USE_STRUCTURE_ASSIGNMENT,
used by runtime/mercury_array_macros.h.
configure.in:
Find out whether we need to define MR_CANNOT_USE_STRUCTURE_ASSIGNMENT.
ADD TRACE DEPTH HISTOGRAMS
runtime/mercury_conf_param.h:
Document MR_TRACE_HISTOGRAM.
runtime/mercury_trace_base.[ch]:
Define the data structures for the histogram, and print the histogram
when a traced program exits if MR_TRACE_HISTOGRAM is set.
trace/mercury_trace.[ch]:
If MR_TRACE_HISTOGRAM is defined, record a count of the number of
events at each depth. This information can help us evaluate space-time
tradeoffs.
FACTOR OUT SHELL CODE HANDLING GRADE IMPLICATIONS
scripts/final_grade_options.sh-subr:
A new file to contain any code that implements implications between
grade flags; currently implements the implication debug -> use trail.
scripts/mgnuc.in:
scripts/ml.in:
Replace the code that is now in final_grade_options.sh-subr with
an inclusion of final_grade_options.sh-subr.
configure.in:
Handle final_grade_options.sh-subr as {init,parse}_grade_options.sh-subr
are handled.
SIMPLIFY THE MAINTAINANCE OF CONSISTENCY BETWEEN DEBUGGER CODE AND DOCUMENTATION
doc/Mmakefile:
Add rules for creating mdb_command_list, a C code fragment
that can included manually in trace/mercury_trace_internal.c
to supply the list of valid commands, and mdb_command_test.inp,
which is a list of invalid invocations of debugger commands,
which tests whether the help message for such invocations
can be located as expected.
doc/generate_mdb_command_list:
doc/generate_mdb_command_test:
Awk scripts to create mdb_command_list and mdb_command_test.inp
respectively from mdb_doc.
tools/bootcheck:
Copy mdb_command_test.inp from doc to tests/debugger.
tests/debugger/Mmakefile:
Add a new test that checks whether we get an internal error, unable
to locate the right help node, for each invalid command invocation in
mdb_command_test.inp.
UPDATE TEST CASES
tests/debugger/Mmakefile:
Reenable queens. Conform to the new set of options.
tests/debugger/*.inp:
tests/debugger/*.exp:
Update the inputs and expected outputs of the debugger test cases
to use the new command set and output formats.
|
||
|
|
4ab3f397b1 |
Allow the debugger to print the values of variables in ancestors
Estimated hours taken: 20 Allow the debugger to print the values of variables in ancestors of the current call. This requires knowledge about which named variables are live at call return sites. Providing this information properly required fixing the interaction of execution tracing and accurate garbage collection. compiler/globals.m: Introduce a new trace level, so that there are now four: none, interface, interface_ports (corresponding to the existing three levels) and the new level interface_ports_returns, each of which requires all the information required by lower levels. Make the trace level abstract, since in the future we may want to introduce trace levels for new combinations, e.g. interfaces and returns but not internal ports. Introduce the necessary new predicates. compiler/continuation_info.m: Redefine internal_label_info to allow us to record separate info about the sets of vars needed at (a) internal ports of execution tracing and at (b) call return points for accurate gc or (now) uplevel printing during execution tracing. Neither is a subset of the other, and they need to be treated differently. compiler/mercury_compile.m: Gather information about vars at return labels if the trace level requires uplevel printing capability, even if agc is off. compiler/stack_layout.m: Fix the handling of labels which are needed both by agc and by execution tracing. If information at a return label is needed only by uplevel printing in execution tracing and not by agc, then discard all info about lvals which do not hold named variables or their typeinfos (in fact we keep all typeinfos at the moment). If a label is both the label of a port and a return label, we include in the layout structure the union of the information recorded for the two roles. Sort the var_info vector before using it to generate layout structures in an attempt to make llds_common more effective and to make lists of variables printed by the debugger look better. Record a distinguished value when there is no info about the vars live at a label, rather than (incorrectly) recording that there are no live variables. Before up-level printing, the lie was harmless; now it isn't. Remove the label number from return label layouts, since the tracer isn't expecting it. It used to be included for debugging purposes if the label was for agc, but it is possible for a label to be needed both for agc and for execution tracing. If Tyson finds he needs the label number, it can be easily turned back on for all label layouts. compiler/code_info.m: Conform to the new definition of internal_label_info. Rename an internal pred for clarity. Rename some bool parameter to correctly reflect their new meaning. compiler/*.m: Trivial changes, mostly due to making trace_level an abstract type. runtime/mercury_stack_layout.h: Remove the label number from return label layouts, since the tracer isn't expecting it. runtime/mercury_stack_trace.[ch]: Add a new function that returns the label layout structure at the Nth ancestor return continuation, together with the values of sp and curfr at that point. This required changing MR_stack_walk_step to step from an entry layout only to the return label layout. runtime/mercury_stacks.h: Add macros that let us access detstackvars and framevars based on these synthesized values of sp and curfr. runtime/mercury_trace_util.[ch]: Generalize several functions to allow them to use synthesized (as opposed to saved) values of sp and curfr in looking up values. Retain functions with the original names and signatures that call the new, general versions with the necessary additional parameters. runtime/mercury_trace_internal.c: Add a new command that sets the "ancestor level". For example, "l 2" sets it to 2, which means that the command "v" and "p" will refer to the grandparent of the current call. The ancestor level persists while the debugger is at the current event; after that it is reset to 0. The implementation involves calling the new function in mercury_stack_trace.c and the generalized functions in mercury_trace_util.c. Also add a deliberately undocumented extra command, X, which prints the stack pointers. NEWS: Add a reminder about removing the X command before release. tests/debugger/* Update half the test cases (those which assume a non-debug-grade library) to conform to the changes in the debugger interface. The others will need to be updated later. |
||
|
|
a70b59e83c |
Add a test to find the number of words needed to represent a
configure.in:
Add a test to find the number of words needed to represent a
synchronization term.
boehm_gc/gc.h:
fix a declaration by replacing the args () with (void).
boehm_gc/solaris_pthreads.c:
add a missing include
check the return values of pthread calls.
compiler/*.m:
Add handling for the new HLDS goal type par_conj.
Add handling for the four new LLDS instructions:
init_sync_term
fork
join_and_terminate
join_and_continue
compiler/code_info.m:
add a new alternative for slot_contents - sync_term.
compiler/handle_options.m:
add .par as part of the grade
compiler/hlds_goal.m:
add the new goal type par_conj.
compiler/instmap.m:
add instmap__unify which takes a list of instmaps
and abstractly unifies them.
add unify_instmap_delta which tajes two instmap deltas
and abstractly unifies them.
compiler/llds.m:
add the new llds instructions.
compiler/mode_info.m:
add par_conj as a lock reason.
library/Makefile:
work around a bug in the solaris version pthread.h
library/benchmarking.m:
reference the stack zones from the engine structure
rather than from global variables.
library/{nc,sp}_builtin.nl:
add an op declaration for &.
library/std_util.m:
change references to global variables to references inside
the engine structure.
runtime/Mmakefile:
add mercury_thread.{c,h}
add THREADLIBS to the libraries
runtime/*.{c,h}
Remove some old junk from the previous processes/shrd-mem
changes that found their way into the repository.
Add MR_ prefixes to lots of names.
runtime/mercury_context.c:
Add init_thread_stuff for creating and initializing a
context structure for the current thread.
runtime/mercury_context.h:
add a field to the mercury context which stores the thread id
of the thread where this context originated.
add various macros for implementing the new llds instructions.
runtime/mercury_engine.c:
initialize the engine structure, rather than a bunch of globals.
runtime/mercury_engine.h:
declare the mercury_engine structure.
runtime/mercury_regorder.h:
if MR_THREAD_SAFE, and there is at least one global register
then use mr0 as a pointer to the mercury engine structure.
scripts/init_grade_options.sh-subr
add thread_safe
scripts/mgnuc.in
add THREAD_OPTS
scripts/ml.in:
add THREAD_LIBS
|
||
|
|
af6f18ab3f |
Fergus's recent change to the handling of some builtins broke the tracing
Estimated hours taken: 20 Fergus's recent change to the handling of some builtins broke the tracing of those builtins. The following changes are a fix for this. compiler/polymorphism.m: Export the predicate that checks whether a predicate is a builtin that lacks the usually necessary typeinfos. Comment out a misleading and in any case not very useful progress message. compiler/liveness.m: Turn off type_info liveness for builtins without typeinfos. Since these builtins establish no gc points and shouldn't be execution traced, this is OK. Make type_info liveness part of live_info, since it can now be incorrect to look up the value of the option. (This may yield a speedup.) compiler/live_vars.m: compiler/store_alloc.m: Pass the pred_id to initial_liveness to liveness.m can do the test. compiler/passes_aux.m: Add a new traversal type that passes along the pred_id. compiler/mercury_compile.m: Turn off execution tracing for the modules builtin.m and private_builtin.m. The latter contains the interface predicates for the builtins without typeinfos. Since the interface predicates also lack the typeinfos, the compiler would get an internal abort if we left execution tracing on. In any case, these two modules contain stuff that users should consider language builtins, which means they should not be execution traced (they can still be stack traced in the right grade). Use the new traversal type for the modules that now need the pred_id. compiler/globals.m: Allow the trace level to be set from outside, in this case mercury_compile.m. The next batch of changes have to do with adding a stack dump command to the debugger. Since debugging is possible even in non-debug grades, this in turn requires allowing stack tracing to work in non-debug grades, on programs in which only some modules are compiled with execution (and hence stack) tracing. compiler/llds_out.m: compiler/mercury_compile.m: runtime/mercury_conf_param.h: Llds_out used to output "#include <mercury_imp.h>" as the first substantive thing in the generated C file. The set of #define parameters in effect when mercury_imp.h is processed determines whether the macros that optionally register stack layouts for label actually do so or not. The values of these parameters are derived from the grade, which means that with this setup it is not possible for a non-debug grade program to register its stack layouts in the label table. The new version of llds_out looks up the option that says whether this module is compiled with execution tracing or not, and if it is, it generates a #define MR_STACK_TRACE_THIS_MODULE *before* the #include of mercury_imp.h. This causes mercury_conf_param.h, included from mercury_imp.h, to define the macros MR_USE_STACK_LAYOUTS and and MR_INSERT_LABELS, which in turn cause stack layouts for labels in this module to be generated and to be inserted into the label table, *without* changing the grade string (this last part is why we do not simply define MR_STACK_TRACE). Use the same mechanism to #include mercury_trace.h when doing execution tracing, since it is simpler than the mechanism we used to use (mercury_compile.m including the #include in a list of C header file fragments). compiler/mercury_compile.m: runtime/mercury_conf_param.h: Split the MR_NEED_INITIALIZATION_CODE macro into two parts. The first, MR_MAY_NEED_INITIALIZATION, now controls whether initialization code makes it into the object file of a module. The second, MR_NEED_INITIALIZATION_AT_START, determines whether the initialization code is called before main/2. When a module is compiled with execution tracing, the macro MR_INSERT_LABELS turns on MR_MAY_NEED_INITIALIZATION but not MR_NEED_INITIALIZATION_AT_START. The debugger will make sure that the initialization code has been called before it tries to do a stack dump (which needs the initialization code to have been executed, because it needs labels to have been put into the label table so that from a return address it can find the layout of the proc to which it belongs). Define MR_NEED_INITIALIZATION_AT_START if PROFILE_TIME is defined, since if PROFILE_TIME is defined mercury_wrapper.c calls init_modules. The fact that MR_NEED_INITIALIZATION_CODE didn't used to be defined when PROFILE_TIME was defined was, I believe, a bug, which was not detected because we do not turn on PROFILE_TIME without also turning on PROFILE_CALLS. runtime/mercury_stack_trace.[ch]: Change the way stack dumps are done, to make it possible to print stack dumps from the debugger and to use trivial run-length encoding on the output (so that 100 consecutive calls to p yield the line "p * 100", rather than 100 lines of "p"). The stack routine now returns an indication of whether the stack dump was fully successful, and if not, a description of the reason why not. This requires knowing when we have found the end of the stack dump, so we provide a global variable, MR_stack_trace_bottom, which mercury_wrapper.c will set to global_success, the address main/2 goes to on success. s/multidet/multi/ runtime/mercury_wrapper.c: Set MR_stack_trace_bottom to the address of globals_success. Use MR_NEED_INITIALIZATION_AT_START to decide whether to call do_init_modules. runtime/mercury_stacks.h: Provide variants of detstackvar(n) and framevar(n) that look up sp and curfr in an array of saved regs, for use by the debugger. runtime/mercury_trace_util.c: Use the new variants of detstackvar(n) and framevar(n). This fixes an old bug on SPARCs. runtime/mercury_trace_internal.c: Completely reorganize the way debugger commands are handled. Centralize reading in command lines, and the breaking up of command lines into words. The command names are the same as they were, but command syntax is now much easier to change. Add a new command "d" to dump as much of the stack as the available information will allow. runtime/mercury_goto.h: Cosmetic changes to avoid the use of two different conditional compilation layout styles. util/mkinit.c: Since we cannot know when we generate the _init.c file whether any modules will be compiled with execution tracing and will thus need stack tracing, we must now include in the generated _init.c file the code to call the initialization functions in all the modules, even if MR_NEED_INITIALIZATION_AT_START is not set, since init_modules can be called later, from the debugger. (We should be able to use the same approach with the accurate collector.) |
||
|
|
d10af74168 |
This change introduces interface tracing, and makes it possible to successfully
Estimated hours taken: 50
This change introduces interface tracing, and makes it possible to successfully
bootstrap the compiler with tracing (either interface or full).
compiler/options.m:
Change the bool options --generate-trace into a string option --trace
with three valid values: minimal, interface and full. The last two mean
what they say; the intention is that eventually minimal will mean
no tracing in non-tracing grades and interface tracing in tracing
grades.
compiler/globals.m:
Add a new global for the trace level.
compiler/handle_options.m:
Convert the argument of --trace to a trace level.
Use only consistent 4-space indentation in the deeply nested
if-then-else.
compiler/trace.m:
Implement interface tracing.
Rename trace__generate_depth_reset_code as trace__prepare_for_call,
since it does more than reset the depth if this module is compiled
with interface tracing.
Do not check whether tracing is enabled before calling MR_trace;
let MR_trace make the check. This trades increased non-tracing
execution time for a substantial code size reduction (which may
in turn benefit execution time).
compiler/call_gen.m:
Call trace__generate_depth_reset_code by its new name.
compiler/code_info.m:
Fix a bug in the handling of non/semi commits. When entering a commit,
we used to push a clone of whatever the top failure continuation was.
However, the resume setup for this continuation could have started
with a label that assumed that the resume vars were in their original
locations (which are often registers), whereas the method of
backtracking to that point only guarantees the survival of stack slots,
not registers.
(This bug caused two lines of incorrect code to be generated among
the approx 30 million lines of code in the stage 2 compiler when
compiled with tracing.)
Fix another bug (previously untriggered as far as I know) in the
handling of multi/det commits. This one was breaking the invariant
that the resume vars set of each entry on the failure continuation
stack included the resume vars set of every other entry below it,
which meant that the values of these resume vars were not guaranteed
to be preserved.
compiler/stack_layout.m:
Make layout structures local to their module. They are not (yet)
referred to by name from other modules, and by declaring them
to be global we caused their names to be included even in stripped
executables, adding several megabytes to the size of the binary.
(The names are not stripped because a dynamically linked library
may want to refer to them.)
Change the mercury_data__stack_layout__ prefix on the names of
generated globals vars to just mercury_data__layout__. It is now
merely too long instead of far too long.
Include the label number in the label layout structure and the number
of typeinfo variables in a var_info structure only with native gc.
Their only use is in debugging native gc.
Fix some documentation rot.
compiler/llds.m:
Add a new field to the pragma_c instruction that says whether the
compiler-generated C code fragments access any stack variables.
compiler/frameopt.m:
Use the new field in pragma_c's to avoid a bug. Because frameopt was
assuming that the pragma_c instruction that filled in the stack slots
containing the call sequence number and depth did not access the stack,
it moved the pragma_c before the incr_sp that allocates the frame
(it was trying to get it out of the loop).
compiler/*.m:
Minor changes to set or ignore the extra field in pragma_c, to refer
to layout structures via the new prefix, or to handle the --trace
option.
doc/user_guide.texi:
Update the documentation for --trace.
runtime/mercury_types.h:
Add the type Unsigned.
runtime/mercury_goto.h:
Use the shorter layout prefix.
runtime/mercury_stack_layout.h:
Use the shorter layout prefix, and include the label number only with
native gc.
runtime/mercury_trace.[ch]:
runtime/mercury_trace_internal.[ch]:
runtime/mercury_trace_external.[ch]:
runtime/mercury_trace_util.[ch]:
Divide the old mercury_trace.[ch] into several components, with one
module for the internal debugger, one for the interface to the
external debugger, one for utilities needed by both. Mercury_trace.c
now has only the top-level stuff that steers between the two
debuggers.
runtime/mercury_trace.[ch]:
Add the new global variable MR_trace_from_full. Before each call,
the calling procedure assigns TRUE to this variable if the caller
is fully traced, and FALSE otherwise. Interface traced procedures
generate trace events only if this variable is TRUE when they are
called (fully traced callee procedures ignore the initial value of
the variable).
Make MR_trace return immediately without doing anything unless
tracing is enabled and a new extra argument to MR_trace is TRUE.
This extra argument is always TRUE for trace events in fully traced
procedures, while for trace events from interface traced procedures,
its value is set from the value of MR_trace_from_full at the time
that the procedure was called (i.e. the event is ignored unless the
interface traced procedure was called from a fully traced procedure).
runtime/mercury_trace.[ch]:
runtime/mercury_trace_internal.[ch]:
For global variables that are stored in stack slots, make their type
Word rather than int.
Use a new function MR_trace_event_report instead of calling
MR_trace_event with a NULL command structure pointer to indicate
that the event is to be reported but there is to be no user
interaction.
Use %ld formats in printfs and casts to long for better portability.
runtime/mercury_trace_internal.c:
Save trace-related globals across calls to Mercury library code
in the debugger, since otherwise any trace events in this code
could screw up e.g. the event number or the call number sequence.
Create separate functions for printing port names and determinisms.
runtime/mercury_wrapper.h:
Disable the tracing of the initialization and finalization code
written in Mercury.
runtime/Mmakefile:
Update for the new source and header files.
tests/debugger/{debugger_regs,interpreter,queens}_lib.{m,inp,exp}:
One new copy of each existing test case. These ones are intended
to be used when the stage 2 library is compiled with tracing, which
affects the tests by adding events for the library procedures called
from the test programs.
The .m files are the same as before; one of the .inp files is a bit
different; the .exp files reflect the correct output when the library
is compiled with full tracing.
tests/debugger/Mmakefile:
Provide separate targets for the new set of test cases.
Use --trace full instead of --generate-trace.
tests/debugger/runtests:
Try both the new set of test cases if the old set fails, and report
failure only if both sets fail. This is simpler than trying to figure
out which set should be really tested, and the probability of a false
positive is negligible.
|
||
|
|
67d8308260 | Same as previous message. | ||
|
|
0f41ebf9e1 |
When deciding where to put the known variables at the end of a branched
Estimated hours taken: 2 store_alloc.m: When deciding where to put the known variables at the end of a branched control structure, and looking at a variable not in the follow-vars set, prefer putting the variable into its stack slot instead of a free register. The semantics of the follow-vars set says that this variable likely won't be used before the next call. Even if follow-vars is not turned on, prefer putting variables in their stack slots to putting them in non-real registers. |
||
|
|
b5dfd26ebd |
Miscellaneous small changes.
Estimated hours taken: 1.5 Miscellaneous small changes. compiler/modes.m: Fix a couple of mode errors which were caught by the new mode checker: use of clobbered mode_infos. compiler/simplify.m: Optimise away unifications of the form X = X. (These can be created by excess assignment elimination.) compiler/follow_vars.m: compiler/hlds_goal.m: compiler/inst_match.m: compiler/prog_data.m: compiler/store_alloc.m: Minor documentation fixes. |
||
|
|
d0085d8119 |
Assorted changes to make the HLDS type and mode correct
Estimated hours taken: 45
Assorted changes to make the HLDS type and mode correct
after lambda expansion. The HLDS is still not unique mode
correct after common structure elimination.
compiler/det_analysis.m
Make sure the inferred_determinism field of the proc_info is filled
in correctly for imported procedures and class methods.
compiler/mode_util.m
Fix a bug in recompute_instmap_delta_call to do with unreachable
instmaps. This caused an abort a couple of months ago when
compiling with --deforestation (not yet committed), but
can't currently be reproduced.
compiler/hlds_pred.m
compiler/lambda.m
Add a field to the proc_info to record which args_method
should be used for this procedure. Procedures directly
called by do_call_*_closure must be compiled with
the `compact' argument convention to avoid the need to permute
the arguments so inputs come before outputs.
compiler/lambda.m
compiler/higher_order.m
Remove permutation of argument variables of lambda expressions
so the HLDS is type and mode correct and mode analysis can
be rerun. Otherwise, rerunning mode analysis will fail on
tests/hard_coded/ho_order.m.
compiler/arg_info.m
Added arg_info__ho_call_args_method which returns
an args_method which can always be directly called by
do_call_*_closure (`compact').
Added arg_info__args_method_is_ho_callable to check that
a given args_method can be directly called.
compiler/unify_gen.m
Abort if a closure is created for a procedure compiled
with the simple argument convention.
compiler/hlds_goal.m
compiler/lambda.m
Mode analysis was not storing the non-locals list on which the
uni_modes field of the construction of a lambda goal was computed.
If the nonlocals were renamed, the sort order could change, and
the non-locals could be incorrectly matched with the arguments
of the introduced lambda expression, causing a mode error. The
argument list is now stored.
This caused rerunning mode-checking on tests/valid/lazy_list.m
after polymorphism to fail.
compiler/*.m
Fill in the args_method field of proc_infos with the value
from the globals.
Handle the extra argument to the lambda_goal unify_rhs.
compiler/follow_vars.m
Remove code to handle complicated unifications, since
they should be removed by polymorphism.m.
compiler/special_pred.m
library/mercury_builtin.m
Make the uniqueness of the comparison_result argument
of builtin_compare_* and the automatically generated
comparison procedures match that of compare/3. Unique mode
errors will still be introduced if polymorphism.m specializes
calls to any of the unique modes of compare/3 and then mode analysis
is rerun, since the compiler-generated comparison procedures
only implement the (uo, in, in) mode. (This is not yet a problem
because currently we don't rerun mode analysis.)
runtime/mercury_ho_call.c
Remove code in do_call_*_closure to deal with the
`simple' args_method. Since the output arguments no longer
need to be moved, the closure call is now a tailcall.
Remove some magic numbers.
compiler/modecheck_unify.m
Avoid some aborts and mode errors when rerunning mode analysis,
especially those resulting from not_reached insts being treated
as bound.
Avoid aborting on higher-order predicate constants with multiple
modes if lambda expansion has already been run.
tests/valid/higher_order.m
Add a test case for an abort in mode analysis when
compiling with --deforestation (not yet committed),
due to a predicate constant for a procedure with multiple
modes.
tests/valid/unreachable_code.m
Add a test case for bogus higher-order unification
mode errors in unreachable code.
|
||
|
|
5013dd9c76 |
Implement nondet pragma C codes.
Estimated hours taken: 40
Implement nondet pragma C codes.
runtime/mercury_stacks.h:
Define a new macro, mkpragmaframe, for use in the implementation
of nondet pragma C codes. This new macro includes space for a
struct with a given sruct tag in the nondet stack frame being created.
compiler/{prog_data.m,hlds_goal.m}:
Revise the representation of pragma C codes, both as the item and
in the HLDS.
compiler/prog_io_pragma.m:
Parse nondet pragma C declarations.
Fix the indentation in some places.
compiler/llds.m:
Include an extra argument in mkframe instructions. This extra argument
gives the details of the C structure (if any) to be included in the
nondet stack frame to be created.
Generalize the LLDS representation of pragma C codes. Instead of a
fixed sequence of <assign from inputs, user c code, assign to outputs>,
let the sequence contain these elements, as well as arbitrary
compiler-generated C code, in any order and possibly with repetitions.
This flexibility is needed for nondet pragma C codes.
Add a field to pragma C codes to say whether they can call Mercury.
Some optimizations can do a better job if they know that a pragma C
code cannot call Mercury.
Add another field to pragma C codes to give the name of the label
they refer to (if any). This is needed to prevent labelopt from
incorrectly optimizing away the label definition.
Add a new alternative to the type pragma_c_decl, to describe the
declaration of the local variable that points to the save struct.
compiler/llds_out.m:
Output mkframe instructions that specify a struct as invoking the new
mkpragmaframe macro, and make sure that the struct is declared just
before the procedure that uses it.
Other minor changes to keep up with the changes to the representation
of pragma C code in the LLDS, and to make the output look a bit nicer.
compiler/pragma_c_gen.m:
Add code to generate code for nondet pragma C codes. Revise the utility
predicates and their data structures a bit to make this possible.
compiler/code_gen.m:
Add code for the necessary special handling of prologs and epilogs
of procedures defined by nondet pragma C codes. The prologs need
to be modified to include a programmer-defined C structure in the
nondet stack frame and to communicate the location of this structure
to the pragma C code, whereas the functionality of the epilog is
taken care of by the pragma C code itself.
compiler/make_hlds.m:
When creating a proc_info for a procedure defined by a pragma C code,
we used to insert unifications between the headvars and the vars of
the pragma C code into the body goal. We now perform substitutions
instead. This removes a factor that would complicate the generation
of code for nondet pragma C codes.
Pass a moduleinfo down the procedures that warn about singletons
(and other basic scope errors). When checking whether to warn about
an argument of a pragma C code not being mentioned in the C code
fragment, we need to know whether the argument is input or output,
since input variables should appear in some code fragments in a
nondet pragma C code and must not appear in others. The
mode_is_{in,out}put checks need the moduleinfo.
(We do not need to check for any variables being mentioned where
they shouldn't be. The C compiler will fail in the presence of any
errors of that type, and since those variables could be referred
to via macros whose definitions we do not see, we couldn't implement
a reliable test anyway.)
compiler/opt_util.m:
Recognize that some sorts of pragma_c codes cannot affect the data
structures that control backtracking. This allows peepholing to
do a better job on code sequences produced for nondet pragma C codes.
Recognize that the C code strings inside some pragma_c codes refer to
other labels in the procedure. This prevents labelopt from incorrectly
optimizing away these labels.
compiler/dupelim.m:
If a label is referred to from within a C code string, then do not
attempt to optimize it away.
compiler/det_analysis.m:
Remove a now incorrect part of an error message.
compiler/*.m:
Minor changes to conform to changes to the HLDS and LLDS data
structures.
|
||
|
|
bb4442ddc1 |
Update copyright dates for 1998.
Estimated hours taken: 0.5 compiler/*.m: Update copyright dates for 1998. |
||
|
|
7406335105 |
This change implements typeclasses. Included are the necessary changes to
Estimated hours taken: 500 or so This change implements typeclasses. Included are the necessary changes to the compiler, runtime and library. compiler/typecheck.m: Typecheck the constraints on a pred by adding constraints for each call to a pred/func with constraints, and eliminating constraints by applying context reduction. While reducing the constraints, keep track of the proofs so that polymorphism can produce the tyepclass_infos for eliminated constraints. compiler/polymorphism.m: Perform the source-to-source transformation which turns code with typeclass constraints into code without constraints, but with extra "typeclass_info", or "dictionary" parameters. Also, rather than always having a type_info directly for each type variable, sometimes the type_info is hidden inside a typeclass_info. compiler/bytecode*.m: Insert some code to abort if bytecode generation is used when typeclasses are used. compiler/call_gen.m: Generate code for a class_method_call, which forms the body of a class method (by selecting the appropriate proc from the typeclass_info). compiler/dead_proc_elim.m: Don't eliminate class methods if they are potentially used outside the module compiler/hlds_data.m: Define data types to store: - the typeclass definitions - the instances of a class - "constraint_proof". ie. the proofs of redundancy of a constraint. This info is used by polymorphism to construct the typeclass_infos for a constraint. - the "base_tyepclass_info_constant", which is analagous the the base_type_info_constant compiler/hlds_data.m: Define the class_method_call goal. This goal is inserted into the body of class method procs, and is responsible for selecting the appropriate part of the typeclass_info to call. compiler/hlds_data.m: Add the class table and instance table to the module_info. compiler/hlds_out.m: Output info about base_typeclass_infos and class_method_calls compiler/hlds_pred.m: Change the representation of the locations of type_infos from "var" to type_info_locn, which is either a var, or part of a typeclass_info, since now the typeclass_infos contain the type_infos for the type that they constrain. Add constraints to the pred_info. Add constraint_proofs to the pred_info (so that typeclass.m can annotate the pred_info with the reasons that constraints were eliminated, so that polymorphism.m can in turn generate the typeclass_infos for the constraints). Add the "class_method" marker. compiler/lambda.m: A feable attempt at adding class ontexts to lambda expressions, untested and almost certainly not working. compiler/llds_out.m: Output the code addresses for do_*det_class_method, and output appropriately mangled symbol names for base_typeclass_infos. compiler/make_hlds.m: Add constraints to the types on pred and func decls, and add class and instance declarations to the class_table and instance_table respectively. compiler/mercury_compile.m: Add the check_typeclass pass. compiler/mercury_to_mercury.m: Output constraints of pred and funcs, and output typeclass and instance declarations. compiler/module_qual.m: Module qualify typeclass names in pred class contexts, and qualify the typeclass and instance decls themselves. compiler/modules.m: Output typeclass declarations in the short interface too. compiler/prog_data.m: Add the "typeclass" and "instance" items. Define the types to store information about the declarations, including class contexts on pred and func decls. compiler/prog_io.m: Parse constraints on pred and func declarations. compiler/prod_out.m: Output class contexts on pred and func decls. compiler/type_util.m: Add preds to apply a substitution to a class_constraint, and to a list of class constraints. Add type_list_matches_exactly/2. Also add typeclass_info and base_typeclass_info as types which should not be optimised as no_tag types (seeing that we cheat a bit about their representation). compiler/notes/compiler_design.html: Add notes on module qualification of class contexts. Needs expansion to include more stuff on typeclasses. compiler/*.m: Various minor changes. New Files: compiler/base_typeclass_info.m: Produce one base_typeclass_info for each instance declaration. compiler/prog_io_typeclass.m: Parse typeclass and instance declarations. compiler/check_typeclass.m: Check the conformance of an instance declaration to the typeclass declaration, including building up a proof of how superclass constraints are satisfied so that polymorphism.m is able to construct the typeclass_info, including the superclass typeclass_infos. library/mercury_builtin.m: Implement that base_typeclass_info and typeclass_info types, as well as the predicates type_info_from_typeclass_info/3 to extract a type_info from a typeclass_info, and superclass_from_typeclass_info/3 for extracting superclasses. library/ops.m: Add "typeclass" and "instance" as operators. library/string.m: Add a (in, uo) mode for string__length/3. runtime/mercury_ho_call.c: Implement do_call_*det_class_method, which are the pieces of code responsible for extracting the correct code address from the typeclass_info, setting up the arguments correctly, then executing the code. runtime/mercury_type_info.h: Macros for accessing the typeclass_info structure. |
||
|
|
5976f769f7 |
Fix a bug for the case of a higher-order function call in code
Estimated hours taken: 1 Fix a bug for the case of a higher-order function call in code with common sub-expression; mercury 0.7 failed this test, reporting "Software Error: modecheck fails when repeated", due to confusion between h.o. _function_ call and h.o. _predicate_ call. compiler/hlds_goal.m: Add `pred_or_func' field to HLDS higher_order_calls. compiler/modes.m: compiler/modecheck_call.m: compiler/hlds_out.m: compiler/*.m: Add code to handle new field for higher_order_call goals. tests/valid/Mmake: tests/valid/ho_func_call.m: Regression test for the above-mentioned bug. |
||
|
|
796f7f7436 |
Fix a bug which caused the code generator to fail on certain
Estimated hours taken: 16 Fix a bug which caused the code generator to fail on certain examples involving predicates with determinism `erroneous'. compiler/inst_match.m: Change `inst_is_bound' so that it succeeds for `not_reached' insts. This change is so that the behaviour of the predicate matches the documentation, and so that it is consistent with the behaviour of `inst_is_ground'. compiler/liveness.m: When computing the value-giving occurrences, check explicitly for unreachable instmaps. This is necessary to handle the above change to `inst_is_bound'. Fix a bug in detect_deadness: it was applying the deaths before the births, but it should be done in the other order. Normally deaths must be applied before births, but in detect_deadness we are traversing the goal backwards, so we must apply births first and then deaths. The old solution of just cancelling out any vars that occur in both the post-death and post-birth set was not quite right; instead we just need to apply them in the correct order. compiler/code_info.m: Change the code so that it applies the pre/post deaths before applying the corresponding births. compiler/live_vars.m: compiler/store_alloc.m: compiler/hlds_goal.m: Add some comments about making sure we always apply the deaths before applying the births. (The code here was already correct, I just added some documentation.) compiler/hlds_out.m: Print out the pre/post deaths before the pre/post births, so that the order that they are printed out in matches the order in which they should be applied. tests/hard_coded/Mmake: tests/hard_coded/erroneous_liveness.m: tests/hard_coded/erroneous_liveness.exp: tests/hard_coded/erroneous_liveness.inp: Regression test for the above-mentioned bug fix. |
||
|
|
04b720630b |
Update the copyright messages so that (a) they contain the correct years
and (b) they say "Copyright (C) ... _The_ University of Melbourne". |
||
|
|
27d156bbb5 |
Implemented a :- use_module directive. This is the same as
Estimated hours taken: 14 Implemented a :- use_module directive. This is the same as :- import_module, except all uses of the imported items must be explicitly module qualified. :- use_module is implemented by ensuring that unqualified versions of items only get added to the HLDS symbol tables if they were imported using import_module. Indirectly imported items (from `.int2' files) and items declared in `.opt' files are treated as if they were imported with use_module, since all uses of them should be module qualified. compiler/module_qual.m Keep two sets of type, mode and inst ids, those which can be used without qualifiers and those which can't. Renamed some predicates which no longer have unique names since '__' became a synonym for ':'. Made mq_info_set_module_used check whether the current item is in the interface, rather than relying on its caller to do the check. Removed init_mq_info_module, since make_hlds.m now uses the mq_info built during the module qualification pass. compiler/prog_data.m Added a pseudo-declaration `used', same as `imported' except uses of the following items must be module qualified. Added a type need_qualifier to describe whether uses of an item need to be module qualified. compiler/make_hlds.m Keep with the import_status whether current item was imported using a :- use_module directive. Use the mq_info structure passed in instead of building a new one. Ensure unqualified versions of constructors only get added to the cons_table if they can be used without qualification. compiler/hlds_module.m Added an extra argument to predicate_table_insert of type need_qualifier. Only add predicates to the name and name-arity indices if they can be used without qualifiers. Changed the structure of the module-name-arity index, so that lookups can be made without an arity, such as when type-checking module qualified higher-order predicate constants. This does not change the interface to the module_name_arity index. Factored out some common code in predicate_table_insert which applies to both predicates and functions. compiler/hlds_pred.m Removed the opt_decl import_status. It isn't needed any more since all uses of items declared in .opt files must now be module qualified. Added some documentation about when the clauses_info is valid. compiler/intermod.m Ensure that predicate and function calls in the `.opt' file are module qualified. Use use_module instead of import_module in `.opt' files. compiler/modules.m Handle use_module directives. Report a warning if both use_module and import_module declarations exist for the same module. compiler/mercury_compile.m Collect inter-module optimization information before module qualification, since it can't cause conflicts any more. This means that the mq_info structure built in module_qual.m can be reused in make_hlds.m, instead of building a new one. compiler/prog_out.m Add a predicate prog_out__write_module_list, which was moved here from module_qual.m. compiler/typecheck.m Removed code to check that predicates declared in `.opt' files were being used appropriately, since this is now handled by use_module. compiler/*.m Added missing imports, mostly for prog_data and term. NEWS compiler/notes/todo.html doc/reference_manual.texi Document `:- use_module'. tests/valid/intermod_lambda_test.m tests/valid/intermod_lambda_test2.m tests/invalid/errors.m tests/invalid/errors2.m Test cases. |
||
|
|
e3471f333f |
Fix a bug in inlining of polymorphic pragma c_code procedures.
Estimated hours taken: 3 Fix a bug in inlining of polymorphic pragma c_code procedures. The bug was that if the actual argument type has a specific type of say `float', then the C variable for the corresponding formal parameter will be declared to have type `Float', whereas without inlining the argument type would have been polymorphic and so the C variable would have been declared to have type `Word'. Hence we need to keep track of the original argument types, before any inlining or specialization has occurred, and use these original argument types to determine how to declare the C variables, rather than using the actual argument types for this particular specialization. compiler/hlds_goal.m: Add a new field to pragma_c_code goals, holding the original argument types (before any inlining or specialization) of the pragma_c_code procedure. compiler/make_hlds.m: Initialize this field with the declared argument types for the pragma c_code procedure. compiler/polymorphism.m: Update this field to account for the inserted type_info variables. compiler/code_gen.m: Pass this field to pragma_c_gen.m. compiler/pragma_c_gen.m: Use the original argument types field for the pragma variable declarations, rather than looking up the actual types of the arguments. compiler/*.m: Trivial changes to handle new field. compiler/live_vars.m: Comment out some code to avoid a warning about `fail' in the condition of an if-then-else. |
||
|
|
4c3b0ecb09 |
Replace calls to map__set with calls to either map__det_insert or
Estimated hours taken: 3 Replace calls to map__set with calls to either map__det_insert or map__det_update. In some cases this required a small amount of code reorganization. |
||
|
|
3ec8a17ffc |
Enable the code to treat `__' as an alternative syntax for module
Estimated hours taken: 8 Enable the code to treat `__' as an alternative syntax for module qualification, after fixing various places in the compiler where we use `__' in ways that are incompatible with this. compiler/prog_io.m: compiler/prog_io_goal.m: Uncomment the code to handle `__' as module qualification. compiler/intermod.m: compiler/hlds_module.m: compiler/modecheck_unify.m: Fix bugs in the handling of module qualified higher-order terms. compiler/*.m: s/hlds__/hlds_/g compiler/passes_aux.m: s/process__/process_/g compiler/pragma_c_gen.m: compiler/code_gen.m: s/code_gen__/pragma_c_gen__/ for the predicates defined in pragma_c_gen.m (this ought to have been done when the code was first moved from code_gen.m to pragma_c_gen.m). compiler/llds.m: s/llds__proc_id/llds_proc_id/g The reason for this was to avoid ambiguity between proc_id in hlds_pred.m and llds__proc_id in llds.m. compiler/quantification.m: compiler/make_hlds.m: compiler/mercury_to_c.m: s/goal_vars/quantification__goal_vars/g The reason for this was to avoid ambiguity between goal_vars in quantification.m and goal_util__goal_vars in goal_util.m. compiler/dupelim.m: compiler/optimize.m: s/dupelim__main/dupelim_main/g The reason for this change is that a program can only have one main/2 predicate. compiler/prog_io_dcg.m: Remove the old "temporary hack" to strip off and ignore io__gc_call/1, since the new handling of `__' broke it. It was only useful for optimizing NU-Prolog performance, which we don't care about anymore. compiler/mercury_compile.m: compiler/modules.m: compiler/intermod.m: compiler/prog_io.m: Remove occurrences of io__gc_call. compiler/llds_out.m: compiler/base_type_info.m: Ensure that we properly handle the special hacks in mercury_builtin where predicates from other modules (e.g. term__context_init) are defined in mercury_builtin because they are needed for type_to_term and term_to_type. llds_out.m: don't put `mercury_builtin' in the mangled names for those symbols. base_type_info.m: handle types whose status is "imported" in their own module. |
||
|
|
91c4330db7 |
The first half of a change to introduce nondet pragma C goals.
Estimated hours taken: 12 The first half of a change to introduce nondet pragma C goals. This half makes the necessary modifications to the HLDS; the next half will modify the LLDS and emit it. prog_data: Add a new pragma type for nondet pragma c_codes; these specify the names of a a bunch of variables to save across backtracking, and a list of label names to which backtracking may take place. Rename is_recursive to may_call_mercury, since this is a more direct expression of the meaning. prog_io: Move much of the functionality to new files. prog_io_dcg, prog_io_goal, prog_io_pragma, prog_io_util: New files, made up of pieces of prog_io. hlds_goal: Add an extra argument to the pragma_c_goals to store the extra information present in the new type of pragma c_codes. det_analysis: Take into account that the new type of pragma_c goal may have more than one solution. goal_util: Rename variables in the new field of pragma_cs. live_vars: Allocate stack slots to the saved variables in the new type of pragma_c goals. make_hlds: Handle the new type of pragma_c goals. mercury_output, hlds_out: Output the new type of pragma_c goals. garbage_out: Rename type "det" to "frame_type". others: Ignore one more arg of pragma_c goals or import prog_io_util. |
||
|
|
54bb1c4a67 |
Move the code that generates code for pragma_c_codes to a new module.
Estimated hours taken: 3 code_gen, pragma_c_code: Move the code that generates code for pragma_c_codes to a new module. llds: Change the representation of reg and temp lvals, in order to create the concept of a "register type" and to reduce memory requirements. Also add a comment indicating a possible future extension dealing with model_non pragma_c_codes. code_exprn, code_info: Add the ability to request registers of a given type, or a specific register, when acquiring registers. bytecode, bytecode_gen, call_gen, dupelim, exprn_aux, follow_vars, frameopt, garbage_out, jumpopt, llds_out, middle_rec, opt_debug, opt_util, store_alloc, string_switch, tag_switch, unify_gen, vn_block, vn_cost, vn_filter, vn_flush, vn_order, vn_temploc, vn_type, vn_util, vn_verify: Small changes to accommodate the new register representation. hlds_goal: Add a comment indicating a possible future extension dealing with model_non pragma_c_codes. inlining: Add a comment indicating a how to deal with a possible future extension dealing with model_non pragma_c_codes. |
||
|
|
3243dbe238 |
The only significant change in this checkin is that liveness.m now
Estimated hours taken: 0.5 The only significant change in this checkin is that liveness.m now tries to compute the best resume_locs for negations (it already did for if-then-elses and disjunctions; leaving out negations was an oversight in my earlier checkin). The other changes are only syntactic: I have removed the cont-lives and nondet-lives field from goal_info, since they are not used anymore. I have replaced the nondet-lives field in code_info, which is not used anymore, with a follow-vars field, which is not used yet (but will be). Some of the "read" access predicates in hlds_goal did not have "get" in their name; I added them. |
||
|
|
08a5f48e2c |
Take the code generator a big step closer to notes/ALLOCATION.
Estimated hours taken: _____ Take the code generator a big step closer to notes/ALLOCATION. The new code generator emits code that is smaller and faster than the code we used to emit. Nondet liveness is no longer used; nondet live sets are always empty. In code that was being modified anyway, remove its handling. Other uses will be removed later (this keeps this change from being far too big; as it is it is merely too big). Similarly for cont-lives. In several places, clarify the code that gathers several code pieces together. call_gen: Unset the failure continuation and flush the resume vars to their stack slots before nondet calls. Move the code that decides whether a nondet call can be a tailcall to code_info. code_aux: Remove the code to handle resume points, since these are now handled in the specific constructs that need them. Replace it with a sanity check. code_exprn: Add a predicate to place multiple vars. code_gen: Remove the predicate code_gen__generate_forced_goal, since it packaged together some operations that should be executed at different times. Don't unset the failure continuation after every nondet goal; this is now done in the constructs that need it. Modify the handling of negation to use resume point info according to notes/ALLOCATION. Remove the predicate code_gen__ensure_vars_are_saved which was use to save all lives variables to the stack before nondet disjunctions and if-then-elses; we don't do that anymore. code_info: Significantly simplify and document the handling of failure continuations, and make the types involved abstract types. Factor out common code in the handling of det and semi commits. Keep track of "zombies", variables that are dead wrt forward execution but whose values we need because they may be needed at a resume point we can reach. Remove several now unneeded predicates, and introduce new predicates to help other modules. code_util: Add a couple of predicates to check whether ia goal cannot fail before flushing all variables to the stack, and whether a goal cannot flush any variables to the stack. These are used in liveness to decide which entry labels will be needed at resume points. disj_gen: Unify the handling of det and semi disjunctions. Model the code handling of nondet disjunctions on the code handling pruned disjunctions. It is possible that the handling of nondet and pruned disjunctions can also be unified; the new code should make this significantly easier. Make the code conform to notes/ALLOCATION. This means saving only the variables mentioned in the resume_point field, not flushing all live variables to the stack at the start of a nondet disjunction, handling zombies, and using the new method of flushing variables at the ends of branched structures. ite_gen: Unify the handling of det and semi if-then-elses. Model the code handling of nondet if-then-elses on the code handling det/semi if-then-elses. It is possible that the handling of nondet and pruned if-then-elses can also be unified; the new code should make this significantly easier. Make the code conform to notes/ALLOCATION. This means saving only the variables mentioned in the resume_point field, not flushing all live variables to the stack at the start of a nondet if-then-else, handling zombies, and using the new method of flushing variables at the ends of branched structures. Apply the new rules about liveness in if-then-elses, which say that the else part is parallel not to the then part but to the conjunction of the condition and the then part. dense_switch, lookup_switch, string_switch, switch_gen, tag_switch, middle_rec: Use the new method of flushing variables at the ends of branched structures. Don't call remake_with_store map; switch_gen will do so. Fix an old bug in lookup_switch. The code in switch_gen which looked for the special case of a two-way switch used to use a heuristic to decide which one was recursive and which one was a base case. We now check the codes of the cases. hlds_goal: Adjust the structure of the resume_point field to make it easier to use. Add a more convenient access predicate. hlds_out: Don't print the nondet liveness and cont live fields, since they are not used anymore. Comment out the printing of the context field, which is rarely useful. Modify the printing of the resume_point field to conform to its new definition. live_vars: Use the resume_point field, not the nondetlives field, to decide which variables may be needed on backward execution. Remove some code copied from liveness.m. liveness: Put the several pieces of information we thread through the traversal predicates into a single tuple. Don't put variables which are local to one branch of a branched structure into the post-birth sets of other branches. Apply the new rules about liveness in if-then-elses, which say that the else part is parallel not to the then part but to the conjunction of the condition and the then part. Variables that are needed in the else part but not in the condition or the then part now die in at the start of the condition (they will be protected by the resume point on the condition). We now treat pruned and non-pruned disjunctions the same way wrt deadness; the old way was too conservative (it had to be). We still mishandle branches which produce some variables but can't succeed. mercury_compile: Liveness now prints its own progress message with -V; support this. store_alloc: When figuring out what variables need to be saved across calls, make sure that we put in interference arcs between those variables and those that are required by enclosing resume points. Don't compute cont-lives, since they are not used anymore. livemap: Fix the starting comment. |
||
|
|
ee24e66a71 |
Switch from using a stack of store_maps in the code_info to govern what
Estimated hours taken: 2.5 Switch from using a stack of store_maps in the code_info to govern what goes where at the end of each branched structure to using the store map fields of the goal expressions of those structures. Fix variable names where they resembled the wrong kind of map(var, lval). code_info: Remove the operations on stacks of store maps. Modify the generate_forced_saves and remake_with_store_map operations to take a store_map parameter. When making variables magically live, pick random unused variables to hold them, since we can no longer use the guidance of the top store map stack entry. This may lead to the generation of some excess move instructions at non-reachable points in the code; this will be fixed later. code_gen: Remove the store map push and pop invocations. Modify the generate_forced_goal operation to take a store_map parameter. code_exprn: Export a predicate for use by code_info. middle_rec, disj_gen, ite_gen, switch_gen, dense_switch, lookup_switch, string_switch, tag_switch: Pass the store map around to get it to invocations of the primitives in code_gen and code_info that now need it. goal_util: Name apart the new follow_vars field in hlds__goal_infos. (This should have been in the change that introduced that field.) common, constraint, cse_detection, det_analysis, dnf, excess, follow_code, intermod, lambda, lco, liveness, make_hlds, mode_util, modes, polymorphism, quantification, simplify, switch_detection, typecheck, unique_modes, unused_args: Fix variable names. follow_vars, store_alloc: Add comments. |
||
|
|
096e738e29 |
Ensure that the store maps at the ends of branched control structures
Estimated hours taken: 1 store_alloc: Ensure that the store maps at the ends of branched control structures contain entries for all live variables and no other variables, that every variable is mapped to a distinct location, and that these locations are real (not artificial locations employed as a convention). liveness: (Rename and) export a predicate, to allow its duplicate in store_alloc to be removed. |
||
|
|
f8da25795a |
Documented the distinction between the three kinds of uses we have
Estimated hours taken: 3 hlds_goal: Documented the distinction between the three kinds of uses we have for map(var, lval): stack_slots, store_map and follow_vars. Added a new field, follow_vars, to hlds__goal_info. follow_vars: Attach the follow_vars information to the kinds of goals listed in notes/ALLOCATION. hlds_out: Print out the follow_vars field. Make some other outputs easier to read. hlds_pred: Remove the follow_vars field of the proc_info, since the follow_vars of the goal_info of the goal of the procedure has taken its place. code_gen: Use the follow_vars field from the main goal's goal_info, rather than the follow_vars field of the proc_info. store_alloc: Attach the last follow_vars not to the proc_info but to the main goal. |
||
|
|
622b165a69 |
Fix some bugs with the handling of partially instantiated
Estimated hours taken: 16 Fix some bugs with the handling of partially instantiated variables which have `no_tag' types. N.B. This fix does not handle the case of passing a partially instantiated variable of a no_tag type to polymorphic predicate. However, polymorphic predicates with partially instantiated modes are a bit of a dodgy case anyway. mode_util.m: Change mode_to_arg_mode to handle `no_tag' types properly. unify_gen.m: Change the code to handle `no_tag' types properly. arg_info.m, bytecode_gen.m: Pass the type of the variable, not just its mode, to mode_to_arg_mode, since whether a variable is `top_in' or not may depend on the type. live_vars.m, liveness.m, store_alloc.m, unify_gen.m: Use `mode_to_arg_mode(..., top_in)' rather than `mode_is_input(...)', since here we're concerned with the low-level concept of top_in/top_out rather than the higher-level notion of input/output. modecheck_unify.m: In split_complicated_subunifies, `mode_to_arg_mode(..., top_in)' rather than `mode_is_input(...)', for same reason as above. (In other parts of mode analysis we're concerned with the higher-level notion, but split_complicated_subunifies is basically just there for the code generator.) type_util.m, make_tags.m, shapes.m: Put the test for a `no_tag' type into a utility predicate type_is_not_tag_type in type_util.m. make_hlds.m: Change the code for add_builtin so that it puts the correct type annotations in the pred_info. (The previous code was wrong, but the problem didn't show up until the new code in the other parts of this change tried to use the var_types field of the pred_info.) |
||
|
|
613f8c06d4 |
Replace the two delta_liveness fields of the goal_info with four
Estimated hours taken: 1.5
goal_util:
Replace the two delta_liveness fields of the goal_info with four
separate fields, {pre,post}{births,deaths}, since they were being
used separate most of the time in any case. The new arrangement
will require less storage.
other files:
Use the interface predicates for getting at these sets separately.
There are no algorithmic changes in this checkin.
|
||
|
|
06e05928e1 |
Makes instmap and instmap_delta into ADTs.
Estimated hours taken: 38 Makes instmap and instmap_delta into ADTs. compiler/code_gen.m: compiler/code_info.m: compiler/cse_detection.m: compiler/det_analysis.m: compiler/dnf.m: compiler/goal_util.m: compiler/higher_order.m: compiler/hlds_goal.m: compiler/hlds_out.m: compiler/hlds_pred.m: compiler/live_vars.m: compiler/liveness.m: compiler/lookup_switch.m: compiler/mode_debug.m: compiler/mode_info.m: compiler/modecheck_call.m: compiler/modecheck_unify.m: compiler/modes.m: compiler/polymorphism.m: compiler/simplify.m: compiler/store_alloc.m: compiler/switch_detection.m: compiler/transform.m: compiler/uniq_modes.m: compiler/unused_args.m: Miscellaneous minor changes to use the new instmap.m compiler/constraint.m: Removed unnecessary duplication of code in constraint__checkpoint/4 and constraint__no_output_vars/2. compiler/det_util.m: Changed no_output_vars/4 to det_no_output_vars/4, moved body of code to instmap.m. compiler/instmap.m: Added abstract types instmap/0, instmap_delta/0. Added predicates: instmap__init_reachable/1, instmap__init_unreachable/1, instmap_delta_init_reachable/1, instmap_delta_init_unreachable/1, instmap__is_reachable/1, instmap__is_unreachable/1, instmap_delta_is_reachable/1, instmap_delta_is_unreachable/1, instmap__from_assoc_list/2, instmap_delta_from_assoc_list/2, instmap__vars/2, instmap__vars_list/2, instmap_delta_changed_vars/2, instmap_delta_lookup_var/3, instmap__set/3, instmap_delta_insert/4, instmap_delta_apply_instmap_delta/3, instmap_delta_restrict/3, instmap_delta_delete_vars/3, instmap__no_output_vars/4, instmap_delta_apply_sub/4, instmap__to_assoc_list/2, instmap_delta_to_assoc_list/2. Renamed predicates: instmap__lookup_var/3 (was instmap_lookup_var/3) instmap__lookup_vars/3 (was instmap_lookup_vars/3) instmap__apply_instmap_delta/3 (was apply_instmap_delta/3) instmap__merge/5 (was instmap_merge/5) instmap__restrict/3 (was instmap_restrict/3) Moved predicates: merge_instmap_delta/5 (from mode_util.m) Removed predicates: instmapping_lookup_var/3 compiler/mode_util.m: Moved merge_instmap_delta/5 to instmap.m |
||
|
|
24fdb52210 |
If the condition of an if-then-else contains only builtins,
Estimated hours taken: 0.5 live_vars: If the condition of an if-then-else contains only builtins, don't insist on the variables live on entry to the condition being allocated stack slots. This fixes the inefficiecy problem with int__abs noticed by Fergus. hlds_out: For internal and/or inline calls, print out that fact with -V. store_alloc: Remove an unintended comment. |
||
|
|
cdc1c3872c |
Fix singleton-variable warning in my last commit.
Estimated hours taken: 0.01 Fix singleton-variable warning in my last commit. |
||
|
|
6af61e59dd |
If X is assigned to Y, treat it as a hint that the preferred location
Estimated hours taken: 1 follow_vars: If X is assigned to Y, treat it as a hint that the preferred location for X is the same as the preferred location for Y. store_alloc: In the store maps at the ends of branched control structures, don't allocate storage to variables that aren't live at that point. |
||
|
|
5d64b759db |
The main changes are
Estimated hours taken: 12
The main changes are
1 associating a name with the arguments of constructors
2 removing the follow_vars field from calls, higher-order calls
and complicated unifications, since they are not used
3 merging the follow_vars and store_alloc passes, since they logically
belong together
4 add a new module, lco, for detecting opportunities for last
call optimization modulo constructor application; it won't
actually apply the optimization until the mode system becomes
expressive enough to handle it (this module detects 529 opportunities
in the compiler and library)
5 make "-O3 --optimize-value-number" do the right thing; previously,
it used not to apply value numbering because the vnrepeat option
defaulted to zero
6 don't refer to .err2 files anymore; use .err instead.
prog_data:
The list associated with each value of type "constructor" now
contains not only the types of the arguments but their names as well.
equiv_type, hlds_data, hlds_out, make_hlds, mercury_to_{goedel,mercury},
mode_util, module_qual, shapes, type_util, unify_proc:
Modify the traversal of type definitions to account for the names
in the lists inside values of type "constructor".
prog_io:
Parse argument names. An unrelated change is that we now
check whether :- pred declarations give modes to some of their
arguments but not to all, in which case we return an error.
hlds_goal:
Remove the follow_vars field from calls, higher-order calls
and complicated unifications.
*.m:
Handle the new arities of calls, higher order calls and complicated
unifications.
mercury_compile:
Don't call follow_vars directly anymore, but do call lco if its option
is set. Also flush the main output before a call to maybe_report_stats
to prevent ugly output.
store_alloc:
Call follow_vars directly.
follow_vars:
Expose the initialization and traversal predicates for store_alloc.
lco:
Find opportunities for last call optimization modulo constructor
application.
passes_aux:
Add a HLDS traversal type for lco.
optimize:
Consider the vnrepeat count to be zero unless value numbering is on.
options:
Set the default value of vnrepeat to 1.
modules:
Don't refer to .err2 files.
|
||
|
|
5fe0f4f82c |
A bunch of changes required to fix problems in code generation for
Estimated hours taken: 24 A bunch of changes required to fix problems in code generation for model_det and model_semi disjunctions. simplify.m: Don't convert all model_det and model_semi disjunctions into if-then-elses, because that doesn't work if the disjuncts have output variables, which can happen (e.g. with cc_nondet disjunctions) disj_gen.m: Fix a bug in the code generation for semidet disjunctions: don't forget to jump to the end of the disjunction after each disjunct! liveness.m, live_vars.m, store_alloc.m, disj_gen.m: Treat backtracking in model_det and model_semi disjunctions as shallow backtracking rather than deep backtracking. This means that rather than pushing all live variables onto the stack at the start of a model_det/semi disjunction, and using the nondet_lives to keep track of them, we instead treat these disjunctions a bit more like an if-then-else and use the ordinary liveness/deadness to keep track of them. code_aux.m: Change code_aux__pre_goal_update so that it only applies the post-deaths if the goal is atomic. Applying the *post*-deaths to the set of live variables in the *pre*-goal update only makes sense for atomic goals. (I think previously we only ever generated post-deaths for atomic goals, but now we generate them also for goals inside model_det or model_semi disjunctions.) code_gen.pp, middle_rec.m: Pass an is-atomic flag to code_aux__pre_goal_update. hlds_goal.m: Add some comments. goal_util.m: Fix bugs in goal_util__name_apart_goalinfo. It wasn't applying the substitution to all the appropriate fields. code_exprn.m: Improve the error message for one of the internal errors. hlds_out.m: Print the stack slot allocations in the HLDS dump again. |
||
|
|
5c149e55b2 |
Mode analyser reorganisation.
Estimated hours taken: 20
Mode analyser reorganisation.
compiler/mode_util.m:
Removed: instmap_init/1, apply_instmap_delta/3, instmap_lookup_var/3,
instmapping_lookup_var/3, instmap_restrict/3, map_restrict/3 (all
moved to instmap.m).
compiler/hlds_goal.m:
Removed the declarations of instmap_delta, instmap and instmapping.
compiler/mode_errors.m:
Added report_mode_errors/2 (was modecheck_report_errors, from
modes.m).
compiler/modes.m:
Predicates now exported:
modecheck_goal/4
modecheck_goal_expr/5 (previously named modecheck_goal_2/5)
handle_extra_goals/8
mode_context_to_unify_context/3
Moved to mode_errors.m:
modecheck_report_errors/2
Moved to instmap.m:
compute_instmap_delta/4
instmap_merge/3
instmap_lookup_vars (was instmap_lookup_arg_list/3)
compute_instmap_delta/4
Moved to mode_debug.m:
Type port/0
mode_checkpoint/4
Moved to modecheck_call.m:
modecheck_call_pred/7
modecheck_higher_order_call/10
modecheck_higher_order_pred_call/4
modecheck_higher_order_func_call/7
Moved to modecheck_unify.m:
modecheck_unification/9
categorize_unify_var_var/12
categorize_unify_var_functor/11
categorize_unify_var_lambda/9
Moved to mode_info.m:
mode_info_error/4
mode_info_add_error/3
compiler/code_gen.pp, compiler/code_info.m, compiler/constraint.m,
compiler/cse_detection.m, compiler/det_analysis.m, compiler/det_util.m,
compiler/dnf.m, compiler/goal_util.m, compiler/higher_order.m,
compiler/hlds_out.m, compiler/hlds_pred.m, compiler/live_vars.m,
compiler/liveness.m, compiler/lookup_switch.m, compiler/polymorphism.m,
compiler/simplify.m, compiler/store_alloc.m, compiler/switch_detection.m,
compiler/transform.m, compiler/unused_args.m:
Imported instmap.m
New files:
compiler/instmap.m:
Handle operations associated with instmaps.
compiler/modecheck_unify.m:
Handle mode checking of unifications.
compiler/modecheck_call.m:
Handle mode checking of calls
compiler/mode_debug.m:
Code to trace the actions of the mode checker.
|
||
|
|
a15c032df7 |
Flesh out the code already here for traversing module_infos,
Estimated hours taken: 4 passes_aux: Flesh out the code already here for traversing module_infos, making it suitable to handle all the passes of the back end. mercury_compile: Use the traversal code in passes_aux to invoke the back end passes over each procvedure in turn. Print a one-line message for each predicate if -v is given (this fixes a long-standing bug). excess.m, follow_code.m, follow_vars.m, live_vars.m, lveness.m, store_alloc.m: Remove the code to traverse module_infos, since it is now unnecessary. export.m: Remove an unused argument from export__produce_header_file_2. others: Move imports from interfaces to implementations, or in some cases remove them altogether. |
||
|
|
0e1e0b0b91 |
Implement recursive' and non_recursive' pragma c_code declarations.
Estimated hours taken: 4 Implement `recursive' and `non_recursive' pragma c_code declarations. This allows the compiler to optimize cases when the C code is known to not call Mercury code. It's also necessary to allow C code which modifies the hp register to work (such code must be declared `non_recursive', otherwise the registers will be saved and restored over it). To make things bootstrap OK, the old pragma c_code declarations default to `non_recursive'. prog_data.m, hlds_goal.m: Add new field c_is_recursive to pragma c_code goals. prog_io.m: Parse the new `recursive' and `non_recursive' pragma c_code declarations. make_hlds.m: Pass the c_is_recursive field from the parse tree to the HLDS. live_vars.m: For non-recursive C code, don't save variables on the stack. code_gen.pp: For non-recursive C code, don't save variables on the stack, don't mark the succip as needing to be saved, and don't call save_registers() and restore_registers(). *.m: Change c_code/5 to c_code/6. |
||
|
|
af15674b0e |
set union and intersection are more efficient in some
Estimated hours taken: 0.2 set union and intersection are more efficient in some implementations if you give the arguments in a particular order. Our convention is big set first, small set second. These changes just swap the order of the arguments in a few places. compiler/modes.m,store_alloc.m: change the order of the arguments in a couple of calls to set__intersect and set__union. |
||
|
|
140ff7c9ff |
These now compile without errors. No other promises are made :-)
Estimated hours taken: 5 bytecode*.m: These now compile without errors. No other promises are made :-) options: Adda new option, --generate-bytecode. mercury_compile: Generate bytecode if the option is set. goal_util: Add a predicate to find all the variables in a goal, even the ones that have been quantified. Used by the bytecode generator. call_gen: Add a predicate and export another for use by the bytecode generator. hlds_module: Add a predicate to look up full naming details on a PredId. Used by the bytecode generator. hlds_pred: Remove the follow_vars field from proc_infos, since it is not needed any more. hlds_goal: Remove the store_map field from goal_infos, since it is not needed any more. code_gen, code_info, follow_vars, goal_util, hlds_out, middle_rec, store_alloc: Accommodate the changes in hlds_goal and hlds_pred vn_block: Fix an oversight in my previous change. |
||
|
|
89644bebb2 |
Fixed a bug that caused restores of succip to be put in the wrong
Estimated hours taken: 5 peephole: Fixed a bug that caused restores of succip to be put in the wrong place, but only after predicate-wide value numbering. opt_debug: Added a couple of debugging predicates used in tracking down this bug. value_number: Fix a bug that left a livevals pseudo-op in the wrong place if a single instruction sequence contained more than one such pseudo-op. options: Add --debug-opt. Rename --vndebug to --debug-vn. Add --generate-bytecode. optimize, vn_debug: Use the new routines in opt_debug, and use the new/renamed options. store_alloc: Don't thread follow_vars through the module, since the follow_vars information is not attached directly to branched structures. We now also use the same slot to hold the store map computed by this pass; this should allow the later deletion of the store map slot from goal_infos. follow_code: Removed dead predicate. livemap: Added a comment. |
||
|
|
99e729814f |
Make sure we don't change the goal being analyzed except possibly
Estimated hours taken: 20 det_analysis: Make sure we don't change the goal being analyzed except possibly for the introduction of `some's (which should not hurt anything). Make sure we don't print any error messages except in the final iteration, when all the inputs to the inference are stable. If the --debug-detism options is set, print messages about the progress of inference and checking. Also moved some code around. det_report: Distinguish the handling of warning messages and error messages. simplify: Use the new ability of det_report to separate warnings and errors. passes_aux: Add a new generic pass form, for use by simplify. option: Add --debug-detism (as above), --aditi, which at the moment only enables the disjunctive normal form transformation, and --inlining/--no-inlining, which set the other three flags involved in inlining depending on whether you want standard inlining or none at all. Follow_code used to be set twice and follow_vars not at all; I fixed this. Reenabled optimize_higher_order at -O3. Moved value numbering to -O4 and pred_value_number to -O5. This makes it easier to separate value numbering from the other optimizations (which are likely to be more effective). Divided options_help into sections to avoid excessive compilation times. store_alloc: Base the store map on the follow_vars info attached to the branched structure which I added recently, and not on the follow_vars map being passed around, since it will be more accurate. hlds_out: Print information about follow_vars and store_maps when -D is given. follow_code: Undo an old hack that change to follow_vars has made counterproductive. middle_rec: Fix a bug uncovered by the change to follow_code. When looking for a register to hold the counter, it is not enough to avoid picking a register that appears in the recursive case; we must also avoid registers that occur only in the base case. livemap: Mentioning the code address succip now causes the succip to be considered live. This may or may not fix the bug with pred_value_number miscompiling unused_args.m; the other changes have caused the input to value numbering to change, and they no longer trigger the problem. (Will try to test this later.) mercury_compile: Try to make sure that we print statistics only after passes that were actually executed. Also, reduce the number of lookups of the verbose option. Move some predicates so that the order of their appearance matches the current order of invocation. vn_table: Loosen a sanity check to let xnuc2 pass through it. code_exprn, switch_detection: Minor changes. |
||
|
|
9a7da88ce0 |
Treat higher-order predicate calls as a new sort of goal,
Estimated hours taken: 24 Treat higher-order predicate calls as a new sort of goal, rather than as calls to the special predicate call/N, in order to remove the fixed limit on the number of arguments and on the modes for call/N. Also, remove the restriction on output arguments preceding input arguments in lambda expressions. hlds_goal.m: Add new functor higher_order_call/6 to the hlds__goal type. *.m: Handle new functor higher_order_call/6. arg_info.m: Abstract things a bit more: the argument passing convention for a procedure may be affected by that procedure's types, modes, and code_model, as well as the arg_method. follow_vars.m: Pass down the args_method, since it is now needed for figuring out the arg_info for unifications and higher-order calls. follow_code.m: Treat complicated unifications in the same way as calls. lambda.m: When creating lambda predicates, permute the arguments so that all input arguments come before all output arguments. call_gen.m: When generating higher-order predicate calls, don't abort if outputs precede inputs; instead, generate code assuming that the called predicate's args have been permuted so that the inputs to come before all the outputs. |
||
|
|
d344165793 |
Add a new option, --branch-delay-slot, intended for use by mc on
Estimated hours taken: 3 options: Add a new option, --branch-delay-slot, intended for use by mc on the basis of the configuattion script. It says whether the machine architecture has delays slots on branches. The setting of option should affect whether we set --optimize-delay-slots at -O2, but this doesn't work yet. hlds_goal: Add an extra field to hold follow_vars infromation to disjunctions, switches and if-then-elses. I intend to use this information to generate better code. *.m: Changes to accommodate the extra field. |
||
|
|
2833bfffb7 |
Divided the old hlds.m into four files:
Estimated hours taken: 10
hlds, hlds_module, hlds_pred, hlds_goal, hlds_data:
Divided the old hlds.m into four files:
hlds_module.m defines the data structures that deal with issues
that are wider than a single predicate. These data structures are
the module_info structure, dependency_info, the predicate table
and the shape table.
hlds_pred.m defined pred_info and proc_info, pred_id and proc_id.
hlds_goal.m defines hlds__goal, hlds__goal_{expr,info}, and the
other parts of goal structures.
hlsd_data.m defines the HLDS types that deal with issues related
to data and its representation: function symbols, types, insts, modes.
It also defines the types related to determinism.
hlds.m is now an empty module. I have not removed it from CVS
because we may need the name hlds.m again, and CVS does not like
the reuse of a name once removed.
other modules:
Import the necessary part of hlds.
det_analysis:
Define a type that was up to now improperly defined in hlds.m.
prog_io:
Move the definition of type determinism to hlds_data. This decision
may need to be revisited when prog_io is broken up.
dnf, lambda:
Simplify the task of defining predicates.
llds:
Fix some comments.
mercury_compile:
If the option -d all is given, dump all HLDS stages.
shape, unused_args:
Fix formatting.
|
||
|
|
3d21a0fa2a |
Fixed a bug in the last change - we were incorrectly storing
Estimated hours taken: 0.1 compiler/store_alloc.m: Fixed a bug in the last change - we were incorrectly storing stuff in the goal_info_cont_lives, clobbering the correct value that was already there. |
||
|
|
440877adb3 |
removed an argument from store_alloc_in_goal_2 which was
Estimated hours taken: 0.2 compiler/store_alloc.m: removed an argument from store_alloc_in_goal_2 which was effectively unused (it always output `no'), and adjusted the caller appropriately. |
||
|
|
64e07ae112 |
There was a problem where variables that die during forward
Estimated hours taken: 5 There was a problem where variables that die during forward execution, and then become live again on backtracking were not being handled correctly. There was some half-working code to deal with the problem. It has now been fixed, and there are some new test cases for the regression tests. compiler/.cvsignore: added *.ql since they become very irritating after a while... compiler/inlining.m: added a couple of comments make a bit of the code more concise. compiler/*.m: changes to handle nondet-liveness correctly. |
||
|
|
3224e94532 |
A new pass to remove unnecessary assignment unifications.
excess: A new pass to remove unnecessary assignment unifications. mercury_compile: Call the new excess assignment module. options: Add a new option, excess_assign, to control the new optimization. Add another, num-real-regs, to specify how many of r1, r2 etc are actually real registers. The default is now set to 5 for kryten; later it should be supplied by the mc script, with a value determined at configuration time. tag_switch: Use num-real-regs to figure out whether it is likely to be worthwhile to eliminate the common subexpression of taking the primary tag of a variable. Also fix an old performance bug: the test for when a jump table is worthwhile was reversed. value_number, vn_block: Do value numbering on extended basic blocks, not basic blocks. vn_debug: Modify an information message. labelopt: Clean up an export an internal predicate for value numbering. Replace bintree_set with set. middle_rec: Prepare for the generalization of middle recursion optimization to include predicates with an if-then-else structure. cse_detection: Fix a bug: when hoisting a common desconstruction X = f(Yi), create new variables for the Yi. This avoids problems with any of the Yis appearing in other branches of the code. goal_util: Add a new predicate for use by cse_detection. common: Fix a bug: recompute instmap deltas, since they may be affected by the optimization of common structures. code_info: Make an error message more explicit. det_analysis: Restrict import list to the needed modules. *.m: Import assoc_list. |
||
|
|
f75693e80a |
The C interface.
The changes made allow declarations of the form: :- pragma(c_code, predname(Varname1::mode1, Varname2::mode2, ...), "Some C code to execute instead of a mercury clause;"). There are still a couple of minor problems to be fixed in the near future: If there is a regular clause given as well as a pragma(c_code, ...) dec, it is not handled well, and variables names '_' are not handled well. prog_io.m: parse the pragma(c_code, ...) dec. hlds.m: define a new hlds__goal_expr 'pragma_c_code'. make_hlds.m: insert the pragma(c_code, ...) dec. as a pragma_c_code into the hlds. det_analysis.m: infer that pragma_c_code goals are det. modes.m: convince the mode checker that the correct pragma variables are bound etc. quantification.m: quantify the variables in the pragma(c_code, ...) dec. code_gen.pp: convert pragma_c_code into pragma_c (in the llds). llds.m: define a new instr, pragma_c. Output the pragma_c hlds_out.m: mercury_to_mercury.m: mercury_to_goedel.m: spit out pragma(c_code, ...) decs properly *.m: handle the new pragma_c_code in the hlds or the new pragma_c in the llds |
||
|
|
ce9a5cf7d5 |
Optimize away unifications with dead variables.
modes.m: Optimize away unifications with dead variables. (The code generator already does that, but by that time we have already allocated unnecessary stack slots for them.) code_exprn.m: Avoid generating sequences such as `r2 = r3; r3 = r2;' when a register already contains the correct value. (This change was in fact at least as much Tom's work as mine.) store_alloc.m: For disjunctions, we only want to allocate registers for the variables that are output by the disjunction. The inputs should go in framevars, not in registers. This avoids much of the register-shuffling in the code generated for e.g. list__member(out, in). (This change was in fact at least as much Tom's work as mine.) |