Commit Graph

150 Commits

Author SHA1 Message Date
Zoltan Somogyi
2b559ad054 Move the RTTI-related parts of std_util.m to three new modules in the standard
Estimated hours taken: 8
Branches: main

Move the RTTI-related parts of std_util.m to three new modules in the standard
library, and (in the case of embedded C code) to new modules in the runtime.
The main reason for this is to allow a reorganization of some of the
RTTi-related functionality without breaking backward compatibility. However,
the new arrangement should also be easier to maintain.

Use a separate type_ctor_rep for functions, to distinguish them from predicates
for RTTI code. (At one point, I thought this could avoid the need for the
change to the initialization files mentioned below. It can't, but it is a good
idea in any case.)

library/std_util.m:
	Remove the functionality moved to the new modules, and replace them
	with type equivalences and forwarding code. There are no changes in
	the meanings of the user-visible predicates, with two exceptions.

	- First, the true, equivalence-expanded names of what used to be
	  std_util:type_desc and std_util:type_ctor_desc are now
	  type_desc:type_desc and type_desc: type_ctor_desc.
	- Second, deconstructing a function term now yields
	  "<<function>>" instead of "<<predicate>>".

	The intention is that the RTTI predicates in std_util.m will continue
	to work in a backwards-compatible manner for the near future, i.e. as
	the new modules are updated, the code in std_util will be updated to
	maintain the same functionality, modulo improvements such as avoiding
	unwanted exceptions. When the RTTI functionality in the other modules
	has stabilised, the RTTI predicates in std_util.m should be marked
	obsolete.

	The exported but non-documented functionality of std_util has been
	moved to one of the new modules without forwarding code, with one
	of the moved predicates being turned into the function it should have
	been in the first place.

library/construct.m:
library/deconstruct.m:
library/type_desc.m:
	Three new modules for the code moved from std_util.m.

library/library.m:
compiler/modules.m:
	Record the names of the three new library modules.

runtime/mercury.[ch]:
compiler/mlds_to_il.m:
	Record that type_desc is now in type_desc.m, not std_util.m.

compiler/static_term.m:
	Import the deconstruct module, since we are using its undocumented
	facilities.

runtime/Mmakefile:
	Mention the two new modules.

runtime/mercury_construct.[ch]:
runtime/mercury_type_desc.[ch]:
	Two new modules holding the C functions that used to be in foreign_code
	in std_util, now using MR_ instead of ML_ prefixes, and being more
	consistent about indentation.

runtime/mercury_type_info.h:
	Add a new type_ctor_rep for functions, separate from predicates.
	(It reuses the EQUIV_VAR type_ctor_rep, which hasn't been used
	in ages.)

	Use type_ctor_reps to distinguish between the type_ctor_infos of
	pred/0 and func/0. However, to create higher order typeinfos, we
	still need to know the addresses of the type_ctor_infos for
	pred/0 and func/0, and we still need to know the address of the
	type_ctor_info for tuples to create typeinfos for tuples. Since
	these three type_ctor_infos are defined in the library,
	we cannot access them directly from the runtime. We therefore need
	to access them indirectly in the usual manner, via address_of
	variables initialized by mkinit-generated code.

library/builtin.m:
library/private_builtin.m:
library/rtti_implementation.m:
runtime/mercury.c:
runtime/mercury_mcpp.{h,cpp}:
java/TypeCtorRep.java:
	Updates to accommondate the new function type_ctor_rep.

runtime/mercury_type_info.[ch]:
	Add some functions from foreign_code in std_util that fit in best here.

runtime/mercury_ml_expand_body.h:
runtime/mercury_tabling.h:
runtime/mercury_unify_compare_body.h:
	Delete the code for handling EQUIV_VAR, and add code for handling
	functions.

runtime/mercury_init.h:
runtime/mercury_wrapper.[ch]:
	Add three variables holding the address of the type_ctor_infos
	representing functions, predicates and tuples.

util/mkinit.c:
	Fill in these three variables.

tests/general/accumulator/construct.{m,exp}:
tests/general/accumulator/deconstruct.{m,exp}:
tests/hard_coded/construct.{m,exp}:
	Rename these tests by adding a _test at the ends of their names,
	in order to avoid collisions with the names of the new standard library
	modules. The test cases have not changed, with the exception of the :-
	module declaration of course.

tests/general/accumulator/Mmakefile:
tests/general/accumulator/INTRODUCED:
tests/hard_coded/Mmakefile:
	Record the name changes.

tests/hard_coded/existential_float.exp:
	Updated the expected output to reflect that deconstructions now print
	"<<function>>" instead of "<<predicate>>" when appropriate.

tests/hard_coded/higher_order_type_manip.exp:
	Updated the expected output to reflect the new name of what used to be
	std_util:type_desc.

trace/mercury_trace_browse.c:
trace/mercury_trace_external.c:
trace/mercury_trace_help.c:
	#include type_desc.h instead of std_util.h, since the C functions
	we want to call are now defined there.

trace/mercury_trace_vars.c:
	Update to account for the movement of type_desc from std_util to
	type_desc, and ensure that we don't refer to any type_ctor_infos
	in MLDS grades.
2002-01-30 05:09:13 +00:00
Simon Taylor
966f5be8f9 Quote special characters occurring in the value of
Estimated hours taken: 0.25

util/mkinit.c:
	Quote special characters occurring in the value of
	MR_runtime_flags written to the `_init.c' file.

tests/hard_coded/Mmakefile:
	Test case.
2002-01-22 17:27:56 +00:00
Simon Taylor
dead626652 Allow Mercury runtime options to be set at compile time.
Estimated hours taken: 1.5
Branches: main

Allow Mercury runtime options to be set at compile time.

scripts/parse_ml_options.sh-subr.in:
	Add an initialization option `--runtime-flags'.

runtime/mercury_wrapper.h:
	Add a global variable MR_runtime_flags.

util/mkinit.c:
	Set MR_runtime_flags.

runtime/mercury_wrapper.c:
	Add the value of MR_runtime_flags to the dummy
	command line passed to getopt().

tests/hard_coded/Mmakefile:
	Use `--runtime-flags' rather than MERCURY_OPTIONS.
2002-01-13 10:13:20 +00:00
Simon Taylor
93f2516efb Write the grade in the header comment in the generated `<module>_init.c' file.
Estimated hours taken: 0.25
Branches: main

Write the grade in the header comment in the generated `<module>_init.c' file.
The `<module>_init.c' file contains grade dependent conditional compilation,
so the `<module>_init.o' file must be rebuilt when the grade changes.

util/mkinit.c:
	Add an option `-g' for the grade.
	Add the grade to the header comment.

scripts/c2init.in:
	Pass the grade to mkinit.

scripts/Mmakefile:
scripts/canonical_grade.sh-subr:
	canonical_grade.sh-subr is now used by c2init.
2001-12-18 05:44:17 +00:00
Zoltan Somogyi
fbfd4970df Make the debugging of minimal model tabling easier by providing a mechanism
Estimated hours taken: 32
Branches: main

Make the debugging of minimal model tabling easier by providing a mechanism
to print the contents of the nondet stack, *including* the values of the
variables in its stack frames, even for frames which are not ancestors
of the currently executing call.

runtime/mercury_stack_trace.[ch]:
	Add functions for traversing the nondet stack, and for keeping track of
	through which label control returns to each nondet stack frame, so that
	we know which label's layout structure to interpret the stack frame's
	contents. For some, this will be the return label of a call; for
	others, it will be the label of a resumption point stored in a
	redoip slot.

	Rename an old function to allow the new one to fit into our naming
	scheme.

runtime/mercury_stack_trace.[ch]:
runtime/mercury_tabling.c:
library/exception.m:
trace/mercury_trace.c:
	Add MR_ prefixes to the values of the enum returned by
	MR_stack_walk_step.

	Rename references to the renamed function.

