Commit Graph

66 Commits

Author SHA1 Message Date
Paul Bone
d43239d6a7 Move some of the goal path code from compiler/goal_path.m to the mdbcomp
library where it can be used by the deep profiler.

Also move the goal path code from program_representation.m to the new module,
goal_path.m in mdbcomp/

mdbcomp/goal_path.m:
    New module containing goal path code.

mdbcomp/program_representation.m:
    Original location of goal path code.

compiler/goal_path.m:
    Move some of this goal_path code into mdbcomp/goal_path.m

mdbcomp/feedback.automatic_parallelisation.m:
mdbcomp/rtti_access.m:
mdbcomp/slice_and_dice.m:
mdbcomp/trace_counts.m:
browser/debugger_interface.m:
browser/declarative_execution.m:
browser/declarative_tree.m:
compiler/build_mode_constraints.m:
compiler/call_gen.m:
compiler/code_info.m:
compiler/continuation_info.m:
compiler/coverage_profiling.m:
compiler/deep_profiling.m:
compiler/format_call.m:
compiler/goal_path.m:
compiler/goal_util.m:
compiler/hlds_data.m:
compiler/hlds_goal.m:
compiler/hlds_out_goal.m:
compiler/hlds_out_pred.m:
compiler/hlds_pred.m:
compiler/interval.m:
compiler/introduce_parallelism.m:
compiler/layout_out.m:
compiler/llds.m:
compiler/mode_constraint_robdd.m:
compiler/mode_constraints.m:
compiler/mode_ordering.m:
compiler/ordering_mode_constraints.m:
compiler/polymorphism.m:
compiler/post_typecheck.m:
compiler/prog_rep.m:
compiler/prop_mode_constraints.m:
compiler/push_goals_together.m:
compiler/rbmm.condition_renaming.m:
compiler/smm_common.m:
compiler/stack_layout.m:
compiler/stack_opt.m:
compiler/trace_gen.m:
compiler/tupling.m:
compiler/type_constraints.m:
compiler/typecheck.m:
compiler/unify_gen.m:
compiler/unneeded_code.m:
deep_profiler/Mmakefile:
deep_profiler/analysis_utils.m:
deep_profiler/coverage.m:
deep_profiler/create_report.m:
deep_profiler/display_report.m:
deep_profiler/dump.m:
deep_profiler/mdprof_fb.automatic_parallelism.m:
deep_profiler/message.m:
deep_profiler/old_query.m:
deep_profiler/profile.m:
deep_profiler/program_representation_utils.m:
deep_profiler/read_profile.m:
deep_profiler/recursion_patterns.m:
deep_profiler/report.m:
deep_profiler/var_use_analysis.m:
slice/Mmakefile:
slice/mcov.m:
    Conform to the move of the goal path code.
2011-01-13 00:36:56 +00:00
Peter Wang
91b78d6738 Make it possible to install and use the csharp.ssdebug grade.
Branches: main

Make it possible to install and use the csharp.ssdebug grade.

Mmake.workspace:
        Never try to link with `mer_rt' in C# grades.

browser/Mmakefile:
mdbcomp/Mmakefile:
ssdb/Mmakefile:
        Use `mmc --make' to install these libraries in `csharp' grades.

        Don't add C libraries to MLLIBS in non-C or asm grades.

browser/Mercury.options:
ssdb/Mercury.options:
        "EXTRA_LIBRARIES-libname" doesn't actually work with `mmc --make',
        but "LIBRARIES-name" does.

library/exception.m:
ssdb/ssdb.m:
        Handle EXCP events in C# grades.

        Trap SIGINT when running ssdb in C# grades.

        Add `exit_process' implementation.

browser/declarative_execution.m:
browser/listing.m:
        Add stubs for C#.

README.CSharp:
        Document the C# backend.

README.DotNet:
        Add a pointer to README.CSharp.

README.Erlang:
README.Java:
        Remove a non-sensical paragraph.

.INSTALL.in:
configure.in:
        Add `--enable-csharp-grade' option.

        Make `configure --enable-ssdebug-grades' add `csharp.ssdebug'
        to the list of library grades.
2010-10-26 04:59:10 +00:00
Ian MacLarty
23d6d4a392 Get the java.ssdebug grade installing and compiling hello world.
Estimated hours taken: 2
Branches: main

Get the java.ssdebug grade installing and compiling hello world.
Note that currently the jars for the java.ssdebug grade are installed in the
same location as the non-ssdebug jars.  That's not a problem for now,
because the standard library currently has the ssdebug transformations
turned off when it's compiled in the ssdebug grade, so the java.ssdebug
jars are the same as the java jars.  Changing it so that the java.ssdebug
jars are installed in a different location requires getting mmc to
adjust the classpath depending on the grade, which doesn't seem worth
it at this stage.

Also note that the interface files for the ssdb, browser and mdbcomp
libraries need to be installed in the ssdebug grade otherwise mmc
complains that it cannot find files like ssdb.m when compiling
a program.  These interface files are currently only installed
when there is an ssdebug grade.

browser/MDB_FLAGS.in:
mdbcomp/MDBCOMP_FLAGS.in:
ssdb/SSDB_FLAGS.in:
    Generate .module_dep files (needed to compile ssdebug transformed
    programs).

browser/Mmakefile:
    Build and install mer_browser.jar.
    Install the interface files when in an ssdebug grade.

browser/browse.m:
    Avoid a determinism warning.

browser/cterm.m:
browser/declarative_execution.m:
browser/listing.m:
    Get this code compiling in java grades.
    The "if (1 == 1)" before throwing an exception is to avoid
    "unreachable code" errors from the Java compiler.

library/Mmakefile:
    Mention that the ssdebug jars are installed in the
    same spot as the non-ssdebug jars.

mdbcomp/Mmakefile:
    Build and install mer_mdbcomp.jar.
    Install the interface files when in an ssdebug grade.

mdbcomp/rtti_access.m:
    Get this code compiling in Java grades.

scripts/Mercury.config.in:
    Add the ssdb, mdbcomp and browser jars to the classpath.
    If they are not installed they will just be ignored.

ssdb/Mmakefile:
    Build and install mer_ssdb.jar.
    Install the interface files when in an ssdebug grade.

ssdb/ssdb.m:
    Get this code compiling in java grades.
    Flush the output buffers after displaying the prompt so that
    it's always displayed.
2009-09-14 05:58:23 +00:00
Zoltan Somogyi
de0ff762d8 Convert some if-then-elses to switches.
Estimated hours taken: 2
Branches: main

analysis/analysis.file.m:
analysis/analysis.m:
browser/declarative_execution.m:
browser/declarative_tree.m:
browser/declarative_user.m:
browser/interactive_query.m:
browser/parse.m:
browser/sized_pretty.m:
	Convert some if-then-elses to switches.
2007-12-30 11:11:06 +00:00
Zoltan Somogyi
672f77c4ec Add a new compiler option. --inform-ite-instead-of-switch.
Estimated hours taken: 20
Branches: main

Add a new compiler option. --inform-ite-instead-of-switch. If this is enabled,
the compiler will generate informational messages about if-then-elses that
it thinks should be converted to switches for the sake of program reliability.

Act on the output generated by this option.

compiler/simplify.m:
	Implement the new option.

	Fix an old bug that could cause us to generate warnings about code
	that was OK in one duplicated copy but not in another (where a switch
	arm's code is duplicated due to the case being selected for more than
	one cons_id).

compiler/options.m:
	Add the new option.

	Add a way to test for the bug fix in simplify.

doc/user_guide.texi:
	Document the new option.

NEWS:
	Mention the new option.

