Commit Graph

135 Commits

Author SHA1 Message Date
Zoltan Somogyi
e35a09542e Print two kinds of ambiguities only if asked for.
trace/mercury_trace_cmd_developer.c:
trace/mercury_trace_tables.[ch]:
    Add two options to the mdb command "ambiguity".

    Print ambiguities between function and predicate forms of the same
    operation, such as list.length, only if the new option -b, or
    --both-pred-and-func, is given.

    Print ambiguities involving procedures that were created by type
    specialization only if the new option -s, or --typespec is given.
    (The -t option name was already taken.)

    These changes remove from the ambiguity command's output
    (some of) the parts that are not useful when one wants to eliminate
    ambiguities by renaming.

    Clarify a heading.

doc/user_guide.texi:
    Document the above changes.

runtime/mercury_proc_id.h:
    Fix a field name that has become misleading.

    MR_UserProcId_Structs have a field named MR_user_arity.
    In this name, the "MR_user_" part is a prefix shared by the other
    fields in that structure, to indicate that they are part of the id
    of a user-defined procedure, as opposed to a compiler-created
    unify, compare or index procedure. However, the arity it contains
    is what the compiler now calls a pred_form_arity: it does not count
    type_info and typeclass_info arguments added by polymorphism, but
    it *does* count function return values for functions. This is now
    misleading, because in the compiler, a user_arity does *not* count
    function return values for functions.

    Replace this field name with MR_user_pred_form_arity, which tells
    readers that this arity is a pred_form_arity. The presence of the
    "user" part of the name may still cause some confusion, but at least
    that confusion should motivate readers to look up the field name,
    whose comment should clarify things.

mdbcomp/rtti_access.m:
runtime/mercury_debug.c:
runtime/mercury_deep_profiling.c:
runtime/mercury_ho_call.c:
runtime/mercury_layout_util.c:
runtime/mercury_ml_expand_body.h:
runtime/mercury_stack_layout.h:
runtime/mercury_trace_base.c:
trace/mercury_trace.c:
trace/mercury_trace_external.c:
trace/mercury_trace_util.c:
    Conform to the change in mercury_proc_id.h.

tests/debugger/ambiguity.{m,inp,exp}:
tests/debugger/ambiguity_helper.m:
    Expand this test case to test the new functionality.
    The type specialized predicates are in a new helper module,
    because this is the simplest way to avoid dead procedure elimination
    deleting any of the predicates whose names we want to test for ambiguities.
2022-07-05 08:00:12 +10:00
Zoltan Somogyi
c5b35aca5f Fix the declarations of builtin proc layouts.
This should fix Mantis bug #514.

runtime/mercury_builtin_types_proc_layouts.h:
    Fix the first problem: refer to four type constructors defined
    in private_builtin.m by their correct arities, so that the proc layout
    structures we generate for their unify and compare predicates
    get generated with the correct names and contents.

    The arities were probably correct when the code was written;
    we changed them from 1 to 0 at some point, and simply forgot
    to update all the affected places.

runtime/mercury_stack_layout.h:
    Fix the second problem: add "extern" to the declarations of those
    proc layout structures. Without the "extern", compilers defaulting
    the -fcommon will place these structures into common storage,
    which can be used as *definitions*. With the "extern", compilers
    should do the right thing whether or not they default to -fcommon.

runtime/mercury_unify_compare_body.h:
    Conform to the change in mercury_builtin_types_proc_layouts.h:
    refer to the affected four types using the correct arities.
2020-07-24 17:14:07 +10:00
Zoltan Somogyi
02bf90da93 Fix a type-size-mismatch bug in RTTI.
runtime/mercury_stack_layout.h:
    Make the count of type params the same size as the descriptions
    of the locations of those type params, since they are filled in
    by values from the same compiler-generated array. The mismatch caused
    hard_coded/copy_pred_2.m to fail on a 64-bit big endian machine
    (AIX/PowerPC).
2019-06-05 17:33:10 +02:00
Julien Fischer
f8d188fda8 Fix minor documentation problems.
deep_profiler/display_report.m:
deep_profiler/message.m:
deep_profiler/recursion_patterns.m:
deep_profiler/var_use_analsis.m:
java/runtime/UnreachableDefault.java:
runtime/mercury_engine.c:
runtime/mercury_minimal_model.c:
runtime/mercury_signal.h:
runtime/mercury_stack_layout.h:
runtime/mercury_wrapper.c:
runtime/mercury_threadscope.c:
trace/mercury_trace_external.c:
HISTORY:
    As above.
2018-10-09 05:27:36 +00:00
Mark Brown
d465fa53cb Update the COPYING.LIB file and references to it.
Discussion of these changes can be found on the Mercury developers
mailing list archives from June 2018.

COPYING.LIB:
    Add a special linking exception to the LGPL.

*:
    Update references to COPYING.LIB.

    Clean up some minor errors that have accumulated in copyright
    messages.
