Estimated hours taken: 20
Fergus's recent change to the handling of some builtins broke the tracing
of those builtins. The following changes are a fix for this.
compiler/polymorphism.m:
Export the predicate that checks whether a predicate is a builtin
that lacks the usually necessary typeinfos.
Comment out a misleading and in any case not very useful progress
message.
compiler/liveness.m:
Turn off type_info liveness for builtins without typeinfos.
Since these builtins establish no gc points and shouldn't be
execution traced, this is OK.
Make type_info liveness part of live_info, since it can now be
incorrect to look up the value of the option. (This may yield
a speedup.)
compiler/live_vars.m:
compiler/store_alloc.m:
Pass the pred_id to initial_liveness to liveness.m can do the test.
compiler/passes_aux.m:
Add a new traversal type that passes along the pred_id.
compiler/mercury_compile.m:
Turn off execution tracing for the modules builtin.m and
private_builtin.m. The latter contains the interface predicates
for the builtins without typeinfos. Since the interface predicates
also lack the typeinfos, the compiler would get an internal abort
if we left execution tracing on.
In any case, these two modules contain stuff that users should
consider language builtins, which means they should not be execution
traced (they can still be stack traced in the right grade).
Use the new traversal type for the modules that now need the pred_id.
compiler/globals.m:
Allow the trace level to be set from outside, in this case
mercury_compile.m.
The next batch of changes have to do with adding a stack dump command
to the debugger. Since debugging is possible even in non-debug grades,
this in turn requires allowing stack tracing to work in non-debug grades,
on programs in which only some modules are compiled with execution
(and hence stack) tracing.
compiler/llds_out.m:
compiler/mercury_compile.m:
runtime/mercury_conf_param.h:
Llds_out used to output "#include <mercury_imp.h>" as the first
substantive thing in the generated C file. The set of #define
parameters in effect when mercury_imp.h is processed determines
whether the macros that optionally register stack layouts for label
actually do so or not. The values of these parameters are derived
from the grade, which means that with this setup it is not possible
for a non-debug grade program to register its stack layouts in the
label table.
The new version of llds_out looks up the option that says whether
this module is compiled with execution tracing or not, and if it is,
it generates a #define MR_STACK_TRACE_THIS_MODULE *before* the #include
of mercury_imp.h. This causes mercury_conf_param.h, included from
mercury_imp.h, to define the macros MR_USE_STACK_LAYOUTS and
and MR_INSERT_LABELS, which in turn cause stack layouts for labels
in this module to be generated and to be inserted into the label
table, *without* changing the grade string (this last part is why
we do not simply define MR_STACK_TRACE).
Use the same mechanism to #include mercury_trace.h when doing
execution tracing, since it is simpler than the mechanism we
used to use (mercury_compile.m including the #include in a list
of C header file fragments).
compiler/mercury_compile.m:
runtime/mercury_conf_param.h:
Split the MR_NEED_INITIALIZATION_CODE macro into two parts.
The first, MR_MAY_NEED_INITIALIZATION, now controls whether
initialization code makes it into the object file of a module.
The second, MR_NEED_INITIALIZATION_AT_START, determines whether
the initialization code is called before main/2.
When a module is compiled with execution tracing, the macro
MR_INSERT_LABELS turns on MR_MAY_NEED_INITIALIZATION but not
MR_NEED_INITIALIZATION_AT_START. The debugger will make sure
that the initialization code has been called before it tries
to do a stack dump (which needs the initialization code to have
been executed, because it needs labels to have been put into the label
table so that from a return address it can find the layout of the
proc to which it belongs).
Define MR_NEED_INITIALIZATION_AT_START if PROFILE_TIME is defined,
since if PROFILE_TIME is defined mercury_wrapper.c calls init_modules.
The fact that MR_NEED_INITIALIZATION_CODE didn't used to be defined
when PROFILE_TIME was defined was, I believe, a bug, which was
not detected because we do not turn on PROFILE_TIME without also
turning on PROFILE_CALLS.
runtime/mercury_stack_trace.[ch]:
Change the way stack dumps are done, to make it possible to
print stack dumps from the debugger and to use trivial run-length
encoding on the output (so that 100 consecutive calls to p
yield the line "p * 100", rather than 100 lines of "p").
The stack routine now returns an indication of whether the stack dump
was fully successful, and if not, a description of the reason why not.
This requires knowing when we have found the end of the stack dump,
so we provide a global variable, MR_stack_trace_bottom, which
mercury_wrapper.c will set to global_success, the address main/2
goes to on success.
s/multidet/multi/
runtime/mercury_wrapper.c:
Set MR_stack_trace_bottom to the address of globals_success.
Use MR_NEED_INITIALIZATION_AT_START to decide whether to call
do_init_modules.
runtime/mercury_stacks.h:
Provide variants of detstackvar(n) and framevar(n) that look up sp and
curfr in an array of saved regs, for use by the debugger.
runtime/mercury_trace_util.c:
Use the new variants of detstackvar(n) and framevar(n). This fixes
an old bug on SPARCs.
runtime/mercury_trace_internal.c:
Completely reorganize the way debugger commands are handled.
Centralize reading in command lines, and the breaking up of command
lines into words. The command names are the same as they were,
but command syntax is now much easier to change.
Add a new command "d" to dump as much of the stack as the available
information will allow.
runtime/mercury_goto.h:
Cosmetic changes to avoid the use of two different conditional
compilation layout styles.
util/mkinit.c:
Since we cannot know when we generate the _init.c file whether any
modules will be compiled with execution tracing and will thus need
stack tracing, we must now include in the generated _init.c file the
code to call the initialization functions in all the modules, even if
MR_NEED_INITIALIZATION_AT_START is not set, since init_modules
can be called later, from the debugger. (We should be able to
use the same approach with the accurate collector.)
Estimated hours taken: 1
Fix a bug which caused link errors in some grades for some test cases
where the module name wasn't the same as the file name, and which
probably would have caused runtime errors in some grades for test
cases using nested modules.
compiler/modules.m:
Call $(C2INIT) with $(foo.cs) instead of $(foo.ms).
This is necessary now that a single .m file can get compiled
to multiple .c files, if it contains nested modules,
or to a .c file whose name reflects the module name rather
than the source file name.
util/mkinit.c:
scripts/c2init.in:
For efficiency, change c2init and mkinit so that when c2init's
arguments are `.c' files, it computes the init function based
on the filename (like it used to do with `.m' files), rather
than by reading the file contents and searching for "** INIT"
comments. Add a new option `-x' (`--extra-inits') which keeps
the old behaviour.
compiler/modules.m:
scripts/Mmake.rules:
Instead of deleting the `_init.c' file every time we recreate
the `.dep' file, just tell make that the `_init.c' file depends on
the `.dep' file, so that make will remake it if the `.dep' file
changes. (I don't know why I didn't do it that way in the
first place.)
Estimated hours taken: 400
Deforestation.
This increases the code size of the compiler by ~80k when compiling
with --intermodule-optimization --deforestation.
The improvement from deforestation is not measurable for mmc -C make_hlds.m.
Compile time for make_hlds.m increased from 50.7 seconds to 52.2 seconds
when running deforestation.
compiler/simplify.m
compiler/common.m
Provide a nicer interface for simplifying a goal,
not an entire procedure.
Rework the interface to avoid manipulating lots of booleans.
Return an estimate of the improvement in cost from simplification.
Remove failing cases and disjuncts.
Add an option to optimize common structures even across calls.
Remove code to merge branched goals, since that is now
done by deforestation.
Fix a bug: the code to collect instmap_deltas for cases was not
including the switched-on variable in the instmap_delta,
which caused an abort in merge_instmap_delta if the switched
on variable was further instantiated in the switch.
This came up while compiling the compiler with --deforestation.
compiler/det_report.
Output duplicate call warnings even if --warn-simple-code is not set.
XXX fix the same problem with `:- pragma obsolete'.
compiler/code_aux.m
Update code_aux__cannot_loop to use termination information.
compiler/hlds_pred.m
compiler/dnf.m
Pass the type_info_varmap and typeclass_info_varmap
into hlds_pred__define_new_pred.
Restrict the variables of the new procedure onto the variables
of the goal.
Make sure all relevant type_infos are passed into the new
procedure if --typeinfo-liveness is set.
compiler/modes.m
compiler/unique_modes.m
compiler/mode_info.m
compiler/modecheck_unify.m
Put `how_to_check_goal' into the mode_info, rather
than passing it around.
Add a field to the `check_unique_modes' case which
controls whether unique modes is allowed to choose
a different procedure. For deforestation, this is
not allowed, since it could result in choosing a less
efficient procedure after generalisation.
compiler/options.m
New options:
--deforestation
--deforestation-depth-limit
Safety net for termination of the algorithm.
--deforestation-cost-factor
Fudge factor for working out whether deforestation
was worthwhile.
--deforestation-vars-threshold
Like --inline-vars-threshold.
Enable deforestation at -O3.
Removed an unnecessary mode for option_defaults_2, since it
resulted in a warning about disjuncts which cannot succeed.
compiler/handle_options.m
--no-reorder-conj implies --no-deforestation.
compiler/inlining.m
Separate code to rename goals into inlining__do_inline_call.
compiler/hlds_goal.m
Added predicates goal_list_nonlocals, goal_list_instmap_delta
and goal_list_determinism to approximate information about
conjunctions.
compiler/hlds_module.m
Added module_info_set_pred_proc_info to put an updated
pred_info and proc_info back into the module_info.
compiler/hlds_out.m
Exported hlds_out__write_instmap for debugging of deforestation.
Bracket module names on constructors where necessary.
compiler/mercury_compile.m
Call deforestation.
Use the new interface to simplify.m.
compiler/intermod.m
Put recursive predicates with a top-level branched goal
into `.opt' files.
goal_util.m
Added goal_calls_pred_id to work out if a predicate is
recursive before mode analysis.
Export goal_util__goals_goal_vars for use by deforestation.
Give a better message for a missing variable in a substitution.
compiler/instmap.m
Give a better message for inst_merge failing.
compiler/notes/compiler_design.m
Document the new modules.
library/varset.m
Add varset__select to project a varset's names and values
onto a set of variables.
doc/user_guide.texi
Document deforestation.
Remove a reference to a non-existent option, --no-specialize.
util/mdemangle.c
profiler/demangle.m
tests/misc_tests/mdemangle_test.{exp,inp}
Handle the `DeforestationIn__' predicate names introduced by
deforestation, similar to the `IntroducedFrom__' for lambda goals.
New files:
deforest.m Deforestation.
pd_cost.m Cost estimation.
pd_debug.m Debugging output.
pd_info.m State type and version control.
pd_term.m Termination checking.
pd_util.m Utility predicates
Estimated hours taken: 24
Add support to the Mercury tracer for interacting with an external
Opium-style debugger via a socket.
TODO: currently there is no way for the debugger to specify
constraints on the arguments for a `forward_move' query.
The current code for doing that doesn't work.
(However, the reporting of arguments to the debugger
for an `output_current' query works fine.)
runtime/mercury_trace.c:
Add code to MR_trace() to open a socket connection to
an external debugger, and to process requests from that
debugger, and send responses back.
runtime/mercury_trace.h:
runtime/mercury_wrapper.c:
Call MR_trace_end() from mercury_runtime_terminate() so that
the external debugger gets notified when the program does
a (normal) exit.
runtime/mercury_stack_layout.h:
Fix a bug where the structures here did not match
the output produced by compiler/stack_layout.m.
library/debugger_interface.m:
New file. Declares the Mercury types used for the debugger
socket interface and defines support routines used by
runtime/mercury_trace.c.
library/io.m:
runtime/mercury_types.h:
Move the definition of MercuryFile from library/io.m to
runtime/mercury_types.h, for use by runtime/mercury_trace.c.
library/io.m:
When printing out values of type `c_pointer', print out
the "<<c_pointer>>" string in single quotes, to ensure
that it has valid syntax for a Prolog or Mercury term.
This is necessary because otherwise c_pointers in procedure
arguments could lead to the Mercury process sending a
syntactically invalid term down the socket to the debugger,
which would then be unable to parse it.
library/library.m:
Add reference to debugger_interface.m, so that it gets
include in libmercury.a.
doc/Mmakefile:
Make sure that the library/debugger_interface.m does *not*
get included in the Mercury library reference manual.
runtime/mercury_wrapper.h:
runtime/mercury_wrapper.c:
runtime/mercury_init.h:
util/mkinit.c:
Declare, define, and initialize pointers to the C functions
exported by library/debugger_interface.m.
(This is to avoid having a circular dependency where the
runtime depends on the library.)
compiler/notes/authors.html:
Add Erwan Jahier.
Estimated hours taken: 12
Add support for stack dumps, do a stack dump from error/1.
compiler/Mmakefile:
library/Mmakefile:
profiler/Mmakefile:
runtime/Mmakefile:
Insert EXTRA_MGNUCFLAGS before CFLAGS or EXTRA_CFLAGS
becasue mgnuc stops processing its options when it
encounters a non-mgnuc option.
library/require.m:
Call MR_dump_stack if error is called.
runtime/Mmakefile:
runtime/mercury_imp.h:
Add #includes of new files.
runtime/mercury_type_info.h:
Remove conditional definition of MR_STATIC_CODE_ADDRESSES
(moved into mercury_conf.h.in).
runtime/mercury_accurate_gc.h:
Remove stack_layout stuff, leave this file for accurate
GC specific definitions.
runtime/mercury_conf.h.in:
Add conditional definitions of MR_INSERT_LABELS,
MR_USE_STACK_LAYOUTS, MR_NEED_INITIALIZATION_CODE and
MR_STATIC_CODE_ADDRESSES, depending on various other options.
runtime/mercury_goto.h:
Insert labels into label table if MR_INSERT_LABELS is defined,
rather than NATIVE_GC.
util/mkinit.c:
Initialize if MR_NEED_INITIALIZATION_CODE is defined, rather than
NATIVE_GC.
runtime/mercury_stack_layout.h:
All the old stack layout definitions from mercury_accurate_gc.h.
Add code for MR_DETISM_DET_CODE_MODEL.
runtime/mercury_stack_trace.c:
runtime/mercury_stack_trace.h:
Implement MR_dump_stack which just provides a dump of the stack
as far as possible.
Set MR_INSERT_LABELS and MR_USE_STACK_LAYOUTS if MR_STACK_TRACE
is set.
runtime/mercury_grade.h:
Add _strce if stack tracing is enabled in the grade. This
might not be a permanent change.
runtime/mercury_ho_call.c:
Remove unused label declarations.
scripts/mgnuc.in:
Add --stack-trace and --no-stack-trace options.
Consolidate some duplicate code.
Estimated hours taken: 1
Fix a bug where `mkinit' was not mangling nested module names properly.
(This bug meant that nested modules didn't work in grades which required
initialization functions, e.g. the profiling grades.)
compiler/llds_out.m:
Use the mangled module name rather than the mangled file name
to compute the init function names, because nested module
names get mangled with the module names separated by `__',
whereas mangled file names use the ugly `f_<numbers>' ASCII escapes
to encode names containing `.'.
util/mkinit.c:
Handle nested module names: convert `.' to `__' when computing
the init function name from the file name.
(Note: it is still not using the full name mangling algorithm
here, so this will still fail if the module name contains special
characters.)
Also change the layout of curly braces in a few places,
to match our C coding guidelines.
Estimated hours taken: 50
Add support for nested modules.
- module names may themselves be module-qualified
- modules may contain `:- include_module' declarations
which name sub-modules
- a sub-module has access to all the declarations in the
parent module (including its implementation section).
This support is not yet complete; see the BUGS and LIMITATIONS below.
LIMITATIONS
- source file names must match module names
(just as they did previously)
- mmc doesn't allow path names on the command line any more
(e.g. `mmc --make-int ../library/foo.m').
- import_module declarations must use the fully-qualified module name
- module qualifiers must use the fully-qualified module name
- no support for root-qualified module names
(e.g. `:parent:child' instead of `parent:child').
- modules may not be physically nested (only logical nesting, via
`include_module').
BUGS
- doesn't check that the parent module is imported/used before allowing
import/use of its sub-modules.
- doesn't check that there is an include_module declaration in the
parent for each module claiming to be a child of that parent
- privacy of private modules is not enforced
-------------------
NEWS:
Mention that we support nested modules.
library/ops.m:
library/nc_builtin.nl:
library/sp_builtin.nl:
compiler/mercury_to_mercury.m:
Add `include_module' as a new prefix operator.
Change the associativity of `:' from xfy to yfx
(since this made parsing module qualifiers slightly easier).
compiler/prog_data.m:
Add new `include_module' declaration.
Change the `module_name' and `module_specifier' types
from strings to sym_names, so that module names can
themselves be module qualified.
compiler/modules.m:
Add predicates module_name_to_file_name/2 and
file_name_to_module_name/2.
Lots of changes to handle parent module dependencies,
to create parent interface (`.int0') files, to read them in,
to output correct dependencies information for them to the
`.d' and `.dep' files, etc.
Rewrite a lot of the code to improve the readability
(add comments, use subroutines, better variable names).
Also fix a couple of bugs:
- generate_dependencies was using the transitive implementation
dependencies rather than the transitive interface dependencies
to compute the `.int3' dependencies when writing `.d' files
(this bug was introduced during crs's changes to support
`.trans_opt' files)
- when creating the `.int' file, it was reading in the
interfaces for modules imported in the implementation section,
not just those in the interface section.
This meant that the compiler missed a lot of errors.
library/graph.m:
library/lexer.m:
library/term.m:
library/term_io.m:
library/varset.m:
compiler/*.m:
Add `:- import_module' declarations to the interface needed
by declarations in the interface. (The previous version
of the compiler did not detect these missing interface imports,
due to the above-mentioned bug in modules.m.)
compiler/mercury_compile.m:
compiler/intermod.m:
Change mercury_compile__maybe_grab_optfiles and
intermod__grab_optfiles so that they grab the opt files for
parent modules as well as the ones for imported modules.
compiler/mercury_compile.m:
Minor changes to handle parent module dependencies.
(Also improve the wording of the warning about trans-opt
dependencies.)
compiler/make_hlds.m:
compiler/module_qual.m:
Ignore `:- include_module' declarations.
compiler/module_qual.m:
A couple of small changes to handle nested module names.
compiler/prog_out.m:
compiler/prog_util.m:
Add new predicates string_to_sym_name/3 (prog_util.m) and
sym_name_to_string/{2,3} (prog_out.m).
compiler/*.m:
Replace many occurrences of `string' with `module_name'.
Change code that prints out module names or converts
them to strings or filenames to handle the fact that
module names are now sym_names intead of strings.
Also change a few places (e.g. in intermod.m, hlds_module.m)
where the code assumed that any qualified symbol was
fully-qualified.
compiler/prog_io.m:
compiler/prog_io_goal.m:
Move sym_name_and_args/3, parse_qualified_term/4 and
parse_qualified_term/5 preds from prog_io_goal.m to prog_io.m,
since they are very similar to the parse_symbol_name/2 predicate
already in prog_io.m. Rewrite these predicates, both
to improve maintainability, and to handle the newly
allowed syntax (module-qualified module names).
Rename parse_qualified_term/5 as `parse_implicit_qualified_term'.
compiler/prog_io.m:
Rewrite the handling of `:- module' and `:- end_module'
declarations, so that it can handle nested modules.
Add code to parse `include_module' declarations.
compiler/prog_util.m:
compiler/*.m:
Add new predicates mercury_public_builtin_module/1 and
mercury_private_builtin_module/1 in prog_util.m.
Change most of the hard-coded occurrences of "mercury_builtin"
to call mercury_private_builtin_module/1 or
mercury_public_builtin_module/1 or both.
compiler/llds_out.m:
Add llds_out__sym_name_mangle/2, for mangling module names.
compiler/special_pred.m:
compiler/mode_util.m:
compiler/clause_to_proc.m:
compiler/prog_io_goal.m:
compiler/lambda.m:
compiler/polymorphism.m:
Move the predicates in_mode/1, out_mode/1, and uo_mode/1
from special_pred.m to mode_util.m, and change various
hard-coded definitions to instead call these predicates.
compiler/polymorphism.m:
Ensure that the type names `type_info' and `typeclass_info' are
module-qualified in the generated code. This avoids a problem
where the code generated by polymorphism.m was not considered
type-correct, due to the type `type_info' not matching
`mercury_builtin:type_info'.
compiler/check_typeclass.m:
Simplify the code for check_instance_pred and
get_matching_instance_pred_ids.
compiler/mercury_compile.m:
compiler/modules.m:
Disallow directory names in command-line arguments.
compiler/options.m:
compiler/handle_options.m:
compiler/mercury_compile.m:
compiler/modules.m:
Add a `--make-private-interface' option.
The private interface file `<module>.int0' contains
all the declarations in the module; it is used for
compiling sub-modules.
scripts/Mmake.rules:
scripts/Mmake.vars.in:
Add support for creating `.int0' and `.date0' files
by invoking mmc with `--make-private-interface'.
doc/user_guide.texi:
Document `--make-private-interface' and the `.int0'
and `.date0' file extensions.
doc/reference_manual.texi:
Document nested modules.
util/mdemangle.c:
profiler/demangle.m:
Demangle names with multiple module qualifiers.
tests/general/Mmakefile:
tests/general/string_format_test.m:
tests/general/string_format_test.exp:
tests/general/string__format_test.m:
tests/general/string__format_test.exp:
tests/general/.cvsignore:
Change the `:- module string__format_test' declaration in
`string__format_test.m' to `:- module string_format_test',
because with the original declaration the `__' was taken
as a module qualifier, which lead to an error message.
Hence rename the file accordingly, to avoid the warning
about file name not matching module name.
tests/invalid/Mmakefile:
tests/invalid/missing_interface_import.m:
tests/invalid/missing_interface_import.err_exp:
Regression test to check that the compiler reports
errors for missing `import_module' in the interface section.
tests/invalid/*.err_exp:
tests/warnings/unused_args_test.exp:
tests/warnings/unused_import.exp:
Update the expected diagnostics output for the test cases to
reflect a few minor changes to the warning messages.
tests/hard_coded/Mmakefile:
tests/hard_coded/parent.m:
tests/hard_coded/parent.child.m:
tests/hard_coded/parent.exp:
tests/hard_coded/parent2.m:
tests/hard_coded/parent2.child.m:
tests/hard_coded/parent2.exp:
Two simple tests case for the use of nested modules with
separate compilation.
Estimated hours taken: 20
Use stack layout tables to transmit information to the tracer, to allow
the tracer to print the names and values of variables at CALL and EXIT ports.
Extend stack layout tables to permit this.
For the time being the tables do not contain information about how to fill
in pseudo-typeinfos, so printing only works for monomorphic procedures.
compiler/llds.m:
Allow space for variable names in the information we gather about live
variables at given labels.
compiler/llds_out.m:
Print out variable names in the information we gather about live
variables at given labels in comments.
compiler/continuation_info.m:
Include variable names in the information we gather about live
variables at given labels.
Record the determinism of each procedure, not its code model.
compiler/{call_gen,code_gen,code_info}.m:
Include the names of variables in the data given to
continuation_info.m.
compiler/options.m:
Add a new developer-only option, --procid-stack-layout, whose effect
is to extend stack_layout structures with static info identifying the
procedure. This is used by execution tracing, and could (should) be
used by stack tracing and profiling.
Rename --alternate-liveness as --typeinfo-liveness. This is more
expressive. Later we should add a new option --trace-liveness, which
preserves every variable until the end of the clause for use by
the trace debugger.
compiler/handle_options.m:
Handle the option implications of --procid-stack-layout.
compiler/stack_layout.m:
Include the encoded determinism instead of the code model in stack
layout tables.
Include variable names in the live data section of stack layout tables
if they are available.
Include procedure identification information in the stack layout tables
if --procid-stack-layout is set.
compiler/trace.m:
Use the new interface to MR_trace.
compiler/*.m:
Trivial changes following from the renaming of --alternate-liveness.
runtime/mercury_accurate_gc.h:
Add macros to decode encoded determinisms.
Define structs for accessing the stack layout tables.
runtime/mercury_regs.h:
Define a macro similar to virtual_reg, except in that it can refer
to an arbitrary memory area, not just fake_reg.
runtime/{mercury_string,mercury_types}.h:
Move the typedefs of Char, UnsignedChar, String and ConstString
from mercury_string.h to mercury_types.h to avoid problems with
circular #includes.
runtime/mercury_trace.[ch]:
Revise the interface to MR_trace so that it takes the layout table
of the procedure as an argument. From the layout table, we can get
to the module name, predicate name, arity, mode number, and
determinism of the procedure, so we don't need to pass these any more,
reducing parameter passing overhead. We can also get to information
about where the input and output arguments are. We now use this
information to allow the user to print out the value of the arguments
at the CALL and EXIT ports.
Change the prompt to a less intrusive "mtrace> ".
runtime/mercury_wrapper.[ch]:
Add a new global variable, MR_library_trace_browser. We reserve space
for this variable in mercury_wrapper.c. It will be initialized by the
automatically generated xxx_init.c file to point to the procedure
that the tracer will invoke to let the user browse the values of
variables. This mechanism allows the runtime to maintain its current
ignorance about the contents of the standard library.
util/mkinit.c:
Generate additional code in the xxx_init.c files to fill in the value
of MR_library_trace_browser.
tests/misc_tests/debugger_test.{inp,exp}:
Add a few printing commands into the input for this test case, and
update the expected output.
Estimated hours taken: 30
Add library and runtime support for stack layouts.
library/array.m:
library/benchmarking.m:
library/mercury_builtin.m:
library/std_util.m:
library/string.m:
runtime/mercury_engine.c:
runtime/mercury_ho_call.c:
runtime/mercury_type_info.c:
Add MR_MAKE_STACK_LAYOUT_* macros to add basic stack layouts for
handwritten C code.
runtime/mercury_type_info.c:
Remove some duplicate label declarations.
runtime/mercury_calls.h:
Don't use ASM_FIXUP_REGS in calls with NATIVE_GC - we don't
want (or need) to use it. We define all labels as entry labels
anyway, so an ASM_FIXUP_REGS is done at each label.
runtime/mercury_label.c:
runtime/mercury_label.h:
runtime/mercury_goto.h:
Insert references to stack layouts into the label table.
Use the label table when NATIVE_GC is defined.
Modify the way labels are declared so they have the necessary
scope.
runtime/mercury_imp.h:
Include mercury_accurate_gc.h
runtime/mercury_accurate_gc.h:
Add some macros to define stack layouts for handwritten
code, and access various fields of the stack layouts.
util/mkinit.c:
Add NATIVE_GC to the #ifdef .... that controls the running of
the initialization code for each module. NATIVE_GC requires the
label table to be initialized.
Fix this code so the two instances of this list of #defines are
replaced by a single string constant. I've been bitten _twice_
by this double definition, and I refuse to be bitten again.
compiler/stack_layout.m:
Rename MR_LIVE_LVAL to Mr_Live_Lval in the documentation.
Estimated hours taken: 2
Cleaned up runtime directory.
runtime/*.c:
- Renamed all .c files as mercury_*.c
Some have been renamed to make their purpose clearer.
call.mod -> mercury_ho_call.c
runtime/*.h:
- Moved contents of .h files to mercury_*.h
- *.h now contain #include mercury_*.h. They be removed later.
- Updated references to conf.h -> mercury_conf.h
runtime/conf.h.in:
- Renamed conf.h.in as mercury_conf.h.in.
Didn't leave a forwarding header for this one, as conf.h was
never part of the repository anyway.
runtime/Mmakefile:
- Convert lists to one-per-line lists.
- Add mercury_accurate_gc.h to HDRS.
- Remove all .mod files
- Make sure runtime.init uses the ORIG_CS not MOD_CS.
- Fix the rules for "clean_o" and "clean_mod_c", which used
wildcards like "*.o" to remove files. The one that removed
all .c files corresponding with *.mod, instead of using MOD_CS
was particularly vicious.
- Cope with the file renamings.
configure.in:
- Cope with the file renamings.
Estimated hours taken: 1
Fix a bug that caused problems with profiling.
util/mdemangle.c:
profiler/demangle.m:
When demangling lambda goals, include the sequence number
and module name in the demangled name.
The profiler requires that the mapping between mangled
and demangled names must be one-to-one.
tests/misc_tests/mdemangle_test.inp:
tests/misc_tests/mdemangle_test.exp:
Update the tests to reflect the new demangling algorithm.
Estimated hours taken: 0.5
configure.in:
runtime/conf.h.in:
util/mdemangle.c:
Check whether the system has memmove(). (SunOS 4.x doesn't.)
If not, use memcpy().
Estimated hours taken: 0.5
util/mdemangle.c:
Fix a bug introduced in Tom's recent changes to handle
lamdbda goals: for ordinary predicates, it was just
printing out the module name, not the predicate name.
tests/misc_tests/mdemangle_test.inp:
tests/misc_tests/mdemangle_test.exp:
Some regression tests for the above bug fix.
Estimated hours taken: 8
Split up the startup interface so that there are seperate
initialization and termination functions, rather than just a single
mercury_runtime_main() function which does everything.
Also change things so that the io__state data is stored in global
variables.
runtime/init.h:
util/mkinit.c:
runtime/wrapper.h:
runtime/wrapper.mod:
Move declarations for stuff defined in wrapper.mod from init.h
to wrapper.h. Clean up the remainder of init.h so that it
is clear which parts are interface and which are just there
for use by *_init.c.
Change the automatically-generated *_init.c files
so that they call mercury_runtime_init(),
mercury_runtime_main(), and mercury_runtime_terminate(),
rather than just mercury_runtime_main().
Define these new two functions in wrapper.mod.
Delete the library_entry_point; change do_interpreter
to call program_entry_point directly, rather than via
library_entry_point.
runtime/engine.h:
runtime/engine.mod:
Add new function terminate_engine().
Delete the function start_mercury_engine();
move the code that used to be there to the end
of init_engine().
runtime/context.h:
runtime/context.mod:
Add new function shutdown_processes().
(The current implementation is just a stub.)
Add a call to debug_memory() in init_process_context().
runtime/memory.h:
runtime/memory.c:
Export the debug_memory() function, for use by context.c.
library/io.m:
library/io.nu.nl:
Change things so that the io__state data is stored in C global
variables (or, for Prolog, using assert/retract), rather than
passing around a data structure. (Actually we still pass the
data structure around, but it is just a dummy Word that never
gets used.)
Delete the old hand-coded io__run predicate, which was
the library entry point; instead export C functions
ML_io_init_state() and ML_io_finalize_state(). Move the
code for handling profiling from io__run to do_interpreter
in runtime/wrapper.mod.
scripts/c2init.in:
Change the default entry point from io__run_0_0 to main_2_0
configure.in:
runtime/conf.h.in:
Define USE_DLLS in conf.h.
runtime/imp.h:
runtime/init.h:
runtime/memory.c:
runtime/table.c:
util/mkinit.c:
boehm_gc/gc.h:
Conditionalize things on `#ifdef(USE_DLLS)' rather than on
`#ifdef(__CYGWIN32__)'. Testing for specific systems tends
to lead to code that is difficult to maintain.
util/mkinit.c:
Fix a bug: it was checking `#if defined(libmer_USE_DLL)', but it
should have been checking `#if !defined(libmer_DEFINE_DLL)'.
Estimated hours taken: 24
Implement support for DLLs on Windows.
The changes consisted of
1. Adding `Makefile.DLLs', which is a file I wrote contains
GNU Make rules for building DLLs. Making sure that
the various Mmakefiles include that one.
2. Making sure we #include the "libfoo_dll.h" header file
generated by `Makefile.DLLs' before every place that
references a global variable.
3. Making sure that code which defines the DLLs is
compiled with -Dlibfoo_DEFINE_DLL.
5. Changing various places to explicitly register the data
segment as a root set with the conservative garbage collector.
This was necessary to get GC working with DLLs under Windows
(there doesn't seem to be any way of automatically finding
the data segments of DLLs under win32).
6. Changing the way names are mangled to ensure that the assembler
names always contain a leading underscore, since `dlltool'
on gnu-win32 requires this.
TODO:
- Document how users can create their own DLLs.
- Add support for that to Mmake.
configure.in:
Mmake.common.in:
Add USE_DLLS variable. (Most of the Makefile changes below are
conditionalized on this variable.)
boehm_gc/Makefile:
Add dependency $(OBJS) : libgc_dll.h.
Add `-DGC_DEFINE_DLL' to CFLAGS.
Include Mmakefile.DLLs.
Add new targets `dll' and `test_dll'.
boehm_gc/Mmakefile:
Add stuff to install libgc_dll.h and libgc_globals.h.
boehm_gc/gc.h:
For __CYGWIN32__, #include "libgc_dll.h".
This is necessary to handle global variables in DLLs on Windows.
For __CYGWIN32__, define GC_INIT() to add the
data segment of the current DLL or executable as
a new root set.
library/Mmakefile:
Add stuff needed for building DLLs.
runtime/wrapper.mod:
library/io.m:
Add call to GC_INIT() to register the root set for
libmer.dll and libmercury.dll respectively.
In wrapper.mod, move the call to GC_is_visible
_after_ the calls to GC_INIT().
runtime/Mmakefile:
Add stuff needed for building DLLs.
runtime/init.h:
runtime/imp.h:
runtime/dummy.c:
runtime/label.c:
runtime/memory.c:
runtime/table.c:
For __CYGWIN32__, make sure we #include "libmer_dll.h".
before defining global variables.
This is necessary to handle global variables in DLLs
on Windows.
runtime/goto.h:
util/mdemangle.c:
prof/demangle.m:
Change the way names are mangled to ensure that the assembler
names always contain a leading underscore, since `dlltool'
on gnu-win32 requires this.
util/mkinit.c:
For __CYGIN32__, when using DLLs, make sure we initialize the
_impure_ptr of the DLLs that we're using.
library/Mmake:
runtime/Mmake:
Compile with -Dlibfoo_USE_DLL options.
Add code to install libfoo_dll.h and libfoo_globals.h.
Include Mmakefile.DLLs.
Estimated hours taken: 1.5
Profiling code with lots of lambda goals was painful, because the names
of the predicates contained no information about which piece of the source
they correspond to. This change corrects this problem by enabling the
profiler to produce output such as:
... 0.00 0.00 <pred/func goal from lp:'pivot', line 362> [10]
... 0.00 0.00 <pred/func goal from lp:'pivot', line 356> [11]
... 0.00 0.00 <pred/func goal from lp:'simplex', line 262> [12]
compiler/lambda.m:
compiler/polymorphism.m:
construct more meaningful predicate names for lambda predicates.
this required adding the name of the predicate that contained the
lambda goal to the info structures that gets threaded through
these modules.
profiler/demangle.m:
util/mdemangle.c:
demangle the names for lambda goals.
Estimated hours taken: 0.3
MGNUC = MERCURY_C_INCL_DIR=$(RUNTIME_DIR) $(SCRIPTS_DIR)/mgnuc
util/Mmake:
Set MERCURY_C_INCL_DIR when running mgnuc, as the installed
runtime directory might not have compatible header files.
and in the profiler.
util/mdemangle.c:
Add code to demangle the special-case names properly.
tests/misc_tests/mdemangle_test.inp:
tests/misc_tests/mdemangle_test.exp:
Modify the expected output to reflect the bug fix to util/demangle.c.
profiler/demangle.m:
New module: contains a procedure for demangling Mercury labels.
profiler/demangle_test.m:
Test harness for demangle.m. Duplicates the functionality of
util/demangle.c. (Currently not used for anything except testing,
but we might one day want to use this code to replace util/demangle.c)
profiler/read.m:
Use the code in demangle.m to demangle labels.
profiler/output.m:
Output the alphabetic listing using one column rather than two,
since the demangled names are often too long to fit in a two-column
format.
profiler/options.m:
profiler/prof_info.m:
Remove some unnecessary `import_module' declarations.
compiler/unused_args.m:
Fix a bug in the mangling of predicate names for unused-arg
versions of special preds (index, compare, unify).
Estimated hours taken: 0.3
util/mdemangle.c:
Fix mdemangle to handle `base_type_functors'.
tests/misc_tests/mdemangle_test.inp:
Add a test case for `base_type_functors'.
Estimated hours taken: 1
util/mkinit.c:
Implement a new `-l' ("library") option.
If this option is enabled, we don't emit a main(),
but instead we emit a mercury_main(argc, argv, stack_bottom)
function that can be called from C.
Estimated hours taken: 1
util/mdemangle.c
Reordered some code so that mangled predicate names with
unused arguments are demangled correctly.
Fix an off-by-one error that caused single character predicate names
with unused arguments to be incorrectly demangled (not that Mercury
programmers ever use single character predicate names :-).
Clarified the code to check for optimization suffixes.
Estimated hours taken: 5
Clean up symbol demangling, and add demangling of mercury_data symbols.
util/mdemangle.c:
Add code to decode mercury_data items, including common
blocks, base_type_infos and base_type_layouts.
Fix demangling of f_cut and other builitins, so that at least
something is output.
Move duplicated code into functions.
(This code might now pass first year).
Estimated hours taken: 0.5
util/mdemangle.c:
Cast the arguments to isdigit() to `unsigned char', since
isdigit() requires that. (This fixes a potential portability
problem porting to C compilers for which `char' is signed.)
Estimated hours taken: 0.5
Mangle function names differently, so that we don't get
symbol name clashes between a function of arity N and
a predicate of arity N+1. (This fixes a bug which resulted
in error messages from the assembler.)
util/mdemangle.c:
Add code to demangle the new encoding of function symbols.
Estimated hours taken: 0.5
util/mkinit.c:
In the code generated for main(), explicitly register the stack
bottom by setting `GC_stackbottom' to the address of a dummy local
variable. This is necessary for the Boehm collector to work
on AIX 4.1.
Estimated hours taken: 0.25
Fix things so that there are no circular dependencies amoungst the
libraries, so that shared libraries work better (e.g. they can
use QuickStart on Irix 5). The dependencies are linear again:
program -> library -> runtime -> boehm_gc.
util/mkinit.c:
Change the set of address variables initialized in the
generated code for main().
Estimated hours taken: 1
util/mdemangle.c
Fixed to handle the __ua<n> and __ho<n> added to the end of the
predicate name by unused_args.m and higher_order.m.
Estimated hours taken: 1
Fix bug in `fast.gc' grade reported by Eero Pajarre.
(The symptom was "Mercury runtime: no entry point supplied".)
util/mkinit.c:
If we are in `fast' or `fast.gc' grade, make sure we invoke
`do_init_modules()' to initialize the entry point variables
before we use them.
util/mkinit.c:
Make sure that there are no undefined external references
when building the shared libraries, so that we can use
`ld -no_unresolved' on Irix 5. This means the shared libraries
can be Quickstarted, which improves startup time.
The way it was done was by changing all calls to external
references to instead call indirectly via global variables.
mkinit.c now generates a main() which initializes various
global variables and then calls mercury_main().
Mmake:
Change the `uninstall' rule so that rather than using `rm -f',
it uses plain `rm' but then ignores the exit status. If we
encounter permission errors when doing a `mmake uninstall', the
user should know about them.