runtime/mercury_conf_param.h:
	Add macros for debugging label names and for debugging retries (which
	needs label names, just as debugging tabling does).

	Add a macro for controlling whether mercury_debug.c prints raw
	addresses as well as offsets (for stack pointers) or label names (for
	labels). The raw pointers can be useful in debugging, but they need to
	be turned off in test cases one wants to be reproducible.

runtime/mercury_label.h:
runtime/mercury_conf_param.h:
	Move the MR_NEED_ENTRY_LABEL_ARRAY and MR_NEED_ENTRY_LABEL_INFO macros
	from mercury_label.h to mercury_conf_param.h, since mercury_debug.c
	also needs them now.

runtime/mercury_debug.c:
	addresses as well as offsets (for stack pointers) or label names (for
	labels). The raw pointers can be useful in debugging, but they need to
	be turned off in test cases one wants to be reproducible.

runtime/mercury_init.h:
runtime/mercury_wrapper.[ch]:
util/mkinit.c:
	Add a global variable pointing to a function through which the stack
	walk code in runtime/mercury_stack_trace.c can invoke code from the
	debugger to print the values of the variables in nondet stack frames
	without breaking the rule prohibiting references to the trace directory
	from the runtime directory.

runtime/mercury_wrapper.c:
	Define the succip of the dummy frame at the bottom of the nondet stack,
	to avoid dereferencing a garbage pointer during detailed stack dumps.

runtime/mercury_goto.h:
	Add a mechanism for always registering the name of a specific label,
	even if label names are not being registered in general. This mechanism
	is intended to be used for labels such as do_fail, which occur
	frequently in nondet stack traces.

runtime/mercury_context.c:
runtime/mercury_engine.c:
runtime/mercury_ho_call.c:
runtime/mercury_trace_base.c:
runtime/mercury_wrapper.c:
	Use this mechanism for the labels defined in these modules.

library/builtin.m:
	Define type_ctor_infos for the pseudotypes representing nondet stack
	frame slots unconditionally, since the debugger may now need them.

trace/mercury_trace.c:
	Add conditionally enabled to code to make debugging retry easier.

trace/mercury_trace_internal.c:
	Add a -d option to the nondet_stack command that causes it to print
	detailed nondet stack dumps, including the names and values of the
	variables in each nondet stack frame.

trace/mercury_trace_vars.c:
	Provide a mechanism for printing the variables of a stack frame
	even when that stack frame is not an ancestor of the current call.

doc/user_guide.texi:
	Document the new option of the nondet_stack command.

tests/debugger/nondet_stack.{m,inp,exp,exp2}:
	A new test case to test "nondet_stack -d".

tests/debugger/Mmakefile:
	Enable the new test case.
2001-12-04 00:44:41 +00:00
Simon Taylor
5544aed7ff Change the list constructor from ./2' to [|]/2'. `./2' will
Estimated hours taken: 3
Branches: main

Change the list constructor from `./2' to `[|]/2'. `./2' will
eventually become the module qualification operator.

library/parser.m:
library/io.m:
library/sparse_bitset.m:
library/std_util.m:
library/term_io.m:
compiler/mercury_to_mercury.m:
compiler/prog_io_dcg.m:
compiler/prog_io_goal.m:
compiler/prog_io_pragma.m:
compiler/prog_io_typeclass.m:
compiler/prog_io_util.m:
browser/interactive_query.m:
extras/moose/grammar.m:
extras/moose/moose.m:
extras/morphine/source/generate_call_site_cov.m:
extras/xml/xml.encoding.m:
samples/muz/higher_order.m:
tests/debugger/declarative/app.m:
tests/dppd/transpose_impl.m:
tests/hard_coded/ground_dd.m:
tests/hard_coded/split_c_files.m:
	Change all references to `./2' to use `[|]/2' instead.

compiler/typecheck.m:
	Handle `./2' as a special case in `report_error_undef_cons'.

	Warn about module list not being imported if `[|]/2' is undefined.

compiler/llds_out.m:
util/mdemangle.c:
profiler/demangle.m:
	Add name conversions for `[|]' (f_cons) and `[]' (f_nil).

NEWS:
doc/reference_manual.texi:
w3/tutorial/lists-n-things.m4:
	Document the changes.