2018-06-09 17:43:12 +10:00
Zoltan Somogyi
53b573692a Convert C code to use // style comments.
runtime/*.[ch]:
trace/*.[chyl]:
    As above. In some places, improve comments, e.g. by expanding contractions
    such as "we've". Add #ifndef guards against double inclusion around
    the trace/*.h files that did not already have them.

tools/*:
    Make the corresponding changes in shell scripts that generate .[ch] files
    in the runtime.

tests/*:
    Conform to a slight change in the text of a message.
2016-07-14 13:57:35 +02:00
Zoltan Somogyi
67326f16e4 Fix style issues in the runtime.
Move all .h and .c files to four-space indentation without tabs,
if they weren't there already.

Use the same vim line for all .h and .c files.

Align all backslashes at the ends of lines in macro definitions.
Align close comment signs.

In some places, fix inconsistent indentation.

Fix a bunch of comments. Add XXXs to a few of them.
2016-07-09 12:14:00 +02:00
Zoltan Somogyi
6367930ce3 Delete long obslete bootstrap code. 2016-03-16 23:26:57 +11:00
Zoltan Somogyi
8a6ffaab19 Fix Mantis bug #354.
I/O tabling has two main purposes. The first and more important is to allow the
debugger to replay parts of the program execution for the programmer, which
requires making I/O operations idempotent (so that we get the same results on
the second, third etc "execution" as on the first). The second purpose is to
let the person using the debugger actually see a list of the I/O actions, and
their results.

The root of the problem here is that the compiler can do the second part
only if it has access to the type_infos describing the types of the arguments
of the I/O action. With the current infrastructure for representing typeclass
information, this is not always possible in the presence of typeclass
constraints on I/O action predicates. The reason is that polymorphism.m can
put the typeinfo for a type variable that is subject to a typeclass constraint
arbitrarily deep inside the typeclass_info for that constraint, but the RTTI
can encode such locations only up to a fixed depth (currently only the
shallowest embedded is encodable).

Before this fix, the test case for this bug got a compiler abort when the
I/O tabling transformation tried to figure out how to table the typeclass
info representing the typeclass constraint on a I/O action predicate.

We still cannot table typeclass infos. We could store them (I/O tabling
does not require anything more complicated), but the problem of deeply buried
typeinfos inside them would still remain. So this fix consists of two parts:

- for typeclass constrained I/O primitives, recording only enough information
  to allow them to replayed (the first purpose above), and not to print them
  out (the second purpose), and
- getting the runtime system to understand this, and not crash with a core dump
  in the absence of the information required for the second purpose.

This second part requires changes to the RTTI used by I/O tabling. These
changes BREAK BINARY COMPATIBILITY in debug grades.

runtime/mercury_stack_layout.h:
    Rename the MR_TableIoDecl structure as the MR_TableIoEntry structure,
    since the I/O table entries that it describes are used not just for
    declarative debugging, but also for printing out I/O actions.

    Add a field to it that specifies whether the fields describing
    the types of the I/O action's arguments are meaningful.

runtime/mercury_grade.h:
    Bump the debug-only binary compatibility version number, since
    the change to mercury_stack_layout.h requires it.

runtime/mercury_trace_base.[ch]:
    When returning information about a tabled I/O action, return a boolean
    that says whether the information abouts its arguments is actually
    present or not. Do not return information about the arguments if
    we cannot convert them into univs due to missing type information.

browser/io_action.m:
    Pay attention to the new info returned by MR_trace_get_action,
    and avoid a potential core dump by generating a description of the
    requested I/O action only if the argument type information needed
    to generate that description is actually available.

trace/mercury_trace_vars.c:
    Pay attention to the new info returned by MR_trace_get_action.
    When the argument type information needed to generate an accurate
    description of the I/O action is not available, generate a
    "description" that mentions this fact.

trace/mercury_trace_cmd_browsing.c:
    Make the fix to mercury_trace_vars.c easier to test by adding a mechanism
    to print out all existing I/O actions, as long as there aren't too many
    of them.

compiler/hlds_pred.m:
compiler/layout.m:
compiler/prog_data.m:
    Prepare for the possibility that we have cannot record the information
    needed to reconstruct the runtime types of the arguments of a I/O tabled
    predicate.

compiler/table_gen.m:
    If an I/O tabled predicate has one or more typeclass constraints,
    do not attempt to record the RTTI needed to reconstruct the types
    of its arguments at runtime.

compiler/continuation_info.m:
compiler/hlds_data.m:
    Rename some data structures that referred to the old MR_TableIoDecl
    structure to refer to its replacement, the MR_TableIoEntry structure.

compiler/bytecode_gen.m:
compiler/ctgc.selector.m:
compiler/dead_proc_elim.m:
compiler/dependency_graph.m:
compiler/erl_unify_gen.m:
compiler/export.m:
compiler/higher_order.m:
compiler/hlds_code_util.m:
compiler/hlds_out_mode.m:
compiler/hlds_out_pred.m:
compiler/hlds_out_util.m:
compiler/hlds_pred.m:
compiler/implementation_defined_literals.m:
compiler/inst_check.m:
compiler/layout.m:
compiler/layout_out.m:
compiler/llds.m:
compiler/llds_out_data.m:
compiler/llds_out_file.m:
compiler/llds_out_util.m:
compiler/mercury_compile_llds_back_end.m:
compiler/mercury_to_mercury.m:
compiler/ml_global_data.m:
compiler/ml_switch_gen.m:
compiler/ml_type_gen.m:
compiler/ml_unify_gen.m:
compiler/mode_util.m:
compiler/module_qual.m:
compiler/opt_debug.m:
compiler/proc_gen.m:
compiler/prog_data.m:
compiler/prog_out.m:
compiler/prog_rep.m:
compiler/prog_type.m:
compiler/prog_util.m:
compiler/rbmm.execution_path.m:
compiler/stack_layout.m:
compiler/structure_reuse.direct.choose_reuse.m:
compiler/switch_gen.m:
compiler/switch_util.m:
compiler/type_ctor_info.m:
compiler/unify_gen.m:
compiler/unused_imports.m:
compiler/xml_documentation.m:
runtime/mercury_misc.h:
runtime/mercury_tabling.h:
    Conform to the above changes.

tests/debugger/tabled_typeclass.{m,inp,exp,exp2}:
    New test case to test that I/O actions that have typeclass constraints
    on them can be printed in mdb.

tests/debugger/Mmakefile:
tests/debugger/Mercury.options:
    Enable the new case.
2014-08-30 00:48:53 +02:00
Zoltan Somogyi
2d0bfc0674 The algorithm that decides whether the order independent state update
Estimated hours taken: 120
Branches: main

The algorithm that decides whether the order independent state update
transformation is applicable in a given module needs access to the list
of oisu pragmas in that module, and to information about the types
of variables in the procedures named in those pragmas. This diff
puts this information in Deep.procrep files, to make them available
to the autoparallelization feedback program, to which that algorithm
will later be added.

Compilers that have this diff will generate Deep.procrep files in a new,
slightly different format, but the deep profiler will be able to read
Deep.procrep files not just in the new format, but in the old format as well.

runtime/mercury_stack_layout.h:
	Add to module layout structures the fields holding the new information
	we want to put into Deep.procrep files. This means three things:

	- a bytecode array in module layout structures encoding the list
	  of oisu pragmas in the module;
	- additions to the bytecode arrays in procedure layout structures
	  mapping the procedure's variables to their types; and
	- a bytecode array containing the encoded versions of those types
	  themselves in the module layout structure. This allows us to
	  represent each type used in the module just once.

	Since there is now information in module layout structures that
	is needed only for deep profiling, as well as information that is
	needed only for debugging, the old arrangement that split a module's
	information between two structures, MR_ModuleLayout (debug specific
	info) and MR_ModuleCommonLayout (info used by both debugging and
	profiling), is no longer approriate. We could add a third structure
	containing profiling-specific info, but it is simpler to move
	all the info into just one structure, some of whose fields
	may not be used. This wastes only a few words of memory per module,
	but allows the runtime system to avoid unnecessary indirections.

runtime/mercury_types.h:
	Remove the type synonym for the deleted type.

runtime/mercury_grade.h:
	The change in mercury_stack_layout.h destroys binary compatibility
	with previous versions of Mercury for debug and deep profiling grades,
	so bump their grade-component-specific version numbers.

runtime/mercury_deep_profiling.c:
	Write out the information in the new fields in module layout
	structures, if they are filled in.

	Since this changes the format of the Deep.procrep file, bump
	its version number.

runtime/mercury_deep_profiling.h:
runtime/mercury_stack_layout.c:
	Conform to the change to mercury_stack_layout.h.

mdbcomp/program_representation.m:
	Add to module representations information about the oisu pragmas
	defined in that module, and the type table of the module.
	Optionally add to procedure representations a map mapping
	the variables of the procedure to their types.

	Rename the old var_table type to be the var_name_table type,
	since it contains just names. Make the var to type map separate,
	since it will be there only for selected procedures.

	Modify the predicates reading in module and procedure representations
	to allow them to read in the new representation, while still accepting
	the old one. Use the version number in the Deep.procrep file to decide
	which format to expect.

mdbcomp/rtti_access.m:
	Add functions to encode the data representations that this module
	also decodes.

	Conform to the changes above.

mdbcomp/feedback.automatic_parallelism.m:
	Conform the changes above.

mdbcomp/prim_data.m:
	Fix layout.

compiler/layout.m:
	Update the compiler's representation of layout structures
	to conform to the change to runtime/mercury_stack_layout.h.

compiler/layout_out.m:
	Output the new parts of module layout structures.

compiler/opt_debug.m:
	Allow the debugging of code referring to the new parts of
	module layout structures.

compiler/llds_out_file.m:
	Conform to the move to a single module layout structure.

compiler/prog_rep_tables.m:
	This new module provided mechanisms for building the string table
	and the type table components of module layouts. The string table
	part is old (it is moved here from stack_layout.m); the type table
	part is new.

	Putting this code in a module of its own allows us to remove
	a circular dependency between prog_rep.m and stack_layout.m;
	instead, both now just depend on prog_rep_tables.m.

compiler/ll_backend.m:
	Add the new module.

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

compiler/prog_rep.m:
	When generating the representation of a module for deep profiling,
	include the information needed by the order independent state update
	analysis: the list of oisu pragmas in the module, if any, and
	information about the types of variables in selected procedures.

	To avoid having these additions increasing the size of the bytecode
	representation too much, convert some fixed 32 bit numbers in the
	bytecode to use variable sized numbers, which will usually be 8 or 16
	bits.

	Do not use predicates from bytecode_gen.m to encode numbers,
	since there is nothing keeping these in sync with the code that
	reads them in mdbcomp/program_representation.m. Instead, use
	new predicates in program_representation.m itself.

compiler/stack_layout.m:
	Generate the new parts of module layouts.

	Remove the code moved to prog_rep_tables.m.

compiler/continuation_info.m:
compiler/proc_gen.m:
	Make some more information available to stack_layout.m.

compiler/prog_data.m:
	Fix some formatting.

compiler/introduce_parallelism.m:
	Conform to the renaming of the var_table type.

compiler/follow_code.m:
	Fix the bug that used to cause the failure of the
	hard_coded/mode_check_clauses test case in deep profiling grades.

deep_profiler/program_representation_utils.m:
	Output the new parts of module and procedure representations,
	to allow the correctness of this change to be tested.

deep_profiler/mdprof_create_feedback.m:
	If we cannot read the Deep.procrep file, print a single error message
	and exit, instead of continuing with an analysis that will generate
	a whole bunch of error messages, one for each attempt to access
	a procedure's representation.

deep_profiler/mdprof_procrep.m:
	Give this program an option that specifies what file it is to
	look at; do not hardwire in "Deep.procrep" in the current directory.

deep_profiler/report.m:
	Add a report type that just prints the representation of a module.
	It returns the same information as mdprof_procrep, but from within
	the deep profiler, which can be more convenient.

deep_profiler/create_report.m:
deep_profiler/display_report.m:
	Respectively create and display the new report type.

deep_profiler/query.m:
	Recognize a query asking for the new report type.

deep_profiler/autopar_calc_overlap.m:
deep_profiler/autopar_find_best_par.m:
deep_profiler/autopar_reports.m:
deep_profiler/autopar_search_callgraph.m:
deep_profiler/autopar_search_goals.m:
deep_profiler/autopar_types.m:
deep_profiler/branch_and_bound.m:
deep_profiler/coverage.m:
deep_profiler/display.m:
deep_profiler/html_format.m:
deep_profiler/mdprof_test.m:
deep_profiler/measurements.m:
deep_profiler/query.m:
deep_profiler/read_profile.m:
deep_profiler/recursion_patterns.m:
deep_profiler/top_procs.m:
deep_profiler/top_procs.m:
	Conform to the changes above.

	Fix layout.

tests/debugger/declarative/dependency.exp2:
	Add this file as a possible expected output. It contains the new
	field added to module representations.
2012-10-24 04:59:55 +00:00
Zoltan Somogyi
c733b0359b Give the Mercury debugger the ability to detect cliques of mutually recursive
Estimated hours taken: 30
Branches: main

Give the Mercury debugger the ability to detect cliques of mutually recursive
predicates on the stack. Exploit this ability to enhance the debugger's
level, retry, finish and stack commands.

runtime/mercury_stack_trace.[ch]:
	Add a function, MR_find_clique_entry, that detects the clique
	that contains the top stack frame. This is used to implement the new
	arguments "clentry" and "clparent" (short for clique entry and parent)
	options of the level, retry and finish commands. "clique" is a synonym
	for "clentry" in these commands.

	Add a function, MR_dump_stack_layout_clique, that implements the
	new capabilities of the stack command. It can detect more than one
	clique, anywhere on the stack.

	To make this possible, modify the existing functions for printing
	the lines of stack traces. These used to keep some information around
	between calls in global variables. Now that information is stored in
	two structures that the caller passes them. One contains the parameters
	that govern what is to be printed, the other contains information about
	what has been buffered up to be printed, but has not been flushed yet.
	(The old code was confused in its handling of parameters. Some parts
	of it looked up the global variables storing them, while other parts
	were given the parameter values by their callers, values that could
	have been -but weren't- inconsistent.)

	Change the buffer flushing code to be idempotent, since in the new
	code, sometimes it is hard to avoid flushing the buffer more than once,
	and we want only the first to print its contents.

	Make some type names conform to our standard style.

runtime/mercury_stack_layout.h:
	Add a new flag in MR_ProcLayouts: a flag that indicates that the
	procedure has one or more higher order arguments. The new code in
	mercury_stack_trace.c handles procedures with this flag specially:
	it does not consider two non-consecutive occurrences of such procedures
	on the stack to be necessarily part of the same clique. This is to
	avoid having two calls to e.g. list.map in different part of the
	program pulling all the procedures between those parts on the stack
	into a single clique. (The deep profiler has a very similar tweak.)

	Add a pointer to the corresponding part of the compiler.

compiler/hlds_pred.m:
	Add a predicate to test whether a predicate has any higher order args.

compiler/stack_layout.m:
	When computing the flag in proc layouts, call the new procedure in
	hlds_pred.m to help figure it out.

trace/mercury_trace_cmd_backward.c:
	Implement the new options of the "retry" command.

trace/mercury_trace_cmd_forward.c:
	Implement the new options of the "finish" command.

trace/mercury_trace_cmd_browsing.c:
	Implement the "new options of the "level" command.

	Implement the new functionality of the "stack" command.

trace/mercury_trace_util.[ch]:
	Add some code common to the implementations of the level, retry and
	finish commands.

trace/mercury_trace_external.c:
	Conform to the changes to the runtime.

doc/user_guide.texi:
	Document the debugger's new capabilities.

NEWS:
	Announce the debugger's new capabilities.

tests/debugger/mutrec.{m,inp,exp}:
	A new test case to test the handling of the stack command
	in the presence of cliques.

tests/debugger/mutrec_higher_order.{m,inp,exp}:
	A new test case to test the handling of the stack command
	in the presence of cliques and higher order predicates.

tests/debugger/Mmakefile:
	Enable both new test cases.
2012-06-05 18:19:33 +00:00
Peter Wang
2ccac171dd Add float registers to the Mercury abstract machine, implemented as an
Branches: main

Add float registers to the Mercury abstract machine, implemented as an
array of MR_Float in the Mercury engine structure.

Float registers are only useful if a Mercury `float' is wider than a word
(i.e. when using double precision floats on 32-bit platforms) so we let them
exist only then.  In other cases floats may simply be passed via the regular
registers, as before.

Currently, higher order calls still require the use of the regular registers
for all arguments.  As all exported procedures are potentially the target of
higher order calls, exported procedures must use only the regular registers for
argument passing.  This can lead to more (un)boxing than if floats were simply
always boxed.  Until this is solved, float registers must be enabled explicitly
with the developer only option `--use-float-registers'.

The other aspect of this change is using two consecutive stack slots to hold a
single double variable.  Without that, the benefit of passing unboxed floats
via dedicated float registers would be largely eroded.


compiler/options.m:
	Add developer option `--use-float-registers'.

compiler/handle_options.m:
	Disable `--use-float-registers' if floats are not wider than words.

compiler/make_hlds_passes.m:
	If `--use-float-registers' is in effect, enable a previous change that
	allows float constructor arguments to be stored unboxed in structures.

compiler/hlds_llds.m:
	Move `reg_type' here from llds.m and `reg_f' option.

	Add stack slot width to `stack_slot' type.

	Add register type and stack slot width to `abs_locn' type.

	Remember next available float register in `abs_follow_vars'.

compiler/hlds_pred.m:
	Add register type to `arg_loc' type.

compiler/llds.m:
	Add a new kind of lval: double-width stack slots.
	These are used to hold double-precision floating point values only.

	Record setting of `--use-float-registers' in exprn_opts.

	Conform to addition of float registers and double stack slots.

compiler/code_info.m:
	Make predicates take the register type as an argument,
	where it can no longer be assumed.

	Remember whether float registers are being used.

	Remember max float register for calls to MR_trace.

	Count double width stack slots as two slots.

compiler/arg_info.m:
	Allocate float registers for procedure arguments when appropriate.

	Delete unused predicates.

compiler/var_locn.m:
	Make predicates working with registers either take the register type as
	an argument, or handle both register types at once.

	Select float registers for variables when appropriate.

compiler/call_gen.m:
	Explicitly use regular registers for all higher-order calls,
	which was implicit before.

compiler/pragma_c_gen.m:
	Use float registers, when available, at the interface between Mercury
	code and C foreign_procs.

compiler/export.m:
	Whether a float rval needs to be boxed/unboxed when assigned to/from a
	register depends on the register type.

compiler/fact_table.m:
	Use float registers for arguments to predicates defined by fact tables.

compiler/stack_alloc.m:
	Allocate two consecutive stack slots for float variables when
	appropriate.

compiler/stack_layout.m:
	Represent double-width stack slots in procedure layout structures.

	Conform to changes.

compiler/store_alloc.m:
	Allocate float registers (if they exist) for float variables.

compiler/use_local_vars.m:
	Substitute float abstract machine registers with MR_Float local
	variables.

compiler/llds_out_data.m:
compiler/llds_out_instr.m:
	Output float registers and double stack slots.

compiler/code_util.m:
compiler/follow_vars.m:
	Count float registers separately from regular registers.

compiler/layout.m:
compiler/layout_out.m:
compiler/trace_gen.m:
	Remember the max used float register for calls to MR_trace().

compiler/builtin_lib_types.m:
	Fix incorrect definition of float_type_ctor.

compiler/bytecode_gen.m:
compiler/continuation_info.m:
compiler/disj_gen.m:
compiler/dupelim.m:
compiler/exprn_aux.m:
compiler/global_data.m:
compiler/hlds_out_goal.m:
compiler/jumpopt.m:
compiler/llds_to_x86_64.m:
compiler/lookup_switch.m:
compiler/opt_debug.m:
compiler/opt_util.m:
compiler/par_conj_gen.m:
compiler/proc_gen.m:
compiler/string_switch.m:
compiler/tag_switch.m:
compiler/tupling.m:
compiler/x86_64_regs.m:
	Conform to changes.

runtime/mercury_engine.h:
	Add an array of fake float "registers" to the Mercury engine structure,
	when MR_Float is wider than MR_Word.

runtime/mercury_regs.h:
	Document float registers in the Mercury abstract machine.

	Add macros to access float registers in the Mercury engine.

runtime/mercury_stack_layout.h:
	Add new MR_LongLval cases to represent double-width stack slots.

	MR_LONG_LVAL_TAGBITS had to be increased to accomodate the new cases,
	which increases the number of integers in [0, 2^MR_LONG_LVAL_TAGBITS)
	equal to 0 modulo 4.  These are the new MR_LONG_LVAL_TYPE_CONS_n cases.

	Add max float register field to MR_ExecTrace.

runtime/mercury_layout_util.c:
runtime/mercury_layout_util.h:
	Extend MR_copy_regs_to_saved_regs and MR_copy_saved_regs_to_regs
	for float registers.

	Understand how to look up new kinds of MR_LongLval: MR_LONG_LVAL_TYPE_F
	(previously unused), MR_LONG_LVAL_TYPE_DOUBLE_STACKVAR,
	MR_LONG_LVAL_TYPE_DOUBLE_FRAMEVAR.

	Conform to the new MR_LONG_LVAL_TYPE_CONS_n cases.

runtime/mercury_float.h:
	Delete redundant #ifdef.

runtime/mercury_accurate_gc.c:
runtime/mercury_agc_debug.c:
	Conform to changes (untested).

trace/mercury_trace.c:
trace/mercury_trace.h:
trace/mercury_trace_declarative.c:
trace/mercury_trace_external.c:
trace/mercury_trace_internal.c:
trace/mercury_trace_spy.c:
trace/mercury_trace_vars.c:
trace/mercury_trace_vars.h:
	Handle float registers in the trace subsystem.  This is mostly a matter
	of saving/restoring them as with regular registers.
2011-10-17 04:31:33 +00:00
Zoltan Somogyi
eccc863e7d Add comments about my recent design decision about the representation
Estimated hours taken: 0.1
Branches: main

runtime/mercury_stack_layout.h:
trace/mercury_trace_declararative.c:
	Add comments about my recent design decision about the representation
	of goal paths.
2011-09-30 05:24:28 +00:00
Zoltan Somogyi
10d6f4c2e2 Remove a bunch of long-obsolete macros. Their job was to define
Estimated hours taken: 0.1
Branches: main

runtime/mercury_stack_layout.h:
	Remove a bunch of long-obsolete macros. Their job was to define
	or to declare individual label layouts, but for a long time now
	we have put all label layouts into arrays.
2011-09-28 07:06:23 +00:00
Zoltan Somogyi
8e3ead5903 Reduce the size of the string tables in debuggable executables by encoding
Estimated hours taken: 6
Branches: main

Reduce the size of the string tables in debuggable executables by encoding
variable names that fit a few standard templates, the most important of which
is STATE_VARIABLE_name_number.

The effect on the compiler is to reduce the string table size from about
3.1Mb to about 2.1Mb, which is about a 30% reduction.

compiler/stack_layout.m:
	Look for the names fitting the patterns in variable names, and encode
	them.

runtime/mercury_stack_layout.[ch]:
	Add a function for looking up variable names, decoding them if needed.

	Since goal paths cannot fit any of the patterns, access them without
	using that function.

mdbcomp/rtti_access.m:
	Use the new function to retrieve variable names.

runtime/mercury_grade.h:
	Increment the debugging compatibility version number, since debuggable
	executables in which some modules were produced by a compiler without
	this diff and some were produced by a compiler with this diff won't
	work together.
2011-09-26 04:29:37 +00:00
Zoltan Somogyi
58211e2f2e Allow more than 2^15 vars in a procedure representation.
Estimated hours taken: 12
Branches: main

Allow more than 2^15 vars in a procedure representation.

mdbcomp/program_representation.m:
	Allow a variable number to be represented by four bytes as well as
	two and one. This means that we also have to represent the number
	of variables in a procedure using a four-byte number, not a two-byte
	number.

	Use four bytes to represent line numbers. Programs that overflow
	16-bit var numbers may also overflow 16 bit line numbers.

	These requires a change in the deep profiler data's binary
	compatibility version number.

compiler/prog_rep.m:
	Encode vars using four bytes if necessary. Be consistent in using
	only signed 8-bit as well as signed 16-bit numbers.

compiler/implicit_parallelism.m:
	Conform to the change in program_representation.m.

deep_profiler/profile.m:
deep_profiler/read_profile.m:
	Add a compression flag to the set of flags read from the data file.
	Put the flags into the profile_stats as a group, not one-by-one.

deep_profiler/canonical.m:
deep_profiler/create_report.m:
deep_profiler/dump.m:
deep_profiler/mdprof_feedback.m:
deep_profiler/old_html_format.m:
deep_profiler/old_query.m:
deep_profiler/query.m:
	Conform to the change in profile.m.

runtime/mercury_deep_profiling.c:
	Prepare for compression of profiling data files being implemented.

runtime/mercury_stack_layout.h:
	Fix some documentation rot.

runtime/mercury_conf_param.h:
	Add an implication between debug flags to make debugging easier.
2010-10-11 00:49:27 +00:00
Zoltan Somogyi
22bf94a53e Fix the bug that caused problems in debug grades on 64 bit machines,
Estimated hours taken: 2
Branches: main

Fix the bug that caused problems in debug grades on 64 bit machines,
as well as some related warnings from the C compiler.

runtime/mercury_stack_layout.h:
	Make MR_LongLvals word size on 64 bit machines as well as 32 bit
	machines.

compiler/layout_out.m:
	Cast some rvals to the expected type.

compiler/llds_out_global.m:
	Don't put & before the names of globals that are already arrays,
	and hence addresses.
2009-11-10 04:23:40 +00:00
Zoltan Somogyi
d4bbcda309 Move all the frequently occurring layout structures and components of layout
Estimated hours taken: 40
Branches: main

Move all the frequently occurring layout structures and components of layout
structures into arrays where possible. By replacing N global variables holding
individual layout structures or layout structure components with one global
variable holding an array of them, we reduce the sizes of the symbol tables
stored in object files, which should speed up both the C compiler and the
linker.

Measured on the modules of the library, mdbcomp and compiler directories
compiled in grade asm_fast.gc.debug, this diff reduces the size of the
generated C source files by 7.8%, the size of the generated object files
by 10.4%, and the number of symbols in the symbol tables of those object files
by a whopping 42.8%. (These improvements include, and are not on top of,
the improvements in my previous similar diff.)

runtime/mercury_stack_layout.h:
	Each label layout structure has information about the type and
	location of every variable that is live at that label. We store
	this information in three arrays: an array of pseudo-typeinfos giving
	the types of all these variables, and two arrays MR_ShortLvals and
	MR_LongLvals respectively giving their locations. (Most of the time,
	the location's encoded form fits into one byte (the MR_ShortLval)
	but sometimes it needs more bits (this is when we use MR_LongLval)).

	We used to store these three arrays, whose elements are different
	types, in a single occurrence-specific common structure,
	one after the other, with a cumbersome mechanism being required
	to access them. We now store them as segments of three separate arrays,
	of pseudo-typeinfos, MR_ShortLvals and MR_LongLvals respectively.
	This makes access simpler and faster (which will matter more to any
	accurate garbage collector than it does to the debugger). It also
	allows more scope for compression, since reusing an existing segment of
	one of the three arrays is easier than reusing an entire common
	structure, which would require the equivalent of exact matches
	on all three arrays.

	Since most label layout structures that have information about
	variables can encode the variables' locations using only MR_ShortLvals,
	create a version of the label layout structure type that omits the
	field used to record the whereabouts of the long location descriptors.

	Add macros now generated by the compiler to initialize layout
	structures.

	Simplify a one-field struct.

runtime/mercury_grade.h:
	Increment the binary compatibility version number for debuggable
	executables, since .c and .o files from before and after the change
	to label layout structures are NOT compatible.

runtime/mercury_type_info.h:
	Fix some binary-compatibility-related bit rot.

runtime/mercury_misc.h:
	Move here the existing macros used by the compiler when generating
	references to layout arrays, and add new ones.

runtime/mercury_goto.h:
	Delete the macros moved to mercury_misc.h.
	Conform to the changes in mercury_stack_layout.h.

runtime/Mmakefile:
	Prevent the unnecessary rebuilding of mercury_conf.h.

runtime/mercury_accurate_gc.c:
runtime/mercury_agc_debug.c:
runtime/mercury_layout_util.c:
runtime/mercury_stack_trace.c:
runtime/mercury_types.h:
trace/mercury_trace.c:
trace/mercury_trace_vars.c:
	Conform to the changes in mercury_stack_layout.h.

runtime/mercury_wrapper.c:
	Improve the debug support a bit.

runtime/mercury_engine.h:
	Fix style.

compiler/layout.m:
	Make the change described at the top. Almost all layout structures
	are now in arrays. The only exceptions are those that occur rarely,
	and proc layouts, whose names need to be derivable from the name
	of the procedure itself.

	Instead of having a single type "layout_data" that can represent
	different kinds of single global variables (not array slots), have
	different kinds for different purposes. This makes the code clearer
	and allows traversals that do not have to skip over inapplicable kinds
	of layout structures.

compiler/layout_out.m:
	Output the new arrays.

compiler/stack_layout.m:
	Generate the new arrays. Previously, an individual term generated by
	stack_layout.m could represent several components of a layout
	structure, with the components separated by layout_out.m. We now
	do the separation in stack_layout.m itself, adding each component
	to the array to which it belongs.

	Instead of passing around a single stack_layout_info structure,
	pass around several smaller one. This is preferable, since I found out
	the hard way that including everything in one structure would give the
	structure 51 fields. Most parts of the module work with only one
	or two of these structures, which makes their role clearer.

	Cluster related predicates together.

compiler/options.m:
doc/user_guide.texi:
	Add an option that control whether stack_layout.m will attempt to
	compress the layout arrays that can meaningfully be comressed.

compiler/llds.m:
	Remove the old distinction between a data_addr and a data_name,
	replacing both types with a single new one: data_id. Since different
	kinds of data_names were treated differently in many places,
	the distinction in types (which was intended to allow us to process
	data_addrs that wrapped data_names differently from other kinds of
	data_addrs) wasn't buying us anything anymore.

	The new data_id type allows for the possibility that the code generator
	wants to generate a reference to an address it does not know yet,
	because it is a slot in a layout array, and the slot has not been
	allocated yet.

	Add the information from which the new layout array structures
	will be generated to the LLDS.

compiler/llds_out.m:
	Call layout_out.m to output the new layout arrays.

	Adapt the decl_id type to the replacement of data_addrs by data_ids.
	Don't both keeping track of the have-vs-have-not-declared status
	of structures that are always declared at the start.

	When writing out a data_addr, for some kinds of data_addr, llds_out.m
	would write out the name of the relevant variable, while for some other
	kinds, it would write out its address. This diff separates out those
	those things into separate predicates, each of which behaves
	consistently.

compiler/mercury_compile_llds_back_end.m:
	Convey the intended contents of the new layout arrays from
	stack_layout.m to llds_out.m.

compiler/continuation_info.m:
	Add a type required by the way we now generate proc_static structures
	for deep profiling.

compiler/hlds_rtti.m:
	Add distinguishing prefixes to the field names of the rtti_proc_label
	type.

compiler/code_info.m:
compiler/code_util.m:
compiler/erl_rtti.m:
compiler/exprn_aux.m:
compiler/global_data.m:
compiler/ll_pseudo_type_info.m:
compiler/ml_code_util.m:
compiler/opt_debug.m:
compiler/proc_gen.m:
compiler/prog_rep.m:
compiler/rtti_out.m:
compiler/unify_gen.m:
	Conform to the changes above.

tests/debugger/declarative/track_through_catch.exp:
	Expect procedures to be listed in the proper order.

tests/EXPECT_FAIL_TESTS.asm_fast.gc.debug:
tests/EXPECT_FAIL_TESTS.asm_fast.gc.profdeep:
	Add these files to ignore expected failues in these grades.
2009-10-30 03:33:34 +00:00
Zoltan Somogyi
9bdc5db590 Try to work around the Snow Leopard linker's performance problem with
Estimated hours taken: 20
Branches: main

Try to work around the Snow Leopard linker's performance problem with
debug grade object files by greatly reducing the number of symbols needed
to represent the debugger's data structures.

Specifically, this diff groups all label layouts in a module, each of which
previously had its own named global variable, into only a few (one to four)
global variables, each of which is an array. References to the old global
variables are replaced by references to slots in these arrays.

This same treatment could also be applied to other layout structures. However,
most layouts are label layouts, so doing just label layouts gets most of the
available benefit.

When the library and compiler are compiled in grade asm_fast.gc.debug,
this diff leads to about a 1.5% increase in the size of their generated C
source files (from 338 to 343 Mb), but a more significant reduction (about 17%)
in the size of the corresponding object files (from 155 to 128 Mb). This leads
to an overall reduction in disk requirements from 493 to 471 Mb (about 4.5%).
Since we generate the same code and data as before, with the data just being
arranged differently, the decrease in object file sizes is coming from the
reduction in relocation information, the information processed by the linker.
This should speed up the linker.

compiler/layout.m:
	Make the change described above. We now define up to four arrays:
	one each for label layouts with and without information about
	variables, one for the layout structures of user events,
	and one for the variable number lists of user events.

compiler/layout_out.m:
	Generate the new arrays that the module being compiled needs.

	Use purpose-specific types instead of booleans.

compiler/trace_gen.m:
	Use a new field in foreign_proc_code instructions to record the
	identity of any labels whose layout structures we want to refer to,
	even though layout structures have not been generated yet. The labels
	will be looked up in a map (generated together with the layout
	structures) by llds_out.m.

compiler/llds.m:
	Add this extra field to foreign_proc_code instructions.

	Add the map (which is actually in two parts) to the c_file type,
	which is the data structure representing the entire LLDS.

	Also add to the c_file type some other data structures that previously
	we used to hand around alongside it. Some of these data structures
	used to conmingle layout structures that we now separate.

compiler/stack_layout.m:
	Generate array slots instead of separate structures for label layouts.
	Return the different arrays separately.

compiler/llds_out.m:
	Order the output of layout structures to require fewer forward
	declarations. The forward declarations of the few arrays holding the
	label layout structures replace a lot of the declarations previously
	needed.

	Include the information needed by layout_out.m in the llds_out_info,
	and conform to the changes above.

	As a side-effect of all these changes, we now generate proc layout
	structures in the same order as the procedures' appearence in the HLDS,
	which is the same as their order in the source code, modulo any
	procedures added by the compiler itself (for lambdas, unification
	predicates, etc).

compiler/code_info.m:
compiler/dupelim.m:
compiler/dup_proc.m:
compiler/exprn_aux.m:
compiler/frameopt.m:
compiler/global_data.m:
compiler/ite_gen.m:
compiler/jumpopt.m:
compiler/livemap.m:
compiler/llds_to_x86_64.m:
compiler/mercury_compile_llds_back_end.m:
compiler/middle_rec.m:
compiler/opt_debug.m:
compiler/opt_util.m:
compiler/pragma_c_gen.m:
compiler/proc_gen.m:
compiler/reassign.m:
compiler/use_local_vars.m:
	Conform to the changes above.

runtime/mercury_goto.h:
	Add the macros used by the new code in layout_out.m and llds_out.m.
	We need new macros because the old ones assumed that the
	C preprocessor can construct the address of a label's layout structure
	from the name of the label, which is obviously no longer possible.

	Make even existing families of macros handle in bulk up to 10 labels,
	up from the previous 8.

runtime/mercury_stack_layout.h:
	Add macros for use by the new code in layout.m.

tests/debugger/*.{inp,exp}:
tests/debugger/declarative/*.{inp,exp}:
	Update these test cases to account for the new (and better) order
	of proc layout structures. Where inputs changed, this was to ensure
	that we still select the same procedures from lists of procedures,
	e.g. to put a breakpoint on.
2009-10-21 06:36:37 +00:00
Zoltan Somogyi
c7c3cf50cd Fix a bug in the MR_DEF_LLNVI_U macro, which defined the the fields
Estimated hours taken: 0.3
Branches: main

runtime/mercury_stack_layout.h:
	Fix a bug in the MR_DEF_LLNVI_U macro, which defined the the fields
	of the label layout structure out of order. There is no test case
	for the bug, since the bug manifested iself only if the variable had
	no information about variables (the "NVI" stands for "no variable
	information"), and our tests all do have such information.

	Make such mistakes harder in the future by making the order of the
	arguments of the macro follow the order of the structure's arguments,
	and by updating the macro argument name that refers to the field for
	user events ("ue", instead of the old "s" for solver events).
2008-11-26 03:01:59 +00:00
Zoltan Somogyi
53286dd4bf Implement a new compiler option, --exec-trace-tail-rec, that preserves direct
Estimated hours taken: 30
Branches: main

Implement a new compiler option, --exec-trace-tail-rec, that preserves direct
tail recursion in det and semidet procedures even when debugging is enabled.
This should allow the debugging of programs that previously ran out of stack.

The problem arose because even a directly tail-recursive call had some code
after it: the code for the EXIT event, like this:

	p:
		incr_sp
		fill in the usual debug slots
		CALL EVENT
		...
		/* tail call */
		move arguments to registers as usual
		call p, return to p_ret
	p_ret:
		/* code to move output arguments to right registers is empty */
		EXIT EVENT
		decr_sp
		return

