Commit Graph

28 Commits

Author SHA1 Message Date
Zoltan Somogyi
04e614485d Implement deep profiling; merge the changes on the deep2 branch back
Estimated hours taken: 500
Branches: main

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

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

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

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

Mmakefile:
	Add targets for the new directory.

	Add support for removing inappropriate files from directories.

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

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

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

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

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

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

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

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

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

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

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

deep_profiler/measurements.m:
	Operations on profiling measurements.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

	Add a mechanism for getting proc_ids for procedure clones.

	Remove next_proc_id, an obsolete and unused predicate.

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

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

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

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

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

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

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

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

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

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

	Improve formatting of the generated C code.

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

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

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

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

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

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

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

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

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

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

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

	Add support for watching the value at a given address.

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

	Print register contents only if -dr is specified.

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

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

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

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

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

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

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

	Add support for watching the value at a given address.

runtime/Mmakefile:
	Mention all the added files.

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

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

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

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

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

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

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

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

tests/*/Mmakefile:
tests/*/*/Mmakefile:
	In deep profiling grades, switch off the tests that test features
	that don't work with deep profiling, either by design or because
	the combination hasn't been implemented yet.
2001-05-31 06:00:27 +00:00
Zoltan Somogyi
7add5e0b0d Disable value numbering, now that it is no longer needed.
Estimated hours taken: 0.5
Branches: main

Disable value numbering, now that it is no longer needed. The value numbering
source files are not deleted from the CVS repository, since that would make
their restoration (in the unlikely event that this is needed) inconvenient,
but they will no longer be compiled or included in compiler executables.

doc/user_guide.texi:
compiler/options.m:
	Delete the options dealing with value numbering.

compiler/optimize.m:
	Do not invoke value numbering.

compiler/handle_options.m:
	Delete code that handles implications involving value numbering.

compiler/opt_debug.m:
	Delete code for debugging value numbering, since leaving it in
	would require importing value numbering modules and would thus drag
	them into the compiler executable.

compiler/value_number.m:
compiler/vn_block.m:
compiler/vn_cost.m:
compiler/vn_debug.m:
compiler/vn_filter.m:
compiler/vn_flush.m:
compiler/vn_order.m:
compiler/vn_table.m:
compiler/vn_temploc.m:
compiler/vn_type.m:
compiler/vn_util.m:
compiler/vn_verify.m:
	Delete these now obsolete modules.

compiler/notes/compiler_design.html:
	Delete mentions of value numbering and its modules.

tests/general/accumulator/Mmakefile:
tests/hard_coded/Mmakefile:
	Remove references to options removed by this change.
2001-05-15 07:12:04 +00:00
Zoltan Somogyi
9c58f97e3b Add a new optimization, --use-local-vars, to the LLDS backend.
Estimated hours taken: 20
Branches: main

Add a new optimization, --use-local-vars, to the LLDS backend. This
optimization is intended to replace references to fake registers and stack
slots with references to temporary variables in C code, since accessing these
should be cheaper.

With this optimization and one for delaying construction unifications,
the eager code generator should generate code at least good as that produced by
the old value numbering pass. This should make it possible to get rid of value
numbering, which is much harder to maintain.

compiler/use_local_vars.m:
	New module containing the optimization.

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

compiler/exprn_aux.m:
	Add new utility predicates for use by use_local_vars.

	If --debug-opt is specified, do not dump instruction sequences to
	standard output. Instead, put them in separate files, where they can be
	compared more easily.

compiler/options.m:
	Add the --use-local-vars option to control whether the use_local_vars
	pass gets run.

compiler/llds.m:
	Add liveness information to the c_code and pragma_foreign_code LLDS
	instructions, in order to allow use_local_vars to work in the presence
	of automatically-generated C code (e.g. by debugging).

compiler/livemap.m:
	Use the new liveness information to generate useful livemap information
	even in the presence of automatically generated C code.

compiler/code_gen.m:
compiler/code_info.m:
compiler/dupelim.m:
compiler/frameopt.m:
compiler/llds_common.m:
compiler/llds_out.m:
compiler/middle_rec.m:
compiler/opt_debug.m:
compiler/opt_util.m:
compiler/pragma_c_gen.m:
compiler/trace.m:
compiler/vn_block.m:
compiler/vn_cost.m:
compiler/vn_filter.m:
compiler/vn_verify.m:
	Provide and/or ignore this additional liveness information.

compiler/wrap_block.m:
	The post_value_number pass wraps LLDS instruction sequences
	using temporaries in a block instruction which actually declares
	those temporaries. It used to be used only by value numbering;
	it is now also used by use_local_vars. It has therefore been renamed
	and put in its own file.

compiler/optimize.m:
	Invoke use_local_vars if required, and call wrap_blocks instead of
	post_value_number.

compiler/value_number.m:
	Since the value numbering pass still cannot handle automatically
	generated C code, check for it explicitly now that livemap carries out
	only a weaker check.

compiler/basic_block.m:
	Add a module qualification.

library/set.m:
library/set_bbbtree.m:
library/set_ordlist.m:
library/set_unordlist.m:
	Add a new predicate, union_list, to each implementation of sets,
	for use by some of the new code above.

tests/general/array_test.m:
	Print out the result of each operation as soon as it is done, so that
	if you get a seg fault, you know which operations have completed and
	which haven't.
2001-04-24 03:59:13 +00:00
Zoltan Somogyi
c32e129db0 Add field names for the proc_layout_info type.
Estimated hours taken: 1

compiler/continuation_info.m:
	Add field names for the proc_layout_info type.

compiler/optimize.m:
	Use the new field names.
2000-08-21 09:42:01 +00:00
Zoltan Somogyi
12af7b3793 Consistently use counters to allocate label numbers and cell numbers
Estimated hours taken: 12