tests/debugger/{,declarative}/*.exp*:
	Update test case results. For some tests the output changed
	because they output lists in the non-pretty format. For others,
	the output changed because the alphabetical ordering of the
	constructors of type `list/1' changed, so the numbering of
	the switch branches in the goal paths changed.
2001-09-25 09:37:12 +00:00
David Jeffery
1500344ad4 Ensure that initialisation code is included if the user explictly
Estimated hours taken: 4

util/mkinit.c:
        Ensure that initialisation code is included if the user explictly
        asks for it.

tests/hard_coded/Mmakefile:
tests/hard_coded/needs_init.m:
tests/hard_coded/needs_init.exp:
        A test case to ensure that initialisation code can be explicitly
        run.
2001-08-21 06:58:53 +00:00
Simon Taylor
aa9ae32225 Improvements for higher-order specialization.
Estimated hours taken: 25
Branches: main

Improvements for higher-order specialization.

WARNING: This changes the order and number of extra arguments
added to specialized versions, including the type-specialized
procedures in the library. Recompile everything.

compiler/higher_order.m:
	Improve the termination check on specialization of recursive
	calls to allow parser combinator programs such as extras/xml
	to be specialized fully. The old check just stopped on any
	recursive specialization.

	Construct constant higher-order and type-info arguments in the goal
	for the specialized version, and remove them from the argument list.
	This increases the chance that terms in the specialized version
	which contain the constant terms will also be constant.

	Attempt to match specialized versions occurring in higher-order
	predicate constants.

	Use record syntax throughout the code.

	Add a version number to the names for type specialized versions
	so that instead of segmentation faults or other program errors
	users get link errors when the argument convention for specialized
	versions changes.

compiler/options.m:
	Add an option `--higher-order-arg-limit' (default 10)
	to control the size of the higher-order arguments for
	which specialization is allowed. Without this,
	extras/xml/xml.parse.chars.m takes too much time
	and memory to compile.

doc/user_guide.texi:
	Document the new option.

tests/hard_coded/Mmakefile:
tests/hard_coded/type_spec_ho_term.m:
tests/hard_coded/type_spec_ho_term.exp:
	Test case.

profiler/demangle.m:
util/mdemangle.c:
tests/misc_tests/mdemangle_test.{inp,exp}:
	Update the documentation and test cases for the symbols
	produced by type specialization.
2001-07-06 14:14:12 +00:00
Fergus Henderson
676d2f260f Fix a bug that broke profiling at `-O5':
Estimated hours taken: 2
Branches: main

profiler/demangle.m:
util/mdemangle.c:
	Fix a bug that broke profiling at `-O5':
	include the __ho<n> sequence number or the __ua<n> mode number
	when demangling procedures created by higher-order specialization
	or unused argument elimination (respectively).
	This avoids a problem where we were demangling distinct symbols
	onto the same mangled name.

tests/misc_tests/mdemangle_test.inp:
tests/misc_tests/mdemangle_test.exp:
	Update to reflect the new demangling algorithm.
2001-06-25 00:58:57 +00:00
Peter Ross
9364b31dcd Define __GNU_LIBRARY__ by including stdio.h before getopt.h.
Estimated hours taken: 0.2
Branches: main

runtime/GETOPT/getopt1.c:
    Define __GNU_LIBRARY__ by including stdio.h before getopt.h.

util/Mmakefile:
    Remove harding coding of __GNU_LIBRARY__ define as we should only
    define this when we are using the GNU version of libc.
2001-06-05 13:25:55 +00:00
Zoltan Somogyi
04e614485d Implement deep profiling; merge the changes on the deep2 branch back
Estimated hours taken: 500
Branches: main

Implement deep profiling; merge the changes on the deep2 branch back
onto the trunk.

The main documentation on the general architecture of the deep profiler
is the deep profiling paper.

doc/user_guide.texi:
	Document how to use the deep profiler.

deep_profiler:
deep_profiler/Mmakefile:
	A new directory holding the deep profiler and its mmakefile.

Mmakefile:
	Add targets for the new directory.

	Add support for removing inappropriate files from directories.

deep_profiler/interface.m:
	The deep profiler consists of two programs: mdprof_cgi.m, which acts
	as a CGI "script", and mdprof_server.m, which implements the server
	process that the CGI script talks to. Interface.m defines the
	interface between them.

script/mdprof.in:
	A shell script template. ../configure uses it to generate mdprof,
	which is a wrapper around mdprof_cgi that tells it how to find
	mdprof_server.

deep_profiler/mdprof_cgi.m:
	The CGI "script" program.

deep_profiler/mdprof_server.m:
	The top level predicates of the server.

deep_profiler/profile.m:
	The main data structures of the server and their operations.

deep_profiler/read_profile.m:
	Code for reading in profiling data files.

deep_profiler/startup.m:
	Code for post-processing the information in profiling data files,
	propagating costs from procedures to their ancestors and performing
	various kinds of summaries.

deep_profiler/server.m:
	Code for responding to requests from the CGI script.

deep_profiler/cliques.m:
	Code to find cliques in graphs.

deep_profiler/array_util.m:
deep_profiler/util.m:
	Utility predicates.

deep_profiler/dense_bitset.m:
	An implementation of (part of) the set ADT with dense bit vectors.

deep_profiler/measurements.m:
	Operations on profiling measurements.

deep_profiler/timeout.m:
	An implementation of a timeout facility.

deep_profiler/conf.m:
	Functions that depend on autoconfigured settings.

configure.in:
	Find out what command to use to find the name of the local host.

	Install deep profiling versions of the standard library along with the
	other profiling versions.

runtime/mercury_conf.h.in:
	Add some macros for deep_profiler/conf.m to use.

library/profiling_builtin.m:
runtime/mercury_deep_call_port_body.h:
runtime/mercury_deep_leave_port_body.h:
runtime/mercury_deep_redo_port_body.h:
	A new library module that implements deep profiling primitives.
	Some of these primitives have many versions, whose common code is
	factor is factored out in three new include files in the runtime.

compiler/deep_profiling.m:
	New module to perform the program transformations described in the
	paper.

compiler/notes/compiler_design.html:
	Document the new compiler module.

compiler/mercury_compiler.m:
	Invoke the new module in deep profiling grades. Allow global static
	data to be generated by deep_profiling.m.

compiler/options.m:
	Add options to turn on deep profiling and (for benchmarking purposes)
	control its implementation.

	Add an optiooption disable tailcall optimization in the LLDS backend,
	to help benchmarking deep profiling.

compiler/jumpopt.m:
compiler/optimize.m:
	Obey the option to disable tailcalls.

compiler/handle_options.m:
	Handle the implications of deep profiling.

compiler/modules.m:
	In deep profiling grades, automatically import profiling_builtin.m.

compiler/prog_util.m:
doc/Makefile:
library/library.m:
	Handle the new builtin module.

compiler/export.m:
	In deep profiling grades, wrap deep profiling code around exported
	procedures to handle the "unscheduled call" aspects of callbacks to
	Mercury from the foreign language.

compiler/higher_order.m:
profiler/demangle.m:
util/demangle.c:
	When creating a name for a higher-order-specialized predicate, include
	the mode number in the name.

compiler/add_trail_ops.m:
compiler/type_util.m:
	Move c_pointer_type from add_trail_ops to type_util, so it can also be
	used by deep_profiling.m.

compiler/hlds_goal.m:
	Add a new goal feature that marks a tail call, for use by
	deep_profiling.m.

compiler/hlds_pred.m:
	Add a new field to proc_info structures for use by deep_profiling.m.

	Add a mechanism for getting proc_ids for procedure clones.

	Remove next_proc_id, an obsolete and unused predicate.

compiler/hlds_data.m:
	Add a new cons_id to refer to the proc_static structure of a procedure.

compiler/bytecode_gen.m:
compiler/code_util.m:
compiler/dependency_graph.m:
compiler/hlds_out.m:
compiler/mercury_to_mercury.m:
compiler/ml_unify_gen.m:
compiler/opt_debug.m:
compiler/prog_rep.m:
compiler/rl_exprn.m:
compiler/switch_util.m:
compiler/unify_gen.m:
	Trivial changes to handle the new cons_id, goal feature and/or
	proc_info argument.

compiler/rtti.m:
	Add a utility predicate for extracting pred_id and proc_id from an
	rtti_proc_label, for use by hlds_out.m

compiler/layout.m:
compiler/layout_out.m:
compiler/llds.m:
compiler/llds_common.m:
	Add support for proc_static and call_site_static structures.

compiler/layout_out.m:
compiler/llds_out.m:
	Add code for the output of proc_static structures.

compiler/code_util.m:
	Make code_util__make_proc_label_from_rtti a function, and export it.

util/mkinit.c:
compiler/llds_out.m:
compiler/layout.m:
compiler/modules.m:
	Add support for a fourth per-module C function, for writing out
	proc_static structures (and the call_site_static structures they
	contains).

	Since proc_static structures can be referred to from LLDS code (and not
	just from other static structures and compiler-generated C code),
	reorganize the declarations of static structures slightly.

	Change the schema for the name of the first per-module C function
	slightly, to make it the addition of the fourth function easier.
	The scheme now is:

		mercury__<modulename>__init
		mercury__<modulename>__init_type_tables
		mercury__<modulename>__init_debugger
		mercury__<modulename>__write_out_proc_statics

	Improve formatting of the generated C code.

library/*.m:
runtime/mercury.c:
runtime/mercury_context.c:
runtime/mercury_engine.c:
runtime/mercury_ho_call.c:
runtime/mercury_tabling.c:
runtime/mercury_trace_base.c:
runtime/mercury_wrapper.c:
trace/mercrury_trace.[ch]:
trace/mercrury_trace_declarative.c:
trace/mercrury_trace_external.c:
trace/mercrury_trace_internal.c:
	Conform to the new scheme for initialization functions for hand-written
	modules.

compiler/mercury_compile.m:
library/benchmarking.m:
runtime/mercury_conf_param.h:
runtime/mercury.h:
runtime/mercury_engine.c:
runtime/mercury_goto.c:
runtime/mercury_grade.h:
runtime/mercury_ho_call.c:
runtime/mercury_label.[ch]:
runtime/mercury_prof.[ch]:
	Add an MR_MPROF_ prefix in front of the C macros used to control the
	old profiler.

compiler/handle_options.m:
runtime/mercury_grade.h:
scripts/canonical_grade.sh-subr:
scripts/init_grade_options.sh-subr:
scripts/parse_grade_options.sh-subr:
	Make deep profiling completely separate from the old profiling system,
	by making the deep profiling grade independent of MR_MPROF_PROFILE_TIME
	and the compiler option --profile-time.

library/array.m:
library/builtin.m:
library/std_util.m:
runtime/mercury_hand_unify_body.h:
runtime/mercury_hand_compare_body.h:
	In deep profiling grades, wrap the deep profiling call, exit, fail
	and redo codes around the bodies of hand-written unification
	and comparison procedures.

	Make the reporting of array bounds violations switchable between
	making them fatal errors, as we currently, and reporting them by
	throwing an exception. Throwing an exception makes debugging code
	using arrays easier, but since exceptions aren't (yet) propagated
	across engine boundaries, we keep the old behaviour as the default;
	the new behaviour is for implementors.

runtime/mercury_deep_profiling_hand.h:
	New file that defines macros for use in Mercury predicates whose
	definition is in hand-written C code.

library/exception.m:
runtime/mercury_exception_catch_body.h:
runtime/mercury_stacks.h:
	In deep profiling grades, wrap the deep profiling call, exit, fail
	and redo codes around the bodies of the various modes of builtin_catch.

	Provide a function that C code can use to throw exceptions.

library/benchmarking.m:
library/exception.m:
library/gc.m:
library/std_util.m:
runtime/mercury_context.[ch]:
runtime/mercury_engine.[ch]:
runtime/mercury_debug.c:
runtime/mercury_deep_copy.c:
runtime/mercury_overflow.h:
runtime/mercury_regs.h:
runtime/mercury_stacks.h:
runtime/mercury_thread.c:
runtime/mercury_wrapper.c:
	Add prefixes to the names of the fields in the engine and context
	structures, to make code using them easier to understand and modify.

runtime/mercury_deep_profiling.[ch]:
	New module containing support functions for deep profiling and
	functions for writing out a deep profiling data file at the end of
	execution.

runtime/mercury_debug.[ch]:
	Add support for debugging deep profiling.

	Add support for watching the value at a given address.

	Make the buffered/unbuffered nature of debugging output controllable
	via the -du option.

	Print register contents only if -dr is specified.

runtime/mercury_goto.h:
runtime/mercury_std.h:
	Use the macros in mercury_std.h instead of defining local variants.

runtime/mercury_goto.h:
runtime/mercury_stack_layout.h:
runtime/mercury_stack_trace.c:
runtime/mercury_tabling.c:
trace/mercury_trace.c:
trace/mercury_trace_declarative.c:
trace/mercury_trace_external.c:
trace/mercury_trace_vars.c:
	Standardize some of the macro names with those used in the debugger
	paper.

runtime/mercury_heap.h:
	Add support for memory profiling with the deep profiler.

runtime/mercury_prof.[ch]:
runtime/mercury_prof_time.[ch]:
	Move the functionality that both the old profiler and the deep profiler
	need into the new module mercury_prof_time. Leave mercury_prof
	containing stuff that is only relevant to the old profiler.

runtime/mercury_prof.[ch]:
runtime/mercury_strerror.[ch]:
	Move the definition of strerror from mercury_prof to its own file.

runtime/mercury_wrapper.[ch]:
	Add support for deep profiling.

	Add suppory for controlling whether debugging output is buffered or
	not.

	Add support for watching the value at a given address.

runtime/Mmakefile:
	Mention all the added files.

scripts/mgnuc.in:
	Add an option for turning on deep profiling.

	Add options for controlling the details of deep profiling. These
	are not documented because they are intended only for benchmarking
	the deep profiler itself, for the paper; they are not for general use.

tools/bootcheck:
	Compile the deep_profiler directory as well as the other directories
	containing Mercury code.

	Turn off the creation of deep profiling data files during bootcheck,
	since all but one of these in each directory will be overwritten
	anyway.

	Add support for turning on --keep-objs by default in a workspace.

tools/speedtest:
	Preserve any deep profiling data files created by the tests.

trace/mercury_trace.c:
	Trap attempts to perform retries in deep profiling grades, since they
	would lead to core dumps otherwise.

util/Mmakefile:
	Avoid compile-time warnings when compiling getopt.

tests/*/Mmakefile:
tests/*/*/Mmakefile:
	In deep profiling grades, switch off the tests that test features
	that don't work with deep profiling, either by design or because
	the combination hasn't been implemented yet.