If the new option is enabled, the compiler will now generate code like this:

	p:
		incr_sp
		fill in the usual debug slots
		fill in new "stack frame reuse count" slot with 0
		CALL EVENT
	p_1:
		...
		/* tail call */
		move arguments to registers as usual
		update the usual debug slots
		increment the "stack frame reuse count" slot
		TAILCALL EVENT
		goto p_1

The new TAIL event takes place in the caller's stack frame, so that the local
variables of the caller are available. This includes the arguments of the
recursive call (though if they are unnamed variables, the debugger will not
show them). The TAIL event serves as a replacement for the CALL event
of the recursive invocation.

compiler/options.m:
	Add the new option.

compiler/handle_options.m:
	Handle an implication of the new option: the declarative debugger
	does not (yet) understand TAIL events.

compiler/mark_tail_calls.m:
	New module to mark directly tail recursive calls and the procedures
	containing them as such.

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

compiler/mercury_compile.m:
	Invoke the new module when the new option asks us to.

compiler/hlds_goal.m:
	Add the feature used to mark tail recursive calls for the debugger.
	Rename an existing feature with a similar but not identical purpose
	to avoid possible confusion.

compiler/hlds_pred.m:
	Add a field to proc_infos that says whether the procedure contains
	tail recursive calls.

	Minor style improvements.

compiler/passes_aux.m:
	Minor change to accommodate the needs of the new module.

compiler/code_info.m:
	Transmit the information from mark_tail_calls to the code generator.

compiler/call_gen.m:
	Implement the new option.

compiler/trace_gen.m:
	Reserve the extra slot needed for the new option.

	Switch to state variable notation in the code that does the slot
	allocation, since this is less error-prone than the previous approach.

compiler/layout.m:
compiler/layout_out.m:
compiler/stack_layout.m:
	Remember what stack slot holds the stack frame reuse counter,
	for transmission to the runtime system.

compiler/proc_gen.m:
	Add the new label needed for tail recursion.

	Put the arguments of some procedures into a more logical order.

compiler/deep_profiling.m:
compiler/deforest.m:
compiler/saved_vars.m:
compiler/table_gen.m:
	Conform to the changes above.

compiler/trace_params.m:
mdbcomp/prim_data.m:
runtime/mercury_trace_base.[ch]:
	Add the new event type.

	Convert mercury_trace_base.h to four-space indentation.

runtime/mercury_stack_layout.h:
	Add a field to the execution trace information we have for each
	procedure that gives the number of the stack slot (if any) that holds
	the stack frame reuse counter. Add a macro to get the value in the
	counter.

	Convert this header file to four-space indentation.

runtime/mercury_stack_trace.[ch]:
	When walking the stack, we now have to be prepared to encounter stack
	frames that have been reused. Modify the algorithms in this module
	accordingly, and modify the interfaces of the exported functions
	to allow the functions' callers to behave accordingly as well.

	Group the information we gather about stack frame for printing into
	one structure, and document it.

	Convert the header to four-space indentation.

library/exception.m:
mdbcomp/trace_counts.m:
	Conform to the changes above.

	In trace_counts.m, fix an apparent cut-and-paste error (that hasn't
	caused any test case failures yet).

trace/mercury_trace.c:
	Modify the implementation of the "next" and "finish" commands
	to accommodate the possibility that the procedure at the selected
	depth may have had its stack frame reused. In such cases

tests/debugger/tailrec1.{m,inp,exp,data}:
	A new test case to check the handling of tail recursive procedures.
2008-11-25 07:46:57 +00:00
Zoltan Somogyi
5f4bda4054 Fix typo in comment.
Estimated hours taken: 0.1
Branches: main

runtime/mercury_stack_layout.h:
	Fix typo in comment.
2008-03-18 01:31:33 +00:00
Zoltan Somogyi
2dc982cfe4 Make a representation of the program available to the deep profiler.
Estimated hours taken: 50
Branches: main

Make a representation of the program available to the deep profiler. We do
this by letting the user request, via the option "--deep-procrep-file"
in MERCURY_OPTIONS, that when the Deep.data file is written, a Deep.procrep
file should be written alongside it.

The intended use of this information is the discovery of profitable
parallelism. When a conjunction contains two expensive calls, e.g. p(...) and
q(...) connected by some shared variables, the potential gain from executing
them in parallel is limited by how early p produces those variables and how
late q consumes them, and knowing this requires access to the code of p and q.

Since the debugger and the deep profiler both need access to program
representations, put the relevant data structures and the operations on them
in mdbcomp. The data structures are significantly expanded, since the deep
profiler deals with the whole program, while the debugger was interested only
in one procedure at a time.

The layout structures have to change as well. In a previous change, I changed
proc layout structures to make room for the procedure representation even in
non-debugging grades, but this isn't enough, since the procedure representation
refers to the module's string table. This diff therefore makes some parts of
the module layout structure, including of course the string table, also
available in non-debugging grades.

configure.in:
	Check whether the installed compiler can process switches on foreign
	enums correctly, since this diff depends on that.

runtime/mercury_stack_layout.[ch]:
runtime/mercury_types.h:
	Add a new structure, MR_ModuleCommonLayout, that holds the part of
	the module layout that is common to deep profiling and debugging.

runtime/mercury_deep_profiling.[ch]:
	The old "deep profiling token" enum type was error prone, since at
	each point in the data file, only a subset was applicable. This diff
	breaks up the this enum into several enums, each consisting of the
	choice applicable at a given point.

	This also allows some of the resulting enums to be used in procrep
	files.

	Rename some enums and functions to avoid ambiguities, and in one case
	to conform to our naming scheme.

	Make write_out_proc_statics take a second argument. This is a FILE *
	that (if not NULL) asks write_out_proc_statics to write the
	representation of the current module to specified stream.

	These module representations go into the middle part of the program
	representation file. Add functions to write out the prologue and
	epilogue of this file.

	Write out procedure representations if this is requested.

	Factor out some code that is now used in more than one place.

runtime/mercury_deep_profiling_hand.h:
	Conform to the changes to mercury_deep_profiling.h.

runtime/mercury_builtin_types.c:
	Pass the extra argument in the argument lists of invocations of
	write_out_proc_statics.

runtime/mercury_trace_base.[ch]:
	Conform to the name change from proc_rep to proc_defn_rep in mdbcomp.

runtime/mercury_grade.h:
	Due to the change to layout structures, increment the binary
	compatibility version numbers for both debug and deep profiling grades.

runtime/mercury_wrapper.[ch]:
	Provide two new MERCURY_OPTION options. The first --deep-procrep-file,
	allows the user to ask for the program representation to be generated.
	The second, --deep-random-write, allows tools/bootcheck to request that
	only a fraction of all program invocations should generate any deep
	profiling output.

	The first option will be documented once it is tested much more fully.
	The second option is deliberately not documented.

	Update the type of the variable that holds the address of the
	(mkinit-generated) write_out_proc_statics function to accept the second
	argument.

