Commit Graph

26 Commits

Author SHA1 Message Date
Peter Wang
2ccac171dd Add float registers to the Mercury abstract machine, implemented as an
Branches: main

Add float registers to the Mercury abstract machine, implemented as an
array of MR_Float in the Mercury engine structure.

Float registers are only useful if a Mercury `float' is wider than a word
(i.e. when using double precision floats on 32-bit platforms) so we let them
exist only then.  In other cases floats may simply be passed via the regular
registers, as before.

Currently, higher order calls still require the use of the regular registers
for all arguments.  As all exported procedures are potentially the target of
higher order calls, exported procedures must use only the regular registers for
argument passing.  This can lead to more (un)boxing than if floats were simply
always boxed.  Until this is solved, float registers must be enabled explicitly
with the developer only option `--use-float-registers'.

The other aspect of this change is using two consecutive stack slots to hold a
single double variable.  Without that, the benefit of passing unboxed floats
via dedicated float registers would be largely eroded.


compiler/options.m:
	Add developer option `--use-float-registers'.

compiler/handle_options.m:
	Disable `--use-float-registers' if floats are not wider than words.

compiler/make_hlds_passes.m:
	If `--use-float-registers' is in effect, enable a previous change that
	allows float constructor arguments to be stored unboxed in structures.

compiler/hlds_llds.m:
	Move `reg_type' here from llds.m and `reg_f' option.

	Add stack slot width to `stack_slot' type.

	Add register type and stack slot width to `abs_locn' type.

	Remember next available float register in `abs_follow_vars'.

compiler/hlds_pred.m:
	Add register type to `arg_loc' type.

