Commit Graph

654 Commits

Author SHA1 Message Date
Zoltan Somogyi
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.)
1998-06-08 08:29:17 +00:00
Zoltan Somogyi
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.)
1998-06-08 08:27:15 +00:00
Tyson Dowd
3046c9a627 Cleanup deep copy.
Estimated hours taken: 4

Cleanup deep copy.

runtime/mercury_deep_copy.c:
	Use MR_categorize_data, and switch on the result.

	This makes the control flow much simpler -- each case only needs
	to worry about copying the data.
	We can also use fallthru to exploit duplicated code.

	Remove get_base_type_layout_entry, it isn't very useful.

runtime/mercury_type_info.c:
runtime/mercury_type_info.h:
	Define MR_categorize_data and the enum MR_DataRepresentation.

	MR_categorize_data can be used by any function that needs to
	manipulate data.
1998-06-02 05:34:46 +00:00
Tyson Dowd
ff5ff5869c Cleanup deep copy.
Estimated hours taken: 4

Cleanup deep copy.

runtime/mercury_deep_copy.c:
	Use MR_categorize_data, and switch on the result.

	This makes the control flow much simpler -- each case only needs
	to worry about copying the data.
	We can also use fallthru to exploit duplicated code.

	Remove get_base_type_layout_entry, it isn't very useful.

runtime/mercury_type_info.c:
runtime/mercury_type_info.h:
	Define MR_categorize_data and the enum MR_DataRepresentation.

	MR_categorize_data can be used by any function that needs to
	manipulate data.
1998-06-02 05:34:42 +00:00
Tyson Dowd
8c5828bda7 Be more forgiving of a missing SA_RESTART flag for sigaction.
Estimated hours taken: 1

Be more forgiving of a missing SA_RESTART flag for sigaction.

configure.in:
	If using sigaction, don't require SA_RESTART to be available.
	If SA_RESTART is unavailable, warn about it.

runtime/mercury_signal.c:
	Handle a missing SA_RESTART or SA_SIGINFO.
1998-05-27 06:12:03 +00:00
Fergus Henderson
28fdbb082e Move the #include of nonportable header files such as
Estimated hours taken: 0.25

runtime/mercury_trace_external.c:
	Move the #include of nonportable header files such as
	<arpa/inet.h>, etc. inside the `#ifdef MR_USE_EXTERNAL_DEBUGGER'.
1998-05-26 16:33:03 +00:00
Fergus Henderson
247b1c24b9 Fix various invasions of the user's namespace by `mercury_builtin.m',
Estimated hours taken: 6

Fix various invasions of the user's namespace by `mercury_builtin.m',
by splitting mercury_builtin.m into two modules, called builtin.m and
private_builtin.m, and ensuring that the latter is imported as if
by `:- use_module' rather than `:- import_module'.

library/builtin.m:
library/private_builtin.m:
	Split mercury_builtin.m into two modules, builtin.m,
	which contains stuff intended to be public,
	and private_builtin.m, which contains implementation
	details that are not supposed to be public.

library/mercury_builtin.m:
	Add a comment saying that this module is no longer used, and
	should eventually be removed.  I have not removed it yet, since
	that would prevent bootstrapping with the current compiler.  It
	will be removed as a seperate change later, once all the
	changes have propagated.

compiler/prog_util.m:
	Change the definition of mercury_private_builtin_module/1 and
	mercury_public_builtin_module so that instead of automatically
	importing mercury_builtin.m as if by `import_module', the
	copiler will now automatically import builtin.m as if by
	`import_module' and private_builtin.m as if by `use_module'.

compiler/polymorphism.m:
	Change a call to mercury_private_builtin_module/1 for
	unsafe_promise_unique to instead call mercury_public_builtin_module/1.

compiler/unify_proc.m:
	Avoid hard-coding "mercury_builtin" by instead
	calling one of  mercury_{private,public}_builtin_module/1.

runtime/mercury_type_info.[ch]:
library/term.m:
library/std_util.m:
compiler/code_util.m:
	Change a few hard-coded instances of "mercury_builtin"
	to "builtin" or "private_builtin" as appropriate.