Consistently use counters to allocate label numbers and cell numbers
throughout the LLDS backend.

compiler/hlds_module.m:
	Change the module_info structure to store a counter instead of an
	integer for cell numbers.

compiler/llds.m:
	Change the c_procedure structure to include a proc_label and a counter,
	to allow LLDS to LLDS optimizations to use this counter to allocate
	new label numbers. (The labels also include the proc_label.)

compiler/code_info.m:
	Change the code_info structure to store counters instead of integers
	for both label numbers and cell numbers.

compiler/code_gen.m:
	When creating the c_procedure, copy the final value of the counter
	from code_info to the c_procedure.

compiler/opt_util.m:
	Delete the existing, inefficient procedure for allocating label
	numbers, and modify the interface of the get_prologue predicate
	to no longer return the proc_label (since it can now be looked up
	more directly).

compiler/*.m:
	Minor changes to conform to the new data structures and to use
	counters instead of direct addition.
2000-08-11 08:19:24 +00:00
Zoltan Somogyi
e46e2d5eb1 Remove calls to !.
Estimated hours taken: 0.5

library/*.m:
compiler/*.m:
	Remove calls to !.
2000-03-28 03:40:39 +00:00
Simon Taylor
17c24d9cf9 Restrict value numbering on procedures containing reconstructions.
Estimated hours taken: 1

Restrict value numbering on procedures containing reconstructions.
Without this change, value numbering could reorder instructions
which extract fields from a cell with the instructions which update
the values of those fields.

compiler/llds.m:
	Add a field to each `c_procedure' to record whether the
	procedure contains a reconstruction.

compiler/code_gen.m:
	Fill in the field.

compiler/value_number.m:
	Wrap labels around all field assignments in procedures which
	contain reconstructions.

compiler/*.m:
	Handle the extra field of the `c_procedure' constructor.
2000-02-10 04:37:40 +00:00
Zoltan Somogyi
0642a10ff8 Reduce the number of arguments of MR_trace() to one.
Estimated hours taken: 24

WARNING: this change affects binary compatibility for debuggable code;
the debuggable modules of the program and the runtime linked into the
executable must either all come from before this change, or they must all
come from after this change. However, this change does *not* affect binary
compatibility for non-debuggable executables.

Reduce the number of arguments of MR_trace() to one. Two of the arguments,
the port and the goal path, move into the label layout structure, as 16-bit
numbers; the port as a simple enumeration type, and the goal path as an
index into the module-wide string table. (The latter will eventually allow the
debugger to support the placement of breakpoints on labels with specific goal
paths.) The third argument, the number of the highest-numbered rN register in
use at the label, has been moved into the proc layout structure. In theory,
this will require more register saves and restores, since the number in the
proc layout is conservative (it is the max of the numbers that would be
required at the individual labels). However, this is not important, for two
reasons. First, we always save and restore all the rM registers that
appear in the mrM array before the last special-purpose register, and in
most cases this dictates how many registers we save/restore. Second, we
save/restore registers only when the debugger starts interaction, so
save/restore is a time critical activity only for the external debugger.

This change reduces the execution time of debuggable executables by about
4-5% when executing outside mdb and 3-4% when executing under mdb. It also
reduces executable sizes, but only by about 0.7% on x86.

This change eliminates the --trace-just-in-case compiler option, since
we now have the best of both --trace-just-in-case and --no-trace-just-in-case.

The drawback of this scheme is slightly increased executable size with the
accurage garbage collector, but that seems a small enough price to pay.

compiler/code_gen.m:
compiler/code_info.m:
	Record the number of the highest numbered rN register live at a trace
	label.

compiler/continuation_info.m:
	Record the number of the highest numbered rN register live at a trace
	label, and the port and goal path associated with the labels of trace
	events.

compiler/stack_layout.m:
	Put the number of the highest numbered rN register live at a trace
	label into proc layouts, and the port and goal path into label layouts.

	Since we are breaking binary compatibility with old debuggable modules
	anyway, compress the procedure id parts of proc layouts by using
	only 16 bits to store the procedure's arity and mode number, instead
	of 32 or 64.

compiler/trace.m:
	Update the handling of ports, goal paths and max live register numbers,
	so that instead of being passed as MR_trace arguments, they are
	recorded in data structures.

	Generate separate labels and layouts for the fail and redo events.
	Although they still have the same layout information, they now record
	different ports.

compiler/llds.m:
	Since trace.m now generates a label layout structure for the redo
	event, we must include redo events in the llds goal path type.

compiler/hlds_goal.m:
	Since the code for handling the port type for nondet pragma events
	has moved from the nondet-pragma-specific to the generic part of
	trace.m, we must now include their event types in the hlds goal path
	type.

compiler/llds_out.m:
	Add a predicate for converting ports into numbers, now that we
	must store ports in static data. Using their symbolic names would
	be better, but that would require complications in the llds type
	system, which would be inadvisable just before the release.

compiler/options.m:
compiler/handle_options.m:
doc/user_guide.texi:
	Eliminate --trace-just-in-case.

compiler/llds.m:
compiler/llds_common.m:
compiler/llds_out.m:
	Eliminate the data structure needed by --trace-just-in-case.

compiler/optimize.m:
	Trivial update to conform to data structure changes.

library/exception.m:
	Update the call to MR_trace.

runtime/mercury_stack_layout.h:
	Update the C structure declarations for the layout structures
	as discussed above.

runtime/mercury_init.h:
	Update the declarations of MR_trace_real and MR_trace_fake
	to use only one argument.

runtime/mercury_wrapper.[ch]:
	Update the declaration of MR_trace_func to use only one argument.

runtime/mercury_trace_base.[ch]:
	Update the declarations of MR_trace, MR_trace_real and MR_trace_fake
	to use only one argument.

	Delete MR_trace_struct(); since we deleted --trace-just-in-case, there
	will not be calls to it anymore.

	Since we are breaking binary compatibility anyway, move the exception
	port to be with the other interface ports. This should speed up a
	frequently executed test in the debugger.

	Update the handling of redo events.

trace/mercury_trace.h:
	Simplify and speed up the macro that tests a port for being an
	interface port, now that exceptions are grouped with other interface
	events.

trace/mercury_trace.c:
	Update the definition of MR_trace_real to use only one argument.
	The port is pulled out of the label layout structure only when
	needed to perform the termination tests for the current debugger
	command, and the goal path and the max live register number are
	looked up only when the termination test succeeds.
1999-12-14 04:54:38 +00:00
Zoltan Somogyi
e9fa3f8792 Fix two related bugs in the debugger. The first was that the code in jumpopt.m
Estimated hours taken: 3

Fix two related bugs in the debugger. The first was that the code in jumpopt.m
for preventing the redirecting of call returns away from labels with layout
structures was only partially effective, since some call return sites have
their layout structures generated only *after* optimization. The second bug
was that the exception events generated by library/exception.m took the label
layouts of call return sites within a predicate and passed them to MR_trace
as if they were the layouts of compiler-generated trace events. However,
while at compiler-generated trace events, all the variables mentioned in the
associated layout structure are supposed to be live, at return sites only
the variables stored in stack slots are live.

compiler/jumpopt.m:
	Do not redirect call returns if execution tracing is enabled.

compiler/optimize.m:
	Pass the trace level to jumpopt.m.

trace/mercury_trace_vars.[ch]:
	Remember the port type of the event, and do not consider the registers
	to contain valid contents even at ancestor level zero if the port type
	is exception.

trace/mercury_trace_{in,ex}ternal.c:
	Pass the port type to mercury_trace_vars.c.

tests/debugger/exception_vars.{m,inp,exp,exp2}:
	Regression test for the fixed bugs. The .exp2 file is not yet filled
	in.

tests/debugger/Mmakefile:
	Enable the new test case.
1999-12-10 04:24:09 +00:00
Zoltan Somogyi
f0964815a3 Support line numbers in the debugger. You now get contexts (filename:lineno
Estimated hours taken: 40

Support line numbers in the debugger. You now get contexts (filename:lineno
pairs) printed in several circumstances, and you can put breakpoints on
contexts, when they correspond to trace events or to calls. The latter are
implemented as breakpoints on the label layouts of the return sites.

This required extending the debugging RTTI, so that associated with each
module there is now a new data structure listing the source file names that
contribute labels with layout structures to the code of the module. For each
such source file, this table gives a list of all such labels arising from
that file. The table entry for a label gives the line number within the file,
and the pointer to the label layout structure.

compiler/llds.m:
	Add a context field to the call instruction.

compiler/continuation_info.m:
	Instead of the old division of continuation info about labels into
	trace ports and everything else, divide them into trace ports, resume
	points and return sites. Record contexts with trace ports, and record
	contexts and called procedure information with return sites.

compiler/code_info.m:
	Conform to the changes in continuation_info.m.

compiler/options.m:
	Add a new option that allows us to disable the generation of line
	number information for size benchmarking (it has no other use).

compiler/stack_layout.m:
	Generate the new components of the RTTI, unless the option says not to.

compiler/code_gen.m:
compiler/pragma_c_gen.m:
compiler/trace.m:
	Include contexts in the information we gather for the layouts
	associated with the events we generate.

compiler/call_gen.m:
	Include contexts in the call LLDS instructions, for association
	with the return site's label layout structure (which is done after
	code generation is finished).

compiler/handle_options.m:
	Delete the code that tests or sets the deleted options.

compiler/mercury_compile.m:
	Delete the code that tests the deleted options.

compiler/basic_block.m:
compiler/dupelim.m:
compiler/frameopt.m:
compiler/livemap.m:
compiler/llds_common.m:
compiler/llds_out.m:
compiler/middle_rec.m:
compiler/opt_debug.m:
compiler/opt_util.m:
compiler/value_number.m:
compiler/vn_*.m:
	Trivial changes to conform to the changes to llds.m.

compiler/jumpopt.m:
	Do not optimize away jumps to labels with layout structures.
	The jumps we are particularly concerned about now are the jumps
	that return from procedure calls. Previously, it was okay to redirect
	returns from several calls so that all go to the same label, since
	the live variable information associated with the labels could be
	merged. However, we now also associate line numbers with calls, and
	these cannot be usefully merged.

compiler/optimize.m:
	Pass the information required by jumpopt to it.

doc/user_guide.texi:
	Document that you can now break at line numbers.

	Document the new "context" command, and the -d or --detailed option
	of the stack command and the commands that set ancestor levels.

runtime/mercury_stack_layout.h:
	Extend the module layout structure definition with the new tables.

	Remove the conditional facility for including label numbers in label
	layout structures. It hasn't been used in a long time, and neither
	Tyson or me expect to use it to debug either gc or the debugger itself,
	so it has no uses left; the line numbers have superseded it.

runtime/mercury_stack_trace.[ch]:
	Extend the code to print stack traces to also optionally print
	contexts.

	Add some utility predicates currently used by the debugger that could
	also be use for debugging gc or for more detailed stack traces.

trace/mercury_trace_internal.c:
	Implement the "break <context>" command, the "context" command, and
	the -d or --detailed option of the stack command and the commands
	that set ancestor levels.

	Conditionally define a conditionally used variable.

trace/mercury_trace_external.c:
	Minor changes to keep up with the changes to stack traces.

	Delete an unused variable.

trace/mercury_trace_spy.[ch]:
	Check for breakpoints on contexts.

trace/mercury_trace_tables.[ch]:
	Add functions to search the RTTI data structures for labels
	corresponding to a given context.

trace/mercury_trace_vars.[ch]:
	Remember the context of the current environment.

tests/debugger/queen.{inp,exp}:
	Test the new capabilities of the debugger.

tests/debugger/*.{inp,exp}:
	Update the expected output of the debugger to account for contexts.
	In some cases, modify the input script to put contexts where they don't
	overflow lines.
1999-11-15 00:43:59 +00:00
Zoltan Somogyi
0b35ee3f56 Add a new option, --checked-nondet-tailcalls, that enables the use of
Estimated hours taken: 8

Add a new option, --checked-nondet-tailcalls, that enables the use of
Prolog style nondet tail calls (which check whether the current frame is
on top of the nondet stack and only do a tail call if it is).

This option is not likely to help Mercury code, since most of the time
the test will fail, which means we incurred its cost and did not gain
the benefit of the tailcall. However, HAL often has predicates that are
declared nondet but are det or semidet most of the time, and these can
benefit.

compiler/options.m:
doc/user_guide.texi:
	Add the new option, which is not on by default and is not turned on
	at any optimization level; you have to give it explicitly.

compiler/llds.m:
	Modify the call_model type to distinguish the new style nondet tail
	call from the old (which does not do a runtime test).

compiler/code_info.m:
	Check the fail state whether it is suitable for new style nondet
	tail calls.

compiler/call_gen.m:
	Put the result from code_info.m into the generated LLDS.

compiler/jumpopt.m:
	Use the new status field in the LLDS to perform the optimization,
	if the option is given.

	Document the main predicate and its new argument.

compiler/optimize.m:
	Pass the value of the new option to jumpopt.

tests/hard_coded/checked_nondet_tailcall.{m,exp}:
	A new test case to check that the code we generate with the new
	option works correctly. (Checking whether it actually reduces
	nondet stack usage would be harder.)
1999-09-30 08:55:51 +00:00
Fergus Henderson
d66c8481ae Some more changes to minimize the complexity of the intermodule dependencies.
Estimated hours taken: 4

Some more changes to minimize the complexity of the intermodule dependencies.
In particular, ensure that hlds_module.m does not need to import llds.m.

compiler/hlds_module.m:
compiler/llds.m:
	Move the definition of the c_interface_info type (and the types
	used for all its fields) from llds.m into hlds_module.m, since
	this type contains high-level information about the user-level
	C interface stuff that is not directly related to the LLDS and
	is needed by other back-ends.

compiler/hlds_module.m:
compiler/llds.m:
compiler/mercury_compile.m:
compiler/code_gen.m:
compiler/stack_layout.m:
compiler/table_gen.m:
	Move the `global_data' type from hlds_module.m into llds.m,
	since this type contains low-level stuff that is dependent on
	the LLDS.  Delete the `global_data' field of the module_info,
	instead passing it around as a separate argument where needed.
	Move the code for inserting llds__tabling_pointer_vars into the
	global_data from table_gen.m to code_gen.m, since this is
	dependent on the LLDS and table_gen.m should be a pure
	HLDS->HLDS transformation, so that it can work with other
	back-ends.

compiler/continuation_info.m:
	Update some comments which this change makes obsolete.

compiler/optimize.m:
	Delete the import of module hlds_data, since it is no longer needed.
1999-07-12 06:21:25 +00:00
Zoltan Somogyi
e33efd211a Allow the native collector to work for nondet code, by generating layout
Estimated hours taken: 10

Allow the native collector to work for nondet code, by generating layout
structures for the resumption points whose addresses can be put into
redoip slots in nondet stack frames.

If the program is compiled with both native gc and debugging, entries
to disjunctions will have two labels and two layout structures, one
for gc and one for the debugger. At the moment we make no attempt
to try to combine the two structures, since doing so would add significant
extra complexity. Optimizing this option combination will not be important
for a while yet anyway.

compiler/code_info.m:
	Update the code that generates resume points to also optionally
	generate layout structures for the stack labels.

compiler/disj_gen.m:
	When we save the heap pointer, update not only the current code_info
	but the saved code_info that represents the branch start position
	as well, since the slot containing the saved heap pointer will be
	live in each of the following disjuncts.

compiler/labelopt.m:
compiler/mercury_compile.m:
compiler/optimize.m:
compiler/value_number.m:
	Arrange to pass the global_data structure to the label elimination
	and value numbering passes. This is to (a) prevent the label
	elimination pass from removing labels (e.g. stack resume labels)
	that have layout structures, and (b) to prevent value numbering
	for moving computations across such labels, since that would
	invalidate the layout structure.

	(The presence of pragma_c_code fragments in the generated code avoids
	both these potential problems for layout structures that correspond
	to trace events, but that solution would be suboptimal for resume
	labels.)

compiler/hlds_module.m:
	Add a utility predicate needed by optimize.m.
1999-03-12 05:53:29 +00:00
Tyson Dowd
319d1952f9 Turn off frame optimizations for accurate GC.
Estimated hours taken: 2

Turn off frame optimizations for accurate GC.
We need the stack frames present so we can replace the succip on the
stack to schedule accurate GC.

compiler/handle_options.m:
	Make accurate GC imply --no-optimize-frames.

compiler/optimize.m:
compiler/peephole.m:
compiler/value_number.m:
	If doing accurate GC, don't peephole optimize incr_sp...decr_sp
	code.
1998-06-16 06:11:42 +00:00
Fergus Henderson
11d8161692 Add support for nested modules.
Estimated hours taken: 50

Add support for nested modules.

- module names may themselves be module-qualified
- modules may contain `:- include_module' declarations
  which name sub-modules
- a sub-module has access to all the declarations in the
  parent module (including its implementation section).

This support is not yet complete; see the BUGS and LIMITATIONS below.

LIMITATIONS
- source file names must match module names
	(just as they did previously)
- mmc doesn't allow path names on the command line any more
	(e.g. `mmc --make-int ../library/foo.m').
- import_module declarations must use the fully-qualified module name
- module qualifiers must use the fully-qualified module name
- no support for root-qualified module names
	(e.g. `:parent:child' instead of `parent:child').
- modules may not be physically nested (only logical nesting, via
  `include_module').

BUGS
- doesn't check that the parent module is imported/used before allowing
	import/use of its sub-modules.
- doesn't check that there is an include_module declaration in the
	parent for each module claiming to be a child of that parent
- privacy of private modules is not enforced

-------------------

NEWS:
	Mention that we support nested modules.

library/ops.m:
library/nc_builtin.nl:
library/sp_builtin.nl:
compiler/mercury_to_mercury.m:
	Add `include_module' as a new prefix operator.
	Change the associativity of `:' from xfy to yfx
	(since this made parsing module qualifiers slightly easier).

compiler/prog_data.m:
	Add new `include_module' declaration.
	Change the `module_name' and `module_specifier' types
	from strings to sym_names, so that module names can
	themselves be module qualified.

compiler/modules.m:
	Add predicates module_name_to_file_name/2 and
	file_name_to_module_name/2.
	Lots of changes to handle parent module dependencies,
	to create parent interface (`.int0') files, to read them in,
	to output correct dependencies information for them to the
	`.d' and `.dep' files, etc.
	Rewrite a lot of the code to improve the readability
	(add comments, use subroutines, better variable names).
	Also fix a couple of bugs:
	- generate_dependencies was using the transitive implementation
	  dependencies rather than the transitive interface dependencies
	  to compute the `.int3' dependencies when writing `.d' files
	  (this bug was introduced during crs's changes to support
	  `.trans_opt' files)
	- when creating the `.int' file, it was reading in the
	  interfaces for modules imported in the implementation section,
	  not just those in the interface section.
	  This meant that the compiler missed a lot of errors.

library/graph.m:
library/lexer.m:
library/term.m:
library/term_io.m:
library/varset.m:
compiler/*.m:
	Add `:- import_module' declarations to the interface needed
	by declarations in the interface.  (The previous version
	of the compiler did not detect these missing interface imports,
	due to the above-mentioned bug in modules.m.)

compiler/mercury_compile.m:
compiler/intermod.m:
	Change mercury_compile__maybe_grab_optfiles and
	intermod__grab_optfiles so that they grab the opt files for
	parent modules as well as the ones for imported modules.

compiler/mercury_compile.m:
	Minor changes to handle parent module dependencies.
	(Also improve the wording of the warning about trans-opt
	dependencies.)

compiler/make_hlds.m:
compiler/module_qual.m:
	Ignore `:- include_module' declarations.

compiler/module_qual.m:
	A couple of small changes to handle nested module names.

compiler/prog_out.m:
compiler/prog_util.m:
	Add new predicates string_to_sym_name/3 (prog_util.m) and
	sym_name_to_string/{2,3} (prog_out.m).

compiler/*.m:
	Replace many occurrences of `string' with `module_name'.
	Change code that prints out module names or converts
	them to strings or filenames to handle the fact that
	module names are now sym_names intead of strings.
	Also change a few places (e.g. in intermod.m, hlds_module.m)
	where the code assumed that any qualified symbol was
	fully-qualified.

compiler/prog_io.m:
compiler/prog_io_goal.m:
	Move sym_name_and_args/3, parse_qualified_term/4 and
	parse_qualified_term/5 preds from prog_io_goal.m to prog_io.m,
	since they are very similar to the parse_symbol_name/2 predicate
	already in prog_io.m.  Rewrite these predicates, both
	to improve maintainability, and to handle the newly
	allowed syntax (module-qualified module names).
	Rename parse_qualified_term/5 as `parse_implicit_qualified_term'.

compiler/prog_io.m:
	Rewrite the handling of `:- module' and `:- end_module'
	declarations, so that it can handle nested modules.
	Add code to parse `include_module' declarations.

compiler/prog_util.m:
compiler/*.m:
	Add new predicates mercury_public_builtin_module/1 and
	mercury_private_builtin_module/1 in prog_util.m.
	Change most of the hard-coded occurrences of "mercury_builtin"
	to call mercury_private_builtin_module/1 or
	mercury_public_builtin_module/1 or both.

compiler/llds_out.m:
	Add llds_out__sym_name_mangle/2, for mangling module names.

compiler/special_pred.m:
compiler/mode_util.m:
compiler/clause_to_proc.m:
compiler/prog_io_goal.m:
compiler/lambda.m:
compiler/polymorphism.m:
	Move the predicates in_mode/1, out_mode/1, and uo_mode/1
	from special_pred.m to mode_util.m, and change various
	hard-coded definitions to instead call these predicates.

compiler/polymorphism.m:
	Ensure that the type names `type_info' and `typeclass_info' are
	module-qualified in the generated code.  This avoids a problem
	where the code generated by polymorphism.m was not considered
	type-correct, due to the type `type_info' not matching
	`mercury_builtin:type_info'.

compiler/check_typeclass.m:
	Simplify the code for check_instance_pred and
	get_matching_instance_pred_ids.

compiler/mercury_compile.m:
compiler/modules.m:
	Disallow directory names in command-line arguments.

compiler/options.m:
compiler/handle_options.m:
compiler/mercury_compile.m:
compiler/modules.m:
	Add a `--make-private-interface' option.
	The private interface file `<module>.int0' contains
	all the declarations in the module; it is used for
	compiling sub-modules.

scripts/Mmake.rules:
scripts/Mmake.vars.in:
	Add support for creating `.int0' and `.date0' files
	by invoking mmc with `--make-private-interface'.

doc/user_guide.texi:
	Document `--make-private-interface' and the `.int0'
	and `.date0' file extensions.

doc/reference_manual.texi:
	Document nested modules.

util/mdemangle.c:
profiler/demangle.m:
	Demangle names with multiple module qualifiers.

tests/general/Mmakefile:
tests/general/string_format_test.m:
tests/general/string_format_test.exp:
tests/general/string__format_test.m:
tests/general/string__format_test.exp:
tests/general/.cvsignore:
	Change the `:- module string__format_test' declaration in
	`string__format_test.m' to `:- module string_format_test',
	because with the original declaration the `__' was taken
	as a module qualifier, which lead to an error message.
	Hence rename the file accordingly, to avoid the warning
	about file name not matching module name.

tests/invalid/Mmakefile:
tests/invalid/missing_interface_import.m:
tests/invalid/missing_interface_import.err_exp:
	Regression test to check that the compiler reports
	errors for missing `import_module' in the interface section.

tests/invalid/*.err_exp:
tests/warnings/unused_args_test.exp:
tests/warnings/unused_import.exp:
	Update the expected diagnostics output for the test cases to
	reflect a few minor changes to the warning messages.

tests/hard_coded/Mmakefile:
tests/hard_coded/parent.m:
tests/hard_coded/parent.child.m:
tests/hard_coded/parent.exp:
tests/hard_coded/parent2.m:
tests/hard_coded/parent2.child.m:
tests/hard_coded/parent2.exp:
	Two simple tests case for the use of nested modules with
	separate compilation.
1998-03-03 17:48:14 +00:00
Fergus Henderson
73131e8df3 Undo Zoltan's bogus update of all the copyright dates.
Estimated hours taken: 0.75

library/*.m:
compiler/*.m:
	Undo Zoltan's bogus update of all the copyright dates.
	The dates in the copyright header should reflect the years
	in which the file was modified (and no, changes to the
	copyright header itself don't count as modifications).
1998-01-23 12:57:08 +00:00
Zoltan Somogyi
bb4442ddc1 Update copyright dates for 1998.
Estimated hours taken: 0.5

compiler/*.m:
	Update copyright dates for 1998.
1998-01-13 10:06:08 +00:00
Zoltan Somogyi
42c540ad67 Give duplicate code elimination more teeth in dealing with similar arguments
Estimated hours taken: 20

Give duplicate code elimination more teeth in dealing with similar arguments
of different function symbols. For the source code

	:- type t1	--->	f(int)
			;	g(int, int).

	:- pred p1(t1::in, int::out) is det.

	p1(f(Y), Y).
	p1(g(Y, _), Y).

we now generate the C code

	Define_entry(mercury__xdup__p1_2_0);
		r1 = const_mask_field(r1, (Integer) 0);
		proceed();

thus avoiding the cost of testing the function symbol.

runtime/mercury_tags.h:
	Add two new macros, mask_field and const_mask_field, that behave
	just like field and const_field except that instead of stripping
	off a known tag from the pointer, they strip (mask) off an unknown
	tag.

compiler/llds.m:
	Change the first argument of the lval field/3 from tag to maybe(tag).

	Make the comments on some types more readable.

compiler/llds_out.m:
	If the first arg of the lval field/3 is no, emit a (const_)mask_field
	macro; otherwise, emit a (const_)field macro.

compiler/basic_block.m:
	New module to convert sequences of instructions to sequences of
	basic blocks and vice versa. Used in the new dupelim.m.

compiler/dupelim.m:
	Complete rewrite to give duplicate code elimination more teeth.
	Whereas previously we eliminated blocks of code only if they exactly
	duplicated other blocks of code, we now look for blocks that can be
	"anti-unified". For example, the blocks

	r1 = field(mktag(0), r2, 0)
	goto L1

	and

	r1 = field(mktag(1), r2, 0)
	<fall through to L1>

	anti-unify, with the most specific common generalization being

	r1 = mask_field(r2, 0)
	goto L1

	If several basic blocks antiunify, we replace one copy with the
	antiunified block and try to eliminate the others. We do not
	eliminate blocks that can be fallen into, since eliminating them
	would require introducing a goto, which would slow the code down.

compiler/peephole,m:
	If a conditional branch to a label is followed by that label or
	by an unconditional branch to that label, eliminate the branch.
	Dupelim produces this kind of code.

compiler/{code_exprn,exprn_aux,lookup_switch,opt_debug,unify_gen}.m:
	Minor changes required by the change to field/3.

compiler/{frameopt,jumpopt,labelopt,mercury_compile,optimize,value_number}.m:
	s/__main/_main/ in predicate names.

compiler/jumpopt.m:
	Add some documentation.

compiler/unify_gen.m:
	Fix a module qualified predicate name reference that would not
	work in Prolog.

compiler/notes/compiler_design.html:
	Document the new file basic_block.m.
1997-12-22 06:59:25 +00:00
Tyson Dowd
24954933b5 Fix some problems Fergus pointed out after reviewing my
Estimated hours taken: 1

Fix some problems Fergus pointed out after reviewing my
stack layouts change.

compiler/continuation_info.m:
	Separate library imports from compiler imports.

compiler/handle_options.m:
compiler/options.m:
	Add some comments to explain the stack_layouts option.
	Comment out the documentation of the stack-layouts option,
	as it is a developer only option.

compiler/code_gen.m:
compiler/llds.m:
compiler/llds_common.m:
compiler/llds_out.m:
compiler/mercury_compile.m:
compiler/optimize.m:
	Remove llds_proc_id from c_procedure, as pred_proc_id is
	available instead.
1997-12-10 07:15:49 +00:00
Tyson Dowd
2a97f96d1a Generate stack layouts for accurate garbage collection.
Estimated hours taken: 50

Generate stack layouts for accurate garbage collection.

compiler/base_type_layout.m:
	Change the order of some arguments so that threaded data
	structures are more often in the final two arguments (allows
	easy use of higher order predicates).
	Simplify some code using higher order preds.
	Export base_type_layout__construct_pseudo_type_info, as
	stack_layout.m needs to be able to generate pseudo_type_infos
	too.
	Fix problems with cell numbers being re-used -- get the next
	cell number from module_info, and update module_info
	after processing base_type_layouts.

compiler/code_gen.m:
	Add information about each procedure to the continuation info.
	Handle new field in c_procedure.

compiler/continuation_info.m:
	Redesign most of this module to deal with labels
	that are continuation points for multiple calls.
	Change the order of some arguments so that threaded data
	structures are in the final two arguments.
	Cleaned up and documented code.

compiler/dupelim.m:
compiler/exprn_aux.m:
	Handle new label_entry data type.

compiler/export.m:
compiler/opt_debug.m:
	Handle new label_entry and general data types.

compiler/llds_out.m:
	Add an argument to get_proc_label to control whether a
	"mercury_" prefix is wanted.
	Handle new label_entry and general data types.

compiler/llds.m:
	Add a new alternative for data_const - a label_entry.
	Add a new alternative for data_name - general, which
	allows any sort of data, with names generated elsewhere.
	Add the pred_proc_id as a field of c_procedure.

compiler/optimize.m:
compiler/llds_common.m:
compiler/optimize.m:
	Handle new field in c_procedure.

compiler/mercury_compile.m:
	Generate layout information after code has been generated,
	and output stack layouts.

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

compiler/stack_layout.m:
	New file - generates the LLDS code that defines
	global constants to hold the stack_layout structures.

compiler/options.m:
compiler/handle_options.m:
	Add --stack-layout option which outputs stack layouts.
	Make accurate gc imply stack_layout.
1997-11-08 13:12:08 +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
Tyson Dowd
cbcb23d17b Enable --warn-interface-imports by default.
Estimated hours taken: 3

Enable --warn-interface-imports by default. This was turned off while
list and term were defined in mercury_builtin.m, since it caused many
warnings.

Fix all the unused interface imports that have been added since then.

compiler/options.m:
	Enable --warn-interface-imports by default.

compiler/module_qual.m:
	Fix formatting inconsistencies with module names in warning
	messages. (".m" was not appended to module names if there was
	only one module).

compiler/*.m:
library/*.m:
tests/invalid/type_loop.m:
tests/warnings/*.m:
	Remove usused interface imports, or move them into
	implementation (mostly bool, list and std_util).
1997-05-21 02:16:53 +00:00
Fergus Henderson
5b60113f9c Insert lots of cuts, with the aim of reducing the memory consumption
Estimated hours taken: 0.5

compiler/mercury_compile.m:
compiler/optimize.m:
	Insert lots of cuts, with the aim of reducing the memory consumption
	of the SICStus Prolog version of the Mercury compiler.
1997-05-07 11:39:31 +00:00
Fergus Henderson
3ec8a17ffc Enable the code to treat `__' as an alternative syntax for module
Estimated hours taken: 8

Enable the code to treat `__' as an alternative syntax for module
qualification, after fixing various places in the compiler where
we use `__' in ways that are incompatible with this.

compiler/prog_io.m:
compiler/prog_io_goal.m:
	Uncomment the code to handle `__' as module qualification.

compiler/intermod.m:
compiler/hlds_module.m:
compiler/modecheck_unify.m:
	Fix bugs in the handling of module qualified higher-order terms.

compiler/*.m:
	s/hlds__/hlds_/g

compiler/passes_aux.m:
	s/process__/process_/g

compiler/pragma_c_gen.m:
compiler/code_gen.m:
	s/code_gen__/pragma_c_gen__/ for the predicates defined in
	pragma_c_gen.m (this ought to have been done when the code
	was first moved from code_gen.m to pragma_c_gen.m).

compiler/llds.m:
	s/llds__proc_id/llds_proc_id/g
	The reason for this was to avoid ambiguity between proc_id
	in hlds_pred.m and llds__proc_id in llds.m.

compiler/quantification.m:
compiler/make_hlds.m:
compiler/mercury_to_c.m:
	s/goal_vars/quantification__goal_vars/g
	The reason for this was to avoid ambiguity between goal_vars
	in quantification.m and goal_util__goal_vars in goal_util.m.

compiler/dupelim.m:
compiler/optimize.m:
	s/dupelim__main/dupelim_main/g
	The reason for this change is that a program can only
	have one main/2 predicate.

compiler/prog_io_dcg.m:
	Remove the old "temporary hack" to strip off and ignore
	io__gc_call/1, since the new handling of `__' broke it.
	It was only useful for optimizing NU-Prolog performance,
	which we don't care about anymore.

compiler/mercury_compile.m:
compiler/modules.m:
compiler/intermod.m:
compiler/prog_io.m:
	Remove occurrences of io__gc_call.

compiler/llds_out.m:
compiler/base_type_info.m:
	Ensure that we properly handle the special hacks in mercury_builtin
	where predicates from other modules (e.g. term__context_init)
	are defined in mercury_builtin because they are needed for
	type_to_term and term_to_type.  llds_out.m: don't put
	`mercury_builtin' in the mangled names for those symbols.
	base_type_info.m: handle types whose status is "imported"
	in their own module.
1997-02-23 06:08:34 +00:00
Zoltan Somogyi
b913c795ca A rewrite of frameopt, with supporting changes in other modules.
Estimated hours taken: 25

A rewrite of frameopt, with supporting changes in other modules.

frameopt:
	A complete rewrite, with three objectives.

	The first is to fix a basic design flaw that was in the module from
	the beginning, which is that it looked at whether a block would have
	a stack frame if the frame setup wasd delayed as long as possible,
	and took this as gospel. This sometimes led to code that throws away
	the frame to enter a block that does not need a frame and then
	constructing it again to enter another block which does need a frame.
	It also lead to some twisted code when we jumped from a block without
	a frame to a block with one, since we'd have to set up a stack frame
	on arrival at the target block; this sometimes required branches
	around this setup code at the start of the target block to properly
	support fallthroughs.

	We now work out in advance which blocks must have a frame, and
	propagate the requirement for a frame both forwards and backwards
	until a fixpoint is reached, and only then transform the code.
	The propagation phase ensures that we never suffer from either
	of the problems described above.

	The second objective is to integrate another optimization concerned
	with stack frames: not delaying the creation, but reusing a frame
	set up for one call to also act as the frame of a tail recursive call.
	We used to this (badly) in peephole; we now do it (well) here.

	The third objective is to separate out the filling of delay slots,
	so frameopt can be invoked before value numbering. (Filling delay
	slots creates code that refers to the same location by two distinct
	names, detstackvar(0) and detstackvar(N) where N>0, which breaks the
	assumption behind value numbering.) Invoking frameopt before value
	numbering should make value numbering more effective whenever frameopt
	decides to keep the stack frame.

delay_slot:
	A new module to perform the optimization of filling branch delay slots.

opt_util:
	Return the initial label instruction from opt_util__get_prologue,
	and delete some predicates that aren't and won't be needed.

peephole:
	Don't pass around the Teardown and Setup maps, since the optimization
	they were needed for (keeping stack frames) is now done by frameopt.

optimize:
	Use the new interface of frameopt and peephole.

	Invoke frameopt before the value numbering passes.

	We don't need a dedicated peephole pass after frameopt anymore,
	What we need is a labelopt pass to get rid of the extra labels frameopt
	introduces, and possibly a jumpopt pass to short-circuit any jumps
	that replace tailcalls.

	Invoke delay_slot optimization and post_value_number at the very end.
	We don't need to invoke any frameopt post-pass anymore.

	Fix a couple of places where we were not dumping the instruction
	properly when --debug-opt was given.

value_number:
	Use the new interface of peephole and opt_util__get_prologue.

jumpopt:
	Under some circumstances we were generating the instruction "r1 = r1";
	we don't do this anymore.

llds_out:
	Add a missing newline at the end of garbage collection annotations.
1997-01-11 08:51:20 +00:00
Fergus Henderson
8a30dcef4b Fix a bug: if --optimize-vn-repeat was non-zero but
Estimated hours taken: 0.5

optimize.m:
	Fix a bug: if --optimize-vn-repeat was non-zero but
	--optimize-value-number was not set, then it was invoking
	the non-value-numbering optimizations the wrong number
	of times.
1996-12-05 04:39:37 +00:00
Zoltan Somogyi
5d64b759db The main changes are
Estimated hours taken: 12

The main changes are

1	associating a name with the arguments of constructors

2	removing the follow_vars field from calls, higher-order calls
	and complicated unifications, since they are not used

3	merging the follow_vars and store_alloc passes, since they logically
	belong together

4	add a new module, lco, for detecting opportunities for last
	call optimization modulo constructor application; it won't
	actually apply the optimization until the mode system becomes
	expressive enough to handle it (this module detects 529 opportunities
	in the compiler and library)

5	make "-O3 --optimize-value-number" do the right thing; previously,
	it used not to apply value numbering because the vnrepeat option
	defaulted to zero

6	don't refer to .err2 files anymore; use .err instead.

prog_data:
	The list associated with each value of type "constructor" now
	contains not only the types of the arguments but their names as well.

equiv_type, hlds_data, hlds_out, make_hlds, mercury_to_{goedel,mercury},
mode_util, module_qual, shapes, type_util, unify_proc:
	Modify the traversal of type definitions to account for the names
	in the lists inside values of type "constructor".

prog_io:
	Parse argument names. An unrelated change is that we now
	check whether :- pred declarations give modes to some of their
	arguments but not to all, in which case we return an error.

hlds_goal:
	Remove the follow_vars field from calls, higher-order calls
	and complicated unifications.

*.m:
	Handle the new arities of calls, higher order calls and complicated
	unifications.

mercury_compile:
	Don't call follow_vars directly anymore, but do call lco if its option
	is set. Also flush the main output before a call to maybe_report_stats
	to prevent ugly output.

store_alloc:
	Call follow_vars directly.

follow_vars:
	Expose the initialization and traversal predicates for store_alloc.

lco:
	Find opportunities for last call optimization modulo constructor
	application.

passes_aux:
	Add a HLDS traversal type for lco.

optimize:
	Consider the vnrepeat count to be zero unless value numbering is on.

options:
	Set the default value of vnrepeat to 1.

modules:
	Don't refer to .err2 files.
1996-11-04 06:26:51 +00:00
Zoltan Somogyi
9d14c35534 Since NU-Prolog hasn't been capable of executing the compiler for a long time
Estimated hours taken: 1

Since NU-Prolog hasn't been capable of executing the compiler for a long time
now, I have removed the .pp files and replaced them with .m files.

code_gen, mercury_compile, optimize:
	Remove NU-Prolog specific code.

Mmake:
	Don't refer to the .pp files.

dnf:
	Add the capability of transforming all procedures regardless of
	markers. This will be useful when generating idiomatic Prolog code.

mercury_to_goedel, polymorphism:
	Fix comments.
1996-10-28 02:08:24 +00:00