2001-05-31 06:00:27 +00:00
Zoltan Somogyi
7a6548e935 Avoid compile-time warnings when compiling getopt.
Estimated hours taken: 0.1
Branches: main

util/Mmakefile:
	Avoid compile-time warnings when compiling getopt.
2001-05-22 04:17:33 +00:00
David Overton
ed0cf3d3f0 Remove accidentally resurrected file.
Estimated hours taken: 0.1
Branches: mode-constraints

util/Makefile:
	Remove accidentally resurrected file.
2001-05-15 02:06:45 +00:00
Fergus Henderson
c08e710e54 Fix a bug in c2init where, if an error occurred, it would leave the
Estimated hours taken: 2
Branches: main

Fix a bug in c2init where, if an error occurred, it would leave the
invalid output file around, causing problems the next time you ran Mmake.

This change also eliminates a dependency on using shell redirection (">")
when invoking system commands.

util/mkinit.c:
	Add new option `-o' for specifying the output file name.
	Also, if this option is specified, and there are any errors,
	then remove the output file. This fixes the bug mentioned above.
	Also, consistently use exit(EXIT_FAILURE) rather than exit(1).

scripts/c2init.in:
	Add new option `-o'/`--output', which just passes `-o' to mkinit.

compiler/modules.m:
compiler/mercury_compile.m:
	Use `-o' rather than shell redirection when invoking c2init.
2001-05-08 12:48:34 +00:00
Fergus Henderson
a044202f86 Rename basename' as base_name', to avoid a gcc compiler warning
Estimated hours taken: 0.1
Branches: main, release

util/mkinit.c:
	Rename `basename' as `base_name', to avoid a gcc compiler warning
	with `-Wshadow'.
2001-05-08 05:55:48 +00:00
Mark Brown
ef3dcb0c58 Test for the existence of files in a more portable way.
Estimated hours taken: 0.1
Branches: main, release

util/mkinit.c:
	Test for the existence of files in a more portable way.
2001-04-09 16:38:09 +00:00
Fergus Henderson
4133711e10 Rename getline' as get_line', to avoid name clash with glibc's
Estimated hours taken: 0.1
Branches: main, release

util/mkinit.c:
	Rename `getline' as `get_line', to avoid name clash with glibc's
	`getline'.  This is needed now that mkinit.c is compiled with
	`--no-ansi'.
2001-04-08 13:21:41 +00:00
Fergus Henderson
c4086b66f7 Some changes needed to port Mercury to work on MinGW <http://www.mingw.org>.
Estimated hours taken: 2
Branches: main, release

Some changes needed to port Mercury to work on MinGW <http://www.mingw.org>.

util/Mmakefile:
	Compile mkinit.c with `mgnuc --no-ansi'.
	This is needed to get the declaration of `struct stat' on MinGW.

compiler/modules.m:
	If renaming the `tmp_d' file doesn't work,
	try again after removing the `.d' file.
	This is needed since on MinGW, io__rename_file
	(i.e. rename()) won't remove the target if it already exists.
	Note that the behaviour of io__rename_file is explicitly
	documented as being implementation-dependent in this situation,
	so we need to handle this case here.

library/io.m:
        Delete some MSVC-specific stuff that isn't needed.
2001-04-08 08:59:32 +00:00
Fergus Henderson
e05f2a4780 Add support for using a different C calling convention for the
Estimated hours taken: 16

Add support for using a different C calling convention for the
C functions generated by the MLDS back-end, if you're on x86
and you define MR_USE_REGPARM.  The code do to this uses GNU C's
function attributes extension; it will only work if you have
the latest snapshot versions of gcc.  So MR_USE_REGPARM is
not enabled by default.

compiler/ml_call_gen.m:
	For higher-order calls and class method calls, assign the
	function pointer to a local variable.  This is needed for
	current versions of gcc, since gcc doesn't support function
	attributes on function types in function pointer type casts.

compiler/mlds_to_c.m:
	Output "MR_CALL" in function declarations.
	Also output a reference to MR_GRADE_VAR, like we do for the
	LLDS back-end.

runtime/mercury_std.h:
	Define MR_CALL.  This is a macro that can expand to some
	implementation-specific C extension to specify the
	calling convention used for the MLDS back-end.
	E.g. for gcc, on x86, if MR_USE_REGPARM is defined it
	expands to `__attribute__((__regparm__(3), __stdcall__))'.

runtime/mercury_conf_param.h:
	Document MR_USE_REGPARM.

runtime/mercury_grade.h:
	Encode the setting of MR_USE_REGPARM in the mangled grade name.

runtime/mercury_types.h:
runtime/mercury.h:
runtime/mercury.c:
runtime/mercury_wrapper.h:
runtime/mercury_wrapper.c:
util/mkinit.c:
library/array.m:
library/builtin.m:
library/exception.m:
	Use MR_CALL for functions that should have the
	Mercury calling convention.

runtime/mercury_types.h:
runtime/mercury.h:
	Move the definition of MR_Cont and MR_NestedCont from
	mercury_types.h to mercury.h.  This was needed to avoid a
	cyclic header dependency problem and is also a good idea
	anyway, since MR_Cont and MR_NestedCont are specific to the
	MLDS back-end.
2000-12-03 02:23:03 +00:00
Zoltan Somogyi
ed858e8748 Refer to do_init_modules with its MR_ prefixed name.
Estimated hours taken: 0.1

util/mkinit.c:
	Refer to do_init_modules with its MR_ prefixed name.
2000-11-23 06:33:25 +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
Zoltan Somogyi
9b60e6c3bf Add .nocopyright files to get rid of warning messages during commits.
Estimated hours taken: 0.1

*/.nocopyright:
	Add .nocopyright files to get rid of warning messages during commits.
2000-11-22 00:07:50 +00:00
Simon Taylor
b6f8e7d618 Implement demangling of predicate names introduced by type
Estimated hours taken: 2

Implement demangling of predicate names introduced by type
specialization. This still doesn't work when the compiler adds
multiple prefixes to a predicate name.

profiler/demangle.m:
util/mdemangle.c:
	When demangling of a compiler-generated predicate name fails, just
	treat the predicate as an ordinary predicate. This is a temporary
	work-around for the problem of demangling names with multiple
	compiler-generated prefixes.

	Change the printing of names in the profiler to match those generated
	by the compiler (module:'p'/3 becomse `module:p/3').

