Commit Graph

886 Commits

Author SHA1 Message Date
David Overton
1df5dc64d7 In the definition of MR_body(), cast the first argument to
Estimated hours taken: 1

runtime/mercury_tags.h:
	In the definition of MR_body(), cast the first argument to
	type Word before doing the tag subtraction.
	This is necessary for code such as:
	r3 = MR_const_field(MR_mktag(1), MR_mkword(MR_mktag(1),
		&mercury_const_46), (Integer) 0);
	(which is produced by value numbering).  MR_mkword casts its
	result to type (Word *) which means that MR_body, called from
	within MR_const_field, was doing pointer arithmetic on it and
	thus failing to remove the tag properly.
1999-07-13 05:05:47 +00:00
Tyson Dowd
eae3174a2c Add MR_TYPECTOR_REP_* to the type_ctor_info to describe the
Estimated hours taken: 30  (including debugging)

Add MR_TYPECTOR_REP_* to the type_ctor_info to describe the
representation of this type.

We want to do this because it allows us to check quickly to see
what kind of data representation is being used.  Previously this
information was spread throughout the type_ctor_layout and
type_ctor_functors data structures.  It was complex to interpret
and contained a lot of unnecessary duplication.

We can now omit data structures such as the type_ctor_layout in many
cases (it is only necessary for discriminated unions).  Because we rule
out some of the possible alternatives, the encodings used in the
type_ctor_layout can be simplified.  Also, the functors indicator in
type_ctor_functors can be removed, as it subsumed by this data
structure.

Use this representation in code that uses RTTI.

compiler/base_type_info.m:
	Add a missing alternative to the type_ctor_rep (this was a
	bug).

library/array.m:
library/builtin.m:
library/private_builtin.m:
runtime/mercury_bootstrap.c:
	Use MR_TYPECTOR_REP_* in the type_ctor_infos for builtin types.

library/std_util.m:
runtime/mercury_deep_copy_body.h:
runtime/mercury_tabling.c:
	Use MR_TYPECTOR_REP_* and MR_DISCUNION_TAG_* to dispatch on
	data representations.

	Also, fix a bug in deep_copy when copying floating point values.
	I'm not sure when this stopped working, or if this is exactly
	the right fix, but it is more correct than the previous code.

runtime/mercury_type_info.c:
runtime/mercury_type_info.h:
	Update code to use MR_TYPECTOR_REP_*.
	Use a struct for type_ctor_info.

tests/hard_coded/Mmakefile:
tests/hard_coded/deep_copy.m:
tests/hard_coded/deep_copy.exp:
	Add a test case for deep_copy.
1999-07-06 06:32:33 +00:00
Zoltan Somogyi
88f26e260b Fix some code rot in code that is included only with minimal tabling.
Estimated hours taken: 0.1

runtime/mercury_tabling.c:
	Fix some code rot in code that is included only with minimal tabling.
1999-07-06 02:34:27 +00:00
Fergus Henderson
f022837d9f Fix a bug: the INIT line was missing the `_bootstrap' suffix that
Estimated hours taken: 1

runtime/mercury_bootstrap.c:
	Fix a bug: the INIT line was missing the `_bootstrap' suffix that
	is needed to distinguish this module from the real one.
	This was causing the initialization for unify_c_pointer_module()
	to be run twice, rather than having it run once and having the
	initialization for unify_c_pointer_module_bootstrap() run once.
	This in turn caused the Mercury profiler to fail.

	Also the function sys_init_unify_c_pointer_module_bootstrap()
	was missing, so I added a definition for it.
1999-07-03 10:59:29 +00:00
Tyson Dowd
2eb7e77257 c_pointer needs to be a hand defined type -- up until now everything but
Estimated hours taken: 0.5

c_pointer needs to be a hand defined type -- up until now everything but
the type_ctor_info is hand defined.  We need to be able to change the
contents of the type_ctor_info, however.

compiler/type_util.m:
library/builtin.m:
runtime/mercury_bootstrap.c:
	Make builtin:c_pointer a hand-defined type, doing the usual
	bootstrapping trick.
1999-06-24 04:32:17 +00:00
Peter Ross
85173b93f6 Update the .cvsignore files to work under linux.
Estimated hours taken: 0.25

browser/.cvsignore:
library/.cvsignore:
profiler/.cvsignore:
runtime/.cvsignore:
trace/.cvsignore:
    Update the .cvsignore files to work under linux.
1999-06-18 04:49:03 +00:00
Fergus Henderson
c460b3eec3 Fix a bug: MR_stack_trace_bottom and MR_nondet_stack_trace_bottom
Estimated hours taken: 0.25

runtime/mercury_stack_trace.h:
runtime/mercury_stack_trace.c:
	Fix a bug: MR_stack_trace_bottom and MR_nondet_stack_trace_bottom
	were being _defined_ in the header file.  I changed it so that
	they were only _declared_ in the header file, and defined in the
	.c file.
1999-06-08 03:47:41 +00:00
Tyson Dowd
3ecbe3eed0 Move the type_ctor_infos for array and univ into their proper places.
Estimated hours taken: 0.5

Move the type_ctor_infos for array and univ into their proper places.
This change has bootstrapped on most of our platforms, but actually
causes trouble linking small programs (because it creates runtime ->
library dependencies).  So we should move it as soon as possible.


library/array.m:
library/std_util.m:
	Add type_ctor_info for array and univ.

runtime/mercury_bootstrap.c:
	Remove type_ctor_info for array and univ.
1999-06-02 10:05:08 +00:00
Zoltan Somogyi
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.
1999-06-01 09:46:20 +00:00
Fergus Henderson
dfc4e243cd Simplify the code by deleting unnecessary uses of $(EXTRA_*), etc.
Estimated hours taken: 1

browser/Mmakefile:
compiler/Mmakefile:
library/Mmakefile:
profiler/Mmakefile:
runtime/Mmakefile:
trace/Mmakefile:
util/Mmakefile:
	Simplify the code by deleting unnecessary uses of $(EXTRA_*), etc.
	This is now handled once and for all in scripts/Mmake.vars, and
	so it doesn't need to be separately handled by */Mmakefile.
	This patch also fixes an annoyance where if you set EXTRA_CFLAGS,
	the flags that you set were being passed to mgnuc twice.
1999-06-01 08:16:13 +00:00
Fergus Henderson
81af75fd89 Fix a problem on IRIX caused by my previous attempt to
Estimated hours taken: 2

Fix a problem on IRIX caused by my previous attempt to
fix a problem with <inttypes.h> on Solaris.  The problem
was that IRIX has <inttypes.h>, but its <inttypes.h>
does not define the types that we need.  The fix is to
get configure to explicitly check for the types that we
need, rather than just checking for the header file.

runtime/mercury_conf.h.in:
	Add new macros HAVE_SYS_TYPES, HAVE_INTPTR_T,
	and HAVE_INT_LEASTN_T.

configure.in:
	Add code to check for <sys/types.h>,
	{u,}intptr_t, and {u,}int_least{8,16,32}_t,
	and define HAVE_SYS_TYPES, HAVE_INTPTR_T,
	and HAVE_INT_LEASTN_T accordingly.

runtime/mercury_types.h:
	Define {u,}intptr_t and {u,}int_least{8,16,32}_t
	iff they aren't defined by the system header files,
	instead of assuming that they don't need to be
	defined if we have <stdint.h> or <inttypes.h>.
1999-05-31 18:25:28 +00:00
Tyson Dowd
0e85f9aa48 Making changes to type_ctor_infos for the builtin types array and univ
Estimated hours taken: 2

