Estimated hours taken: 120
Branches: main
The following change is only 98% complete, not 100%. I am committing it in
this state because (1) we pass many more test cases in deep profiling grade
with it than without it, and (2) the double maintanance involved in fixing
CVS conflicts is preventing me from doing the last 2%.
Get the deep profiler to work for code that sets up to catch exceptions,
which for the last year or more has included the compiler, and to get it
almost working for code that actually catching exceptions.
The basic problem is that code that throws exceptions will in general cause
several calls to "return" without executing the exit or fail port codes that
the deep profiling transformation inserted into their bodies, and this leaves
the data structure being built by the deep profiling inconsistent. The solution
uses the same approach as we have adopted for the debugger: have the code that
handles the throwing of exceptions simulate a return from each call between
the throw and the catch, updating the deep profiling data structures as needed.
This requires us to be able to walk the stack at runtime not just in debugging
grades but also in deep profiling grades. Since the debugger already has the
mechanisms required for this, we reuse them. The procedure layouts used by the
debugger were designed to have three segments: the procedure stack walk
information, the procedure id, and the execution tracing information. We now
modify this design to make the third segment contain two pointers: to the
execution tracing information (for use by the debugger), and to the procedure's
proc_static structure (for use by deep profiling). Each pointer will be null
unless the pointed-to structure is required by compile-time options.
This common use by the debugger and by deep profiling of the stack-walk
structure and the procedure id structure (which deep profiling used to
generate independently and possibly redundantly) required some rearrangement
of the compiler's version of these data structures.
To make this rearrangement simpler, this diff removes a capability that
we theoretically supported but never used: turning on stack traces without
turning on execution tracing and vice versa. After this diff, stack tracing
is enabled if and only if either execution tracing or deep profiling is
enabled.
The diff also includes improvements in the debugging infrastructure for
debugging deep profiling, which were necessary for the implementation of the
rest of the changes.
compiler/deep_profiling.m:
The code in exception.m needs to know the locations of the variables
that we would pass to the exit or fail port code, so it can simulate
leaving the procedure invocation through the exception port. Without
this information, throwing an exception leaves the deep profiling
data structures of the procedure invocations between throw and catch
in an inconsistent state.
Deep_profiling.m creates these variables, but it doesn't know where
they will be at runtime, so it records their identities; the code
generator will allocate them stack slots and record the numbers of
these stack slots for placement in the now expanded proc layout
structures. Deep profiling used to generate static data structures
separately from the HLDS, but since the code generator now needs
access to them, we store their information in proc_infos in the HLDS.
Instead of passing the addresses of proc_static structures to the deep
profiling port procedures, pass the address of proc_layout structures,
since the information about the identities of procedures are now stored
not in the proc_static structure, but in the proc_layout structure
that points to the proc_static structure.
compiler/hlds_pred.m:
compiler/layout.m:
Move the definitions of the static data structures generated by deep
profiling from layout.m to hlds_pred.m, to allow deep_profiling.m
to store them in proc_infos.
compiler/hlds_pred.m:
compiler/rtti.m:
Move the definition of rtti_proc_label from rtti.m to hlds_pred.m,
since some of the new data structures in hlds_pred.m need it. Despite
its name, the rtti_proc_label type doesn't contain any info that
doesn't belong in the HLDS.
Add some information to the rtti_proc_label type that is now needed
by deep profiling, e.g. record determinisms instead of just code
models. Record explicitly the outcome of some tests that used to be
duplicated in more than one place in the compiler, e.g. for whether
the procedure (as opposed to the predicate) is imported. Change some
of the field names to be more precise about the field's meaning.
compiler/code_gen.m:
Transmit the contents of the deep profiling data structures stored in
the proc_info by deep_profiling.m to continuation_info.m, together
with the layout structures created for execution tracing and the
identities of the variables needed for handling exceptions,
when code generation for a procedure is complete.
After the goal that generates these variables, save them to stack
for use by the exception handler.
compiler/hlds_goal.m:
Add a feature to mark the goal that generates the deep profiling
variables needed by the exception handler.
compiler/hlds_llds.m:
Add a utility predicate for new code in code_gen.m
compiler/continuation_info.m:
Hold the deep profiling information computed by code_gen.m for use by
stack_layout.m.
compiler/layout.m:
compiler/layout_out.m:
Update the definitions of the data structures describing procedure
layouts, and the code writing them out, to reflect the use of some
parts of procedure layouts by deep profiling as well as debugging.
Change the layout structures generated by deep profiling to use
rtti_proc_labels, which are backend independent, instead of
proc_labels, which are specific to the LLDS backend.
Conform to the changes in runtime/mercury_stack_layout.h.
compiler/stack_layout.m:
Generate the updated version of proc_layout structures.
compiler/mercury_compile.m:
compiler/global_data.m:
Conform to the fact that deep profiling no longer generates layout
structures separate from proc_infos.
compiler/llds_out.m:
Register proc_layout structures instead of proc_static structures
for use by runtime/mercury_deep_profiling.c.
compiler/options.m:
compiler/handle_options.m:
Rename the require_tracing option as exec_trace, since this more
directly reflects its meaning.
Instead of having --debug set both require_tracing and stack_trace,
make it set (be the user-visible name of) just exec_trace;
the value of stack_trace is implied.
Turn off the specialization of deep profiling for self-tail-recursive
procedures for now. Due to the changes made by this diff in the data
structures involved in debugging, it cannot be debugged until this
change has been installed. Handling the full language is more important
than a specialization that reduces only stack space overheads, not
runtime overheads.
compiler/compile_target_code.m:
Conform to the changes in options.m and runtime/mercury_grade.h.
compiler/hlds_data.m:
Replace the deep_profiling_proc_static cons_id, and its associated tag,
to deep_profiling_proc_layout, since we now generate addresses of proc
layout structures, not of proc_static structures.
compiler/code_util.m:
Simplify some code based on the new info in rtti_proc_labels.
compiler/bytecode_gen.m:
compiler/dependency_graph.m:
compiler/higher_order.m:
compiler/hlds_out.m:
compiler/mercury_to_mercury.m:
compiler/ml_code_util.m:
compiler/ml_unify_gen.m:
compiler/opt_debug.m:
compiler/proc_label.m:
compiler/prog_rep.m:
compiler/rl_exprn.m:
compiler/rtti_out.m:
compiler/rtti_to_mlds.m:
compiler/saved_vars.m:
compiler/switch_util.m:
compiler/unify_gen.m:
Minor changes to conform to the change from deep_profiling_proc_static
to deep_profiling_proc_layout, to the change in the structure of
rtti_proc_labels, to the changes in types of layout.m, and/or to the
new goal feature.
deep_profiler/measurements.m:
Reserve space for exception counts.
deep_profiler/html_format.m:
Add a column for exception counts.
deep_profiler/profile.m:
deep_profiler/read_profile.m:
Rename the data structures referring to compiler generated unify,
compare and index predicates to avoid misleading names: they are
not the only compiler generated predicates.
deep_profiler/read_profile.m:
runtime/mercury_deep_profiling.c:
Update the string that identifies deep profiling data files.
This is necessary because the format has changed: it now includes
information about exception port counts.
library/exception.m:
In deep profiling grades, execute the exception port code for every
procedure invocation between a throw and a catch, using the procedure
layout structures now generated by the compiler for every procedure.
Rename the function involved to reflect its new, more general purpose.
Update the definitions of the hand-written proc_static and proc_layout
structures for the procedures implemented via hand-written C code.
Indent C preprocessor directives and foreign_procs according to our
coding standards.
library/profiling_builtin.m:
Change the parameters of the call port code procedures from proc_static
to proc_layout. Reach the proc_static structure from the proc_layout
structure when needed. Include the proc_layout structure in any
messages from assertion failures.
Add some conditionally compiled debugging code.
Give some variables better names.
runtime/mercury_type_info.h:
runtime/mercury_builtin_types.c:
Move the macros required to create the proc_static structures
of unify and compare predicates from mercury_type_info.h
to mercury_builtin_types.c, since the latter is the only file
that needs them.
Use the same macros for creating the proc_static structures
of hand-written unify, compare and compare_reprentation predicates
as for user defined predicates. This required changing their naming
scheme.
runtime/mercury_unify_compare_body.h:
Conform to the new naming scheme.
runtime/mercury_ho_call.c:
Provide the mechanism for mercury_unify_compare_body.h to conform
to the new naming scheme.
Remove the definitions of the proc_static structures for
hand-written unify, compare and compare_reprentation predicates,
since these now have to be defined together with the corresponding
proc_layout structures in mercury_builtin_types.c.
runtime/mercury_builtin_types.[ch]:
Update the definitions of the hand-written proc_static and proc_layout
structures for the procedures implemented via hand-written C code,
and add the required declarations first.
Handle deep profiling of compare_representation as well as unify
and compare predicates on builtin types.
Handle deep profiling of compare_representation on user-defined types,
since this is done entirely in the runtime, not by compiler generated
predicates.
runtime/mercury_builtin_types_proc_layouts.h:
New header file containing the declarations of the proc layout
structures of the unify, compare and index predicates of builtin types.
Logically, these declarations belong in mercury_builtin_types.h,
but putting them there causes problems for the linker; the details
are explained in the file itself.
runtime/Mmakefile:
Add the new header file.
runtime/mercury_minimal_model.[ch]:
Update the definitions of the hand-written proc_static and proc_layout
structures for the procedures implemented via hand-written C code,
and add the required declarations first.
runtime/mercury_grade.h:
Replace the MR_REQUIRE_TRACING grade option with MR_EXEC_TRACING.
Besides being better named, the MR_EXEC_TRACING option implies
MR_STACK_TRACE.
Besides the overall binary compatibility version number, add subsidiary
version numbers for binary compatibility in deep profiling and
debugging grades. These will make it easier to bootstrap changes
(such as this) that affect binary compatibility only in such grades.
runtime/mercury_trace_base.c:
trace/mercury_trace.c:
Conform to the new names of the configuration parameters.
runtime/mercury_hand_compare_body.h:
runtime/mercury_hand_unify_body.h:
runtime/mercury_hand_unify_compare_body.h:
runtime/mercury_ho_call.c:
tools/make_port_code:
Pass proc_layout structures instead of proc_static structures
to deep profiling port routines.
runtime/mercury_conf_param.h:
Make MR_DEEP_PROFILING as well as MR_EXEC_TRACING imply MR_STACK_TRACE,
since deep profiling now needs stack tracing. (MR_STACK_TRACE needs
to be set in this file, because tests in this file depend on knowing
its value, and this file is among the first files included (in this
case indirectly) in mercury_imp.h.)
Document the macros controlling the debugging of deep profiling.
Enable printing of label names when the relevant deep profiling
debugging macro is set.
runtime/mercury_debug.c:
runtime/mercury_deep_rec_depth_actions.h:
runtime/mercury_deep_rec_depth_body.h:
runtime/mercury_exception_catch_body.h:
Get to proc_statics via proc_layouts.
runtime/mercury_deep_call_port_body.c:
runtime/mercury_deep_leave_port_body.c:
Get to proc_statics via proc_layouts.
Allow the debugger to disable deep profiling in Mercury code that is
part of the debugger, not of the user program being executed.
Add some more assertions.
runtime/mercury_engine.[ch]:
Add a new debugging flag that controls at runtime whether we generate
a human readable Deep.debug equivalent to the binary Deep.data files.
(We already had a mechanism for controlling this at compile time,
but this isn't flexible enough.)
runtime/mercury_wrapper.c:
Allow this new debugging flag to be set from MERCURY_OPTIONS.
runtime/mercury_deep_profiling.[ch]:
Respect this new debugging flag.
Update the hand-written proc_static structures representing the runtime
system.
Print out addresses of proc_layout as well as proc_static structures
when assertions fail.
Add a field to the measurement structure for exception port counts,
and write out this field with the other port counts.
Remove procedure id information from proc_static structures,
deep profiling now uses the procedure id in the proc_layout structure.
Add to proc_static structures fields that specify where, if anywhere,
the variables needed by exception.m to executed the exception port code
are in the procedure's stack frame.
Define a global flag that allows the debugger to disable deep
profiling in Mercury code that is part of the debugger, not of the
user program being executed.
Increase type safety by providing two versions of the function
for registering proc_layouts, one for the proc_layout structures
of user-defined predicates and one for unify, compare and index
predicates.
Fix a bug that occurs only if MR_DEEP_PROFILING_EXPLICIT_CALL_COUNTS is
defined (which it usually isn't): the initial call count was wrong.
runtime/mercury_deep_profiling_hand.h:
Fix a bug: the handwritten code saving deep profiling variables was
saving them in slots that didn't belong to the relevant stack frame.
Update to conform to the modified definitions of proc_static structures
and the fact that we now reach them via proc_layout structures.
runtime/mercury_exception_catch_body.h:
runtime/mercury_stacks.h:
Fix the other side of the bug in mercury_deep_profiling_hand.h
by reserving the right number of stack slots in the stack frames
of the various modes of exception__catch. Make it harder to make
the same bug in the future by getting the needed info from the
place in mercury_stacks.h that defines the structure of the relevant
stack frame.
runtime/mercury_proc_id.h:
Rename the procedure id structure fields referring to compiler
generated unify, compare and index predicates: they are not the only
compiler-generated predicates.
runtime/mercury_stack_layout.h:
Change procedure layout structures to allow them to be used for deep
profiling as well as for debugging, as described in the prologue above.
We don't need the capability to support label layout structures with
links to misnamed proc layout structures, and supporting it is
inconvenient, so delete the capability.
runtime/mercury_debug.c:
runtime/mercury_deep_profiling_hand.h:
runtime/mercury_layout_util.c:
runtime/mercury_ml_expand_body.h:
runtime/mercury_stack_trace.c:
runtime/mercury_types.h:
trace/mercury_trace_external.c:
Conform to the new names of the procedure id structure fields.
runtime/mercury_std.h:
Add some more arities for MR_PASTE for use in some of the modified
modules in the runtime.
trace/mercury_trace_internal.c:
Disable deep profiling actions in Mercury code that is part of the
debugger, not of the program being debugged.
scripts/init_grade_options.sh-subr:
scripts/parse_grade_options.sh-subr:
Make changes parallel to the ones in runtime/mercury_grade.h: delete
--stack-trace as an independent option, and make --debug set its
own option, not --require-tracing.
scripts/canonical_grade.sh-subr:
scripts/final_grade_options.sh-subr:
scripts/c2init.in:
scripts/mgnuc.in:
scripts/ml.in:
Conform to the changes in grade options for debugging and for deep
profiling.
tools/bootcheck:
If Mmake.stage.{browser,deep,library,runtime,trace}.params exist,
copy them to become the file Mmake.$dir.params in stage2/$dir
(where dir is derived from the name of the original file in the obvious
way). This allows more flexibility in the creation of the stage2;
for example, it allows some directories (e.g. runtime or library)
to be compiled with more debugging than other directories (e.g.
compiler). This may be required because compiling all directories
with lots of debugging may cause the linker to thrash.
Add an option, --disable-debug-libs, that clobbers the libraries
that should be linked in only in debugging grades.
To conserve disk space, remove Deep.data files created by the bootcheck
by default. Add an option, --keep-deep-data, to preserve these files.
Use a consistent mechanism (test -f) for testing the existence of
all files whose existence is tested.
When recording modification times, record the modification times
of some more files.
tests/hard_coded/Mmakefile:
In deep profiling grades, disable the test cases that we don't now
pass in such grades, and document the reasons for their failure.
Fix the misclassification of the write_binary test case.
Estimated hours taken: 1
Branches: main
scripts/parse_ml_options.in:
scripts/ml.in:
Add an option, --print-map, that allows the user to request the linker
to generate information that can be used to diagnose link problems.
Estimated hours taken: 0.25
Branches: main
scripts/ml.in:
When linking with the MSVCRT we also need to pass /nodefaultlib:libc to
the linker, so that it doesn't also try and link with the standard C
library and have duplicate symbol errors.
Estimated hours taken: 0.5
Branches: main
scripts/mgnuc.in:
When building using MS Visual C runtime, we also need to pass
/MD at compile time (despite it being documented as a linker
flag).
Estimated hours taken: 2
Branches: main
Allow at configure time to build the compiler so that it uses the MS
Visual C runtime by default.
This is needed here at MC to build some components which require
linking against the MS Visual C runtime versus the standard C runtime.
configure.in:
Add the option --with-msvcrt so that the
scripts/mgnuc.in:
If we wish to use the MS Visual C runtime, then we need to
define GC_NOT_DLL when we are not in a parallel grade, as
otherwise the header files for boehm_gc decide the collector
must've been built as a DLL, which isn't true.
scripts/ml.in:
Pass /MD to the linker so that it links against the MS Visual C
runtime, if required.
README.MS-VisualC:
Document the --with-msvcrt option.
Estimated hours taken: 1.5
Branches: main
Simplify use of the Java grade by automatically setting the classpath.
scripts/Mercury.config.in:
scripts/Mercury.config.bootstrap.in:
Set the --java-classpath option in DEFAULT_MC_FLAGS.
Define STD_LIB_NAME, RT_LIB_NAME.
scripts/c2init.in:
Add the above two files to the list of those which use STD_LIB_NAME and
RT_LIB_NAME.
library/Mmakefile:
Use RT_LIB_NAME instead of STD_LIB_NAME.runtime
compiler/modules.m:
Remove the XXX comment that worries about this issue.
README.Java:
Remove instructions relating to setting the classpath manually.
Estimated hours taken: 0.2
Branches: main
Bug fix for Mercury.config.bootstrap.in.
scripts/Mercury.config.bootstrap.in:
Moved a comment that was causing problems.
Estimated hours taken: 0.25
Branches: main
compiler/handle_options.m:
scripts/final_grade_options.sh-subr:
Make `--target il' imply `--high-level-data'.
This is needed to ensure that the `--il' and `--target il'
options select the `il' grade, which uses high-level data,
rather than the `ilc' grade, which uses low-level data and
which is no longer documented because it is not useful;
high-level data is better for both efficiency and
interoperability and for IL there are no advantages to
low-level data.
Estimated hours taken: 8
Branches: main
Have the configure script decide whether to install the Java grade.
configure.in:
Add Java to the list of library grades to install by default,
if the Java SDK is installed.
Add the option to disable the Java grade.
aclocal.m4:
Detect whether the Java SDK is installed. Currently this is done
by checking for javac, java and jar, then testing whether a program
can be compiled which confirms the version is recent enough.
scripts/Mmake.vars.in:
Add JAVAC, JAVA_INTERPRETER and JAR to the generated make variables.
Add JAR_CREATE_FLAGS make variable, set as "cf"
scripts/Mercury.config.in:
scripts/Mercury.config.bootstrap.in:
Define environmental variables MERCURY_JAVA_COMPILER and
MERCURY_JAVA_INTERPRETER.
Have the configure script set the default java compiler and interpreter
as part of DEFAULT_MC_FLAGS.
library/Mmakefile:
Use "$(JAR) $(JAR_CREATE_FLAGS)" instead of "jar cf"
Estimated hours taken: 3
Branches: main
Clean up the handling of the `--java' and `--gc' compilation options.
README.Java:
Document the `--java' and `--target java' options,
and use `--java' rather than `--grade java' in the examples.
compiler/handle_options.m:
Fix a bug where `mmc --java --output-grade-string'
was printing "java.gc" instead of "java". It was calling
set_gc_method to set the gc_method field in the globals structure,
but it was not setting the corresponding string option in the
options table, and compute_grade was looking at the string option.
The fix was to also set the string option.
scripts/parse_grade_options.sh-subr:
Handle the `--java' and `--java-only' options.
scripts/final_grade_options.sh-subr:
For the IL and Java back-ends, set the gc_method to automatic.
For the Java back-end, set highlevel_data to true.
compiler/globals.m:
Fix an XXX: add a new alternative to the gc_method type,
"automatic", to distinguish lack of GC ("none") from the
automatic GC done by Java or the .NET CLR.
compiler/options.m:
doc/user_guide.texi:
Document the new `--gc automatic' alternative for the `--gc' option.
Delete the documentation of the deprecated `--gc conservative'
option (which has been replaced with `--gc boehm').
compiler/compile_target_code.m:
compiler/handle_options.m:
scripts/parse_grade_options.sh-subr:
scripts/final_grade_options.sh-subr:
Handle the new `--gc automatic' option..
Estimated hours taken: 3
Branches: main
New rules for installing the Mercury standard library in grade Java.
library/Mmakefile:
Added new target 'jars' which creates a jar file for the library
classes and a jar file for the runtime classes.
Modified target 'install_library' so that it adds these jar files to
a new directory in the install path.
To use these jar files, the CLASSPATH environment variable must be set
to:
<library_path>/mer_std.jar:<library_path>/mer_std.runtime.jar:.
scripts/Mmake.vars.in:
Added variable INSTALL_JAVA_LIBRARY_DIR to define where the above jar
files will be installed.
Estimated hours taken: 0.25
Branches: main
scripts/mtags:
Apply a review comment from Peter Moulder: use "foo()" rather than
"&foo", since the latter disables prototype-checking.
Estimated hours taken: 1
Branches: main
scripts/mtags:
Change the way that mtags gets invoked so that it passes `-w'
to perl, to enable warnings, and fix the resulting warnings:
- use "&foo" instead of the deprecated "do foo" notation for
calling subroutines
- use uppercase for file handle variables, instead of lowercase
(which could overlap with future keywords)
- s/shift(ARGV)/shift(@ARGV)/g
- add underscore prefixes to singleton variables
($_cmd, $_running_under_some_shell).
- use 'exec perl ... ${1+"$@"}' instead of "exec perl $*".
This is necessary for correct handling of command-line arguments
that contain spaces.
Estimated hours taken: 0.25
Branches: main
scripts/ml.in:
Fix a bug in Zoltan's previous change to add the mdbcomp library:
mdbcomp was missing from the list of libraries to link with when
when tracing and static linking are both enabled.
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.
Estimated hours taken: 400
Branches: main
Implement the infrastructure for term size profiling. This means adding two
new grade components, tsw and tsc, and implementing them in the LLDS code
generator. In grades including tsw (term size words), each term is augmented
with an extra word giving the number of heap words it contains; in grades
including tsc (term size cells), each term is augmented with an extra word
giving the number of heap cells it contains. The extra word is at the start,
at offset -1, to leave almost all of the machinery for accessing the heap
unchanged.
For now, the only way to access term sizes is with a new mdb command,
"term_size <varspec>". Later, we will use term sizes in conjunction with
deep profiling to do experimental complexity analysis, but that requires
a lot more research. This diff is a necessary first step.
The implementation of term size profiling consists of three main parts:
- a source-to-source transform that computes the size of each heap cell
when it is constructed (and increments it in the rare cases when a free
argument of an existing heap cell is bound),
- a relatively small change to the code generator that reserves the extra
slot in new heap cells, and
- extensions to the facilities for creating cells from C code to record
the extra information we now need.
The diff overhauls polymorphism.m to make the source-to-source transform
possible. This overhaul includes separating type_ctor_infos and type_infos
as strictly as possible from each other, converting type_ctor_infos into
type_infos only as necessary. It also includes separating type_ctor_infos,
type_infos, base_typeclass_infos and typeclass_infos (as well as voids,
for clarity) from plain user-defined type constructors in type categorizations.
This change needs this separation because values of those four types do not
have size slots, but they ought to be treated specially in other situations
as well (e.g. by tabling).
The diff adds a new mdb command, term_size. It also replaces the proc_body
mdb command with new ways of using the existing print and browse commands
("print proc_body" and "browse proc_body") in order to make looking at
procedure bodies more controllable. This was useful in debugging the effect
of term size profiling on some test case outputs. It is not strictly tied
to term size profiling, but turns out to be difficult to disentangle.
compiler/size_prof.m:
A new module implementing the source-to-source transform.
compiler/notes/compiler_design.html:
Mention the new module.
compiler/transform_hlds.m:
Include size_prof as a submodule of transform_hlds.
compiler/mercury_compile.m:
If term size profiling is enabled, invoke its source-to-source
transform.
compiler/hlds_goal.m:
Extend construction unifications with an optional slot for recording
the size of the term if the size is a constant, or the identity of the
variable holding the size, if the size is not constant. This is
needed by the source-to-source transform.
compiler/quantification.m:
Treat the variable reference that may be in this slot as a nonlocal
variable of construction unifications, since the code generator needs
this.
compiler/compile_target_code.m:
Handle the new grade components.
compiler/options.m:
Implement the options that control term size profiling.
doc/user_guide.texi:
Document the options and grade components that control term size
profiling, and the term_size mdb command. The documentation is
commented out for now.
Modify the wording of the 'u' HLDS dump flag to include other details
of unifications (e.g. term size info) rather than just unification
categories.
Document the new alternatives of the print and browse commands. Since
they are for developers only, the documentation is commented out.
compiler/handle_options.m:
Handle the implications of term size profiling grades.
Add a -D flag value to print HLDS components relevant to HLDS
transformations.
compiler/modules.m:
Import the new builtin library module that implements the operations
needed by term size profiling automatically in term size profiling
grades.
Switch the predicate involved to use state var syntax.
compiler/prog_util.m:
Add predicates and functions that return the sym_names of the modules
needed by term size profiling.
compiler/code_info.m:
compiler/unify_gen.m:
compiler/var_locn.m:
Reserve an extra slot in heap cells and fill them in in unifications
marked by size_prof.
compiler/builtin_ops.m:
Add term_size_prof_builtin.term_size_plus as a builtin, with the same
implementation as int.+.
compiler/make_hlds.m:
Disable warnings about clauses for builtins while the change to
builtin_ops is bootstrapped.
compiler/polymorphism.m:
Export predicates that generate goals to create type_infos and
type_ctor_infos to add_to_construct.m. Rewrite their documentation
to make it more detailed.
Make orders of arguments amenable to the use of state variable syntax.
Consolidate knowledge of which type categories have builtin unify and
compare predicates in one place.
Add code to leave the types of type_ctor_infos alone: instead of
changing their types to type_info when used as arguments of other
type_infos, create a new variable of type type_info instead, and
use an unsafe_cast. This would make the HLDS closer to being type
correct, but this new code is currently commented out, for two
reasons. First, common.m is currently not smart enough to figure out
that if X and Y are equal, then similar unsafe_casts of X and Y
are also equal, and this causes the compiler do not detect some
duplicate calls it used to detect. Second, the code generators
are also not smart enough to know that if Z is an unsafe_cast of X,
then X and Z do not need separate stack slots, but can use the same
slot.
compiler/type_util.m:
Add utility predicates for returning the types of type_infos and
type_ctor_infos, for use by new code in polymorphism.m.
Move some utility predicates here from other modules, since they
are now used by more than one module.
Rename the type `builtin_type' as `type_category', to better reflect
what it does. Extend it to put the type_info, type_ctor_info,
typeclass_info, base_typeclass_info and void types into categories
of their own: treating these types as if they were a user-defined
type (which is how they used to be classified) is not always correct.
Rename the functor polymorphic_type to variable_type, since types
such as list(T) are polymorphic, but they fall into the user-defined
category. Rename user_type as user_ctor_type, since list(int) is not
wholly user-defined but falls into this category. Rename pred_type
as higher_order_type, since it also encompasses functions.
Replace code that used to check for a few of the alternatives
of this type with code that does a full switch on the type,
to ensure that they are updated if the type definition ever
changes again.
compiler/pseudo_type_info.m:
Delete a predicate whose updated implementation is now in type_util.m.
compiler/mlds_to_c.m:
compiler/mlds_to_gcc.m:
compiler/mlds_to_il.m:
compiler/mlds_to_java.m:
Still treat type_infos, type_ctor_infos, typeclass_infos and
base_typeclass_infos as user-defined types, but prepare for when
they won't be.
compiler/hlds_pred.m:
Require interface typeinfo liveness when term size profiling is
enabled.
Add term_size_profiling_builtin.increase_size as a
no_type_info_builtin.
compiler/hlds_out.m:
Print the size annotations on unifications if HLDS dump flags call
for unification details. (The flag test is in the caller of the
modified predicate.)
compiler/llds.m:
Extend incr_hp instructions and data_addr_consts with optional fields
that allow the code generator to refer to N words past the start of
a static or dynamic cell. Term size profiling uses this with N=1.
compiler/llds_out.m:
When allocating memory on the heap, use the macro variants that
specify an optional offset, and specify the offset when required.
compiler/bytecode_gen.m:
compiler/dense_switch.m:
compiler/dupelim.m:
compiler/exprn_aux.m:
compiler/goal_form.m:
compiler/goal_util.m:
compiler/higher_order.m:
compiler/inst_match.m:
compiler/intermod.m:
compiler/jumpopt.m:
compiler/lambda.m:
compiler/livemap.m:
compiler/ll_pseudo_type_info.m:
compiler/lookup_switch.m:
compiler/magic_util.m:
compiler/middle_rec.m:
compiler/ml_code_util.m:
compiler/ml_switch_gen.m:
compiler/ml_unify_gen.m:
compiler/mlds.m:
compiler/mlds_to_c.m:
compiler/mlds_to_gcc.m:
compiler/mlds_to_il.m:
compiler/mlds_to_java.m:
compiler/modecheck_unify.m:
compiler/opt_debug.m:
compiler/opt_util.m:
compiler/par_conj_gen.m:
compiler/post_typecheck.m:
compiler/reassign.m:
compiler/rl.m:
compiler/rl_key.m:
compiler/special_pred.m:
compiler/stack_layout.m:
compiler/static_term.m:
compiler/string_switch.m:
compiler/switch_gen.m:
compiler/switch_util.m:
compiler/table_gen.m:
compiler/term_util.m:
compiler/type_ctor_info.m:
compiler/unused_args.m:
compiler/use_local_vars.m:
Minor updates to conform to the changes above.
library/term_size_prof_builtin.m:
New module containing helper predicates for term size profiling.
size_prof.m generates call to these predicates.
library/library.m:
Include the new module in the library.
doc/Mmakefile:
Do not include the term_size_prof_builtin module in the library
documentation.
library/array.m:
library/benchmarking.m:
library/construct.m:
library/deconstruct.m:
library/io.m:
library/sparse_bitset.m:
library/store.m:
library/string.m:
Replace all uses of MR_incr_hp with MR_offset_incr_hp, to ensure
that we haven't overlooked any places where offsets may need to be
specified.
Fix formatting of foreign_procs.
Use new macros defined by the runtime system when constructing
terms (which all happen to be lists) in C code. These new macros
specify the types of the cell arguments, allowing the implementation
to figure out the size of the new cell based on the sizes of its
fields.
library/private_builtin.m:
Define some constant type_info structures for use by these macros.
They cannot be defined in the runtime, since they refer to types
defined in the library (list.list and std_util.univ).
util/mkinit.c:
Make the addresses of these type_info structures available to the
runtime.
runtime/mercury_init.h:
Declare these type_info structures, for use in mkinit-generated
*_init.c files.
runtime/mercury_wrapper.[ch]:
Declare and define the variables that hold these addresses, for use
in the new macros for constructing typed lists.
Since term size profiling can refer to a memory cell by a pointer
that is offset by one word, register the extra offsets with the Boehm
collector if is being used.
Document the incompatibility of MR_HIGHTAGS and the Boehm collector.
runtime/mercury_tags.h:
Define new macros for constructing typed lists.
Provide macros for preserving the old interface presented by this file
to the extent possible. Uses of the old MR_list_cons macro will
continue to work in grades without term size profiling. In term
size profiling grades, their use will get a C compiler error.
Fix a bug caused by a missing backslash.
runtime/mercury_heap.h:
Change the basic macros for allocating new heap cells to take
an optional offset argument. If this is nonzero, the macros
increment the returned address by the given number of words.
Term size profiling specifies offset=1, reserving the extra
word at the start (which is ignored by all components of the
system except term size profiling) for holding the size of the term.
Provide macros for preserving the old interface presented by this file
to the extent possible. Since the old MR_create[123] and MR_list_cons
macros did not specify type information, they had to be changed
to take additional arguments. This affects only hand-written C code.
Call new diagnostic macros that can help debug heap allocations.
Document why the macros in this files must expand to expressions
instead of statements, evn though the latter would be preferable
(e.g. by allowing them to declare and use local variables without
depending on gcc extensions).
runtime/mercury_debug.[ch]:
Add diagnostic macros to debug heap allocations, and the functions
behind them if MR_DEBUG_HEAP_ALLOC is defined.
Update the debugging routines for hand-allocated cells to print the
values of the term size slot as well as the other slots in the relevant
grades.
runtime/mercury_string.h:
Provide some needed variants of the macro for copying strings.
runtime/mercury_deconstruct_macros.h:
runtime/mercury_type_info.c:
Supply type information when constructing terms.
runtime/mercury_deep_copy_body.h:
Preserve the term size slot when copying terms.
runtime/mercury_deep_copy_body.h:
runtime/mercury_ho_call.c:
runtime/mercury_ml_expand_body.h:
Use MR_offset_incr_hp instead of MR_incr_hp to ensure that all places
that allocate cells also allocate space for the term size slot if
necessary.
Reduce code duplication by using a now standard macro for copying
strings.
runtime/mercury_grade.h:
Handle the two new grade components.
runtime/mercury_conf_param.h:
Document the C macros used to control the two new grade components,
as well as MR_DEBUG_HEAP_ALLOC.
Detect incompatibilities between high level code and profiling.
runtime/mercury_term_size.[ch]:
A new module to house a function to find and return term sizes
stored in heap cells.
runtime/mercury_proc_id.h:
runtime/mercury_univ.h:
New header files. mercury_proc_id.h contains the (unchanged)
definition of MR_Proc_Id, while mercury_univ.h contains the
definitions of the macros for manipulating univs that used to be
in mercury_type_info.h, updated to use the new macros for allocating
memory.
In the absence of these header files, the following circularity
would ensue:
mercury_deep_profiling.h includes mercury_stack_layout.h
- needs definition of MR_Proc_Id
mercury_stack_layout.h needs mercury_type_info.h
- needs definition of MR_PseudoTypeInfo
mercury_type_info.h needs mercury_heap.h
- needs heap allocation macros for MR_new_univ_on_hp
mercury_heap.h includes mercury_deep_profiling.h
- needs MR_current_call_site_dynamic for recording allocations
Breaking the circular dependency in two places, not just one, is to
minimize similar problems in the future.
runtime/mercury_stack_layout.h:
Delete the definition of MR_Proc_Id, which is now in mercury_proc_id.h.
runtime/mercury_type_info.h:
Delete the macros for manipulating univs, which are now in
mercury_univ.h.
runtime/Mmakefile:
Mention the new files.
runtime/mercury_imp.h:
runtime/mercury.h:
runtime/mercury_construct.c:
runtime/mercury_deep_profiling.h:
Include the new files at appropriate points.
runtime/mercury.c:
Change the names of the functions that create heap cells for
hand-written code, since the interface to hand-written code has
changed to include type information.
runtime/mercury_tabling.h:
Delete some unused macros.
runtime/mercury_trace_base.c:
runtime/mercury_type_info.c:
Use the new macros supplying type information when constructing lists.
scripts/canonical_grade_options.sh-subr:
Fix an undefined sh variable bug that could cause error messages
to come out without identifying the program they were from.
scripts/init_grade_options.sh-subr:
scripts/parse_grade_options.sh-subr:
scripts/canonical_grade_options.sh-subr:
scripts/mgnuc.in:
Handle the new grade components and the options controlling them.
trace/mercury_trace_internal.c:
Implement the mdb command "term_size <varspec>", which is like
"print <varspec>", but prints the size of a term instead of its value.
In non-term-size-profiling grades, it prints an error message.
Replace the "proc_body" command with optional arguments to the "print"
and "browse" commands.
doc/user_guide.tex:
Add documentation of the term_size mdb command. Since the command is
for implementors only, and works only in grades that are not yet ready
for public consumption, the documentation is commented out.
Add documentation of the new arguments of the print and browse mdb
commands. Since they are for implementors only, the documentation
is commented out.
trace/mercury_trace_vars.[ch]:
Add the functions needed to implement the term_size command, and
factor out the code common to the "size" and "print"/"browse" commands.
Decide whether to print the name of a variable before invoking the
supplied print or browse predicate on it based on a flag design for
this purpose, instead of overloading the meaning of the output FILE *
variable. This arrangement is much clearer.
trace/mercury_trace_browse.c:
trace/mercury_trace_external.c:
trace/mercury_trace_help.c:
Supply type information when constructing terms.
browser/program_representation.m:
Since the new library module term_size_prof_builtin never generates
any events, mark it as such, so that the declarative debugger doesn't
expect it to generate any.
Do the same for the deep profiling builtin module.
tests/debugger/term_size_words.{m,inp,exp}:
tests/debugger/term_size_cells.{m,inp,exp}:
Two new test cases, each testing one of the new grades.
tests/debugger/Mmakefile:
Enable the two new test cases in their grades.
Disable the tests sensitive to stack frame sizes in term size profiling
grades.
tests/debugger/completion.exp:
Add the new "term_size" mdb command to the list of command completions,
and delete "proc_body".
tests/debugger/declarative/dependency.{inp,exp}:
Use "print proc_body" instead of "proc_body".
tests/hard_coded/nondet_c.m:
tests/hard_coded/pragma_inline.m:
Use MR_offset_incr_hp instead of MR_incr_hp to ensure that all places
that allocate cells also allocate space for the term size slot if
necessary.
tests/valid/Mmakefile:
Disable the IL tests in term size profiling grades, since the term size
profiling primitives haven't been (and probably won't be) implemented
for the MLDS backends, and handle_options causes a compiler abort
for grades that combine term size profiling and any one of IL, Java
and high level C.
Estimated hours taken: 0.2
Branches: main
Fix bugs in the binary distribution.
configure.in:
Move the code to work out the arguments to pass
when reconfiguring before macro calls which clobber
the argument list.
scripts/mercury_config.in:
Don't abort because tools/lmc.in and tools/dotime.in
when configuring the binary distribution.
Estimated hours taken: 50
Branches: main
Remove Unix dependencies in the compiler.
Avoid calling passes_aux.invoke_shell_command, which
requires the presence of a Unix shell.
The implementation of fact tables still has dependencies
on Unix utilities (e.g. sort).
aclocal.m4:
Don't pass Unix style paths to MSVC.
configure.in:
Use `cygpath -m' rather than `cygpath -w'.
`cygpath -m' uses '/' as the directory separator,
so it doesn't cause quoting problems in shell
scripts.
Apply $CYGPATH to $PREFIX, $LIBDIR, $CONFIG_PREFIX
and $CONFIG_LIBDIR.
Don't pass `-lm' when linking with MSVC.
configure.in:
compiler/options.m:
scripts/Mercury.config.in:
Add extra configuration options to deal with differences
between linking with gcc and MSVC:
--linker-opt-separator
--linker-link-lib-flag
--linker-link-lib-suffix
--shlib-linker-link-lib-flag
--shlib-linker-link-lib-suffix
--linker-path-flag
NEWS:
doc/user_guide.texi:
compiler/options.m:
compiler/compile_target_code.m:
compiler/make.program_target.m:
Instead of substituting in an arbitrary shell script when
processing `--pre-link-command' and `--extra-init-command',
require that these options specify a command which will
be passed the name of the source file containing the main
module as the first argument, with the source files containing
the remaining modules following. This is simpler and avoids
dependencies on a shell.
Fix quote_arg to handle Windows paths better.
compiler/handle_options.m:
Don't attempt to use symlinks if they're not available.
compiler/compile_target_code.m:
Be more careful about quoting.
Don't call invoke_shell_command where invoke_system_command
would do.
Allow linking using MSVC.
compiler/modules.m:
Remove make_directory, which is now implemented by dir.m.
Use io.make_symlink rather than shell scripts.
Implement mercury_update_interface in Mercury.
compiler/llds_out.m:
compiler/make.program_target.m:
Use dir.make_directory, not modules.make_directory,
which has been removed.
compiler/make.module_target.m:
Invoke mercury_compiler directly, not through the
mmc script to avoid shell dependencies.
If we can't fork() child `mmc --make' processes,
pass the arguments to the child process using a
file to avoid overflowing system limits on Windows.
compiler/mercury_compile.m:
compiler/options_file.m:
Read argument files.
Handle backslash-newline in options files correctly.
compiler/passes_aux.m:
invoke_system_command shouldn't set the exit status --
the caller may be able to try something else.
compiler/process_util.m:
Export can_fork for use by make.module_target.m.
Remove hacks to work around bugs in the implementation
of zero-arity foreign procs.
compiler/prog_io.m:
Handle bizarre file names without aborting.
library/Mmakefile:
library/print_extra_inits:
Move code to find extra initialization functions into
print_extra_inits, due to the change to the handling
of the --extra-init-command option described above.
scripts/mmc.in:
Set the MERCURY_COMPILER environment variable if it is
not already set, so that the mercury_compile executable
knows where to find itself.
scripts/mercury.bat.in:
Make this actually work.
tools/bootcheck:
Set ANALYSIS_LIB_NAME.
Apply cygpath (-m not -w) to $root.
Link print_extra_inits into the stage2 and stage3
library directories.
util/mkinit.c:
Handle '\\' in path names.
Estimated hours taken: 0.1
Branches: main
scripts/c2init.in:
Document why this file includes canonical_grade_options.sh-subr
without including the other files (init_grade_options.sh-subr,
parse_grade_options.sh-subr and final_grade_options.sh-subr)
that canonical_grade_options.sh-subr depends on.
Estimated hours taken: 1
Branches: main
Don't create symlinks when installing with a Win32 version
of the compiler. The compiler won't know how to follow the
symlinks.
configure.in:
scripts/Mmake.vars.in:
scripts/Mercury.config.in:
compiler/modules.m:
When using `gcc -mno-cygwin' or MS Visual C++ to
build the compiler, don't create symlinks when installing.
compiler/options.m:
Add an option `--no-use-symlinks'.
Estimated hours taken: 0.25
Branches: main
compiler/modules.m:
Always pass ALL_GRADEFLAGS to mmc, even when building the
interface files. This avoids spurious "debugging is
available only in low-level C grades" errors when
the default grade is hlc.gc.
Zoltan did this for scripts/Mmake.rules but not modules.m.
scripts/Mmake.rules:
Pass ALL_GRADEFLAGS when errorchecking and converting to Mercury.
Estimated hours taken: 0.5
Branches: main
Make it easier to boostrap the addition of new configuration
options.
scripts/Mercury.config.bootstrap.in:
A version of Mercury.config.in that does not contain
any options which are not understood by the installed
compilers. This is used when building the stage1 compiler.
Mercury.config is used to build the stage2 and stage3
compilers, and when running the tests. Mercury.config is
installed by `mmake install'.
Mercury.config.bootstrap.in is currently the same
as Mercury.config.in.
Mmake.workspace:
tools/bootcheck:
tools/binary_step:
tools/lmc.in:
Work out which configuration file to use.
configure.in:
scripts/Mmakefile:
scripts/mercury_config.in:
Handle Mercury.config.bootstrap.
Estimated hours taken: 0.2
Branches: main
scripts/Mercury.config.in:
Remove quotes which caused problems if the configured
C compiler command consisted of multiple words,
e.g. gcc --no-cpp-precomp.
Estimated hours taken: 0.1
Branches: main
Fix bugs in my change to the handling of environment variables.
scripts/mgnuc.in:
Fix a sh syntax error which broke .hl(c) grades.
scripts/mmc.in:
Fix the list of environment variables.
Estimated hours taken: 0.5
Branches: main
Clean up the handling of environment variables.
scripts/Mmake.rules:
scripts/c2init.in:
scripts/mgnuc.in:
scripts/ml.in:
scripts/mmc.in:
scripts/parse_ml_options.sh-subr.in:
scripts/binary_step.in:
Remove support for the environment variables which were
previously used to override the location of the standard
library (MERCURY_ALL_C_INCL_DIRS, MERCURY_ALL_MC_C_INCL_DIRS,
MERCURY_INT_DIR, MERCURY_C_LIB_DIR, MERCURY_MOD_LIB_MODS,
MERCURY_TRACE_LIB_MODS).
scripts/Mercury.config.in:
Fix syntax errors.
Set the DEFAULT_MERCURY_LINKAGE variable here rather
than in the mmc script.
scripts/mmc.in:
Setting DEFAULT_MCFLAGS is no longer required -- mmc
now reads its configuration information from the
Mercury.config file. This also fixes a bug which
caused failures in the `mmc --make' tests in
debugging grades on mundroo -- `mmc --make' wasn't
including /usr/local/lib and /usr/local/include in
the search paths for libraries and headers.
configure.in:
Check that the installed compiler is capable of
reading the Mercury.config file.
Bootstrap tag: bootstrap_20030413_read_config_file.
NEWS:
doc/user_guide.texi:
Document the change.
Estimated hours taken: 0.2
Branches: main
scripts/Mmake.rules:
Pass $(ALL_GRADEFLAGS) to all invocations of the compiler, since
the compiler now has sanity checks on option values that could be
tripped with the default grade that may not be tripped with the actual
desired grade.
library/Mmakefile:
Delete my previous "fix" for this problem, since it is not needed
anymore.
Estimated hours taken: 20
Branches: main
Move the setting of configuration options from mmc.in to
an options file Mercury.config. This has a few advantages:
- reduces the duplication between mmc and mercury.bat
- reduces the chance of running out of environment space
on crappy operating systems (although we probably exceed
the command line length limits on those systems anyway).
- makes it easier to bootstrap changes which add new
configuration options.
Always read the options files, even without `--make',
to avoid inconsistent behaviour.
scripts/Mercury.config.in:
New file containing the configuration code from mmc.in.
configure.in:
Create scripts/Mercury.config.
bindist/Mmakefile:
Make sure Mercury.config.in goes in the binary distribution.
Mmakefile:
bindist/Mmakefile:
Mmake.common.in:
Make sure we get the correct setting of INSTALL_PREFIX
when building the binary distribution.
scripts/Mmakefile:
scripts/mercury_config.in:
bindist/bindist.Mmakefile.in:
Install Mercury.config.
compiler/options.m:
doc/user_guide.texi:
Add documentation for the `--config-file' option, which gives
the name of the configuration file to read.
Add an option `read-config-file-2003-03-01' which will be
used in configure.in to test whether the compiler is up
to date after the configuration code is removed from mmc.in
(after this change is installed everywhere).
Add `--mercury-config-dir' as an abbreviation for
`--mercury-configuration-directory'.
Mmake.workspace:
Use the configuration file in scripts/Mercury.config.
browser/Mmakefile:
compiler/Mmakefile:
scripts/Mmake.vars.in:
Always pass ALL_MCFLAGS to mmc so that mmc will
use the configuration file specified in the options.
compiler/handle_options.m:
Handle the default value of `--config-file'.
compiler/mercury_compile.m:
Read the configuration file.
Always read the options files, even without `--make',
to avoid inconsistent behaviour.
compiler/make.m:
Pass the variable settings from the configuration file
to make__process_args.
The options files have already been read in mercury_compile.m,
so don't read them again here.
compiler/make.util.m:
Add a version of build_with_module_options which doesn't
need a make_info, for use by mercury_compile.m.
compiler/options_file.m:
Export a predicate to read a single options file.
Make the predicates to read options files add to an initial
options_variables map, rather than always creating a new one.
Allow MERCURY_STDLIB_DIR and MERCURY_CONFIG_DIR
to be set in the options file or environment.
scripts/mmc.in:
Set MERCURY_STDLIB_DIR and MERCURY_CONFIG_DIR in
mercury_compile's environment.
Estimated hours taken: 0.25
Branches: main
Fix `mmc --make' test failures in debugging grades on mundroo
(it wasn't finding the readline library).
aclocal.m4:
scripts/mmc.in:
Pass `-L/usr/local/lib' and `--c-include-directory /usr/local/include'
to mmc if those directories exist.
Estimated hours taken: 3
Branches: main
Make sure the Java back-end puts class files in the right place with
`--use-subdirs' and properly cleans up all generated .class files.
mercury/compiler/compile_target_code.m:
mercury/scripts/Mmake.rules:
Tell to Java compiler to put generated .class files in the
`Mercury/classs' directory.
mercury/compiler/modules.m:
Clean up all generated .class files.
Estimated hours taken: 0.1
Branches: main
scripts/Mmake.vars.in:
Don't pass MLFLAGS to `mmc --make' -- it's ignored
now that ml is implemented in the compiler.
Estimated hours taken: 25
Branches: main
Implement the ml and c2init scripts in the compiler to
reduce dependencies on Cygwin.
compiler/compile_target_code.m:
Implement the functionality of ml and c2init, rather than
calling those scripts.
Handle all compiler dependencies using options, rather than
testing for particular compilers here.
compiler/options.m:
NEWS:
doc/user_guide.texi:
Add options which implement functionality which is part
of ml, c2init or mgnuc when using Mmake:
--warn-target-code, --output-link-command,
--output-shared-lib-link-command, --ansi-c,
--no-strip, --no-demangle, --no-main,
--allow-undefined, --use-readline, --runtime-flags,
--extra-inits.
Add options to describe the C compiler and linker, for
use by configure/mmc.
The `--ml-flags' (`--link-flags') option has been removed.
compiler/options_file.m:
Remove the MLFLAGS variable.
compiler/handle_options.m:
`--target-debug' implies `--no-strip'.
Add the path to the GC libraries to the library search paths.
compiler/mercury_compile.m:
Handle --output-link-command and --output-shared-lib-link-command.
compiler/passes_aux.m:
Add a variant of invoke_shell_command which takes a second
command to process the first command's output. This is used
by compile_target_code.m to invoke the demangler.
configure.in:
scripts/mmc.in:
Handle extra default options.
scripts/c2init.in:
scripts/ml.in:
Document that the code here is duplicated in
compiler/compile_target_code.m.
Mmake.workspace:
browser/Mmakefile:
compiler/Mercury.options:
compiler/Mmakefile:
library/Mmakefile:
Pass `-R' options pointing to the installation directories
to mmc, as we already do for ml.
Estimated hours taken: 0.5
Branches: main
If $(EXT_FOR_EXE) is not empty, add a phony target
`main_module' which depends on `main_module'$(EXT_FOR_EXE)
With this change, the command used to build an executable
is consistent across platforms.
compiler/make.m:
Assume that a target on the command line which doesn't match
any other file type is an executable, even if $(EXT_FOR_EXE)
is not empty.
compiler/modules.m:
Add the rule.
scripts/Mmake.vars.in:
Add the name of each of the $(MERCURY_MAIN_MODULES) to
the list of targets which should be made by `mmc --make'
if mmake was invoked wih `--use-mmc-make'.
Estimated hours taken: 20
Branches: main
Allow reconfiguration of existing installations, for example
to use a different C compiler. The reconfiguration works
by making a new copy of the scripts and mercury_conf.h,
and storing them in a partial installation directory tree
which uses the libraries and executables from the existing
installation.
Use this method to configure binary distributions, rather
than using a cut down version of the configuration script,
to avoid code duplication and to handle the case where the
C compiler in use on the installation machine is different
than that used to build the binary distribution.
This is more robust than the previous method of using a different
C compiler, which was to set the MERCURY_C_COMPILER variable and
hope the different C compilers were compatible enough.
Mmakefile:
runtime/Mmakefile:
scripts/Mmakefile:
Modify the `install' targets to store files needed to create
a new configuration in $INSTALL_LIBDIR/reconf.
runtime/Mmakefile:
Install mercury_conf.h in $INSTALL_LIBDIR/conf, rather than
$INSTALL_LIBDIR/inc, so that it can be overridden by a
different configuration.
scripts/mercury_config.in:
Create a new configuration, by creating part of a Mercury
source tree from the files stored in $INSTALL_LIBDIR/reconf,
running configure, then copying the files into a partial
installation tree.
scripts/Mmake.vars.in:
Define ENABLE_DEEP_PROFILER, for use by bindist/bindist.Makefile.
Define variables INSTALL_CONF_DIR (contains the files describing
the configuration) and INSTALL_RECONF_DIR (contains files needed
to reconfigure an installation).
configure.in:
Add an option `--enable-reconfigure', for use by
mercury_config.in.
Don't look for runtime/mercury_wrapper.c when checking
for the sources -- it isn't present when reconfiguring.
Look for scripts/mmc.in instead.
Look for the runtime headers in the installation hierarchy
rather than the `runtime/' and `trace/' directories when
reconfiguring.
Output the help message for the `configure' script to
`configure.help'. This is included in the help message
for `mercury_config'.
Add new configuration variables CONFIG_PREFIX and CONFIG_LIBDIR,
which are like PREFIX and LIBDIR except that they point
to the configuration files, not the library files.
In the normal case PREFIX and CONFIG_PREFIX will be the same.
bindist/bindist.INSTALL.in:
bindist/bindist.Makefile.in:
Use mercury_config to configure binary distributions.
bindist/Mmakefile:
bindist/bindist.configure.in:
bindist/bindist.build_vars.in:
Remove bindist.configure.in and bindist.build_vars.in.
compiler/options.m:
scripts/parse_ml_options.sh-subr.in:
scripts/mgnuc.in:
doc/user_guide.texi:
Add an option `--mercury-config-dir', and an environment
variable MERCURY_CONFIG_DIR, which tell the compiler and
scripts where to find the configuration files for the
installation.
MERCURY_CONFIG_DIR is not documented because it should
only be used by the scripts.
compiler/compile_target_code.m:
Pass `--mercury-config-dir' to the scripts.
compiler/handle_options.m:
Add `--c-include-directory $MERCURY_CONFIG_DIR/conf'.
library/getopt.m:
Handle `maybe_string_special' options.
doc/user_guide.texi:
Update the "Using a different C compiler" chapter.
NEWS:
Document the changes.
Estimated hours taken: 20
Branches: main
Make it easier to use shared libraries on x86 with
`mmc --make'.
There is now a third kind of object file, `.lpic_o'.
These files are compiled with `--pic-reg' but not with
CFLAGS_FOR_PIC, so they can be linked with shared Mercury
libraries.
On x86, executables which are linked with shared Mercury
libraries now depend on $(main_module.lpic_os), not
$(main_module.os).
This doesn't work with Mmake because ml doesn't know
which libraries are Mercury libraries, so it can't
link with the static versions of those libraries if
MERCURY_LINKAGE is set to "static".
configure.in:
bindist/bindist.configure.in:
bindist/bindist.build_vars.in:
Work out whether `.lpic_o' files are needed.
compiler/modules.m:
Add `.lpic_o' to the list of grade or architecture
dependent files.
NEWS:
README.Linux:
compiler/options.m:
doc/user_guide.texi:
Document MERCURY_LINKAGE, LINKAGE, --linkage,
--mercury-linkage and -R.
compiler/options_file.m:
compiler/make.program_target.m:
Handle LINKAGE and MERCURY_LINKAGE variables.
Allow LIBGRADES, LINKAGE and MERCURY_LINKAGE to be target-specific.
scripts/mmc.in:
Set up the default linkage using the MERCURY_LINKAGE
variable.
compiler/compile_target_code.m:
Build `.lpic_o' files.
Work out which type of object files to link with.
When linking statically with Mercury libraries,
find the absolute pathname for the `.a' file
for each Mercury library, and pass that to ml,
rather than just using `-lname'.
Pass `-R' options to ml for each `-R' option to mmc.
compiler/make.module_target.m:
compiler/make.program_target.m:
compiler/mercury_compile.m:
Specify which type of object files to build.
compiler/make.program_target.m:
compiler/make.module_target.m:
Make sure all generated object files are cleaned up.
compiler/prog_io.m:
Add a better message for files which can't be found.
compiler/make.util.m:
Add `.lpic_o' to the list of extensions.
compiler/Mmakefile:
profiler/Mmakefile:
deep_profiler/Mmakefile:
Pass `--linkage shared' to mmc (`--shared' is in MLFLAGS).
tests/Mmakefile:
tests/mmc_make/Mmakefile:
tests/mmc_make/Mercury.options:
tests/mmc_make/complex_test.{m,exp}:
tests/mmc_make/hello.{m,exp}:
Test `mmc --make'.
tests/lib/complex*.m:
The complex numbers library from the extras distribution,
for use in the mmc_make tests.
Estimated hours taken: 80
Branches: main
A first implementation of the inter-module analysis framwork.
Currently only unused argument analysis is supported.
The current inter-module analysis scheme using `.trans_opt' files
has some major limitations. The compilation dependencies introduced
by `.trans_opt' files are too complicated for Mmake without major
limitations on which modules can use the contents of which `.trans_opt'
files. Also, the `.trans_opt' file system only computes greatest fixpoints,
which is often too weak to find opportunities for optimization.
A better solution is to provide a library which manually handles
the dependencies introduced by inter-module analysis, and can deal with
the complications introduced by cyclic module dependencies.
TODO:
- support other analyses, e.g. termination, type specialization
- dependency tracking and invalidation after source modifications
- garbage collection of unused versions
- least fixpoint analyses
analysis/Mmakefile:
analysis/mer_analysis.m:
analysis/analysis.m:
analysis/analysis.file.m:
The analysis library.
analysis/README:
Description and design documentation.
Mmake.workspace:
Mmakefile:
compiler/Mmakefile:
tools/bootcheck:
Link the analysis library into mercury_compile.
compiler/hlds_module.m:
Store analysis information in the module_info.
compiler/options.m:
doc/user_guide.texi:
Add an option `--intermodule-analysis'.
compiler/mercury_compile.m:
Call the analysis library to write the gathered
information at the end of a compilation.
compiler/unused_args.m:
Call the analysis library to retrieve information
about imported procedures. This replaces code which
used the `.opt' files.
Change the names created for unused arguments procedures
to include the arguments removed, rather than a sequence
number. I think Zoltan is working on a change to name
mangling, so I haven't updated the demangler.
compiler/prog_util.m:
Generate the new predicate names for unused_args.m.
library/std_util.m:
Add a polymorphic version of unit, which is useful
for binding type variables.
compiler/modules.m:
scripts/Mmake.vars.in:
Clean up files created by the analysis framework
in `mmake realclean'.
util/mdemangle.c:
profiler/demangle.m:
Document the change in the name mangling of procedures with
unused arguments.
configure.in:
Check for state variables and fixes for some typeclass bugs.
tests/warnings/Mmakefile:
tests/warnings/unused_args_analysis.{m,exp}:
Test case.
Estimated hours taken: 2
Branches: main
scripts/canonical_grade.sh-subr:
Fix a bug where passing il or java as the argument to
./canonical_grade --grade <grade> was returning "hl".
Estimated hours taken: 1
Branches: main, release
scripts/gud.el:
Fix the regexp which matches a procedure specification so that
it matches procedures which are contained in sub-modules.