tests/misc_tests/mdemangle_test.inp:
tests/misc_tests/mdemangle_test.exp:
	Test case.
2000-11-11 13:37:02 +00:00
Zoltan Somogyi
38a9f649e5 Undo Pete's temporary workaround, since the real fix works.
Estimated hours taken: 0.1

util/mkinit.c:
	Undo Pete's temporary workaround, since the real fix works.
2000-11-06 05:10:01 +00:00
Peter Ross
c8c6c51206 Zoltans recent change which provides a register of all the types defined
Estimated hours taken: 0.5

Zoltans recent change which provides a register of all the types defined
in the program breaks the MLDS backend as the new init functions are not
generated by the MLDS backend.

util/mkinit.c:
    Protect calls to the new init functions inside
    #ifndef MR_HIGHLEVEL_CODE.
2000-11-02 11:05:29 +00:00
Zoltan Somogyi
2ac218f9a7 This is part 2 of a change that provides a register of all the types defined
Estimated hours taken: 4

This is part 2 of a change that provides a register of all the types defined
in the program.

util/mkinit.c:
	After part 1 of this change, each compiler-generated module has three
	initialization functions: the old one (to register label addresses
	etc), one to register type_ctor_infos, and one to register module
	layouts for the debugger. However, only the first was invoked from
	the mkinit generated <mainmodule>_init.c file.

	This change invokes the other two as well. One complication is that
	hand-written "modules" do not have the two new kinds of initialization
	functions, so only their first initialization function should be
	called. We do this by requiring those "modules" to have one of two
	specific forms: an initial prefix of either sys_init or
	mercury_sys_init.

scripts/c2init.in:
	Rerrange the mechanism we use to allow the overriding of the locations
	of the init files to be passed to mkinit. The previous mechanism used
	a single environment variable, MERCURY_MOD_LIB_MODS, to hold the names
	of these init files. While the default setting of this variable was
	conditional on whether the --trace option was given to c2init
	(including the init file for the browser only with --trace),
	there was no way to override the default value in a similarly
	conditional manner. This is now a problem, because including the
	browser init file in the list of init files passed to mkinit will
	cause mkinit to emit code that causes the browser's modules to be
	linked in, without also linking in the libraries (e.g. -ldl) on which
	the browser depends. The reason why this hasn't bitten us earlier
	is that the code that drags in the browser was #ifdef'ed out
	in the first initialization function; the reason why it would
	bite us now is that it is *not* #ifdef'ed out in the second
	initialization function (the one that register type_ctor_infos).

	The new mechanism uses two environment variables, MERCURY_MOD_LIB_MODS
	and MERCURY_TRACE_LIB_MODS, with the first normally containing
	the filenames of the init files of the runtime and library directories
	and the second the filename of the init file of the browser directory.
	The value of the second environment variable is passed to mkinit
	only if c2init is invoked with the --trace flag.

	There is also a new environment variable MERCURY_TRACE_LIB_DIR,
	which has a role parallel to MERCURY_MOD_LIB_DIR.

compiler/Mmakefile:
profiler/Mmakefile:
tools/bootcheck:
	Specify the filename of the browser init file in
	MERCURY_TRACE_LIB_MODS.

library/array.m:
library/builtin.m:
library/private_builtin.m:
library/std_util.m:
	Add code to initialization functions to register the type_ctor_infos
	of hand-defined types.

	Note that this code is in the usual initialization function, the one
	called by do_init_modules(). Putting this code in a separate
	initialization function that is called by do_init_modules_type_tables()
	would require complicating mkinit.c considerably.

runtime/mercury_wrapper.c:
	Make do_init_modules_type_tables() call do_init_modules(), so that
	calling do_init_modules_type_tables() guarantees the registration
	of all the type_ctor_infos in the program, including the hand-defined
	ones.

runtime/mercury_context.c:
	Make the name of the handwritten module follow the convention now
	required by mkinit.
2000-10-31 07:54:11 +00:00
Zoltan Somogyi
257d26cc60 Add a tags target.
Estimated hours taken: 0.1

util/Mmakefile:
	Add a tags target.
2000-10-10 03:49:49 +00:00
Simon Taylor
46a8da81cb Implement builtin tuple types, similar to those in Haskell.
Estimated hours taken: 30

Implement builtin tuple types, similar to those in Haskell.

Tuples are constructed and deconstructed using
the syntax X = {Arg1, Arg2, ...}.
Tuples have type `{Arg1, Arg2, ...}'.

Unary tuples (X = {Arg}) do work, unlike in Haskell. The rationale
for this is that it is useful to be able to construct unary tuples
to be passed to a polymorphic predicate which uses std_util__deconstruct
to deal with a tuple of any arity. Since this is probably the only
use for unary tuples, it's not really worth the effort of treating
them as no_tag types, so we don't.

The type-infos for tuples have the same structure as for higher-order
types. There is a single type_ctor_info for tuples, and the arity
is placed before the argument type_infos.

library/parser.m:
	Change the way '{}/N' terms are parsed, so that the parsed
	representation is consistent with the way other functors
	are represented (previously the arguments were left as
	unparsed ','/2 terms). This avoids special case code
	in prog_io__parse_qualified_term, term__term_to_type
	and term__type_to_term.

compiler/prog_io_dcg.m:
compiler/prog_io_util.m:
	Handle the new structure of '{}/N' terms when parsing DCG escapes
	by converting the argument list back into a single ','/2 term.

compiler/module_qual.m:
	Treat tuples as a builtin type.

compiler/typecheck.m:
	Typecheck tuple constructors.

compiler/mode_util.m:
	Propagate types into tuple bound insts.

compiler/type_util.m:
	Add type_is_tuple/2 and type_id_is_tuple/1 to identify tuple types.
	Add tuples to the list of types which are not atomic types.

	Handle tuple types in `type_constructors' and
	`get_cons_id_arg_types' and `switch_type_num_functors'.

compiler/tabling.m:
	Handle tabling of tuples.

compiler/term_util.m:
	Handle tuples in the code to compute functor norms.

compiler/magic_util.m:
compiler/rl.m:
compiler/rl_key.m:
	Handle tuple types in the Aditi back end.

compiler/mercury_to_mercury.m:
library/io.m:
library/term_io.m:
	Handle output of '{}/N' terms.

compiler/higher_order.m:
compiler/simplify.m:
	Don't specialize complicated unifications of tuple
	types into calls to a specific unification procedure --
	even if the procedure were implemented, it probably
	wouldn't be that much more efficient.

compiler/unify_proc.m:
	Generate unification procedures for complicated unifications
	of tuples (other than in-in unifications). These are generated
	lazily as required.

compiler/make_hlds.m:
	Export add_special_pred for use by unify_proc.m.

compiler/polymorphism.m:
	Export polymorphism__process_pred for use by unify_proc.m.

compiler/bytecode_gen.m:
compiler/code_util.m:
compiler/ml_code_util.m:
	Handle unify procedure names and tags for tuple types.