Making changes to type_ctor_infos for the builtin types array and univ
is much easier if we can simply change their type_ctor_info by hand
rather than detecting them as simple cases.  They already have their
type_ctor_functors and layouts defined by hand anyway.

compiler/type_util.m:
	Turn off the generation of type_ctor_info for the types array:array
	and std_util:univ.

runtime/mercury_bootstrap.c:
	Put type_ctor_infos for these types into the bootstrapping file.
	They are not needed (or wanted) for stage 1, but needed for stage 2.
	We rename the functors and layouts slightly so that the stage 2
	linking doesn't have them multiply defined.
1999-05-31 09:32:10 +00:00
Mark Brown
07cad7c169 If calling from the internal debugger, use readline input for the
Estimated hours taken: 6

If calling from the internal debugger, use readline input for the
interactive term browser and interactive queries.

browser/browse.m:
	Change some if-then-elses to switches, which will help
	catch errors if a new functor is added to the debugger type.

browser/parse.m:
browser/util.m:
	Return a string from util__trace_getline/4 rather than a
	list of chars, which saves converting from a string to a list
	of chars and then back again.

browser/util.m:
	Add a version of util__trace_getline that also takes I/O
	stream arguments.  Pass these arguments to MR_trace_getline.

browser/declarative_oracle.m:
	Call util__trace_getline/4 to do input via readline (if
	available).  Improve error handling.

browser/interactive_query.m:
	Call util__trace_getline to get user input, instead of
	standard library predicates.

runtime/mercury_init.h:
runtime/mercury_wrapper.c:
runtime/mercury_wrapper.h:
trace/mercury_trace_internal.c:
trace/mercury_trace_internal.h:
	Add two I/O stream arguments to MR_trace_getline.
1999-05-30 03:55:13 +00:00
Zoltan Somogyi
e3232306cb Add a module layout structure containing a string table and a table of
Estimated hours taken: 14

Add a module layout structure containing a string table and a table of
pointers to the proc layouts of the module's procedures. This speeds up
debugger initialization, and reduces the executable size of the compiler
by almost 1.2 Mb (about 3.7%) when compiled with debugging.

Instead of representing variables names as strings (32 or 64 bit pointers)
in the debugger's static data structures, with the string's prefix representing
the variable's number (e.g. "5:X"), represent them as a 16-bit variable number
and a 16 bit offset into the module-wide string table. This gains simplicity
of processing (no more search for the ":") and reduces the amount of storage
required, a bit on 32-bit platforms (we don't have to store "5:ModuleInfo"
and "10:ModuleInfo" strings separately, and there are no string prefixes to
store) and more on 64-bit platforms.

The 16-bit limits are generous. A procedure with more than 64K variables will
take forever to compile (that is why we impose a 4K limit on the number
of variables in inlining), and even the string tables of typecheck.m and
make_hlds require less than four kilobytes each. Exceeding the limits
would require code no human would write. Automatically generated code may
be a problem, but the help the debugger can give on such code is limited
already. In any case, we detect overflows and handle them sensibly.

This change does not enhance the debugger to take advantage of the easier
availability of variable numbers, except to improve the implementation
of retry; that will come later.

The inclusion of the procedure table in the module layout structure
reduces the cost of registering all procedures in all modules,
a task usually performed at the time of the setting of the first breakpoint.
This used to require processing all the internal labels in the label table,
and thus used to take a few seconds for large executables. The sweep of
all internal labels is no longer required, so registering is now much faster.

runtime/mercury_stack_layout.h:
	Add the definition of MR_Module_Layout.

	Modify label layouts to represent names as offsets in the string table,
	not as raw character pointers. This required modifing proc layouts
	to include a pointer to the module's layout, so you can find the
	string table.

	Update the macros that look up variable names.

runtime/mercury_layout_util.h:
	Use the updated macros for looking up variable names.

runtime/mercury_wrapper.[ch]:
	Add a new indirect pointer, MR_register_module_layout, which points
	to a function that registers a module layout, or is NULL if debugging
	is not enabled.

runtime/mercury_init.h:
	Declare the function whose address may be assigned to
	MR_register_module_layout in a <main>_init.c file.

util/mkinit.c:
	Initialize MR_register_module_layout with either the address of
	MR_register_module_layout_real or NULL, depending on whether
	debugging is enabled or not.

compiler/continuation_info.m:
	Don't give names (V_n) to nameless variables, because we don't want
	them to be included in the variables debugging knows about.

compiler/llds.m:
	Add a new function symbol to the type data_addr, which stands for
	the module layout structure of the named (now always the current)
	module.

	Add a new function symbol to the type rval_const. The new function
	symbols, multi_string_const, contains an array of characters of an
	explicitly given length, which consists of several strings, each
	terminated by a null character.

compiler/llds_out.m:
	Accommodate the changes to llds.m, and expand the module initialization
	code to register the module layout structure, if the pointer to the
	registration function is not NULL.

compiler/stack_layout.m:
	Generate the new data structures for representing variable names,
	as well as the module layout.

compiler/mercury_compile.m:
	Rename some variables to reflect the fact that stack_layout.m can
	now include a module layout structure in the list of static layout
	structures it returns.

compiler/dupelim.m:
compiler/exprn_aux.m:
compiler/jumpopt.m:
compiler/opt_debug.m:
	Minor changes to accommodate multi_string_consts.

trace/mercury_trace_tables.[ch]:
	Replace the old data structures for recording information about
	each debuggable module with the module layout structure, and
	register module layout structures directly, instead of trying
	to discover them through the internal label table.

trace/mercury_trace.[ch]:
	Now that it is more easily accessible, use variable numbers
	instead of variable names to find the current locations of
	the input arguments when implementing retry. Unlike our previous
	method, this works even if the user names some variables HeadVar__1,
	etc.

	Remove an unnecessary export of an internal function.

trace/mercury_trace_external.c:
trace/mercury_trace_internal.c:
runtime/mercury_layout_util.c:
	Use the updated macros for looking up variable names.
1999-05-28 05:29:51 +00:00
Zoltan Somogyi
60b24d6e1d Add a module layout structure containing a string table and a table of
Estimated hours taken: 14

Add a module layout structure containing a string table and a table of
pointers to the proc layouts of the module's procedures. This speeds up
debugger initialization, and reduces the executable size of the compiler
by almost 1.2 Mb (about 3.7%) when compiled with debugging.

Instead of representing variables names as strings (32 or 64 bit pointers)
in the debugger's static data structures, with the string's prefix representing
the variable's number (e.g. "5:X"), represent them as a 16-bit variable number
and a 16 bit offset into the module-wide string table. This gains simplicity
of processing (no more search for the ":") and reduces the amount of storage
required, a bit on 32-bit platforms (we don't have to store "5:ModuleInfo"
and "10:ModuleInfo" strings separately, and there are no string prefixes to
store) and more on 64-bit platforms.

The 16-bit limits are generous. A procedure with more than 64K variables will
take forever to compile (that is why we impose a 4K limit on the number
of variables in inlining), and even the string tables of typecheck.m and
make_hlds require less than four kilobytes each. Exceeding the limits
would require code no human would write. Automatically generated code may
be a problem, but the help the debugger can give on such code is limited
already. In any case, we detect overflows and handle them sensibly.

This change does not enhance the debugger to take advantage of the easier
availability of variable numbers, except to improve the implementation
of retry; that will come later.

The inclusion of the procedure table in the module layout structure
reduces the cost of registering all procedures in all modules,
a task usually performed at the time of the setting of the first breakpoint.
This used to require processing all the internal labels in the label table,
and thus used to take a few seconds for large executables. The sweep of
all internal labels is no longer required, so registering is now much faster.

