Commit Graph

12 Commits

Author SHA1 Message Date
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
Thomas Conway
541ab2829f Add a new option for deep profiling to the compiler and the scripts.
Estimated hours taken: 0.5

Add a new option for deep profiling to the compiler and the scripts.

compiler/options.m:
	Add the new profiling options `profile-deep' and `deep-profiling'.
compiler/handle_options.m:
	Add code to handle the above options.

scripts/init_grade_options.sh-subr:
	Initialize the profile_deep option to false.
scripts/parse_grade_options.sh-subr:
	Add code handle the deep-profiling options.
1999-09-13 04:51:20 +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
Zoltan Somogyi
dc03496d06 Rewrite significant parts of minimal model tabling so that it works
Estimated hours taken: 130

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

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

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

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

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

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

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

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

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

	Rename the predicates referred to by table_gen.m.

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

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

runtime/mercury_conf_param.h:
	Document MR_USE_MINIMAL_MODEL.

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

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

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

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

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

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

	Improve the documentation considerably.

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

	Ensure that global names start with MR_.

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

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

	Fix a sorting error.

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

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

trace/mercury_trace_internal.c:
	If MR_USE_MINIMAL_MODEL is defined, add a new command to print
	the generator stack. (The new command is deliberately not documented
	in doc/mdb_doc yet, since (a) it is intended for developers only,
	and (b) there is no way to test MR_USE_MINIMAL_MODEL in mdb_doc.)
1999-04-20 11:48:56 +00:00
Thomas Conway
5927080429 When parsing a --grade option, set all the grade options to the
Estimated time taken: 1

sripts/parse_grade_options.sh-subr:
	When parsing a --grade option, set all the grade options to the
	appropriate `off' value. As a result the last --grade option overides
	all earlier ones.

compiler/handle_options.m:
	Add a table for the `off' values for grade options, and reset the
	grade options to those values when processing a --grade option.
1998-09-22 22:57:11 +00:00
Fergus Henderson
1665b44c55 A bug fix from Warwick Harvey.
Estimated hours taken: 0.25

A bug fix from Warwick Harvey.

scripts/parse_grade_options.sh-subr:
	If a grade is specified, the GC method should default
	to `none' rather than `conservative'.
1998-09-14 10:40:47 +00:00
Thomas Conway
b1aa225ce3 This change makes the parsing of GRADE/--grade strings more flexible.
Estimated hours taken: 4

