Commit Graph

52 Commits

Author SHA1 Message Date
Peter Wang
ef81b66625 Move the intermodule analysis framework into the `compiler' directory, in
Estimated hours taken: 2
Branches: main

Move the intermodule analysis framework into the `compiler' directory, in
preparation for making it specific to the Mercury compiler, rather than having
it generic in case some fictional being might want to use it with a .NET
compiler one day.  This will make it easier to use and modify.

compiler/analysis.file.m:
compiler/analysis.m:
	Copy these files from the `analysis' directory.

compiler/top_level.m:
	Include analysis.m as a new package.

compiler/Mercury.options:
	Add a bug workaround line from analysis/Mercury.options.

analysis/Mercury.options:
analysis/Mmakefile:
analysis/analysis.file.m:
analysis/analysis.m:
analysis/mer_analysis.m:
	Replace the contents of these files with comments that the analysis
	framework is now in the `compiler' directory.  We don't actually
	delete them so their histories remain easily accessible.

analysis/README:
	Mention that the code has been moved.

compiler/notes/compiler_design.html:
compiler/notes/overall_design.html:
	Update documentation.

Mmake.workspace:
Mmakefile:
configure.in:
compiler/.mgnuc_copts:
compiler/COMP_FLAGS.in:
compiler/Mmakefile:
deep_profiler/.mgnuc_copts:
scripts/Mmake.vars.in:
scripts/c2init.in:
scripts/mercury_config.in:
scripts/prepare_tmp_dir_fixed_part.in:
tools/binary:
tools/binary_step:
tools/bootcheck:
tools/lmc.in:
tools/make_arena:
compiler/notes/coding_standards.html:
	Remove references to the `analysis' directory and `libmer_analysis'.
2008-02-20 03:10:00 +00:00
Zoltan Somogyi
9e1c06af71 Fix a bug that prevented the compiler from bootstrapping in deep profiling
Estimated hours taken: 6
Branches: main

Fix a bug that prevented the compiler from bootstrapping in deep profiling
grades. The symptom was the violation of a sanity check in
mercury_deep_profiling.c, which lead to this message:

	Mercury runtime: UNWRITTEN nodes: Deep.data file corrupted

Mmake.workspace:
	Don't include the ssdb library's init file unconditionally in every
	_init.c file we generate; instead include the ssdb library's init file
	only in ssdb grades.

	The reason why this is needed is that the referenced but unwritten
	nodes were the proc layouts of three predicates in the browser
	directory. They were not written because the browser library's init
	file is (correctly) included in the compiler's _init.c file only if
	the browser library is linked into the compiler, i.e. only if the
	compiler is compiled in a debug grade. They were referenced by call
	site static structures from ssdb/ssdb.m, whose init file was
	(incorrectly) being included in the compiler's _init.c file even if
	the compiler wasn't being compiled in an ssdb grade.

scripts/parse_ml_options.sh-subr.in:
	Add the option needed by Mmake.workspace to add an init file only in an
	ssdb grade: --ssdb-init-file.

scripts/c2init.in:
	Act on the value of that option.

	Delete a reference to $TRACE_INIT_FILES, since it should always be
	empty. Document a similar problem with $EXTRA_INIT_FILES.

Mmakefile:
	Improve formatting.

compiler/layout_out.m:
	Avoid inconsistent indentation in the generated .c code.

tools/bootcheck:
	Add two options that helped track down the bug: --deep-all-write,
	which causes bootcheck to write out *every*deep profiling data file,
	and --deep-debug, which switches on the already existing deep profiling
	debug support.

runtime/mercury_deep_profiling.c:
	Put the two lines of the error message we generate for unwritten nodes
	if deep profiling's debug support is enabled in the logical order.
2007-12-23 23:57:20 +00:00
Peter Wang
4953e5e574 Update files as required for the addition of the new library `libmer_ssdb',
Estimated hours taken: 8
Branches: main

Update files as required for the addition of the new library `libmer_ssdb',
and make the changes to add a new grade component `ssdebug'.

Mmake.workspace:
Mmakefile:
	Add `mer_ssdb.init', `libmer_ssdb' and `ssdb' directory to the
	appropriate lists.

	Order "ssdb" occurrences according to its position in the list of
	which libraries can call functions in which other libraries.

configure.in:
	Check the bootstrap compiler supports the `--no-ssdb' option.

browser/MDB_FLAGS.in:
library/LIB_FLAGS.in:
mdbcomp/MDBCOMP_FLAGS.in:
	Add `--no-ssdb' to break the cyclic dependencies between these
	libraries and `libmer_ssdb' that would be introduced if the
	source-to-source debugging transformation was applied these libraries.
	It also prevents the infinite recursion which would result from ssdb
	procedures calling transformed library procedures and vice versa.

analysis/.mgnuc_copts:
analysis/ANALYSIS_FLAGS.in:
analysis/Mmakefile:
profiler/.mgnuc_copts:
profiler/PROF_FLAGS.in:
slice/.mgnuc_copts:
slice/Mmakefile:
slice/SLICE_FLAGS.in:
	Search the `ssdb' directory for files.

compiler/Mmakefile:
	Remove the explicit `libmer_ssdb.a' from MLOBJS as it is redundant.

	Make the compiler binary depend on `libmer_ssdb'.

compiler/compile_target_code.m:
scripts/mgnuc.in:
	Pass "-DMR_SS_DEBUG" when compiling a C file if `--ssdb' is enabled.

	Implicitly include `mer_ssdb.init' and `libmer_ssdb' in various lists
	when `--ssdb' is enabled.

runtime/mercury_conf_param.h:
	Document `MR_SS_DEBUG' preprocessor macro.

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:
	Add "ssdebug" grade component.

	Add "--ss-debug" option as an alias for "--ssdb" to be consistent with
	"--decl-debug".  Move the clauses to the right position.

scripts/c2init.in:
scripts/ml.in:
	Link in `libmer_ssdb' if `--ssdb' enabled.

tools/lmc.in:
tools/lml:
	Link in `libmer_ssdb' and add `mer_ssdb.init'.

tools/bootcheck:
	Delete `ssdb' directory if `--disable-debug-libs' option enabled.

tools/binary:
tools/linear:
	Link `ssdb' directory.

compiler/notes/overall_design.html:
	Mention `ssdb' directory.

doc/user_guide.texi:
	Add commented out documentation for the `--ss-debug' option and the
	`ssdebug' grade component.
2007-10-24 09:21:19 +00:00
Julien Fischer
c3d813a47b When building with mmc --make use the grade specific versions of the
Estimated hours taken: 4
Branches: main

When building with mmc --make use the grade specific versions of the
.init files.

Support grade specific .init files with --use-grade-subdirs.

compiler/compile_target_code.m:
	Use the grade specific version of the .init files for the Mercury
	standard libraries, i.e. rt, stdlib, browser, trace.

	If --use-grade-subdirs is enabled them symlink/copy .init files
	into the user's directory.

compiler/options.m:
	Delay handling the init file directories until after the grade
	has been computed.

compiler/handle_options.m:
	Append the grade to each init file directory, so that we get
	the grade specific version of the .init files.

	Unrelated changes: replace an if-then-else with a switch.
			   minor formatting changes.

compiler/modules.m:
	.init files are now grade dependent.

scripts/c2init.in:
	Use the grade specific version of the .init files for the
	standard Mercury libraries.
2006-11-30 12:45:48 +00:00
Zoltan Somogyi
9ec86d6a6d The objective of this diff is to switch from a table of solver events built
Estimated hours taken: 32
Branches: main

The objective of this diff is to switch from a table of solver events built
into the compiler (and eventually the debugger) into a table of events
defined by a file provided by the user to the compiler, which the compiler
then records in the executable for use by the debugger.

The current design, for speed of implementation, uses temporary files parsed
by a bison-generated parser. Since the compiler needs to be able to invoke
the parser even if it is compiled in a non-debug grade, the parser is in
a new library, the eventspec library, that is always linked into the Mercury
compiler and is always linked into any Mercury program with debugging enabled
(but is of course linked only once into a Mercury compiler which has debugging
enabled).

Modify the debugger to give it the ability to print the attributes of
user-defined events (for now, only the non-synthesized attributes).
Implement a new debugger command, "user", which goes to the next user-defined
event.

configure.in:
	Require flex and and bison to be available.

doc/user_guide.texi:
	Document user defined events and the new debugger capabilities.

doc/mdb_categories:
	Include "user" in the list of forward movement commands.

	Fix some earlier omissions in that list.

runtime/mercury_stack_layout.h:
	Include an event number in the user-defined event structure.

	Include a string representing an event set specification in module
	layout structures.

runtime/mercury_stack_layout.h:
runtime/mercury_trace_base.[ch]:
runtime/mercury_types.h
	Switch from solver events to user events in names.

runtime/mercury_trace_term.[ch]:
	Provide a representation of flat terms, for use in representing
	the calls that generate synthesized attributes.

	Ensure that exported field names have an MR_ prefix.

browser/cterm.m:
	Conform to the change to runtime/mercury_trace_term.h.

scripts/c2init.in:
scripts/ml.in:
	Include the eventspec library in programs compiled with debugging
	enabled.

compiler/Mmakefile:
	Include the eventspec library in the compiler.

compiler/options.m:
	Add a new option, --event-spec-file-name, that allows the user to
	specify the set of user-defined events the program may use.

compiler/handle_options.m:
	Set this optimization from an environment variable (which may be
	set by the mmc script) if the new option is not explicitly given.

compiler/prog_data.m:
	Define the data structures for the compiler's representation of the
	event set specification.

	Move some definitions around to group them more logically.

compiler/hlds_module.m:
	Include the event set specification as a new field in the module_info.

compiler/prog_event.m:
	Add the code for invoking the parser in the eventspec library,
	and for converting the simple term output by the parser to the
	compiler own representation, which contains more information
	(to wit, the types of the function attributes) and which has had
	a whole bunch of semantic checks done on it (e.g. whether synthesized
	attributes depend on themselves or on nonexistent attributes).

	Provide a function to generate a canonicalized version of the event
	specification file.

