mirror of
https://github.com/Mercury-Language/mercury.git
synced 2025-12-16 14:25:56 +00:00
ec86c88404a46a2bbfb8dad31852f430d5ce7eb0
34 Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
c6812299c2 |
Remove support for --args simple. We don't use it, we won't use it even for
Estimated hours taken: 4.5 Remove support for --args simple. We don't use it, we won't use it even for experiments, and it is unnecessary complication. If anybody were using --args simple, this would need bootstrapping, but since nobody does, there is no need, and this can be committed as an ordinary change. compiler/options.m: doc/user_guide.texi: scripts/*.in: scripts/*.sh-subr: Remove the --args option. compiler/globals.m: Remove the args_method global and its access predicates. compiler/handle_options.m: Don't set the args_method global from the option. compiler/arg_info.m: Remove support for --args simple. This allows us to remove a now redundant argument from an exported predicate. compiler/mercury_compile.m: Remove the code for passing -DCOMPACT_ARGS to the C compiler. compiler/bytecode_gen.m: compiler/fact_table.m: compiler/follow_vars.m: compiler/live_vars.m: compiler/call_gen.m: Don't pass the unnecessary argument to arg_info. compiler/call_gen.m: compiler/unify_gen.m: Remove now unnecessary assertions. compiler/hlds_pred.m: Don't include an args_method in proc_infos; instead, include a slot that says whether the procedure's address is taken or not. (In most cases, this determined whether the args_method was simple or compact.) We will need this bool in the near future (when we generate layout structures for procedures whose address is taken). Modify the signatures of exported predicates to accommodate this change to the data structure. compiler/hlds_out.m: Print the new slot, not the args_method. compiler/lambda.m: When creating procedures from lambdas, set the address-taken slot to address_is_taken instead of setting up its args_method. compiler/make_hlds.m: Minor changes to conform to the changes in the signatures of the predicates exported from hlds_pred.m. compiler/check_typeclass.m: compiler/clause_to_proc.m: compiler/dnf.m: compiler/magic.m: compiler/magic_util.m: compiler/modecheck_call.m: compiler/pd_info.m: compiler/post_typecheck.m: compiler/unify_gen.m: Minor changes to conform to the changes in the signatures of the predicates exported from hlds_pred.m and make_hlds.m. runtime/mercury_type_info.h: Remove the conditional definition of the macros that provided an argument-method-independent way of referring to the registers holding the inputs and outputs of e.g. unification procedures. We don't need the independence anymore, and using registers instead of macros in the code ensures that maintainers are aware of register reuse issues (e.g. they copy an input from r1 before overwriting it with an output). runtime/mercury_conf_param.h: runtime/mercury_grade.h: Remove support for the args method component of the grade. runtime/mercury_ho_call.c: runtime/mercury_tabling.c: library/*.m: Conform to the changes in runtime/mercury_type_info.h by effectively applying the #defines appropriate to compact args by hand. Remove code and data structures only needed for simple args. Remove comments needed only in the presence of uncertainty about the args method. |
||
|
|
085c8b8113 |
Make it possible to compile a module (e.g. std_util) without debugging,
Estimated hours taken: 18
Make it possible to compile a module (e.g. std_util) without debugging,
while still allowing debuggable code called from that module via higher-order
predicates (e.g. solutions) to have a proper stack trace.
compiler/options.m:
Add the new option --stack-trace-higher-order.
compiler/mercury_compile.m:
Always invoke continuation_info and stack_layout, since it is no
longer the case that either all procedures or none get layout
structures generated for them, and the other modules are in a better
position to make that decision.
compiler/continuation_info.m:
Handle the extra tests required by the change to mercury_compile.m.
When we gather info about a procedure, remember whether that
procedure must have a procedure layout that includes the procedure id
section.
compiler/stack_layout.m:
Use the flag remembered by continuation_info to help decide
whether we need procedure layout structures.
Fix an old space wastage: after generating marker saying that
the second and later groups of fields of a procedure layout are
not present, do not generate another marker saying that the
third group of fields is not present. Since it was in the wrong
position, it did not have the right meaning; it only worked because,
due to the presence of the first marker, it was never looked at anyway.
compiler/code_gen.m:
Use the new capability of continuation_info.m to require
procedure layouts including procedure id sections for any predicate
that has higher-order arguments, if --stack-trace-higher-order is set.
compiler/globals.m:
Rename want_return_layouts as want_return_var_layouts, since this
is a more accurate representation of what the predicate does.
compiler/call_gen.m:
compiler/code_info.m:
Conform to the change in globals.m.
compiler/llds_out.m:
Separate the c_modules containing compiler-generated code into two
groups, those that define labels that have stack layouts and those
that don't. In most cases one or the other category will be empty,
but with --stack-trace-higher-order, the c_modules containing
higher-order procedures will have stack layouts, while others will
not.
Reorganize the way the way the initialization functions are generated,
by putting c_modules falling into different categories into different
bunches. c_module falling into the first category always have their
initialization code included, while those in the second category
have it included only if the old flag MR_MAY_NEED_INITIALIZATION
is set.
Delete the obsolete #define of MR_STACK_TRACE_THIS_MODULE.
Improve some predicate names, in an effort to prevent confusion
about what a "file" is (since the code uses more than one meaning,
given the presence of --split-c-files).
compiler/pragma_c_gen.m:
Fix an old bug: s/NONDET_FIXED_SIZE/MR_NONDET_FIXED_SIZE/.
Required for the change to library/string.m.
doc/user_guide.texi:
Document the new option.
runtime/mercury_goto.c:
Simplify the conditions under which labels get added to the label
table with:
- The macros init_{entry,label,local}_ai always add
the label to the label table without a layout structure.
- The macros init_{entry,label,local}_sl always add it with a layout
structure.
- Whether the macros init_{entry,label,local} with no suffix
add the label to the label table depends on the values of other
configuration parameters, but they will never include a layout
structure.
The intended use is that any label that has a layout structure should
be initialized with a _sl macro. Any other label that should always
be in the label table if the label table is needed at all (labels
such as do_fail) should be initialized with _ai. Everything else
should be initialized with a suffixless macro.
runtime/mercury_conf_params.c:
Remove MR_USE_STACK_LAYOUTS and MR_STACK_TRACE_THIS_MODULE, since
due to the simplification of mercury_goto.h, they are not used anymore.
runtime/mercury_stack_layout.h:
Remove the old macros for creating layout structures with bogus
contents, and replace them with new macros for creating layout
structures with meaningful contents.
runtime/mercury_engine.c:
runtime/mercury_wrapper.c:
Remove bogus layout structures. Ensure the labels defined here
always get into the label table.
runtime/mercury_ho_call.c:
Remove bogus layout structures. Add proper ones where necessary.
runtime/mercury_bootstrap.c:
runtime/mercury_type_info.c:
Remove bogus layout structures.
runtime/mercury_boostrap.h:
Add this new file for bootstrapping purposes.
Temporarily #define NONDET_FIXED_SIZE as MR_NONDET_FIXED_SIZE, since
pragma_c_gen.m refers to the former until the update to it gets
installed.
runtime/Mmakefile:
Add a reference to mercury_boostrap.h.
library/builtin.m:
Remove bogus layout structures.
library/array.m:
library/benchmarking.m:
library/private_builtin.m:
Remove bogus layout structures. Add proper ones.
library/std_util.m:
Remove bogus layout structures. Add proper ones.
Replace references to framevar(n) with references to MR_framevar(n+1).
Fix an old bug in code under #ifndef COMPACT_ARGS: in the
implementation of mercury____Compare___std_util__univ_0_0_i1, the
succip register was not being saved across the call to
mercury__compare_3_0.
library/string.m:
Remove the need for bogus layout structures, by converting the
implementation of string__append(out, out, in) from hand-written
C module into nondet pragma C code.
|
||
|
|
16f3d4ccaa |
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. |
||
|
|
09141817ba |
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.) |
||
|
|
6921e0e015 |
Add a `--debug' option for Mercury-level debugging
Estimated hours taken: 6 Add a `--debug' option for Mercury-level debugging using the trace-based debugger. scripts/init_grade_options.sh-subr: scripts/parse_grade_options.sh-subr: scripts/mgnuc.in: scripts/ml.in: compiler/options.m: compiler/handle_options.m: compiler/mercury_compile.m: Split the old `--debug' option into `--low-level-debug' (formerly the absence of -DSPEED, now handle by -DLOWLEVEL_DEBUG) and `--c-debug' (passes -g to C compiler). Delete the old `debug' grade. Add support for new options `--require-tracing' (makes --trace minimum equivalent to --trace interfaces, and passes -DMR_REQUIRE_TRACING to C compiler) `--stack-trace' (passes -DMR_STACK_TRACE to C compiler; actually this one was already supported) and `--debug' (implies previous two), with corresponding grade modifiers `.trace', `.strce', and `.debug'. Actually I think there's little point in specifying just one of `--require-tracing' and `--stack-trace' so for the moment I'm just providing `--debug': the code for the more fine-grained options and grade modifiers has been added but commented out. runtime/mercury_conf_param.h: Document the new configuration parameter MR_REQUIRE_TRACING and the existing but undocumented parameter MR_STACK_TRACE. runtime/mercury_grade.h: Include MR_REQUIRE_TRACING in the mangled grade identifier. compiler/globals.m: compiler/handle_options.m: compiler/options.m: Allow new tracing type `--trace default', and make it the default. This gets replaced with `full' if require_tracing is yes or `minimal' if require_tracing is no. Also `--trace minimum' gets replaced with `interface' if require_tracing is yes. doc/user_guide.texi: Document the new `--debug', `--low-level-debug', and `--c-debug' options. scripts/mgnuc.in: compiler/mercury_compile.m: doc/user_guide.texi: Change things so that `--c-debug' does not imply `--no-c-optimize'. configure.in: Add `-fomit-frame-pointer' to CFLAGS_FOR_GOTOS on alpha-*. Empirically, this seems to be needed, otherwise lots of the test cases fail when compiled with `--no-c-optimize'. (It might also be needed for other architectures, I don't know.) |
||
|
|
4845a3782b |
Fix a typo in Zoltan's changes for tracing: s/"mininum"/"minimum"/
Estimated hours taken: 0.1 compiler/globals.m: Fix a typo in Zoltan's changes for tracing: s/"mininum"/"minimum"/ |
||
|
|
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.
|
||
|
|
803fb1c727 |
Remove the last vestiges of support for type_info representations
Estimated hours taken: 0.5 compiler/options.m: compiler/handle_options.m: compiler/globals.m: compiler/polymorphism.m: runtime/mercury_type_info.h: Remove the last vestiges of support for type_info representations other than "shared-one-or-two-cell". |
||
|
|
bb4442ddc1 |
Update copyright dates for 1998.
Estimated hours taken: 0.5 compiler/*.m: Update copyright dates for 1998. |
||
|
|
c6a012bf18 |
Fix the handling of copy/2.
Estimated hours taken: 0.2 Fix the handling of copy/2. library/mercury_builtin.m: Implement copy/2 properly, using deep_copy(). Add unsafe_promise_unique/2 with the same semantics as the old copy/2. library/io.m: library/set_bbbtree.m: compiler/handle_options.m: compiler/typecheck.m: compiler/mode_info.m: compiler/globals.m: Change some occurrences of copy/2 to call unsafe_promise_unique/2. library/io.m: Change io__get_stream_names and io__set_stream_names to not use unique modes (this seems the simplest way for the moment of avoiding some ugly calls to unsafe_promise_unique). |
||
|
|
f9ad85698a |
Add termination analysis to the compiler. The termination analysis
Estimated hours taken: 500 Add termination analysis to the compiler. The termination analysis annotates each procinfo structure with termination information stating whether each procedure is guaranteed to terminate. Add transitive intermodule optimization to the compiler. Transitive intermodule optimization uses .trans_opt files to store optimization information. The difference between .trans_opt files and .opt files is that .trans_opt files may depend on other .trans_opt files, whereas .opt files may only depend on a .m file. compiler/termination.m: New file. The main module which controls the termination analysis. compiler/term_pass1.m: New file. This file implements the first pass of the termination analysis which attempts to derive relationships between the relative sizes of variables. This information is used by term_pass2.m compiler/term_pass2.m: New file. The second pass of the termination analysis attempts to prove that each predicate or function in the program is guaranteed to terminate. compiler/term_util.m: New file. Contains utilities which are used in various stages of the termination analysis. compiler/term_errors.m: New file. Contains predicates for printing out error messages produced by termination analysis. compiler/trans_opt.m: New file. This module contains predicates for both reading in and writing .trans_opt files. compiler/globals.m: compiler/handle_options.m: compiler/options.m: Various modifications to handle the new options. Some of the new options imply other options, and the `--termination-norm' option is a string option which needs processing. compiler/hlds_goal.m: Added a comment that the list(uni_mode) subfield of construct, and the unify_mode subfield of unify are not necessarily valid when the unification applies to higher order terms. compiler/hlds_out.m: Added code to output termination information, as well as code to print out the new markers. compiler/hlds_pred.m: Added the termination subfield to the proc_info structure and added code to support it. Also added support for the new markers. compiler/make_hlds.m: compiler/mercury_to_mercury.m: compiler/module_qual.m: compiler/modules.m: compiler/prog_io_pragma.m: Added support for the new pragmas, `termination_info', `teminates', `check_termination' and `does_not_terminate'. compiler/prog_data.m: Added the new pragmas to the pragma_type. Also reformatted the type declarations to conform with the coding specifications. compiler/prog_io.m: Reformatted some code and comments. compiler/mercury_compiler.m: Added code to call the termination analyser and to call the predicate which creates .trans_opt files. doc/reference_manual.texi: Documented the termination analysis and the new pragmas. doc/user_guide.texi: Documented the new options. |
||
|
|
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. |
||
|
|
327a5131e2 |
Remove support for term_to_type and type_to_term implemented as special
Estimated hours taken: 5 Remove support for term_to_type and type_to_term implemented as special preds. Remove support for one-cell and one-or-two-cell type_infos (now shared-one-or-two-cell type_infos). Move definitions that were in mercury_builtin.m back to where they belong. This code has been removed because it is no longer used, and was no longer being maintained but was still quite complex. compiler/globals.m: compiler/handle_options.m: compiler/mercury_compile.m: compiler/options.m: Remove one_cell and one_or_two_cell from type_info methods. compiler/polymorphism.m: Remove term_to_type and type_to_term support. Remove one_cell and one_or_two_cell from type_info methods. Fix documentation to reflect the new situation. compiler/special_pred.m: compiler/unify_proc.m: Remove term_to_type and type_to_term support. library/list.m: Put the definition of `list' back into list.m library/mercury_builtin.m: Take the definitions of `list', `term', `var', `var__supply', etc, out of this module. Remove type_to_term, term_to_type, det_term_to_type, term__init_var_supply, term__create_var, term__var_to_int and term__context_init. Remove references to USE_TYPE_TO_TERM and #ifdefs around SHARED_ONE_OR_TWO_CELL_TYPE_INFO. library/std_util.m: Remove references ONE_OR_TWO_CELL_TYPE_INFO, and code that handles one-cell typeinfo comparisons. library/term.m: Add type_to_term, term_to_type, det_term_to_type, term__init_var_supply, term__create_var, term__var_to_int and term__context_init back to term.m. Add new implementation of type_to_term/2. library/uniq_array.m: Fix a typo in a comment - term_to_type/3 instead of term_to_type/2. runtime/call.mod: Remove special case code for unify, compare, index for one-cell typeinfos. Remove code for type_to_term/2. runtime/type_info.h: Remove references to ONE_CELL_TYPE_INFO or ONE_OR_TWO_CELL_TYPE_INFO. Make sure only SHARED_ONE_OR_TWO_CELL_TYPE_INFO. Remove references to USE_TYPE_TO_TERM. compiler/base_type_layout.m: compiler/bytecode_gen.m: compiler/code_util.m: compiler/delay_slot.m: compiler/det_util.m: compiler/fact_table.m: compiler/hlds_data.m: compiler/hlds_goal.m: compiler/mode_debug.m: compiler/tree.m: library/bag.m: library/queue.m: Import module `list' or `term' (or both). |
||
|
|
1a2e04a068 |
Implement shared-one-or-two-cell type_infos for grades without static
Estimated hours taken: 25 Implement shared-one-or-two-cell type_infos for grades without static code addresses. This allows us to use functor, arg, expand, deep_copy, etc without changes in all grades. compiler/base_type_info.m: - If static code addresses are not available, eliminate the special procedures, and output the constant 0 instead of a code address. - We now keep the `eliminated' predicates in the base_gen_info structure, so that dead_proc_elim knows they are referenced from the base_type_info. compiler/dead_proc_elim.m: - For the moment, don't eliminate any special preds - the analysis to so this safely is quite complex so we take a conservative approach - base_type_infos are always needed, and hence the special preds are always referenced. - Also, fix a bug in the handling of eliminated procs - if they are eliminated elsewhere, any eliminated here should be added find the total number. (this bug doesn't occur presently due to the conservative approach we now make). compiler/globals.m: compiler/handle_options.m: - Change the handling of type_info_method option - we no longer need static addresses to do shared-one-or-two-cell. - Add predicate globals__have_static_code_addresses/2 to check for this feature. - Make shared-one-or-two-cell the default type_info method. compiler/llds_out.m: - Output initialisation code for the base_type_infos in this module as part of the module initialisation. - Don't declare base_type_infos as const if the don't have static code addresses, because we'll have to initialise them at runtime. - Don't make decls of base_type_infos `const' if we don't have static code addresses. compiler/polymorphism.m: - Update examples of transformed code to include base_type_layouts, clarify difference between shared and non-shared one-or-two-cell. library/mercury_builtin.m: - Conditionally reference entry labels of builtin special preds, using `MR_MAYBE_STATIC_CODE()' macro. - Replace `const' in handwritten base_type_info structs with `MR_STATIC_CODE_CONST'. - Add initialisation code to fill in the code addresses. runtime/type_info.h: - Conditionally define MR_STATIC_CODE_ADDRESSES. - Define macros to initialise base_type_infos: mercury_init_builtin_base_type_info, and mercury_init_base_type_info - Define `MR_STATIC_CODE_CONST' (which is `const' if static code addresses are available, and blank otherwise). _ Define MR_MAYBE_STATIC_CODE(X) which is X if static code addresses are available, and 0 otherwise. - Make shared-one-or-two-cell the default setting, don't require static code addresses for one-or-two-cell. - Create versions of make_typelayout_for_all_tags for 0, 1, 2 and 3 tagbits, so as to save space, add error message if we try to use more than 3 tagbits. - Improve layout and commenting, break file up into sections. - Fix typos. |
||
|
|
a2e36bffe4 |
Most of this change is preparing for the generation of Prolog code, which
Estimated hours taken: _____ Most of this change is preparing for the generation of Prolog code, which is not ready yet. I am committing the part change because Tom wants the performance fix to unify_gen installed ASAP. unify_gen: Det deconstructions used to always cause the flushing of any cached code for creating the cell being deconstructed. This turns out to be quite bad for performance in some cases, so det deconstructions now update only the cache. vn_cost: Speed up slightly the code for computing the costs of lvals. options: Add some new options. The --generate-prolog will tell the compiler to emit idiomatic Prolog code, the dialect being specified via a new --prolog-dialect option. The --optimize-constructor recursion option will switch on tail recursion module constructor application. (Anybody got a better name?) globals: Make the value of the --prolog-dialect option a component of the global structure. handle_options: Use the value of the --prolog-dialect option when creating the global structure. hlds_pred: Add a predicate for ensuring that every variable in a procedure has a unique name. This will be useful when generating Prolog code. passes_aux: Add a new type of traversal that threads an abstract type (a cookie) through the various invocations of the predicate-valued argument. This will be useful when generating Prolog code. |
||
|
|
539854bb20 |
Prepare for the new type_info representation.
Estimated hours taken: 2 Prepare for the new type_info representation. options: Add a --type-info option to specify which type_info representation should be used. globals: Add a field to the global tuple giving the type_info method. handle_options: Convert the type_info option value to the global value. hlds_data: Associate an import_status with type definitions. This will be needed to figure out whether the base_type_info associated with the type needs to be exported or not. hlds_out: Print out the status field of type definitions. make_hlds: Compute the right value for the status fields of type definitions. type_util: Fix spelling. |
||
|
|
c70dbe9e2b |
When we are processing the flushing of create expressions, make sure
Estimated hours taken: 2 code_exprn: When we are processing the flushing of create expressions, make sure the Lval we are creating into isn't a field reference. This avoids deep field of field of field of ... nesting. It does introduce references to high register numbers, but this is a lesser evil, and Tom and I plan to fix this anyway. arg_info, globals, options: Change --args old to --args simple. options: Make some help messages more specific. code_aux, code_exprn, code_info, det_report, make_hlds, mercury_to_goedel, prog_io, typecheck: Changes to accommodate the move from varset__lookup_name to varset__search_name. |
||
|
|
bc2b8632b1 |
Add support for the compact argument passing convention.
Estimated hours taken: 6 arg_info: Add support for the compact argument passing convention. The proper handling of higher order calls etc is still missing. globals: Added a third global type, args_method, current either "old" or "compact". passes_aux: Moved some auxiliary predicates from mercury_compile and options to passes_aux. constraint, det_analysis, make_hlds, modules, optimize, undef_types: Import and refer to passes_aux. mercury_compile, handle_options: Remove the predicates moved to passes_aux. Also move the option postprocessing code to a new module, handle_options. Another change is that we stop after syntax errors if the new option --halt-at-syntax-errors is set. handle_option: New module for option postprocessing. options: Remove the option lookup predicates, which were obsolete. Add new options --args, --halt-at-syntax-errors and --opt-level. Add a special handler for --opt-level. lookup_switch: Call getopt to look up options, not options. value_number, vn_block: Extended basic blocks with more than one incr_hp pose a problem for value numbering when using boehm_gc, because value numbering coalesces all the allocations into one. Previously we did not optimize such sequences. I modified value numbering to divide up such blocks into smaller blocks, each with at most one incr_hp, and optimize these. At the moment, some of these blocks contain deeply nested field refs, which value numbering is very slow to handle; code_exprn should be modified to fix these. value_number: Rename usemap to useset, since this is more accurate. Fixed a bug in --pred-value-number, which manifested itself as the generation of duplicate labels. labelopt: Rename usemap to useset, since this is more accurate. |
||
|
|
6d7f4b9b30 |
Undo dylan's changes in the names of some library entities,
Estimated hours taken: 1.5 Undo dylan's changes in the names of some library entities, by applying the following sed script s/term_atom/term__atom/g s/term_string/term__string/g s/term_integer/term__integer/g s/term_float/term__float/g s/term_context/term__context/g s/term_functor/term__functor/g s/term_variable/term__variable/g s/_term__/_term_/g s/std_util__bool_/bool__/g to all the `.m' and `.pp' files in the compiler and library directories. The reason for undoing these changes was to minimize incompatibilities with 0.4 (and besides, the changes were not a really good idea in the first place). I also moved `bool' to a separate module. The main reason for that change is to ensure that the `__' prefix is only used when it genuinely represents a module qualifier. (That's what dylan's changes were trying to acheive, but `term__' does genuinely represent a module qualifier.) compiler/*.m: Apply sed script above; where appropriate, add `bool' to the list of imported modules. |
||
|
|
b87de68334 |
Implement unique modes. We do not handle local aliasing yet, so this
------------------------------------------------------- Implement unique modes. We do not handle local aliasing yet, so this is still not very useful, except for io__state. Destructive update is not yet implemented. Also note that this really only implements "mostly unique" variables that may be non-unique on backtracking - we don't check that you don't backtrack over I/O, for example. prog_io.m, mode_util.m, modes.m, inst_match.m: Major changes to Handle unique modes. mercury_to_mercury.m, polymorphism.m, prog_out.m, undef_modes.m: Use `ground(Uniqueness)' rather than just `ground'. compiler/*.m: Fix compile errors now that unique modes are enforced: add a few calls to copy/2, and comment out lots of unique mode declarations that caused problems. typecheck.m, mode_info.m: Hack around the use of unique modes, which doesn't work because we don't allow local aliasing yet: make the insts `uniq_type_info' and `uniq_mode_info' not unique at all, and add a call to copy/2 when extracting the io_state from type_info or mode_info. ------------------------------------------------------- Plus a couple of unrelated changes: hlds.m: Change the modes for the special predicates from `ground -> ground' to `in', so that any error messages that show those modes come out looking nicer. Add a new shared_inst_table for shared versions of user-defined insts. mercury_to_goedel.m: Use string__is_alnum_or_underscore. |
||
|
|
ac4f8ba0fb |
Add copyright messages.
compiler/*: Add copyright messages. Change all occurences of *.nl in comments to *.m. compiler/mercury_compile.pp: Change the output to the .dep files to use *.m rather than *.nl. (NOTE: this means that `mmake' will not work any more if you call your files *.nl!!!) |
||
|
|
d8c9479872 |
Override the MERCURY_LIB_OBJS variable when invoking ml.
Makefile.mercury: Override the MERCURY_LIB_OBJS variable when invoking ml. This avoids some bootstrapping problems. Also, add mercury_compile.nu. Makefile.common: Bump NU-Prolog's -u option up to 2000 (8M), to avoid some memory problems. array.nl, bintree.nl, char.nl, dir.nl, globals.nl, list.nl, map.nl, modes.nl, prog_util.nl, stack.nl, std_util.nl, string.nl, term.nl: Avoid the use of implied modes. code_info.nl, bimap.nl, make_hlds.nl, mercury_compile.nl, mercury_to_mercury.nl, unify_proc.nl: Fix determinism errors which had previously not been discovered because of either implied modes or running out of memory. (Note that I had to change the interface to bimap__lookup, since it's not possible to make it bidirectional.) code_util.nl, llds.nl, opt_debug.nl, value_number.nl: Rename `operator' as `binary_op'. hlds.nl, code_info.nl, unify_gen.nl, llds.nl, opt_debug.nl, switch_gen.nl: *** Handle simple cases of higher-order pred terms. *** (We don't yet handle taking the address of an overloaded predicate or a predicate with multiple modes. We don't handle closures. call/1 and call/N are not yet implemented. This has not yet been tested.) make_hlds.nl: Modify the mode priority ordering so that semidet modes get selected before det ones. llds.nl: Don't include the priority part of the mode number in the mangled label name. *** Note: this will break some things! *** mercury_compile.nl: Move the NU-Prolog hacks into mercury_compile.nu.nl. switch_gen.nl: Fix a simple logic bug in handling the grab/slap of the code_info. prog_io.nl, builtins.nl, int.nl: Fix bugs and omissions with handling of the new arithmetic operators. prog_io.nl: As a quick hack, strip off calls to io__gc_call (this avoids spurious error messages which are due to the fact that we don't get mode analysis right in those cases). |
||
|
|
693d42285f |
Rename globals__lookup*option as globals__io_lookup*option.
*.nl: Rename globals__lookup*option as globals__io_lookup*option. Create new globals__lookup*option predicates. Fix up the option handling in the code generator. |
||
|
|
534e5c221e |
Fix lots of determinism problems.
*.nl: Fix lots of determinism problems. |
||
|
|
a29f0da038 |
Add a whole bunch of new options.
options.nl: Add a whole bunch of new options. Please read `mercury_compile --help', everyone! code_gen.nl: Use the `--gc' flag instead of old `save-succip' flag. globals.nl: Added two new global vars for two of the new options; lots of new access predicates. int.nl: Add int__pow; also use slightly more meaningful variable names in the code for the other preds. llds.nl: Output field(...) rvals and lvals with the proper `mktag(...)'. Also a a new mktag(...) rval. make_hlds.nl: Pass the command-line options to make_tags.nl. make_tags.nl: Assign the tags according to the --num-tag-bits option. mercury_compile.nl: Allow more than one file on the command line; Also a little bit of special processing for two of the new options. unify_gen.nl: Rearrange unify_gen__generate_tag_test slightly. Generate better code for tests of complicated_constant_tags. |
||
|
|
e0a02e7adb |
Remove the unused `declared_determinsm' field in the goal_info.
hlds.nl, hlds_out.nl, det_analysis.nl: Remove the unused `declared_determinsm' field in the goal_info. Rename the `inferred_determinism' field as just `determism'. Add a new field `local_determinism'. In det_analysis.nl, Plug the contents of the new `local_determinsm' field in the goal_info into the computation of the determinism for each goal. det_analysis.nl, fix_errs.sed: For the cases which we currently don't handle correctly, generate incorrect code in preference to generating spurious error messages (we still have to handle these cases sometime, but this means that we can deal with them one at a time). arg_info.nl, builtins.nl, code_gen.nl, delay_info.nl, det_analysis.nl, getopt.nl, globals.nl, make_hlds.nl, modes.nl, mode_util.nl, stack.nl, string.nl, string.nu.nl, term.nl, undef_modes.nl, varset.nl: Fix determinism errors uncovered by the changes in the determinism analysis. |
||
|
|
8aa1a88583 |
Fix bug: we need to consult `np_builtin.nl'.
doit.nl: Fix bug: we need to consult `np_builtin.nl'. globals.nl: Add some new access preds. hlds_out.nl: Don't output verbose information about the clauses_info clauses even if --verbose-dump-hlds is set, because the information is wrong - only the proc_info has the correct information. Fix bug in output when --verbose-dump-hlds was not set. Move the delta instmap output to after the goal. mercury_compile.nl: Fix things so that all messages are output to stderr and there is no interleaving of stdout and stderr. Remove the temporary hack I put in last time. code_gen.nl, code_info.nl: Store the proc_info in the code_info. Write a new predicate code_info__cons_id_to_tag to replace the old code_info__cons_id_to_abstag stub. hlds.nl, make_tags.nl: Add string_constant, float_constant, and int_constant to the cons_tags type. Use int_constant instead of enum_constant. |
||
|
|
079b3f15a8 |
remove redundant liveness check.
call_gen.nl: remove redundant liveness check. call_info.nl: bring delta-liveness stuff on-line. goboal.nl string.nl: add detism decls. |
||
|
|
8bf2aacf0b |
Rename a whole bunch of predicates.
*.nl: Rename a whole bunch of predicates. Apart from some manual changes to list.nl, the changes were all generated by applying the following sed script: /[^a-zA-Z_]goedel_expand(/s/goedel_expand(/prog_util__expand(/g /[^a-zA-Z_]goedel_replace(/s/goedel_replace(/prog_util__replace(/g /[^a-zA-Z_]to_upper(/s/to_upper(/char__to_upper(/g /[^a-zA-Z_]to_lower(/s/to_lower(/char__to_lower(/g /[^a-zA-Z_]is_upper(/s/is_upper(/char__is_upper(/g /[^a-zA-Z_]is_lower(/s/is_lower(/char__is_lower(/g /[^a-zA-Z_]is_alpha(/s/is_alpha(/char__is_alpha(/g /[^a-zA-Z_]is_alnum(/s/is_alnum(/char__is_alnum(/g /[^a-zA-Z_]is_alpha_or_underscore(/s/is_alpha_or_underscore(/char__is_alpha_or_underscore(/g /[^a-zA-Z_]is_alnum_or_underscore(/s/is_alnum_or_underscore(/char__is_alnum_or_underscore(/g /[^a-zA-Z_]is_digit(/s/is_digit(/char__is_digit(/g /[^a-zA-Z_]lower_upper(/s/lower_upper(/char__lower_upper(/g /[^a-zA-Z_]io__op(/s/io__op(/term_io__op(/g /[^a-zA-Z_]io__current_ops(/s/io__current_ops(/term_io__current_ops(/g /[^a-zA-Z_]io__read_term(/s/io__read_term(/term_io__read_term(/g /[^a-zA-Z_]io__write_term(/s/io__write_term(/term_io__write_term(/g /[^a-zA-Z_]io__write_constant(/s/io__write_constant(/term_io__write_constant(/g /[^a-zA-Z_]io__write_variable(/s/io__write_variable(/term_io__write_variable(/g /[^a-zA-Z_]mercury_quote_string(/s/mercury_quote_string(/term_io__quote_string(/g /[^a-zA-Z_]mercury_quote_atom(/s/mercury_quote_atom(/term_io__quote_atom(/g /[^a-zA-Z_]mercury_quote_char(/s/mercury_quote_char(/term_io__quote_char(/g /[^a-zA-Z_]mercury_quote_single_char(/s/mercury_quote_single_char(/term_io__quote_single_char(/g /[^a-zA-Z_]delay_info_/s/delay_info_/delay_info__/g /[^a-zA-Z_]process_options(/s/process_options(/getopt__process_options(/g /[^a-zA-Z_]lookup_option(/s/lookup_option(/globals__lookup_option(/g /[^a-zA-Z_]append(/s/append(/list__append(/g /[^a-zA-Z_]member(/s/member(/list__member(/g /[^a-zA-Z_]merge(/s/merge(/list__merge(/g /[^a-zA-Z_]member_chk(/s/member_chk(/list__member_chk(/g /[^a-zA-Z_]length(/s/length(/list__length(/g /[^a-zA-Z_]condense(/s/condense(/list__condense(/g /[^a-zA-Z_]same_length(/s/same_length(/list__same_length(/g /[^a-zA-Z_]split_list(/s/split_list(/list__split_list(/g /[^a-zA-Z_]reverse(/s/reverse(/list__reverse(/g /[^a-zA-Z_]delete(/s/delete(/list__delete(/g /[^a-zA-Z_]delete_first(/s/delete_first(/list__delete_first(/g /[^a-zA-Z_]sort(/s/sort(/list__sort(/g /[^a-zA-Z_]nth_member_search(/s/nth_member_search(/list__nth_member_search(/g /[^a-zA-Z_]nth_member_lookup(/s/nth_member_lookup(/list__nth_member_lookup(/g /^goedel_expand(/s/goedel_expand(/prog_util__expand(/g /^goedel_replace(/s/goedel_replace(/prog_util__replace(/g /^to_upper(/s/to_upper(/char__to_upper(/g /^to_lower(/s/to_lower(/char__to_lower(/g /^is_upper(/s/is_upper(/char__is_upper(/g /^is_lower(/s/is_lower(/char__is_lower(/g /^is_alpha(/s/is_alpha(/char__is_alpha(/g /^is_alnum(/s/is_alnum(/char__is_alnum(/g /^is_alpha_or_underscore(/s/is_alpha_or_underscore(/char__is_alpha_or_underscore(/g /^is_alnum_or_underscore(/s/is_alnum_or_underscore(/char__is_alnum_or_underscore(/g /^is_digit(/s/is_digit(/char__is_digit(/g /^lower_upper(/s/lower_upper(/char__lower_upper(/g /^io__op(/s/io__op(/term_io__op(/g /^io__current_ops(/s/io__current_ops(/term_io__current_ops(/g /^io__read_term(/s/io__read_term(/term_io__read_term(/g /^io__write_term(/s/io__write_term(/term_io__write_term(/g /^io__write_constant(/s/io__write_constant(/term_io__write_constant(/g /^io__write_variable(/s/io__write_variable(/term_io__write_variable(/g /^mercury_quote_string(/s/mercury_quote_string(/term_io__quote_string(/g /^mercury_quote_atom(/s/mercury_quote_atom(/term_io__quote_atom(/g /^mercury_quote_char(/s/mercury_quote_char(/term_io__quote_char(/g /^mercury_quote_single_char(/s/mercury_quote_single_char(/term_io__quote_single_char(/g /^delay_info_/s/delay_info_/delay_info__/g /^process_options(/s/process_options(/getopt__process_options(/g /^lookup_option(/s/lookup_option(/globals__lookup_option(/g /^append(/s/append(/list__append(/g /^member(/s/member(/list__member(/g /^merge(/s/merge(/list__merge(/g /^member_chk(/s/member_chk(/list__member_chk(/g /^length(/s/length(/list__length(/g /^condense(/s/condense(/list__condense(/g /^same_length(/s/same_length(/list__same_length(/g /^split_list(/s/split_list(/list__split_list(/g /^reverse(/s/reverse(/list__reverse(/g /^delete(/s/delete(/list__delete(/g /^delete_first(/s/delete_first(/list__delete_first(/g /^sort(/s/sort(/list__sort(/g /^nth_member_search(/s/nth_member_search(/list__nth_member_search(/g /^nth_member_lookup(/s/nth_member_lookup(/list__nth_member_lookup(/g /[^a-zA-Z_]delete_all(/s/delete_all(/list__delete_all(/g /^delete_all(/s/delete_all(/list__delete_all(/g |
||
|
|
019ee742f8 |
Break modes.nl up into separate modules.
modes.nl, mode_errors.nl, delay_info.nl, mode_info.nl, undef_modes.nl: Break modes.nl up into separate modules. toplevel.nl (plus LOTS of other files): Change the way module imports are handled. Fix the resulting missing import problems found in most of the modules. mode_util.nl: Add predicate inst_is_bound_to_functors/3. switch_detection.nl: New file. Still very incomplete. meta.nl: Remove. This file was old junk. |
||
|
|
9f29364f56 |
Added handling of command-line options.
toplevel.nl, typecheck.nl: Added handling of command-line options. globals.nl: Added predicate `lookup_option'. options.nl: Added new option `-d' / `--dump-hlds'. Also added some new predicates `maybe_write_string' and `maybe_report_stats'. io.nl: Added predicate io__report_stats. The old report_stats should not be used. |
||
|
|
c852e70715 |
Add command-line option handling.
(Command-line options are now parsed, and the option data is saved in the io__state, but the options aren't yet actually used.) |