This change makes the parsing of GRADE/--grade strings more flexible.
The GRADE string can now have its components given in any order. The
only places that depend on the order are those that use the grade as
part of a pathname: ml and install_grades. There is also a new option
to the compiler `--output-grade-string' which prints the grade string
for the set of options given to mmc/mmake.

NEWS:
	mention the changes.

compiler/handle_options.m:
	Reimplement convert_grade_option to accept a grade string with
	its components in any order. The conversion is now table-driven,
	which should make it easier to add new dimensions to the grade
	and new values to existing ones.

	Reimplement compute_grade to use the same table as
	convert_grade_option.

compiler/mercury_compile.m:
	If --output-grade-string option was given, just compute the
	grade string and print it.

compiler/options.m:
	Add the --output-grade-string option.

library/list.m:
	Add an extra mode to list__foldl2 (gee, it would be nice to be
	able to make higher order predicates polymorphic in their
	determinism).

scripts/ml.in:
	Include .par in the grade string. (bugfix)

scripts/parse_grade_options.sh-subr:
	split the grade string into . separated pieces and process them
	in a loop, setting the appropriate options.

doc/user_guide.texi:
	Add documentation on --output-grade-string.
	Change the description of how grades are handled to match
	the implementation. Add a some missing bits.
1998-07-27 01:05:20 +00:00
Thomas Conway
a70b59e83c Add a test to find the number of words needed to represent a
configure.in:
        Add a test to find the number of words needed to represent a
        synchronization term.

boehm_gc/gc.h:
        fix a declaration by replacing the args () with (void).
boehm_gc/solaris_pthreads.c:
        add a missing include
        check the return values of pthread calls.

compiler/*.m:
        Add handling for the new HLDS goal type par_conj.
        Add handling for the four new LLDS instructions:
                init_sync_term
                fork
                join_and_terminate
                join_and_continue

compiler/code_info.m:
        add a new alternative for slot_contents - sync_term.

compiler/handle_options.m:
        add .par as part of the grade

compiler/hlds_goal.m:
        add the new goal type par_conj.

compiler/instmap.m:
        add instmap__unify which takes a list of instmaps
                and abstractly unifies them.
        add unify_instmap_delta which tajes two instmap deltas
                and abstractly unifies them.

compiler/llds.m:
        add the new llds instructions.

compiler/mode_info.m:
        add par_conj as a lock reason.

library/Makefile:
        work around a bug in the solaris version pthread.h

library/benchmarking.m:
        reference the stack zones from the engine structure
        rather than from global variables.

library/{nc,sp}_builtin.nl:
        add an op declaration for &.

library/std_util.m:
        change references to global variables to references inside
        the engine structure.

runtime/Mmakefile:
        add mercury_thread.{c,h}
        add THREADLIBS to the libraries

runtime/*.{c,h}
        Remove some old junk from the previous processes/shrd-mem
        changes that found their way into the repository.
        Add MR_ prefixes to lots of names.

runtime/mercury_context.c:
        Add init_thread_stuff for creating and initializing a
        context structure for the current thread.

runtime/mercury_context.h:
        add a field to the mercury context which stores the thread id
        of the thread where this context originated.
        add various macros for implementing the new llds instructions.

runtime/mercury_engine.c:
        initialize the engine structure, rather than a bunch of globals.

runtime/mercury_engine.h:
        declare the mercury_engine structure.

runtime/mercury_regorder.h:
        if MR_THREAD_SAFE, and there is at least one global register
        then use mr0 as a pointer to the mercury engine structure.

scripts/init_grade_options.sh-subr
        add thread_safe

scripts/mgnuc.in
        add THREAD_OPTS

scripts/ml.in:
        add THREAD_LIBS
1998-06-09 02:16:31 +00:00
Fergus Henderson
fcdf5e117b Fix a cut-and-paste error in the handling of `debug' grade.
Estimated hours taken: 0.1

scripts/parse_grade_options.sh-subr:
	Fix a cut-and-paste error in the handling of `debug' grade.
	(Thanks to Warwick Harvey for reporting this bug.)
1998-05-27 13:47:36 +00:00
Fergus Henderson
6921e0e015 Add a `--debug' option for Mercury-level debugging
Estimated hours taken: 6

Add a `--debug' option for Mercury-level debugging
using the trace-based debugger.

scripts/init_grade_options.sh-subr:
scripts/parse_grade_options.sh-subr:
scripts/mgnuc.in:
scripts/ml.in:
compiler/options.m:
compiler/handle_options.m:
compiler/mercury_compile.m:
	Split the old `--debug' option into `--low-level-debug'
	(formerly the absence of -DSPEED, now handle by -DLOWLEVEL_DEBUG)
	and `--c-debug' (passes -g to C compiler).
	Delete the old `debug' grade.
	Add support for new options `--require-tracing'
	(makes --trace minimum equivalent to --trace interfaces,
	and passes -DMR_REQUIRE_TRACING to C compiler)
	`--stack-trace' (passes -DMR_STACK_TRACE to C compiler;
	actually this one was already supported)
	and `--debug' (implies previous two),
	with corresponding grade modifiers `.trace', `.strce', and `.debug'.
	Actually I think there's little point in specifying just one
	of `--require-tracing' and `--stack-trace' so for the moment
	I'm just providing `--debug': the code for the more fine-grained
	options and grade modifiers has been added but commented out.

runtime/mercury_conf_param.h:
	Document the new configuration parameter MR_REQUIRE_TRACING
	and the existing but undocumented parameter MR_STACK_TRACE.

runtime/mercury_grade.h:
	Include MR_REQUIRE_TRACING in the mangled grade identifier.

