Commit Graph

28 Commits

Author SHA1 Message Date
Julien Fischer
459847a064 Move the univ, maybe, pair and unit types from std_util into their own
Estimated hours taken: 18
Branches: main

Move the univ, maybe, pair and unit types from std_util into their own
modules.  std_util still contains the general purpose higher-order programming
constructs.

library/std_util.m:
	Move univ, maybe, pair and unit (plus any other related types
	and procedures) into their own modules.

library/maybe.m:
	New module.  This contains the maybe and maybe_error types and
	the associated procedures.

library/pair.m:
	New module.  This contains the pair type and associated procedures.

library/unit.m:
	New module. This contains the types unit/0 and unit/1.

library/univ.m:
	New module. This contains the univ type and associated procedures.

library/library.m:
	Add the new modules.

library/private_builtin.m:
	Update the declaration of the type_ctor_info struct for univ.

runtime/mercury.h:
	Update the declaration for the type_ctor_info struct for univ.

runtime/mercury_mcpp.h:
runtime/mercury_hlc_types.h:
	Update the definition of MR_Univ.

runtime/mercury_init.h:
	Fix a comment: ML_type_name is now exported from type_desc.m.

compiler/mlds_to_il.m:
	Update the the name of the module that defines univs (which are
	handled specially by the il code generator.)