runtime/mercury_stack_layout.h:
	Add the definition of MR_Module_Layout.

	Modify label layouts to represent names as offsets in the string table,
	not as raw character pointers. This required modifing proc layouts
	to include a pointer to the module's layout, so you can find the
	string table.

	Update the macros that look up variable names.

runtime/mercury_layout_util.h:
	Use the updated macros for looking up variable names.

runtime/mercury_wrapper.[ch]:
	Add a new indirect pointer, MR_register_module_layout, which points
	to a function that registers a module layout, or is NULL if debugging
	is not enabled.

runtime/mercury_init.h:
	Declare the function whose address may be assigned to
	MR_register_module_layout in a <main>_init.c file.

util/mkinit.c:
	Initialize MR_register_module_layout with either the address of
	MR_register_module_layout_real or NULL, depending on whether
	debugging is enabled or not.

compiler/continuation_info.m:
	Don't give names (V_n) to nameless variables, because we don't want
	them to be included in the variables debugging knows about.

compiler/llds.m:
	Add a new function symbol to the type data_addr, which stands for
	the module layout structure of the named (now always the current)
	module.

	Add a new function symbol to the type rval_const. The new function
	symbols, multi_string_const, contains an array of characters of an
	explicitly given length, which consists of several strings, each
	terminated by a null character.

compiler/llds_out.m:
	Accommodate the changes to llds.m, and expand the module initialization
	code to register the module layout structure, if the pointer to the
	registration function is not NULL.

compiler/stack_layout.m:
	Generate the new data structures for representing variable names,
	as well as the module layout.

compiler/mercury_compile.m:
	Rename some variables to reflect the fact that stack_layout.m can
	now include a module layout structure in the list of static layout
	structures it returns.

compiler/dupelim.m:
compiler/exprn_aux.m:
compiler/jumpopt.m:
compiler/opt_debug.m:
	Minor changes to accommodate multi_string_consts.

trace/mercury_trace_tables.[ch]:
	Replace the old data structures for recording information about
	each debuggable module with the module layout structure, and
	register module layout structures directly, instead of trying
	to discover them through the internal label table.

trace/mercury_trace.[ch]:
	Now that it is more easily accessible, use variable numbers
	instead of variable names to find the current locations of
	the input arguments when implementing retry. Unlike our previous
	method, this works even if the user names some variables HeadVar__1,
	etc.

	Remove an unnecessary export of an internal function.

trace/mercury_trace_external.c:
trace/mercury_trace_internal.c:
runtime/mercury_layout_util.c:
	Use the updated macros for looking up variable names.
1999-05-28 05:29:42 +00:00
Zoltan Somogyi
f143c3891f Get the debugger to sort variables better.
Estimated hours taken: 12

Get the debugger to sort variables better.

trace/mercury_trace_vars.[ch]:
	A new module to manage the debugger's information about the variables
	live at the current program point (which can be defined as the
	combination of a specific event and an ancestor level).

	This new module centralizes the management of the (sorted) list of
	current variables. This in turn allows us to use a better sorting
	method, one that orders VarName15 correctly wrt both VarName2 and
	VarName.

	The new module also uses the type, not the name, of a variable
	to decide whether to exclude it from the list of variables
	that may be presented to the user (e.g. if it is a typeinfo
	or a typeclassinfo).

trace/mercury_trace_internal.c:
trace/mercury_trace_external.c:
	Use the new module's facilities. This factors out some "mostly"
	common code.

trace/Mmakefile:
	Add the new module.

runtime/mercury_layout_util.[ch]:
	Remove the code recently moved here from trace/mercury_trace_internal,
	as well as the filtered versions of some functions, since they are
	not needed anymore.

	Move the code for MR_make_var_list to trace/mercury_trace_external,
	since that is the only place where it is used (or is at all likely
	to be used). Since its new home is next to several very similar
	functions, this should also reduce the probability that any required
	maintenance will be overlooked. Also alter its coding style to conform
	to its new neighbours.

	Move the definition of MR_Var_Spec to trace/mercury_trace_vars.h.