util/mkinit.c:
	Pass the extra argument in the argument list of write_out_proc_statics.

mdbcomp/program_representation.m:
	Extend the existing data structures for representing a procedure body
	to represent a procedure (complete with name), a module and a program.
	The name is implemented as string_proc_label, a form of proc_label that
	can be written out to files. This replaces the old proc_id type the
	deep profiler.

	Extend the representation of switches to record the identity of the
	variable being switched on, and the cons_ids of the arms. Without the
	former, we cannot be sure when a variable is first used, and the latter
	is needed for meaningful prettyprinting of procedure bodies.

	Add code for reading in files of bytecodes, and for making sense of the
	bytecodes themselves. (It is this code that uses foreign enums.)

mdbcomp/prim_data.m:
	Note the relationship of proc_label with string_proc_label.

mdbcomp/rtti_access.m:
	Add the access operations needed to find module string tables with the
	new organization of layout structures.

	Provide operations on bytecodes and string tables generally.

trace/mercury_trace_cmd_browsing.c:
	Conform to the change to mdbcomp/program_representation.m.

compiler/layout.m:
	Add support for a MR_ModuleCommonLayout.

	Rename some function symbols to avoid ambiguities.

compiler/layout_out.m:
	Handle the new structure.

compiler/stack_layout.m:
	Generate the new structure and the procedure representation bytecode
	in deep profiling grades.

compiler/llds_out.m:
	Generate the code required to write out the prologue and epilogue
	of program representation files.

	Pass the extra argument in the argument lists of invocations of
	write_out_proc_statics that tells those invocations to write out
	the module representations between the prologue and the epilogue.

compiler/prog_rep.m:
	When generating bytecodes, include the new information for switches.

compiler/continuation_info.m:
	Replace a bool with a more expressive type.

compiler/proc_rep.m:
	Conform to the change to continuation_info.m.

compiler/opt_debug.m:
	Conform to the change to layout.m.

deep_profiler/mdprof_procrep.m:
	A new test program to test the reading of program representations.

deep_profiler/DEEP_FLAGS.in:
deep_profiler/Mmakefile:
	Copy the contents of the mdbcomp module to this directory on demand,
	instead of linking to it. This is necessary now that the deep profiler
	depends directly on mdbcomp even if it is compiled in a non-debugging
	grade.

	The arrangements for doing this were copied from the slice directory,
	which has long done the same.

	Avoid a duplicate include of Mmake.deep.params.

	Add the new test program to the list of programs in this directory.

Mmakefile:
	Go through deep_profiler/Mmakefile when deciding whether to do "mmake
	depend" in the deep_profiler directory. The old actions won't work
	correctly now that we need to copy some files from mdbcomp before we
	can run "mmake depend".

deep_profiler/profile.m:
	Remove the code that was moved (in cleaned-up form) to mdbcomp.

deep_profiler/dump.m:
deep_profiler/profile.m:
	Conform to the changes above.

browser/declarative_execution.m:
browser/declarative_tree.m:
	Conform to the changes in mdbcomp.

doc/user_guide.texi:
	Add commented out documentation of the two new options.

slice/Mmakefile:
	Fix formatting, and a bug.

library/exception.m:
library/par_builtin.m:
library/thread.m:
library/thread.semaphore.m:
	Update all the handwritten modules to pass the extra argument now
	required by write_out_proc_statics.

tests/debugger/declarative/dependency.exp:
	Conform to the change from proc_rep to proc_defn_rep.

tools/bootcheck:
	Write out deep profiling data only from every 25th invocation, since
	otherwise the time for a bootcheck takes six times as long in deep
	profiling grades than in asm_fast.gc.

	However, do test the ability to write out program representations.

	Use the mkinit from the workspace, not the installed one.

	Don't disable line wrapping.
2007-09-12 06:21:20 +00:00
Zoltan Somogyi
0d6c3c9fdf Satisfy a request by Peter Ross: give mdb users the ability to specify
Estimated hours taken: 8
Branches: main

Satisfy a request by Peter Ross: give mdb users the ability to specify
exactly which events inside a procedure they want to put breakpoints on.
Amongst other things, this can make checking postconditions easier:
you can now put a conditional breakpoint on only the exit event.

runtime/mercury_stack_layout.h:
	Add to the exec trace part of proc layouts fields describing an array
	of the label layouts describing the events of the procedure. This is
	the most direct way to implement the new functionality. (In theory,
	we could search the data structures that map file names and line
	numbers to label layouts, but that would be complex, inefficient,
	and *error prone*.)

	To make room for the new fields, and to prepare for making the
	procedure body available to the deep profiler as well (which could
	use it to map execution frequencies of calls back to their location
	in the procedure body, and thus to things like the frequencies with
	which various switch arms are selected), move the procedure body
	of the execution-trace-specific part of the proc layout, and to
	where the deep profiler could in the future also get at it.

runtime/mercury_goto.h:
	Add macros for declaring more than one label layout structure at a
	time.

compiler/layout.m:
	Implement the changes in mercury_stack_layout.h in the compiler's
	data structures as well.

compiler/stack_layout.m:
	Conform to the changes in mercury_stack_layout.h.

	Turn some tuples into named types.

compiler/layout_out.m:
	Conform to the changes in mercury_stack_layout.h.

	Add a mechanism to declare the label layouts in the new array before
	referring to them, by generalizing some existing code. Make this code
	require that the label layouts we refer to via the macros in
	mercury_goto.h match the declarations generated by those macros,
	i.e. that they have information about variables (if debugging is
	enabled, they will).

compiler/opt_debug.m:
	Conform to the change to layout.m.

compiler/prog_rep.m:
	Make a predicate name more expressive.

trace/mercury_trace_cmd_breakpoint.c:
	Implement the new way of using the "break" command, which is
	to add a port name after the procedure specification.

	Register procedures at the start of the function implementing
	the "break" command, instead of "on demand", since all alternatives
	eventually do demand it.

	Write ambiguity reports wholly to mdb's stdout, instead of partially to
	stderr and partially to stdout.

trace/mercury_trace_spy.c:
	Print the port and the goal path for breakpoints on specific events.

	Make the invocation conditions left-aligned, not right-aligned.

doc/user_guide.texi:
	Document the new way of using the "break" command.

NEWS:
	Announce the new capability.

tests/queens.{inp,exp,exp2}:
	Add tests of the new capability.

tests/breakpoints.{exp,exp}:
tests/lval_desc_array.{exp,exp2}:
	Expect the new alignment of invocation conditions.
2007-06-12 06:06:35 +00:00
Peter Ross
1087bee8e5 Fixes to make the compiler compile using MSVC in the LLDS grades.
Estimated hours taken: 2
Branches: main

Fixes to make the compiler compile using MSVC in the LLDS grades.

compiler/llds_out.m:
	MSVC treats declarations such as
		"static const struct s a[];"
	as definitions.  As a definition it doesn't know the size
	of the definition, so aborts.
	Thus if we are using the MSVC compiler we change "static"
	to "extern", via the use of #ifdef _MSC_VER.

runtime/mercury_stack_layout.h:
	The MSVC C pre-processor aborts on comments inside C
	pre-processor #defines, eg
		#define P(X) Q(/* extern */, X)
	It seems to treat strip the comment and then complain
	about the missing argument.
	The comment is no replaced with a pre-processor simple
	which evaluates to the empty string.
2007-05-28 06:32:41 +00:00
Zoltan Somogyi
8576975c4e Implement breakpoints on user events. Users may specify an event set,
Estimated hours taken: 20
Branches: main

Implement breakpoints on user events. Users may specify an event set,
an event name, both, or neither. Four forms of the mdb "break" command
create such breakpoints:

	break [the usual options] user_event <event_name>
	break [the usual options] user_event <event_set_name> <event_name>
	break [the usual options] user_event_set
	break [the usual options] user_event_set <event_set_name>

In addition, the command

	break [the usual options] user_event

is also accepted, as a synonym for

	break [the usual options] user_event_set

Since user events are not interface events or entry events, add a new, simple
ignore specification, which decrements the ignore count on every match of the
event.

Make the "break_print" mdb command consistent with the other command that
operates on existing breakpoints ("condition") by making it apply by default
to the most recently created breakpoint.

Make "condition" and "break_print" use the same option letter (-b) to introduce
the breakpoint number.

Fix a bug in the implementation of "break_print" that led to printing out
the selected variable, but not the selected *path* within the selected
variable. The reason was that we recorded what to print (variable spec plus
path) in a string, but that the process of using that record to print out
what was wanted destroyed the string (by putting a NULL between the variable
specification and the path), so that *later* uses of that string would find
an empty path. The fix is to record a var_spec/path pair in the print list.

Fix some slightly misleading output: when printing part of a variable, we
printed the name of the variable without any indication that the value printed
wasn't the whole value of the variable. We now print the path as well.

doc/user_guide.texi:
	Document the changes above.

	Document the usage "break_print [options] none", which we have always
	supported, but which was not documented.

runtime/mercury_stack_layout.h:
	Add a utility macro.

trace/mercury_trace.c:
	Fix a bug which left a variable uninitialized.

trace/mercury_trace_cmd_breakpoint.c:
	Implement the new command forms and options described above.

trace/mercury_trace_spy.[ch]:
	Implement data structures for keeping track of the new forms of
	breakpoints, and add the necessary functions for manipulating them.
	Update the function that checks whether the current event matches.
	Factor some common code out of that function, as well as out of the
	functions for adding new breakpoints.

	Change the print list data structure as described above.

	Add some utility functions.

	Add MR_ prefixes to the names of structure fields that previously
	lacked them.

trace/mercury_trace_cmd_misc.c:
	Handle the new breakpoint types.

trace/mercury_trace_tables.c:
trace/mercury_trace_internal.c:
	We used to parse the event set descriptions in module layout structures
	when the debugger was initialized (in mercury_trace_internal.c).
	However, we delay registering all the modules until this is needed,
	so at that time we don't yet *have* the list of module layout
	structures, so we used to parse nothing. This diff moves the code
	for doing the parsing to the time when the module layout structures
	are registered (in mercury_trace_tables.c).

	Don't test whether the module layout structure contains the fields
	for user event descriptions, since that diff has been installed on
	all our systems weeks ago.

trace/mercury_trace_internal.c:
	Conform to the new print list structure.

trace/mercury_trace_vars.[ch]:
	Print any selected path together with a variable name when printing a
	value. (This is the last bug fix mentioned at the top.)

	Export a function for use in mercury_trace_internal.c.

	Add some utility functions.

	Improve some error messages.

trace/mercury_trace_tables.h:
	Add a const qualifier.

tests/debugger/user_event.{inp,exp}:
	Extend this test case to test the new functionality.

tests/debugger/breakpoints.{inp,exp,exp2}:
	Conform to the change to the break_print command.

tests/queens.{inp,exp}:
	Change the input to test the bug fix to the break_print command,
	and the expected output.

tests/browser_test.exp:
tests/field_names.exp:
	Conform to the fact that we now print paths after variables names.
2007-01-19 04:42:52 +00:00
Mark Brown
ffa9c4d631 Fix a typo.
Estimated hours taken: 0
Branches: main

runtime/mercury_stack_layout.h:
	Fix a typo.
2007-01-10 16:08:20 +00:00
Zoltan Somogyi
8d57bbfb27 Fix the failure of the user event related test cases on saturn and other
Estimated hours taken: 0.5
Branches: main

Fix the failure of the user event related test cases on saturn and other
64 bit machines. The problem was that MR_LongLvals, which were 32 bits
in size, were being asked store pointers to closures, which on these
platforms are 64 bits. The fix is to make MR_LongLvals contain MR_Unsigneds,
whose size adjusts to the platform.

runtime/mercury_stack_layout.h:
	Make the change described above.

	Change the macros for looking up long and short lval descriptions
	to return the semantic types MR_LongLval and MR_ShortLval, not the
	physical types they are equivalent to. This will make similar problems
	easier to spot in future.

runtime/mercury_layout_util.c:
trace/mercury_trace.c:
	Conform to the change to mercury_stack_layout.h.

compiler/stack_layout.m:
	Give the size of the rvals represent MR_LongLvals as unsigned,
	not as uint_least32_t.
2007-01-08 09:15:22 +00:00
Zoltan Somogyi
cff0019b0b Make the system compile programs using minimal model tabling cleanly
Estimated hours taken: 10
Branches: main

Make the system compile programs using minimal model tabling cleanly
in .mmos grades. (They still do not work, since the .mmos grade's
implementation is not yet complete.)

compiler/prog_data.m:
	Split the eval method for own stack minimal model tabling in two:
	one for the consumer predicate, and one for the generator, since they
	have distinct properties.

	Add a utility predicate for use by llds_out and ml_code_gen.

compiler/prog_out.m:
	Split the predicate for converting an eval method to a string into two:
	one used for debugging purposes (which must be full of information),
	and one used for generating the names of pragmas (which must conform
	to the user-level syntax).

compiler/table_gen.m:
	Have the own stack transformation generate the proc_table_info now
	required to generate the variable containing the root of the call
	table, as well as the information describing the structure of the call
	and answer tables.

	Fix some software rot.

compiler/hlds_out.m:
	Print out the tabling information that may be attached to proc_infos.

compiler/llds_out.m:
compiler/ml_code_gen.m:
	Factor out some common code from these modules, and move it to
	prog_data.m.

compiler/add_pragma.m:
compiler/hlds_pred.m:
compiler/layout_out.m:
	Conform to the changes above.

runtime/mercury_mm_own_stacks.[ch]:
	Record the name of the predicate in generator and consumer structures,
	for debugging purposes (they can be taken out once the system works).

	Record the context in each consumer.

	Fix a link error by providing a dummy statistics printing predicate.

	Fix a cut-and-paste bug (wrong macro name guarding the handwritten
	C module).

runtime/mercury_tabling_preds.h:
	Implement some predicates needed by the own stack transformation.

	Fix some software rot.

runtime/mercury_debug.c:
	Avoid warnings from the C compiler.

runtime/mercury_context.c:
runtime/mercury_engine.h:
runtime/mercury_wrapper.c:
	Minor style fixes.

runtime/mercury_stack_layout.h:
trace/mercury_trace.c:
trace/mercury_trace_cmd_developer.c:
	Conform to the splitting of the own stack eval method into two.
2006-12-27 04:16:39 +00:00
Zoltan Somogyi
aa25c53cf6 For each attribute of each user event, record the order in which the attribute
Estimated hours taken: 6
Branches: main

For each attribute of each user event, record the order in which the attribute
it depends on, indirectly as well as directly, should be synthesized. This
information allows each attribute to materialized independently of other
attributes, a capability we don't yet need, but may need someday.

compiler/prog_event.m:
	Generate this information.

compiler/prog_data.m:
	Make room for the information generated by prog_event.

compiler/layout.m:
compiler/layout_out.m:
	Record this information in the layout structures we generate.

compiler/opt_debug.m:
	Conform to the change to layout.m.

runtime/mercury_stack_layout.h:
	Allow the -1 sentinel at the end of the attribute number vector.

trace/mercury_trace_vars.c:
	Make the var_details mdb command (which is for developers only)
	to print the newly collected information.
2006-12-22 05:37:57 +00:00
Zoltan Somogyi
544aae2355 Implement synthesized attributes at user events.
Estimated hours taken: 32
Branches: main

Implement synthesized attributes at user events.

doc/user_guide.texi:
	Document synthesized attributes.

runtime/mercury_stack_layout.h:
	Include information about synthesized attributes in layout structures.

	Move the the information about user events that is not specific to a
	given event occurrence to a central table of user event specifications
	in the module layout structure, to reduce the space overhead, and allow
	a future Ducasse style execution monitor to look up information about
	each event without having to search all label layout structures (e.g.
	when compiling a set of user commands about what to do at each event
	into a state machine).

	Update the current layout structure version number.

	Introduce a named type to represent HLDS variable numbers in layout
	structures.

runtime/mercury_types.h:
	Add typedefs for the new types in mercury_stack_layout.h.