library/*.m:
compiler/*.m:
browser/*.m:
mdbcomp/*.m:
profiler/*.m:
deep_profiler/*.m:
	Conform to the above changes.  Import the new modules where they
	are needed; don't import std_util where it isn't needed.

	Fix formatting in lots of modules.  Delete duplicate module
	imports.

tests/*:
	Update the test suite to confrom to the above changes.
2006-03-29 08:09:58 +00:00
Zoltan Somogyi
ef55b420fd Remove from std_util.m the predicates that merely call predicates in
Estimated hours taken: 12
Branches: main

Remove from std_util.m the predicates that merely call predicates in
the type_desc, construct and deconstruct modules, to reduce clutter
in std_util.m.

library/std_util.m:
	Remove those predicates from std_util.m.

library/deconstruct.m:
	Add a type we need that was previously defined in std_util.m.

library/construct.m:
	Delete some module qualifications that have now become unnecessary,

browser/browse.m:
browser/browser_info.m:
browser/declarative_tree.m:
browser/dl.m:
browser/help.m:
browser/sized_pretty.m:
browser/term_rep.m:
compiler/bytecode_gen.m:
compiler/llds_out.m:
compiler/mlds_to_il.m:
compiler/mlds_to_managed.m:
library/assoc_list.m:
library/hash_table.m:
library/io.m:
library/pprint.m:
library/private_builtin.m:
library/prolog.m:
library/require.m:
library/rtti_implementation.m:
library/store.m:
library/term.m:
library/term_to_xml.m:
library/version_hash_table.m:
mdbcomp/program_representation.m:
	Import type_desc.m, construct.m and/or deconstruct.m to provide
	definitions of functions or predicates that up till now were in
	std_util.m. Modify the calls if the called function or predicate
	had a slightly different interface in std_util.m.

	Also, convert term_to_xml.m to four-space indentation, and delete
	unnecessary module qualifications in term.m.

tests/debugger/polymorphic_output.{m,inp,exp,exp2}:
tests/hard_coded/copy_pred_2.m:
tests/hard_coded/deconstruct_arg.exp:
tests/hard_coded/deconstruct_arg.exp2:
tests/hard_coded/deconstruct_arg.m:
tests/hard_coded/elim_special_pred.m:
tests/hard_coded/existential_bound_tvar.m:
tests/hard_coded/expand.m:
tests/hard_coded/foreign_type2.m:
tests/hard_coded/higher_order_type_manip.m:
tests/hard_coded/nullary_ho_func.m:
tests/hard_coded/tuple_test.m:
tests/hard_coded/type_ctor_desc.m:
tests/hard_coded/type_qual.m:
tests/hard_coded/write_xml.m:
tests/hard_coded/sub-modules/class.m:
tests/hard_coded/sub-modules/nested.m:
tests/hard_coded/sub-modules/nested2.m:
tests/hard_coded/sub-modules/nested3.m:
tests/hard_coded/sub-modules/parent.m:
tests/hard_coded/sub-modules/parent2.child.m:
tests/hard_coded/typeclasses/existential_rtti.m:
tests/recompilation/type_qual_re.m.1:
cvs update: Updating tests/submodules
cvs update: Updating tests/tabling
cvs update: Updating tests/term
cvs update: Updating tests/tools
cvs update: Updating tests/trailing
cvs update: Updating tests/typeclasses
cvs update: Updating tests/valid
tests/valid/agc_unbound_typevars.m:
tests/valid/agc_unbound_typevars2.m:
tests/valid/agc_unused_in.m:
	Replace references to the deleted predicates in std_util with
	references to the equivalent predicates in type_desc, construct
	and/or deconstruct. In test cases that already tested both the
	functionality in std_util and in the other modules, simply delete
	the part exercising std_util.
2006-03-22 02:56:44 +00:00
Zoltan Somogyi
7822554732 Replace __ with . as the module qualifier everywhere in all the modules
Estimated hours taken: 2
Branches: main

browser/*.m:
	Replace __ with . as the module qualifier everywhere in all the modules
	of the browser directory. Convert the currently tab-indented modules
	to four-space indentation. Delete some unnecessary module
	qualifications. Change some type names and function symbols to avoid
	ambiguities. Replace a bunch of uses of DCGs with state variable
	notation.
2006-03-10 06:31:06 +00:00
Zoltan Somogyi
a77588f6d2 Add two new capabilities to the debugger.
Estimated hours taken: 8
Branches: main

Add two new capabilities to the debugger.

The first capability is the idea of "held variables", variables that the
debugger holds onto even when execution has left the event they came from.
You can hold onto a variable via the mdb command "hold varname heldvarname".
You can suffix the name of the existing variable with a term path, in which
case the new held variable will refer only to the specified part of the term.
Later mdb commands can refer to the held variable by prefixing its name with
a dollar sign. For example, after "hold HeadVar__1^2 x", "$x" will refer to
the term that was the second argument of HeadVar__1 at the program point
at which the "hold" command was executed.

The second capability is the ability to compute the diff of two terms and
express those diffs as the term paths of the function symbols at which the two
terms differ, instead of the line numbers you get by using save_to_file and the
usual Unix diff command. The mdb command is "diff var1 var2". We limit the
number of term paths of difference sites that we display at any one time;
the mdb diff command has options to control this.

NEWS:
	Mention the new capabilities.

doc/user_guide.texi:
	Document the new mdb commands "hold" and "diff", the new mdb command
	"held_vars" which simply lists the names of all the held variables
	(just as "vars" lists the names of all the nonheld variables currently
	accessible), and the concept of held variables.

doc/mdb_categories:
	Update this file for the new mdb commands and concepts.

browser/browse_diff.m:
	This new module implements the diff operation on terms.

browser/mdb.m:
	Add the new module to the list of submodules of the mdb package.

browser/*.m:
	Minor cleanups, such as importing only one module per line; there
	are no algorithmic changes.

trace/mercury_trace_hold_vars.[ch]:
	This new module implements the database of held variables.

trace/Mmakefile:
	Mention the new module.

trace/mercury_trace_internal.c:
	Implement the three new mdb commands.

trace/mercury_trace_vars.[ch]:
	Modify the functions that recognize variable specifications or
	process them to work with held variables as well as variables from
	the current environment. This required some reorganization of the
	internals of this module.

	Provide some a utility function, MR_trace_parse_lookup_var_path,
	for converting a string representing the specification of a term
	(a variable and possibly some path within it) to the type and value
	of that term. Make the utility function this is based upon,
	MR_lookup_unambiguous_var_spec, replace the previous but less capable
	MR_convert_var_spec_to_type_value.

trace/mercury_trace_spy.c:
	Conform to the change in mercury_trace_vars.c.

trace/mercury_trace_util.c:
	Make a utility function more robust.

trace/mercury_trace_alias.c:
	Minor cleanups.

tests/debugger/queens.{inp,exp*}:
	Update this test case to test the debugger's new capabilities.

tests/debugger/completion.{inp,exp*}:
	Update this test case to expect the new mdb commands, and avoid the
	ambiguity between "help" and "held_vars".
2005-07-11 07:30:31 +00:00
Zoltan Somogyi
67895b0b65 Fix the current mixture of __ and . to module qualify module names
Estimated hours taken: 0.2
Branches: main

browser/*.m:
	Fix the current mixture of __ and . to module qualify module names
	by standardizing on the latter.
2005-01-24 07:41:05 +00:00
Zoltan Somogyi
6eaf8db507 Bring these modules up to date with our current coding guidelines:
Estimated hours taken: 0.2
Branches: main

browser/dl.m:
browser/help.m:
browser/parse.m:
browser/util.m:
	Bring these modules up to date with our current coding guidelines:
	using predmode declarations and state variable syntax where relevant.
2004-09-02 04:03:50 +00:00
Julien Fischer
3295904008 Remove the use of the old C interface in the debugger.
Estimated hours taken: 0.1
Branches: main

Remove the use of the old C interface in the debugger.

browser/dl.m:
browser/interactive_query.m:
browser/util.m:
	Use the new foreign language interface rather than
	the old one.
2004-07-16 08:08:29 +00:00
Simon Taylor
1de86c7f9c Move the code in dl.m to create closures into the runtime.
Estimated hours taken: 2
Branches: main

browser/dl.m:
runtime/mercury_ho_call.{c,h}:
	Move the code in dl.m to create closures into the runtime.
	The code is actually clarified by implementing it entirely
	in C, rather than a mish-mash of C and Mercury.

	The rationale for this change is that Aditi needs to be able
	to create closures for dynamically linked procedures.  Just
	copying browser/dl.m as it was into the Aditi sources would
	create an undesirable dependency on Mercury runtime
	implementation details.
2003-09-24 06:33:28 +00:00
Peter Ross
6f1f7f0083 Add Mercury versions of code which has been defined only as
Estimated hours taken: 1
Branches: main

browser/collect_lib.m:
browser/declarative_debugger.m:
browser/declarative_execution.m:
browser/dl.m:
browser/interactive_query.m:
browser/io_action.m:
browser/mdb.m:
browser/name_mangle.m:
browser/util.m:
	Add Mercury versions of code which has been defined only as
	foreign procs so as to allow this directory to compile for
	the non-C backends.
	The Mercury versions just call private_builtin__sorry.
2003-02-06 13:37:08 +00:00
Zoltan Somogyi
048f8357cf Until now, programmers could add `tabled_for_io' annotations to foreign_procs
Estimated hours taken: 12
Branches: main

Until now, programmers could add `tabled_for_io' annotations to foreign_procs
that do I/O, which asks the compiler to make those foreign_procs idempotent,
i.e. ensures that they are performed at most once even in the presence of a
retry operation in the debugger. This change adds a compiler option,
--trace-table-io-require, which generates an error if a foreign_proc that does
I/O does not have this annotation. Specifying this option thus ensures
that all I/O done by the program is idempotent.

In the future, we may want to have this option turned on in all debugging
grades. Until we decide about, the new option is not yet documented.

compiler/options.m:
	Add the new option --trace-table-io-require.

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

compiler/table_gen.m:
	If --trace-table-io-require is enabled, require all I/O primitives
	to have the tabled_for_io annotation.

compiler/mercury_compile.m:
	Pass I/O states to table_gen.m, since it can now generate error
	messages.

trace/mercury_trace_util.h:
trace/mercury_trace_vars.c:
	When calling Mercury code from the trace directory, disable I/O
	tabling, since any I/O actions executed by Mercury code in the browser
	directory (or by library code called from there) should not be tabled,
	not being part of the user program.

	Due to the depth of nesting, make mercury_trace_vars.c use four-space
	indentation.

browser/collect_lib.m:
browser/declarative_debugger.m:
browser/declarative_execution.m:
browser/dl.m:
browser/io_action.m:
browser/mdb.m:
browser/name_mangle.m:
browser/util.m:
compiler/gcc.m:
compiler/mercury_compile.m:
compiler/passes_aux.m:
compiler/process_util.m:
compiler/stack_layout.m:
library/io.m:
library/time.m:
tests/debugger/declarative/tabled_read_decl.m:
	Add a whole lot of tabled_for_io annotations, to enable the compiler to
	bootstrap with --trace-table-io-require enabled.

	In many cases, this required turning old-style pragma c_code into
	pragma foreign_proc. While doing that, I standardized the layouts
	of pragma foreign_procs.

browser/util.m:
	Turn an impure semidet predicate into a pure det predicate with I/O
	states, to allow it to be tabled. Make it return a Mercury bool
	to indicate success or failure.

library/bool.m:
	Add functions that allow C code to get their hands on the constants
	`yes' and `no', for communication with Mercury code.

library/table_builtin.m:
	Add debugging code to the main primitive of I/O tabling. This is
	controlled both by the macro for retry debugging and a boolean global.

library/mercury_trace_base.[ch]:
	Add the boolean global variable to switch the new debugging code in
	table_builtin.m on and off.

library/mercury_trace_internal.c:
	When starting I/O tabling with retry debug enabled, turn on the switch.

tests/debugger/queens.exp3:
	New expected output file that applies when the library is compiled with
	--trace-table-io-require.
2002-07-22 07:13:14 +00:00
Fergus Henderson
ce6c563769 Fix a bug that broke tests/interactive_query in grade
Estimated hours taken: 1
Branches: main

Fix a bug that broke tests/interactive_query in grade
asm_fast.gc.tr.rt.

browser/dl.m:
	Change the code for constructing closures so that it does not
	assume so much about how Mercury types get layed out in memory.
	Previously it was assuming that certain types with only one
	functor will have the same representation as closures, and in
	particular that they will have the same primary tag (zero),
	but that assumption is false with --reserve-tag.
	The fix was to write the code to allocate the closure
	structure in C rather than Mercury.
2002-03-20 15:52:55 +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
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
Simon Taylor
c66cea0665 Add MR_ prefixes to uses of configuration macros.
Estimated hours taken: 2.5
Branches: main

Add MR_ prefixes to uses of configuration macros.
Bootcheck now succeeds with MR_NO_CONF_BACKWARDS_COMPAT.

Mmake.common.in:
	Define MR_NO_CONF_BACKWARDS_COMPAT when checking
	for namespace cleanliness.

RESERVED_MACRO_NAMES:
	Remove the configuration macros.

runtime/mercury_conf_bootstrap.h:
	Remove a duplicate definition of BOXED_FLOAT.

configure.in:
*/*.c:
*/*.h:
*/*.m:
	Add MR_ prefixes.