runtime/mercury_trace_util.c:
runtime/mercury_trace_internal.c:
library/prolog.m:
compiler/*.m:
	Update comments that refer to "mercury_builtin" to instead
	refer to either "builtin" or "private_builtin".

doc/Mmakefile:
	Don't include the interface to private_builtin.m in the
	library reference manual.

tools/bootcheck:
	Add `-p'/`--copy-profiler' option.  This is needed to get
	the above changes to bootstrap.

tools/test_mercury:
	Pass `-p' to tools/bootcheck.

tests/term/*.trans_opt_exp:
	s/mercury_builtin/builtin/g
1998-05-25 21:55:28 +00:00
Fergus Henderson
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.)
1998-05-20 11:11:57 +00:00
Fergus Henderson
baa8904877 Fix spelling error in comment.
Estimated hours taken: 0.02

runtime/mercury_stack_trace.h:
	Fix spelling error in comment.
1998-05-19 15:16:56 +00:00
Zoltan Somogyi
2f2a450ed0 Move the number of type parameters from the label layout structures
Estimated hours taken: 2

compiler/stack_layout.m:
	Move the number of type parameters from the label layout structures
	to the start of the vector of type parameter locations. Since
	different labels' layouts often have the same set of typeinfo variable
	locations, this saves one word on a large fraction of all label
	layout tables.

	Fix some documentation rot.

runtime/mercury_stack_layout.h:
	Make the corresponding change in the C description of the layout
	structure.

runtime/mercury_trace_internal.c:
	Make the corresponding change in the C code that accesses the layout
	structure.

	Fix an earlier oversight: don't try to materialize type parameters
	that aren't live.
1998-05-19 05:15:10 +00:00
Tyson Dowd
1d430795ed Change int to bool for the need_info argument.
Estimated hours taken: 0.01

runtime/mercury_signal.h:
runtime/mercury_signal.c:
	Change int to bool for the need_info argument.
1998-05-18 08:41:35 +00:00
Tyson Dowd
872d2873ab Fix some problems with signal setting.
Estimated hours taken: 0.5

Fix some problems with signal setting.

runtime/mercury_signal.c:
runtime/mercury_signal.h:
	- Use Code * instead of void * for the type of signal handlers.
	- Use sigaction if HAVE_SIGACTION is defined, not HAVE_SIGINFO_T.
	- Use SA_SIGINFO only if it is defined.
1998-05-18 08:25:56 +00:00
Fergus Henderson
59f26ddb7a Fix a spelling error in the comment that I added in my
Estimated hours taken: 0.1

runtime/mercury_table.h:
	Fix a spelling error in the comment that I added in my
	previous change.
1998-05-17 07:03:14 +00:00
Fergus Henderson
92ed2c27e1 Various bug fixes and other cleanups of the new tabling code.
Estimated hours taken: 1

Various bug fixes and other cleanups of the new tabling code.

library/mercury_builtin.m:
	Fix a couple of bugs in the new tabling code that broke in
	grades other than asm_fast.gc.

runtime/mercury_tabling.h:
	Fix a couple of type errors that caused things to break in
	grades other than asm_fast.gc.
	Change the layout to match our coding guidelines.

runtime/mercury_table_any.c:
	Fix the layout to match our coding guidelines.

runtime/mercury_table_any.h:
runtime/mercury_table_enum.h:
runtime/mercury_table_int_float_string.h:
runtime/mercury_table_type_info.h:
	Add copyright notice.

runtime/mercury_table.h:
	Add a comment pointing out that this is hash tables,
	not tabling.
1998-05-16 15:31:03 +00:00
Zoltan Somogyi
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.
1998-05-16 07:31:33 +00:00
Fergus Henderson
6eac542889 Add missing `#include <errno.h>', needed e.g. on Irix.
Estimated hours taken: 0.1

runtime/mercury_signal.c:
	Add missing `#include <errno.h>', needed e.g. on Irix.
1998-05-15 16:39:35 +00:00
Oliver Hutchison
bcf7dbf9f8 Add support for tabling.
Estimated hours taken: 250

Add support for tabling.

This change allows for model_det, model_semidet and model_non memoing,
minimal model and loop detection tabling.

compiler/base_type_layout.m:
	Update comments to reflect new runtime naming standard.

compiler/det_analysis.m:
	Allow tabling to change the result of det analysis. This is
	necessary in the case of minimal model tabling which can
	turn a det procedure into a semidet one.

compiler/det_report.m:
compiler/hlds_data.m:
	Add code to report error messages for various non compatible
	tabling methods and determinism.

compiler/hlds_out.m:
compiler/modules.m:
	Remove reference to the old memo marker.

compiler/hlds_pred.m:
	Create new type (eval_method) to define which of the available
	evaluation methods should be used each procedure.
	Add new field to the proc_info structure.
	Add several new predicates relating to the new eval_method type.

compiler/inlining.m:
compiler/intermod.m:
	Make sure only procedures with normal evaluation are inlined.

compiler/make_hlds.m:
	Add code to process new tabling pragmas.

compiler/mercury_compile.m:
	Call the tabling transformation code.

compiler/modes.m:
	Make sure that all procedures with non normal evaluation have
	no unique/partially instantiated modes. Produce error messages
	if they do. Support for partially instantiated modes is currently
	missing as it represents a large amount of work for a case that
	is currently not used.

compiler/module_qual.m:
compile/prog_data.m:
compiler/prog_io_pragma.m:
	Add three new pragma types:
		`memo'
		`loop_check'
		`minimal_model'
	and code to support them.

compiler/simplify.m:
	Don't report infinite recursion warning if a procedure has
	minimal model evaluation.

compiler/stratify.m:
	Change the stratification analyser so that it reports cases of
	definite non-stratification. Rather than reporting warnings for
	any code that is not definitely stratified.
	Remove reference to the old memo marker.

compiler/switch_detection.m:
	Fix a small bug where goal were being placed in reverse order.
	Call list__reverse on the list of goals.

compiler/table_gen.m:
	New module to do the actual tabling transformation.

compiler/notes/compiler_design.html:
	Document addition of new tabling pass to the compiler.

doc/reference_manual.texi:
	Fix mistake in example.

library/mercury_builtin.m:
	Add many new predicates for support of tabling.

library/std_util.m:
library/store.m:
	Move the functions :
		ML_compare_type_info
		ML_collapse_equivalences
		ML_create_type_info
	to the runtime.

runtime/mercury_deep_copy.c:
runtime/mercury_type_info.h:
runtime/mercury_type_info.c:
	Move the make_type_info function into the mercury_type_info module
	and make it public.

runtime/Mmakefile:
runtime/mercury_imp.h:
	Add references to new files added for tabling support.

runtime/mercury_string.h:
	Change hash macro so it does not cause a name clash with any
	variable called "hash".

runtime/mercury_type_info.c:
runtime/mercury_type_info.h:
	Add three new functions taken from the library :
		MR_compare_type_info
		MR_collapse_equivalences
		MR_create_type_info.

runtime/mercury_table_any.c:
runtime/mercury_table_any.h:
runtime/mercury_table_enum.c:
runtime/mercury_table_enum.h:
runtime/mercury_table_int_float_string.c:
runtime/mercury_table_int_float_string.h:
runtime/mercury_table_type_info.c:
runtime/mercury_table_type_info.h:
runtime/mercury_tabling.h:
	New modules for the support of tabling.
1998-05-15 07:09:29 +00:00
Tyson Dowd
b97c093a98 Fix a small bug -- an argument was missing from MR_setup_signal.
Estimated hours taken: 0.1

runtime/mercury_prof.c:
	Fix a small bug -- an argument was missing from MR_setup_signal.
	(needed PROFILE_TIME set to uncover this bug).
1998-05-15 05:15:15 +00:00
Tyson Dowd
cd3914c609 More cleanup of the memory management code.
Estimated hours taken: 5

More cleanup of the memory management code.
This time we clean up the signal handler setup code.

runtime/Mmakefile:
	Add new files.

runtime/mercury_memory.c:
	Rename setup_signal() to setup_signals().

runtime/mercury_memory_handlers.c:
runtime/mercury_memory_handlers.h:
	Clean up signal handling.
	Use MR_setup_signal to setup signal handlers.
	Define bus_handler and segv_handler signal handlers, the
	old signal handlers are just one or the other (or both).

runtime/mercury_prof.c:
	Use MR_setup_signal to setup signal handler.

runtime/mercury_signal.c:
runtime/mercury_signal.h:
	New files -- a standard interface for setting up signal
	handlers (a porting base, if you like).
1998-05-14 06:35:16 +00:00
Tyson Dowd
aa641c6121 Clean up memory management code. This mostly involves cleaning up
Estimated hours taken: 5

Clean up memory management code.  This mostly involves cleaning up
the #defines and removing duplicate code.  This is just an incremental
improvement, more changes are expected.

runtime/mercury_conf_param.h:
	Add definitions for MR_CAN_GET_PC_AT_SIGNAL and
	MR_CHECK_OVERFLOW_VIA_MPROTECT.

runtime/mercury_context.c:
	Rename reset_zone() as reset_redzone().

runtime/mercury_memory_handlers.c:
	Define one set of functions with conditional bodies, rather
	than conditional defintions of functions.

runtime/mercury_memory_zones.c:
	Use MR_CHECK_OVERFLOW_VIA_MPROTECT rather than just looking
	for HAVE_MPROTECT and HAVE_SIGINFO.

runtime/mercury_memory_zones.h:
	Only use redzones with MR_CHECK_OVERFLOW_VIA_MPROTECT.

	Correct a comment about how much memory is should be
	given to construct_zone.
	The correct caculation is
		size + unit (for offset) + unit (for hardmax)

	Rename reset_zone as reset_redzone.
1998-05-11 08:23:26 +00:00
Tyson Dowd
7527913d68 Use (void) as parameter list of functions without parameters,
Estimated hours taken: 0.05

runtime/mercury_memory_zones.c:
	Use (void) as parameter list of functions without parameters,
	instead of ().
1998-05-08 02:56:03 +00:00
Tyson Dowd
917c158436 Split mercury_memory.{c,h} into several files.
Estimated hours taken: 5

Split mercury_memory.{c,h} into several files.  Added a few
comments about functions whose declarations have been moved into
the header files, otherwise the content is unchanged.

runtime/Mmakefile:
	Add new files.

runtime/mercury_context.c:
	Add a #include "mercury_memory_handlers.h" as this module
	creates new zones using default_handler.

runtime/mercury_memory.c:
runtime/mercury_memory.h:
	Other code (mostly code to set up the actual memory
	zones we use in the Mercury runtime).

runtime/mercury_memory_handlers.c:
runtime/mercury_memory_handlers.h:
	Signal handlers for memory access violations.

runtime/mercury_memory_zones.c:
runtime/mercury_memory_zones.h:
	The implementation MemoryZone data type.
1998-05-08 02:53:41 +00:00
Fergus Henderson
7192af7ceb Add macros MR_saved_sp(save_area), MR_saved_hp(save_area) etc.
Estimated hours taken: 3

runtime/mercury_regorder.h:
	Add macros MR_saved_sp(save_area), MR_saved_hp(save_area) etc.
	which access the underlying slot in the specified save_area
	rather than the real machine register.

runtime/mercury_regs.h:
	Add definitions for MR_virtual_sp, MR_virtual_hp, etc.
	which access the underlying slot in fake_reg
	rather than the real machine register.
	Add some more comments and move some code around, so as to
	clearly delineate between the different abstraction layers.
1998-05-06 10:26:34 +00:00
Tyson Dowd
561e0d8e19 Use stack layout data structures to do stack dumps.
Estimated hours taken: 1

runtime/mercury_stack_trace.c:
	Use stack layout data structures to do stack dumps.
	Improve the output format, output the determinism and
	mode number of each predicate.
1998-04-24 06:15:27 +00:00
Tyson Dowd
f89be73c94 Fix stack traces dying in -O-1.
Estimated hours taken: 3

Fix stack traces dying in -O-1.

error/1 is usually generated with no stack frame, but in -O-1 it is
generated with one (but doesn't need it).  error/1 passes
MR_dump_stack MR_succip and MR_sp, and MR_dump_stack assumes that
MR_succip is for the topmost stack frame, but if error/1 has a stack
frame, this is not true.

library/require.m:
	Make sure the caller of MR_dump_stack has no stack frame
	by using handwritten code.  We call the handwritten code
	from error/1, and so we have the nice side effect that
	error now appears in the stack dump.

runtime/mercury_stack_trace.h:
	Document that MR_dump_stack assumes the succip is for the
	topmost stack frame.

runtime/mercury_label.h:
	Fix a comment, layout info is for a label, not a procedure.
1998-04-21 05:51:42 +00:00
Tyson Dowd
dd835a5cb8 Fix stack traces, which were broken with recent tracing code changes.
Estimated hours taken: 4

Fix stack traces, which were broken with recent tracing code changes.

runtime/mercury_ho_call.c:
runtime/mercury_wrapper.c:
	Use init_label_sl, instead of init_label.

runtime/mercury_stack_layout.h:
	Update MR_MAKE_STACK_LAYOUT_INTERNAL_* to have new fields
	so that stack layouts generated in this way are correct.

runtime/mercury_stack_trace.c:
	Change algorithm to be a little more robust (doing bit
	operations on a possibly negative integer probably isn't a good
	idea, so check the value isn't -1 first).
1998-04-18 08:06:52 +00:00
Fergus Henderson
ef83c24152 Fix a couple of memory allocation bugs.
Estimated hours taken: 1

runtime/mercury_trace.c:
	Fix a couple of memory allocation bugs.
	Update an obsolete comment.
1998-04-15 07:08:32 +00:00
Fergus Henderson
e76d7e425e Fix a couple of formatting errors in the tracer help message.
Estimated hours taken: 0.1

runtime/mercury_trace.c:
	Fix a couple of formatting errors in the tracer help message.
1998-04-09 03:43:50 +00:00
Zoltan Somogyi
67d8308260 Same as previous message. 1998-04-08 11:36:13 +00:00
Tyson Dowd
951ed445bf Implement nondet stack dumps.
Estimated hours taken: 1

Implement nondet stack dumps.

library/require.m:
	Call MR_dump_stack with MR_curfr.

runtime/mercury_stack_trace.c:
runtime/mercury_stack_trace.h:
	Get MR_curfr as input.
	If we hit a nondet stack frame, handle moving down a frame a
	little differently.
1998-04-07 05:23:07 +00:00
Fergus Henderson
6f065be64a Fix some Mmakefile errors that were diagnosed by `--warn-undefined-variables'.
Estimated hours taken: 1

Fix some Mmakefile errors that were diagnosed by `--warn-undefined-variables'.
Also, make a small fix to mmake.in and add empty definitions for various
Mmake variables to avoid spurious warnings.

scripts/mmake.in:
	Add ` dep*' to the patterns for which we do not
	pass `--warn-undefined-variables'; previously it
	matched "$@" against `dep*', which did not catch the
	case of `mmake -k depend'.
		       ^^^

scripts/Mmake.vars.in:
	Add definition for `ds_subdir'.
	Define `MLLIBS' as `$(EXTRA_MLLIBS)' rather than empty,
	and add empty definition for `EXTRA_MLLIBS'.
	Add empty definition for `MAIN_TARGET'.

Mmakefile:
	Fix misspelling: `deps_subdir' not `dep_subdir'.
	Add empty definitions for `PREINSTALL_HACK', `POSTINSTALL_HACK',
	and `MMAKEFLAGS'.

boehm_gc/Mmakefile:
	Add empty definition for `PROF'.

runtime/Mmakefile:
	Add empty definition for `DLL_CFLAGS'.

library/Mmakefile:
	Add empty definition for `CHECK_TERM_OPTS'.

compiler/Mmakefile:
	Add empty definition for `MTAGSFLAGS'.
1998-03-30 13:03:17 +00:00
Andrew Bromage
2b5f65707f Include some verbose progress messages in the polymorphism pass.
Estimated hours taken: 0.5

compiler/mercury_compile.m:
compiler/polymorphism.m:
	Include some verbose progress messages in the polymorphism pass.

runtime/mercury_memory.h:
runtime/mercury_memory.c:
runtime/mercury_misc.h:
runtime/mercury_misc.c:
	Move checked_malloc() to mercury_memory.c, add checked_realloc().
1998-03-30 03:09:06 +00:00
Fergus Henderson
60eac4cd0c Pass `--warn-undefined-variables', except when making dependencies.
Estimated hours taken: 0.75

scripts/mmake.in:
	Pass `--warn-undefined-variables', except when making dependencies.

runtime/Mmakefile:
scripts/Mmake.vars.in:
	Add empty definitions of a few variables, to avoid warnings with
	`--warn-undefined-variables'.
1998-03-27 08:34:23 +00:00
Oliver Hutchison
19132d25bb Fix bug in copying of array types that caused the elements of
Estimated hours taken: 0.1

runtime/mercury_deep_copy.c:
	Fix bug in copying of array types that caused the elements of
        arrays to be shallow copied.
1998-03-23 04:29:09 +00:00
Thomas Conway
a2071fb30d Add mercury_conf_params.h to the HDRS variable in the Mmakefile
Estimated hours taken: 0.1

runtime/Mmakefile:
	Add mercury_conf_params.h to the HDRS variable in the Mmakefile
	so that it gets installed.
1998-03-17 03:31:28 +00:00
Fergus Henderson
c315607690 Clean up the handling of configuration macros in the runtime.
Estimated hours taken: 4

Clean up the handling of configuration macros in the runtime.

runtime/mercury_conf.h.in:
runtime/mercury_conf_param.h:
	Move the code to set configuration parameters based on
	the values of other configuration parameters from
	mercury_conf.h.in to a new file mercury_conf_param.h,
	because otherwise autoconf munges the code in undesirable ways
	(it replaces all `#undef <foo>' statements with `/* #undef <foo> */').