compiler/prog_data.m:
compiler/prog_event.m:
	Record the call that synthesizes synthesized attributes in terms of
	attribute numbers (needed by the layout structures) as well as in terms
	of attribute names (the user-friendly notation). Record some other
	information now needed by the layout structures, e.g. the evaluation
	order of synthesized attributes. (Previously, we computed this order
	-in reverse- but then threw it away.)

	Do not separate out non-synthesized attributes, now that we can handle
	even synthesized ones. Return *all* attributes to call_gen.m.

	Pass the filename of the event set specification file to the event
	spec parser, for use in error messages.

	Generate better error messages for semantic errors in event set
	specifications.

compiler/continuation_info.m:
compiler/layout.m:
compiler/layout_out.m:
compiler/stack_layout.m:
	Generate the new layout structures, the main changes being the
	inclusion of synthesized attributes, and generating information about
	event attribute names, types and maybe synthesis calls for all possible
	events at once (for the module layout) instead of separately at each
	user event occurrence.

	In stack_layout.m, rename a couple of predicates to avoid ambiguities.

	In layout_out.m, eliminate some repetitions of terms.

compiler/call_gen.m:
	When processing event calls, match the supplied attributes against the
	list of all attributes, and include information about the synthesized
	attributes in the generated layout structures.

compiler/equiv_type.m:
compiler/module_qual.m:
	Conform to the change in prog_data.m.

compiler/opt_debug.m:
	Conform to the change in layout.m.

compiler/hlds_out.m:
	Generate valid Mercury for event calls.

trace/mercury_event_spec.[ch]:
	Record the name of the file being parsed, for use in syntax error
	messages when the parser is invoked by the compiler.

	Add a field for recording the line numbers of attributes, for use in
	better error messages.

trace/mercury_event_parser.y:
trace/mercury_event_scanner.l:
	Record the line numbers of attributes.

	Modify the grammar for event set specifications to allow C-style
	comments.

trace/mercury_trace_internal.c
	Pass a dummy filename to mercury_event_spec. (The event set
	specifications recorded in layout structures should be free of errors,
	since the compiler generates them and it checked the original version
	for errors.)

trace/mercury_trace_tables.[ch]:
	Conform to the new design of layout structures, and record the extra
	information now available.

trace/mercury_trace_vars.[ch]:
	Record the values of attributes in two passes: first the
	non-synthesized attributes, then the synthesized attributes
	in the evaluation order recorded in the user event specification.

tests/debugger/synth_attr.{m,inp,exp}:
tests/debugger/synth_attr_spec:
	New test case to test the debugger's handling of synthesized
	attributes.

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

tests/invalid/syntax_error_event.{m,err_exp}:
tests/invalid/syntax_error_event_spec:
	New test case to test the handling of syntax errors in event set
	specifications.

tests/invalid/synth_attr_error.{m,err_exp}:
tests/invalid/synth_attr_error_spec:
	New test case to test the handling of semantic errors in event set
	specifications.

tests/invalid/Mmakefile:
	Enable the new test cases.
2006-12-14 04:36:04 +00:00
Zoltan Somogyi
45fd0daf5a Implement some of Mark's wish list for making user events more useful.
Estimated hours taken: 20
Branches: main

Implement some of Mark's wish list for making user events more useful.

1. When executing "print *" in mdb, we used to print both the values of all
   attributes and the values of all live variables. Since some attributes'
   values were given directly by live variables, this lead to some things being
   printed twice. This diff eliminates this duplication.

2. At user events, we now print the name of the event. Whether we print the
   other stuff we also print at events (the predicate containing the event,
   and its source location) is now controlled by a new mdb command,
   "user_event_context".

3. We would like different solvers to be compilable independently of one
   another. This means that neither solver's event set should depend on the
   existence of the events needed by the other solvers. This diff therefore
   eliminates the requirement that all modules of the program be compiled with
   the same event set specification. Instead, a program may contain modules
   that were compiled with different event sets. Each event set is named;
   the new requirement is that different named event sets may coexist in the
   program (each being used to compile some modules), but two event sets with
   the same name must be identical in all other respects as well (we need this
   requirement to prevent inconsistencies arising between different versions of
   the same event set).

4. We now generate user events even from modules compiled with --trace shallow.
   The problem here is that user events can occur in procedures that do not
   get caller events and whose ancestors may not get caller events either.
   Yet these procedures must still pass on debugger information such as call
   sequence numbers and the call depth to the predicate with the user event.
   This diff therefore decouples the generation of code for this basic debugger
   infrastructure information from the generation of call events by inventing
   two new trace levels, settable by the compiler only (i.e. not from the
   command line). The trace level "basic_user" is for procedures containing a
   user event whose trace level (in a shallow traced module) would otherwise be
   "none". The trace level "basic" is for procedures not containing a user
   event but which nevertheless may need to transmit information (e.g. depth)
   to a user event. For the foreseeable future, this means that shallow traced
   modules containing user events will have some debugging overhead compiled
   into *all* their procedures.

runtime/mercury_stack_layout.h:
	Add a new field to MR_UserEvent structures, giving the HLDS number of
	the variable representing each attribute.

	Add a new field to module layout structures, giving the name of the
	event set (if any) the module was compiled with.

	Add the new trace levels to the MR_TraceLevel type.

	Update the current layout structure version number.

runtime/mercury_stack_trace.[ch]:
	Allow the printing of the containing predicate's name and/or the
	filename/linenumber context to be turned off when printing contexts.
	Factor out some of the code involved in this printing.

	Give a bunch of variables better names.

	Rename a type to get rid of unnecessary underscores.

compiler/prog_data.m:
compiler/prog_event.m:
	Include the event set name in the information we have about the event
	set.

compiler/simplify.m:
	Mark each procedure and each module that contains user events
	as containing user events.

	Use the same technique to mark each procedure that contains parallel
	conjunctions as containing parallel conjunctions, instead of marking
	the predicate containing the procedure. (Switch detection may eliminate
	arbitrary goals, including parallel conjunctions, from switch arms
	that are unreachable due to initial insts, and in any case we want to
	handle the procedures of a predicate independently from each other
	after mode analysis.)

	Also, change the code handling generic calls to switch on the generic
	call kind, and factor out some common code.

compiler/hlds_module.m:
compiler/hlds_pred.m:
	Provide slots in the proc_info and the module_info for the information
	gathered by simplify.

compiler/trace_params.m:
	Implement the new trace levels described above. This required changing
	the signature of some of the predicates of this module.

compiler/code_info.m:
	Record whether the compiler generated any trace events. We need to know
	this, because if it did, then we must generate a proc layout structure
	for it.

compiler/proc_gen.m:
	Act on the information recorded by code_info.m.

	Factor out the code for generating the call event and its layout
	structure, since the conditions for generating this event have changed.

compiler/continuation_info.m:
compiler/call_gen.m:
	For each user event, record the id of the variables corresponding to
	each argument of a user event.

compiler/layout.m:
compiler/layout_out.m:
compiler/stack_layout.m:
	Generate the new field (giving the HLDS variable number of each
	attribute) in user event structures, and the new field (event set name)
	in module layout structures.

	Allow the call event's layout structure to be missing. This is needed
	for user events in shallow traced modules.

compiler/options.m:
compiler/handle_options.m:
compiler/mercury_compiler.m:
	Rename the option for specifying event sets from --event-spec-file-name
	to --event-set-file-name, since it specifies only one event set, not
	all events.

compiler/jumpopt.m:
	Give some predicates better names.

compiler/dep_par_conj.m:
compiler/deforest.m:
compiler/granularity.m:
compiler/hlds_out.m:
compiler/inlining.m:
compiler/intermod.m:
compiler/lambda.m:
compiler/liveness.m:
compiler/modes.m:
compiler/opt_debug.m:
compiler/optimize.m:
compiler/size_proc.m:
compiler/stack_alloc.m:
compiler/store_alloc.m:
compiler/table_gen.m:
compiler/trace_gen.m:
compiler/typecheck.m:
	Conform to the changes above.

doc/mdb_categories:
	Mention the new mdb command.

doc/user_guide.texi:
	Update the documentation of user events to account for the changes
	above.

trace/mercury_event_parser.y:
trace/mercury_event_scanner.l:
	Modify the grammar for event set specifications to a name for the
	event set.

trace/mercury_event_spec.[ch]:
	Instead of recording information about event sets internally
	in this module, return a representation of each event set read in
	to the callers, for them to do with as they please.

	Include the event set name when we print the Mercury term for
	compiler/prog_event.m.

trace/mercury_trace.c:
	Do not assume that every procedure that contains an event contains a
	call event (and hence a call event layout structure), since that
	is not true anymore.

trace/mercury_trace_cmd_parameter.[ch]:
	Implement the new mdb command "user_event_context".

trace/mercury_trace_cmd_internal.[ch]:
	Include "user_event_context" in the list of mdb commands.

	Print the user event name at user events. Let the current setting
	of the user_event_context mdb command determine what else to print
	at such events.

	Instead of reading in one event set on initialization, read in
	all event sets that occur in the program.

trace/mercury_trace_tables.[ch]:
	Allow the gathering of information for more than one event set
	from the modules of the program.

trace/mercury_trace_vars.[ch]:
	For each attribute value of a user event, record what the HLDS variable
	number of the attribute is. When printing all variables at an event,
	mark the variable numbers of printed attributes as being printed
	already, causing the variable with the same number not to be printed.

	Include the name of the variable (if it has one) in the description
	of an attribute. Without this, users may wonder why the value of the
	variable wasn't printed.

trace/mercury_trace_cmd_browsing.[ch]:
	Pass the current setting of the user_event_context mdb command to
	runtime/mercury_stack_trace.c when printing the context of an event.

tests/debugger/user_event_shallow.{m,inp,exp}:
	New test case to test the new functionality. This test case is the same
	as the user_event test case, but it is compiled with shallow tracing,
	and its mdb input exercises the user_event_context mdb command.

tests/debugger/user_event_spec:
tests/invalid/invalid_event_spec:
	Update these event set spec files by adding an event set name.

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

tests/debugger/user_event.exp:
	Update the expected output of the old user event test case, which now
	prints event names, but doesn't print attribute values twice.

tests/debugger/completion.exp:
	Expect the new "user_event_context" mdb command in the command list.

tests/debugger/mdb_command_test.inp:
	Test the existence of the documentation for the new mdb command.

tests/invalid/Mercury.options:
	Conform to the name change of the --event-spec-file-name option.
2006-12-05 03:51:22 +00:00
Zoltan Somogyi
455e1eea75 The runtime had two different conventions for naming types.
Estimated hours taken: 2
Branches: main

The runtime had two different conventions for naming types. One convention,
used mostly in the debugger-related modules, added underscores between
capitalized words; example: MR_Label_Layout. The other convention, used
in most modules, used capitalized words without underscores (e.g. MR_TypeInfo).

This diff standardizes on the second convention. It has no algorithmic changes,
only renames of types.