compiler/module_qual.m:
compiler/equiv_type.m:
	Process event spec specifications as well as items, to module qualify
	the names of the types of event arguments, and expanding out
	equivalence types.

	In equiv_type.m, rename some variables to make clear what kind of info
	they represent.

compiler/mercury_compile.m:
	Process the event set specification file if one has been selected:
	read it in, module qualify it, expand its equivalence types, and add
	to the module_info.

compiler/compile_target_code.m:
	Include the event_spec library when linking debuggable executables.

compiler/call_gen.m:
compiler/continuation_info.m:
compiler/trace_gen.m:
compiler/trace_params.m:
mdbcomp/prim_data.m:
mdbcomp/trace_counts.m:
runtime/mercury_goto.h:
	Generate user-defined events instead of solver events.

compiler/layout.m:
compiler/layout_out.m:
compiler/stack_layout.m:
	Include a canonicalized version of the event specification file
	in the module layout if the module has any user-defined events.

compiler/code_info.m:
compiler/llds_out.m:
compiler/modes.m:
compiler/modules.m:
compiler/opt_debug.m:
compiler/typecheck.m:
	Conform to the changes above.

compiler/passes_aux.m:
	Rename a predicate to avoid an ambiguity.

trace/Mmakefile:
	Add the definition and rules required to build the eventspec library.

trace/mercury_event_scanner.l:
trace/mercury_event_parser.y:
	A scanner and a parser for reading in event spec specifications.