tests/debugger/*.exp:
	Update the expected output files. In most cases, this is just because
	the new module outputs different white space, but in some cases, it
	also reflects that the debugger now prints variables in a different
	order.
1999-05-27 01:01:33 +00:00
Fergus Henderson
7fd8fd988b Fix a minor cut-and-paste error in a comment.
Estimated hours taken: 0.1

runtime/mercury_conf_param.h:
	Fix a minor cut-and-paste error in a comment.
1999-05-26 04:13:00 +00:00
Tyson Dowd
7acedf1557 Move the type_ctor_infos for typeclass_info and base_typeclass_info
Estimated hours taken: 0.3

library/private_builtin.m:
runtime/mercury_bootstrap.c:
	Move the type_ctor_infos for typeclass_info and base_typeclass_info
	into private_builtin since they have almost certainly
	bootstrapped by now (they have been there since November).
1999-05-24 13:21:55 +00:00
Fergus Henderson
a47197303f Fix a problem on Solaris: Solaris has <inttypes.h> and #includes that
Estimated hours taken: 0.75

Fix a problem on Solaris: Solaris has <inttypes.h> and #includes that
file from <sys/types.h>, which conflicted with our definitions of intptr_t
etc. in runtime/mercury_types.h.  The solution is to check for <inttypes.h>
not just <stdint.h> and to use <inttypes.h> if it is available rather than
defining the types ourselves.

configure.in:
	Check for inttypes.h.

runtime/mercury_conf.h.in:
	Define HAVE_INTTYPES.

runtime/mercury_types.h:
	If HAVE_INTTYPES is defined, use <inttypes.h>.
1999-05-24 08:40:53 +00:00
Erwan Jahier
045aa58368 Incorporate the term brower stuff in the external debugger.
Estimated hours taken: 20

Incorporate the term brower stuff in the external debugger.

browser/browse.m:
	Define browse__browse_external() which is the same as browse__browse()
	but for the case where the term browser is called from the external
	debugger.

	Add an argument in predicates that need it to indicate whether the term
	browser was called from the external or the internal debugger.

	Define write_string_debugger/4, nl_debugger/3, write_int_debugger/4,
	print_format_debugger/4 predicates and call them in place of
	io__write_string/4, io__nl/3, io__write_int/4, and io__print/4
	respectively. If the term browser is called from the internal debugger,
	those predicates call the predicates they replace; otherwise, they
	send their argument to the socket via a term of type
	term_browser_response.


browser/debugger_interface.m
	Define a new debugger request `browse/1'.

	Define get_variable_name/2 that allows to retrieve from
	mercury_trace_external.c the name of the variable to browse.

browser/parse.m:
	Define parse__read_command_external/3 that parses the browser command
	sent through the socket.

runtime/mercury_layout_util.c:
trace/mercury_trace_internal.c:
	Move the definition of MR_trace_find_var() and
	MR_trace_validate_var_count() from mercury_trace_internal.c to
	mercury_layout_util.c to make it available to the external debugger.

runtime/mercury_layout_util.h:
trace/mercury_trace_internal.c:
	Move the definition of MR_Var_Spec_Kind and MR_Var_Spec from
	mercury_trace_internal.c to mercury_layout_util.h to make it
	available to mercury_layout_util.c.

trace/mercury_trace_browse.ch:
	Define the function MR_trace_browse_external() which is the same
	as MR_trace_browse() except it uses the external debugger socket
	instead of mdb_in and mdb_out.

trace/mercury_trace_external.c:
	Define MR_trace_browse_one_external(), MR_trace_browse_var_external()
	which are the same as MR_trace_browse_one() and MR_trace_browse_var()
	of mercury_trace_internal.c, but for the use of the external debugger.

	Define MR_get_variable_name() that calls get_variable_name/2 defined
	in debugger_interface.m.
1999-05-21 14:38:21 +00:00
Mark Brown
2bbf02daaf Use the same method of input for the browser as for the internal
Estimated hours taken: 5

Use the same method of input for the browser as for the internal
tracer.  Previously, the browser did input via the Mercury library
and the internal tracer did input via readline (if available).  This
did not work properly if files were redirected into stdin, which meant
that test cases could not be written for the browser.  This change
also adds a test case.

browser/util.m:
	Add a predicate, util__trace_getline/4, which does input via
	the same method used by the internal debugger.

browser/parse.m:
	Call util__trace_getline/4 instead of io__read_line/3.

browser/browse.m:
	Pass the prompt to browser/parse.m as a string, rather than
	printing it before calling.

trace/mercury_trace_internal.c:
trace/mercury_trace_internal.h:
	Declare MR_trace_getline extern.

runtime/mercury_init.h:
runtime/mercury_wrapper.c:
runtime/mercury_wrapper.h:
util/mkinit.c:
	Make MR_trace_getline available to the browser via a function
	pointer.

tests/debugger/Mmakefile:
	Add the new test case.

tests/debugger/browser_test.m:
tests/debugger/browser_test.inp:
tests/debugger/browser_test.exp:
	The new test case.

runtime/mercury_trace_base.c:
runtime/mercury_trace_base.h:
	Export MR_tracing_not_enabled() for use by browser/util.m.
1999-05-14 02:25:53 +00:00
Warwick Harvey
a22d63b18b Mercury failed to configure properly if `<stdint.h>' existed.
Estimated hours taken: 1

Mercury failed to configure properly if `<stdint.h>' existed.  This was due
to `HAVE_STDINT' not being included in `runtime/mercury_conf.h.in'.

runtime/mercury_conf.h.in:
	Added entries for `HAVE_STDINT'.
1999-05-13 08:08:38 +00:00
Zoltan Somogyi
f97297c65d Compress the representation of value shape information.
Estimated hours taken: 3

Compress the representation of value shape information. Instead of a
pointer to a two-word cell containing a pseudotypeinfo and a dummy inst,
just have the pseudotypeinfo itself.

However, we were previously using small integer "pointers" to represent
special kinds of values such as saved succips, hps, etc. Since pseudotypeinfos
use small integer values for their own purposes (to represent type variables),
we can't continue doing this. Therefore this change also creates type_ctor_info
structures for each of these special kinds of values. These values are only
used by the garbage collector, so nothing else is affected.

compiler/stack_layout.m:
	Effect the above change.

library/builtin.m:
	Add type_ctor_info structures and their components for the new kinds
	of values.

runtime/mercury_stack_layout.h:
	Delete the section on shape information, since we don't generate
	such structures anymore.

runtime/mercury_layout_util.c:
	Access pseudotypeinfos directly, not through the shape structure.

runtime/mercury_type_info.h:
	Add new values to the type_ctor_layout enum for the special kinds
	of values.
1999-05-07 08:09:05 +00:00
Zoltan Somogyi
ca0b3b7c6b Add an option that causes the compiler to pass information to the
Estimated hours taken: 8

Add an option that causes the compiler to pass information to the
execution tracing system in one struct, rather than four separate arguments.

Two of these arguments are pointers, which each require two instructions
to set up on SPARC, MIPS and other RISCs that do not use a global pool.
The other two arguments are small constants. Therefore on 32-bit RISCs,
replacing MR_trace/4 with MR_trace_struct/1 will probably replace
six instructions with two, which saves four instructions' worth
of time and 16 bytes of code, at the cost of 12 bytes of data,
and possibly the cost of some instructions later loading the info
from the struct into registers. However, this loading cost does not have
to be paid if tracing is not enabled, and other optimizations may
reduce the cost even if tracing is enabled. For example, I strongly suspect
that on out-of-order machines, which means most CPUs you can buy today,
the load instructions are effectively free, because they happen while
the indirect jump to MR_trace_real takes place.

I intend to benchmark this option on our various platforms,
and have autoconfigure set it on the machines in which it is beneficial.

doc/user_guide.texi:
	Document the new --call-trace-struct option, and say it is not
	for general use.

compiler/options.m:
	Add the new option.

compiler/trace.m:
	If the option is set, call MR_trace_struct instead of MR_trace,
	and create a new kind of static (in both senses) global data structure
	to hold the arguments.

	Move the definition of trace_port to llds.m, and the procedure to
	convert it to string to llds_out.m

compiler/code_info.m:
	Add an extra code_info slot to hold this new kind of global data,
	and its access predicates.

compiler/code_gen.m:
	Transfer this new kind of global data from code_info to the global_data
	part of module_info.

compiler/hlds_module.m:
	Add a new field to the global_data data structure to hold this data.

compiler/mercury_compile.m:
	Include the new global data in the list of things we give to llds_out.

compiler/llds.m:
	Add a new kind of comp_gen_c_data to hold MR_trace_struct arguments.

	Also move the definition of trace_port from trace.m to here,
	since the new kind of comp_gen_c_data refers to this type.

compiler/llds_out.m:
	Add code to print the new kind of comp_gen_c_data.

	Move the code to print trace_ports from trace.m to here.

compiler/llds_common.m:
	Ignore the new kind of comp_gen_c_data, since by construction
	its contents are never common with anything else.

runtime/mercury_trace_base.[ch]:
	Add a new variant of MR_trace, MR_trace_struct, that consolidates
	the arguments into a single MR_Trace_Call_Info struct.

	Fix a bad variable name: the int argument to MR_trace is a max r
	register number, not a max mr register number.
1999-04-30 08:24:24 +00:00
Zoltan Somogyi
c2da42e6d0 Allow the compiler to handle create rvals whose arguments have a size
Estimated hours taken: 16

Allow the compiler to handle create rvals whose arguments have a size
which is different from the size of a word. Use this capability to reduce
the size of RTTI information, in two ways.

The first way is by rearranging the way in which we represent information
about the live values at a label. Instead of an array with an entry for
each live value, the entry being a pair of Words containing a shape
representation and a location description respectively, use an array
of shape representations (still Words), followed by an array of 32-bit ints
(which may be smaller than Word) describing locations whose descriptions
don't fit into 8 bits, followed by an array of 8-bit ints describing
locations whose descriptions do fit into 8 bits.

The second way is by reducing the sizes of some fields in the C structs
used for RTTI. Several of these had to be bigger than necessary in the
past because their fields were represented by the args of a create rval.

On cyclone, this reduces the size of the object file for queens.m by 2.8%.

IMPORTANT
Until this change is reflected in the installed compiler, you will not be
able to use any modules compiled with debugging in your workspaces if the
workspace has been updated to include this change. This is because the RTTI
data structures generated by the old installed compiler will not be compatible
with the new structure definitions.

The workaround is simple: if your workspace contains modules compiled with
debugging, don't do a cvs update until this change has been installed.

configure.in:
	Check whether <stdint.h> is present. If not, autoconfigure
	types that are at least 16 and 32 bits in size.

runtime/mercury_conf.h.in:
	Mention the macros used by the configure script, MR_INT_LEAST32_TYPE
	and MR_INT_LEAST16_TYPE.

runtime/mercury_conf_param.h:
	Document the macros used by the configure script, MR_INT_LEAST32_TYPE
	and MR_INT_LEAST16_TYPE.

runtime/mercury_types.h:
	If <stdint.h> is available, get the basic integer types (intptr_t,
	int_least8_t, etc) from there. Otherwise, get them from the
	autoconfigure script. Define types such as Word in terms of these
	(eventually) standard types.

runtime/mercury_stack_layout.h:
	Add macros for manipulating short location descriptions, update the
	types and macros for manipulating long location descriptions.
	Modify the way the variable count is represented (since it now must
	count locations with long and short descriptions separately),
	and move it to the structure containing the arrays it describes.

	Reduce the size of the some fields in structs. This required some
	reordering of fields to avoid the insertion of padding by the compiler,
	and changes to the definitions of some types (e.g. MR_determinism).

runtime/mercury_layout_util.[ch]:
runtime/mercury_stack_trace.c:
runtime/mercury_accurate_gc.c:
trace/mercury_trace.c:
trace/mercury_trace_external.c:
trace/mercury_trace_internal.c:
	Update the code to conform to the changes to stack_layout.h.

compiler/llds.m:
	Modify the create rval in two ways. First, add an extra argument to
	represent the types of the arguments, which used to always be implicit
	always a word in size, but may now be explicit and possibly smaller
	(e.g. uint_least8). Second, since the code generator would do the wrong
	thing with creates with smaller than wordsize arguments, replace
	the old must-be-unique vs may-be-nonunique bool with a three-valued
	marker, must_be_dynamic vs must_be_static vs can_be_either.

	Add uint_least8, uint_least16, uint_least32 (and their signed variants)
	and string as llds_types.

	Add a couple of utility predicates for checking whether an llds_type
	denotes a type whose size is the same as word.

compiler/llds_out.m:
	Use explicitly given argument types when declaring and initializing
	the arguments of a cell, if they are given.

compiler/llds_common.m:
	Don't conflate creates with identical argument values but different
	C-level argument types. The probability of a match is minuscule anyway.

compiler/stack_layout.m:
	Use the new representation of creates to generate the new versions of
	RTTI data structures.

compiler/code_exprn.m:
	If a create is marked must_be_static, don't inspect the arguments
	to decide whether it can be static or not. If it can't, we'll get
	an abort later on in llds_out or during C compilation anyway.

compiler/base_type_layout.m:
	When creating pseudo typeinfos, return the llds_type of the resulting
	rval.

	Minor changes required by the change in create.

compiler/base_type_info.m:
compiler/base_typeclass_info.m.m:
compiler/code_util.m:
compiler/dupelim.m:
compiler/exprn_aux.m:
compiler/jumpopt.m:
compiler/livemap.m:
compiler/lookup_switch.m:
compiler/middle_rec.m:
compiler/opt_debug.m:
compiler/opt_util.m:
compiler/string_switch.m:
compiler/unify_gen.m:
compiler/vn_cost.m:
compiler/vn_filter.m:
compiler/vn_flush.m:
compiler/vn_order.m:
compiler/vn_type.m:
compiler/vn_util.m:
compiler/vn_verify.m:
	Minor changes required by the change in create.

library/benchmarking.m:
library/std_util.m:
	Use the new macros in hand-constructing proc layout structures.

library/Mmakefile:
	Add explicit dependencies for benchmarking.o and std_util.o
	on ../runtime/mercury_stack_layout.h. Although this is only a subset
	of the truth (in reality, all library objects depend on most of the
	runtime headers), it is a good tradeoff between safety and efficiency.
	The other runtime header files tend not to change in incompatible ways.

trace/Mmakefile:
	Add explicit dependencies for all the object files on
	../runtime/mercury_stack_layout.h, for similar reasons.
1999-04-30 06:21:49 +00:00
Zoltan Somogyi
566cec5b30 Prefix everything defined in runtime/mercury_{stacks,tags}.h MR_.
Estimated hours taken: 3

Prefix everything defined in runtime/mercury_{stacks,tags}.h MR_.
In the process, get rid of the grade component MR_DEBUG_NONDET_STACK,
since this makes the update to mercury_stacks.h simpler and its use is
long obsolete.

runtime/mercury_tags.h:
	Put MR_ prefixes in front of everything defined here.

runtime/mercury_stacks.h:
	Put MR_ prefixes in front of everything defined here.

	Remove support for MR_DEBUG_NONDET_STACK. Replace most of the
	lost functionality by calling an updated mkframe_msg.

	Remove the definitions of push() and pop(). Their use conflicts with
	the idea that everything on the det stack is part of a frame, which
	the RTTI stuff depends on.

runtime/mercury_bootstrap.h:
	Add backward compatibility macros for the old names in the above two
	files.

	Remove some old entries in this file which are no longer needed.

runtime/mercury_wrapper.c:
	Remove the only uses of push() and pop().

	Put MR_ in front of some things that need them.

runtime/mercury_engine.c:
	Put MR_ in front of some things that need them.

runtime/mercury_misc.[ch]:
	Make mkframe_msg get the name of the procedure that owns the stack
	frame from an explicitly passed argument, rather than the prednm slot
	(which no longer exists). This actually improves low-level debugging
	support without MR_DEBUG_NONDET_STACK.

	Remove unnecessary return statements.

runtime/mercury_debug.h:
	Pass on the new arg of mkframe_msg.

	Fix long lines.

runtime/mercury_conf_param.h:
	Remove the documentation of MR_DEBUG_NONDET_STACK.

runtime/mercury_grade.h:
	Remove the grade component of MR_DEBUG_NONDET_STACK.

doc/reference_manual.texi:
	Document the MR_ prefixed versions of list_empty, list_cons etc.

library/io.m:
library/std_util.m:
library/string.m:
	Add prefixes to some references to the runtime.
1999-04-30 04:25:43 +00:00
Zoltan Somogyi
dfb59414e4 Prefix everything defined in runtime/mercury_{stacks,tags}.h MR_.
Estimated hours taken: 3

Prefix everything defined in runtime/mercury_{stacks,tags}.h MR_.
In the process, get rid of the grade component MR_DEBUG_NONDET_STACK,
since this makes the update to mercury_stacks.h simpler and its use is
long obsolete.

runtime/mercury_tags.h:
	Put MR_ prefixes in front of everything defined here.

runtime/mercury_stacks.h:
	Put MR_ prefixes in front of everything defined here.

	Remove support for MR_DEBUG_NONDET_STACK. Replace most of the
	lost functionality by calling an updated mkframe_msg.

	Remove the definitions of push() and pop(). Their use conflicts with
	the idea that everything on the det stack is part of a frame, which
	the RTTI stuff depends on.

runtime/mercury_bootstrap.h:
	Add backward compatibility macros for the old names in the above two
	files.

	Remove some old entries in this file which are no longer needed.

runtime/mercury_wrapper.c:
	Remove the only uses of push() and pop().

	Put MR_ in front of some things that need them.

runtime/mercury_engine.c:
	Put MR_ in front of some things that need them.

runtime/mercury_misc.[ch]:
	Make mkframe_msg get the name of the procedure that owns the stack
	frame from an explicitly passed argument, rather than the prednm slot
	(which no longer exists). This actually improves low-level debugging
	support without MR_DEBUG_NONDET_STACK.

	Remove unnecessary return statements.

runtime/mercury_debug.h:
	Pass on the new arg of mkframe_msg.

	Fix long lines.

runtime/mercury_conf_param.h:
	Remove the documentation of MR_DEBUG_NONDET_STACK.

runtime/mercury_grade.h:
	Remove the grade component of MR_DEBUG_NONDET_STACK.

doc/reference_manual.texi:
	Document the MR_ prefixed versions of list_empty, list_cons etc.

library/io.m:
library/std_util.m:
library/string.m:
	Add prefixes to some references to the runtime.
1999-04-30 04:25:42 +00:00
Zoltan Somogyi
c0adb5f1b0 Increase the default det stack size from 2 Mb to 4 Mb. 2 Mb is
Estimated hours taken: 0.1

runtime/mercury_wrapper.c:
	Increase the default det stack size from 2 Mb to 4 Mb. 2 Mb is
	not enough to compile rl_code.m in a debugging grade.
1999-04-27 10:28:40 +00:00
Zoltan Somogyi
df8f8072ba Don't enable MR_INSERT_INTERNAL_LABEL_NAMES for PROFILE_CALLS.
Estimated hours taken: 0.1

runtime/mercury_conf_param.h:
	Don't enable MR_INSERT_INTERNAL_LABEL_NAMES for PROFILE_CALLS.
1999-04-26 05:28:32 +00:00
Zoltan Somogyi
95d3df772d Remove this obsolete file, a mere 17 months after Fergus "temporarily"
Estimated hours taken: 0.1

runtime/imp.h:
	Remove this obsolete file, a mere 17 months after Fergus "temporarily"
	resurrected it.
1999-04-26 03:39:54 +00:00
Zoltan Somogyi
ef88102601 Include label names in the label tables only if needed.
Estimated hours taken: 3

Include label names in the label tables only if needed. This reduces the
size of the object file for queens.m with debugging enabled by 18%.

runtime/mercury_conf_param.h:
	Define and document MR_INSERT_{INTERNAL,ENTRY}_LABEL_NAMES, which
	are turned on only when we want the names of internal and entry
	labels respectively to be included in the label table.
	This occurs when some forms of low level debugging are turned on,
	and also with profiling (although I am not sure whether profiling
	needs the names of internal labels).

runtime/mercury_goto.h:
	If MR_INSERT_*_LABEL_NAMES is not defined, always pass a NULL pointer
	instead of the label name to the functions that insert into the label
	tables. By ignoring the label names, we prevent the inclusion of those
	long names in the rodata section of the object file.

runtime/mercury_label.h:
	Document that the names may be NULL.

runtime/mercury_accurate_gc.c:
runtime/mercury_label.c:
runtime/mercury_misc.c:
	Don't assume that label names are always valid.
1999-04-26 03:34:38 +00:00
Zoltan Somogyi
854fb06907 Include label names in the label tables only if needed.
Estimated hours taken: 3

Include label names in the label tables only if needed. This reduces the
size of the object file for queens.m with debugging enabled by 18%.

runtime/mercury_conf_param.h:
	Define and document MR_INSERT_{INTERNAL,ENTRY}_LABEL_NAMES, which
	are turned on only when we want the names of internal and entry
	labels respectively to be included in the label table.
	This occurs when some forms of low level debugging are turned on,
	and also with profiling (although I am not sure whether profiling
	needs the names of internal labels).

runtime/mercury_goto.h:
	If MR_INSERT_*_LABEL_NAMES is not defined, always pass a NULL pointer
	instead of the label name to the functions that insert into the label
	tables. By ignoring the label names, we prevent the inclusion of those
	long names in the rodata section of the object file.

runtime/mercury_label.h:
	Document that the names may be NULL.

runtime/mercury_accurate_gc.c:
runtime/mercury_label.c:
runtime/mercury_misc.c:
	Don't assume that label names are always valid.
1999-04-26 03:34:28 +00:00
Fergus Henderson
8ee99af828 Fix a bug in my previous bug fix: the old do_call_* labels
Estimated hours taken: 0.25

runtime/mercury_ho_call.c:
	Fix a bug in my previous bug fix: the old do_call_* labels
	don't have `mercury__' prefixes.
1999-04-23 05:43:26 +00:00
Fergus Henderson
78adcae6a6 Add a missing `#include "mercury_deep_copy.h";
Estimated hours taken: 0.25

runtime/mercury_tabling.h:
	Add a missing `#include "mercury_deep_copy.h";
	this is needed since some of the macros defined here
	call deep_copy().
1999-04-22 15:36:14 +00:00
Fergus Henderson
8e8a921f16 Fix some problems caused by the recently added autoconf tests for
Estimated hours taken: 2

Fix some problems caused by the recently added autoconf tests for
determining how to handle variable-sized arrays.

runtime/mercury_conf_param.h:
runtime/mercury_std.h:
	Change the definition of MR_VARIABLE_SIZED so that it uses
	compile-time checks rather than autoconf-based configuration.
	Using autoconf-based configuration for compiler-dependent
	properties breaks the instructions for using compilers other
	than gcc in the Mercury User's Guide; in particular, with the
	autoconf approach, if you had installed Mercury using GNU C
	(or if you were using a binary distribution that was configured
	with GNU C), and then you set the environment variable
	MERCURY_C_COMPILER to point to a C compiler that doesn't
	support GNU-style variable-length arrays (e.g. lcc), then you
	would get compile errors.

	Also move the definition of MR_VARIABLE_SIZED from
	mercury_conf_param.h to mercury_std.h (it never belonged
	in the former location, IMHO, since it was only ever
	a definition that _used_ configuration parameters rather
	than being a configuration parameter itself).

configure.in:
runtime/mercury_conf.h.in:
	Delete the configuration tests and configuration macros for
	variable-sized arrays, since the above change means these are
	no longer needed.

runtime/mercury_stack_layout.h:
	Include mercury_std.h rather than mercury_conf_param.h
	for MR_VARIABLE_SIZED.
1999-04-22 06:14:00 +00:00
Tyson Dowd
6cb525f6bc This change does some renaming to match the new nomenclature introduced
Estimated hours taken: 5

This change does some renaming to match the new nomenclature introduced
in the RTTI paper.

Rename simple tags as unshared tags, complicated tags as shared
remote tags and complicated constant tags as shared local.
Also rename "simple vector" as "functor descriptor",
"functors vector" as "enum vector".

compiler/base_type_layout.m:
compiler/bytecode.m:
compiler/bytecode_gen.m:
compiler/hlds_data.m:
compiler/make_tags.m:
compiler/switch_gen.m:
compiler/tag_switch.m:
compiler/unify_gen.m:
	Perform these renamings in the compiler, renaming a few
	functors and data structures.

library/std_util.m:
runtime/mercury_deep_copy_body.h:
runtime/mercury_tabling.c:
runtime/mercury_type_info.c:
runtime/mercury_type_info.h:
	Perform these renamings in the library and runtime, renaming
	macros and variables.
1999-04-22 01:04:32 +00:00
Fergus Henderson
2d8f4048da Fix a bug where Zoltan's recent change to the representation of closures
Estimated hours taken: 1

Fix a bug where Zoltan's recent change to the representation of closures
broke binary backwards compatibility.

runtime/mercury_ho_call.c:
	Fix the code for mercury_call_{det,semi,nondet}_closure so that
	it preserves backwards compatibility properly.
	It's possible for a closure using the new representation to be
	passed to one of these old labels, e.g. if newly compiled code
	passes a closure to code which hasn't yet been recompiled.

	Also delete the duplicated old code for
	mercury_call_{det,semi,nondet}_class_method
	and implement these by just jumping to do_call_class_method.

	Also fix some compiler warnings.
1999-04-21 13:41:36 +00:00
Fergus Henderson
14494e0551 Back out my previous change of moving the definition of MR_SUBGOAL()
Estimated hours taken: 0.25

runtime/mercury_tabling.h:
	Back out my previous change of moving the definition of MR_SUBGOAL()
	outside of the #ifdef MR_USE_MINIMAL_MODEL, since that was not the
	right fix.  (The right fix was to instead change
	library/private_builtin.m so that it did not use MR_SUBGOAL() if
	MR_USE_MINIMAL_MODEL was not defined.  Tyson has committed that fix.)
1999-04-21 07:57:22 +00:00
Fergus Henderson
202faefcda Fix a bug in Zoltan's previous change: the definition of
Estimated hours taken: 0.25

runtime/mercury_tabling.h:
	Fix a bug in Zoltan's previous change: the definition of
	MR_SUBGOAL() should be outside of the `#ifdef MR_USE_MINIMAL_MODEL'.
	Without this change, library/private_builtin.m failed to compile.
1999-04-20 17:25:40 +00:00
Fergus Henderson
62f779e874 New file.
Estimated hours taken: 0.25

runtime/mercury_stacks.c:
	New file.
	Zoltan forgot to commit this as part of his previous change.
1999-04-20 15:38:37 +00:00
Zoltan Somogyi
dc03496d06 Rewrite significant parts of minimal model tabling so that it works
Estimated hours taken: 130

Rewrite significant parts of minimal model tabling so that it works
in a much wider variety of situations, including coups. Also, clean up
the tabling implementation to make it more maintainable, and introduce
a new grade component, .mm, that enables minimal model tabling.
(Minimal model tabling requires distributed fat, and we don't want to
incur such costs unless necessary.)

compiler/options.m:
	Add a new option --use-minimal-model, which for now is documented
	as "not for general use". This option is a grade option, and is
	required if minimal model tabling is to work.

compiler/handle_options.m:
	When --use-minimal-model is given, do not allow nondet frame hijacks,
	since minimal model tabling cannot cope with hijacks.

	Make --use-minimal-model a grade component.

compiler/code_info.m:
	When --use-minimal-model is given, insert calls to MR_commit_{mark,cut}
	around goals being committed across. This is now necessary, so that we
	can detect and handle sitations where a goal being committed across
	starts but does not complete a tabled goal.

compiler/table_gen.m:
	Rename many of the tabling helper predicates, using a naming scheme
	that separates predicates used for model_non procedures from those
	used to implement simpler forms of tabling, while bringing out
	the parallels between these two sets of predicates.

	When calls to two tabling helper predicates always occur
	one after the other, merge the two into one.

	Generate and use more meaningful variable names; having all of the
	several variables inserted by this transformation named TableVar
	was quite confusing.

library/private_builtin.m:
	Reorganize this file, to separate out the different sections.
	The contents of the non-tabling sections were not modified, only
	moved around.

	Rename the predicates referred to by table_gen.m.

	Move most of the type declarations and complex code out of here,
	into runtime/mercury_tabling.c. This makes it easier to debug them,
	since (a) creating a new executable is quicker, since you don't have
	to wait for lots of mercury compiler invocations, and (b) gdb doesn't
	get confused by #line directives. It also makes it easier to write
	them, since you don't have to !&(*U&( remember to double all your
	double quotes and to backslash all your backslashes.

runtime/mercury_grade.h:
	Include a grade component reflecting whether MR_USE_MINIMAL_MODEL
	is defined.

runtime/mercury_conf_param.h:
	Document MR_USE_MINIMAL_MODEL.

runtime/mercury_stacks.[ch]:
	The changes to tabling require the addition of two new stacks,
	the generator stack and the cut stack. This module defines the
	structures of the frames of these stacks and provides the
	operations on these stacks.

	The header file also contains some additional macros that return
	the addresses of fixed nondet stack slots, not their contents,
	for use by tabling code.

runtime/mercury_context.[ch]:
runtime/mercury_memory.[ch]:
runtime/mercury_wrapper.[ch]:
	Declare and set up the two new stacks, both in saved contexts and in
	the active context, if MR_USE_MINIMAL_MODEL is defined.

runtime/mercury_regorder.h:
	Add four new global virtual machine registers to hold pointers
	to the memory areas of the two new stacks and the current offsets
	within them. These are defined whether MR_USE_MINIMAL_MODEL is defined
	or not, since the cost is minimal and the potential bugs we avoid
	would be hard to track down.

runtime/mercury_engine.h:
runtime/mercury_wrapper.c:
	Add support for a new debugging flag, -dS, which prints the contents
	of the nondet stack at several points during tabling.

runtime/mercury_tabling.[ch]:
	The implementation of the new tabling system. Much of the new code here
	is stuff moved from library/private_builtin.m, but in a significantly
	rewritten form. There is also substantial new code, e.g. to handle
	the extension of saved stack segments, and to manage dependencies
	between subgoals in general.

	Improve the documentation considerably.

	Replace lists stored as Mercury data structures with lists stored
	as linked structures in the usual C fashion. This allows us to use
	debuggers such as ddd on these data structures, whose complexity
	requires this.

	Ensure that global names start with MR_.

runtime/mercury_init.h:
	Explicitly include mercury_regs.h at the start. Without this,
	we get an error, because now mercury_wrappers.h, which mercury_init.h
	includes, also includes mercury_regs.h, but not before functions
	have been declared.

runtime/Mmakefile:
	Refer to the new file mercury_stacks.c (mercury_stacks.h already
	existed, but the module consisted entirely of macros.)

	Fix a sorting error.

scripts/{init,parse,final}_grade_options.sh-subr:
scripts/mgnuc.in:
	Handle the new grade component.

tests/tabling/*
	Add several new test cases that we now pass, most of which we couldn't
	pass before. Also add some new test cases that we don't pass yet,
	due to interactions between tabling and negated contexts.

trace/mercury_trace_internal.c:
	If MR_USE_MINIMAL_MODEL is defined, add a new command to print
	the generator stack. (The new command is deliberately not documented
	in doc/mdb_doc yet, since (a) it is intended for developers only,
	and (b) there is no way to test MR_USE_MINIMAL_MODEL in mdb_doc.)
1999-04-20 11:48:56 +00:00
Tyson Dowd
7a4548e108 The next stage in cleaning up the RTTI information.
Estimated hours taken: 0.5

The next stage in cleaning up the RTTI information.  Make the
type_ctor_representation available.

compiler/base_type_info.m:
        Output type_ctor_representation.

runtime/mercury_type_info.h:
	Set the offset for type_ctor_layout to the new offset.
1999-04-20 02:33:13 +00:00
Fergus Henderson
2a463dd102 Fix another bug in Zoltan's recent change to autoconf the
Estimated hours taken: 0.25

runtime/mercury_conf.h.in:
	Fix another bug in Zoltan's recent change to autoconf the
	variable-sized array stuff: it was missing an entry for
	MR_FAKED_VARIABLE_SIZED_ARRAY, which is defined by
	configure.in and used by mercury_conf_param.h.
	Also make some changes to the comments about
	MR_SUPPORT_VARIABLE_SIZED_ARRAY.
1999-04-19 10:55:54 +00:00
Fergus Henderson
b72c7a35fc Add `#include "mercury_conf_param.h"', since this is needed for
Estimated hours taken: 0.5

runtime/mercury_stack_layout.h:
	Add `#include "mercury_conf_param.h"', since this is needed for
	MR_VARIABLE_SIZED; without this, configure.in wrong infers
	grade `asm_jump.gc' rather than `asm_fast.gc'.

	Also delete a duplicate `#include "mercury_types.h"'.
1999-04-19 07:43:46 +00:00
Zoltan Somogyi
e8c2b44ea5 Fix indentation.
Estimated hours taken: 0.01

runtime/mercury_trail.h:
	Fix indentation.
1999-04-17 07:15:04 +00:00
Mark Brown
e2855ed9d8 Copy the declaration of MR_edt_root_node from
Estimated hours taken: 0.1

runtime/mercury_init.h:
	Copy the declaration of MR_edt_root_node from
	trace/mercury_trace_declarative.h to here.  This is so
	the `--enable-decl-debug' configure option can work.
1999-04-16 06:37:20 +00:00
Zoltan Somogyi
3bf462e0b7 Switch to a closure representation that includes runtime type and procedure id
Estimated hours taken: 36

Switch to a closure representation that includes runtime type and procedure id
information, so that closures can be copied, garbage collected, printed, etc.

This RTTI information is not yet used. Adding code to use it would be futile
until Tyson finishes his changes to the other RTTI data structures.

Note also that this change provides the information required for solving the
problem of trying to deep copy closures only for grades that include
--typeinfo-liveness. Providing this info for other grades is future work.

configure.in:
	Find out what the right way to refer to a variable-sized array
	at the end of a struct is.

runtime/mercury_ho_call.h:
	New file to define the structure of closures and macros for accessing
	closures.

runtime/Mmakefile:
	Add the new header file.

runtime/mercury_ho_call.c:
	Add an entry point to handle calls to new-style closures. The code
	to handle old-style closures, which was unnecessarily duplicated for
	each code model, stays until all the installed compilers use the new
	closure representation.

	Until that time, the new entry point will contain code to detect
	the use of old-style closures and invoke the old code instead.
	This allows stage1s compiled with old compilers to use the old style
	and stage2 to use the new style without any special tricks anywhere
	else.

	Add a new entry point to handle method calls of all code models.
	The old entry points, which had the same code, will also be deleted
	after this change has been bootstrapped.

runtime/mercury_calls.h:
	Remove the macros that call closures. Their interface sucked, they
	were not used, and their implementation is now out of date.

runtime/mercury_stack_layout.h:
	Add a new type, MR_Type_Param_Locns, for use by the C type
	representing closures. Since MR_Stack_Layout_Vars has a field,
	MR_slvs_tvars, which references a data structure identical
	in every way to MR_Type_Param_Locns, change the type of that field
	to this new type, instead of the previous cheat.

runtime/mercury_layout_util.h:
	Minor update to conform to the new type of the MR_slvs_tvars field.
	(This is the only use of that field in the system.)

runtime/mercury_type_info.h:
	Add new types MR_TypeInfo and MR_PseudoTypeInfo. For now, they
	are just Word, but later we can make them more accurate.
	In the meantime, we can refer to them instead of to Word,
	making code clearer. One such reference is now in mercury_ho_call.h.

compiler/notes/release_checklist.html:
	Add a reminder to remove the redundant code from mercury_ho_call.c
	after bootstrapping.

compiler/llds.m:
	Replace three code addresses for calling closures and another three
	for calling methods with one each.

compiler/call_gen.m:
compiler/dupelim.m:
compiler/opt_debug.m:
compiler/opt_util.m:
compiler/llds_out.m:
	Trivial updates in accordance with the change to llds.m

compiler/code_info.m:
	Move the code to handle layouts to continuation_info.m,
	since that's where it belongs. Leave only the code for picking
	up parameters from code_infos and for putting results back in there.

	Remove the redundant arguments of code_info__init, and extract
	them from ProcInfo, to make clear that they are related.

compiler/code_gen.m:
	Since we pass ProcInfo to code_info__init, don't pass its components.

compiler/continuation_info.m:
	Add the code moved from code_info.m, in a form which takes explicit
	arguments for things that used be hidden in the code_info.

	Add new code, closely related to the moved code, that creates
	layout info from a procedure's argument info, rather than from a
	(part of) the current code generator state. This way, it can be
	invoked from places that don't have a code_info for the procedure
	for which they want to generate layouts. This is the case when
	we generate layouts for closures.

compiler/par_conj_gen.m:
compiler/trace.m:
	Minor changes required by the move of stuff from code_info to
	continuation_info.

compiler/stack_layout.m:
	Export some predicates for use by unify_gen.

compiler/unify_gen.m:
	Switch to creating new style closures, complete with layout info.

	Optimize the code for extending closures a bit. By copying the
	fixed words of the closure outside the loop, we avoid incurring
	the loop overhead twice.

compiler/code_util.m:
	Add a couple of utility predicates for continuation_info.m and
	unify_gen.m

library/benchmarking.m:
library/std_util.m:
	Refer to the new entry point for handling closures.

browser/dl.m:
	Use the new closure representation.

	Note that extras/dynamic_linking/dl.m, which is supposed to be
	the same as browser/dl.m but is not, should also be updated, but
	this will be handled later by Fergus.

tests/hard_coded/closure_extension.{m,exp}:
	A new test case to exercise the code for extending closures.

tests/hard_coded/Mmakefile:
	Enable the new test case.
1999-04-16 06:05:49 +00:00
Mark Brown
dfcb358e86 Add the option `--enable-decl-debug' to configure, which enables
Estimated hours taken: 2

Add the option `--enable-decl-debug' to configure, which enables
declarative debugging support in the internal debugger.

configure.in:
	Add the option to configure.

browser/declarative_debugger.m:
runtime/mercury_wrapper.c:
	Avoid using MR_address_of_edt_root_node unless configured
	for declarative debugging.

runtime/mercury_conf.h.in:
runtime/mercury_conf_param.h:
	Move the configuration macro to mercury_conf.h.in.

trace/mercury_trace_declarative.c:
	Define MR_edt_root_node only if configured for declarative
	debugging, thereby undoing a previous change.
1999-04-16 03:08:14 +00:00
Mark Brown
59f61e4edf Fix a bug causing the debugger tests to get link errors.
Estimated hours taken: 3

Fix a bug causing the debugger tests to get link errors.

browser/declarative_debugger.m:
	Call MR_edt_root_node indirectly via MR_address_of_edt_root_node.

runtime/mercury_wrapper.{c,h}:
	Add a global function pointer, MR_address_of_edt_root_node.

util/mkinit.c:
	Make sure MR_address_of_edt_root_node is initialized.

trace/mercury_trace_declarative.c:
	Define MR_edt_root_node even if the declarative debugger is not
	used.
1999-04-14 14:09:22 +00:00
Mark Brown
4fec7f6137 Add a front end to the declarative debugger, written in Mercury.
Estimated hours taken: 80

Add a front end to the declarative debugger, written in Mercury.  Modify
the back end to call this whenever an EDT is built.  Also, various
bug fixes and improvements.

browser/declarative_debugger.m:
	New module.  This is a first implementation of the front end of
	the declarative debugger.  It uses a simple top-down algorithm
	to search the EDT for a buggy node.  The results are printed
	in a simple format to the output stream.  It is called from the
	back end, in trace/mercury_trace_declarative.c.

browser/declarative_oracle.m:
	New module.  This is a first implementation of an oracle for the
	declarative debugger.  It simply passes all queries directly
	on to the user.

browser/browser_library.m:
	Import the new modules.

trace/mercury_trace_declarative.c:
	- Various fixes/improvements of comments.
	- Fix bugs where `int' is used instead of `Unsigned'.
	- Pass the event_info structure to MR_trace_decl_update_path,
	  rather than passing various components of it.
	- Use the copy of MR_trace_event_number in the event_info structure
	  rather than referring to the global variable directly.
	- Remove the EDT printing functions, as they have been superseded by
	  the new front end.  Call the new front end instead of these old
	  functions.
	- Provide an interface to the EDT nodes that is imported by the
	  front end.
	- Ensure that, after diagnosis, we end up at the same event we
	  started at.
	- Fix a bug where it was assumed all procedures had at least one
	  argument.
	- Ensure that the user is notified if the dd_wrong operation cannot
	  be started due to MR_trace_retry failing.

trace/mercury_trace_declarative.h:
	- Move a #include to the correct place.
	- Declare the interface to the EDT nodes.

trace/mercury_trace_internal.c:
	Fix a bug introduced earlier.

runtime/mercury_conf_param.h:
	Add a new configuration macro, MR_DEBUG_DD_BACK_END.  When defined
	this causes information about the declarative debugger back end
	to be printed out during operation.
1999-04-12 04:11:48 +00:00