compiler/llds.m:
	Add a new kind of lval: double-width stack slots.
	These are used to hold double-precision floating point values only.

	Record setting of `--use-float-registers' in exprn_opts.

	Conform to addition of float registers and double stack slots.

compiler/code_info.m:
	Make predicates take the register type as an argument,
	where it can no longer be assumed.

	Remember whether float registers are being used.

	Remember max float register for calls to MR_trace.

	Count double width stack slots as two slots.

compiler/arg_info.m:
	Allocate float registers for procedure arguments when appropriate.

	Delete unused predicates.

compiler/var_locn.m:
	Make predicates working with registers either take the register type as
	an argument, or handle both register types at once.

	Select float registers for variables when appropriate.

compiler/call_gen.m:
	Explicitly use regular registers for all higher-order calls,
	which was implicit before.

compiler/pragma_c_gen.m:
	Use float registers, when available, at the interface between Mercury
	code and C foreign_procs.

compiler/export.m:
	Whether a float rval needs to be boxed/unboxed when assigned to/from a
	register depends on the register type.

compiler/fact_table.m:
	Use float registers for arguments to predicates defined by fact tables.

compiler/stack_alloc.m:
	Allocate two consecutive stack slots for float variables when
	appropriate.

compiler/stack_layout.m:
	Represent double-width stack slots in procedure layout structures.

	Conform to changes.

compiler/store_alloc.m:
	Allocate float registers (if they exist) for float variables.

compiler/use_local_vars.m:
	Substitute float abstract machine registers with MR_Float local
	variables.

compiler/llds_out_data.m:
compiler/llds_out_instr.m:
	Output float registers and double stack slots.

compiler/code_util.m:
compiler/follow_vars.m:
	Count float registers separately from regular registers.

compiler/layout.m:
compiler/layout_out.m:
compiler/trace_gen.m:
	Remember the max used float register for calls to MR_trace().

compiler/builtin_lib_types.m:
	Fix incorrect definition of float_type_ctor.

compiler/bytecode_gen.m:
compiler/continuation_info.m:
compiler/disj_gen.m:
compiler/dupelim.m:
compiler/exprn_aux.m:
compiler/global_data.m:
compiler/hlds_out_goal.m:
compiler/jumpopt.m:
compiler/llds_to_x86_64.m:
compiler/lookup_switch.m:
compiler/opt_debug.m:
compiler/opt_util.m:
compiler/par_conj_gen.m:
compiler/proc_gen.m:
compiler/string_switch.m:
compiler/tag_switch.m:
compiler/tupling.m:
compiler/x86_64_regs.m:
	Conform to changes.

runtime/mercury_engine.h:
	Add an array of fake float "registers" to the Mercury engine structure,
	when MR_Float is wider than MR_Word.

runtime/mercury_regs.h:
	Document float registers in the Mercury abstract machine.

	Add macros to access float registers in the Mercury engine.

runtime/mercury_stack_layout.h:
	Add new MR_LongLval cases to represent double-width stack slots.

	MR_LONG_LVAL_TAGBITS had to be increased to accomodate the new cases,
	which increases the number of integers in [0, 2^MR_LONG_LVAL_TAGBITS)
	equal to 0 modulo 4.  These are the new MR_LONG_LVAL_TYPE_CONS_n cases.

	Add max float register field to MR_ExecTrace.

runtime/mercury_layout_util.c:
runtime/mercury_layout_util.h:
	Extend MR_copy_regs_to_saved_regs and MR_copy_saved_regs_to_regs
	for float registers.

	Understand how to look up new kinds of MR_LongLval: MR_LONG_LVAL_TYPE_F
	(previously unused), MR_LONG_LVAL_TYPE_DOUBLE_STACKVAR,
	MR_LONG_LVAL_TYPE_DOUBLE_FRAMEVAR.

	Conform to the new MR_LONG_LVAL_TYPE_CONS_n cases.

runtime/mercury_float.h:
	Delete redundant #ifdef.

runtime/mercury_accurate_gc.c:
runtime/mercury_agc_debug.c:
	Conform to changes (untested).

trace/mercury_trace.c:
trace/mercury_trace.h:
trace/mercury_trace_declarative.c:
trace/mercury_trace_external.c:
trace/mercury_trace_internal.c:
trace/mercury_trace_spy.c:
trace/mercury_trace_vars.c:
trace/mercury_trace_vars.h:
	Handle float registers in the trace subsystem.  This is mostly a matter
	of saving/restoring them as with regular registers.
2011-10-17 04:31:33 +00:00
Zoltan Somogyi
455e1eea75 The runtime had two different conventions for naming types.
Estimated hours taken: 2
Branches: main

The runtime had two different conventions for naming types. One convention,
used mostly in the debugger-related modules, added underscores between
capitalized words; example: MR_Label_Layout. The other convention, used
in most modules, used capitalized words without underscores (e.g. MR_TypeInfo).

This diff standardizes on the second convention. It has no algorithmic changes,
only renames of types.

runtime/*.[ch]:
trace/*.[ch]:
compiler/*.m:
library/*.m:
mdbcomp/*.m:
	Effect the change described above. The only substantive change is that
	runtime/mercury_stack_layout.h used to define *two* types for trace
	levels: MR_TraceLevel and MR_Trace_Level, and this diff standardizes
	on just one (they had equivalent definitions).

runtime/mercury_bootstrap.h:
	Add a #define from the old name to the new for all the changed type
	names that the installed compiler can put into .c files. We can delete
	these #defines some time after this diff has bootstrapped.

slice/.mgnuc_opts:
	Restore the --no-mercury-stdlib-dir option, without which the slice
	directory won't compile after this change (because it looks for type
	names in the installed runtime header files, which define the old
	versions of type names).
2006-11-29 05:18:42 +00:00
Ian MacLarty
521967f39f Implement a second version of the subterm dependency tracking algorithm
Estimated hours taken: 20
Branches: main

Implement a second version of the subterm dependency tracking algorithm
that uses the following heuristic to speed things up: If the subterm is being
tracked through an output argument, and there is an input argument with the
same name as the output argumnet, except for a numerical suffix, then the new
algorithm will check if the subterm appears in the same position in the input
argument.  If it does then it will continue tracking the subterm in the input
argument, thus bypassing the subtree rooted at the call.  Since dereferencing a
subterm in a large structure can be expensive, the new algorithm will only try
to bypass calls to procedures it has not tried to bypass before.  The set of
procedures it has tried is reset each time a new explicit subtree or supertree
is generated.

Add a `track' command that behaves in the same way as `mark', except that
it doesn't assert that the node is erroneous or inadmissible.
Add an optional `--accurate' argument which tells the declarative debugger to
use the original tracking algorithm.
We still allow the old algorithm to be used, because there
are situations where the new algorithm could find the wrong call (i.e.
when a subterm appears in the same position in an input argument,
but the subterm in the output argument is actually bound by a descendent call
-- it just happens to be bound to the same value as the input subterm).

doc/user_guide.texi:
	Change the documentation accordingly.

browser/browse.m:
browser/browser_info.m:
browser/parse.m:
browser/declarative_user.m:
	Add a `track' command that does the same thing as a `mark' command,
	except it doesn't assert the atom to be erroneous or inadmissible.
	Allow an `--accurate' or `-a' argument for the `mark' and `track'
	commands which indicates that the old subterm dependency tracking
	algorithm should be used.
	Pass information about tracked subterms to the declarative debugger.
	Do not allow a whole atom to be tracked or marked as this doesn't
	make sense.

browser/declarative_analyser.m:
browser/declarative_debugger.m:
browser/declarative_edt.m:
browser/declarative_oracle.m:
	Implement the new tracking algorithm.

browser/term_rep.m:
	Add a predicate to dereference a subterm in another term.

mdbcomp/rtti_access.m:
	Add a predicate to find a candidate input argument on which to
	apply the new heuristic.

runtime/Mmakefile:
runtime/mercury_layout_util.h:
runtime/mercury_stack_layout.h:
trace/mercury_trace_vars.c:
trace/mercury_trace_vars.h:
	Move the function for finding the name of a variable to the runtime,
	so that it can be called from the declarative debugger.

tests/debugger/declarative/Mmakefile:
tests/debugger/declarative/nodescend_tracking.exp:
tests/debugger/declarative/nodescend_tracking.inp:
tests/debugger/declarative/nodescend_tracking.m:
	Test the new heuristic.

tests/debugger/declarative/closure_dependency.inp2:
tests/debugger/declarative/closure_dependency.exp2:
	Expect an error message when marking a whole atom.
2005-11-02 14:02:16 +00:00
Zoltan Somogyi
d1c13d57c5 Fix some layout issues in these files. There are no algorithmic
Estimated hours taken: 0.3
Branches: main

runtime/mercury_accurate_gc.h:
runtime/mercury_agc_debug.h:
runtime/mercury_array_macros.h:
runtime/mercury_construct.h:
runtime/mercury_deconstruct.h:
runtime/mercury_init.h:
runtime/mercury_layout_util.h:
runtime/mercury_stack_layout.h:
runtime/mercury_stack_trace.h:
runtime/mercury_trail.h:
	Fix some layout issues in these files. There are no algorithmic
	changes.
2005-06-21 03:12:03 +00:00
Fergus Henderson
9656086353 Implement accurate GC for type class methods.
Estimated hours taken: 24
Branches: main

Implement accurate GC for type class methods.
Accurate GC now supports the whole Mercury language.

compiler/ml_closure_gen.m:
	Generate GC tracing code for the type class method instance
	wrapper functions whose addresses get stored in typeclass_infos.
	This code generates a closure layout for the method instance
	procedure, and then calls MR_materialize_closure_params(),
	passing it the typeclass_info and the closure layout.

runtime/mercury_layout_util.h:
runtime/mercury_layout_util.c:
	Add new routine MR_materialize_typeclass_info_params(), for use
	by the code generated by ml_closure_gen.m.
	This is similar to MR_materialize_closure_params() except that
	it works on a typeclass_info rather than an MR_Closure.

compiler/ml_code_util.m:
	Change ml_bump_function_labels so that it also bumps the constant
	sequence number, and rename it as ml_bump_counters.  This is needed
	to avoid clashes between different local closure_layout constants
	after they get hoisted to the top level by ml_elim_nested.m.

compiler/rtti_to_mlds.m:
	Update to reflect the changed interface to ml_gen_closure_wrapper
	and ml_code_util.m.

compiler/ml_elim_nested.m:
	Update the accurate GC TODO list.

compiler/options.m:
doc/user_guide.texi:
	Document that accurate GC is now supported.

NEWS:
	Mention that we now support accurate GC.
2003-09-25 07:56:47 +00:00
Zoltan Somogyi
ab5a7c7acf Fix two bugs in the printing of goals where the predicate concerned is an
Estimated hours taken: 6
Branches: main

Fix two bugs in the printing of goals where the predicate concerned is an
compiler-generated unify, compare or index predicate. Improve the mechanisms
for debugging bugs like this.

runtime/mercury_layout_util.[ch]:
	Fix bug one: do not return the arity of a type constructor as
	the arity of the unify, compare or index predicate of that
	type constructor; return the actual arity. When the falsely
	returned arity was greater than the actual arity, we could get
	core dumps; when it was smaller, the mdb command "print goal"
	printed wrong output.

	Provide a mechanism for fixing bug two: add a utility function
	for computing *correctly* a procedure's original arity and the number
	of type_info and/or typeclass_info arguments added by the compiler.
	(For convenience, it also returns a predicate/function indication.)

runtime/mercury_stack_layout.h:
	Rename the MR_comp_arity field of MR_Compiler_Proc_Id to
	MR_comp_type_arity, to make clear that it gives the arity of the type
	constructor, not the arity of the predicate, and thus avoid bugs such
	as those above.

runtime/mercury_stack_trace.c:
	Use the new name of the MR_comp_type_arity field.

trace/mercury_trace_declarative.c:
trace/mercury_trace_vars.c:
	Call the new, correct utility function in runtime/mercury_layout_util
	to compute how many typeinfo and/or typeclassinfo arguments are added
	by the compiler to a unify, compare, or index procedure's arguments,
	instead of the different, but logically equivalent and equally wrong
	pieces of code here.

trace/mercury_trace_external.c:
	Use the new name of the MR_comp_type_arity field. Leave an XXX, since
	I am not sure whether Morphine interprets the arity as the arity of the
	type constructor or as the arity of the predicate.

runtime/mercury_engine.[ch]:
runtime/mercury_layout_util.c:
	Make the printing of locations obtained from RTTI data structures
	switchable from mdb, to make problems like this easier to debug.

tests/debugger/uci.{m,inp,exp}:
	A new test case to test the proper handling of unify, compare and index
	predicates.

tests/debugger/Mercury.options:
tests/debugger/Mmakefile:
	Enable the new test case.
2003-04-02 23:01:45 +00:00
Zoltan Somogyi
985b13ed3f Make I/O actions known to the declarative debugger.
Estimated hours taken: 48
Branches: main

Make I/O actions known to the declarative debugger. The debugger doesn't do
anything with them yet beyond asking about their correctness.

browser/io_action.m:
	New module for representing I/O actions, and for constructing the map
	from I/O action numbers to the actions themselves.

browser/mdb.m:
	Include the new module.

browser/declarative_analysis.m:
	Make the map from I/O action numbers to the actions themselves part
	of the analyzer state, since conversions from annotated trace nodes
	to EDT nodes may now require this information. This information is
	stored in the analyzer state because only the analyser needs this
	information (when converting annotated trace nodes to EDT tree nodes).
	It is not stored in the trace node store because its lifetime is
	different: its contents does not change during a tree deepening
	operation.

browser/declarative_execution.m:
	Store the current value of the I/O action counter with each call and
	exit node. The list of I/O actions associated with the atom of the exit
	node is given by the I/O actions whose counters lie between these two
	values (initial inclusive, final exclusive).

browser/declarative_debugger.m:
browser/declarative_oracle.m:
	Distinguish atoms associated with exit nodes from atoms associated with
	call nodes, since the former, but not the latter, now have a list of
	I/O actions associated with them.

browser/declarative_user.m:
	Add mechanisms for printing and browsing the I/O actions associated
	with EDT nodes and bugs.

runtime/mercury_trace_base.[ch]:
	Move the code for finding an I/O action here from the file
	mercury_trace_declarative.c, for use by browser/io_action.m.

runtime/mercury_layout_util.[ch]:
	Move a utility function here from mercury_trace_declarative.c,
	for use by the code moved to mercury_trace_base.c.

trace/mercury_trace_declarative.c:
	When invoking the front end, pass to it the boundaries of the required
	I/O action map. Cache these boundaries, so we can tell the front end
	when reinvocation of the back end by the front end (to materialize
	previously virtual parts of the annotated trace) does not require
	the reconstruction of the I/O action map.

trace/mercury_trace_vars.[ch]:
	Separate out the code for finding an I/O action from the code for
	browsing it, for use in mercury_trace_declarative.c.

	Note places where the implementation does not live up to the
	documentation.

trace/mercury_trace.[ch]:
	Add a parameter to MR_trace_retry that allows retries to cross I/O
	actions without asking the user if this is OK.

trace/mercury_trace_internal.c:
trace/mercury_trace_external.c:
	Pass MR_FALSE as this new parameter to MR_trace_retry.

tests/debugger/declarative/tabled_read_decl.{m,inp,exp}:
	A slightly modified copy of the tests/debugger/tabled_read_decl test
	case, to check the declarative debugger's handling of goals with I/O
	actions.

tests/debugger/declarative/Mmakefile:
	Enable the new test case.
2002-05-15 11:24:21 +00:00
Fergus Henderson
e8d8b655ff Fix some misleading documentation and a misleading name for
Estimated hours taken: 1
Branches: main

runtime/mercury_layout_util.h:
runtime/mercury_layout_util.c:
	Fix some misleading documentation and a misleading name for
	MR_materialize_typeinfos() and friends: s/typeinfos/type_params/g.

runtime/mercury_accurate_gc.c:
runtime/mercury_agc_debug.c:
runtime/mercury_deep_copy_body.h:
runtime/mercury_ml_expand_body.h:
trace/mercury_trace_vars.c:
	Use the new names.
2002-03-27 07:35:38 +00:00
Zoltan Somogyi
b51c742885 Allow the debugger to print higher order values and typeinfos, mainly by
Estimated hours taken: 50
Branches: main

Allow the debugger to print higher order values and typeinfos, mainly by
making the committed choice modes of the predicates in deconstruct.m to
deconstruct higher order values and typeinfos. (The non committed choice
versions will continue to return only placeholders.)

Having the debugger print typeinfos is occasionally useful but more often
it is just distracting. This change therefore adds a new debugger command,
"print_optionals", that toggles the printing of optional values. For now,
the only optional values are typeinfos.

NEWS:
	Mention the new capability and the new predicates in the library.

	Mention the predicates added previously that allow the caller to
	specify how non-canonical terms should be handled, since the change
	in their semantics that we anticipated when they were added has now
	happened, and their semantics should now be more stable.

browser/browser_info.m:
	Use the predicates in the deconstruct.m instead of std_util,
	to make the choice of noncanonical term method handling explicit.

browser/browse.m:
	When writing small terms using io__write_univ, explicitly use
	the same noncanonical term handling method as browser_info.m

library/io.m:
	Add predicates to retrieve the current input and output streams.

	Add versions of io__write_univ that specify the stream and maybe
	the method of handling noncanonical terms.

	Add a mode to io__write_list that allows the closure that prints the
	list elements to be cc_multi.

	All of these are for the new functionality in the browser.

runtime/mercury_ml_expand_body.h:
	In committed choice contexts, deconstruct closures as if they were
	ordinary terms, with the function symbol being the name of the
	predicate/function and the arguments being the terms stored in
	the closure.

	In committed choice contexts, deconstruct typeinfos as if they were
	ordinary terms, with the function symbol being the name of the type
	constructor and the arguments being the type constructor's arguments.

runtime/mercury_type_info.[ch]:
	Add a new function, MR_collapse_ctor_equivalences, for use by
	mercury_ml_expand_body.h.

	Delete a redundant function comment.

library/deconstruct.m:
	Document the changes in the behavior of the predicates defined in this
	module as a result of the change to mercury_ml_expand_body.h.

runtime/mercury_ho_call.h:
runtime/mercury_stack_layout.h:
	Add prefixes on structure field names that did not have them.

browser/dl.m:
	Add prefixes where needed by the changes to mercury_ho_call.h.

runtime/mercury_layout_util.[ch]:
	Remove the first argument of MR_materialize_closure_typeinfos, since
	its correct value is always the same part of the second argument.

runtime/mercury_deep_copy_body.h:
	Do not pass the first argument of MR_materialize_closure_typeinfos.

	Add field name prefixes where necessary.

compiler/modules.m:
	The mercury_builtin module is no longer part of the library.

compiler/pd_debug.m:
compiler/rl_analyze.m:
	Minor updates to avoid trying to take the address of io__write_list,
	since it now has more than one mode.

runtime/mercury_init.h:
runtime/mercury_wrapper.[ch]:
trace/mercury_trace_vars.[ch]:
	Add a parameter to MR_trace_browse_all_on_level that specifies
	whether we should print values of type type_info.

trace/mercury_trace_vars.c:
	Do not ignore predicates and functions anymore.

runtime/mercury_stack_trace.c:
trace/mercury_trace.c:
trace/mercury_trace_declarative.c:
trace/mercury_trace_external.c:
	Pass the new parameter of MR_trace_browse_all_on_level.

trace/mercury_trace_internal.c:
	Implement the "print_optionals" command.

doc/user_guide.texi:
	Document the "print_optionals" command.

tests/debugger/mdb_command_test.inp:
	Test the documentation of "print_optionals".

tests/debugger/higher_order.{m,inp,exp,exp2}:
	A new test case to exercise the ability to print higher order values.

	Note that the format of the predicate names in the output should be
	improved, but that is a separate change since doing it the right way
	requires bootstrapping.

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

tests/debugger/nondet_stack.exp*:
	Update the expected output to reflect the fact that nondet stack dumps,
	being intended for debugging, include type_infos.

tests/debugger/tabled_read_decl.exp*:
	Update the expected output to reflect the fact that for maximum
	usefulness, the printing of I/O action atoms prints meaningful
	type_infos.

tests/hard_coded/deconstruct_arg.*:
tests/hard_coded/write_reg1.*:
	Expand these tests to check that we handle higher order values
	correctly not just when canonicalizing but also in committed choice
	modes.
2002-02-24 11:53:46 +00:00
Zoltan Somogyi
13f0e7610a A large step towards declarative debugging of goals that do I/O.
Estimated hours taken: 40
Branches: main

A large step towards declarative debugging of goals that do I/O. This step
does everything needed for that except modify the declarative debugger itself;
that is for Mark to do.

If you give the new option --trace-table-io-decl, the transformation performed
by the compiler on I/O primitives will preserve not just the output arguments
of the primitive, so that the primitive can be "reexecuted" without performing
any side-effects, but also the input arguments and the identity of the I/O
primitive itself. The I/O table therefore will contain a list of the I/O
primitives executed by the program after I/O tabling is started.

You can test this via the new debugger commands "print action <action-number>"
and "browse action <action-number>".

The new option is currently not documented, because the declarative debugger
does not yet use the information it provides. The new debugger commands are
not documented because they are meant only for implementors, at least for
now.

Since this change adds a field to proc_layout structures, any workspaces
compiled with debugging enabled will need to do a cvs update when this change
is installed.

compiler/options.m:
	Add the option --trace-table-io-decl. When set, this causes the
	compiler to transform I/O action primitives to allow declarative
	debugging of I/O actions.

compiler/handle_options.m:
	Make --trace-table-io-decl imply --trace-table-io.

compiler/table_gen.m:
	Perform the transformation, which is similar to the existing
	--trace-table-io transformation, but preserves the identity of all
	non-io-state arguments (not just the outputs) and the identity
	of the I/O primitive itself.

	Provide better names for variables generated by tabling
	transformations.

compiler/hlds_goal.m:
	Add extra parameters to procedures whose job it is to create new
	goals to name the variables in those goals.

compiler/layout.m:
	Add a new layout structure to contain the information the runtime
	system needs to interpret the information saved by the new
	transformation.

compiler/layout_out.m:
	Output the new layout structure.

compiler/continuation_info.m:
	Add a field to proc_layouts to point to the declarative I/O tabling
	structure, and another to identify the proc_layout without using LLDS
	types.

compiler/code_gen.m:
	Provide the definition of this field when appropriate.

compiler/hlds_pred.m:
	Add a field to proc_infos to store the information from the tabling
	transformation until code generation.

compiler/stack_layout.m:
	Add a mechanism for transforming the high level description of I/O
	action tabling data in proc_infos to the low level description we need
	to generate C data structures.

compiler/hlds_data.m:
	Add a new cons_id and a new cons_tag; they are used to refer to I/O
	tabling structures in code generated by the new transformation.

compiler/*.m:
	Handle the updates to global data types above.

library/table_builtin.m:
	Modernize some old code.

	Fix an old off-by-one error: make I/O tabling use the first slot
	in the I/O action table.

library/varset.m:
	Add a mechanism for creating a variable that is named iff the caller
	has a name for it.

runtime/mercury_layout_util.[ch]:
	Add a function for materializing type parameters from an answer block,
	not from registers or a closure.

runtime/mercury_stack_layout.h:
	Declare a C type for the data structure holding information about
	I/O primitives transformed by --trace-table-io-decl, and add a field
	to proc_layout structures to point to these new structures.

	Add a new evaluation method for --trace-table-io-decl.

runtime/mercury_tabling_macros.h:
	Add some conditionally-compiled debugging code to the primitive for
	saving answers.

trace/mercury_trace_vars.[ch]:
	Add functions for printing I/O action goals.

trace/mercury_trace_internal.c:
	Add code for recognizing and implementing commands to print I/O
	action goals.

trace/mercury_trace.c:
	Add code for handling the new eval method.

tests/debugger/tabled_read.{m,inp,exp*}:
	Add a polymorphic I/O action primitive, add calls to it, and test
	the printing of both monomorphic and polymorphic action goals.

tests/debugger/tabled_read_decl.{m,inp,exp*,data}:
	A new test case. It does the same things as the new version of
	tabled_read, but it is compiled with --trace-table-io-decl, not
	just --trace-table-io. It therefore can (and does) test the printing
	of tabled I/O actions.

tests/debugger/Mmakefile:
	Add the new test case.
2002-02-20 03:14:51 +00:00
Simon Taylor
b7c4a317e9 Add MR_ prefixes to the remaining non-prefixed symbols.
Estimated hours taken: 4
Branches: main

Add MR_ prefixes to the remaining non-prefixed symbols.

This change will require all workspaces to be updated
The compiler will start generating references to MR_TRUE,
MR_bool, etc., which are not defined in the old runtime
header files.

runtime/mercury_std.h:
	Add MR_ prefixes to bool, TRUE, FALSE, max, min,
	streq, strdiff, strtest, strntest, strneq, strndiff,
	strntest, NO_RETURN.

	Delete a commented out definition of `reg'.