trace/mercury_event_spec_missing.h:
	Provide the declarations that should be (but aren't) provided by
	flex and bison.

trace/mercury_event_spec.[ch]:
	The main module of the eventspec library. Provides functions to read
	in event set specifications from a file, and to write them out as a
	Mercury term in the form needed by the compiler.

trace/mercury_trace_tables.c:
	If the module layouts being registered include event set
	specifications, then check their consistency. Make the specification
	and the consistency indication available to other modules.

trace/mercury_trace_internal.c:
	During initialization, if the modules contain a consistent set of event
	set specifications, then read that specification into the debugger.
	(We don't yet make use of this information.)

	Add an extra mdb command, "user", which goes forward to the next
	user-defined event.

trace/mercury_trace.[ch]:
trace/mercury_trace_cmd_forward.[ch]:
	Implement the new mdb command.

trace/mercury_trace_vars.[ch]:
	For user-defined events, include the attributes' values among the
	values that can be printed or browsed.

trace/mercury_trace_cmd_browsing.c:
trace/mercury_trace_declarative.c:
	Minor changes.

scripts/scripts/prepare_tmp_dir_grade_part:
	Copy the .y and .l files to the tmp dir we use for installs.

tools/bootcheck:
	Copy the .y and .l files of the trace directory to stage 2.

tools/lmc.in:
	Include the eventspec library when linking debuggable executables.

tests/debugger/user_event.{m,inp,exp}:
tests/debugger/user_event_spec:
	New test case to test the new functionality.

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

tests/debugger/completion.exp:
	Expect the new "user" mdb command in the completion output.
2006-11-24 03:48:30 +00:00
Julien Fischer
9d8ca0ad37 Remove residual parts of the Aditi backend that weren't deleted the other day.
Estimated hours taken: 1.5
Branches: main

Remove residual parts of the Aditi backend that weren't deleted the other day.

configure.in:
Mmake.common.in:
	Remove support for enabling the Aditi backend.

runtime/mercury_aditi.h:
	Remove this file.

runtime/Mmakefile:
runtime/mercury.h:
runtime/mercury_imp.h:
runtime/mercury_ho_call.[ch]:
runtime/mercury_wrapper.[ch]:
	Delete support for Aditi in the runtime.

scripts/Mmake.rules:
scripts/Mmake.vars.in:
scripts/c2init.in:
scripts/parse_ml_options.sh-subr.in:
	Remove mmake support for building .rlo files, etc.

util/mkinit.c:
	Remove Aditi specific code.

compiler/bytecode_data.m:
compiler/closure_analysis.m:
compiler/code_model.m:
compiler/compile_target_code.m:
compiler/det_analysis.m:
compiler/handle_options.m:
compiler/hlds_goal.m:
compiler/hlds_module.m:
compiler/make.dependencies.m:
compiler/make.m:
compiler/make.module_target.m:
compiler/make.program_target.m:
compiler/make.util.m:
compiler/make_hlds_error.m:
compiler/make_hlds_passes.m:
compiler/mercury_to_mercury.m:
compiler/mlds_to_gcc.m:
compiler/modecheck_call.m:
compiler/modules.m:
compiler/opt_debug.m:
compiler/options.m:
compiler/prog_data.m:
compiler/prog_foreign.m:
compiler/prog_mode.m:
compiler/prog_type.m:
compiler/rtti.m:
compiler/rtti_out.m:
compiler/rtti_to_mlds.m:
compiler/term_errors.m:
compiler/unify_proc.m:
mdbcomp/prim_data.m:
	Remove residual support for Aditi.

library/ops.m:
	Remove the 'aditi_bottom_up' and 'aditi_top_down' operators from the
	ops table.

doc/reference_manual.texi:
doc/user_guide.texi:
	Delete the sections on the Aditi interface.

extras/aditi/*:
	Delete this.
2006-02-24 07:11:21 +00:00
Zoltan Somogyi
5ebb612c9c Provide a mechanism that allows the user to specify that a certain
Estimated hours taken: 2
Branches: main

util/mkinit.c:
	Provide a mechanism that allows the user to specify that a certain
	function should always be executed on Mercury startup. This is intended
	to be used to initialize global variables that point to Mercury data.
	This is useful e.g. in constraint solvers, because it removes the need
	for the solver to check, on every access to its state, whether it has
	been initialized yet.

scripts/parse_ml_options-sh-subr.in:
scripts/c2init.in:
	Pass along the required option to mkinit.

scripts/Mmakefile:
	Provide a mechanism to automatically rebuild c2init and other
	configured files when ../config.status changes.
2005-05-09 08:10:22 +00:00
Zoltan Somogyi
86ac840326 Implement a mechanism to generate the information required to determine the
Estimated hours taken: weeks
Branches: main

Implement a mechanism to generate the information required to determine the
algorithmic complexity of selected procedures.

The basis of the mechanism is a program transformation that wraps up the body
of each selected procedure in code that detects top-level (non-recursive)
calls, and for each top-level call, records the sizes of the input arguments
and information about the cost of the call. For now, the cost information
consists only of the number of cells and words allocated during the call,
but there is provision for later adding information from a real-time clock.

compiler/complexity.m:
	A new module containing the new transformation.

compiler/transform_hlds.m:
	Add complexity.m to the list of submodules.

compiler/mercury_compile.m:
	Invoke the new module.

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

compiler/options.m:
	Add an option, --experimental-complexity. Its argument is a filename
	that specifies the list of procedures to transform.

	Add an option, --no-allow-inlining, to disallow all inlining.
	This is simpler to use than specifying several options to turn off
	each potential reason to inline procedures.

doc/user_guide.texi:
	Document the new options. The documentation present now is only a
	shell; it will be expanded later.

compiler/table_gen.m:
compiler/goal_util.m:
	Move the predicate for creating renamings from table_gen.m to
	goal_util.m, since complexity.m also needs it now. In the process,
	make it more general by allowing outputs to have more complex modes
	than simply `out'.

compiler/goal_util.m:
	Fix a bug exposed by the new transformation: when renaming goals
	(e.g. for quantification), rename the variables holding information
	about term sizes.

compiler/handle_options.m:
	Disable inlining if experimental complexity analysis is enabled.

compiler/compile_target_code.m:
	Pass the --experimental-complexity option on to the linker.

library/term_size_prof_builtin.m:
	Add the Mercury predicates that serve as interfaces to the primitives
	needed by the experimental complexity transformation.

runtime/mercury_term_size.[ch]:
	Add the implementations of the primitives needed by the experimental
	complexity transformation.

runtime/mercury_wrapper.[ch]:
	Add global variables holding counters of the numbers of words and cells
	allocated so far.

runtime/mercury_heap.h:
	Update these global variables when allocating memory.

runtime/mercury_complexity.h:
	New file that contains the definition of the data structures holding
	the data collected by the experimental complexity transformation.
	This is separate from mercury_term_size.h, because it needs to be
	#included in mercury_init.h, the header file of the mkinit-generated
	<program>_init.c files.

runtime/mercury_init.h:
runtime/mercury_imp.h:
	#include mercury_complexity.h.

util/mkinit.c:
	Define and initialize the data structures holding complexity
	information when given the -X option (mkinit doesn't have long
	options).

	Fix some deviations from our coding style.

scripts/parse_ml_options.sh-subr.in:
	Accept the --experiment-complexity option.

scripts/c2init.in:
	Pass the --experiment-complexity option on to mkinit.c.

tools/bootcheck:
	Preserve the files containing the results of complexity analysis,
	if they exist.

tools/makebatch:
	Allow the specification of EXTRA_MLFLAGS in the generated
	Mmake.stage.params files.
2005-02-15 05:22:40 +00:00
Zoltan Somogyi
e0c212359f Fix problems in white space in the commit of the fix of the deep profiler.
Estimated hours taken: 0.2
Branches: main

Fix problems in white space in the commit of the fix of the deep profiler.
These were caused by the fact that the workspace in which the original commit
took place was created by applying a patch to a fresh workspace, and the patch
was created with diff -b.
2004-05-20 22:53:32 +00:00
Zoltan Somogyi
c80d143cc8 The following change is only 98% complete, not 100%.
Estimated hours taken: 120
Branches: main

The following change is only 98% complete, not 100%. I am committing it in
this state because (1) we pass many more test cases in deep profiling grade
with it than without it, and (2) the double maintanance involved in fixing
CVS conflicts is preventing me from doing the last 2%.

Get the deep profiler to work for code that sets up to catch exceptions,
which for the last year or more has included the compiler, and to get it
almost working for code that actually catching exceptions.

The basic problem is that code that throws exceptions will in general cause
several calls to "return" without executing the exit or fail port codes that
the deep profiling transformation inserted into their bodies, and this leaves
the data structure being built by the deep profiling inconsistent. The solution
uses the same approach as we have adopted for the debugger: have the code that
handles the throwing of exceptions simulate a return from each call between
the throw and the catch, updating the deep profiling data structures as needed.

This requires us to be able to walk the stack at runtime not just in debugging
grades but also in deep profiling grades. Since the debugger already has the
mechanisms required for this, we reuse them. The procedure layouts used by the
debugger were designed to have three segments: the procedure stack walk
information, the procedure id, and the execution tracing information. We now
modify this design to make the third segment contain two pointers: to the
execution tracing information (for use by the debugger), and to the procedure's
proc_static structure (for use by deep profiling). Each pointer will be null
unless the pointed-to structure is required by compile-time options.

This common use by the debugger and by deep profiling of the stack-walk
structure and the procedure id structure (which deep profiling used to
generate independently and possibly redundantly) required some rearrangement
of the compiler's version of these data structures.

To make this rearrangement simpler, this diff removes a capability that
we theoretically supported but never used: turning on stack traces without
turning on execution tracing and vice versa. After this diff, stack tracing
is enabled if and only if either execution tracing or deep profiling is
enabled.

The diff also includes improvements in the debugging infrastructure for
debugging deep profiling, which were necessary for the implementation of the
rest of the changes.

compiler/deep_profiling.m:
	The code in exception.m needs to know the locations of the variables
	that we would pass to the exit or fail port code, so it can simulate
	leaving the procedure invocation through the exception port. Without
	this information, throwing an exception leaves the deep profiling
	data structures of the procedure invocations between throw and catch
	in an inconsistent state.

	Deep_profiling.m creates these variables, but it doesn't know where
	they will be at runtime, so it records their identities; the code
	generator will allocate them stack slots and record the numbers of
	these stack slots for placement in the now expanded proc layout
	structures. Deep profiling used to generate static data structures
	separately from the HLDS, but since the code generator now needs
	access to them, we store their information in proc_infos in the HLDS.

	Instead of passing the addresses of proc_static structures to the deep
	profiling port procedures, pass the address of proc_layout structures,
	since the information about the identities of procedures are now stored
	not in the proc_static structure, but in the proc_layout structure
	that points to the proc_static structure.

compiler/hlds_pred.m:
compiler/layout.m:
	Move the definitions of the static data structures generated by deep
	profiling from layout.m to hlds_pred.m, to allow deep_profiling.m
	to store them in proc_infos.

compiler/hlds_pred.m:
compiler/rtti.m:
	Move the definition of rtti_proc_label from rtti.m to hlds_pred.m,
	since some of the new data structures in hlds_pred.m need it. Despite
	its name, the rtti_proc_label type doesn't contain any info that
	doesn't belong in the HLDS.

	Add some information to the rtti_proc_label type that is now needed
	by deep profiling, e.g. record determinisms instead of just code
	models. Record explicitly the outcome of some tests that used to be
	duplicated in more than one place in the compiler, e.g. for whether
	the procedure (as opposed to the predicate) is imported. Change some
	of the field names to be more precise about the field's meaning.

compiler/code_gen.m:
	Transmit the contents of the deep profiling data structures stored in
	the proc_info by deep_profiling.m to continuation_info.m, together
	with the layout structures created for execution tracing and the
	identities of the variables needed for handling exceptions,
	when code generation for a procedure is complete.

	After the goal that generates these variables, save them to stack
	for use by the exception handler.

compiler/hlds_goal.m:
	Add a feature to mark the goal that generates the deep profiling
	variables needed by the exception handler.

compiler/hlds_llds.m:
	Add a utility predicate for new code in code_gen.m

compiler/continuation_info.m:
	Hold the deep profiling information computed by code_gen.m for use by
	stack_layout.m.

compiler/layout.m:
compiler/layout_out.m:
	Update the definitions of the data structures describing procedure
	layouts, and the code writing them out, to reflect the use of some
	parts of procedure layouts by deep profiling as well as debugging.

	Change the layout structures generated by deep profiling to use
	rtti_proc_labels, which are backend independent, instead of
	proc_labels, which are specific to the LLDS backend.

	Conform to the changes in runtime/mercury_stack_layout.h.

compiler/stack_layout.m:
	Generate the updated version of proc_layout structures.

compiler/mercury_compile.m:
compiler/global_data.m:
	Conform to the fact that deep profiling no longer generates layout
	structures separate from proc_infos.

compiler/llds_out.m:
	Register proc_layout structures instead of proc_static structures
	for use by runtime/mercury_deep_profiling.c.

compiler/options.m:
compiler/handle_options.m:
	Rename the require_tracing option as exec_trace, since this more
	directly reflects its meaning.

	Instead of having --debug set both require_tracing and stack_trace,
	make it set (be the user-visible name of) just exec_trace;
	the value of stack_trace is implied.

	Turn off the specialization of deep profiling for self-tail-recursive
	procedures for now. Due to the changes made by this diff in the data
	structures involved in debugging, it cannot be debugged until this
	change has been installed. Handling the full language is more important
	than a specialization that reduces only stack space overheads, not
	runtime overheads.

compiler/compile_target_code.m:
	Conform to the changes in options.m and runtime/mercury_grade.h.

compiler/hlds_data.m:
	Replace the deep_profiling_proc_static cons_id, and its associated tag,
	to deep_profiling_proc_layout, since we now generate addresses of proc
	layout structures, not of proc_static structures.

compiler/code_util.m:
	Simplify some code based on the new info in rtti_proc_labels.

compiler/bytecode_gen.m:
compiler/dependency_graph.m:
compiler/higher_order.m:
compiler/hlds_out.m:
compiler/mercury_to_mercury.m:
compiler/ml_code_util.m:
compiler/ml_unify_gen.m:
compiler/opt_debug.m:
compiler/proc_label.m:
compiler/prog_rep.m:
compiler/rl_exprn.m:
compiler/rtti_out.m:
compiler/rtti_to_mlds.m:
compiler/saved_vars.m:
compiler/switch_util.m:
compiler/unify_gen.m:
	Minor changes to conform to the change from deep_profiling_proc_static
	to deep_profiling_proc_layout, to the change in the structure of
	rtti_proc_labels, to the changes in types of layout.m, and/or to the
	new goal feature.

deep_profiler/measurements.m:
	Reserve space for exception counts.

deep_profiler/html_format.m:
	Add a column for exception counts.

deep_profiler/profile.m:
deep_profiler/read_profile.m:
	Rename the data structures referring to compiler generated unify,
	compare and index predicates to avoid misleading names: they are
	not the only compiler generated predicates.

deep_profiler/read_profile.m:
runtime/mercury_deep_profiling.c:
	Update the string that identifies deep profiling data files.
	This is necessary because the format has changed: it now includes
	information about exception port counts.

library/exception.m:
	In deep profiling grades, execute the exception port code for every
	procedure invocation between a throw and a catch, using the procedure
	layout structures now generated by the compiler for every procedure.
	Rename the function involved to reflect its new, more general purpose.

	Update the definitions of the hand-written proc_static and proc_layout
	structures for the procedures implemented via hand-written C code.

	Indent C preprocessor directives and foreign_procs according to our
	coding standards.

library/profiling_builtin.m:
	Change the parameters of the call port code procedures from proc_static
	to proc_layout. Reach the proc_static structure from the proc_layout
	structure when needed. Include the proc_layout structure in any
	messages from assertion failures.

	Add some conditionally compiled debugging code.

	Give some variables better names.

runtime/mercury_type_info.h:
runtime/mercury_builtin_types.c:
	Move the macros required to create the proc_static structures
	of unify and compare predicates from mercury_type_info.h
	to mercury_builtin_types.c, since the latter is the only file
	that needs them.

	Use the same macros for creating the proc_static structures
	of hand-written unify, compare and compare_reprentation predicates
	as for user defined predicates. This required changing their naming
	scheme.

runtime/mercury_unify_compare_body.h:
	Conform to the new naming scheme.

runtime/mercury_ho_call.c:
	Provide the mechanism for mercury_unify_compare_body.h to conform
	to the new naming scheme.

	Remove the definitions of the proc_static structures for
	hand-written unify, compare and compare_reprentation predicates,
	since these now have to be defined together with the corresponding
	proc_layout structures in mercury_builtin_types.c.

runtime/mercury_builtin_types.[ch]:
	Update the definitions of the hand-written proc_static and proc_layout
	structures for the procedures implemented via hand-written C code,
	and add the required declarations first.

	Handle deep profiling of compare_representation as well as unify
	and compare predicates on builtin types.

	Handle deep profiling of compare_representation on user-defined types,
	since this is done entirely in the runtime, not by compiler generated
	predicates.

runtime/mercury_builtin_types_proc_layouts.h:
	New header file containing the declarations of the proc layout
	structures of the unify, compare and index predicates of builtin types.
	Logically, these declarations belong in mercury_builtin_types.h,
	but putting them there causes problems for the linker; the details
	are explained in the file itself.

runtime/Mmakefile:
	Add the new header file.

runtime/mercury_minimal_model.[ch]:
	Update the definitions of the hand-written proc_static and proc_layout
	structures for the procedures implemented via hand-written C code,
	and add the required declarations first.

runtime/mercury_grade.h:
	Replace the MR_REQUIRE_TRACING grade option with MR_EXEC_TRACING.
	Besides being better named, the MR_EXEC_TRACING option implies
	MR_STACK_TRACE.

	Besides the overall binary compatibility version number, add subsidiary
	version numbers for binary compatibility in deep profiling and
	debugging grades. These will make it easier to bootstrap changes
	(such as this) that affect binary compatibility only in such grades.

runtime/mercury_trace_base.c:
trace/mercury_trace.c:
	Conform to the new names of the configuration parameters.

runtime/mercury_hand_compare_body.h:
runtime/mercury_hand_unify_body.h:
runtime/mercury_hand_unify_compare_body.h:
runtime/mercury_ho_call.c:
tools/make_port_code:
	Pass proc_layout structures instead of proc_static structures
	to deep profiling port routines.

runtime/mercury_conf_param.h:
	Make MR_DEEP_PROFILING as well as MR_EXEC_TRACING imply MR_STACK_TRACE,
	since deep profiling now needs stack tracing. (MR_STACK_TRACE needs
	to be set in this file, because tests in this file depend on knowing
	its value, and this file is among the first files included (in this
	case indirectly) in mercury_imp.h.)

	Document the macros controlling the debugging of deep profiling.

	Enable printing of label names when the relevant deep profiling
	debugging macro is set.

runtime/mercury_debug.c:
runtime/mercury_deep_rec_depth_actions.h:
runtime/mercury_deep_rec_depth_body.h:
runtime/mercury_exception_catch_body.h:
	Get to proc_statics via proc_layouts.

runtime/mercury_deep_call_port_body.c:
runtime/mercury_deep_leave_port_body.c:
	Get to proc_statics via proc_layouts.

	Allow the debugger to disable deep profiling in Mercury code that is
	part of the debugger, not of the user program being executed.

	Add some more assertions.

runtime/mercury_engine.[ch]:
	Add a new debugging flag that controls at runtime whether we generate
	a human readable Deep.debug equivalent to the binary Deep.data files.
	(We already had a mechanism for controlling this at compile time,
	but this isn't flexible enough.)

runtime/mercury_wrapper.c:
	Allow this new debugging flag to be set from MERCURY_OPTIONS.

runtime/mercury_deep_profiling.[ch]:
	Respect this new debugging flag.

	Update the hand-written proc_static structures representing the runtime
	system.

	Print out addresses of proc_layout as well as proc_static structures
	when assertions fail.

	Add a field to the measurement structure for exception port counts,
	and write out this field with the other port counts.

	Remove procedure id information from proc_static structures,
	deep profiling now uses the procedure id in the proc_layout structure.

	Add to proc_static structures fields that specify where, if anywhere,
	the variables needed by exception.m to executed the exception port code
	are in the procedure's stack frame.

	Define a global flag that allows the debugger to disable deep
	profiling in Mercury code that is part of the debugger, not of the
	user program being executed.

	Increase type safety by providing two versions of the function
	for registering proc_layouts, one for the proc_layout structures
	of user-defined predicates and one for unify, compare and index
	predicates.

	Fix a bug that occurs only if MR_DEEP_PROFILING_EXPLICIT_CALL_COUNTS is
	defined (which it usually isn't): the initial call count was wrong.

runtime/mercury_deep_profiling_hand.h:
	Fix a bug: the handwritten code saving deep profiling variables was
	saving them in slots that didn't belong to the relevant stack frame.

	Update to conform to the modified definitions of proc_static structures
	and the fact that we now reach them via proc_layout structures.

runtime/mercury_exception_catch_body.h:
runtime/mercury_stacks.h:
	Fix the other side of the bug in mercury_deep_profiling_hand.h
	by reserving the right number of stack slots in the stack frames
	of the various modes of exception__catch. Make it harder to make
	the same bug in the future by getting the needed info from the
	place in mercury_stacks.h that defines the structure of the relevant
	stack frame.

runtime/mercury_proc_id.h:
	Rename the procedure id structure fields referring to compiler
	generated unify, compare and index predicates: they are not the only
	compiler-generated predicates.

runtime/mercury_stack_layout.h:
	Change procedure layout structures to allow them to be used for deep
	profiling as well as for debugging, as described in the prologue above.

	We don't need the capability to support label layout structures with
	links to misnamed proc layout structures, and supporting it is
	inconvenient, so delete the capability.

runtime/mercury_debug.c:
runtime/mercury_deep_profiling_hand.h:
runtime/mercury_layout_util.c:
runtime/mercury_ml_expand_body.h:
runtime/mercury_stack_trace.c:
runtime/mercury_types.h:
trace/mercury_trace_external.c:
	Conform to the new names of the procedure id structure fields.

runtime/mercury_std.h:
	Add some more arities for MR_PASTE for use in some of the modified
	modules in the runtime.

trace/mercury_trace_internal.c:
	Disable deep profiling actions in Mercury code that is part of the
	debugger, not of the program being debugged.

scripts/init_grade_options.sh-subr:
scripts/parse_grade_options.sh-subr:
	Make changes parallel to the ones in runtime/mercury_grade.h: delete
	--stack-trace as an independent option, and make --debug set its
	own option, not --require-tracing.

scripts/canonical_grade.sh-subr:
scripts/final_grade_options.sh-subr:
scripts/c2init.in:
scripts/mgnuc.in:
scripts/ml.in:
	Conform to the changes in grade options for debugging and for deep
	profiling.

tools/bootcheck:
	If Mmake.stage.{browser,deep,library,runtime,trace}.params exist,
	copy them to become the file Mmake.$dir.params in stage2/$dir
	(where dir is derived from the name of the original file in the obvious
	way). This allows more flexibility in the creation of the stage2;
	for example, it allows some directories (e.g. runtime or library)
	to be compiled with more debugging than other directories (e.g.
	compiler). This may be required because compiling all directories
	with lots of debugging may cause the linker to thrash.

	Add an option, --disable-debug-libs, that clobbers the libraries
	that should be linked in only in debugging grades.

	To conserve disk space, remove Deep.data files created by the bootcheck
	by default. Add an option, --keep-deep-data, to preserve these files.

	Use a consistent mechanism (test -f) for testing the existence of
	all files whose existence is tested.

	When recording modification times, record the modification times
	of some more files.

tests/hard_coded/Mmakefile:
	In deep profiling grades, disable the test cases that we don't now
	pass in such grades, and document the reasons for their failure.

	Fix the misclassification of the write_binary test case.
2004-05-19 04:00:01 +00:00
James Goddard
bf70ebd080 Simplify use of the Java grade by automatically setting the classpath.
Estimated hours taken: 1.5
Branches: main

Simplify use of the Java grade by automatically setting the classpath.

scripts/Mercury.config.in:
scripts/Mercury.config.bootstrap.in:
	Set the --java-classpath option in DEFAULT_MC_FLAGS.
	Define STD_LIB_NAME, RT_LIB_NAME.

scripts/c2init.in:
	Add the above two files to the list of those which use STD_LIB_NAME and
	RT_LIB_NAME.

library/Mmakefile:
	Use RT_LIB_NAME instead of STD_LIB_NAME.runtime

compiler/modules.m:
	Remove the XXX comment that worries about this issue.

README.Java:
	Remove instructions relating to setting the classpath manually.
2004-02-12 02:48:37 +00:00
Zoltan Somogyi
ecdc285bc7 Split the existing browser library into two libraries, by making the
Estimated hours taken: 10
Branches: main

Split the existing browser library into two libraries, by making the
program_representation module into its own library. This is useful because
the compiler refers to program_representation.m, whose code thus needs to be
linked into compiler executables even if the compiler isn't compiled with
debugging enabled. By creating a new library for this module, we avoid any
chance of the linker dragging in the rest of the modules in the browser
library. (This is a problem with an upcoming diff.).

The name of the new library is "mdbcomp", because the intention is that it
contain code that is shared between the debugger and the compiler. This means
mostly the definitions of data structures that the compiler generates for the
debugger, and the predicates that operate on them.

Mmake.common.in:
	Allow MDB_COMP_ as a prefix for symbol names in the browser directory.

Mmake.workspace:
	Add a make variable holding for the name of the new library, and
	add the name to the relevant lists of libraries.

	Avoid duplicating the lists of filenames that need to be updated
	when adding new libraries or changing their names.

Mmakefile:
	Use make variables to refer to library names.

browser/mdbcomp.m:
browser/mer_mdbcomp.m:
	Add these files as the top modules of the new library.

browser/program_representation.m:
	Make program_representation.m a submodule of mdbcomp, not mdb.

browser/program_representation.m:
browser/browser_info.m:
	Move a predicate from program_representation.m to browser_info.m
	to avoid the mdbcomp library depend on the browser library, since
	this would negate the point of the exercise.

browser/mdb.m:
	Delete program_representation.m from the list of submodules.

browser/Mmakefile:
	Update this file to handle the new module.

browser/Mercury.options:
	Mention the new module.

browser/*.m:
	Update the lists of imported modules. Import only one browser module
	per line.

compiler/notes/overall_design.html:
	Document the new library.

compiler/compile_target_code.m:
	Add the mdbcomp library to the list of libraries we need to link with.

compiler/prog_rep.m:
trace/mercury_trace_internal.c:
	Import program_representation.m by its new name.

scripts/c2init.in:
	Centralize knowledge about which files need to be updated when the list
	of libraries changes here.

scripts/c2init.in:
scripts/ml.in:
tools/binary:
tools/binary_step:
tools/bootcheck:
tools/linear:
tools/lml:
	Update the list of libraries programs are linked with.
2003-10-27 06:00:50 +00:00
Zoltan Somogyi
5099371a94 Document why this file includes canonical_grade_options.sh-subr
Estimated hours taken: 0.1
Branches: main

scripts/c2init.in:
	Document why this file includes canonical_grade_options.sh-subr
	without including the other files (init_grade_options.sh-subr,
	parse_grade_options.sh-subr and final_grade_options.sh-subr)
	that canonical_grade_options.sh-subr depends on.
2003-06-13 09:39:44 +00:00
Simon Taylor
2b6712425e Clean up the handling of environment variables.
Estimated hours taken: 0.5
Branches: main

Clean up the handling of environment variables.

scripts/Mmake.rules:
scripts/c2init.in:
scripts/mgnuc.in:
scripts/ml.in:
scripts/mmc.in:
scripts/parse_ml_options.sh-subr.in:
scripts/binary_step.in:
	Remove support for the environment variables which were
	previously used to override the location of the standard
	library (MERCURY_ALL_C_INCL_DIRS, MERCURY_ALL_MC_C_INCL_DIRS,
	MERCURY_INT_DIR, MERCURY_C_LIB_DIR, MERCURY_MOD_LIB_MODS,
	MERCURY_TRACE_LIB_MODS).

scripts/Mercury.config.in:
	Fix syntax errors.

	Set the DEFAULT_MERCURY_LINKAGE variable here rather
	than in the mmc script.

scripts/mmc.in:
	Setting DEFAULT_MCFLAGS is no longer required -- mmc
	now reads its configuration information from the
	Mercury.config file. This also fixes a bug which
	caused failures in the `mmc --make' tests in
	debugging grades on mundroo -- `mmc --make' wasn't
	including /usr/local/lib and /usr/local/include in
	the search paths for libraries and headers.

configure.in:
	Check that the installed compiler is capable of
	reading the Mercury.config file.
	Bootstrap tag: bootstrap_20030413_read_config_file.

NEWS:
doc/user_guide.texi:
	Document the change.
2003-04-13 05:48:37 +00:00
Simon Taylor
4b49b1f019 Implement the ml and c2init scripts in the compiler to
Estimated hours taken: 25
Branches: main

Implement the ml and c2init scripts in the compiler to
reduce dependencies on Cygwin.

compiler/compile_target_code.m:
	Implement the functionality of ml and c2init, rather than
	calling those scripts.

	Handle all compiler dependencies using options, rather than
	testing for particular compilers here.

compiler/options.m:
NEWS:
doc/user_guide.texi:
	Add options which implement functionality which is part
	of ml, c2init or mgnuc when using Mmake:
	--warn-target-code, --output-link-command,
	--output-shared-lib-link-command, --ansi-c,
	--no-strip, --no-demangle, --no-main,
	--allow-undefined, --use-readline, --runtime-flags,
	--extra-inits.

	Add options to describe the C compiler and linker, for
	use by configure/mmc.

	The `--ml-flags' (`--link-flags') option has been removed.

compiler/options_file.m:
	Remove the MLFLAGS variable.

compiler/handle_options.m:
	`--target-debug' implies `--no-strip'.

	Add the path to the GC libraries to the library search paths.

compiler/mercury_compile.m:
	Handle --output-link-command and --output-shared-lib-link-command.

compiler/passes_aux.m:
	Add a variant of invoke_shell_command which takes a second
	command to process the first command's output. This is used
	by compile_target_code.m to invoke the demangler.

configure.in:
scripts/mmc.in:
	Handle extra default options.

scripts/c2init.in:
scripts/ml.in:
	Document that the code here is duplicated in
	compiler/compile_target_code.m.

Mmake.workspace:
browser/Mmakefile:
compiler/Mercury.options:
compiler/Mmakefile:
library/Mmakefile:
	Pass `-R' options pointing to the installation directories
	to mmc, as we already do for ml.
2003-02-05 14:41:20 +00:00
Simon Taylor
5d693f5a1c Factor out the common Mmake code to set up the mmc, mgnuc
Estimated hours taken: 8
Branches: main

Factor out the common Mmake code to set up the mmc, mgnuc
and ml flags when building the Mercury compiler and libraries.
Use options, not environment variables. This will make it simpler
to use `mmc --make' to compile the compiler.

Mmake.workspace:
	Similar to tools/lmc. Sets up Mmake variables to
	use the library files in a workspace rather than
	an installed library.

configure.in:
	Check for the `--no-mercury-stdlib-dir' mmc option.
	Bootstrap CVS tag: bootstrap_20020429_stdlib_dir

Mmake.common.in:
*/Mmakefile:
	Move common code into Mmake.workspace.

browser/Mmakefile:
library/Mmakefile:
	Avoid invoking the linker explicitly when creating
	libraries of Mercury code. That won't work well
	with `mmc --make'.

tools/bootcheck:
tests/Mmake.common:
	Use Mmake.workspace instead of setting up environment
	variables in bootcheck.

scripts/Mmake.vars.in:
	mmc compiles split C files to object code itself,
	so pass `--cflags "$(ALL_CFLAGS)"' to mmc when
	compiling with `--split-c-files'.

browser/interactive_query.m:
	Use `mmc --make' when compiling the query. This is needed
	to make tests/debugger/interactive_query.m work when linking
	against a workspace using options rather than environment
	variables.  This also fixes a bug -- mmc options were being
	passed to ml.

	Clean up after the query.

tests/debugger/Mmakefile:
tests/debugger/interactive.inp:
tests/debugger/interactive.inp.subdirs:
tests/debugger/interactive.inp.nosubdirs:
tests/debugger/interactive.exp:
tests/debugger/interactive.exp2:
	Generate the input file to this test so that MCFLAGS
	and MC_MAKE_FLAGS (from Mmake.workspace) are used when
	compiling queries.

	tests/debugger/Mmakefile now sets SHELL to /usr/local/bash
	to allow the use of $(...) style command substitution
	(`...` style command substitution can't be nested).

tests/warnings/Mmakefile:
tests/dppd/Mmakefile:
	Include tests/Mmake.common.

tools/*:
scripts/c2init.in:
scripts/ml.in:
	Update the lists of files containing the library names.
2002-04-29 08:22:08 +00:00
Simon Taylor
b99e6cc370 Allow alternative locations for the standard library files
Estimated hours taken: 6
Branches: main

Allow alternative locations for the standard library files
to be specified using options to the various Mercury scripts
rather than environment variables.  This change is necessary
to allow the compiler to be compiled using `mmc --make', because
`mmc --make' does not support the environment variables.

All of the Mercury scripts now accept an option
`--mercury-standard-library-directory' to specify the installed
library to use, or `--no-mercury-standard-library-directory' to
disable the use of the installed library. The location
of the alternate files to use can then be specified
using ordinary options to the scripts.

There is a new environment variable MERCURY_STDLIB_DIR, which has
the same effect as the `--mercury-standard-library-directory' option.

scripts/parse_ml_options.sh-subr.in:
scripts/mgnuc.in:
scripts/mmc.in:
scripts/mmake.in:
scripts/Mmake.vars.in:
scripts/Mmake.rules:
	Handle MERCURY_STDLIB_DIR and `--mercury-standard-library-directory'.

	Remove support for the MERCURY_C_INCL_DIR, MERCURY_MOD_LIB_DIRS
	and MERCURY_TRACE_LIB_DIRS environment variables -- they aren't
	used anywhere. MERCURY_C_INCL_DIR is being removed because the
	assumption it makes (that all header files are installed into
	a single directory) will not hold for much longer because the
	generated header files for hl* grades are grade dependent.

compiler/options.m:
compiler/compile_target_code.m:
	Add an option `--trace-init-file', used to specify `.init'
	files which should only be used when tracing is enabled,
	such as browser/mer_browse.init.

	Allow `--mercury-stdlib-dir' as an abbreviation for
	`--mercury-standard-library-directory'.

tools/lmc:
	Use options rather than environment variables.

doc/user_guide.texi:
	Document MERCURY_STDLIB_DIR, MERCURY_TRACE_LIB_MODS
	and the `--trace-init-file' mmc option.

	Remove documentation for the no longer used MERCURY_C_INCL_DIR,
	MERCURY_MOD_LIB_DIRS, MERCURY_TRACE_LIB_DIRS and
	MERCURY_NC_BUILTIN environment variables.
2002-04-19 14:59:37 +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
Simon Taylor
5c9f6f5841 Combine the options for ml and c2init. Once mmake has been
Estimated hours taken: 1
Branches: main

Combine the options for ml and c2init. Once mmake has been
altered to pass MLFLAGS to c2init users will be able to
mostly ignore the existence of c2init.

This change requires an installed compiler which uses `--init-c-file'
rather than `-o' to name c2init's output file. This is difficult to
test for in configure.in.

Bootstrap CVS tag: bootstrap_20011203_init_c_file_c2init_option

scripts/parse_ml_options.sh-subr.in:
	Parse the combined options for ml and c2init.

	The `-o' and `--output' options for c2init have been removed
	(`-o' conflicts with a linker option), use `--init-c-file' instead.

configure.in:
	Add parse_ml_options.sh-subr.in to the list of files to substitute.

scripts/ml.in:
scripts/c2init.in:
	Include parse_ml_options.sh-subr.

scripts/Mmakefile:
	ml and c2init depend on parse_ml_options.sh-subr.
2001-12-03 03:11:26 +00:00
Simon Taylor
161226cc22 This is the first part of a change to make c2init and ml take
Estimated hours taken: 0.25

This is the first part of a change to make c2init and ml take
the same set of options (the c2init options will be added as
an "Initialization options" section of the ml options). When
this change is complete, users will only need to add `--trace'
to MLFLAGS, not C2INITFLAGS as well. c2init is an implementation
detail that users shouldn't need to know about.

scripts/c2init.in:
	Remove the `-l' short form of the `--library' option,
	since it conflicts with the use of `-l' as a linker option.

	Add `--no-main' as a synonym for `--library', which will
	cause less confusion with the `--make-shared-lib' ml
	option. `--library' will still be accepted for backwards
	compatability because the C interface samples refer to it.

	Add `--init-c-file' as a synonym for `-o' and `--output'.
	The latter two will be removed after mmake and mmc are
	changed to use `--init-c-file' because they don't make
	sense as ml options.
2001-11-13 08:28:05 +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
018fc359f2 Delete some debugging code (`set -x') that zs left in
Estimated hours taken: 0.1

scripts/c2init.in:
	Delete some debugging code (`set -x') that zs left in
	(apparently accidentally) in his last commit.
2000-11-05 04:15:34 +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
Simon Taylor
247a5bd308 Fix a bug in the handling of the `--aditi' option -- it was
Estimated hours taken: 0.25

scripts/c2init.in:
	Fix a bug in the handling of the `--aditi' option -- it was
	performing a shift even though `--aditi' does not take an
	argument.
2000-05-12 05:13:33 +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
Zoltan Somogyi
22840901fd Fix potential problems with the way we were handling grade components: the
Estimated hours taken: 5

Fix potential problems with the way we were handling grade components: the
places that know about grade components were not being kept totally in sync.
This change fixes previous damage and aims to prevent future damage.

The file runtime/mercury_grade.h contains a list of all the files in the
compiler that know about grade components. All these files now process the
grade components in the same order, so that they can be checked for consistency
more easily.

runtime/mercury_grade.h:
	Add the list.

runtime/mercury_conf_param.h:
	Remove a comment about an obsolete grade component.

scripts/init_grade_options.sh-subr:
	Remove initializations of variables that do not correspond to grade
	components, add missing initializations of shell variables that do
	correspond to grade components, and concentrate the grade options
	component of usage messages here, to prevent double maintenance.

	Update list of user scripts.

scripts/final_grade_options.sh-subr:
	Add missing initializations in processing the --grade superoption.

	Standardize the order of processing options, and the indentation.

	Update list of user scripts.

scripts/c2init.in:
	Take the usage message for grade component options from
	init_grade_options.sh-subr.

scripts/mgnuc.in:
	Take the usage message for grade component options from
	init_grade_options.sh-subr.

	Standardize the order of processing grade options, and separate the
	processing of grade options and non-grade options.

scripts/ml.in:
	Take the usage message for grade component options from
	init_grade_options.sh-subr.

	Standardize the order of processing grade options. Process some missing
	ones.

compiler/handle_options.m:
	Standardize the order of processing grade options.

	Remove code to handle an obsolete grade component.
1999-11-09 01:45:43 +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
Zoltan Somogyi
c6812299c2 Remove support for --args simple. We don't use it, we won't use it even for
Estimated hours taken: 4.5

Remove support for --args simple. We don't use it, we won't use it even for
experiments, and it is unnecessary complication.

If anybody were using --args simple, this would need bootstrapping, but
since nobody does, there is no need, and this can be committed as an
ordinary change.

compiler/options.m:
doc/user_guide.texi:
scripts/*.in:
scripts/*.sh-subr:
	Remove the --args option.

compiler/globals.m:
	Remove the args_method global and its access predicates.

compiler/handle_options.m:
	Don't set the args_method global from the option.

compiler/arg_info.m:
	Remove support for --args simple. This allows us to remove a now
	redundant argument from an exported predicate.

compiler/mercury_compile.m:
	Remove the code for passing -DCOMPACT_ARGS to the C compiler.

compiler/bytecode_gen.m:
compiler/fact_table.m:
compiler/follow_vars.m:
compiler/live_vars.m:
compiler/call_gen.m:
	Don't pass the unnecessary argument to arg_info.

compiler/call_gen.m:
compiler/unify_gen.m:
	Remove now unnecessary assertions.

compiler/hlds_pred.m:
	Don't include an args_method in proc_infos; instead, include
	a slot that says whether the procedure's address is taken or not.
	(In most cases, this determined whether the args_method was
	simple or compact.) We will need this bool in the near future
	(when we generate layout structures for procedures whose address
	is taken).

	Modify the signatures of exported predicates to accommodate
	this change to the data structure.

compiler/hlds_out.m:
	Print the new slot, not the args_method.

compiler/lambda.m:
	When creating procedures from lambdas, set the address-taken slot
	to address_is_taken instead of setting up its args_method.

compiler/make_hlds.m:
	Minor changes to conform to the changes in the signatures of
	the predicates exported from hlds_pred.m.

compiler/check_typeclass.m:
compiler/clause_to_proc.m:
compiler/dnf.m:
compiler/magic.m:
compiler/magic_util.m:
compiler/modecheck_call.m:
compiler/pd_info.m:
compiler/post_typecheck.m:
compiler/unify_gen.m:
	Minor changes to conform to the changes in the signatures of
	the predicates exported from hlds_pred.m and make_hlds.m.

runtime/mercury_type_info.h:
	Remove the conditional definition of the macros that provided
	an argument-method-independent way of referring to the registers
	holding the inputs and outputs of e.g. unification procedures.
	We don't need the independence anymore, and using registers instead
	of macros in the code ensures that maintainers are aware of register
	reuse issues (e.g. they copy an input from r1 before overwriting it
	with an output).

runtime/mercury_conf_param.h:
runtime/mercury_grade.h:
	Remove support for the args method component of the grade.

runtime/mercury_ho_call.c:
runtime/mercury_tabling.c:
library/*.m:
	Conform to the changes in runtime/mercury_type_info.h by effectively
	applying the #defines appropriate to compact args by hand.

	Remove code and data structures only needed for simple args.
	Remove comments needed only in the presence of uncertainty about
	the args method.
1999-06-01 09:46:20 +00:00
Fergus Henderson
c66dbd7265 Include the grade options in the help message.
Estimated hours taken: 0.25

scripts/c2init.in:
	Include the grade options in the help message.
	Include the file `final_grade_options.sh-subr' so
	that options will get properly post-processed.
1999-04-26 03:10:23 +00:00
Fergus Henderson
77b319d2a5 Fix a bug where it was generating code that referred to
Estimated hours taken: 0.5

scripts/c2init.in:
	Fix a bug where it was generating code that referred to
	the initialization functions for the browser library
	even when `--trace' was not specified on the command line
	and the grade was not a debugging grade.
1999-03-21 04:40:31 +00:00
Simon Taylor
18430aaef1 Aditi compilation.
Estimated hours taken: 1200

Aditi compilation.

compiler/options.m:
	The documentation for these is commented out because the Aditi
	system is not currently useful to the general public.
	--aditi: enable Aditi compilation.
	--dump-rl: write the intermediate RL to `<module>.rl_dump'.
	--dump-rl-bytecode: write a text version of the bytecodes
		to `<module>.rla'
	--aditi-only: don't produce a `.c' file.
	--filenames-from-stdin: accept a list of filenames to compile
		from stdin. This is used by the query shell.
	--optimize-rl, --optimize-rl-cse, --optimize-rl-invariants,
	--optimize-rl-index, --detect-rl-streams:
		Options to control RL optimization passes.
	--aditi-user:
		Default owner of any Aditi procedures,
		defaults to $USER or "guest".
	--generate-schemas:
		write schemas for base relations to `<module>'.base_schema
		and schemas for derived relations to `<module>'.derived_schema.
		This is used by the query shell.

compiler/handle_options.m:
	Handle the default for --aditi-user.

compiler/hlds_pred.m:
compiler/prog_data.m:
compiler/prog_io_pragma.m:
compiler/make_hlds.m:
	Add some Aditi pragma declarations - `aditi', `supp_magic', `context',
	`naive', `psn' (predicate semi-naive), `aditi_memo', `aditi_no_memo',
	`base_relation', `owner' and `index'.
	Separate out code to parse a predicate name and arity.

compiler/hlds_pred.m:
	Add predicates to identify Aditi procedures.
	Added markers `generate_inline' and `aditi_interface', which
	are used internally for Aditi code generation.
	Add an `owner' field to pred_infos, which is used for database
	security checks.
	Add a field to pred_infos to hold the list of indexes for a base
	relation.

compiler/make_hlds.m:
	Some pragmas must be exported if the corresponding predicates
	are exported, check this.
	Make sure stratification of Aditi procedures is checked.
	Predicates with a mode declaration but no type declaration
	are no longer assumed to be local.
	Set the `do_aditi_compilation' field of the module_info if there
	are any local Aditi procedures or base relations.
	Check that `--aditi' is set if Aditi compilation is required.

compiler/post_typecheck.m:
	Check that every Aditi predicate has an `aditi__state' argument,
	which is used to ensure sequencing of updates and that Aditi
	procedures are only called within transactions.

compiler/dnf.m:
	Changed the definition of disjunctive normal form slightly
	so that a call followed by some atomic goals not including
	any database calls is considered atomic. magic.m can handle
	this kind of goal, and it results in more efficient RL code.

compiler/hlds_module.m:
compiler/dependency_graph.m:
	Added dependency_graph__get_scc_entry_points which finds
	the procedures in an SCC which could be called from outside.
	Added a new field to the dependency_info, the
	aditi_dependency_ordering. This contains all Aditi SCCs of
	the original program, with multiple SCCs merged where
	possible to improve the effectiveness of differential evaluation
	and the low level RL optimizations.

compiler/hlds_module.m:
	Add a field to record whether there are any local Aditi procedures
	in the current module.
	Added versions of module_info_pred_proc_info and
	module_info_set_pred_proc_info which take a pred_proc_id,
	not a separate pred_id and proc_id.

compiler/polymorphism.m:
compiler/lambda.m:
	Make sure that predicates created for closures in Aditi procedures
	have the correct markers.

compiler/goal_util.m:
	Added goal_util__switch_to_disjunction,
	goal_util__case_to_disjunct (factored out from simplify.m)
	and goal_util__if_then_else_to_disjunction. These are
	require because supplementary magic sets can't handle
	if-then-elses or switches.

compiler/type_util.m:
	Added type_is_aditi_state/1.

compiler/mode_util.m:
	Added partition_args/5 which partitions a list of arguments
	into inputs and others.

compiler/inlining.m:
	Don't inline memoed procedures.
	Don't inline Aditi procedures into non-Aditi procedures.

compiler/intermod.m:
	Handle Aditi markers.
	Clean up handling of markers which should not appear in `.opt' files.

compiler/simplify.m:
	Export a slightly different interface for use by magic.m.
	Remove explicit quantifications where possible.
	Merge multiple nested quantifications.
	Don't report infinite recursion warnings for Aditi procedures.

compiler/prog_out.m:
	Generalised the code to output a module list to write any list.

compiler/code_gen.m:
compiler/arg_info.m:
	Don't process Aditi procedures.

compiler/mercury_compile.m:
	Call magic.m and rl_gen.m.
	Don't perform the low-level annotation passes on Aditi procedures.
	Remove calls to constraint.m - sometime soon a rewritten version
	will be called directly from deforestation.

compiler/passes_aux.m:
	Add predicates to process only non-Aditi procedures.

compiler/llds.m:
compiler/llds_out.m:
	Added new `code_addr' enum members, do_{det,semidet,nondet}_aditi_call,
	which are defined in extras/aditi/aditi.m.

compiler/call_gen.m:
	Handle generation of do_*_aditi_call.

compiler/llds_out.m:
	Write the RL code for the module as a constant char array
	in the `.c' file.

compiler/term_errors.m:
compiler/error_util.m:
	Move code to describe predicates into error_util.m
	Allow the caller to explicitly add line breaks.
	Added error_util:list_to_pieces to format a list of
	strings.
	Reordered some arguments for currying.

compiler/hlds_out.m:
	Don't try to print clauses if there are none.

runtime/mercury_init.h:
util/mkinit.c:
scripts/c2init.in:
	Added a function `mercury__load_aditi_rl_code()' to the generated
	`<module>_init.c' file which throws all the RL code for the program
	at the database. This should be called at connection time by
	`aditi__connect'.
	Added an option `--aditi' which controls the output
	`mercury__load_aditi_rl_code()'.

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

Mmakefile:
bindist/Mmakefile:
	Don't distribute extras/aditi yet.

New files:

compiler/magic.m:
compiler/magic_util.m:
	Supplementary magic sets transformation. Report errors
	for constructs that Aditi can't handle.

compiler/context.m:
	Supplementary context transformation.

compiler/rl_gen.m:
compiler/rl_relops.m:
	Aditi code generation.

compiler/rl_info.m:
	Code generator state.

compiler/rl.m:
	Intermediate RL representation.

compiler/rl_util:
	Predicates to collect information about RL instructions.

compiler/rl_dump.m:
	Print out the representation in rl.m.

compiler/rl_opt.m:
	Control low-level RL optimizations.

compiler/rl_block.m:
	Break a procedure into basic blocks.

compiler/rl_analyse.m:
	Generic dataflow analysis for RL procedures.

compiler/rl_liveness.m:
	Make sure all relations are initialised before used, clear
	references to relations that are no longer required.

compiler/rl_loop.m:
	Loop invariant removal.

compiler/rl_block_opt.m:
	CSE and instruction merging on basic blocks.

compiler/rl_key.m:
	Detect upper/lower bounds for which a goal could succeed.

compiler/rl_sort.m:
	Use indexing for joins and projections.
	Optimize away unnecessary sorting and indexing.

compiler/rl_stream.m:
	Detect relations which don't need to be materialised.

compiler/rl_code.m:
	RL bytecode definitions. Automatically generated from the Aditi
	header files.

compiler/rl_out.m:
compiler/rl_file.m:
	Output the RL bytecodes in binary to <module>.rlo (for use by Aditi)
	and in text to <module>.rla (for use by the RL interpreter).
	Also output the schema information if --generate-schemas is set.

compiler/rl_exprn.m:
	Generate bytecodes for join conditions.

extras/aditi/Mmakefile:
extras/aditi/aditi.m:
	Definitions of some Aditi library predicates and the
	interfacing and transaction processing code.
1998-12-06 23:49:14 +00:00
David Overton
ed91b801be Fix some scripts in the tools directory to work with the new
Estimated hours taken: 0.5

Fix some scripts in the tools directory to work with the new
directories and library names.

tools/binary:
tools/binary_step:
tools/linear:
	Update these scripts to work properly with the new browser and
	trace directories and the renamed libraries.

Mmake.common.in:
scripts/c2init.in:
scripts/ml.in:
	Add tools/binary, tools/binary_step and tools/linear to the
	list of files that know about library names.
1998-10-09 05:41:58 +00:00
Zoltan Somogyi
f633c977f6 Update the comments about the other locations that know the names of
Estimated hours taken: 0.2

Mmake.common.in:
scripts/ml.in:
tools/bootcheck:
	Update the comments about the other locations that know the names of
	the libraries, now that c2init knows them too.

scripts/c2init.in:
	Add a comment about the other locations.
1998-10-01 09:11:10 +00:00
Fergus Henderson
1f6694098b Fix a bug introduced in zs's change to add two new directories.
Estimated hours taken: 0.5

Fix a bug introduced in zs's change to add two new directories.

scripts/c2init.in:
	Update the list of `.init' files to match the new names
	and to include the init file for the `browser' library.
1998-10-01 04:19:49 +00:00
Zoltan Somogyi
8ddce575d4 Introduce two new directories, trace and browser, containing libraries
Estimated hours taken: 10

Introduce two new directories, trace and browser, containing libraries
holding the C and Mercury code of the debugger respectively. (Although
the browser directory does not have a browser in it yet, the browser
should soon become its biggest component.) Take the opportunity to
rename the existing libraries, for consistency.

After this change, the linking order becomes:

	the object of the auto-generated init file
	program object files
	trace library (libmer_trace.a)
	browser library (libmer_browser.a)
	standard library (libmer_std.a)
	runtime library (libmer_rt.a)
	Boehm collector (libgc.a)

To avoid circularities, libraries cannot contain direct calls to
any routines that are defined in libraries (or object files) that
occur earlier in the above list.  Any such calls must be made into
indirect calls via function pointers.

In particular, there was a circularity caused by the library calling
MR_trace() which invokes the tracer which in turn invokes the
library.  This circularity was broken by having MR_trace(),
which is defined in the runtime, call the tracer indirectly via
a global variable named MR_trace_func_ptr.  This global variable
is initialized by the auto-generated *_init.c file.

To avoid linking in the tracer even when it is not being used,
this global variable is only set to point to MR_trace_real()
if you're using a debugging grade or if c2init was invoked
with the `-t' flag.  Otherwise it is set to MR_trace_fake()
which just prints an error message telling the user to
rebuild the executable with debugging enabled.

Makefile.DLLs:
	Reserve random locations for the two new libraries. Whether they work
	will be decided by testing on Windows.

Mmake.common.in:
	Add variables naming the new directories, and create variables
	naming the libraries.

Mmakefile:
	Add targets for the new directories, and modify existing rules
	as appropriate.

browser/Mmakefile:
	Mmakefile for the new directory, modelled on library/Mmakefile.

browser/browser_library.m:
	Umbrella file for the new directory, modelled on library/library.m.

{browser,library}/debugger_interface.m:
	Moved this file from library to browser without change.

browser/help.m:
	A new module for the help system of the debugger. Not yet used.

compiler/Mmakefile:
	Update to refer to the new directories and libraries where
	appropriate.

compiler/mercury_compile.m:
	If we are doing tracing, then pass -t instead of -i to c2init.

compiler/modules.m:
	When generating the .dep file, get the grade flags passed to c2init.

doc/Mmakefile:
	Remove the special treatment of library/debugger_interface.m.

library/Mmakefile:
	Update to refer to the new directories and libraries where
	appropriate, and to conform to the new name of the library.

library/library.m:
	Do not import debugger_interface.

profiler/Mmakefile:
	Update to refer to the new directories and libraries where
	appropriate.

runtime/Mmakefile:
	Update to refer to the new directories and libraries where
	appropriate, and to conform to the new name of the library.

	Remove references to files being moved to the trace directory.

runtime/mercury_init.h:
	Refer to the automatically generated dll header file by its new name
	(renamed because the runtime library is renamed).

	Add declarations to support the new global variable MR_trace_func_ptr.

runtime/mercury_memory_handlers.c:
runtime/mercury_memory_zones.c:
runtime/mercury_misc.c:
	Remove inappropriate #includes of "mercury_trace.h", and substitute
	a #include of "mercury_trace_base.h" if necessary.

{runtime,trace}/mercury_trace.[ch]:
{runtime,trace}/mercury_trace_external.[ch]:
{runtime,trace}/mercury_trace_internal.[ch]:
	Move these files from the runtime to the trace directory.

	The only changes are the removal from mercury_trace.h of declarations
	added to runtime/mercury_trace_base.h, and the change from MR_trace
	to MR_trace_real.

runtime/mercury_trace_base.[ch]:
	Define MR_trace(), which does an indirect call through
	MR_trace_func_ptr if the event should be traced.

	Define MR_trace_fake, which just prints an error message.
	Its address will be assigned to MR_trace_func_ptr if tracing
	is not enabled.

	Define the types needed by the signature of MR_trace.

	Fix an old bug: s/MERCURY_TRACE_PERMANENT_H/MERCURY_TRACE_BASE_H/.

runtime/mercury_wrapper.[ch]:
	Add the new global variable MR_trace_func_ptr.

scripts/c2init.in:
	Add a new option, -t/--trace, which enables tracing by causing the
	address of MR_trace_real to be assigned to MR_trace_func_ptr.

	Have this option be implied by the grade. Also have the old option
	-i (need initialization code) be implied by the grade, as well as by
	-t.

scripts/ml.in:
	Include the new libraries in the link command.

tests/debugger/Mmakefile:
	Include -t instead of -i in the list of c2init options. (-t implies
	-i.)

tools/bootcheck:
	Copy and build the new directories as appropriate. The trace directory
	is treated like the runtime, the browser directory is treated like the
	library.

trace/Mmakefile:
	Mmakefile for the new directory, modelled on runtime/Mmakefile.

util/mkinit.c:
	Add the new option -t, as discussed above.
	Mmakefile for the new directory, modelled on runtime/Mmakefile.

util/Mmakefile:
	Specify -O0, since with the default optimization level, gcc on
	cyclone ignores the assignment of TRUE to need_tracing when -t is
	given (!!!).
1998-09-29 05:12:06 +00:00
Zoltan Somogyi
4ada219856 Reorganize the label table to better fit the needs of accurate gc
Estimated hours taken: 25

Reorganize the label table to better fit the needs of accurate gc
and the tracer, and reduce the size of executables.

With these changes, the size of hello world, compiled with static
Mercury libraries but dynamic C libraries, goes from 150+ Kb to
138+ Kb, much of which is beyond our control (e.g. Boehm gc).

runtime/mercury_label.[ch]:
	The old label table contained both entry labels and internal labels,
	even though they had different kinds of layouts associated with them
	(proc layouts and label layouts respectively). The two kinds of labels
	have different usage patterns. Internal labels are needed for stack
	walking, which requires random access by exact label address. Entry
	labels are needed for finding which procedure a program counter is in
	for accurate GC, which requires lower-bound inexact search.

	The module now has two separate data structures for the two
	different kinds of labels. Internal labels are in a hash table,
	as before. Entry labels are in an array (resized on demand),
	which is sorted for binary search. The entry label array and
	its associated functions are present only if they are needed.

runtime/mercury_goto.h:
	Call the new functions in mercury_label.c from the
	init_{local,label,entry}{,_sl} macros.

runtime/mercury_misc.[ch]
	Use the new functions in mercury_label. Fix some software rot,
	so that the code now compiles with MR_DEBUG_GOTOS. (It still does not
	compile with MR_LOWLEVEL_DEBUG, but the fix for that would conflict
	with Tom's planned change to zone handling, so that fix should be
	done after Tom is done.)

	Note that mercury_misc.c still defines newmem() and oldmem()
	although they are declared in mercury_std.h.

runtime/mercury_stack_trace.c:
	Use the new functions in mercury_label. As a result, we also need
	to make a few more pointers const.

runtime/mercury_table.[ch]:
	Add a new traversal predicate to support a new function in
	mercury_label.c. (That function is not used yet, but will be soon.)

runtime/mercury_trace.[ch]:
runtime/mercury_trace_base.[ch]:
	Split the old mercury_trace module into two. The functions and
	variables that will always be linked in (because they are referenced
	from modules such as mercury_wrapper which are always needed) are
	now in mercury_trace_base; the other functions and variables
	stay in mercury_trace. This way, mercury_trace.o will be linked in
	only if some module was compiled with execution tracing. Since
	mercury_trace.o drags in mercury_trace_internal.o which drags in
	everything needed for printing arbitrary terms (which is a lot),
	this can be a significant win.

runtime/Mmakefile:
	Include the new module in the library.

runtime/mercury_wrapper.c:
runtime/mercury_conf_param.h:
	Remove some obsolete MERCURY_OPTIONS options, which would be
	difficult to support with the new label table.

	Move the #ifdefs around the -P option, so that programs not
	compiled with MR_THREAD_SAFE will accept but ignore the option,
	instead of aborting with the usage message.

	Replace the long usage message for malformed MERCURY_OPTIONS
	environment variables with a pointer to the user's guide.
	This saves about 1 Kb on every executable.

runtime/mercury_conf_param.h:
	Document MR_STACK_TRACE_THIS_MODULE.

util/mkinit.c:
	Add a new flag, -i. If this flag is given, include the initialization
	code regardless of grade. If it is not given, include the init code
	only if the grade requires it.

	The -i should be given if you want the executable to support stack
	tracing, or uplevel printing in execution tracing, at the cost of
	making the executable link in the init functions of all the modules
	in the library.

	Put the option handling code in alphabetical order.

	Fix the wrong default name of the entry point. (It only worked because
	c2init was always overriding the default.)

scripts/c2init.in:
	Pass through the -i flag to mkinit.

	Put the option handling code in alphabetical order.

compiler/mercury_compile.m:
	If the trace level specifies any kind of tracing, pass -i to c2init.

tests/debugger/Mmakefile:
	Add -i to the c2init flags.

tests/debugger/*
	Update the other half the test cases (those which assume a traced
	library) to conform to the changes in the debugger interface.
	The first half were updated earlier.

doc/user_guide.texi:
	In the environment variable section, modify the entry for
	MERCURY_OPTIONS to document all the options it makes sense
	for non-developers to use.

	Slight changes to two other parts of the guide to reduce duplication
	with the new material.
1998-07-03 02:36:09 +00:00
Fergus Henderson
38ae5fe0c5 Fix a bug which caused link errors in some grades for some test cases
Estimated hours taken: 1

Fix a bug which caused link errors in some grades for some test cases
where the module name wasn't the same as the file name, and which
probably would have caused runtime errors in some grades for test
cases using nested modules.

compiler/modules.m:
	Call $(C2INIT) with $(foo.cs) instead of $(foo.ms).
	This is necessary now that a single .m file can get compiled
	to multiple .c files, if it contains nested modules,
	or to a .c file whose name reflects the module name rather
	than the source file name.

util/mkinit.c:
scripts/c2init.in:
	For efficiency, change c2init and mkinit so that when c2init's
	arguments are `.c' files, it computes the init function based
	on the filename (like it used to do with `.m' files), rather
	than by reading the file contents and searching for "** INIT"
	comments.  Add a new option `-x' (`--extra-inits') which keeps
	the old behaviour.

compiler/modules.m:
scripts/Mmake.rules:
	Instead of deleting the `_init.c' file every time we recreate
	the `.dep' file, just tell make that the `_init.c' file depends on
	the `.dep' file, so that make will remake it if the `.dep' file
	changes.  (I don't know why I didn't do it that way in the
	first place.)
1998-05-30 13:34:17 +00:00
Fergus Henderson
a6357c33bb Fix a small quoting bug in my previous change.
Estimated hours taken: 0.1

scripts/c2init.in:
	Fix a small quoting bug in my previous change.
1997-09-06 12:04:15 +00:00
Fergus Henderson
8bc9cf2d1c Use only libmercury.init and runtime.init in $MERCURY_MOD_LIB_DIR,
Estimated hours taken: 0.25

scripts/c2init.in:
	Use only libmercury.init and runtime.init in $MERCURY_MOD_LIB_DIR,
	rather than using `$MERCURY_MOD_LIB_DIR/*'.  This avoids problems
	if other .init files (e.g. cfloat_lib.init) are installed in
	the same directory.
1997-09-06 11:44:02 +00:00
Fergus Henderson
d1cc2ddee4 Split up the startup interface so that there are seperate
Estimated hours taken: 8

Split up the startup interface so that there are seperate
initialization and termination functions, rather than just a single
mercury_runtime_main() function which does everything.
Also change things so that the io__state data is stored in global
variables.

runtime/init.h:
util/mkinit.c:
runtime/wrapper.h:
runtime/wrapper.mod:
	Move declarations for stuff defined in wrapper.mod from init.h
	to wrapper.h.  Clean up the remainder of init.h so that it
	is clear which parts are interface and which are just there
	for use by *_init.c.

	Change the automatically-generated *_init.c files
	so that they call mercury_runtime_init(),
	mercury_runtime_main(), and mercury_runtime_terminate(),
	rather than just mercury_runtime_main().
	Define these new two functions in wrapper.mod.

	Delete the library_entry_point; change do_interpreter
	to call program_entry_point directly, rather than via
	library_entry_point.

runtime/engine.h:
runtime/engine.mod:
	Add new function terminate_engine().
	Delete the function start_mercury_engine();
	move the code that used to be there to the end
	of init_engine().

runtime/context.h:
runtime/context.mod:
	Add new function shutdown_processes().
	(The current implementation is just a stub.)
	Add a call to debug_memory() in init_process_context().

runtime/memory.h:
runtime/memory.c:
	Export the debug_memory() function, for use by context.c.

library/io.m:
library/io.nu.nl:
	Change things so that the io__state data is stored in C global
	variables (or, for Prolog, using assert/retract), rather than
	passing around a data structure.  (Actually we still pass the
	data structure around, but it is just a dummy Word that never
	gets used.)

	Delete the old hand-coded io__run predicate, which was
	the library entry point; instead export C functions
	ML_io_init_state() and ML_io_finalize_state().	Move the
	code for handling profiling from io__run to do_interpreter
	in runtime/wrapper.mod.

scripts/c2init.in:
	Change the default entry point from io__run_0_0 to main_2_0
1997-09-05 22:38:58 +00:00
Fergus Henderson
04b720630b Update the copyright messages so that (a) they contain the correct years
and (b) they say "Copyright (C) ... _The_ University of Melbourne".
1997-07-27 15:09:59 +00:00
Fergus Henderson
8ce103cc76 Add Unix-style man pages for most of the Mercury development tools.
scripts/c2init.in:
scripts/mmake.in:
scripts/msc.in:
	Small changes to the help messages to make them come out
	better when converted to man pages.

scripts/mgnuc.in:
	Add a `--help' option.
1997-02-07 14:17:41 +00:00
Fergus Henderson
d14bdd2eee More stuff to support non-Mercury main() programs.
Estimated hours taken: 0.5

More stuff to support non-Mercury main() programs.

util/c2init.c:
	Implement a new `-l' / `--libary' option.
	If this option is enabled, we pass `-l' to mkinit,
	which has the end result that we don't emit a main(),
	but instead we emit a mercury_main(argc, argv, stack_bottom)
	function that can be called from C.
1997-02-01 00:12:06 +00:00
Fergus Henderson
62377e8bf2 Fix a portability problem: ULTRIX's /bin/sh does not understand
Estimated hours taken: 0.5

scripts/{c2init,mnc,mnl,msc,msl}.in:
	Fix a portability problem: ULTRIX's /bin/sh does not understand
	`shift 2', so I've replaced all occurrences of this with
	`shift; shift'.  (Thanks to Jeff Schultz for the bug report.)
1996-05-13 06:12:48 +00:00
Fergus Henderson
8cf86fd1ef Replace all uses of
scripts/*.in:
	Replace all uses of

		... "$@" ...

	with

		case $# in
			0) ... ...
			*) ... "$@" ...
		esac

	since on ULTRIX and OSF, "$@" does the wrong thing if $# is 0.
1995-09-18 07:14:09 +00:00
Fergus Henderson
eaf2c48c34 Don't use `getopts', since it is not portable.
c2init.in:
	Don't use `getopts', since it is not portable.
	Add long versions of all the options.
	Improve usage message.
1995-07-21 08:13:26 +00:00
Zoltan Somogyi
1849d45e77 Fixed usage message.
c2init.in:
	Fixed usage message.
1995-05-29 01:49:39 +00:00
Fergus Henderson
60bc8f3ef9 Change "#!/bin/sh" to "#! /bin/sh", since the latter is more portable.
scripts/*.in:
	Change "#!/bin/sh" to "#! /bin/sh", since the latter is more portable.
	Add "# @configure_input@" to the start of each file.
1995-05-19 08:17:46 +00:00
Fergus Henderson
1a468516f1 Another correction to the comments.
scripts/c2init.in:
	Another correction to the comments.
1995-05-19 07:35:01 +00:00