runtime/*.[ch]:
trace/*.[ch]:
compiler/*.m:
library/*.m:
mdbcomp/*.m:
	Effect the change described above. The only substantive change is that
	runtime/mercury_stack_layout.h used to define *two* types for trace
	levels: MR_TraceLevel and MR_Trace_Level, and this diff standardizes
	on just one (they had equivalent definitions).

runtime/mercury_bootstrap.h:
	Add a #define from the old name to the new for all the changed type
	names that the installed compiler can put into .c files. We can delete
	these #defines some time after this diff has bootstrapped.

slice/.mgnuc_opts:
	Restore the --no-mercury-stdlib-dir option, without which the slice
	directory won't compile after this change (because it looks for type
	names in the installed runtime header files, which define the old
	versions of type names).
2006-11-29 05:18:42 +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
Zoltan Somogyi
e4e6904b53 Add a version number to the module layout structure.
Estimated hours taken: 0.1
Branches: main

Add a version number to the module layout structure. This is needed to
allow future changes to layout structures to take place in a backwards
compatible manner.

However, this change itself is backward compatible only for programs
without debugging enabled. If your installed compiler generates the new field
but your runtime doesn't define it, or vice versa, you will get strange crashes
whenever you use the debugger.

runtime/mercury_stack_layout.h:
	Add a version number field to the start of the module layout structure.

compiler/layout_out.m:
	Fill in the new field.

runtime/mercury_grade.h:
	Increment the binary compatibility version number for debug grades.
2006-11-14 00:22:34 +00:00
Zoltan Somogyi
9eed887d33 This diff is the second step in implementing trace events.
Estimated hours taken: 24
Branches: main

This diff is the second step in implementing trace events. It modifies
label layouts to include room for solver-event-specific information, and
modifies the compiler to generate this information. Modifications to the
debugger to use this information, user-level documentation and test cases
will come later.

runtime/mercury_stack_layout.h:
	Modify label layouts to allow them to hold information about solver
	events.

	Modify the macros creating label layouts to include a null pointer
	as the value of the label layout's solver event field. For each such
	macro, add a version that puts a pointer to the label's solver event
	structure in that field.

	Modify the definition of the MR_Long_Lval type to allow the
	representation of constants, since without this capability solver
	events would often need to be preceded by code to put constant
	values (e.g. solver ids) into lvals. To make it easier to locate
	all the places where MR_Long_Lvals are used (which need to be updated),
	change the type MR_Long_Lval from a synonym for an int to a structure
	containing an int.

runtime/mercury_types.h:
	Add the typedefs now required for mercury_stack_layout.h.

runtime/mercury_goto.h:
	Add a macro needed by mercury_stack_layout.h.

runtime/mercury_grade.h:
	Change the binary compatibility version number for debug grades,
	due to the change to label layouts.

runtime/mercury_layout_util.c:
	Update the functions interpreting MR_Long_Lvals to conform to the
	change in mercury_stack_layout.h.

runtime/mercury_deep_profiling_hand.h:
	Fix a bug, possibly the bug preventing us from bootchecking in deep
	profiling grades: stack slot numbers of ProcStatic structures are
	supposed to be plain integers, not MR_Long_Lvals.

runtime/mercury_stack_trace.c:
library/exception.m:
trace/mercury_trace.c:
	Conform the change in MR_Long_Lval.

runtime/mercury_trace_base.[ch]:
	Add a new port: the solver event port.

	Add a macro and a function for solver events: MR_SOLVER_EVENT and
	MR_solver_trace. For now, they do the same thing as MR_EVENT and
	MR_trace, but in future, they can do something else (e.g. generate
	information for a visualization tool).

mdbcomp/prim_data.m:
	Add a new port: the solver event port.

	Rename all ports to eliminate clashes with language keywords such as
	"call".

mdbcmp/trace_counts.m:
browser/declarative_execution.m:
slice/mcov.m:
compiler/tupling.m:
	Conform to the change in port names, and to the addition of the new
	port.

compiler/trace_params.m:
	Conform to the change in port names, and to the addition of the new
	port.

	Rename some function symbols to avoid some ambiguities.

trace/mercury_trace_declarative.c:
	Ignore the solver port when building the annotated trace, since it
	doesn't fit into it.

compiler/prog_event.m:
	Extend the representation of events to include names for the event
	attributes.

compiler/call_gen.m:
	Implement event goals. The implementation consists of a call to
	MR_SOLVER_EVENT with a layout structure whose solver event field
	points to a solver event structure giving the event goal's arguments.

	Rename some function symbols to avoid some ambiguities.

compiler/trace_gen.m:
	Add a predicate for generating solver events.

	Conform to the change in port names.

	Rename some function symbols to avoid some ambiguities.

compiler/code_info.m:
	When recording trace layout information for a label, take an extra
	argument describing the label layout's associated solver event, if any.

compiler/continuation_info.m:
	Extend the first representation of label layouts to include room
	for solver events.

compiler/stack_layout.m:
	Convert the representation of solver events in continuation_info.m's
	data structure to the data structure required by layout_out.m.

	Conform to the changes in MR_Long_Lvals.

compiler/layout.m:
	Extend the compiler's internal representation of the contents of label
	layout structures to accommodate the optional solver event field.

compiler/layout_out.m:
	Generate the extended label layout structures, using the new macros
	in mercury_stack_layout.h if necessary.

	Conform to the change in the MR_Long_Lval type.

	Conform to the change in port names.

	Rename some function symbols to avoid some ambiguities.

compiler/global_data.m:
	Modify rval_type_as_arg to require only the value of the relevant
	option, not a package of such options. This is for the new code
	in stack_layout.m.

compiler/var_locn.m:
	Conform to the change in global_data.m.

compiler/llds_out.m:
	Conform to the change in continuation_info.m.

	Delete this module's unused definition of rval_type_as_arg.

compiler/opt_debug.m:
	Conform to the change in continuation_info.m.
2006-09-29 06:34:57 +00:00
Zoltan Somogyi
74ce85d476 Provide a mechanism for collecting statistics about tabling operations,
Estimated hours taken: 60
Branches: main

Provide a mechanism for collecting statistics about tabling operations,
and provide a much more convenient mechanism for resetting tables.

Since it would too complex to do this while preserving the capability
of setting --tabling-via-extra-args to no, eliminate that capability
and the option. That option was useful only for measurements of the
performance boost from setting --tabling-via-extra-args to yes in any case,
so users lose no functionality.

Previously, the only way to debug the low level details of the tabling
mechanism was to build a runtime with a specific C macro (MR_TABLE_DEBUG)
and link with that runtime; this was cumbersome. Change that so that
every one of the debuggable tabling macros has a bool argument that says
whether debugging is enabled or not. The compiler can then set this to
MR_TRUE if the new option --table-debug is given, and to MR_FALSE otherwise.
If set to MR_FALSE, the C compiler should optimize away the debug code,
with zero impact on program size or speed.

Since these changes to macros require nontrivial bootstrapping, which we don't
want to do unnecessarily, modify the interface of the tabling macros as
required to support size limits on tables. This diff also implements the
parsing of size limit specifications on tables, but does not implement them
yet; that is for a future change.

To make the syntax simpler, this diff deletes the free-standing fast_loose_memo
pragma. The same functionality is now available with a fast_loose annotation
on an ordinary memo pragma.

Make a bunch of changes to improve readability and maintainability
in the process. These mostly take the form of renaming ambiguous and/or
not sufficiently expressive function symbols.

runtime/mercury_stack_layout.h:
runtime/mercury_tabling.h:
	Move the description of structure of tables from mercury_stack_layout.h
	to mercury_tabling.h, since we now need it for statistics even if
	execution tracing is not enabled.

	Modify those data structures to have room for the statistics.

	Don't distinguish "strict", "fast_loose" and "specified" memoing
	as separate eval methods; treat them as just different kinds
	of the same eval method: "memo".

	Remove underscores from the names of some types that the style guide
	says shouldn't be there.

runtime/mercury_tabling_preds.h:
runtime/mercury_tabling_macros.h:
	Modify the approach we use for macros that implement the predicates
	of library/table_builtin.m. Instead of selecting between debug and
	nondebug based on whether MR_TABLE_DEBUG is defined or not, add
	an explicit argument controlling this to each debuggable macro.
	The advantage of the new arrangement is that it scales. Another
	argument controls whether we are computing statistics (and if yes,
	where do we put it), and a third argument controls whether we maintain
	back links in the tries and hash tables (this last argument is present
	but is ignored for now).

	Since the values of the arguments will be known when the .c files
	containing calls to these macros are compiled, we pay the space and
	time cost of debugging, statistics gathering and the maintenance of
	back links if and only we need the revelant functionality.

	Provide macros for limited backward compatibility with the old set
	of macros; these allow workspaces created by old compilers to work
	with the new macros in the runtime. The old macros followed the
	naming scheme MR_table_*, the new ones are named MR_tbl_*.

runtime/mercury_table_int_fix_index_body.h:
runtime/mercury_table_int_start_index_body.h:
runtime/mercury_table_type_body.h:
	New files containing parts of the old mercury_tabling.c. Each of these
	files contains the body of the functions that used to be in
	mercury_tabling.c. The new mercury_tabling.c #includes each of these
	files more than once, to provide more than one variant of the old
	function. These variants differ in aspects such as whether debugging
	is enabled or statistics is being collected. Each variant therefore
	incurs only the time costs it needs to. (We pay the space cost of
	having all these variants all the time of course, but this cost
	is negligible.)

runtime/mercury_tabling_stats_defs.h:
runtime/mercury_tabling_stats_nodefs.h:
runtime/mercury_tabling_stats_undefs.h:
	New files that serve as wrappers around the newly #included files,
	controlling how they handle statistics.

runtime/mercury_tabling.c:
	Delete functions now in the new files, and #include them instead.
	Delete the data structures that used to contain summary statistics;
	the new approach keeps statistics in compiler-generated,
	procedure-specific data structures.

runtime/mercury_trace_base.c:
	Use the new versions of the tabling macros to access the I/O table.

runtime/mercury_type_info.h:
	Update some documentation for the movement of code out of
	mercury_tabling.c.

runtime/mercury_types.h:
	Provide forward declarations of the identifiers denoting the new types
	in mercury_tabling.h.

runtime/mercury_grade.h:
	Increment the exec trace version number, since we have changed
	a part of the exec trace structure.

runtime/mercury_bootstrap.h:
	Fix some temporary issues that arise from some renames above.

runtime/mercury_hash_lookup_or_add_body.h:
	Fix comment.

runtime/Mmakefile:
	Mention the new files and the dependencies that involve them.

library/table_builtin.m:
	Provide a type for representing statistics and a predicate for
	printing statistics.

	Use the updated versions of the macros in
	runtime/mercury_tabling_preds.h.

compiler/prog_item.m:
	Change representation of tabling pragmas to allow room for the new
	attributes.

	Allow an item to be marked as being generated by the compiler
	as a result of a pragma memo attribute. We use this for the reset
	and statistics predicates.

compiler/mercury_to_mercury.m:
	Write out the new attributes of the tabling pragma.

compiler/prog_data.m:
compiler/hlds_data.m:
	Change the cons_id that used to refer to a procedure's call table root
	to refer to the entirety of the new data structure now containing it.
	The compiler now needs a way to refer to the other components of this
	new data structure, since it contains the statistics.

	As in the runtime, don't distinguish "strict", "fast_loose" and
	"specified" memoing as separate eval methods; treat them as just
	different kinds of the same eval method: "memo".

	Rename some of the uses of the function symbols "c", "java", "il".

compiler/hlds_pred.m:
	Add an extra field in proc_infos for storing any tabling attributes.

	Change the existing proc_info field that records information about
	the kinds of arguments of tabled procedures to record the information
	needed by the debugger too. This was needed to allow us to shift all
	the RTTI for procedure-specific tables (as opposed to the RTTI for
	the global I/O table) from mercury_stack_layout.h to mercury_tabling.h
	without duplicating the data (which would be a maintenance problem).

	Reformat some comments to make them easier to read.

compiler/layout.m:
compiler/layout_out.m:
	Delete the part of the exec trace information that used to record
	RTTI for tables, since this information is not generated only as
	part of the debugger data structures anymore.

compiler/prog_io_pragma.m:
	Recognize the updated syntax for tabling pragmas.

compiler/add_pragma.m:
	When processing tabling pragmas for inclusion in the HLDS, create
	any reset and statistics predicates they ask for.

compiler/make_hlds_passes.m:
	Export a predicate now needed by add_pragma.m.

	Handle the new attributes on tabling pragmas

compiler/globals.m:
	Change the function symbols of the types describing backends and
	foreign languages to say what they are. Previously, both types (as well
	as several others) included the function symbol "c"; now, they are
	target_c and lang_c respectively.

compiler/table_gen.m:
	Implement the changes described at the top.

	When passing around varsets and vartypes, pass the arguments in the
	standard order.

compiler/goal_util.m:
compiler/hlds_goal.m:
	When passing around varsets and vartypes, pass the arguments in the
	standard order.

compiler/rtti.m:
	Provide types for representing the runtime's data structures for
	tabling (which are now significantly more complex than a single word)
	and predicates for manipulating them, for use by both the ml and ll
	backends.

compiler/llds.m:
	Replace the comp_gen_c_var type with the tabling_info_struct type,
	which contains the information needed to create the per-procedure
	tabling data structures.

	Replace references to call tables with references to the various
	components of the new tabling data structures.

compiler/llds_out.m:
	Add code to write out tabling_info_structs.

	Delete the code required for the old, hacky way of resetting tables.

	Reorder some code more logically.

compiler/proc_gen.m:
	Generate tabling_info_structs.

compiler/stack_layout.m:
	Don't generate the information now generated in proc_gen.m.

compiler/mlds.m:
	Give mlds_proc_labels their own function symbols, instead of using
	a pair. Rename some other function symbols to avoid ambiguity and add
	expressiveness.

	Provide for the representation of references to the various components
	of the new tabling data structures, and for the representation of their
	types.

compiler/ml_code_gen.m:
	When generating code for a tabled procedure, generate also the data
	structures required for its table.

compiler/rtti_to_mlds.m:
compiler/ml_util.m:
	Move some predicates from rtti_to_mlds.m to ml_util.m, since we
	now also want to call them from ml_code_gen.m.

compiler/name_mangle.m:
	Add some utility predicates.

compiler/options.m:
	Delete the old --allow-table-reset option.

	Add the new --table-debug option.

	Comment out an implementor-only option.

compiler/add_pred.m:
compiler/add_solver.m:
compiler/add_trail_ops.m:
compiler/add_type.m:
compiler/bytecode_gen.m:
compiler/code_gen.m:
compiler/compile_target_code.m:
compiler/complexity.m:
compiler/dependency_graph.m:
compiler/det_report.m:
compiler/export.m:
compiler/fact_table.m:
compiler/foreign.m:
compiler/global_data.m:
compiler/globals.m:
compiler/handle_options.m:
compiler/higher_order.m:
compiler/hlds_code_util.m:
compiler/hlds_data.m:
compiler/hlds_goal.m:
compiler/hlds_out.m:
compiler/inlining.m:
compiler/intermod.m:
compiler/make.dependencies.m:
compiler/make.module_target.m:
compiler/make.program_target.m:
compiler/make.util.m:
compiler/make_hlds_passes.m:
compiler/mercury_compile.m:
compiler/ml_call_gen.m:
compiler/ml_closure_gen.m:
compiler/ml_code_gen.m:
compiler/ml_code_util.m:
compiler/ml_elim_nested.m:
compiler/ml_optimize.m:
compiler/ml_switch_gen.m:
compiler/ml_tailcall.m:
compiler/ml_type_gen.m:
compiler/ml_unify_gen.m:
compiler/mlds_to_c.m:
compiler/mlds_to_gcc.m:
compiler/mlds_to_il.m:
compiler/mlds_to_ilasm.m:
compiler/mlds_to_java.m:
compiler/mlds_to_managed.m:
compiler/modes.m:
compiler/module_qual.m:
compiler/modules.m:
compiler/opt_debug.m:
compiler/opt_util.m:
compiler/polymorphism.m:
compiler/pragma_c_gen.m:
compiler/proc_label.m:
compiler/prog_data.m:
compiler/prog_foreign.m:
compiler/prog_item.m:
compiler/prog_mutable.m:
compiler/prog_out.m:
compiler/prog_rep.m:
compiler/prog_util.m:
compiler/recompilation.version.m:
compiler/size_prof.m:
compiler/special_pred.m:
compiler/switch_util.m:
compiler/transform_llds.m:
compiler/tupling.m:
compiler/type_ctor_info.m:
compiler/unify_gen.m:
	Conform to the changes above, and/or improve some comments.

mdbcomp/prim_data.m:
	Make the names of the function symbols of the proc_label type more
	expressive and less ambiguous.

mdbcomp/prim_data.m:
mdbcomp/mdbcomp.m:
mdbcomp/program_representation.m:
mdbcomp/rtti_access.m:
mdbcomp/slice_and_dice.m:
mdbcomp/trace_counts.m:
	Use . instead of __ as module qualifier.

	Conform to the change to prim_data.m.

browser/declarative_execution.m:
browser/declarative_oracle.m:
browser/declarative_tree.m:
	Conform the change to mdbcomp/prim_data.m.

tests/debugger/Mercury.options:
	Don't specify --allow-table-reset for fib.m, since that option
	doesn't exist anymore.

tests/debugger/fib.m:
	Use the new mechanism for resetting the table.

tests/debugger/print_table.m:
	Use the new syntax for pragma memo attributes.

tests/invalid/specified.{m,err_exp}:
	Use to the new syntax and reset method for pragma memo attributes.
	Test the handling of errors in the new attribute syntax.

tests/tabling/Mercury.options:
	Don't specify --allow-table-reset for specified.m, since that option
	doesn't exist anymore.

tests/tabling/specified.m:
	Use the new syntax for pragma memo attributes, and use the new
	mechanism for resetting tables. We could also use this test case
	for testing the printing of statistics, but the format of that
	output is still not final.

tests/tabling/fast_loose.m:
	Use the new syntax for pragma memo attributes, and use the new
	mechanism for resetting tables.

trace/mercury_trace.c:
trace/mercury_trace_cmd_developer.c:
	Conform to the changes in the RTTI data structures regarding tabling.

	Remove underscores from the names of some types that the style guide
	says shouldn't be there.

library/robdd.m:
	Comment out the tabling pragma until this change is bootstrapped.
	Without this, the conflict between the old calls to macros generated
	by the existing compiler and the new definition of those macros
	in the runtime would cause errors from the C compiler.
2006-06-08 08:20:17 +00:00
Zoltan Somogyi
5692b3d2c1 Remove the macros that we don't generate anymore.
Estimated hours taken: 0.1
Branches: main

runtime/mercury_misc.h:
runtime/mercury_stack_layout.h:
	Remove the macros that we don't generate anymore. This completes the
	bootstrap of the diff that reorganized the handling of static cells
	to use arrays instead of individual variables.
2006-03-27 05:05:46 +00:00
Zoltan Somogyi
276ed0f120 Change the way we represent static cells. Instead of generating a separate
Estimated hours taken: 6
Branches: main

Change the way we represent static cells. Instead of generating a separate
global variable for each static cell, generate global variables that are
arrays, each containing all the static cells of the same type. By reducing
the number of symbols requiring relocation, this reduces link times, especially
in debug grades (since those have lots of static cells).

compiler/global_data.m:
	Rewrite the part of this module that handles static cells in line
	with the above.

compiler/llds.m:
	Modify the data structures for representing static cells in line with
	the above.

compiler/llds_out.m:
	Delete all the code for grouping together all the static cells of the
	same type, since it is not needed anymore. Replace with simpler code
	to print out the new arrays of static cells.

	Rename some predicates to eliminate ambiguity.

compiler/opt_debug.m:
	Conform to the change in llds.m.

compiler/rtti_out.m:
	Conform to the change in llds_out.m.

runtime/mercury_misc.h:
runtime/mercury_stack_layout.h:
	Create variants of the existing shorthand macros to refer to static
	cells not using a specified global variable but using a specified
	offset in a specified array.

	Once this change has been bootstrapped on all our machines, the old
	variants can be deleted.
2006-03-21 02:33:41 +00:00
Ian MacLarty
521967f39f Implement a second version of the subterm dependency tracking algorithm
Estimated hours taken: 20
Branches: main

Implement a second version of the subterm dependency tracking algorithm
that uses the following heuristic to speed things up: If the subterm is being
tracked through an output argument, and there is an input argument with the
same name as the output argumnet, except for a numerical suffix, then the new
algorithm will check if the subterm appears in the same position in the input
argument.  If it does then it will continue tracking the subterm in the input
argument, thus bypassing the subtree rooted at the call.  Since dereferencing a
subterm in a large structure can be expensive, the new algorithm will only try
to bypass calls to procedures it has not tried to bypass before.  The set of
procedures it has tried is reset each time a new explicit subtree or supertree
is generated.

Add a `track' command that behaves in the same way as `mark', except that
it doesn't assert that the node is erroneous or inadmissible.
Add an optional `--accurate' argument which tells the declarative debugger to
use the original tracking algorithm.
We still allow the old algorithm to be used, because there
are situations where the new algorithm could find the wrong call (i.e.
when a subterm appears in the same position in an input argument,
but the subterm in the output argument is actually bound by a descendent call
-- it just happens to be bound to the same value as the input subterm).

doc/user_guide.texi:
	Change the documentation accordingly.

browser/browse.m:
browser/browser_info.m:
browser/parse.m:
browser/declarative_user.m:
	Add a `track' command that does the same thing as a `mark' command,
	except it doesn't assert the atom to be erroneous or inadmissible.
	Allow an `--accurate' or `-a' argument for the `mark' and `track'
	commands which indicates that the old subterm dependency tracking
	algorithm should be used.
	Pass information about tracked subterms to the declarative debugger.
	Do not allow a whole atom to be tracked or marked as this doesn't
	make sense.

browser/declarative_analyser.m:
browser/declarative_debugger.m:
browser/declarative_edt.m:
browser/declarative_oracle.m:
	Implement the new tracking algorithm.

browser/term_rep.m:
	Add a predicate to dereference a subterm in another term.

mdbcomp/rtti_access.m:
	Add a predicate to find a candidate input argument on which to
	apply the new heuristic.

runtime/Mmakefile:
runtime/mercury_layout_util.h:
runtime/mercury_stack_layout.h:
trace/mercury_trace_vars.c:
trace/mercury_trace_vars.h:
	Move the function for finding the name of a variable to the runtime,
	so that it can be called from the declarative debugger.

tests/debugger/declarative/Mmakefile:
tests/debugger/declarative/nodescend_tracking.exp:
tests/debugger/declarative/nodescend_tracking.inp:
tests/debugger/declarative/nodescend_tracking.m:
	Test the new heuristic.

tests/debugger/declarative/closure_dependency.inp2:
tests/debugger/declarative/closure_dependency.exp2:
	Expect an error message when marking a whole atom.
2005-11-02 14:02:16 +00:00
Zoltan Somogyi
d609181cb9 Consider types of the form
Estimated hours taken: 30
Branches: main

Consider types of the form

	:- type x ---> f.

to be dummy types, since they contain no information. Optimize them the same
way we currently optimize io.state and store.store.

runtime/mercury_type_info.h:
	Add a new type_ctor_rep for dummy types.

runtime/mercury_tabling.h:
	Add a representation for "tabled" dummy types, which don't actually
	have a level in the trie, so that the runtime system can handle that
	fact.

runtime/mercury_ml_expand_body.h:
	When deconstructing a value of a dummy type, ignore the actual value
	(since it will contain garbage) and instead return the only possible
	value of the type.

runtime/mercury_construct.c:
runtime/mercury_deconstruct.c:
runtime/mercury_deep_copy_body.c:
runtime/mercury_tabling.c:
runtime/mercury_unify_compare_body.h:
library/rtti_implementation.m:
	Handle the type_ctor_rep of dummy types.

runtime/mercury_builtin_types.c:
	Provide a place to record profiling information about unifications and
	comparisons for dummy types.

runtime/mercury_mcpp.h:
java/runtime/TypeCtorRep.java:
library/private_builtin.m:
	Add a new type_ctor_rep for dummy types, and fix some previous
	discrepancies in type_ctor_reps.

mdbcomp/prim_data.m:
	Move a bunch of predicates for manipulating special_pred_ids here from
	the browser and compiler directories.

	Rename the function symbols of the special_pred_id type to avoid the
	need to parenthesize the old `initialise' function symbol.

	Convert to four-space indentation.

mdbcomp/rtti_access.m:
	Don't hardcode the names of special preds: use the predicates in
	prim_data.m.

	Convert to four-space indentation.

browser/declarative_execution.m:
	Delete some predicates whose functionality is now in
	mdbcomp/prim_data.m.

compiler/hlds_data.m:
	Replace the part of du type that says whether a type an enum, which
	used to be a bool, with something that also says whether the type is a
	dummy type.

	Convert to four-space indentation.

compiler/make_tags.m:
	Compute the value for the new field of du type definitions.

compiler/hlds_out.m:
	Write out the new field of du type definitions.

compiler/rtti.m:
	Modify the data structures we use to create type_ctor_infos to allow
	for dummy types.

	Convert to four-space indentation.

compiler/type_ctor_info.m:
	Modify the code that generates type_ctor_infos to handle dummy types.

compiler/type_util.m:
	Provide predicates for recognizing dummy types.

	Convert to four-space indentation.

compiler/unify_proc.m:
	Generate the unify and compare predicates of dummy types using a new
	code scheme that avoids referencing arguments that contain garbage.

	When generating code for unifying or comparing other types, ignore
	any arguments of function symbols that are dummy types.

	Don't use DCG style access predicates.

compiler/higher_order.m:
	Specialize the unification and comparison of values of dummy types.

	Break up an excessively large predicate, and factor out common code
	from the conditions of a chain of if-then-elses.

compiler/llds.m:
	For each input and output of a foreign_proc, include a field saying
	whether the value is of a dummy type.

compiler/pragma_c_gen.m:
	Fill in the new fields in foreign_proc arguments.

compiler/hlds_goal.m:
	Rename some predicates for constructing unifications to avoid
	unnecessary ad-hoc overloading. Clarify their documentation.

	Rename a predicate to make clear the restriction on its use,
	and document the restriction.

	Add a predicate for creating simple tests.

	Add a utility predicate for setting the context of a goal directly.

compiler/modules.m:
	Include dummy types interface files, even if they are private to the
	module. This is necessary because with the MLDS backend, the generated
	code inside the module and outside the module must agree whether a
	function returning a value of the type returns a real value or a void
	value, and this requires them to agree on whether the type is dummy
	or not.

	The impact on interface files is minimal, since very few types are
	dummy types, and changing a type from a dummy type to a non-dummy type
	or vice versa is an ever rarer change.

compiler/hlds_pred.m:
	Provide a representation in the compiler of the trie step for dummy
	types.

compiler/layout_out.m:
	Print the trie step for dummy types.

compiler/table_gen.m:
	Don't table values of dummy types, and record the fact that we don't
	by including a dummy trie step in the list of trie steps.

compiler/add_pragma.m:
compiler/add_special_pred.m:
compiler/add_type.m:
compiler/aditi_builtin_ops.m:
compiler/bytecode.m:
compiler/bytecode_gen.m:
compiler/code_gen.m:
compiler/code_info.m:
compiler/continuation_info.m:
compiler/cse_detection.m:
compiler/det_report.m:
compiler/exception_analysis.m:
compiler/inst_match.m:
compiler/livemap.m:
compiler/llds_out.m:
compiler/llds_out.m:
compiler/middle_rec.m:
compiler/ml_call_gen.m:
compiler/ml_closure_gen.m:
compiler/ml_code_gen.m:
compiler/ml_code_util.m:
compiler/ml_type_gen.m:
compiler/ml_unify_gen.m:
compiler/mlds_to_c.m:
compiler/mlds_to_gcc.m:
compiler/mlds_to_il.m:
compiler/mlds_to_il.m:
compiler/modecheck_unify.m:
compiler/modes.m:
compiler/opt_util.m:
compiler/post_term_analysis.m:
compiler/post_typecheck.m:
compiler/qual_info.m:
compiler/rl.m:
compiler/rl_exprn.m:
compiler/rl_key.m:
compiler/rtti_out.m:
compiler/simplify.m:
compiler/size_prof.m:
compiler/term_constr_initial.m:
compiler/term_constr_util.m:
compiler/term_norm.m:
compiler/termination.m:
compiler/trace.m:
compiler/typecheck.m:
compiler/unify_gen.m:
	Conform to the changes above.

compiler/export.m:
compiler/exprn_aux.m:
compiler/foreign.m:
compiler/polymorphism.m:
compiler/proc_label.m:
compiler/rtti_to_mlds.m:
compiler/special_pred.m:
compiler/stack_alloc.m:
compiler/stack_layout.m:
compiler/state_var.m:
compiler/switch_util.m:
compiler/trace_params.m:
	Conform to the changes above.

	Convert to four-space indentation.

compiler/mlds_to_java.m:
compiler/var_locn.m:
	Conform to the changes above, which requires threading the module_info
	through the module.

	Convert to four-space indentation.

compiler/mercury_compile.m:
	Pass the module_info to mlds_to_java.m.

compiler/ml_util.m:
compiler/polymorphism.m:
compiler/type_ctor_info.m:
compiler/type_util.m:
	Delete some previously missed references to the temporary types used
	to bootstrap the change to the type_info type's arity.

compiler/polymorphism.m:
	Turn back on an optimization that avoids passing parameters (such as
	type_infos) to foreign_procs if they are not actually referred to.

compiler/prog_data.m:
	Convert to four-space indentation.

library/svvarset.m:
	Add a missing predicate.

trace/mercury_trace.c:
	Delete the unused function that used to check for dummy types.

tests/debugger/field_names.{m,inp,exp}:
	Add to this test case a test of the handling of dummy types. Check that
	their values can be printed out during normal execution, and that the
	debugger doesn't consider them live nondummy variables, just as it
	doesn't consider I/O states live nondummy variables.
2005-10-05 06:34:27 +00:00
Mark Brown
67791773af Fix some warnings and type errors that show up on the x86_64 architecture.
Estimated hours taken: 3
Branches: main

Fix some warnings and type errors that show up on the x86_64 architecture.

browser/io_action.m:
	Declare is_func in the C code for pickup_io_action to be MR_Bool
	rather than MR_bool, since it is a (word sized) Mercury bool, not
	a C boolean.

library/construct.m:
runtime/mercury_unify_compare_body.h:
	Provide values for variables even when MR_fatal_error is called,
	to avoid warnings about uninitialized variables.  Add default
	switch cases which call MR_fatal_error.

mdbcomp/rtti_access.m:
	Pass an int* to MR_find_context, and cast the result to an MR_Integer
	afterwards.

robdd/bryant.h:
	This code incorrectly assumes that unsigned long will have 32 bits.
	Flag the error with an XXX.

runtime/mercury_deconstruct.c:
trace/mercury_trace_internal.c:
	Cast arity values to int before printing.  We don't support
	arity > 1024 anyway.

runtime/mercury_proc_id.h:
runtime/mercury_types.h:
	Add an extra branch to the MR_Proc_Id union for the case when no
	proc id is present, and add a macro to test for this case.  We can't
	test the enum directly as we did before, because C compilers may
	report a warning that the test will never succeed (since -1 is not
	one of the values in the enum).

	Clarify the comment about the requirement of MR_PredFunc to match
	prim_data.pred_or_func.

	Define a macro for the value that indicates there is no proc id.

	Fix a couple of out-of-date comments.

trace/mercury_trace_browse.h:
	Clarify the comments about the requirement of MR_Browse_Caller_Type,
	MR_Browse_Format and MR_Query_Type to match their corresponding
	Mercury types.

runtime/mercury_tags.h:
	Add a comment to point out that enums don't necessarily have the
	same size as MR_words.

runtime/mercury_stack_layout.h:
	Use the new macro instead of testing directly whether the proc id
	exists.

runtime/mercury_stack_trace.c:
runtime/mercury_trace_base.c:
runtime/mercury_type_info.c:
trace/mercury_trace_internal.c:
	Use MR_INTEGER_LENGTH_MODIFIER, which is set by `configure', to
	get the right format specifier when printing integers with the same
	size as MR_Word.

runtime/mercury_type_info.c:
	Compare pseudo-typeinfos as MR_Integers rather than ints.

trace/mercury_trace.c:
trace/mercury_trace_tables.c:
	Provide a dummy value for variables to avoid uninitialized variable
	warnings.

trace/mercury_trace_completion.c:
	Cast a void* to MR_Integer before casting it to int.  It would be
	nicer to avoid the second cast altogether, but the readline interface
	requires it.

trace/mercury_trace_internal.c:
	Use MR_trace_is_unsigned when working with MR_Unsigned values.

	Cast pseudo-typeinfos which are variables to MR_Integer rather than
	int, to avoid compiler warnings about pointer casts.  We cast them
	to int before printing them, but that is because we know they won't
	be that big.

	Parse the argument to the goto command as type MR_Unsigned instead
	of int, to make it possible to goto an event with a number bigger
	than 2^31, on 64-bit machines at least.  (We already get 200M+
	events when the compiler is in a debug grade.)

trace/mercury_trace_util.c:
trace/mercury_trace_util.h:
	Provide MR_trace_is_unsigned, which is like MR_trace_is_natural_number
	except that it works with MR_Unsigned values.

trace/mercury_trace_vars.c:
	Cast void* to MR_Integer rather than int.
2005-09-01 07:37:26 +00:00
Ian MacLarty
fefcf468a0 Use dicing information in the declarative debugger.
Estimated hours taken: 30
Branches: main

Use dicing information in the declarative debugger.  Each label in the program
is assigned a suspicion based on a supplied dice.  A new search mode then
performs divide and query using the total suspicion of a subtree as the
weighting of the subtree.

browser/declarative_analyser.m:
	Parameterize the divide and query search mode by allowing it to work
	with an arbitrary weighting heuristic.

	Support two weighting heuristics: number of events and suspicion.

	Since there is still only one weight field for each suspect,
	if the weighting heuristic changes, then update all the weights of all
	the suspects.

	Return a different reason for asking a divide and query question,
	depending on the weighting heuristic.

 	Some information (specifically how many suspect events remain and
	the estimated number of questions remaining for divide and query)
	returned by the info command depends on the current weighting heuristic
	being the number of events.  If the current weighting heuristic is not
	the number of events then do not show this information.

browser/declarative_debugger.m:
	Pass the trace node store to set_fallback_search_mode so that the
	weights can be recalculated if the search strategy changes.

browser/declarative_edt.m:
	In the mercury_edt typeclass, rename the edt_weight method to
	edt_number_of_events and add a new method edt_subtree_suspicion.

	The weight field of each suspect in the search space can either
	be based on suspicion or number of events.
	Add a field to the search_space type to determine which weighting
	heuristic to use.  Export predicates to get and set the current
	weighting heuristic being used.  If the weighting heuristic
	changes the recalculate the weights of all the suspects.

	When calculating the weight of a suspect use the current weighting
	heuristic.

browser/declarative_execution.m:
	Record a suspicion accumulator at each interface event which
	can be used to calculate the suspicion of a subtree in the EDT.

	Move the label_layout and proc_layout types as well as all utility
	predicates for those types to a new module, mdbcomp.label_layout.

browser/declarative_oracle.m:
browser/declarative_user.m:
browser/debugger_interface.m:
	Import mdbcomp.label_layout.

browser/declarative_tree.m:
	Adjust for the extra field in interface nodes in the annotated trace.

	Look at the weighting heuristic when calculating the weight of a
	subtree.

browser/util.m:
mdbcomp/program_representation.m:
	Move goal_path_string to mdbcomp.program_representation since
	it is needed in mdbcomp.label_layout.

doc/user_guide.texi:
	Document the new search mode.

mdbcomp/label_layout.m:
	This module contains the types label_layout and proc_layout and
	supporting predicates which were in mdb.declarative_execution.
	These types are needed in the mdbcomp.slice_and_dice module.

mdbcomp/mdbcomp.m:
	Include label_layout.

mdbcomp/slice_and_dice.m:
	Add functions for calculating different suspicion formulas.  The
	intention is to experiment with different formulas in the future.

	Export predicates for reading a dice from the C backend.

	Export a predicate for retrieving the suspicion of a label
	given a dice.  This predicate uses the suspicion_ratio_binary
	formula, since that seems most effective in my (as yet very limited)
	experience.  I will implement better ways to control and customise
	the formula used in the future.

mdbcomp/trace_counts.m:
	Add a function for constructing a path_port given a goal path and
	a trace port.

	If there is an unexpected exception when reading a trace counts
	file then print the unexpected exception.

	Add a predicate to convert trace count file types to a string and
	vica versa.

runtime/mercury_stack_layout.h:
	Fix a typo.

runtime/mercury_trace_base.c:
runtime/mercury_trace_base.h:
	Export a function to look up the trace count slot for a label.
	Use this function when recording trace counts.
	This function will also be used in the declarative debugger backend to
	look up suspicions for labels.

	Add a function to initialise the array which records which ports
	need a goal path to uniquely identifiy the label.
	Initially I used this array elsewhere which is why I exported it.
	I didn't actually end up needing to use it in the final version,
	but I'm still exporting it, since it might be useful in the future.

tests/debugger/declarative/Mmakefile:
tests/debugger/declarative/dice.exp:
tests/debugger/declarative/dice.inp:
tests/debugger/declarative/dice.m:
	Test the new search mode.

tests/debugger/declarative/info.exp:
tests/debugger/declarative/change_search.exp:
	The weigting heuristic is now printed with the info command.
	Also some information, such as the number of suspect events,
	is no longer printed if the weigthing heuristic is not the number
	of events (since then that information is not available).

trace/mercury_trace_declarative.c:
	Add a function to setup the trace counts array with a suspicion for
	each label.  For efficiency the suspicion is converted from a
	float to an integer between 0 and 100.

	If a flag is set, then increment an accumulator with the
	suspicion of each label executed as the annotated trace is being
	constructed.  Store the value of the accumulator at interface events,
	so that the frontend can efficiently calculate the suspicion of any
	subtree.

	Remove a redundant variable and comment: the goal path is no
	longer passed to the frontend, because the frontend has access to
	the label_layout from which it can get the goal path (the variable and
	comment are artifacts of a previous change).

	When checking if a search mode is valid also check if failing and
	passing trace counts are required for the search mode.
	Allow abbreviations for the search mode arguments.

trace/mercury_trace_declarative.h:
	Export the predicate to set up the suspicions for each label.

trace/mercury_trace_internal.c:
	Allow passing and failing test case(s) to be passed
	as arguments to the dd command.

	If passing and failing test case(s) are supplied then record
	suspicions in the annotated trace even if the sdq search mode
	is not specified.  The user could switch to the sdq search mode later
	on.

	Initialise some values which were causing warnings from the C
	compiler.
browser/debugger_interface.m:
browser/declarative_analyser.m:
browser/declarative_debugger.m:
browser/declarative_edt.m:
browser/declarative_execution.m:
browser/declarative_oracle.m:
browser/declarative_tree.m:
browser/declarative_user.m:
browser/util.m:
doc/user_guide.texi:
mdbcomp/mdbcomp.m:
mdbcomp/program_representation.m:
mdbcomp/rtti_access.m:
mdbcomp/slice_and_dice.m:
mdbcomp/trace_counts.m:
runtime/mercury_stack_layout.h:
runtime/mercury_trace_base.c:
runtime/mercury_trace_base.h:
tests/debugger/declarative/Mmakefile:
tests/debugger/declarative/dice.exp:
tests/debugger/declarative/dice.inp:
tests/debugger/declarative/dice.m:
tests/debugger/declarative/info.exp:
trace/mercury_trace_declarative.c:
trace/mercury_trace_declarative.h:
trace/mercury_trace_internal.c:
2005-08-24 09:07:14 +00:00
Zoltan Somogyi
f7c8e5899d Add a new tabling method, one which specifies how each argument should
Estimated hours taken: 20
Branches: main

Add a new tabling method, one which specifies how each argument should
be treated, like this:

    :- pragma memo(p(in, in, in, out), [value, addr, promise_implied, output]).

doc/reference_manual.texi:
	Document the new tabling method.

compiler/prog_data.m:
	Add a new tabling method, one which specifies how each argument should
	be treated.

compiler/hlds_pred.m:
	Provide for the description of untabled input arguments of tabled
	procedures.

compiler/prog_io_pragma.m:
	Parse the new tabling method.

	Fix a bunch of formatting problems.

compiler/add_pragma.m:
	When adding a tabling pragma to the HLDS, check that if the pragma
	individually specifies the tabling methods of a procedure's arguments,
	then those tabling methods agree with the modes of those arguments.

	Fix an old bug: check whether a tabled predicate's arguments are
	fully input or fully output, and print an error message if not.
	We used to check this only in table_gen.m, but there we could only
	abort the compiler if the check failed.

	Factor out some common code and thereby fix an old bug: check for
	conflicting tabling pragmas not just when adding the pragma to all
	procedures of a predicate, but also when adding it to only a
	specified procedure.

compiler/table_gen.m:
	Implement the new tabling method.

compiler/prog_out.m:
compiler/layout_out.m:
	Conform to the changes above.

runtime/mercury_stack_layout.h:
	Provide for the description of untabled input arguments of tabled
	procedures.

trace/mercury_trace.c:
	Handle the new tabling method.

trace/mercury_trace_internal.c:
	Handle the new tabling method. Delete the defaults from some switches
	on enums to allow gcc to recognize missing cases.

	Handle the untabled input arguments of tabled procedures: skip over
	them when printing procedures' call tables.

	Enable better completion for mdb's "table" command.

trace/mercury_trace_tables.[ch]:
	Rename the breakpoint completer the proc_spec completer, since it does
	completions on procedure specifications.

tests/debugger/print_table.{m,inp,exp}:
	Modify this test case to test the ability to print the tables of
	predicates with some untabled arguments.

tests/tabling/specified.{m,exp}:
	New test case to check the functioning of the new tabling method
	by testing whether it is in fact faster to table the address of
	an argument instead of its value, or to not table it at all.
	Since the gains here are not quite as dramatic as tabled vs untabled,
	use a slightly looser criterion for comparing speeds than we use
	in the various versions of the fib test case.

tests/tabling/Mmakefile:
tests/tabling/Mercury.options:
	Enable the new test case, and set up the option it needs.

tests/invalid/specified.{m,err_exp}:
	New test case, a slight variant of tests/tabling/specified.m,
	to check the compiler's ability to detect errors in the new form
	of tabling pragma.

tests/invalid/Mmakefile:
	Enable the new test case.
2005-08-14 03:20:59 +00:00
Zoltan Somogyi
d1c13d57c5 Fix some layout issues in these files. There are no algorithmic
Estimated hours taken: 0.3
Branches: main

runtime/mercury_accurate_gc.h:
runtime/mercury_agc_debug.h:
runtime/mercury_array_macros.h:
runtime/mercury_construct.h:
runtime/mercury_deconstruct.h:
runtime/mercury_init.h:
runtime/mercury_layout_util.h:
runtime/mercury_stack_layout.h:
runtime/mercury_stack_trace.h:
runtime/mercury_trail.h:
	Fix some layout issues in these files. There are no algorithmic
	changes.
2005-06-21 03:12:03 +00:00
Zoltan Somogyi
6e2d095a98 Add a new form of tabling pragma, fast_loose_memo.
Estimated hours taken: 12
Branches: main

Add a new form of tabling pragma, fast_loose_memo. It differs from memo in
only one way: for arguments of user-defined types, instead of tabling every
single function symbol in the value, it tables a pointer to the term instead.
(Actually, it tables the contents of the selected argument register, so it
works even if the value is not a pointer.)

As the name implies, this form of tabling is faster than memo. The tradeoff
is that it is looser: if two invocations specify two terms that are at
different addresses but have the same value, this new form of tabling will
not recognize the commonality.

doc/reference_manual.texi:
	Document the new pragma.

compiler/prog_data.m:
	Generalize the type specifying eval methods to allow the expression
	of the new form of tabling.

compiler/prog_io_pragma.m:
	Parse the new form of tabling pragma.

compiler/hlds_pred.m:
	Handle the new, more general form of memoing.

	Add the required provisions for the representation of the new form
	of trie step in tables.

compiler/table_gen.m:
	Implement the new form of tabling as a minor variant of memo tabling.

	Convert this module to four-space indentation to reduce the number
	of bad line breaks.

compiler/layout_out.m:
compiler/prog_out.m:
	Conform to the changes above.

library/table_builtins.m:
	Add the primitives required to implement fast_loose_memo.

	Fix an old bug: make table_lookup_insert_poly call the right macro.

runtime/mercury_tabling.h:
runtime/mercury_tabling_macros.h:
runtime/mercury_tabling_preds.h:
	Provide the basic mechanism of fast_loose_memo tabling: a hash table
	that works on MR_Words.

runtime/mercury_stack_layout.h:
	Allow the representation of the new evaluation method and the new form
	of trie step.

tests/tabling/fast_loose.{m,exp}:
	Add this test case of the operation of fast_loose tabling. The test
	case pronounces success only if fast_loose_memo is measured to be
	significantly faster than plain memo.

tests/tabling/Mmakefile:
	Enable the new test case.
2005-06-07 03:00:10 +00:00
Zoltan Somogyi
617433270d Fix typo in comment.
Estimated hours taken: 0.1
Branches: main

runtime/mercury_stack_layout.h:
	Fix typo in comment.
2005-04-14 02:35:01 +00:00
Zoltan Somogyi
309910d736 Change the mechanism we use to transmit a representation of procedure bodies
Estimated hours taken: 16
Branches: main

Change the mechanism we use to transmit a representation of procedure bodies
from the compiler to the declarative debugger from Mercury terms to a bytecode.
This achieves two objectives.

First, the code for Mercury terms worked only as long as the compiler used
the same data representation as the program being compiled; it generated
incorrect term representations when e.g. the compiler generating code in
reserve tag grades.

Second, the new representation is significantly smaller. The total size of the
.c files in the compiler directory in grade asm_fast.gc.decldebug.tr is now
only 213 Mb compared with 313 Mb previously (a reduction of almost one third).
The executable file size of a compiler compiled in asm_fast.gc.decldebug.tr is
now only 59 Mb, compare with 64 Mb previously (a reduction of almost 8%, and
there is room for further reductions). The overhead of the decldebug grade
when compared with a plain debug grade now only about 25%, compared to
about 36% before.

The downside is that the procedure body representation must now be constructed
by the declarative debugger from the bytecode instead of being available
directly. We minimize this effect by using a cache to ensure that each
procedure's body representation is constructed at most once.

browser/declarative_execution.m:
	Do not include the procedure representation in call nodes. This should
	make the annotated trace somewhat smaller and quicker to construct.
	Since this code will be executed many more times than the number of
	procedures whose bodies are needed by subterm dependency tracking,
	the overall effect of this change on speed should be positive.

	Instead, add code to construct procedure body representations on demand
	from bytecode, which is reachable indirectly through the call's node
	label label structure.

browser/declarative_tree.m:
	Conform to the new structure of call nodes.

compiler/prog_rep.m:
	Replace the code that generated the term representation of procedure
	bodies with code that generates a bytecode representation of procedure
	bodies.

compiler/static_term.m:
	Delete this file, since it is no longer needed.

compiler/notes/compiler_design.html:
	Document the deletion of static_term.m.

mdbcomp/program_representation.m:
	Add the definitions related to the structure of the bytecode that are
	shared by the compiler and the declarative debugger. This includes
	the representations of determinisms.

compiler/code_model.m:
	To prevent requiring double maintenance, use the facilities now in
	mdbcomp/program_representation.m to encode determinisms.

runtime/mercury_stack_layout.h:
compiler/layout.m:
compiler/layout_out.m:
compiler/opt_debug.m:
compiler/stack_layout.m:
	Replace the proc layout field holding the procedure representation term
	with the field holding the procedure representation bytecode.

runtime/mercury_grade.h:
	Record the breaking of backward compatibility in debug grades.

compiler/options.m:
	Add an option for use by compiler implementors while implementing
	changes like this.

runtime/mercury_trace_base.[ch]:
	Add the hash table that caches the results of bytecode translations.

trace/mercury_trace_declarative.c:
	Do not include procedure representations when constructing call nodes,
	since it is no longer necessary.

trace/mercury_trace_internal.c:
	Update the code that deals with procedure bodies to use the bytecode
	representation.
2005-03-31 04:44:33 +00:00
Zoltan Somogyi
d03ce7dbc0 Fix some bugs in my previous diff that optimized away stack slots storing
Estimated hours taken: 8
Branches: main

Fix some bugs in my previous diff that optimized away stack slots storing
dummy values that manifested themselves as warnings from the C compiler
about integers too big to fit into 8 or 16 bits being implicitly truncated.
They did not lead to the failure of any test case, since it doesn't matter
whether the debugger gets the values it ignores (I/O states or stores)
from valid stack slots or not.

When generating RTTI for gc and the debugger, the compiler had three places
that generated references to stack slots: the return sites of calls, resume
points, and trace events. The previous diff updated only the first of these.
This diff updates the other two, and ensures there are no more.

Since the debugger needs to know whether a procedure has a pair of I/O state
arguments (e.g. when performing a retry), we add a field to proc layouts
to hold this information.

runtime/mercury_grade.h:
	Increment the debug grade runtime compatibility version number
	to reflect the change in layout structures.

runtime/mercury_stack_layout.h:
	Add an extra field to proc layouts to specify flags. At the moment,
	the only flag says whether the procedure has a pair of I/O state
	arguments.

	Add an extra field to proc layouts to specify the trace level of a
	procedure. This used to be the same as the module's trace level,
	but one of my bug fixes a couple of months ago broke that link.
	We don't yet use this field, but it makes sense to do it at the same
	time as the increment of the compatibility version number.

compiler/continuation_info.m:
	Attach to every description of a live value a description of where
	in the compiler that description was created.

	Rename the type involved to avoid an ambiguity.

	Ignore dummy types when generating resume layouts.

	Add some sanity checks.

	Add new fields to the continuation_info data structure to allow
	stack_layout.m to fill in the new fields in proc layout structures.

compiler/trace.m:
	Do not generate references to dummy values at trace events,
	except at call ports. At those ports, all live variables should
	be in registers.

compiler/stack_layout.m:
	Make the check for whether a value fits into an unsigned 8 bit value
	a direct rather than an indirect one. The indirect one assumed that
	stack slot numbers are all positive, which is now a bad assumption.

	Check for negative stack slot numbers in all RTTI stack slot
	descriptions.

	Fill in the two new slots in proc layout structures.

compiler/layout.m:
	Reserve space for the two new slots in proc layout structures.

compiler/layout_out.m:
	Output the two new slots in proc layout structures.

compiler/code_gen.m:
	Preserve the information needed by stack_layout.m for the two new
	fields.

compiler/llds_out.m:
	Add some code that ensures that we never output an integer constant
	that doesn't fit into the range of its type. Since this code is
	executed many millions of times, it is designed to be enabled only
	when the checking is manually enabled. It is normally off, but I got
	a clean bootcheck in the debug grade (which is the best stress test)
	with it enabled.

compiler/trace_params.m:
	Update a comment.

compiler/code_info.m:
	Export a function for use by trace.m.

compiler/hlds_pred.m:
	Export a predicate for use by stack_layout.m.

compiler/Mercury.options:
	Enable inlining for llds_out.m, to get rid of the sanity checking
	overhead if it is not enabled.

tests/debugger/completion.exp*:
tests/debugger/interpreter.exp*:
tests/debugger/multi_parameter.exp*:
tests/debugger/queens.exp*:
tests/debugger/print_goal.exp*:
tests/debugger/tabled_read.exp*:
tests/debugger/tabled_read_decl.exp*:
tests/debugger/declarative/io_stream_test.exp*:
tests/debugger/declarative/tabled_read_decl.exp*:
	Update these expected output files to not expect dummy values that
	aren't kept anymore.
2004-11-19 05:46:25 +00:00
Simon Taylor
42025cecfc Allow Aditi to call Mercury. At the moment, this involves Aditi
Estimated hours taken: 200
Branches: main

Allow Aditi to call Mercury.  At the moment, this involves Aditi
loading a shared library containing the user's code.

runtime/mercury_aditi.h:
	Define a structure MR_Aditi_Proc_Info used to describe
	a procedure called by Aditi.  Aditi will use dlsym() to
	look up these structures in the shared library supplied
	by the user.

compiler/rtti.m:
compiler/rtti_out.m:
compiler/rtti_to_mlds.m:
compiler/ml_code_util.m:
compiler/mlds_to_gcc.m:
compiler/opt_debug.m:
	Add an aditi_proc_info alternative to the rtti_data type,
	which corresponds to an MR_AditiProcInfo structure in
	the generated code.

	In the rtti_proc_label type, record the determinism rather
	than the code_model for use by Aditi.

compiler/options.m:
doc/user_guide.texi:
	Add an option `--aditi-calls-mercury'.
	This is needed for the Aditi tests, which currently don't
	handle loading the shared libraries for user defined code.

	Move `--aditi' into the compilation model options section.

compiler/rl.m:
	Sort the constructors for d.u. types when creating an Aditi
	type declaration to make it easier to find a particular
	constructor.

compiler/code_model.m:
compiler/stack_layout.m:
	Move represent_determinism into code_model.m, for use
	by rtti_to_mlds.m.

compiler/rl_exprn.m:
compiler/rl_file.pp:
compiler/rl_out.pp:
compiler/hlds_module.m:
compiler/mercury_compile.m:
	Create the procedures for each top-down Mercury goal which
	needs to be called from Aditi.
	Each created procedure has one input and one output argument,
	both of which will have a `{}/N' type.

	Allow nondet join conditions.

compiler/rl_exprn.m:
	Use record syntax.

compiler/rl_out.pp:
	Minor changes to the support for memoing.

runtime/Mmakefile:
runtime/mercury_imp.h:
runtime/mercury.h:
	Add mercury_aditi.h.

runtime/mercury_stack_layout.m:
	Add a comment about the duplication between MR_DETISM_*
	and code_model.represent_determinism.

tests/valid/Mmakefile:
tests/valid/Mercury.options:
tests/valid/aditi_calls_mercury.m:
	Test case.

	Also, enable the Aditi tests in hlc grades.
2004-10-20 09:45:11 +00:00