runtime/mercury_tags.h:
	Add an MR_ prefix to TAGBITS.

configure.in:
runtime/mercury_goto.h:
runtime/machdeps/i386_regs.h/mercury_goto.h:
	Add an MR_ prefix to PIC.

runtime/mercury_conf_param.h:
	Allow non-prefixed PIC and HIGHTAGS to be defined on
	the command line.

runtime/mercury_bootstrap.h:
	Add backwards compatibility definitions.

RESERVED_MACRO_NAMES:
	Remove the renamed macros.

compiler/export.m:
compiler/ml_code_gen.m:
	Use MR_bool rather than MR_Bool (MR_Bool is
	meant to be for references to the Mercury type
	bool__bool).

runtime/mercury_types.h:
	Add a comment the MR_Bool is for references to
	bool__bool.

*/*.c:
*/*.h:
*/*.m:
	Add MR_ prefixes.
2002-02-18 07:01:33 +00:00
Fergus Henderson
5e0cfaf6bd Fix a bug where MR_deep_copy() was crashing when copying closures
Estimated hours taken: 3
Branches: main, release

Fix a bug where MR_deep_copy() was crashing when copying closures
for polymorphic predicates.

runtime/mercury_layout_util.h:
runtime/mercury_layout_util.c:
	Add MR_materialize_closure_typeinfos(),
	for use by mercury_deep_copy_body.h.

runtime/mercury_deep_copy.c:
	#include mercury_layout_util.h, for MR_materialize_closure_typeinfos().

runtime/mercury_deep_copy_body.h:
	Fix a bug: when copying closures, use MR_materialize_closure_typeinfos()
	to get the type_infos for the already-applied closure arguments
	from the closure itself, rather than trying to get them from
	the arguments of the typeinfo for the closure (the latter holds
	the type-infos for the yet-to-be-applied arguments, not the
	already-applied arguments).

tests/hard_coded/Mmakefile:
tests/hard_coded/copy_pred_2.m:
tests/hard_coded/copy_pred_2.exp:
	Add a test case.
2001-08-07 23:12:32 +00:00
Zoltan Somogyi
2498d9d3fd Instead of generating the layout structures of labels, procs and modules
Estimated hours taken: 36

Instead of generating the layout structures of labels, procs and modules
as rvals, generate them almost entirely as C structures. This will make
future modifications much easier, since mismatches between what the runtime
expects and what the compiler generates will now be pointed out by the C
compiler. (It also reduces the size of the C source files generated with
debugging enabled by about 5%.) Layout structures contain a few components
that are not well-typed in C; we continue to generate these as rvals.

Closure layout structures used to have a well-typed part and a non-well-typed
part. We now generate the well-typed part as a separate structure, pointed to
from the other. We also extend the well-typed part, so that instead of
just giving the name the called procedure, it also identifies the source
location where the closure was constructed. This could be useful for
the debugger and for deep profiling.

This diff also includes a change to get the compiler to bootstrap with lcc
in grade none.gc.debug.tr: initializing the string tables in module layouts
not as a string but as an array of characters.

runtime/mercury_stack_layout.h:
	Reorganize the definitions of layout structures. Rename
	Stack_Layout_Entry structures as Proc_Layout structures,
	and Stack_Layout_Label structures as Label_Layout structures.
	(The debugger paper refers to the structures by the new names.)
	Fold the Stack_Layout_Vars structure into the structure that contains
	it, the Label_Layout structure. Add a Closure_Id structure that
	contains a Proc_Id structure as well as extra information identifying
	the source location where the closure was created.

	Create "short" versions of the Proc_Layout structures, which contain
	only the first one or two of the three groups of fields. Previously,
	the Mercury compiler would define new C types when it generated such
	short structures. Since we are not defining new C types anymore, there
	must be a C type for every kind of structure the Mercury compiler can
	generate. We now also have separate variants for the layouts of
	user-defined and compiler-generated procedures, since the format
	of their procedure id information is different. While the runtime
	system refers to their procedure id information through a union,
	the C types of the structures generated by the Mercury compiler
	do not use a union, since a union cannot be initialized through
	its second member.

	Make the constant fields of structures const, since we now generate
	values of those structure types, and initialize them with constant
	data.

	Move the documentation of layout structures here from stack_layout.m.

runtime/mercury_ho_call.h:
	Instead of bodily including an MR_Proc_Id structure in closures,
	include a pointer to the more detailed MR_Closure_Id structure.

runtime/mercury_accurate_gc.c:
runtime/mercury_agc_debug.c:
runtime/mercury_init.h:
runtime/mercury_label.[ch]:
runtime/mercury_layout_util.[ch]:
	Minor updates to conform to changes in mercury_stack_layout.h.

runtime/mercury_goto.h:
	Use separate naming schemes for label layout structures and proc layout
	structures.

library/exception.m:
	Minor updates to conform to changes in mercury_stack_layout.h.

compiler/layout.m:
	A new module that defines data structures for label, proc and module
	layout structures and for closure id structures.

compiler/layout_out.m:
	A new module that converts the Mercury data structures of layout.m into
	declarations and definitions of C data structures.

compiler/stack_layout.m:
	Generate the new layout structures instead of rvals.

	Move the documentation of layout structures from here to
	runtime/mercury_stack_layout.h, since this module is no longer
	aware of some of their details.

compiler/llds.m:
	Make layout structures a separate kind of compiler-generated data.

compiler/llds_out.m:
	Remove the code for the output of layout structures; call layout_out.m
	instead.

compiler/llds_out.m:
compiler/rtti_out.m:
	Turn some predicates into functions.

compiler/code_gen.m:
compiler/code_info.m:
compiler/llds.m:
compiler/mercury_compile.m:
compiler/unify_gen.m:
	Instead of handling closure layouts like other static data, handle
	them separately. Add a counter to the code_info structure in order
	to allow closure id structures to be identified uniquely by a pair
	consisting of the id of the procedure that generates them and a closure
	sequence number within that procedure.

compiler/llds_common.m:
	Look for common rvals among the rvals in layout structures.

compiler/opt_debug.m:
	Generate developer-friendly names for layout structure references.

browser/dl.m:
	Update the code for constructing closure layouts.
2001-01-18 01:19:17 +00:00
Zoltan Somogyi
090552c993 Make everything in the runtime use MR_ prefixes, and make the compiler
Estimated hours taken: 10

Make everything in the runtime use MR_ prefixes, and make the compiler
bootstrap with -DMR_NO_BACKWARDS_COMPAT.

runtime/mercury_*.[ch]
	Add MR_ prefixes to all functions, global variables and almost all
	macros that could pollute the namespace. The (intentional) exceptions
	are

	1. some function, variable, type and label names that already start
	   with MR_, mercury_, Mercury or _entry;
	2. some standard C macros in mercury_std.h;
	3. the macros used in autoconfiguration (since they are used in scripts
	   as well as the runtime, the MR_ prefix may not be appropriate for
	   those).

	In some cases, I deleted things instead of adding prefixes
	if the "things" were obsolete and not user visible.

runtime/mercury_bootstrap.h:
	Provide MR_-less forms of the macros for bootstrapping and for
	backward compatibility for user code.

runtime/mercury_debug.[ch]:
	Add a FILE * parameter to a function that needs it.

compiler/code_info.m:
compiler/export.m:
compiler/fact_table.m:
compiler/llds.m:
compiler/llds_out.m:
compiler/pragma_c_gen.m:
compiler/trace.m:
	Add MR_ prefixes to the C code generated by the compiler.

library/*.m:
	Add MR_ prefixes to handwritten code.

trace/mercury_trace_*.c:
util/mkinit.c:
	Add MR_ prefixes as necessary.

extras/concurrency/semaphore.m:
	Add MR_ prefixes as necessary.
2000-11-23 02:01:11 +00:00
Tyson Dowd
5384f88ac2 Updates to the accurage garbage collector (including fixes to get it to
Estimated hours taken: 8

Updates to the accurage garbage collector (including fixes to get it to
compile and also to use the MR_Long_Lval and MR_Short_Lval code).
A prototype of non-det stack tracing.

runtime/mercury_accurate_gc.c:
runtime/mercury_accurate_gc.h:
runtime/mercury_agc_debug.c:
runtime/mercury_agc_debug.h:
	Updates to the GC necessary to get it to compile.

runtime/mercury_conf_param.h:
runtime/mercury_wrapper.c:
	Add an option to set the heap very small (useful for debugging).

runtime/mercury_deep_copy.c:
runtime/mercury_deep_copy_body.h:
	Start adding checks for traversal range (things that aren't on
	the heap, but might contain pointers into the heap).
	Not all of the checks have been done yet.

runtime/mercury_layout_util.c:
runtime/mercury_layout_util.h:
	Fix a type -- MR_TypeInfo instead of MR_Word.

runtime/mercury_memory_handlers.c:
	Add get_curfr_from_context

runtime/mercury_stack_layout.h:
	Fix a comment.
	Define MR_SHORT_LVAL_NUMBER to find the number (e.g. register
	number or stack from) from a short lval.
2000-11-07 08:58:35 +00:00
Tyson Dowd
db64a3588d Add MR_ prefixes to the types used when generating C code.
Estimated hours taken: 4

Add MR_ prefixes to the types used when generating C code.
This means types such as Word, String, Bool, Float become MR_Word,
MR_String, MR_Bool, MR_Float.  Also define MR_Box for both the LLDS and
MLDS backends so we can use it uniformly.

This is very important in environments where String or Bool have already
been used as system types (for example, managed C++).  And besides, we
should do it anyway as part of the grand namespace cleanup.

I have fixed all of the uses of the non-prefixed types in the runtime
and trace directories.  I haven't done it for the library and compiler
directories yet (no promises that I will do it in future either).  But
if you see a non-prefixed type in code from now on, please consider it a
bug and fix it.

mercury_bootstrap.h contains #defines to map the non-prefixed types into
the prefixed ones.  Like many of the other namespace cleaning backwards
compatibility macros, this can be turned off with
MR_NO_BACKWARDS_COMPAT.

This shouldn't break any code, but this kind of change affects so many
things that of course there could be problems lurking in there somewhere.

If you start getting errors from the C compiler after this change is
installed, you will want to make sure you at least have the runtime
system updated so that you are getting the backwards compatibility
definitions in mercury_bootstrap.h.  Then if you continue to have
problems you can bug me about it.

compiler/export.m:
compiler/llds_out.m:
compiler/mlds_to_c.m:
	Use MR_Word, MR_Float, MR_Bool, etc when generating C.

doc/reference_manual.texi:
	Update the reference manual to talk about MR_Word, MR_String,
	MR_Char, etc.

runtime/mercury_bootstrap.h:
	Add bootstrapping typedefs.

runtime/*:
trace/*:
	Change Word, Float, Bool, Code, String, etc to
	MR_Word, MR_Float, MR_Bool, MR_Code, MR_String.
2000-08-03 06:19:31 +00:00
Fergus Henderson
a1b02cfc47 More fixes for the MLDS back-end.
Estimated hours taken: 8

More fixes for the MLDS back-end.

compiler/ml_code_gen.m:
library/private_builtin.m:
runtime/mercury.h:
	Don't treat unsafe_type_cast as an inline builtin, since the
	code generated for it as an inline builtin is not type-correct.
	Instead, declare `unsafe_type_cast/2' as external in
	library/private_builtin.m, so that the generated code
	for this module does not try to declare or define it.
	And in runtime/mercury.h, define unsafe_type_cast/2 as a
	macro / inline function.

library/private_builtin.m:
	Fix a bug in my previous change: add a missing cast.

runtime/mercury_type_info.h:
	Declare the constants mercury_data___type_ctor_info_{pred,func}_0;
	used by the MR_TYPE_CTOR_INFO_HO_{FUNC,PRED} macros.
	Add some conditional code so that those macros do the right
	thing for the MLDS back-end.

runtime/mercury_deep_copy.c:
runtime/mercury_tabling.c:
library/std_util.m:
	Delete the now unnecessary declarations of
	mercury_data___type_ctor_info_{pred,func}_0;
	these are now declared in runtime/mercury_type_info.h.

library/std_util.m:
	Delete the redundant definitions of the MR_TYPE_CTOR_INFO_*()
	macros; these were defined identically in runtime/mercury_type_info.h.
	Also use MR_TYPE_CTOR_INFO_HO_{FUNC,PRED} rather than hard-coding
	their definitions.

runtime/mercury.h:
runtime/mercury.c:
	Update to reflect recent RTTI changes.
	In particular, use MR_TypeCtorInfo rather than MR_BaseTypeInfo,
	and delete the code for the index/2 predicate.

runtime/mercury_std.h:
runtime/mercury.h:
	Move the definition of MR_INLINE and MR_EXTERN_INLINE
	from mercury.h to mercury_std.h, since they're used in
	mercury_heap.h.

runtime/mercury.c:
	Wrap `#ifdef MR_HIGHLEVEL_CODE' around the whole of this file,
	so that it does the right thing in LLDS-based grades.

runtime/mercury_heap.h:
runtime/mercury_imp.h:
runtime/mercury_deep_copy.h:
runtime/mercury_layout_util.h:
	Add some missing `#include' directives.

runtime/Mmakefile:
	Add mercury.c and mercury.h to the respective file lists.
	Split the HDRS variable into HDRS and BODY_HDRS, so that
	`mmake check_headers' does not assume that *_body.h
	will be syntactically correct.
2000-05-05 10:14:50 +00:00
Zoltan Somogyi
c2a696d8b6 Clean up the runtime system's handling of type_infos and pseudo_type_infos.
Estimated hours taken: 40

Clean up the runtime system's handling of type_infos and pseudo_type_infos.
This cleanup has two major aspects. First, it represents type_infos and
pseudo_type_infos with distinct C types, and reducing the use of casts
to the minimum. These casts are in two kinds of places: in a few macros
defined in runtime/mercury_type_info.h, and at the interfaces between C code
and Mercury code (since Mercury code represents (pseudo-)type_infos, like
everything else, as Words). Part of this aspect is the separation of the
type "MR_TypeInfo" from the type "MR_TypeInfoParams"; a MR_TypeInfo can be
used as a source of type parameters directly only when it is first order.
Second, it removes the confusion between the types named "type_info" and
"type_ctor_info" defined by the modules private_builtin.m and std_util.m,
by renaming the types defined in std_util.m to "type_desc" and
"type_ctor_desc".

To avoid doing this cleanup twice, this diff also removes support for the
old type_ctor_info representation. This in turn makes it feasible to provide
conditionally enabled code to support unification and comparison by RTTI.

runtime/mercury_grade.h:
	Increment the binary compatibility version number. This is required
	by the dropping of support for old type_ctor_info representations.

runtime/mercury_type_info.h:
	Define the types MR_TypeInfo, MR_PseudoTypeInfo and MR_TypeInfoParams,
	and macros that operate on them.

	Remove the types and macros that were useful only with the old RTTI
	representation.

	Move the section that deals with initializing code addresses in
	type_ctor_info structure for grades without static code addresses
	to the logical place.

	Add a const qualifier to the MR_sectag_alternatives field in
	MR_DuPtagLayout, since this simplifies code manipulating du types.

	Convert the whole file to 4 space indentation, since it is a nuisance
	if only part of it is so indented.

runtime/mercury_deep_copy.h:
runtime/mercury_deep_copy_body.h:
runtime/mercury_tabling.h:
runtime/mercury_tabling.c:
	Clean up the implementation as described above.

runtime/mercury_type_info.c:
runtime/mercury_make_type_info_body.h:
	Clean up the implementation as described above.

	Eliminate the code duplication between the function MR_make_type_info
	and MR_create_type_info, and their helpers, which do the same thing
	except for how they allocate memory, by putting the common code into
	the new file mercury_make_type_info_body.h, and including it twice
	in two different #define contexts.

	Move the (updated) documentation of those functions to
	mercury_type_info.h, where it belongs.

runtime/mercury_ho_call.c:
runtime/mercury_unify_compare_body.h:
	Clean up the implementation as described above.

	Eliminate the code duplication between the implementation of unify
	and compare, which do very similar jobs, by putting the common code
	into the new file mercury_unify_compare_body.h, and including it three
	times in two different #define contexts. The third time is for defining
	the body of a C function which does the same thing as compare. This
	is necessary for unification and comparison by RTTI, since the
	unification or comparison of two structured terms requires comparing
	their subterms. (There is no need for a separate C function for
	unification; the C comparison function is sufficient.)

	mercury_unify_compare_body.h has conditional support for unification
	and comparison by RTTI. Although this has been tested and is known
	to work, it is turned off for the moment. This may change after
	benchmarking.

runtime/Mmakefile:
	Add the new include files to the list.

library/std_util.m:
	Rename type_info to type_desc and type_ctor_info to type_info_desc.
	Keep the old names as equivalence types, for the time being.
	Document the representations.

	Move the macros that refer to type_descs and type_ctor_descs here from
	runtime/mercury_type_info.h, since this is the only place where they
	are used. Rename them to conform to the new names of the types.

	Clean up the implementation of the RTTI predicates and functions
	as described above. In the process, fix some bugs where type variables
	were expanded twice, with the second expansion's code being incorrect.
	Also factor out some common code, and unfactor some uncommon code
	(where a function had two uses, but its implementation was inefficient
	overkill for one of them).

library/builtin.m:
library/private_builtin.m:
library/io.m:
library/store.m:
runtime/mercury_layout_util.[ch]:
trace/mercury_trace_declarative.c:
trace/mercury_trace_external.c:
trace/mercury_trace_vars.[ch]:
	When calling C functions involving type_infos, cast them to the new
	types.

runtime/mercury_stack_layout.h:
	Fix a bug that was masked by casts in its client code.

compiler/rtti_out.m:
	Delete from the output a cast made unnecessary by the new const
	qualifier on MR_sectag_alternatives.

browser/browse.m:
browser/help.m:
library/io.m:
library/term.m:
tests/hard_coded/construct.m;
tests/hard_coded/existential_types_test.m:
tests/hard_coded/higher_order_type_manip.{m,exp}:
	Refer to the types defined in std_util.m by their new names.

tests/hard_coded/existential_rtti.{m,exp}:
	Make the test tougher by printing out not just one deconstructed term,
	but deconstructed versions of all the terms created by this test.
2000-03-24 10:28:07 +00:00
Fergus Henderson
9b1de2d770 Update a comment to reflect my recent change
Estimated hours taken: 0.1

runtime/mercury_layout_util.h:
	Update a comment to reflect my recent change
	to mercury_layout_util.c.
1999-12-13 14:03:40 +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
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
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
Erwan Jahier
048016ba14 Fix a bug in the external debugger. The execution was crashing during the
Estimated hours taken: 3

Fix a bug in the external debugger. The execution was crashing during the
printing of polymorphic arguments. In runtime/mercury_layout_util.c,
MR_get_type_filtered() and MR_get_type_and_value_filtered() were calling
MR_get_type() and MR_get_type_and_value() without type_info information (third
argument set to NULL), which is needed to retrieve polymorphic types.


runtime/mercury_layout_util.[ch]:
	Pass down type_info in argument of MR_get_type_and_value_filtered() and
	MR_get_type_filtered() to be able to call MR_get_type_and_value() and
	MR_get_type() with type_info information.

runtime/mercury_layout_util.c
	Filter out variables which names begin by "TypeClassInfo" in
	MR_get_type_and_value_filtered() (as it was already done in
	MR_get_type_filtered()).

runtime/mercury_layout_util.c
trace/mercury_trace_external.c:
	In a few functions, do not try to retrieve information about live
	variables if it does not exist any.

trace/mercury_trace_external.c:
	Pass type_info in argument of MR_get_type_and_value_filtered()
	and MR_get_type_filtered().

	Filter out in MR_trace_make_var_names_list() the variable names
	that are also filtered in MR_get_type_and_value_filtered().
1999-02-19 16:11:48 +00:00
Fergus Henderson
fbd55b8d7c Fix the code in the runtime so that `mmake check_headers' succeeds.
Estimated hours taken: 3

Fix the code in the runtime so that `mmake check_headers' succeeds.

runtime/*.h:
	Add #include statements to make all the header files
	self-contained.

runtime/mercury_table.h:
runtime/mercury_table.c:
	Delete these empty files.
	For some reason zs left these files as empty instead of deleting
	them when he renamed the module as mercury_hash_table.{h,c}.

runtime/mercury_table_builtins.h:
runtime/mercury_table_enum.h:
runtime/mercury_table_any.h:
runtime/mercury_table_type_info.h:
runtime/mercury_table_builtins.c:
runtime/mercury_table_enum.c:
runtime/mercury_table_any.c:
runtime/mercury_table_type_info.c:
runtime/mercury_tabling.h:
runtime/mercury_tabling.c:
	Avoid a circular dependency problem (mercury_tabling.h
	depended on mercury_table_*.h which in turn depended on
	mercury_tabling.h) by moving all the tabling code into
	a single module mercury_tabling.{h,c}.
	The new module is a total of 1100 lines of code,
	which is not too large IMHO.

	Also improve the documentation a little.

runtime/Mmakefile:
	Update the reflect the added and removed files.
	Also update the rule for `mmake check_headers' so that
	it can make use of parallelism in parallel makes.
	And make a start towards enforcing namespace cleanliness --
	I've added code to check it, but not to enforce it.
1998-11-09 10:24:46 +00:00
Fergus Henderson
2236de7b28 Add some comments.
Estimated hours taken: 0.25

runtime/mercury_wrapper.h:
runtime/mercury_layout_util.h:
	Add some comments.
1998-11-09 05:23:34 +00:00
Zoltan Somogyi
8a0ceb49aa This checkin has several major purposes, set out in the sections below,
Estimated hours taken: 240

This checkin has several major purposes, set out in the sections below,
all connected with the implementation of the new debugger command set.

DOCUMENT NEW DEBUG COMMAND SET

doc/user_guide.texi:
	Add a new section on the debugger. The description of the commands
	is complete, but some of the background sections, and the section
	about how to build debuggable executables, are not yet done.

	Update the documentation of the tracing options.

doc/generate_mdb_doc:
	A new shell script that automatically converts some of the new
	sections of the user guide into the online documentation of the
	debugger.

doc/mdb_categories:
	The fixed initial part of the online documentation.

doc/Mmakefile:
	Add rules for creating mdb_doc, the file that is the online
	documentation of the debugger, and for installing it together
	with mdbrc.

Mmake.common.in:
	Define INSTALL_DOC_DIR for doc/Mmakefile.

scripts/mdbrc.in:
	A debugger command script that reads in the online documentation
	and then defines some standard aliases.

configure.in:
	Define the variable that scripts/mdb.in and scripts/mdbrc.in use
	to find the right files, and get configure to perform the
	substitutions.

configure.in:
scripts/mdb:
scripts/mdb.in:
	Replace mdb with mdb.in. Mdb is now created during configuration
	from mdb.in, filling in the name of the file that contains the default
	debugger initialization commands.

util/info_to_mdb.c:
	A program that does most of the work involved in automatically
	converting user guide sections into online documentation.
	(This couldn't easily be written in sh, because sh's read
	command has no notion of pushback.)

util/Mmakefile:
	Add info_to_mdb to the list of targets.

tools/bootcheck:
	Make sure that the tests in tests/debugger are executed with an
	initialization setup that is equivalent to what users will see
	by default.

REORGANIZE TRACING OPTIONS

compiler/globals.m:
compiler/handle_options.m:
compiler/options.m:
compiler/trace.m:
	Reorganize the handling of trace levels around the new options
	--trace-internal, --trace-redo, and --trace-return.

compiler/*.m:
	Use the new ways of getting at trace levels.

tests/hard_coded/typeclasses/Mmakefile:
	s/--trace all/--trace deep/

SUPPORT RETRY

compiler/trace.m:
	After every call to MR_trace(), emit code that checks whether it
	should jump away, and if yes, performs the jump. This is used to
	implement retry. (The debugger cannot execute the jump itself
	because it is in the wrong C stack frame.)

compiler/llds.m:
compiler/continuation_info.m:
compiler/stack_layout.m:
	Modify the data structures that record information about live
	value at program points, to record the identity of each variable.
	This is necessary for the implementation of the restart command,
	since we do not want to confuse two distinct variables just because
	they have the same name. For example, a variable whose name is X
	and number is 5 is now recorded in the name array as "5:X".

	Clean up the data structure a bit, so that we don't have to store
	dummy names for values that are not variables.

compiler/*.m:
	Minor changes to conform to the data structure changes.

runtime/mercury_stack_layout.h:
	Redefine an existing macro to strip away the initial number: prefix
	from the "name" of a variable (keeping its original function on
	changed data), and add a new one to access the raw unstripped data.

runtime/mercury_init.h:
runtime/mercury_wrapper.h:
	Update the prototype of MR_trace_{fake,real}, and the type of the
	global that points to them.

runtime/mercury_layout_util.h:
	Add an extra function, MR_get_register_number, for use by retry.

USE FIXED STACK SLOTS FOR TRACE INFO

compiler/code_gen.m:
compiler/code_info.m:
compiler/live_vars.m:
compiler/trace.m:
	If execution tracing is enabled, reserve the first few stack slots
	to hold the event number of the call event, the call number, the
	call depth, the redo layout structure address (if generating redo
	events) and the from_full flag at the time of call (if we are doing
	shallow tracing). By allocating the first four of these to fixed stack
	slots, the debugger knows where to look for them without having
	to be told. It finds out the location of the fifth, if needed,
	from a new slot in the proc layout structure. (It is not possible
	to allocate all five to fixed stack slots without wasting stack space
	in some cases.)

compiler/trace.m:
	Remove from the call to MR_trace the parameters that are now in fixed
	stack slots, since MR_trace can now look them up itself.

compiler/continuation_info.m:
compiler/stack_layout.m:
	Add an extra field to the proc_layout_info. If the module is shallow
	traced, this field says which stack slot holds the saved value of
	MR_from_full. If it is not shallow traced, this field says that
	there is no such stack slot.

runtime/mercury_stack_layout.h:
	Add macros for accessing the fixed stack slots holding the event
	number of the call event, the call number, the call depth, and,
	at a redo event, the redo layout structure address.

	Support the new field in proc layouts that gives the location of the
	from-full flag (if any).

runtime/mercury_trace_base.[ch]:
trace/mercury_trace.[ch]:
	Remove the call number and call depth arguments from MR_trace
	and its avatars, since this info is now in fixed stack slots
	in every procedure that can call MR_trace. This should reduce
	the size of the executable significantly, since there are lots
	of calls to MR_trace.

runtime/mercury_init.h:
runtime/mercury_wrapper.h:
	Update the prototype of MR_trace_{fake,real}, and the type of the
	global that points to them.

START NUMBERING FRAMEVARS FROM ONE

compiler/code_info.m:
compiler/live_vars.m:
compiler/llds_out.m:
compiler/trace.m:
	Start numbering framevars from 1 internally to the compiler;
	the runtime already starts from 1. This simplifies several tasks.

ADD REDO EVENTS

compiler/trace.m:
compiler/code_gen.m:
	Before the code that executes "succeed()", emit code to push a
	a temp nondet frame whose redoip points to a label in the runtime
	that calls MR_trace for a REDO event and then fails, provided
	--trace-redo is set.

compiler/llds.m:
	Add a new code address constant, do_trace_redo_fail, which stands
	for the address in the trace system to which calls MR_trace for
	the redo event and then fails.

compiler/trace.m:
compiler/llds_out.m:
	Provided we are doing redo tracing, fill in the slot that holds
	the layout information for the REDO event.

compiler/*.m:
	Minor changes to conform to handle the new code address constant.

browser/debugger_interface.m:
	Add redo to trace_port_type.

runtime/mercury_trace_base.[ch]:
	Add a C module containing the code that calls MR_trace for REDO
	events.

ENSURE THAT INPUT ARGUMENTS ARE ALWAYS VISIBLE

compiler/trace.m:
	When generating the set of live variables at internal ports,
	the variables that are in the pre-death set of the goal into which
	we are entering may not be available. However, the variables in the
	pre-death set that are also in the resume vars set will be available,
	so now include info about them in the layout structure for the event.
	Since with tracing the non-clobbered input args are in all resume vars
	sets, this ensures that these input args will be available from all
	internal events.

compiler/code_info.m:
	Export a previously internal predicate (current_resume_point_vars)
	to make this possible.

BUG FIX: WANT RETURN LAYOUTS

compiler/globals.m:
compiler/call_gen.m:
compiler/code_info.m:
compiler/mercury_compile.m:
	Add a new pred globals__want_return_layouts, which says whether the
	compiler should generate layout structures for call returns. This pred
	centralizes the several previous copies of the test. One of those
	copies (the one in call_gen) was faulty, leading to a bug: in the
	presence of execution tracing but the absence of accurate gc,
	information about the variables that are live at the call return
	wasn't being gathered properly.

BUG FIX: #include mercury_trace_base.h

compiler/llds_out.m:
	#include mercury_trace_base.h, not mercury_trace.h, since now
	mercury_trace_base.h defines everything directly accessible from
	modules compiled with tracing.

RECAST MERCURY_TRACE_UTIL AS MERCURY_LAYOUT_UTIL

runtime/mercury_trace_util.[ch]:
runtime/mercury_layout_util.[ch]:
	Rename this module from trace_util to layout_util, since it is also
	used by the native garbage collector. Remove "trace" from the names
	of functions.

	Get rid of the global variable MR_saved_regs, and instead thread
	a pointer to this data structure through the relevant functions
	as an extra argument.

	Add a lot more documentation in the header file.

runtime/Mmakefile:
	Reflect the module rename.

runtime/*.c:
	Refer to the new module.

DELETE EASY-TO-MISUSE MACROS

runtime/mercury_stacks.h:
	Delete the based_framevar and based_detstackvar macros, since their
	continued use can lead to off-by-one errors, and the saved_framevar
	and saved_detstackvar macros, since they are no longer used.

runtime/*.c
	Update any references to any macros removed from mercury_stacks.h.

MISC RUNTIME CHANGES

runtime/mercury_trace_base.[ch]:
trace/mercury_trace*.[ch]:
	Make typedef'd names conform to the naming convention.

	Make MR_trace_call_{seqno,depth} consistently Unsigned, rather than
	sometimes Word and sometimes Unsigned.

FIX BUG: MAKE THE DEBUGGER PRINT TO STDOUT, NOT THE CURRENT STREAM

library/io.m:
	Export to C code the predicates that return the identities and types
	of stdin, stdout and stderr, as well as io__print/[34].

library/std_util.m:
	Export to C code a predicate that returns the type_info for the
	type stdutil:type_info. This type_info is required if C code
	wants to invoke make_permanent on any type_info structure,
	as the debugger does.

runtime/mercury_init.h:
	Add extern declarations for the C functions now exported from io.m.

runtime/mercury_wrapper.[ch]:
	Add new global variables to hold the addresses of these C functions.

runtime/mercury_layout_util.c:
	Use indirect calls through these global variables to print Mercury
	values, instead of lower-level code.

util/mkinit.c:
	Assign the addresses of the functions exported from io.m to the
	global variables defined in mercury_wrapper.h.

BUG FIX: STACK TRACE FUNCTIONS DEPEND ON THE LABEL TABLE

runtime/mercury_stack_trace.c:
	On entry to any of the functions exported from this module,
	ensure that the label table is loaded by calling do_init_modules.
	Without a filled-in label table, the stack trace will not be able to
	find any stack layout info.

BUG FIX: REMOVE BROWSER/*.C

configure.in:
	When removing .c files generated by the C compiler, remove those
	in the browser directory as well as the compiler, library and
	profiler directories.

IMPLEMENT NEW DEBUGGER COMMAND SET

runtime/mercury_stack_trace.[ch]:
	Factor out the code that prints the id of a procedure into a function
	of its own, so that it can also be used from the debugger, ensuring
	appearance commonality.

	Add more documentation in the header file.

trace/mercury_trace_internal.c:
	Implement the proposed command set. Command names are now words,
	and several commands now have options allowing the user to override
	the default print level or strictness of the command, or the
	invocation conditions or action of a break point. Allows control
	over command echoing and the scrolling of sequences of event reports.
	Supports aliases, command file sourcing etc. Implements the retry
	command, using the info in the fixed stack slots.

trace/mercury_trace.[ch]:
	Extend the trace controls to support the new functionalities
	required by the new debugger language, which are print levels,
	variable-strictness commands, a more flexible finish command,
	and the retry command.

	Pass the command structure to MR_trace_event_report, since
	the user can now forcibly terminate the scrolling of reports.

trace/mercury_trace_alias.[ch]:
	New module to manage aliases for the debugger.

trace/mercury_trace_help.[ch]:
	New module to interface to browser/help.m.

trace/mercury_trace_spy.[ch]:
	New module to manage break points. The test of whether an event
	matches a break point is now much more efficient than before.
	The new module also allows several breakpoints with different
	actions and different invocation conditions (e.g. all ports,
	entry port, interface ports or specific (possibly internal) port)
	to be defined on the same procedure.

trace/mercury_trace_tables.[ch]:
	New module to manage a table of the debuggable modules, in which
	each such module is linked to the list of the layouts of all the
	procedures defined in that module. This information allows the
	debugger to turn the name of a predicate/function (possibly together
	with its arity and mode number) into the procedure layout structure
	required by the spy point module. Eventually it may also be useful
	in supplying lists of identifiers for command line completion.

	Modules for which no stack layout information is available will
	not be included in the table, since do_init_modules will not
	register any labels for them in the label table.

trace/Mmakefile:
	Mention the new files.

runtime/mercury_array_macros.h:
	A new file holding macros that can be useful in more than one module.

runtime/Mmakefile:
	Mention the new file.

runtime/mercury_conf.h.in:
	Mention a new configuration macro, MR_CANNOT_USE_STRUCTURE_ASSIGNMENT,
	used by runtime/mercury_array_macros.h.

configure.in:
	Find out whether we need to define MR_CANNOT_USE_STRUCTURE_ASSIGNMENT.

ADD TRACE DEPTH HISTOGRAMS

runtime/mercury_conf_param.h:
	Document MR_TRACE_HISTOGRAM.

runtime/mercury_trace_base.[ch]:
	Define the data structures for the histogram, and print the histogram
	when a traced program exits if MR_TRACE_HISTOGRAM is set.

trace/mercury_trace.[ch]:
	If MR_TRACE_HISTOGRAM is defined, record a count of the number of
	events at each depth. This information can help us evaluate space-time
	tradeoffs.

FACTOR OUT SHELL CODE HANDLING GRADE IMPLICATIONS

scripts/final_grade_options.sh-subr:
	A new file to contain any code that implements implications between
	grade flags; currently implements the implication debug -> use trail.

scripts/mgnuc.in:
scripts/ml.in:
	Replace the code that is now in final_grade_options.sh-subr with
	an inclusion of final_grade_options.sh-subr.

configure.in:
	Handle final_grade_options.sh-subr as {init,parse}_grade_options.sh-subr
	are handled.

SIMPLIFY THE MAINTAINANCE OF CONSISTENCY BETWEEN DEBUGGER CODE AND DOCUMENTATION

doc/Mmakefile:
	Add rules for creating mdb_command_list, a C code fragment
	that can included manually in trace/mercury_trace_internal.c
	to supply the list of valid commands, and mdb_command_test.inp,
	which is a list of invalid invocations of debugger commands,
	which tests whether the help message for such invocations
	can be located as expected.

doc/generate_mdb_command_list:
doc/generate_mdb_command_test:
	Awk scripts to create mdb_command_list and mdb_command_test.inp
	respectively from mdb_doc.

tools/bootcheck:
	Copy mdb_command_test.inp from doc to tests/debugger.

tests/debugger/Mmakefile:
	Add a new test that checks whether we get an internal error, unable
	to locate the right help node, for each invalid command invocation in
	mdb_command_test.inp.

UPDATE TEST CASES

tests/debugger/Mmakefile:
	Reenable queens. Conform to the new set of options.

tests/debugger/*.inp:
tests/debugger/*.exp:
	Update the inputs and expected outputs of the debugger test cases
	to use the new command set and output formats.
1998-10-16 06:20:28 +00:00