compiler/mlds_to_c.m:
	Output tuple types as MR_Tuple.

compiler/ml_unify_gen.m:
	Compute the field types for tuples.

compiler/polymorphism.m:
compiler/pseudo_type_info.m:
	Treat tuple type_infos in a similar way to higher-order type_infos.

compiler/hlds_data.m:
	Document how cons_ids for tuple types are represented.

compiler/switch_gen.m:
compiler/table_gen.m:
	Add tuple types to switches on type_util__builtin_type.

compiler/llds_out.m:
util/mdemangle.c:
profiler/demangle.m:
	Transform items named "{}" to "f_tuple" when mangling symbols.

library/builtin.m:
	Define the type_ctor_info used for tuples.

library/private_builtin.m:
	Add `builtin_unify_tuple/2' and `builtin_compare_tuple/3',
	both of which abort. All comparisons and in-in unifications
	of tuples are performed by the generic unification functions
	in runtime/mercury_ho_call.c and runtime/mercury.c.

library/std_util.m:
	Implement the various RTTI functions for tuples.

	Encode tuple `TypeCtorDesc's in a similar way to that
	used for higher-order types. This has the consequence that the limit
	on the arity of higher-order types is now MAX_VIRTUAL_REG,
	rather than 2*MAX_VIRTUAL_REG.

	Avoid calling MR_GC_free for the type-info vector returned
	from ML_expand() for tuples because unlike the vectors
	for du types, it is not copied.

runtime/mercury_type_info.h:
	Add macros for extracting fields from tuple type-infos.
	These just call the macros for extracting fields from higher-order
	type-infos.

	Add a macro MR_type_ctor_rep_is_variable_arity(), which
	returns TRUE for tuples and higher-order types.

	The distinction between higher-order and first-order types
	is now misnamed -- the distinction is really between fixed arity
	types and builtin variable arity types. I'm not sure whether
	it's worth renaming everything.

runtime/mercury.h:
runtime/mercury.c:
	Define unification and comparison of tuples in
	high-level code grades.

runtime/mercury_deep_copy_body.h:
runtime/mercury_make_type_info_body.h:
runtime/mercury_tabling.c:
runtime/mercury_unify_compare_body.h:
	Handle tuple types in code which traverses data using RTTI.

tests/hard_coded/construct.{m,exp}:
tests/hard_coded/expand.{m,exp}:
	Test RTTI functions from std_util.m applied to tuples.

tests/hard_coded/tuple_test.{m,exp}:
	Test unification, comparison, term_to_type etc. applied to tuples.

tests/hard_coded/deep_copy.{m,exp}:
	Test deep copy of tuples.

tests/hard_coded/typeclasses/tuple_instance.{m,exp}:
	Test instance declarations for tuples.

tests/tabling/expand_tuple.{m,exp}:
	Test tabling of tuples.

tests/hard_coded/write.m:
	Add some module qualifications for code which uses
	`{}/1' constructors which are not tuples.

tests/invalid/errors2.{m,err_exp,err_exp2}:
	Test handling of tuples in type errors messages.

NEWS:
doc/reference_manual.texi:
w3/news/newsdb.inc:
	Document tuples.

doc/transition_guide.texi:
	Document the change to the parsing of '{}/N' terms.
2000-09-18 11:53:19 +00:00
Peter Ross
7d946d77f4 Build the hlc.par.gc grade using MSVC.
Estimated hours taken: 32

Build the hlc.par.gc grade using MSVC.

boehm_gc/NT_MAKEFILE:
	Seperate the rules for building libpar_gc.lib and libgc.lib as
	they use different makefiles.
	Use gc.mak to build libpar_gc.dll
	Note the thread safe garbage collector must be built as a dll
	according to the README.win32 documentation.

boehm_gc/gc.mak:
	Change the name from gc.dll to libpar_gc.dll
	This gets built in the Release directory.

boehm_gc/Mmakefile:
	Remove the Release directory as well.

scripts/mgnuc.in:
scripts/ml.in:
	Pass the appropiate flags to the c compiler and the linker to
	build in hlc.par.gc grade.

util/mkinit.c:
	Delete a duplicate reference to GC_stackbottom.
2000-09-06 11:04:44 +00:00
Mark Brown
7d66a930c7 Allow multiple browser commands on one line, separated by semicolons.
Estimated hours taken: 3

Allow multiple browser commands on one line, separated by semicolons.

trace/mercury_trace_internal.c:
trace/mercury_trace_internal.h:
	Separate the code for splitting lines and checking for EOF into
	a new function, MR_trace_get_command.

browser/parse.m:
	Call util__trace_get_command to read each command.

browser/util.m:
	Implement util__trace_get_command, which calls the function
	in the trace directory via an indirect pointer.

runtime/mercury_init.h:
runtime/mercury_wrapper.c:
runtime/mercury_wrapper.h:
util/mkinit.c:
	Set up the indirect pointer to the new function.

tests/debugger/browser_test.inp:
tests/debugger/browser_test.exp:
tests/debugger/browser_test.exp2:
	Test the new feature.
2000-08-26 04:34:36 +00:00
Peter Ross
83cae0d2d0 When generating the .dv and .dep files use autoconfed settings for
Estimated hours taken: 8

When generating the .dv and .dep files use autoconfed settings for
such things as: object and library file extensions, and how to create a
library.  Change the compiler Mmakefiles to handle files with the new
extensions.

compiler/modules.m:
    When generating the '.dv' and '.dep' files use '.$O' and '.$A'
    instead of '.o' and '.a'.  Use $EXT_FOR_EXE when generating the
    realclean target, as you need to pass the full file name to rm.
    Use $AR_LIBFILE_OPT when creating libraries.

scripts/Mmake.vars.in:
    Set the value EXT_FOR_EXE, which is the extension which must be
    placed on executables.

Mmakefile:
library/Mmakefile:
runtime/Mmakefile:
scripts/Mmake.rules:
tools/bootcheck:
trace/Mmakefile:
    Use '.$O' for '.o' and '.$A' for '.a'.

util/Mmakefile:
    You need to remove PROGFILENAMES not PROGS, as PROGFILENAMES
    includes the executable extension.
2000-06-22 08:50:27 +00:00
Peter Ross
a68df3d95f Allow compilation of the mercury compiler *ONLY* in the grade hlc.gc
Estimated hours taken: 40

Allow compilation of the mercury compiler *ONLY* in the grade hlc.gc
using the Microsoft Visual C++ compiler (MSVC).  This is still
work-in-progress.

configure.in:
    Test to see whether or not we are using the Microsoft compiler.
    Don't fail if we can't interpret return values from system.

boehm_gc/Mmakefile:
    Use NT_MAKEFILE if we are using MSVC.

boehm_gc/NT_MAKEFILE:
    Apply the the changes to boehm_gc/Makefile to this file.

browser/Mmakefile:
library/Mmakefile:
runtime/Mmakefile:
trace/Mmakefile:
    Use the correct executable to create libraries.
    Use AR_LIBFILE_OPT to name the library.

compiler/llds_out.m:
    Export output_c_file_intro_and_grade so that the correct header can
    be placed at the start of each C file.

compiler/mlds_to_c.m:
    Output the header at the start of each C file, so that configure
    doesn't delete the file when checking the compatability with
    the configured settings.
    When initializing empty arrays place a dummy entry in the array, so
    that the MSVC compiler generates a symbol for that array.

compiler/passes_aux.m:
    Add invoke_shell_command.  This predicate wraps commands with
    a bash -c 'command ' when shell scripts aren't supported by the
    target system.

compiler/mercury_compile.m:
compiler/modules.m:
    Use invoke_shell_command instead of invoke_system_command for shell
    scripts.

library/io.m:
    Call _unlink in io_rename_file, when compiling with MSVC.


runtime/mercury_wrapper.c:
    Initialise MR_runqueue_head so that the segment containing this
    variable is registered with the garbage collector.  This stops
    intermittent failures of the GC_is_visible() test.

runtime/mercury_conf.h.in:
    Define MR_WIN32 when we are using MSVC.