2002-02-13 09:56:49 +00:00
Tyson Dowd
cdaafbf4b0 Soon foreign_proc will be impure by default unless given a promise_pure
Estimated hours taken: 8
Branches: main

Soon foreign_proc will be impure by default unless given a promise_pure
or promise_semipure attribute.  The syntax has been accepted for some
time, we now add the necessary declarations.

browser/dl.m:
compiler/timestamp.m:
library/*.m:
tests/hard_coded/unused_float_box_test.m:
	Add promise_pure and promise_semipure declarations for foreign_procs.
2002-01-20 07:32:32 +00:00
Tyson Dowd
a355bebec9 Improve the code handling foreign_proc_attribute parsing.
Estimated hours taken: 4
Branches: main

Improve the code handling foreign_proc_attribute parsing.  This is in
anticipation of my next change which will add another attribute.

browser/dl.m:
	Fix an incorrect pragma foreign_code that should have been
	pragma foreign_proc.

compiler/prog_io_pragma.m:
	Improve the error handling when parsing attributes.
	Also improve the code for detecting conflicting attributes (e.g.
	thread_safe and not_thread_safe).
	This fixes an XXX in parse_pragma_foreign_proc_attributes_term
	concerning the lack of error return mechanisms in the code.
2001-07-06 14:39:30 +00:00
Zoltan Somogyi
4da8c2a500 Address Fergus's late review comments on a previous change.
Estimated hours taken: 1.5

Address Fergus's late review comments on a previous change.

browser/dl.m:
	Allocate closures on the heap.

runtime/mercury_heap.h:
	Add a mechanism to allocate C structures on the heap.

runtime/mercury_stacks.h:
runtime/mercury_types.h:
	Move a macro from mercury_stacks.h to mercury_types.h, to give
	mercury_heap.h access to it.
2001-02-21 05:53:43 +00:00
Ina Cheng
dd75b82d26 Add more error messages.
Estimated hours taken: 0.5

Add more error messages.

browser/dl.m:
        Add extra error messages for dl__mercury_sym.
2001-02-13 00:06:12 +00:00
Fergus Henderson
90ad99ebc3 Mention that using copy/2 won't necessarily solve the problems
Estimated hours taken: 0.1
	Mention that using copy/2 won't necessarily solve the problems
	with dl__close.
2001-02-08 12:51:22 +00:00
Fergus Henderson
96b842c0e2 Document the dangers of calling dl__close.
Estimated hours taken: 1

browser/dl.m:
	Document the dangers of calling dl__close.
2001-02-06 09:13:23 +00:00
Fergus Henderson
8b0dcbb231 Various fixes to get the GCC back-end interface to bootstrap.
Estimated hours taken: 20

Various fixes to get the GCC back-end interface to bootstrap.

library/exception.m:
	Define function versions of mercury__exception__builtin_catch_3_p_*.
	This is needed (a) in case we take their address, and (b) for the
	GCC back-end interface, where we can't use C macros, since we're
	compiling to assembler.

browser/dl.m:
browser/util.m:
browser/interactive_query.m:
compiler/stack_layout.m:
	Add #includes for header files needed by these modules.

browser/dl.m:
	Delete an unnecessary nested extern declaration, to avoid
	a warning from `gcc -Wshadow'.

compiler/mlds_to_gcc.m:
	When calling mlds_to_c to process foreign_code, make all
	definitions public, so that the can be used from the assembler
	code that we generate in mlds_to_gcc.

	Don't call mlds_to_c to generate `.c' and `.h' files if the
	module contains only `pragma foreign_decls', not `pragma
	foreign_code', `pragma foreign_proc', or `pragma export'.
	This change is needed to avoid calling mlds_to_c when
	intermodule optimization is enabled and `pragma c_header_code'
	declarations have been read in from the `.opt' file and have
	propagated through to the MLDS.  Calling mlds_to_c when the
	module itself doesn't contain C code breaks things, since
	Mmake won't compile and link in the generated `.c' files, but
	those files contain the definition of the `*__init_type_tables()'
	functions that are referenced by `*_init.c'.

	XXX This is not quite right, since if the module itself contains
	`pragma foreign_decls', the `.h' file might be needed.
	But the Mercury standard library needs intermodule optimization
	enabled for `make install' to work.
	A better fix would be to ignore foreign_decls that were defined
	in other modules, but to call mlds_to_c for foreign_decls
	that were defined in the module that we're compiling.

compiler/modules.m:
	Change the code which decides when to link in extra object files
	for foreign code to reflect the above change to when mlds_to_gcc.m
	invokes mlds_to_c.m.

compiler/mlds_to_c.m:
	When target=asm, i.e. we're compiling to asm, but mlds_to_c.m
	has been invoked to generate C code for a `foreign_code',
	`foreign_proc', or `pragma export' declaration, don't generate
	#include directives for the imported modules, since we may not
	have generated any header file for them.

	XXX This is a bit of a hack; it might sometimes lead to
	problems, since the header files might sometimes be needed.
	But including them unconditionally is definitely wrong,
	since they may not exist, and so this change is needed to get
	the compiler to bootstrap.

compiler/Mmakefile:
	Add a dependency of mercury_compile on $(GCC_BACK_END_LIBS),
	so that we know to relink it if the GCC back-end has changed.
	(That variable is set to empty if we're not linking in the GCC
	back-end, so it won't cause problems when not using the GCC
	back-end.)

library/Mmakefile:
browser/Mmakefile:
compiler/Mmakefile:
	Add an `ss' target, for use by tools/bootcheck.

tools/bootcheck:
	Add `--target asm' option.  If that is set, pass `--target asm'
	to mmake, and build and compare the stage 3 `.s' files rather
	than the `.c' files.

	Also add `--make-opts' option, for passing options to `make'.
	Put `-k' in `--make-opts', not `--mmake-opts', since `-k' is
	an option to `make', not to `mmake'.  This makes a difference
	since although `make' options can be passed to `mmake', any
	options after the first `make' option are assumed to be
	options to `make', not to `mmake'.
2001-01-29 06:47: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
Fergus Henderson
881d0526ef Apply some patches that had been previously applied to
Estimated hours taken: 0.1

browser/dl.m:
	Apply some patches that had been previously applied to
	extras/dynamic_linking/dl.m but not to the copy here.
2001-01-11 05:41:53 +00:00
Zoltan Somogyi
1c8cb6faf2 Get the compiler to bootstrap with -DMR_NO_BACKWARDS_COMPAT.
Estimated hours taken: 2

Get the compiler to bootstrap with -DMR_NO_BACKWARDS_COMPAT.

compiler/c_util.m:
compiler/rtti_out.m:
	Add MR_ prefixes to various type names in generated code.

compiler/*.m:
browser/*.m:
library/*.m:
	Add MR_prefixes to various type and function names in pragma C code.

runtime/*.[ch]:
trace/*.[ch]:
	Add MR_prefixes to various type and function names in
	hand-written code.
2000-10-16 01:34:14 +00:00
Simon Taylor
9ba3b14098 Make all the modules in the browser library sub-modules of
Estimated hours taken: 1

Make all the modules in the browser library sub-modules of
module `mdb', to avoid link errors when users use module names
such as `parse'.

browser/Mmakefile:
browser/browser_library.m:
browser/mdb.m:
	Rename browser_library.m to mdb.m.
	Change `:- import_module' declarations to
	`:- include_module' declarations.

browser/Mmakefile:
	Remove the special case rule for `mer_browser.init' --
	it doesn't work when the file names are not the same
	as the module name. Instead, the default rule for `mdb.init'
	is used and the output is copied to `mer_browser.init'.

browser/.cvsignore:
	Rename header files, etc.

browser/*.m:
	Add a `mdb__' prefix to the names of modules in the browser library
	in `:- module' and `:- import_module' declarations.

trace/*.c:
	Rename the header files for the browser library in
	`#include' statements.

tests/hard_coded/Mmakefile:
tests/hard_coded/parse.m:
tests/hard_coded/parse.exp:
	Test case.
2000-02-04 03:45:53 +00:00
Zoltan Somogyi
acb3438bfd Put MR_ prefixes on uses of make_aligned_string() in order to allow
Estimated hours taken: 0.2

library/*.m:
	Put MR_ prefixes on uses of make_aligned_string() in order to allow
	bootstrap with -DMR_NO_BACKWARDS_COMPAT.
1999-11-15 10:13:08 +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
Fergus Henderson
f1d1041d08 Add support for invoking interactive queries to mdb.
Estimated hours taken: 17

Add support for invoking interactive queries to mdb.

browser/interactive_query.m:
	New module, to implement interactive queries.

browser/dl.m:
browser/name_mangle.m:
	Copy these files from extras/dynamic_linking, since
	they are needed by browser/interactive_query.m.

configure.in:
runtime/mercury_conf.h.in:
	Autodetect the presence of support for dlopen() etc.

browser/dl.m:
	Add #ifdefs so that the code will compile (but report
	an error at runtime) if dlopen() etc. are not supported.

browser/browser_library.m:
	Add interface_query, dl, and name_mangle to the list of
	modules in this library.

trace/mercury_trace_browse.h:
trace/mercury_trace_browse.c:
	Add a new function MR_trace_query() to interface to the ML_query()
	function defined by browser/interfactive_query.m.

trace/mercury_trace_internal.c:
	Add code to implement new commands `query', `cc_query', `io_query',
	and `mmc_options', using the MR_trace_query() function defined by
	trace/mercury_trace_browse.h.

runtime/mercury_grade.h:
	Add code to define MR_GRADE_OPT, so that browser/interactive_query.m
	can use this to invoke mmc with the same grade that the executable
	being debugged was built with.

doc/mdb_categories:
doc/user_guide.texi:
	Document the new commands `query', `cc_query', `io_query',
	and `mmc_options'.
1999-03-05 12:52:34 +00:00