library/*.m:
mdbcomp/*.m:
browser/*.m:
compiler/*.m:
deep_profiler/*.m:
	Convert if-then-elses to switches at most of the sites suggested by the
	new option. At the remaining sites, switching to switches would have
	nontrivial downsides. This typically happens with the switched-on type
	has many functors, and we treat one or two specially (e.g. cons/2 in
	the cons_id type).

	Perform misc cleanups in the vicinity of the if-then-else to switch
	conversions.

	In a few cases, improve the error messages generated.

compiler/accumulator.m:
compiler/hlds_goal.m:
	(Rename and) move insts for particular kinds of goal from
	accumulator.m to hlds_goal.m, to allow them to be used in other
	modules. Using these insts allowed us to eliminate some if-then-elses
	entirely.

compiler/exprn_aux.m:
	Instead of fixing some if-then-elses, delete the predicates containing
	them, since they aren't used, and (as pointed out by the new option)
	would need considerable other fixing if they were ever needed again.

compiler/lp_rational.m:
	Add prefixes to the names of the function symbols on some types,
	since without those prefixes, it was hard to figure out what type
	the switch corresponding to an old if-then-else was switching on.

tests/invalid/reserve_tag.err_exp:
	Expect a new, improved error message.
2007-11-23 07:36:01 +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
e33ca246a5 Move the code for reading procedure representations from the browser directory
Estimated hours taken: 0.2
Branches: main

Move the code for reading procedure representations from the browser directory
(in declarative_execution.m) to the mdbcomp directory (the file
program_representation.m) in order to make it accessible for the deep
profiler, since future changes by Paul Bone will require this.

browser/declarative_execution.m:
mdbcomp/program_representation.m:
	Make the move.

	Turn a semidet function into a predicate.

	Update some old constructs.

mdbcomp/program_representation.m:
mdbcomp/slice_and_dice.m:
	Change the prefix on the functions exported to C to MR_MDBCOMP
	from the previous mixture of MR_MDB and ML.

trace/*.c:
	Conform to the new prefixes on exported C functions.
2007-07-31 05:48:21 +00:00
Zoltan Somogyi
ebb805a2d3 Currently, all disjuncts from a disjunction generate an event with the same
Estimated hours taken: 3
Branches: main

Currently, all disjuncts from a disjunction generate an event with the same
port: MR_PORT_DISJ. However, the declarative debugger treats first disjuncts
differently from later ones, and the g12 visualizer will want this distinction
too. Therefore this diff splits MR_PORT_DISJ into two: MR_PORT_DISJ_FIRST
and MR_PORT_DISJ_LATER.

(The visualizer will also probably want to know when the disjunction is
complete, but it is not yet known whether this should be done as a separate
port type for the last disjunct or a new kind of event that happens when
execution backtracks out of the disjunction overall, so we hold off for now.)

runtime/mercury_trace_base.[ch]:
	Make the split described above.

	Move the user-visible names of ports from the source file to the
	header file to make them easier to maintain.

	Update the list of places that need to be updated when the list of
	ports is changed.

	Have two sets of names for trace ports: one that uniquely identifies
	each port, and one that conflates MR_PORT_DISJ_FIRsT and
	MR_PORT_DISJ_LATER. The first is for use by automatic tools,
	the second is for presentation to humans (so that mdb output,
	for example, remains the same.)

	Put some parts of the header file in a more logical order.

browser/declarative_execution.m:
mdbcomp/prim_data.m:
mdbcomp/trace_counts.m:
compiler/layout_out.m:
trace/mercury_trace_internal.m:
trace/mercury_trace_tables.m:
	Conform to the above changes.

compiler/trace_params.m:
	Conform to the above changes. Start numbering ports from 0, since C
	enums start from 0. This change has no repercussions since we don't
	yet have any code that depends on the details of the encoding.

compiler/trace_gen.m:
	Decide which kind of disj event to create.

trace/mercury_trace_declarative.c:
	Handle first and later disjuncts separately.
2007-05-02 02:16:02 +00:00
Zoltan Somogyi
9ce35377f6 Fix a problem with the representation of goal paths for switches on unbounded
Estimated hours taken: 2
Branches: main

Fix a problem with the representation of goal paths for switches on unbounded
numbers of function symbols, such as ints, floats and strings. We used to
represent such switches as a negative number in the field representing the
number of function symbols in the switched-on type, but some parts of the
system weren't handling negative numbers specially, and they couldn't be
properly parsed back in anyway (since "-" was also the character separating
the case's ordinal number from this number).

mdbcomp/program_representation.m:
	Change the switch goal path step to use a maybe type to record the
	number of function symbols in the switched-on type, with a "no" meaning
	the type is unbounded. Update the goal path step printing and parsing
	code accordingly.

	Make the names of some other function symbols more expressive.

browser/declarative_execution.m:
	Conform to the change to program_representation.m.

compiler/goal_path.m:
compiler/deep_profiling.m:
compiler/unneeded_code.m:
	Update the code that creates goal path steps.

	In deep_profiling.m, fix an old bug: the two integers (case number,
	number of function symbols in switched-on type) were swapped.

	In deep_profiling.m, give a prefix to the field names of the main
	structure passed around, to try to make them unique.

tests/debugger/switch_on_unbounded.{m,inp,exp}:
	New test case to test this fix.

tests/debugger/Mmakefile:
	Enable the new test case.
2007-04-19 04:24:53 +00:00
Zoltan Somogyi
b56885be93 Fix a bug that caused bootchecks with --optimize-constructor-last-call to fail.
Estimated hours taken: 12
Branches: main

Fix a bug that caused bootchecks with --optimize-constructor-last-call to fail.

The problem was not in lco.m, but in follow_code.m. In some cases,
(specifically, the LCMC version of insert_2 in sparse_bitset.m),
follow_code.m moved an impure goal (store_at_ref) into the arms of an
if-then-else without marking those arms, or the if-then-else, as impure.
The next pass, simplify, then deleted the entire if-then-else, since it
had no outputs. (The store_at_ref that originally appeared after the
if-then-else was the only consumer of its only output.)

The fix is to get follow_code.m to make branched control structures such as
if-then-elses, as well as their arms, semipure or impure if a goal being moved
into them is semipure or impure, or if they came from an semipure or impure
conjunction.

Improve the optimization of the LCMC version of sparse_bitset.insert_2, which
had a foreign_proc invocation of bits_per_int in it: replace such invocations
with a unification of the bits_per_int constant if not cross compiling.

Add a new option, --optimize-constructor-last-call-null. When set, LCMC will
assign NULLs to the fields not yet filled in, to avoid any junk happens to be
there from being followed by the garbage collector's mark phase.

This diff also makes several other changes that helped me to track down
the bug above.

compiler/follow_code.m:
	Make the fix described above.

	Delete all the provisions for --prev-code; it won't be implemented.

	Don't export a predicate that is not now used anywhere else.

compiler/simplify.m:
	Make the optimization described above.

compiler/lco.m:
	Make sure that the LCMC specialized procedure is a predicate, not a
	function: having a function with the mode LCMC_insert_2(in, in) = in
	looks wrong.

	To avoid name collisions when a function and a predicate with the same
	name and arity have LCMC applied to them, include the predicate vs
	function status of the original procedure included in the name of the
	new procedure.

	Update the sym_name of calls to LCMC variants, not just the pred_id,
	because without that, the HLDS dump looks misleading.

compiler/pred_table.m:
	Don't have optimizations like LCMC insert new predicates at the front
	of the list of predicates. Maintain the list of predicates in the
	module as a two part list, to allow efficient addition of new pred_ids
	at the (logical) end without using O(N^2) algorithms. Having predicates
	in chronological order makes it easier to look at HLDS dumps and
	.c files.

compiler/hlds_module.m:
	Make module_info_predids return a module_info that is physically
	updated though logically unchanged.

compiler/options.m:
	Add --optimize-constructor-last-call-null.

	Make the options --dump-hlds-pred-id, --debug-opt-pred-id and
	--debug-opt-pred-name into accumulating options, to allow the user
	to specify more than one predicate to be dumped (e.g. insert_2 and
	its LCMC variant).

	Delete --prev-code.

doc/user_guide.texi:
	Document the changes in options.m.

compiler/code_info.m:
	Record the value of --optimize-constructor-last-call-null in the
	code_info, to avoid lookup at every cell construction.

compiler/unify_gen.m:
compiler/var_locn.m:
	When deciding whether a cell can be static or not, make sure that
	we never make static a cell that has some fields initialized with
	dummy zeros, to be filled in for real later.

compiler/hlds_out.m:
	For goals that are semipure or impure, note this fact. This info was
	lost when I changed the representation of impurity from markers to a
	field.

mdbcomp/prim_data.m:
	Rename some ambiguous function symbols.

compiler/intermod.m:
compiler/trans_opt.m:
	Rename the main predicates (and some function symbols) of these modules
	to avoid ambiguity and to make them more expressive.

compiler/llds.m:
	Don't print line numbers for foreign_code fragments if the user has
	specified --no-line-numbers.

compiler/make.dependencies.m:
compiler/mercury_to_mercury.m:
compiler/recompilation.usage.m:
	Don't use io.write to write out information to files we may need to
	parse again, because this is vulnerable to changes to the names of
	function symbols (e.g. the one to mdbcomp/prim_data.m).

	The compiler still contains some uses of io.write, but they are
	for debugging. I added an item to the todo list of the one exception,
	ilasm.m.

compiler/recompilation.m:
	Rename a misleading function symbol name.

compiler/parse_tree.m:
	Don't import recompilation.m here. It is not needed (all the components
	of parse_tree that need recompilation.m already import it themselves),
	and deleting the import avoids recompiling almost everything when
	recompilation.m changes.

compiler/*.m:
	Conform to the changes above.

compiler/*.m:
browser/*.m:
slice/*.m:
	Conform to the change to mdbcomp.

library/sparse_bitset.m:
	Use some better variable names.
2007-01-19 07:05:06 +00:00
Julien Fischer
b4c3bb1387 Clean up in unused module imports in the Mercury system detected
Estimated hours taken: 3
Branches: main

Clean up in unused module imports in the Mercury system detected
by --warn-unused-imports.

analysis/*.m:
browser/*.m:
deep_profiler/*.m:
compiler/*.m:
library/*.m:
mdbcomp/*.m:
profiler/*.m:
slice/*.m:
	Remove unused module imports.

	Fix some minor departures from our coding standards.

analysis/Mercury.options:
browser/Mercury.options:
deep_profiler/Mercury.options:
compiler/Mercury.options:
library/Mercury.options:
mdbcomp/Mercury.options:
profiler/Mercury.options:
slice/Mercury.options:
	Set --no-warn-unused-imports for those modules that are used as
	packages or otherwise break --warn-unused-imports, e.g. because they
	contain predicates with both foreign and Mercury clauses and some of
	the imports only depend on the latter.
2006-12-01 15:04:40 +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
91501d2453 This diff is the first step in implementing trace events.
Estimated hours taken: 12
Branches: main

This diff is the first step in implementing trace events. It introduces the
representation of trace event goals into both the parse tree and HLDS
representations, and updates most compiler passes to handle them.
Changes to the code generator and to the runtime system, user-level
documentation and test cases will come later.

library/ops.m:
	Add "event" as an operator.

mdbcomp/program_representation.m:
	Extend the representation of goals to include events.

browser/declarative_execution.m:
	Allow the reconstruction from bytecode of event goals.

browser/declarative_tree.m:
	Extend the algorithm for following terms to their sources to allow
	it to traverse events (which never generate any values).

compiler/prog_item.m:
compiler/hlds_goal.m:
	Extend the parse tree and the HLDS representations to include event
	goals.

compiler/prog_io_goal.m:
	Convert the term representation of events to the parse tree
	representation.

compiler/add_clause.m:
	Convert the parse tree representation of events to the HLDS
	representation.

compiler/prog_event.m:
	Add this new module to contain the compiler's database of event types.

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

compiler/parse_tree.m:
	Include the new module.

compiler/prog_rep.m:
	Generate the extended bytecode for event goals.

compiler/mercury_to_mercury.m:
	Output event goals.

compiler/typecheck.m:
	Typecheck event goals. The types of the arguments of each event type
	is given by the database in prog_event.m.

compiler/typecheck_errors.m:
	Add a predicate for reporting unknown events.

compiler/modecheck_call.m:
	Add a predicate to modecheck event goals. The modes of the arguments
	are also given by the database in prog_event.m.

compiler/modes.m:
	Call the new predicate in modecheck_call.m for event goals.

	Some predicates in this module took a boolean flag, tested many times
	at runtime, to control whether an exact match was required or not.
	However, the choice was fixed at all call sites except one. I have
	split each predicate into two, one for each value of the boolean flag,
	both for clarity of code and for slightly improved speed.

compiler/ml_call_gen.m:
	Ignore event goals, since the MLDS backend doesn't support debugging.

compiler/call_gen.m:
	Document the fact that event goals *should* be handled here.

compiler/build_mode_constraints.m:
compiler/deep_profiling.m:
compiler/exception_analysis.m:
compiler/goal_util.m:
compiler/hlds_out.m:
compiler/hlds_pred.m:
compiler/intermod.m:
compiler/mercury_to_mercury.m:
compiler/mlds_to_c.m:
compiler/mode_constraints.m:
compiler/modecheck_unify.m:
compiler/module_qual.m:
compiler/prog_util.m:
compiler/purity.m:
compiler/simplify.m:
compiler/superhomogeneous.m:
compiler/tabling_analysis.m:
compiler/term_traversal.m:
compiler/trailing_analysis.m:
compiler/typecheck.m:
compiler/typecheck_errors.m:
compiler/unique_modes.m:
	Handle the new goal type. In most cases the new code should be
	functional, but in a few cases (e.g. constraint based mode analysis
	and deep profiling) it just aborts the compiler.
2006-09-05 06:21:37 +00:00
Julien Fischer
553fb3f7d9 Use pragma foreign_export' in preference to pragma export' throughout
Estimated hours taken: 1
Branches: main

Use `pragma foreign_export' in preference to `pragma export' throughout
the Mercury distribution.

Convert more of the extras distribution to four-space indentation and
other minor cleanups.

browser/*.m:
library/*.m:
samples/*:
extras/*:
	As above.
2006-08-31 11:09:54 +00:00
Zoltan Somogyi
00741b0162 This diff contains no algorithmic changes.
Estimated hours taken: 6
Branches: main

This diff contains no algorithmic changes. It merely renames apart a bunch more
function symbols to reduce ambiguity.

After this diff, the summary line from the mdb command "ambiguity -f" is

	Total: 351 names used 975 times, maximum 31, average: 2.78

browser/*.m:
compiler/*.m:
	Rename function symbols to eliminate ambiguities.

tests/debugger/declarative/dependency.exp:
tests/debugger/declarative/dependency2.exp:
	Update the expected out where some internal function symbol names
	appear in the output of the debugger. (This output is meant for
	implementors only.)
2006-08-22 05:04:29 +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
Julien Fischer
49faf8152a Fix a bunch of typos and some formatting.
Estimated hours taken: 0.5
Branches: main

browser/*.m:
	Fix a bunch of typos and some formatting.
2006-06-06 02:27:16 +00:00
Julien Fischer
459847a064 Move the univ, maybe, pair and unit types from std_util into their own
Estimated hours taken: 18
Branches: main

Move the univ, maybe, pair and unit types from std_util into their own
modules.  std_util still contains the general purpose higher-order programming
constructs.

library/std_util.m:
	Move univ, maybe, pair and unit (plus any other related types
	and procedures) into their own modules.

library/maybe.m:
	New module.  This contains the maybe and maybe_error types and
	the associated procedures.

library/pair.m:
	New module.  This contains the pair type and associated procedures.

library/unit.m:
	New module. This contains the types unit/0 and unit/1.

library/univ.m:
	New module. This contains the univ type and associated procedures.

library/library.m:
	Add the new modules.

library/private_builtin.m:
	Update the declaration of the type_ctor_info struct for univ.

runtime/mercury.h:
	Update the declaration for the type_ctor_info struct for univ.

runtime/mercury_mcpp.h:
runtime/mercury_hlc_types.h:
	Update the definition of MR_Univ.

runtime/mercury_init.h:
	Fix a comment: ML_type_name is now exported from type_desc.m.

compiler/mlds_to_il.m:
	Update the the name of the module that defines univs (which are
	handled specially by the il code generator.)

library/*.m:
compiler/*.m:
browser/*.m:
mdbcomp/*.m:
profiler/*.m:
deep_profiler/*.m:
	Conform to the above changes.  Import the new modules where they
	are needed; don't import std_util where it isn't needed.

	Fix formatting in lots of modules.  Delete duplicate module
	imports.

tests/*:
	Update the test suite to confrom to the above changes.
2006-03-29 08:09:58 +00:00
Zoltan Somogyi
7822554732 Replace __ with . as the module qualifier everywhere in all the modules
Estimated hours taken: 2
Branches: main

browser/*.m:
	Replace __ with . as the module qualifier everywhere in all the modules
	of the browser directory. Convert the currently tab-indented modules
	to four-space indentation. Delete some unnecessary module
	qualifications. Change some type names and function symbols to avoid
	ambiguities. Replace a bunch of uses of DCGs with state variable
	notation.
2006-03-10 06:31:06 +00:00
Zoltan Somogyi
869dadb221 Minor style cleanups.
Estimated hours taken: 0.2
Branches: main

browser/*.m:
	Minor style cleanups.
2005-11-04 07:27:24 +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
Ian MacLarty
fef2d804cc Allow subterms to be tracked through partial unifications in the
Estimated hours taken: 4
Branches: main

Allow subterms to be tracked through partial unifications in the
declarative debugger.
This involves adding new types of atomic goals to the program representation
stored with the executable of programs compiled with `--trace rep'.

Remove the ``unsafe'' from the cast goal representation to bring the program
representation up to date with Mark's recent change.

browser/declarative_execution.m:
	Read partial unification atomic goals from bytecode.

browser/declarative_tree.m:
	Handle partial unifications when tracking a subterm.

compiler/prog_rep.m:
	If a construction or deconstruction unification is a partial
	unification then generate a partial construction or deconstruction
	goal type.

	Make atomic_goal_info_to_byte_list return the list of variables bound
	by the atomic goal so we can check if a deconstruction is a
	partial unification (the LHS will be in the list of bound variables).

	Wrap the arguments of the RHS of the partial unification in a maybe
	type, so that we can tell which were input.

mdbcomp/program_representation.m:
	Add a new atomic goal `unify_partial_rep' to represent partial
	unifications.

tests/debugger/declarative/Mmakefile:
tests/debugger/declarative/partial.exp:
tests/debugger/declarative/partial.inp:
tests/debugger/declarative/partial.m:
	Test tracking of subterms through partial unifications.
2005-09-13 04:04:07 +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
Ian MacLarty
8ac929888b In the declarative debugger, dynamically calculate the depth implicit subtrees
Estimated hours taken: 15
Branches: main

In the declarative debugger, dynamically calculate the depth implicit subtrees
need to be built to, to achieve a desired weight.

This is done by recording the number of events at each depth in each
implicit subtree.  The array used to record these depths need only be
as big as the desired weight divided by two, since the thinnest a tree can be
is a stick with two events at each depth (a CALL and an EXIT/FAIL/EXCP).

Initially the tree is built down to a predetermined, conservative depth.  At
the root of each implicit subtree in the newly materialized tree, we record
the depth the implicit subtree needs to be built to, to achieve the desired
weight (this is refered to as the ideal depth in the code).  This is done
everytime we materialize a new implicit subtree.

This results in about a 3.6% slowdown when the declarative debugger reexecutes
a portion of the program.  However, this also reduces the number of
reexecutions of the program, since we needn't be conservative about how deep to
build subtrees to anymore.  We also avoid adding too many nodes to the
annotated trace if the tree has a large branching factor, so we are able to
control memory usage more easily.

I also added a progress indicator which is activated if a reexecution continues
for more than a second.

I added some macros to optionally print benchmarking information when
building a new portion of the annotated trace.

browser/declarative_debugger.m:
 	Pass the ideal depth of a subtree to the backend.

browser/declarative_edt.m:
	Handle the case where edt_dependency says an explicit subtree is
	required.

browser/declarative_execution.m:
	Record the ideal depth at the CALL event corresponding to the root
	of an implicit subtree.

	Add predicates to get and set this value from the backend.

browser/declarative_tree.m:
	Export a new predicate, trace_implicit_tree_info, which is used to
	get the info stored at the root of an implicit root.

	Make trace_dependency respond that an explicit subtree is required
	if it needs to explore the children of an implicit subtree.  Previously
	we made this situation impossible by requiring the backend to
	always generate the children of nodes at the depth limit.  This,
	however, complicated the backend code unnecessarily.

doc/user_guide.texi:
	Change the --depth-step-size dd option to just --depth which is now
	only used as the initial depth to build the subtree to.  Comment out
	the --depth option, since it requires knowledge of the internal
	workings of the declarative debugger.

	Document the new dd option, --nodes, which controls how many nodes
	to build in the annotated trace at a time.

library/gc.m:
	Export garbage_collect so it can be called from the backend when
	printing out benchmarking information.

tests/debugger/declarative/*.{inp*, exp*}
	For the tests set the --nodes and --depth options to a low value, so
	that we exercise the code that builds new portions of the annotated
	trace.

trace/mercury_trace_declarative.[ch]:
	Move the MR_DECL_UNTABLED_IO_RETRY_MESSAGE macro to
	mercury_trace_declarative.h.

	Add some macros and functions which print benchmarking information
	if the MR_DD_PRINT_EDT_STATS macro is defined.

	Add an overview of the backend.

	Show progress if the tree takes more than a second to generate.

	Count the events at each depth in each implicit subtree.
	Calculate the ideal depth when exiting an implicit subtree and store
	this in the annotated trace.

	Add the depth limit as an argument to MR_trace_restart_decl_debug
	instead of using the value of the global MR_edt_depth_step_size
	(which no longer exists).

	Do not materialize the children of nodes at the depth limit, since
	this is no longer necessary.

trace/mercury_trace_internal.c:
	Add and handle the --nodes dd option.  Rename the --depth-step-size
	option to --depth.
2005-05-20 05:40:37 +00:00
Ian MacLarty
78fc863efa Reduce the size of the bytecode representations of procedures (generated with
Estimated hours taken: 10
Branches: main

Reduce the size of the bytecode representations of procedures (generated with
the --trace rep option) by applying two optimizations.

The first optimization is to store strings in the existing global string table
and just keep the offsets in the bytecode representation.  This reduces the
size of the procedure representation bytecode for mercury_compile by 15.46% and
the total size of the executable by 2.34%.

The second optimization is to use a single byte to store variable numbers
where the biggest variable number in a procedure is less than or equal to 255.
An extra byte is stored at the beginning of the procedure to indicate whether
variable numbers are stored as bytes or shorts.  This optimization reduces the
size of the procedure representation bytecode for mercury_compile by 11.34% and
the total size of the executable by 1.75%.

browser/declarative_execution.m:
	Pass the label_layout for a call to any predicates than need to
	look up strings in the bytecode.  The global string table is accessable
	via the label_layout.

	Pass the representation used for variable numbers (byte or short) to
	any predicates that need to look up variable numbers in the bytecode.

compiler/c_util.m:
	Escape (') characters in the C representation of the string table.

compiler/prog_rep.m:
	Update the global string table when converting a string to bytecode.

	Determine the maximum variable number in a procedure and use a byte
	to represent the variable numbers if this is less than 256.

compiler/stack_layout.m:
	Export the predicate that adds a string to the global string table.
	Export an abstract version of the stack_layout_info type that the
	above predicate operates on.

	Pass the stack_layout_info to the predicate that constructs the
	bytecodes for a procedure, so it can update the global string
	table.

mdbcomp/program_representation.m:
	Add a predicate to convert the byte indicating whether bytes or shorts
	are used to represent variable numbers to a Mercury value.

trace/mercury_trace_internal.c:
	Pass the label layout when reading a procedure from the bytecode, so
	that strings can be looked up in the global string table.
2005-04-12 01:53:56 +00:00
Ian MacLarty
a789c0bbfc Include the reason why a question was asked in the information provided by the
Estimated hours taken: 14
Branches: main

Include the reason why a question was asked in the information provided by the
`info' command.  This includes the place where a marked subterm was bound if
the user marked a subterm in the previous question.

browser/declarative_analyser.m
	Add a new type to record the reason why a question was asked.  Keep
	this information with the last question asked in the analyser state, in
	case the user issues an `info' command.  Display the reason when the
	user issues an `info' command.

	Change the behaviour of subterm dependency tracking slightly: if the
	binding node was previously skipped then ask about it anyway.
	The user can then see in which node the subterm was bound, which may
	help them in answering the previously skipped question.

browser/declarative_edt.m
	Add two new methods to the mercury_edt typeclass.  One to get the
	proc_label of a node and the other to convert an arg_pos to a
	user argument number with respect to an atom in a node.  These
	are needed to display the question reason to the user in
	mdb.declarative_analyser.

	Add a new type to record the primitive operation that bound a subterm.

browser/declarative_execution.m
	Add a predicate to convert an arg_pos into a user arg number.

browser/declarative_oracle.m
	Fix a faulty comment.

browser/declarative_tree.m
	Implement the new methods added to the mercury_edt typeclass.

	Return the type of primitive operation that bound a subterm.

doc/user_guide.texi
	Document the fact that the reason is now also displayed when the
	`info' command is issued.

tests/debugger/declarative/dependency.exp
tests/debugger/declarative/dependency2.exp
	The type of primitive operation is now shown in the debugging output.

tests/debugger/declarative/info.exp
tests/debugger/declarative/info.inp
tests/debugger/declarative/info.m
	Test the info command more thoroughly.
2005-04-11 06:43:35 +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
Ian MacLarty
1a708a0ccc Add a new declarative debugger response, `info', which shows some information
Estimated hours taken: 6
Branches: main

Add a new declarative debugger response, `info', which shows some information
about the current question and the state of the bug search.

browser/declarative_analyser.m
	Add the show_info predicate.

browser/declarative_debugger.m
	Handle the oracle show_info response.

browser/declarative_edt.m
	Add a new method to the mercury_edt typeclass, edt_context,
	which returns the filename and line number of the predicate for
	a node.

browser/declarative_execution.m
	Instead of recording the goal path of a call in its parent, record
	the return label.  The goal path and the parent context can then
	be derived from the return label.

	Add a function to get the goal path from a return label.

	Add a function to get the context of a label.

	Modify the exported predicates used to build the annotated trace
	to take a return label instead of the goal path.

browser/declarative_oracle.m
	Add a `show_info' oracle response.

browser/declarative_tree.m
	Implement trace_context which returns the filename and line number
	of the predicate that corresponds with a node in the annotated trace.

	Derive a call's goal path in its caller from the return label where
	necessary.

browser/declarative_user.m
	Add and document the user response `info'.

browser/dice.m
	Fix a line that was over 79 characters.

doc/user_guide.texi
	Document the info command.

	Say that the --resume option can be used to resume an aborted or pd'd
	session.

tests/debugger/declarative/Mmakefile
tests/debugger/declarative/info.exp
tests/debugger/declarative/info.inp
tests/debugger/declarative/info.m
	Test the new response.

trace/mercury_trace_declarative.c
	Pass the return label when constructing the annotated trace.
2005-03-12 04:46:33 +00:00
Ian MacLarty
3ee6e024fe Record label layouts in the annotated trace.
Estimated hours taken: 7
Branches: main

Record label layouts in the annotated trace.  This does away with the need
to store goal path strings and proc_layouts in the annotated trace, since
both can be obtained from the label layout (we still however need to store the
goal path of a call in its parent for subterm dependency tracking).

The label layouts will be used for displaying more detailed information
in declarative debugging sessions (such as line numbers) and also for
for slicing and dicing in the declarative debugger.

browser/declarative_execution.m
	Add label_layout foreign types and some useful functions on this type.

	Add label_layout field to each event in an annotated trace.

	Record just the arguments of an atom for call and exit events in the
	annotated trace.  The complete atom can be constructed from the
	label_layout and the arguments.

	When recording argument values add them to the front of the
	argument list instead of inserting them in a specified position in the
	argument list.  This means the arguments must be added in reverse order
	in trace/mercury_trace_declarative.c.

	Adjust the predicates for building the annotated trace to also accept
	a label_layout.

browser/declarative_debugger.m
	Get the proc_layout from the label_layout.

browser/declarative_tree.m
	Make adjustments for the extra field.

trace/mercury_trace_declarative.c
	Pass the label_layout when constructing pieces of the annotated trace.

	Construct only the atom's arguments.  Also when adding the arguments
	add them in reverse order, because of the change in
	browser/declarative_execution mentioned above.
2005-02-22 05:17:29 +00:00
Julien Fischer
4aa7104e19 Replace deprecated mode and inst syntax.
Estimated hours taken: 0.1
Branches: main, release

browser/declarative_execution.m:
browser/declarative_tree.m:
compiler/mode_constraints.m:
compiler/prog_io.m:
compiler/rl_file.pp:
	Replace deprecated mode and inst syntax.
2005-02-07 11:41:05 +00:00
Ian MacLarty
4970242093 Use proc_label data structure defined in mdbcomp.prim_data instead of proc_id
Estimated hours taken: 4
Branches: main

Use proc_label data structure defined in mdbcomp.prim_data instead of proc_id
defined in mdb.declarative_execution and delete proc_id, since these data
structures are almost identical.

browser/declarative_execution.m
	Remove proc_id and flat_module_name types.  Use
	mdbcomp.prim_data.proc_label and mdbcomp.prim_data.module_name instead.

browser/declarative_debugger.m
browser/declarative_oracle.m
browser/declarative_tree.m
browser/declarative_user.m
	Use mdbcomp.prim_data.proc_label and mdbcomp.prim_data.module_name
	instead of mdb.declarative_execution.proc_id and
	mdb.declarative_execution.module_name.

mdbcomp/prim_data.m
compiler/prog_out.m
	Move sym_name_to_string from prog_out to prim_data.
	Fix comment for prog_out.sym_name_and_arity_to_string.

compiler/bytecode.m
compiler/check_typeclass.m
compiler/code_gen.m
compiler/deforest.m
compiler/higher_order.m
compiler/hlds_code_util.m
compiler/hlds_error_util.m
compiler/hlds_module.m
compiler/hlds_out.m
compiler/intermod.m
compiler/layout_out.m
compiler/make.module_target.m
compiler/make_hlds.m
compiler/mercury_compile.m
compiler/mercury_to_mercury.m
compiler/ml_elim_nested.m
compiler/mlds_to_c.m
compiler/mlds_to_gcc.m
compiler/mlds_to_il.m
compiler/mlds_to_java.m
compiler/mlds_to_managed.m
compiler/modes.m
compiler/modules.m
compiler/opt_debug.m
compiler/options_file.m
compiler/polymorphism.m
compiler/prog_io.m
compiler/prog_rep.m
compiler/rl.m
compiler/rl_exprn.m
compiler/rl_gen.m
compiler/rl_info.m
compiler/rl_out.pp
compiler/rtti.m
compiler/rtti_out.m
compiler/rtti_to_mlds.m
compiler/source_file_map.m
compiler/table_gen.m
compiler/trans_opt.m
compiler/unify_gen.m
compiler/unique_modes.m
compiler/unused_args.m
	Use mdbcomp.prim_data.sym_name_to_string instead of
	prog_out.sym_name_to_string.
2005-02-01 07:11:42 +00:00
Ian MacLarty
aa1e562a09 In the declarative debugger: use predmode syntax where appropriate; use `.'
Estimated hours taken: 1.2
Branches: main

In the declarative debugger: use predmode syntax where appropriate; use `.'
as a module qualifier instead of `__'; use state variables for IO instead of
DCGs; use `io' instead of `io.state'.

browser/declarative_debugger.m
browser/declarative_execution.m
browser/declarative_oracle.m
browser/declarative_test.m
browser/declarative_tree.m
browser/declarative_user.m
	Apply the above mentioned changes.
2005-01-28 00:56:06 +00:00
Zoltan Somogyi
67895b0b65 Fix the current mixture of __ and . to module qualify module names
Estimated hours taken: 0.2
Branches: main

browser/*.m:
	Fix the current mixture of __ and . to module qualify module names
	by standardizing on the latter.
2005-01-24 07:41:05 +00:00
Julien Fischer
f58b8a4041 The namespace cleanliness check in the browser directory
Estimated hours taken: 1
Branches: main

The namespace cleanliness check in the browser directory
has been failing in the high-level C grades.  This is
because the symbols exported from term_rep did not have
one of the expected prefixes.  Fix this by making term_rep
part of the mdb package.

browser/mdb.m:
browser/term_rep.m:
	Make the term_rep module part of the mdb package.

browser/declarative_debugger.m:
browser/declarative_execution.m:
browser/declarative_user.m:
	Conform to the above change.
2005-01-21 14:54:47 +00:00
Peter Wang
59d2d4a573 This adds a module mdbcomp__trace_counts that reads in the
Estimated hours taken: 17
Branches: main

This adds a module mdbcomp__trace_counts that reads in the
.mercury_trace_counts files produced by the compiler's trace mechanism.
The format of said files was slightly changed.

As the new module is to be used by the compiler and the debugger, it is
placed in the mdbcomp module.  This required bringing some types from the
compiler into a new module within mdbcomp.

browser/trace_counts.m:
	New module for reading execution trace summaries.

browser/prim_data.m:
	New module holding types and predicates moved in from the compiler.
	Types:
		pred_or_func, sym_name, module_name, proc_label,
		special_pred_id, trace_port
	Predicates:
		string_to_sym_name, insert_module_qualifier

	The mode field of proc_label is now an int instead of a proc_id
	to avoid pulling proc_id into mdbcomp.

browser/mdbcomp.m:
	Add trace_counts and prim_data to the mdbcomp module.

browser/declarative_execution.m:
	Renamed mdb's definition of module_name to flat_module_name
	to avoid conflicts with the definition in mdbcomp__prim_data.

runtime/mercury_trace_base.c:
	In the format of .mercury_trace_counts, write module and predicate
	names now use quoted atom syntax so that names with spaces and
	non-printable characters can be machine-parsed.

browser/:
compiler/:
	Many changes to account for movement of types, and the change to
	proc_label.
2005-01-19 03:11:22 +00:00
Ian MacLarty
4e2e2c88ef Change the way atoms in the annotated trace are compared by constructing
Estimated hours taken: 4
Branches: main

Change the way atoms in the annotated trace are compared by constructing
a representation of the atom and then doing deterministic comparisons
on the representation, instead of calling compare_representation on
the actual atoms, which is cc_multi.

This will make looking up atoms in the knowledge base deterministic instead
of cc_multi, which is considerably easier to program with.

browser/declarative_debugger.m
	Define an exception as a term representation instead of a univ.

browser/declarative_execution.m
	In the annotated trace store atom arguments and exceptions as
	term_reps instead of univs.

	Make predicates that construct an atom argument and an exception
	cc_multi.

browser/declarative_oracle.m
	Remove the dependency on tree234_cc and set_cc - use map and set
	instead.

	Also make predicates that look up info in the knowledge base semidet
	instead of cc_multi.

browser/declarative_user.m
	Convert term_reps back to univs before printing them.

browser/term_rep.m
	New module implementing the term_rep type.

trace/mercury_trace_declarative.c
	Use new versions of procs to construct exceptions and atom
	arguments.
2005-01-19 02:43:38 +00:00
Ian MacLarty
85dff41b45 Add divide and query search strategy to declarative debugger.
Estimated hours taken: 80
Branches: main

Add divide and query search strategy to declarative debugger.  This version of
divide and query uses the number of descendent events as a weighting instead of
the number of descendent nodes, mainly because this is easy to compute when
portions of the annotated trace are not materialized.

browser/declarative_analyser.m
	Implement divide and query search.

	Introduce a default search mode which can be either top-down or
	divide and query.

browser/declarative_debugger.m
	Export predicates so the default search mode can be set with the
	`dd' command.

browser/declarative_edt.m
	Implement helper predicates for divide and query search.

	Maintain a weight field for each suspect and adjust this when
	suspects are asserted correct, inadmissible or ignored.

	Implement a check to make sure all suspects in the portion of the
	search space that could contain a bug have the correct weights.

	Recalculate the weights when a node is revised.

	Remove some code that will never be executed in
	assert_suspect_is_erroneous/3.  The code handles a case when
	a correct or inadmissible suspect is marked erroneous.  This can
	only happen when a search is being revised in which case the
	correct or erroneous suspect would be marked unknown.

	When marking suspects as in the complement of an erroneous subtree
	stop marking if a correct or inadmissible node is encountered since
	descendents of these will already have been removed from the bug
	search.

	Renamed the variable Leaves to StopSuspects in
	propagate_status_downwards, since the value of this variable is the
	list of the children of the lowest updated suspects which may or may
	not be leaves.

browser/declarative_execution.m
	Record REDO event numbers since these are used to calculate the
	number of descendent events for backtracked over calls.

browser/declarative_tree.m
	Implement predicate to calculate the number of descendent events
	for a node in the EDT.

doc/user_guide.texi
	Document divide and query and top-down search strategies and
	document the new --default-search-mode dd option.

	Put @samp{} around CALL.

tests/debugger/declarative/Mmakefile
tests/debugger/declarative/divide_and_query1.exp
tests/debugger/declarative/divide_and_query1.inp
tests/debugger/declarative/divide_and_query1.m
	Test divide and query search strategy.

trace/mercury_trace_declarative.h
trace/mercury_trace_declarative.c
	Record REDO event numbers.

	Add some functions to set the default search mode by calling the
	predicate exported from declarative_debugger.m

	Add a function to check that a search mode argument string is valid.

trace/mercury_trace_internal.c
	Add --default-search-mode option for `dd' command.

	Use readline completion for `dd' command options.
2005-01-09 01:14:09 +00:00
Ian MacLarty
c511bd8b3e Allow the declarative debugger to search nodes above the node where the initial
Estimated hours taken: 20
Branches: main

Allow the declarative debugger to search nodes above the node where the initial
`dd' command was given.  If the user asserts that the node at which the `dd'
command was given is correct or inadmissible then the declarative debugger will
ask questions about ancestors of the node at which the `dd' command was given.
The declarative debugger will only say it cannot find a bug if the user asserts
that the main/2 (or whatever the topmost traced call is) call is correct or
inadmissible.

This is useful when you've found an inadmissible node in the procedural
debugger, but you're not sure where the erroneous ancestor is.

Fix bug in sub-term dependency tracking when tracking an input sub-term: If the
sub-term was bound by a primitive operation then the next question was about
the child of the node in which the sub-term was bound, instead of the node
itself.

Add --depth-step-size option to mdb `dd' command.  This allows the user to
specify the depth of each materialized portion of the EDT.

browser/declarative_analyser.m
	Allow analyser to request an explicit supertree from the diagnoser
	and respond correctly once an explicit subtree has been generated.

	When the primitive operation that binds a sub-term is found, the
	suspect_id of the node containing the primitive op is now returned, so
	handle this by asking the next question about the node containing the
	primitive op if its status is unknown.

	Stop tracking the sub-term if it is an input and we encounter an
	erroneous node.

	Remove previous_roots field from analyser_state.  It is not
	needed because this information is now kept in the search space.

browser/declarative_debugger.m
	Add new diagnoser response to tell backend to generate an explicit
	supertree.

browser/declarative_edt.m
	Add methods to mercury_edt typeclass to get the parent of an EDT node,
	tell if two nodes refer to the same event and tell if a node is the
	topmost node (usually the 1st call to main/2).

	Make find_subterm_origin return the suspect in which a primitive
	operation was executed.

	Add predicate to incorporate a new explicit supertree into the search
	space.

	Add predicate to tell the analyser when it's okay to stop tracking
	a sub-term.

	Fix bug in find_subterm_origin so it doesn't report a child as the
	binding node when it should be the parent.  Also replace duplicated
	code in find_subterm_origin with new predicate resolve_origin.

	Add extend_search_space_upwards predicate which attempts to add an
	extra node to the top of the search space.

	If a status is changed from erroneous to correct or vica versa then
	mark the suspects which were eliminated from the search space by
	the original status as unknown.

browser/declarative_execution.m
	Rename call_last_exit_redo to call_last_interface, since excp and fail
	nodes can also go here.

browser/declarative_tree.m
	Add implementations for new methods from mercury_edt typeclass.

doc/user_guide.texi
	Document --depth-step-size dd option.

	Remove duplicate save command documentation.

	Add a comment about new functionality.

tests/debugger/declarative/Mmakefile
tests/debugger/declarative/mapinit.exp
tests/debugger/declarative/mapinit.inp
	Use standardized event printing for mapinit test.

tests/debugger/declarative/app.exp
tests/debugger/declarative/app.inp
tests/debugger/declarative/revise_2.exp
tests/debugger/declarative/revise_2.inp
	Changed expected output and input because the bug search now continues
	in the ancestors of the node the original `dd' command was given in.

tests/debugger/declarative/catch.exp
	Now also get a "reached unknown label" warning after the (expected)
	error "no support for code that catches exceptions", since now a retry
	is done so we can return to the original event in the mdb session.

tests/debugger/declarative/explicit_subtree.exp
tests/debugger/declarative/explicit_subtree.exp2
tests/debugger/declarative/explicit_subtree.inp
tests/debugger/declarative/explicit_subtree.inp2
tests/debugger/declarative/explicit_subtree.m
	Modify this test to also test generation of an explicit supertree.

trace/mercury_trace_declarative.c
	If requested to generate a supertree then retry to a node
	above the current top most node and collect events down to the
	current top most node.

	Interactively retry across IO when building the annotated trace.
	This is more user friendly than simply aborting if untabled IO is
	encountered.

trace/mercury_trace_declarative.h
	Export MR_edt_depth_step_size so it can be set with the
	--depth-step-size dd option.

trace/mercury_trace_internal.c
	Add --depth-step-size option for `dd' command.
2004-12-16 00:12:41 +00:00
Ian MacLarty
732a892fe6 The main changes to the declarative debugger are:
Estimated hours taken: 200
Branches: main

The main changes to the declarative debugger are:

When you mark a subterm (using the term browser from within the DD), the
next question will be about the node that bound that subterm.  If that node is
correct then a binary search will be done between that node and the last
node you asserted was erroneous.

The declarative debugger is now a 3-valued debugger.  This means you can answer
inadmissible if a call's inputs violate some precondition of the call.  The
debugger will also infer a call is inadmissible if you mark one of its inputs
from the browser.

You don't have to give an argument number when invoking the term browser from
within the DD.  If an argument number is omitted then the whole call is
browsed as if it were a data term.

The subterm dependency tracking code now has the ability to track subterms of
closures, including subterms used when creating the closure by currying.
Subterm dependency tracking is also now more reliable when tracing information
is missing.

Lots of stuff in declarative_analyser.m has been redesigned to facilitate
future improvements, such as probabalistic debugging.

browser/declarative_analyser.m
	Transferred the definition of the mercury_edt type class to
	declarative_edt.m.  Added two new search algorithms: one to use
	suspicious subterm information to direct the bug search and one to do
	a binary search on a path in the EDT.

browser/declarative_debugger.m
	Added inadmissible as a truth value for the declarative debugger.
	Added ignore and skip responses.  Ignore responses are used when a
	call is to a trusted predicate.  Ignore tells the analyser that the
	node is not a bug itself, though it may have buggy children.  Skip
	means the oracle has skipped the question.

browser/declarative_edt.m
	Definition of the EDT type class and search_space type.  Search spaces
	are an extra layer on top of the EDT and provide useful services to
	the analyser such as keeping track of which nodes in the EDT might
	contain a bug.  In the future the search space will also be used to
	hold information like the probability that a node is buggy.
	Extended the mercury_edt type class with some useful methods.

browser/declarative_execution.m
	Added some utility predicates to extract information from a proc_id.

browser/declarative_oracle.m
	The oracle now only answers one question at a time.  This makes the
	implementation simpler.  I plan to get the oracle to tell the
	analyser everything it knows, without having to ask the user, whenever
	children are added to the search space, so that maximum information
	is always available to the search algorithms.
	Added a mechanism so the analyser can explicitly request that a
	question be re-asked of the user.
	Made some changes to handle inadmissible calls.

browser/declarative_tree.m
	Can now produce an i_bug as well as an e_bug.
	Made changes to handle dependency tracking of closure arguments.
	There are now two slightly different modes of subterm dependency
	tracking.  A fall-back mode where not all trace information is
	available and a "full" mode that assumes everything has been traced
	(which will be the case if compilation was with a debug grade).  The
	main difference is with higher order calls.  Because the id of the
	pred being called in a higher order call is not (easily) available,
	we can't safely match the HO call up with events on the contour if
	everything is not traced.  If everything is traced, then we can be sure
	the HO call's events will be where we expect them.
	Handled builtin calls which are treated as primitive ops.

browser/declarative_user.m
	User can now browse an entire call, instead of only one argument at
	a time.
	Allowed user to answer inadmissible.

browser/mdb.m
	Added mdb.declarative_edt.

browser/program_representation.m
	Added builtin_call_rep to represent builtin calls.
	Made plain calls to UCI predicates be treated as primitive ops.
	Added function to say if a goal generates internal events directly.
	Added a function to say whether an atomic goal is identifiable (i.e.
	whether we can get from its goal_rep its name, module and arity).

compiler/prog_rep.m
	Now creates builtin_call_rep atomic goal if the plain call was to
	a builtin.

compiler/trace_params.m
	Made minimum tracing for decldebug grade include program
	representations.  This is so the libraries compile with program
	representations, so we can do subterm dependency tracking through
	library calls.
	Trace level decl now includes the program representation.
	The default trace level for decldebug grade now includes the program
	representation.

doc/user_guide.texi
	Updated with new features.

tests/debugger/declarative/Mercury.options
	Removed superflous `--trace rep' options (since this is now implied by
	--trace decl).

tests/debugger/declarative/Mmakefile
	Added new tests.  Also made it possible to specify 3 different inputs:
	one for non-debugging grades, one for debug grades and one for
	decldebug grades.

tests/debugger/declarative/binary_search.exp
tests/debugger/declarative/binary_search.exp2
tests/debugger/declarative/binary_search.inp
tests/debugger/declarative/binary_search.inp2
tests/debugger/declarative/binary_search.m
tests/debugger/declarative/binary_search_1.m
	Test binary search.

tests/debugger/declarative/builtin_call_rep.exp
tests/debugger/declarative/builtin_call_rep.inp
tests/debugger/declarative/builtin_call_rep.m
	Test that builtin_call_rep appears in the program representation
	for builtin calls.

tests/debugger/declarative/catch.exp
tests/debugger/declarative/catch.exp2
tests/debugger/declarative/catch.inp
	Use standardized output.

tests/debugger/declarative/closure_dependency.exp
tests/debugger/declarative/closure_dependency.exp2
tests/debugger/declarative/closure_dependency.inp
tests/debugger/declarative/closure_dependency.inp2
tests/debugger/declarative/closure_dependency.m
	Test dependency tracking through higher order calls.

tests/debugger/declarative/confirm_abort.exp
tests/debugger/declarative/confirm_abort.inp
	If the dd command is typed then the root node is now always asked as
	the first question even if the oracle knows the answer (except where
	the predicate is trusted).  Updated the test to reflect this change.

tests/debugger/declarative/dependency.exp
tests/debugger/declarative/dependency2.exp
	Arguments are now counted from the back (a change to get dependency
	tracking to work with higher order calls), so the debug messages
	printed in this test needed to be changed.

tests/debugger/declarative/explicit_subtree.exp
tests/debugger/declarative/explicit_subtree.exp2
tests/debugger/declarative/explicit_subtree.inp
tests/debugger/declarative/explicit_subtree.inp2
tests/debugger/declarative/explicit_subtree.m
	Test for a bug fixed with this diff.  The bug occured when the subtree
	for an implicit node was generated and then the explicit subtree for
	another implicit node to the left of the generated subtree was
	requested.  When building the new subtree execution proceeded from
	where execution stopped when the previous subtree was generated, so
	execution never passed through nodes to the left of the
	previous subtree and the requested subtree wasn't built.

tests/debugger/declarative/family.exp
tests/debugger/declarative/family.inp
	Some changes to event numbers to do with changes in the way explicit
	subtrees are generated (see comment for
	tests/debugger/declarative/explicit_subtree above).  Also some changes
	to do with the fact that the analyser now only asks the oracle one
	question at a time.

tests/debugger/declarative/find_origin.exp
tests/debugger/declarative/find_origin.exp2
tests/debugger/declarative/find_origin.exp3
tests/debugger/declarative/find_origin.inp
tests/debugger/declarative/find_origin.inp2
tests/debugger/declarative/find_origin.inp3
tests/debugger/declarative/find_origin.m
	Test sub-term dependency tracking.

tests/debugger/declarative/ho5.exp3
	Changes to do with the fact that the standard library is now
	compiled with deep tracing in the decldebug grade.

tests/debugger/declarative/ignore.exp
tests/debugger/declarative/ignore.exp2
tests/debugger/declarative/ignore.inp
tests/debugger/declarative/ignore.inp2
tests/debugger/declarative/ignore.m
tests/debugger/declarative/ignore_1.m
	Test `ignore' oracle response.

tests/debugger/declarative/inadmissible.exp
tests/debugger/declarative/inadmissible.inp
tests/debugger/declarative/inadmissible.m
	Test inadmissibility.

tests/debugger/declarative/input_term_dep.exp
tests/debugger/declarative/input_term_dep.inp
	Some of the bugs found are now inadmissible call bugs, since inputs
	were marked as incorrect.  Also made changes to do with the fact that
	incorrect sub-terms are now followed to where they're bound.

tests/debugger/declarative/lpe_example.exp3
	Added new expected output when in decldebug grade.  Event numbers and
	call depths are different now because of deep tracing in the standard
	library.

tests/debugger/declarative/mismatch_on_call.exp
tests/debugger/declarative/mismatch_on_call.exp2
tests/debugger/declarative/mismatch_on_call.inp
tests/debugger/declarative/mismatch_on_call.m
	This test used to cause an "mismatch on call" exception to be thrown
	by the dependency tracking routine.

tests/debugger/declarative/skip.exp
tests/debugger/declarative/skip.inp
tests/debugger/declarative/skip.m
	Test `skip' oracle response.

tests/debugger/declarative/solutions.exp3
tests/debugger/declarative/solutions.inp3
	Added new input and expected output for decldebug grade.
	Some standard modules need to be trusted since they are now deep traced
	in this grade.

tests/debugger/declarative/special_term_dep.exp
	A bug is now reported as an inadmissible call.

tests/debugger/declarative/throw.exp3
	Because the standard library in decldebug grade is now deep traced
	by default event numbers are different, parent contexts are printed
	and "reached label with no stack layout info" warnings are not
	encountered.

trace/mercury_trace_declarative.c
	Made the depth step size used when deciding which events to put in
	the annotated trace a variable so that it can be dynamically adjusted
	in the future.
	The EDT depth is now calculated independently instead of using
	event_info->MR_call_depth (which is not always consistent with
	the EDT depth).
	When generating an annotated trace for an explicit subtree the
	first event's preceeding event now points to the correct event in the
	existing annotated trace (instead of NULL).  This allows the parent of
	the root of the new explicit subtree to be calculated.
	Made changes so that all the interface events of child calls of a call
	are included in the annotated trace, so that contours are built
	correctly.
2004-11-19 11:54:46 +00:00
Fergus Henderson
d0228c4489 Some work towards getting the "browser" directory to build in grade java.
Estimated hours taken: 24
Branches: main

Some work towards getting the "browser" directory to build in grade java.

In particular, this is a step towards fixing a problem in the Java
back-end with sub-modules.  When compiling code that uses sub-modules,
we run up against a Java restriction that a class which is in a package
is not allowed to have the same name as the package.  The work-around
is to use names starting with an uppercase letter for Java class names,
and names starting with a lower-case letter for Java package names.

XXX This diff is a partial step: it uses names starting with an
uppercase letter for Java class names that correspond to Mercury types.
It does not yet use an uppercase letter for Java classes that correspond
to Mercury modules.

XXX With this diff, we just flip the case of the initial letter,
which just works around the problem by avoiding the clashing cases,
rather than eliminating them.  We should use a more complicated mangling
that eliminates the problem completely, e.g. map lowercase Mercury names
to uppercase, map uppercase Mercury names to "U_" followed by the name.

compiler/mlds_to_java.m:
	Output type names with an initial uppercase letter.

compiler/mlds.m:
	Add a new enumeration type qual_kind, with values type_qual
	and module_qual.
	Add a qual_kind field to the fully_qualified_type type.
	Add a qual_kind argument to the append_class_qualifier function,
	and if the qual_kind is module_qual, adjust the case of the
	qualifier appropriately for the back-end.

compiler/ml*.m:
compiler/rtti_to_mlds.m:
	Fill in the new qual_kind field, and pass qual_kind to
	append_class_qualifier.

library/builtin.m:
library/private_builtin.m:
library/type_desc.m:
library/io.m:
library/rtti_implementation.m:
	Use type names with an initial uppercase letter.

browser/Mmakefile:
	Work around problems where Java compilers don't like the file names
	generated by mmc for code using sub-modules.

	For IL and Java, build with --allow-stubs --no-warn-stubs.

browser/declarative_execution.m:
	Give a Java definition for the "proc_layout" type.
	This is needed to avoid compilation errors in grade java.
2004-08-02 08:30:17 +00:00
Julien Fischer
1e62e29b2e Replace deprecated syntax for :- inst and :- mode
Estimated hours taken: 0.2
Branches: main

browser/declarative_execution.m:
browser/declarative_tree.m:
browser/tree234_cc.m:
	Replace deprecated syntax for :- inst and :- mode
	declarations.
2004-07-21 07:25:12 +00:00
Ian MacLarty
6b14f3921d The annotated trace used for declarative debugging now keeps a reference to the
Estimated hours taken: 5
Branches: main

The annotated trace used for declarative debugging now keeps a reference to the
proc layout for a predicate/function, instead of all the details of the
predicate/function.  This saves space and gives access to more information
about the predicate/function.

browser/declarative_debugger.m
	Changed write_origin to look up the proc name through the proc_layout.

browser/declarative_execution.m
	Info about the predicate like its name, module etc is now represented
	by a proc_layout type.  Changed the trace_atom type appropriately and
	added useful predicates and functions to manipulate proc_layouts -
	thanks to Zoltan.

browser/declarative_oracle.m
	Since proc_layouts are unique per mode, all modes must now be added to
	the knowledge base in assert_oracle_kb.

browser/declarative_tree.m
	Minor changes to predicate that expected four arguments to trace_atom
	type.

browser/declarative_user.m
	Minor changes to predicates that used the old trace_atom type.

tests/debugger/declarative/remember_modes.m
	Test to see that all modes of a predicate are added to the knowledge
	base of the oracle.

tests/debugger/declarative/Mmakefile
	Added remember_modes test.

tests/debugger/declarative/remember_modes.exp
	Expected results for remember_modes test.

tests/debugger/declarative/remember_modes.inp
	Input to remember_modes test.

tests/debugger/declarative/trust.m
	Removed superfluous import of trust_1 in interface.

trace/mercury_trace_declarative.c
	Removed MR_decl_atom_name_and_module which is no longer necessary
	since the debugger looks the name and module up in the proc_layout
	directly.
2004-07-07 05:26:17 +00:00
Ian MacLarty
8ea1dbc3b5 Added a `trust' command to mdb which tells the declarative debugger to assume
Estimated hours taken: 35
Branches: main

Added a `trust' command to mdb which tells the declarative debugger to assume
all procedures in a given module are correct.

browser/declarative_debugger.m
	Added function which finds out the atom a given	question relates to.
	Exported a add_trusted_module predicate so modules can be added from
	c code (used by trace/mercury_trace_declarative.c).

browser/declarative_execution.m
	Add module_name field to the atom constructor for the trace_atom type.
	Made necessary changes to predicates that expected 3 fields for the
	atom constructor for the trace_atom type.

browser/declarative_oracle.m
	Added a set of trusted module names to the oracle_state type.

browser/declarative_tree.m
	Updated various predicates that expected the atom constructor to have
	3 fields where now it has 4.

browser/declarative_user.m
	Updated various predicates that expected the atom constructor to have
	3 fields where now it has 4.

trace/mercury_trace_declarative.h
	Added MR_decl_add_trusted_module function to add a module to the set of
	trusted modules for the currect diagnoser.

trace/mercury_trace_declarative.c
	Implemented the MR_decl_add_trusted_module function.  This calls
	MR_trace_decl_ensure_init to make sure the diagnoser is initialised
	first.

	Changed the MR_decl_make_atom function to include the module name
	when constructing an atom.

	Added MR_decl_atom_name_and_module function which extracts the proc
	name and module from a MR_Proc_Layout.  This replaces the
	MR_decl_atom_name function which just extracted the name.  This
	function will also extract the name and module of user defined equality
	and comparison predicates.

trace/mercury_trace_internal.c
	Added MR_trace_cmd_trust function to add a trusted module to the
	current diagnoser when the user issues a `trust' command.

doc/mdb_categories
	Added `trust' command to misc category (will need to make a declarative
	category when there are more commands).

doc/user_guide.texi
	Added some help text for the `trust' command.

tests/debugger/mdb_command_test.inp
	Added `trust' command to list of tests.

tests/debugger/declarative/Mmakefile
	Added calls to the trust.m program to test the `trust' command.

tests/debugger/declarative/trust.m
	Test program for the `trust' command.  This imports 2 modules in the
	and calls a user-defined comparison predicate from the one module and
	a normal predicate from the other.

tests/debugger/declarative/trust_1.m
	Imported by trust.m.  Defines a new type and a user-defined comparison
	predicate on the type.

tests/debugger/declarative/trust_2.m
	Also imported by trust.m.  Defines a predicate using the type defined
	in trust_1.m.

tests/debugger/declarative/trust.inp
	Input to mdb to test the `trust' command.  Contains commands to tell
	mdb to trust the trust_1 and trust_2 modules.

tests/debugger/declarative/trust.exp
	Expected output of mdb when running trust with trust.inp as input.
2004-06-15 05:35:13 +00:00
Zoltan Somogyi
ecdc285bc7 Split the existing browser library into two libraries, by making the
Estimated hours taken: 10
Branches: main

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

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

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

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

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

Mmakefile:
	Use make variables to refer to library names.

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

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

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

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

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

browser/Mercury.options:
	Mention the new module.

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

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

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

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

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

scripts/c2init.in:
scripts/ml.in:
tools/binary:
tools/binary_step:
tools/bootcheck:
tools/linear:
tools/lml:
	Update the list of libraries programs are linked with.
2003-10-27 06:00:50 +00:00
Peter Ross
6f1f7f0083 Add Mercury versions of code which has been defined only as
Estimated hours taken: 1
Branches: main

browser/collect_lib.m:
browser/declarative_debugger.m:
browser/declarative_execution.m:
browser/dl.m:
browser/interactive_query.m:
browser/io_action.m:
browser/mdb.m:
browser/name_mangle.m:
browser/util.m:
	Add Mercury versions of code which has been defined only as
	foreign procs so as to allow this directory to compile for
	the non-C backends.
	The Mercury versions just call private_builtin__sorry.
2003-02-06 13:37:08 +00:00
Mark Brown
f302f534fd Move the code that defines an instance of mercury_edt/2 from
Estimated hours taken: 1
Branches: main

Move the code that defines an instance of mercury_edt/2 from
browser/declarative_debugger.m into a module of its own.  This section
of code is large and reasonably self-contained, so it makes sense for it
to have its own module.  Moreover, declarative_debugger.m contains the
main declarative debugging definitions and the upper levels of code for
the front end, and the mercury_edt/2 instance doesn't fit into either of
these categories.

Add an exception handler to the front end, so that if declarative debugging
fails for whatever reason, the debugging session can at least continue using
the procedural debugger.  Rather than calling error in the front end, throw
exceptions that are of a type specific to the front end (so we know which
errors are ours and which aren't).

browser/declarative_debugger.m:
	Add a new type, diagnoser_exception/0.  Handle these exceptions
	but rethrow any other kind.

browser/declarative_debugger.m:
browser/declarative_tree.m:
	Move the mercury_edt/2 instance to the new module.

browser/mdb.m:
	Add the new module to the mdb library.

browser/declarative_*.m:
	Call throw/1 instead of error/1.

tests/debugger/declarative/Mmakefile:
tests/debugger/declarative/catch.exp:
tests/debugger/declarative/catch.inp:
tests/debugger/declarative/catch.m:
	A test case for debugging code that catches exceptions.  This sort
	of code is still not supported by the front end, but at least we
	now give a decent error message and allow debugging to resume.
2002-09-13 04:17:47 +00:00
Zoltan Somogyi
048f8357cf Until now, programmers could add `tabled_for_io' annotations to foreign_procs
Estimated hours taken: 12
Branches: main

Until now, programmers could add `tabled_for_io' annotations to foreign_procs
that do I/O, which asks the compiler to make those foreign_procs idempotent,
i.e. ensures that they are performed at most once even in the presence of a
retry operation in the debugger. This change adds a compiler option,
--trace-table-io-require, which generates an error if a foreign_proc that does
I/O does not have this annotation. Specifying this option thus ensures
that all I/O done by the program is idempotent.

In the future, we may want to have this option turned on in all debugging
grades. Until we decide about, the new option is not yet documented.

compiler/options.m:
	Add the new option --trace-table-io-require.

compiler/handle_options.m:
	Make --trace-table-io-require imply --trace-table-io.

compiler/table_gen.m:
	If --trace-table-io-require is enabled, require all I/O primitives
	to have the tabled_for_io annotation.

compiler/mercury_compile.m:
	Pass I/O states to table_gen.m, since it can now generate error
	messages.

trace/mercury_trace_util.h:
trace/mercury_trace_vars.c:
	When calling Mercury code from the trace directory, disable I/O
	tabling, since any I/O actions executed by Mercury code in the browser
	directory (or by library code called from there) should not be tabled,
	not being part of the user program.

	Due to the depth of nesting, make mercury_trace_vars.c use four-space
	indentation.

browser/collect_lib.m:
browser/declarative_debugger.m:
browser/declarative_execution.m:
browser/dl.m:
browser/io_action.m:
browser/mdb.m:
browser/name_mangle.m:
browser/util.m:
compiler/gcc.m:
compiler/mercury_compile.m:
compiler/passes_aux.m:
compiler/process_util.m:
compiler/stack_layout.m:
library/io.m:
library/time.m:
tests/debugger/declarative/tabled_read_decl.m:
	Add a whole lot of tabled_for_io annotations, to enable the compiler to
	bootstrap with --trace-table-io-require enabled.

	In many cases, this required turning old-style pragma c_code into
	pragma foreign_proc. While doing that, I standardized the layouts
	of pragma foreign_procs.

browser/util.m:
	Turn an impure semidet predicate into a pure det predicate with I/O
	states, to allow it to be tabled. Make it return a Mercury bool
	to indicate success or failure.

library/bool.m:
	Add functions that allow C code to get their hands on the constants
	`yes' and `no', for communication with Mercury code.

library/table_builtin.m:
	Add debugging code to the main primitive of I/O tabling. This is
	controlled both by the macro for retry debugging and a boolean global.

library/mercury_trace_base.[ch]:
	Add the boolean global variable to switch the new debugging code in
	table_builtin.m on and off.

library/mercury_trace_internal.c:
	When starting I/O tabling with retry debug enabled, turn on the switch.

tests/debugger/queens.exp3:
	New expected output file that applies when the library is compiled with
	--trace-table-io-require.
2002-07-22 07:13:14 +00:00
Zoltan Somogyi
985b13ed3f Make I/O actions known to the declarative debugger.
Estimated hours taken: 48
Branches: main

Make I/O actions known to the declarative debugger. The debugger doesn't do
anything with them yet beyond asking about their correctness.

browser/io_action.m:
	New module for representing I/O actions, and for constructing the map
	from I/O action numbers to the actions themselves.

browser/mdb.m:
	Include the new module.

browser/declarative_analysis.m:
	Make the map from I/O action numbers to the actions themselves part
	of the analyzer state, since conversions from annotated trace nodes
	to EDT nodes may now require this information. This information is
	stored in the analyzer state because only the analyser needs this
	information (when converting annotated trace nodes to EDT tree nodes).
	It is not stored in the trace node store because its lifetime is
	different: its contents does not change during a tree deepening
	operation.

browser/declarative_execution.m:
	Store the current value of the I/O action counter with each call and
	exit node. The list of I/O actions associated with the atom of the exit
	node is given by the I/O actions whose counters lie between these two
	values (initial inclusive, final exclusive).

browser/declarative_debugger.m:
browser/declarative_oracle.m:
	Distinguish atoms associated with exit nodes from atoms associated with
	call nodes, since the former, but not the latter, now have a list of
	I/O actions associated with them.

browser/declarative_user.m:
	Add mechanisms for printing and browsing the I/O actions associated
	with EDT nodes and bugs.

runtime/mercury_trace_base.[ch]:
	Move the code for finding an I/O action here from the file
	mercury_trace_declarative.c, for use by browser/io_action.m.

runtime/mercury_layout_util.[ch]:
	Move a utility function here from mercury_trace_declarative.c,
	for use by the code moved to mercury_trace_base.c.

trace/mercury_trace_declarative.c:
	When invoking the front end, pass to it the boundaries of the required
	I/O action map. Cache these boundaries, so we can tell the front end
	when reinvocation of the back end by the front end (to materialize
	previously virtual parts of the annotated trace) does not require
	the reconstruction of the I/O action map.

trace/mercury_trace_vars.[ch]:
	Separate out the code for finding an I/O action from the code for
	browsing it, for use in mercury_trace_declarative.c.

	Note places where the implementation does not live up to the
	documentation.

trace/mercury_trace.[ch]:
	Add a parameter to MR_trace_retry that allows retries to cross I/O
	actions without asking the user if this is OK.

trace/mercury_trace_internal.c:
trace/mercury_trace_external.c:
	Pass MR_FALSE as this new parameter to MR_trace_retry.

tests/debugger/declarative/tabled_read_decl.{m,inp,exp}:
	A slightly modified copy of the tests/debugger/tabled_read_decl test
	case, to check the declarative debugger's handling of goals with I/O
	actions.

tests/debugger/declarative/Mmakefile:
	Enable the new test case.
2002-05-15 11:24:21 +00:00
Mark Brown
03a8cad379 Document the type variable naming conventions for mercury_edt.
Estimated hours taken: 0.1
Branches: main

browser/declarative_analyser.m:
	Document the type variable naming conventions for mercury_edt.

browser/declarative_execution.m:
	Document the type variable naming conventions for annotated_trace.

browser/declarative_debugger.m:
	Document the type edt_node/1.
2002-04-24 17:43:56 +00:00
Zoltan Somogyi
700e5cc1b6 Redesign the way the declarative debugger tracks dependencies, to avoid bugs
Estimated hours taken: 60
Branches: main

Redesign the way the declarative debugger tracks dependencies, to avoid bugs
and make the code comprehensible. This required tackling an issue we could
ignore before: the typeinfos added to procedure arguments by the compiler.

browsers/declarative_debugger.m:
	Rewrite the dependency algorithm from scratch. It now has three phases:
	materializing the contour leading up to the relevent point in the
	procedure body, using that contour to construct a list of the conjoined
	primitive operations executed up to that point by the procedure body,
	and tracking the source of the marked subterm in this list of
	primitives.

	Add a mechanism to print out the result of the dependency tracking
	algorithm if a flag is set, for testing and debugging.

browsers/declarative_analyser.m:
	Transmit the result of the dependency tracking algorithm to where
	it may be printed out.

browsers/declarative_user.m:
	Update the user interface to make it switchable between viewing atoms
	from the user's perspective (with compiler-generated arguments hidden)
	and the implementor's perspective (with compiler-generated arguments
	visible). The default view is the user view.

browsers/declarative_execution.m:
	Add the immediate parent's goal path to the representation of call
	events; this allows us to place the call in the body of its parent.

	Expand the representation of atom arguments to include their HLDS
	variable numbers, and a boolean that says whether the argument
	is a programmer-visible headvar.

	Use this extra information to add support for indexing lists of
	arguments from either the user view or the implementor view.

	Add field names to several types.

browsers/program_representation.m:
	Add a field to plain calls, giving the name of the module defining
	the called procedure. This is necessary to reliably distinguish
	the builtin unify and compare procedures, calls to which must be
	handled specially because they generate no events. (They don't need to,
	since they are correct by construction.)

	Add mechanisms for converting goal paths from strings to structured
	terms, for use by the dependency tracking code.

	Add tests on atomic goals, for use by the dependency tracking code.

	Add a mechanism to let C code retrieve the types of proc_reps as well
	as goal_reps.

compiler/prog_rep.m:
	Fill in the module name field in plain calls.

trace/mercury_trace_vars.[ch]:
	Add functions to get information about a variable specified by HLDS
	number.

trace/mercury_trace_declarative.c:
	Include typeinfos in the atoms constructed at interface events.
	(The same code will work for typeclassinfos as well, once they
	become deconstructable and hence printable.)

	Fill in the extra slot in call events, and the extra slots in
	representations of atom arguments.

trace/mercury_trace_internal.c:
	Fix a bug in the implementation of the proc_body command: the
	type of the proc_rep slot is proc_rep, not goal_rep.

tests/debugger/declarative/dependency.{m,inp,exp}:
	A new test case to exercise dependency tracking. It cooperates with
	instrumentation code in the browser directory to print out the result
	of each trace_dependency operation.

	The test case also tests the proc_body command.

tests/debugger/declarative/Mmakefile:
	Enable the new test case.
2002-04-23 08:52:46 +00:00