runtime/mercury_memory.c:
runtime/mercury_memory_handlers.c:
runtime/mercury_memory_zones.c:
runtime/mercury_prof.c:
runtime/mercury_reg_workarounds.c:
runtime/mercury_reg_workarounds.h:
runtime/mercury_signal.c:
runtime/mercury_timing.c:
runtime/mercury_timing.h:
runtime/mercury_trace_base.c:
util/mkinit.c:
    Only include unistd.h and sys/times.h when they exist.
    MSVC doesn't have SIGBUS so #ifdef sections which refer to it.

scripts/Mmake.rules:
    Use /Fo instead of -o to generate .o files if compiling with MSVC.

scripts/Mmake.vars.in:
    Define AR to use the autoconfed executable for linking.

scripts/mgnuc.in:
    Only add option -Wno-uninitialized if we are using gcc.

util/Mmakefile:
    Explicitly locate the getopt src, and use it in compiling the
    utilities.
2000-06-08 07:59:13 +00:00
Fergus Henderson
aa3f54f73f More work on the MLDS back-end.
Estimated hours taken: 6

More work on the MLDS back-end.

runtime/mercury.c:
	Fix a cut-and-paste bug in the code for compare/3:
	I forgot to add `break' after each case of a `switch' statement.

library/builtin.m:
library/private_builtin.m:
	Replace the hand-coded definition of builtin_{compare,unify}_pred
	in builtin.m with ordinary Mercury clauses in private_builtin.m.
	This ensures that it works with the MLDS back-end.
	(It also means that these procedures call error/1 rather than
	MR_fatal_error(), so you get an exception rather than a
	program abort.)

runtime/mercury.h:
runtime/mercury.c:
	Add declarations and definitions of the compare and unify
	procedures for the builtin types.  (For some types,
	the definitions here are still just stubs.)

runtime/mercury.h:
runtime/mercury.c:
runtime/mercury_init.h:
	Add some hacks to work-around the current lack of support
	for `pragma export'.

runtime/mercury_type_info.c:
	If MR_HIGHLEVEL_CODE is defined, don't #include "mercury_imp.h",
	since it is not needed.

runtime/mercury_wrapper.c:
runtime/mercury_wrapper.h:
runtime/mercury_init.h:
util/mkinit.c:
scripts/c2init.in:
	Add support for the MLDS back-end to the program start-up
	code.
2000-05-08 16:11:22 +00:00
Fergus Henderson
15674493e3 Add a missing `const', to avoid a warning with gcc -Wwrite-string.
Estimated hours taken: 0.1

util/mkinit.c:
	Add a missing `const', to avoid a warning with gcc -Wwrite-string.
2000-02-12 15:53:49 +00:00
Simon Taylor
11a9d6fa17 Remove the dependency of the Aditi interface library in
Estimated hours taken: 1

Remove the dependency of the Aditi interface library in
extras/aditi/aditi.m on code in the automatically generated
C init file.

runtime/mercury_wrapper.h:
	Add a global variable `MR_address_of_do_load_aditi_rl_code'.

	Add a function `MR_load_aditi_rl_code', which calls
	the function pointed to by `MR_address_of_do_load_aditi_rl_code',
	aborting if it is not set.

runtime/mercury_init.h:
	Remove the declaration for `mercury__load_aditi_rl_code()' --
	that is now local to the `<module>_init.c' file.

util/mkinit.c:
	Rename `mercury__load_aditi_rl_code' to `MR_do_load_aditi_rl_code()'
	in the `<module>_init.c' file, and add a static prototype for it.

	Add a statement to `mercury_init()' to fill in the
	`MR_address_of_do_load_aditi_rl_code' variable.

extras/aditi/aditi.m:
	Rename `mercury__load_aditi_rl_code()' to `MR_load_aditi_rl_code()'.
2000-02-08 02:08:08 +00:00
Zoltan Somogyi
a98b8fd0a5 Fix a trivial mistake in my previous trivial diff.
Estimated hours taken: 0.1

util/mkinit.c:
	Fix a trivial mistake in my previous trivial diff.
1999-12-22 03:41:58 +00:00
Zoltan Somogyi
46e3aa26f5 Simplify the conditional code for setting up the debugger-relevant
Estimated hours taken: 0.1

util/mkinit.c:
	Simplify the conditional code for setting up the debugger-relevant
	globals, testing each condition just once. This is to make it clear
	where future insertions into this list should go.