compiler/globals.m:
compiler/handle_options.m:
compiler/options.m:
	Allow new tracing type `--trace default', and make it the default.
	This gets replaced with `full' if require_tracing is yes
	or `minimal' if require_tracing is no.
	Also `--trace minimum' gets replaced with `interface' if
	require_tracing is yes.

doc/user_guide.texi:
	Document the new `--debug', `--low-level-debug', and `--c-debug'
	options.

scripts/mgnuc.in:
compiler/mercury_compile.m:
doc/user_guide.texi:
	Change things so that `--c-debug' does not imply `--no-c-optimize'.

configure.in:
	Add `-fomit-frame-pointer' to CFLAGS_FOR_GOTOS on alpha-*.
	Empirically, this seems to be needed, otherwise lots of
	the test cases fail when compiled with `--no-c-optimize'.
	(It might also be needed for other architectures, I don't know.)
1998-05-20 11:11:57 +00:00
Fergus Henderson
e6ac077bae Add support for memory profiling.
Estimated hours taken: 40 (+ unknown time by Zoltan)

Add support for memory profiling.

(A significant part of this change is actuallly Zoltan's work.  Zoltan
did the changes to the compiler and a first go at the changes to the
runtime and library.  I rewrote much of Zoltan's changes to the runtime
and library, added support for the new options/grades, added code to
interface with mprof, did the changes to the profiler, and wrote the
documentation.)

[TODO: add test cases.]

NEWS:
	Mention support for memory profiling.

runtime/mercury_heap_profile.h:
runtime/mercury_heap_profile.c:
	New files.  These contain code to record heap profiling information.

runtime/mercury_heap.h:
	Add new macros incr_hp_msg(), tag_incr_hp_msg(),
	incr_hp_atomic_msg(), and tag_incr_hp_atomic_msg().
	These are like the non-`msg' versions, except that if
	PROFILE_MEMORY is defined, they also call MR_record_allocation()
	from mercury_heap_profile.h to record heap profiling information.
	Also, fix up the indentation in lots of places.

runtime/mercury_prof.h:
runtime/mercury_prof.c:
	Added code to dump out memory profiling information to files
	`Prof.MemoryWords' and `Prof.MemoryCells' (for use by mprof).
	Change the format of the `Prof.Counts' file so that the
	first line says what it is counting, the units, and a scale
	factor.  Prof.MemoryWords and Prof.MemoryCells can thus have
	exactly the same format as Prof.Counts.
	Also cleaned up the interface to mercury_prof.c a bit, and did
	various other minor cleanups -- indentation changes, changes to
	use MR_ prefixes, additional comments, etc.

runtime/mercury_prof_mem.h:
runtime/mercury_prof_mem.c:
	Rename prof_malloc() as MR_prof_malloc().
	Rename prof_make() as MR_PROF_NEW() and add MR_PROF_NEW_ARRAY().

runtime/mercury_wrapper.h:
	Minor modifications to reflect the new interface to mercury_prof.c.

runtime/mercury_wrapper.c:
runtime/mercury_label.c:
	Rename the old `-p' (primary cache size) option as `-C'.
	Add a new `-p' option to disable profiling.

runtime/Mmakefile:
	Add mercury_heap_profile.[ch].
	Put the list of files in alphabetical order.
	Delete some obsolete stuff for supporting `.mod' files.
	Mention that libmer_dll.h and libmer_globals.h are
	produced by Makefile.DLLs.

runtime/mercury_imp.h:
	Mention that libmer_dll.h is produced by Makefile.DLLs.

runtime/mercury_dummy.c:
	Change a comment to refer to libmer_dll.h rather than
	libmer_globals.h.

compiler/llds.m:
	Add a new field to `create' and `incr_hp' instructions
	holding the name of the type, for heap profiling.

compiler/unify_gen.m:
	Initialize the new field of `create' instructions with
	the appropriate type name.

compiler/llds_out.m:
	Output incr_hp_msg() / tag_incr_hp_msg() instead of
	incr_hp() / tag_incr_hp().

compiler/*.m:
	Minor changes to most files in the compiler back-end to
	accomodate the new field in `incr_hp' and `create' instructions.

library/io.m:
	Add `io__report_full_memory_stats'.

library/benchmarking.m:
	Add `report_full_memory_stats'.  This uses the information saved
	by runtime/mercury_heap_profile.{c,h} to print out a report
	of memory usage by procedures and by types.
	Also modify `report_stats' to print out some of that information.

compiler/mercury_compile.m:
	If `--statistics' is enabled, call io__report_full_memory_stats
	at the end of main/2.  This will print out full memory statistics,
	if the compiler was compiled with memory profiling enabled.

compiler/options.m:
compiler/handle_options.m:
runtime/mercury_grade.h:
scripts/ml.in:
scripts/mgnuc.in:
scripts/init_grade_options.sh-subr:
scripts/parse_grade_options.sh-subr:
	Add new option `--memory-profiling' and new grade `.memprof'.
	Add `--time-profiling' as a new synonym for `--profiling'.
	Also add `--profile-memory' for more fine-grained control:
	`--memory-profiling' implies both `--profile-memory' and
	`--profile-calls'.

scripts/mprof_merge_runs:
	Update to handle the new format of Prof.Counts and to
	also merge Prof.MemoryWords and Prof.MemoryCells.

profiler/options.m:
profiler/mercury_profile.m:
	Add new options `--profile memory-words' (`-m'),
	`--profile memory-cells' (`-M') and `--profile time' (`-t').
	Thes options make the profiler select a different count file,
	Prof.MemoryWords or Prof.MemoryCells instead of Prof.Counts.
	specific to time profiling.

profiler/read.m:
profiler/process_file.m:
profiler/prof_info.m:
profiler/generate_output.m:
	Update to handle the new format of the counts file.
	When reading the counts file, look at the first line of
	the file to determine what is being profiled.

profiler/globals.m:
	Add a new global variable `what_to_profile' that records
	what is being profiled.

profiler/output.m:
	Change the headings to reflect what is being profiled.

doc/user_guide.texi:
	Document memory profiling.
	Document new options.

doc/user_guide.texi:
compiler/options.m:
	Comment out the documentation for `.proftime'/`--profile-time',
	since doing time and call profiling seperately doesn't work,
	because the code addresses change when you recompile with a
	different grade.  Ditto for `.profmem'/`--profile-memory'.
	Also comment out the documentation for
	`.profcalls'/`--profile-calls', since it is redundant --
	`.memprof' produces the same information and more.

configure.in:
	Build a `.memprof' grade.  (Hmm, should we do this only
	if `--enable-all-grades' is specified?)
	Don't ever build a `.profcalls' grade.
1997-12-05 15:58:34 +00:00
Fergus Henderson
eb7bcf0fd9 Change mgnuc and ml to support the same
compilation model options as mmc.
Allow the user to mix `--grade foo' options with
other options that affect the grade such as `--profiling'.
Compute the final grade to link with from the options.

Also add a few new options and grade modifiers.

compiler/options.m:
compiler/mercury_compile.m:
	Add `--profile-time' and `--profile-calls' options.
	Change `--profiling' to now just imply both of those.
	Add `--pic-reg' option (just implies `-DPIC_REG' in cflags).

compiler/handle_options.m:
	Add support for grade modifiers `.proftime' and `.profcalls'.
	Make `.debug' a grade modifier, rather than having a base
	grade `debug'.

scripts/init_grade_options.sh-subr:
scripts/parse_grade_options.sh-subr:
	New files containing sh subroutines for parsing grade-related
	options.

configure.in:
bindist/bindist.configure.in:
	Use AC_SUBST_FILE to allow #inclusion of the above-mentioned
	`.sh-subr' files.

scripts/ml.in:
scripts/mgnuc.in:
	Use the above-mentioned sh subroutines.

scripts/ml.in:
compiler/mercury_compile.m:
compiler/handle_options.m:
	Compute the final grade to link with from the various
	grade-related options.

scripts/mgnuc.in:
	Support the `--inline-alloc' option.

doc/user_guide.texi:
README.Linux:
	Document the above changes.
1997-10-08 13:16:33 +00:00