runtime/mercury_conf.h.in:
runtime/mercury_conf_param.h:
runtime/*.h:
runtime/*.c:
	Use more meaningful names, starting with the usual `MR_' prefix,
	for various configuration parameters:
		- replace the existing configuration macros SPEED with
		  three new macros MR_CHECK_OVERFLOW, MR_LOWLEVEL_DEBUG,
		  and MR_DEBUG_NONDET_STACK;
		- rename DEBUG_GOTOS as MR_DEBUG_GOTOS, and make it
		  implied by MR_LOWLEVEL_DEBUG;
		- rename DEBUG_LABELS as MR_CHOOSE_ENTRY_POINT.

	(But there are still many configuration parameters that don't
	start with `MR_', I'm afraid.)

runtime/CFLAGSFILE:
runtime/mercury_conf_param.h:
	Removed CFLAGSFILE.  The documentation there was had rotted badly.
	I moved most of it to mercury_conf_param.h where hopefully
	it will stand a better chance of being kept up-to-date.
	I added documentation for the configuration parameters added in
	the last year or so.  The documentation here now covers
	every configuration parameter that we use; please keep it that way!

runtime/mercury_debug.h:
	Fix a bug: there was a misplaced "#endif".

runtime/mercury_stack_trace.c:
	Fix yet another misspelling of "deterministic".
1998-03-16 12:23:40 +00:00
Fergus Henderson
d4ad1ae39a Move a comment about MercuryFile from io.m to mercury_types.h,
Estimated hours taken: 0.1

runtime/mercury_types.h:
library/io.m:
	Move a comment about MercuryFile from io.m to mercury_types.h,
	since the definition of the MercuryFile type had been moved.
1998-03-12 19:45:44 +00:00
Fergus Henderson
a16424f6a1 Add support to the Mercury tracer for interacting with an external
Estimated hours taken: 24

Add support to the Mercury tracer for interacting with an external
Opium-style debugger via a socket.

TODO: currently there is no way for the debugger to specify
constraints on the arguments for a `forward_move' query.
The current code for doing that doesn't work.
(However, the reporting of arguments to the debugger
for an `output_current' query works fine.)

runtime/mercury_trace.c:
	Add code to MR_trace() to open a socket connection to
	an external debugger, and to process requests from that
	debugger, and send responses back.

runtime/mercury_trace.h:
runtime/mercury_wrapper.c:
	Call MR_trace_end() from mercury_runtime_terminate() so that
	the external debugger gets notified when the program does
	a (normal) exit.

runtime/mercury_stack_layout.h:
	Fix a bug where the structures here did not match
	the output produced by compiler/stack_layout.m.

library/debugger_interface.m:
	New file.  Declares the Mercury types used for the debugger
	socket interface and defines support routines used by
	runtime/mercury_trace.c.

library/io.m:
runtime/mercury_types.h:
	Move the definition of MercuryFile from library/io.m to
	runtime/mercury_types.h, for use by runtime/mercury_trace.c.

library/io.m:
	When printing out values of type `c_pointer', print out
	the "<<c_pointer>>" string in single quotes, to ensure
	that it has valid syntax for a Prolog or Mercury term.
	This is necessary because otherwise c_pointers in procedure
	arguments could lead to the Mercury process sending a
	syntactically invalid term down the socket to the debugger,
	which would then be unable to parse it.

library/library.m:
	Add reference to debugger_interface.m, so that it gets
	include in libmercury.a.

doc/Mmakefile:
	Make sure that the library/debugger_interface.m does *not*
	get included in the Mercury library reference manual.

runtime/mercury_wrapper.h:
runtime/mercury_wrapper.c:
runtime/mercury_init.h:
util/mkinit.c:
	Declare, define, and initialize pointers to the C functions
	exported by library/debugger_interface.m.
	(This is to avoid having a circular dependency where the
	runtime depends on the library.)

compiler/notes/authors.html:
	Add Erwan Jahier.
1998-03-11 22:07:38 +00:00
Tyson Dowd
f58ee880df Add support for stack dumps, do a stack dump from error/1.
Estimated hours taken: 12

Add support for stack dumps, do a stack dump from error/1.


compiler/Mmakefile:
library/Mmakefile:
profiler/Mmakefile:
runtime/Mmakefile:
	Insert EXTRA_MGNUCFLAGS before CFLAGS or EXTRA_CFLAGS
	becasue mgnuc stops processing its options when it
	encounters a non-mgnuc option.

library/require.m:
	Call MR_dump_stack if error is called.

runtime/Mmakefile:
runtime/mercury_imp.h:
	Add #includes of new files.

runtime/mercury_type_info.h:
	Remove conditional definition of MR_STATIC_CODE_ADDRESSES
	(moved into mercury_conf.h.in).

runtime/mercury_accurate_gc.h:
	Remove stack_layout stuff, leave this file for accurate
	GC specific definitions.

runtime/mercury_conf.h.in:
	Add conditional definitions of MR_INSERT_LABELS,
	MR_USE_STACK_LAYOUTS, MR_NEED_INITIALIZATION_CODE and
	MR_STATIC_CODE_ADDRESSES, depending on various other options.

runtime/mercury_goto.h:
	Insert labels into label table if MR_INSERT_LABELS is defined,
	rather than NATIVE_GC.

util/mkinit.c:
	Initialize if MR_NEED_INITIALIZATION_CODE is defined, rather than
	NATIVE_GC.

runtime/mercury_stack_layout.h:
	All the old stack layout definitions from mercury_accurate_gc.h.
	Add code for MR_DETISM_DET_CODE_MODEL.

runtime/mercury_stack_trace.c:
runtime/mercury_stack_trace.h:
	Implement MR_dump_stack which just provides a dump of the stack
	as far as possible.
	Set MR_INSERT_LABELS and MR_USE_STACK_LAYOUTS if MR_STACK_TRACE
	is set.

runtime/mercury_grade.h:
	Add _strce if stack tracing is enabled in the grade.  This
	might not be a permanent change.

runtime/mercury_ho_call.c:
	Remove unused label declarations.

scripts/mgnuc.in:
	Add --stack-trace and --no-stack-trace options.
	Consolidate some duplicate code.
1998-03-11 06:01:17 +00:00
Simon Taylor
8b1b74de29 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.
1998-02-12 01:25:54 +00:00
Zoltan Somogyi
9797aa4029 This change fixes a bug in the tracer's handling of the virtual registers
Estimated hours taken: 1.5

This change fixes a bug in the tracer's handling of the virtual registers
that are not real registers.

runtime/mercury_regs.h:
	Make the saved_reg macro refer only to the given save area,
	not to the machine registers or to the fake_reg array.

runtime/mercury_trace.c:
	Make sure we save both real and fake registers in the save area.

	Make the internal functions and variables static, and make sure
	everything is prefixed by MR_. Use string concatenation in several
	places to make the code shorter.

tests/misc_tests/debugger_regs.{m,inp,exp}:
	A regression test case to make sure the tracer is handling high
	register numbers properly.
1998-02-04 03:55:54 +00:00
Zoltan Somogyi
5ef3bb6fdc Use stack layout tables to transmit information to the tracer, to allow
Estimated hours taken: 20

Use stack layout tables to transmit information to the tracer, to allow
the tracer to print the names and values of variables at CALL and EXIT ports.
Extend stack layout tables to permit this.

For the time being the tables do not contain information about how to fill
in pseudo-typeinfos, so printing only works for monomorphic procedures.

compiler/llds.m:
	Allow space for variable names in the information we gather about live
	variables at given labels.

compiler/llds_out.m:
	Print out variable names in the information we gather about live
	variables at given labels in comments.

compiler/continuation_info.m:
	Include variable names in the information we gather about live
	variables at given labels.

	Record the determinism of each procedure, not its code model.

compiler/{call_gen,code_gen,code_info}.m:
	Include the names of variables in the data given to
	continuation_info.m.

compiler/options.m:
	Add a new developer-only option, --procid-stack-layout, whose effect
	is to extend stack_layout structures with static info identifying the
	procedure. This is used by execution tracing, and could (should) be
	used by stack tracing and profiling.

	Rename --alternate-liveness as --typeinfo-liveness. This is more
	expressive. Later we should add a new option --trace-liveness, which
	preserves every variable until the end of the clause for use by
	the trace debugger.

compiler/handle_options.m:
	Handle the option implications of --procid-stack-layout.

compiler/stack_layout.m:
	Include the encoded determinism instead of the code model in stack
	layout tables.

	Include variable names in the live data section of stack layout tables
	if they are available.

	Include procedure identification information in the stack layout tables
	if --procid-stack-layout is set.

compiler/trace.m:
	Use the new interface to MR_trace.

compiler/*.m:
	Trivial changes following from the renaming of --alternate-liveness.

runtime/mercury_accurate_gc.h:
	Add macros to decode encoded determinisms.

	Define structs for accessing the stack layout tables.

runtime/mercury_regs.h:
	Define a macro similar to virtual_reg, except in that it can refer
	to an arbitrary memory area, not just fake_reg.

runtime/{mercury_string,mercury_types}.h:
	Move the typedefs of Char, UnsignedChar, String and ConstString
	from mercury_string.h to mercury_types.h to avoid problems with
	circular #includes.

runtime/mercury_trace.[ch]:
	Revise the interface to MR_trace so that it takes the layout table
	of the procedure as an argument. From the layout table, we can get
	to the module name, predicate name, arity, mode number, and
	determinism of the procedure, so we don't need to pass these any more,
	reducing parameter passing overhead. We can also get to information
	about where the input and output arguments are. We now use this
	information to allow the user to print out the value of the arguments
	at the CALL and EXIT ports.

	Change the prompt to a less intrusive "mtrace> ".

runtime/mercury_wrapper.[ch]:
	Add a new global variable, MR_library_trace_browser. We reserve space
	for this variable in mercury_wrapper.c. It will be initialized by the
	automatically generated xxx_init.c file to point to the procedure
	that the tracer will invoke to let the user browse the values of
	variables. This mechanism allows the runtime to maintain its current
	ignorance about the contents of the standard library.

util/mkinit.c:
	Generate additional code in the xxx_init.c files to fill in the value
	of MR_library_trace_browser.

tests/misc_tests/debugger_test.{inp,exp}:
	Add a few printing commands into the input for this test case, and
	update the expected output.
1998-02-03 08:20:12 +00:00
Zoltan Somogyi
37235bf8c8 Fix the same trivial grammar error in two comments.
Estimated hours taken: 0.01

runtime/mercury_accurate_gc.h:
	Fix the same trivial grammar error in two comments.
1998-01-27 22:11:45 +00:00
Fergus Henderson
7d7774a280 Add a call to `fflush(stdout)' before writing to stderr;
Estimated hours taken: 0.25

runtime/mercury_trace.c:
	Add a call to `fflush(stdout)' before writing to stderr;
	this avoids some confusing interleaving between the output of
	the program being debugged and the output of the tracer.
1998-01-25 08:22:49 +00:00
Fergus Henderson
d1795181eb Fix a name clash: the code here and in mercury_heap.h
Estimated hours taken: 0.5

runtime/mercury_debug.h:
runtime/mercury_misc.h:
runtime/mercury_misc.c:
	Fix a name clash: the code here and in mercury_heap.h
	were using the name `incr_hp_msg' to mean two different things.
	The reason this wasn't picked up earlier is that the
	code here is only included conditionally, if DEBUG is defined.
	To fix it, I renamed the one here as `incr_hp_debug_msg'.
1998-01-23 15:26:35 +00:00
Fergus Henderson
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".
1998-01-23 12:12:05 +00:00
Zoltan Somogyi
a3fd46cd4d Implement nondet pragma C codes.
Estimated hours taken: 45

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.
1998-01-13 09:52:25 +00:00
Tyson Dowd
ac8d233cdf Various changes to get stack traces working, and simplify their
Estimated hours taken: 3

Various changes to get stack traces working, and simplify their
implementation.

library/mercury_builtin.m:
runtime/mercury_type_info.c:
	Remove initialization of pred base_type_info from mercury_builtin.m
	and put it into mercury_type_info.c where it belongs.

runtime/mercury_accurate_gc.h:
runtime/mercury_goto.h:
	Fix defintions so that stack traces will work correctly.
	Remove the address from internal stack layouts, it was
	unnecessary and difficult to initialize in a consistent way
	with the entry address.

runtime/mercury_label.c:
	Remove the hack to get labels to work, since it's no
	longer required.

runtime/mercury_wrapper.c:
	Add initialization of stack layouts for some labels that
	got missed somehow during the renaming of files in the
	runtime.
1998-01-06 07:06:06 +00:00
Fergus Henderson
1273bb4449 Delete (actually just `#if 0' out) the code to fixup
Estimated hours taken: 3

mercury_calls.h:
	Delete (actually just `#if 0' out) the code to fixup
	the GP register in call macros; that should not be
	necessary, since restoration of the GP register
	is done in the Define_label() macro.

	This might break the non-asm `jump' and `fast' grades,
	because the non-asm labels don't restore the GP register,
	but those grades don't work on the Alpha anyway, and the
	fact that they ever worked on other architectures is probably
	just coincidence -- restoring the GP register only on returns
	would work most of the time, but I can imagine situations where
	it wouldn't work.  We could fix these grades, but the fixed
	grades would be similar enough to the asm_jump and asm_fast
	grades that I don't think there is any point.
1998-01-04 05:23:50 +00:00
Fergus Henderson
b7141c33d7 Trivial layout change (indent some #if's).
Estimated hours taken: 0.1

runtime/mercury_goto.h:
	Trivial layout change (indent some #if's).
1998-01-01 10:56:14 +00:00