1999-12-21 06:41:28 +00:00
Fergus Henderson
c9b940ed69 Add support for catching interrupts (i.e. SIGINT signals,
Estimated hours taken: 2

Add support for catching interrupts (i.e. SIGINT signals,
normally generated by control-C) in the debugger.

runtime/mercury_wrapper.h:
runtime/mercury_wrapper.c:
	Add declaration and definition of a new variable
	MR_address_of_trace_interrupt_handler.

runtime/mercury_trace_base.c:
	Add code to MR_trace_start() to call MR_setup_signal() to install
	the function pointed to by MR_address_of_trace_interrupt_handler
	as the signal handler for SIGINT signals.

runtime/mercury_init.h:
	Add declaration for MR_trace_interrupt_handler().

util/mkinit.c:
	Add code to initialize MR_address_of_trace_interrupt_handler
	to point to MR_trace_interrupt_handler().

trace/mercury_trace.c:
	Add MR_trace_interrupt(), which is like MR_trace_real(), except
	that it enters the interactive debugger unconditionally.
	Add MR_trace_interrupt_handler(); this function just sets
	MR_trace_func_ptr to MR_trace_interrupt(), so that a SIGINT
	will cause the interactive debugger to be entered at the
	next call to MR_trace().

trace/mercury_trace_internal.h:
trace/mercury_trace_internal.c:
	Add MR_trace_interrupt_message(), which prints a message
	indicating that the debugger caught an interrupt.
1999-12-20 14:04:12 +00:00
Mark Brown
9179be5e15 Implement a new data structure for declarative debugging.
Estimated hours taken: 160

Implement a new data structure for declarative debugging.  The
major differences between this and the old implementation are:
	- The data structure is implemented in Mercury.  The definition
	  of the type, and procedures for constructing values of that
	  type, have been moved from trace/mercury_trace_declarative.{c,h}
	  to browser/declarative_execution.m (which is a new module).
	- The front end no longer needs to call the back end via an
	  indirect pointer---the front end does not call the back end at
	  all.
	- The data structure is not specifically for wrong answer
	  analysis, it is intended to be used for any sort of analysis.
	- The data structure represents execution at a lower level---the
	  new front end defines a more abstract view in terms of this
	  data structure.

Implement a test harness for debugging the front end code.  This allows
the front end to run as a stand-alone program, which can then be
debugged using `mdb'.

The code in the front end does not currently handle the new structure
very nicely.  This is because that code is about to undergo some major
structural changes, so there is little point cleaning it up now.
Consequently:
	- Some of the code in the front end is incorrect (eg. the
	  user interface does not print missing answer nodes
	  properly).
	- The tests have not been reinstated.
These things will be fixed in subsequent changes.

Likewise the compiler still reserves two stack slots, even though
only one is required.  After this change the algorithm should be able
to get away with using no stack slots, so modifications to the compiler
will be postponed until then.

browser/declarative_execution.m:
	New module.  Implement the execution_tree typeclass, which
	represents the execution of a Mercury program.  Implement
	two instances of this typeclass, one for normal use and one for
	testing purposes.

browser/declarative_test.m:
	New module.  A test harness that can be compiled as a
	stand-alone program, enabling the front end to be debugged.

trace/mercury_trace_declarative.c:
trace/mercury_trace_declarative.h:
	- Remove the definition of the old data structure.
	- Add some macros which enable the new Mercury data structure
	  to be destructively updated by C code.
	- Change the interface to this module so that it reflects more
	  general diagnosis, not just wrong answer analysis.
	- Implement the new algorithm.
	- Call an alternative front end if in test mode.
	- Update comments.

trace/mercury_trace_internal.h:
	Add a new mode for debugging the declarative debugger.

trace/mercury_trace_internal.c:
	Change the command from `dd_wrong' to `dd', since it is not
	specifically for wrong answer analysis.  Add a new command
	`dd_dd' which calls the alternative front end used for testing.

runtime/mercury_init.h:
runtime/mercury_wrapper.c:
runtime/mercury_wrapper.h:
util/mkinit.c:
	Remove any reference to `MR_edt_root_node', since it is no
	longer used.

browser/declarative_debugger.m:
	- Add a case for missing answer nodes to `edt_node'.
	- Change the `evaluation_tree' typeclass into `mercury_edt'
	  typeclass.  This is to make it more distinct from the new
	  `execution_tree' typeclass, which is a lower level concept.
	- New interface to the diagnoser: types `diagnoser_response'
	  and `diagnoser_state', and procedure `diagnosis'.
	- Define an instance of `mercury_edt' from an instance of
	  `execution_tree'.
	- Updates to the analyser to get it to compile---further changes
	  will be forthcoming.

browser/declarative_user.m:
	- Updates to the user interface to get it to compile---further
	  changes will be forthcoming.

browser/browser_library.m:
	Import the new module (declarative_execution.m).

browser/debugger_interface.m:
browser/util.m:
	Move the definitions of trace_port_type and goal_path_string
	to browser/util.m, since they are now used by more than just
	the external debugger.

browser/Mmakefile:
	Add the test harness as a `depend' target.

browser/browse_test.m:
	Use the correct interface to the browser.
1999-11-30 00:05:08 +00:00
Fergus Henderson
0d8d4fc163 Improve the mdb help.
Estimated hours taken: 1

Improve the mdb help.

util/info_to_mdb.c:
	Update to reflect the fact that concept headings are now
	formatted with @emph rather than @var.
	My previous change to fix the formatting of the headings
	in the manual unfortunately broke the mdb help.

doc/mdb_categories:
	List the names of the documented debugger concepts,
	so that the user knows what documentation is available.
	Mention the `delete' command in the list of breakpoint commands.
	Add "For help on the `help' command, type `help help help'"
	to the help for the "help" category.
1999-11-18 13:33:31 +00:00
Simon Taylor
3bbb2d8bf5 In the code to handle embedded Aditi queries, add a #include
Estimated hours taken: 0.1

util/mkinit.c:
	In the code to handle embedded Aditi queries, add a #include
	for aditi_api_config.h, which sets up some macros that
	aditi_clnt.h expects to be defined.
1999-11-15 04:14:39 +00:00
Fergus Henderson
8df9f27c5b Fix a bug that caused an undefined symbol error when compiling modules
Estimated hours taken: 0.75

Fix a bug that caused an undefined symbol error when compiling modules
whose name started with `f_' in certain grades, e.g. --debug.

util/mkinit.c:
	Ensure that the module names in `mercury__<module>__init' symbols
	are properly mangled according to the same algorithm used by
	llds_out__name_mangle/2 in compiler/llds_out.m.
	For simplicity, I didn't bother to handle the case where the
	module name contains special symbols; it just checks for that
	case and aborts.  But I added new code to handle the case
	where the module name starts with `f_'.
1999-10-29 06:21:10 +00:00
Fergus Henderson
17dc28cf0c Improve the error messages for linking objects compiled in different grades.
Estimated hours taken: 1

Improve the error messages for linking objects compiled in different grades.

util/mdemangle.c:
	Check for `MR_grade_*' and `MR_runtime_grade', and if they are
	found, print out a message explaining the cause of the problem.
	But only do that if a new option `--explain-link-errors' is set,
	so that this message will only come out when you get a message
	from the linker, not when you invoke mdemangle manually e.g.
	via `nm *.o | mdemangle'.

scripts/ml.in:
	Pass the new `--explain-link-errors' option to mdemangle.
1999-09-30 21:33:14 +00:00
Fergus Henderson
6ef4ab36d8 Ensure that we include a reference to the grade variable,
Estimated hours taken: 0.5

util/mkinit.c:
	Ensure that we include a reference to the grade variable,
	so that we will catch attempts to files compiled in different
	grades.

runtime/mercury_grade.h:
	Include mercury_tags.h, since this file uses the TAGBITS macro.
1999-09-23 11:25:26 +00:00
Fergus Henderson
98b0afa001 Use clean_local' instead of clean' and `realclean_local' instead
Estimated hours taken: 0.75

Mmakefile:
*/Mmakefile:
*/*/Mmakefile:
*/*/*/Mmakefile:
	Use `clean_local' instead of `clean' and `realclean_local' instead
	of `realclean' where appropriate.  This is necessary now that
	`realclean' does not depend on `clean'.
1999-09-16 04:46:31 +00:00
Warwick Harvey
a7b1401531 Allow the user to conveniently use Mercury libraries installed in
Estimated hours taken: 70

Allow the user to conveniently use Mercury libraries installed in
non-standard places, by specifying the variables `EXTRA_LIBRARIES' and
`EXTRA_LIB_DIRS' in their Mmakefile.

doc/user_guide.texi:
	Documented the new `EXTRA_LIBRARIES' and `EXTRA_LIB_DIRS' Mmake
	variables.

scripts/Mmake.vars.in:
	Added/changed definitions appropriately to support the new
	variables.
	This included adding a `GRADESTRING' variable which holds the
	canonical name of the grade being used, taking into account all the
	grade flags.

scripts/c2init.in:
	Added a new option to `c2init':
	-I/--init-file-directory <directory> adds the directory to the list
		of directories to search for `.init' files.

util/mkinit.c:
	Added a new option `-I' to add a directory to the list of
	directories to search for `.init' files.
1999-07-26 02:52:46 +00:00
Tyson Dowd
d1938d4019 Improve build and installation on MS-Windows.
Estimated hours taken: 3

Improve build and installation on MS-Windows.

configure.in:
Mmake.common.in:
	Set extension for executables (.exe for Windows, nothing
	otherwise).
	Detect presence of perl, makeinfo, texi2dvi and dvips.

Mmakefile:
README.MS-Windows:
	Remove old preinstall and postinstall hacks for windows.

compiler/Mmakefile:
profiler/Mmakefile:
util/Mmakefile:
	Use the extension for executables when installing.

doc/Mmakefile:
	Don't generate documentation unless the appropriate tools
	are available.  Use the auto-detection of perl,
	makeinfo, texi2dvi and dvips to build documentation.

doc/generate_mdb_doc:
	Don't insist on rm being in /bin
1999-07-20 21:30:02 +00:00
Fergus Henderson
c997936cc9 Delete some obsolete old code.
Estimated hours taken: 0.1

util/mkinit.c:
	Delete some obsolete old code.
1999-06-29 19:08:32 +00:00
Peter Ross
8ab130a3b0 Add a new pass to the compiler, that attempts to introduce accumulators
Estimated hours taken: 500

Add a new pass to the compiler, that attempts to introduce accumulators
into a procedure so as to make that procedure tail recursive.

WORK_IN_PROGRESS:
    Document that the transformation now exists.

compiler/goal_util.m:
    Create goal_util__can_reorder_goals, which is a version of
    pd_util__can_reorder_goals that will work on the alias branch.

compiler/instmap.m:
    Add instmap__changed_vars.  This predicate is meant to provide the
    same functionality as instmap_delta_changed_vars, but work on the
    alias branch.

    Also add comment to instmap_delta_changed_vars about using
    instmap_changed_vars

compiler/accumulator.m:
    The transformation.

compiler/mercury_compile.m:
    Call the transformation.

compiler/options.m:
    Add the option to turn the transformation on.

doc/user_guide.texi:
    Document the option.

profiler/demangle.m:
util/mdemangle.c:
    Demangle the accumulator version of the procedure labels.

compiler/notes/compiler_design.html:
    Add the new pass to the documentation.
1999-06-15 07:10:17 +00:00
Fergus Henderson
dfc4e243cd Simplify the code by deleting unnecessary uses of $(EXTRA_*), etc.
Estimated hours taken: 1

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