Estimated hours taken: 4
Branches: main
Add MR_ prefixes to the remaining non-prefixed symbols.
This change will require all workspaces to be updated
The compiler will start generating references to MR_TRUE,
MR_bool, etc., which are not defined in the old runtime
header files.
runtime/mercury_std.h:
Add MR_ prefixes to bool, TRUE, FALSE, max, min,
streq, strdiff, strtest, strntest, strneq, strndiff,
strntest, NO_RETURN.
Delete a commented out definition of `reg'.
runtime/mercury_tags.h:
Add an MR_ prefix to TAGBITS.
configure.in:
runtime/mercury_goto.h:
runtime/machdeps/i386_regs.h/mercury_goto.h:
Add an MR_ prefix to PIC.
runtime/mercury_conf_param.h:
Allow non-prefixed PIC and HIGHTAGS to be defined on
the command line.
runtime/mercury_bootstrap.h:
Add backwards compatibility definitions.
RESERVED_MACRO_NAMES:
Remove the renamed macros.
compiler/export.m:
compiler/ml_code_gen.m:
Use MR_bool rather than MR_Bool (MR_Bool is
meant to be for references to the Mercury type
bool__bool).
runtime/mercury_types.h:
Add a comment the MR_Bool is for references to
bool__bool.
*/*.c:
*/*.h:
*/*.m:
Add MR_ prefixes.
Estimated hours taken: 6
Branches: main
Add a capability for measuring statistics about the stack frame usage
of a program.
configure.in:
Find out the symbolic names of the max values for the 16 and 32 bit
integer types.
runtime/mercury_conf.h.in:
Include MR_{UINT,INT}_LEAST{16,32}_MAX among the macros whose values
are determined by autoconfiguration.
runtime/mercury_conf_param.h:
Document MR_STACK_FRAME_STATS as a macro whose definition causes the
program to collect statistics on stack frame sizes.
Fix an obsolete reference: PARALLEL was renamed MR_THREAD_SAFE a long
time ago.
Document the incompatibility between MR_THREAD_SAFE and the statistics
collection flags.
runtime/mercury_stacks.h:
If MR_STACK_FRAME_STATS is defined, then record statistics every time
we create a stack frame.
runtime/mercury_stacks.c:
Define the global variables and functions needed for stack frame
statistics.
runtime/mercury_heap_profile.h:
runtime/mercury_dword.h:
Move the macros for managing 64-bit counters from
mercury_heap_profile.h to a new header file, mercury_dword.h,
since mercury_stacks.h now needs such counters too.
Rewrite the macros to make fewer assumptions, using MR_int_least64_t
and MR_int_least32_t instead of "long long" and "int".
Add expression-like forms of some of the macros for use in
mercury_stacks.h.
Rename the type MR_dword as MR_Dword.
runtime/mercury_heap_profile.c:
#include the new header file.
runtime/mercury_prof.c:
Conform to the change from MR_dword to MR_Dword.
runtime/Mmakefile:
Add the new header file to the list of header files.
runtime/mercury_wrapper.c:
If MR_STACK_FRAME_STATS is defined, initialize the stack frame stats
before execution starts and write out the statistics when execution
ends.
tools/speedtest:
Add an option that when set, causes the script to report stack frame
stats for each variant being tested.
Estimated hours taken: 4
Add MR_ prefixes to the types used when generating C code.
This means types such as Word, String, Bool, Float become MR_Word,
MR_String, MR_Bool, MR_Float. Also define MR_Box for both the LLDS and
MLDS backends so we can use it uniformly.
This is very important in environments where String or Bool have already
been used as system types (for example, managed C++). And besides, we
should do it anyway as part of the grand namespace cleanup.
I have fixed all of the uses of the non-prefixed types in the runtime
and trace directories. I haven't done it for the library and compiler
directories yet (no promises that I will do it in future either). But
if you see a non-prefixed type in code from now on, please consider it a
bug and fix it.
mercury_bootstrap.h contains #defines to map the non-prefixed types into
the prefixed ones. Like many of the other namespace cleaning backwards
compatibility macros, this can be turned off with
MR_NO_BACKWARDS_COMPAT.
This shouldn't break any code, but this kind of change affects so many
things that of course there could be problems lurking in there somewhere.
If you start getting errors from the C compiler after this change is
installed, you will want to make sure you at least have the runtime
system updated so that you are getting the backwards compatibility
definitions in mercury_bootstrap.h. Then if you continue to have
problems you can bug me about it.
compiler/export.m:
compiler/llds_out.m:
compiler/mlds_to_c.m:
Use MR_Word, MR_Float, MR_Bool, etc when generating C.
doc/reference_manual.texi:
Update the reference manual to talk about MR_Word, MR_String,
MR_Char, etc.
runtime/mercury_bootstrap.h:
Add bootstrapping typedefs.
runtime/*:
trace/*:
Change Word, Float, Bool, Code, String, etc to
MR_Word, MR_Float, MR_Bool, MR_Code, MR_String.
Estimated hours taken: 4
runtime/mercury_heap_profile.c:
When inserting new nodes into the heap profiling table,
allocate a new copy of the procedure name string, rather
than just copying the pointer. This is needed in case
the procedure name string is later deallocated. The
procedure name string will normally be a string literal,
but even then, if it was in a dynamically loaded module
it may still be deallocated, using dlclose().
Estimated hours taken: 40 (+ unknown time by Zoltan)
Add support for memory profiling.
(A significant part of this change is actuallly Zoltan's work. Zoltan
did the changes to the compiler and a first go at the changes to the
runtime and library. I rewrote much of Zoltan's changes to the runtime
and library, added support for the new options/grades, added code to
interface with mprof, did the changes to the profiler, and wrote the
documentation.)
[TODO: add test cases.]
NEWS:
Mention support for memory profiling.
runtime/mercury_heap_profile.h:
runtime/mercury_heap_profile.c:
New files. These contain code to record heap profiling information.
runtime/mercury_heap.h:
Add new macros incr_hp_msg(), tag_incr_hp_msg(),
incr_hp_atomic_msg(), and tag_incr_hp_atomic_msg().
These are like the non-`msg' versions, except that if
PROFILE_MEMORY is defined, they also call MR_record_allocation()
from mercury_heap_profile.h to record heap profiling information.
Also, fix up the indentation in lots of places.
runtime/mercury_prof.h:
runtime/mercury_prof.c:
Added code to dump out memory profiling information to files
`Prof.MemoryWords' and `Prof.MemoryCells' (for use by mprof).
Change the format of the `Prof.Counts' file so that the
first line says what it is counting, the units, and a scale
factor. Prof.MemoryWords and Prof.MemoryCells can thus have
exactly the same format as Prof.Counts.
Also cleaned up the interface to mercury_prof.c a bit, and did
various other minor cleanups -- indentation changes, changes to
use MR_ prefixes, additional comments, etc.
runtime/mercury_prof_mem.h:
runtime/mercury_prof_mem.c:
Rename prof_malloc() as MR_prof_malloc().
Rename prof_make() as MR_PROF_NEW() and add MR_PROF_NEW_ARRAY().
runtime/mercury_wrapper.h:
Minor modifications to reflect the new interface to mercury_prof.c.
runtime/mercury_wrapper.c:
runtime/mercury_label.c:
Rename the old `-p' (primary cache size) option as `-C'.
Add a new `-p' option to disable profiling.
runtime/Mmakefile:
Add mercury_heap_profile.[ch].
Put the list of files in alphabetical order.
Delete some obsolete stuff for supporting `.mod' files.
Mention that libmer_dll.h and libmer_globals.h are
produced by Makefile.DLLs.
runtime/mercury_imp.h:
Mention that libmer_dll.h is produced by Makefile.DLLs.
runtime/mercury_dummy.c:
Change a comment to refer to libmer_dll.h rather than
libmer_globals.h.
compiler/llds.m:
Add a new field to `create' and `incr_hp' instructions
holding the name of the type, for heap profiling.
compiler/unify_gen.m:
Initialize the new field of `create' instructions with
the appropriate type name.
compiler/llds_out.m:
Output incr_hp_msg() / tag_incr_hp_msg() instead of
incr_hp() / tag_incr_hp().
compiler/*.m:
Minor changes to most files in the compiler back-end to
accomodate the new field in `incr_hp' and `create' instructions.
library/io.m:
Add `io__report_full_memory_stats'.
library/benchmarking.m:
Add `report_full_memory_stats'. This uses the information saved
by runtime/mercury_heap_profile.{c,h} to print out a report
of memory usage by procedures and by types.
Also modify `report_stats' to print out some of that information.
compiler/mercury_compile.m:
If `--statistics' is enabled, call io__report_full_memory_stats
at the end of main/2. This will print out full memory statistics,
if the compiler was compiled with memory profiling enabled.
compiler/options.m:
compiler/handle_options.m:
runtime/mercury_grade.h:
scripts/ml.in:
scripts/mgnuc.in:
scripts/init_grade_options.sh-subr:
scripts/parse_grade_options.sh-subr:
Add new option `--memory-profiling' and new grade `.memprof'.
Add `--time-profiling' as a new synonym for `--profiling'.
Also add `--profile-memory' for more fine-grained control:
`--memory-profiling' implies both `--profile-memory' and
`--profile-calls'.
scripts/mprof_merge_runs:
Update to handle the new format of Prof.Counts and to
also merge Prof.MemoryWords and Prof.MemoryCells.
profiler/options.m:
profiler/mercury_profile.m:
Add new options `--profile memory-words' (`-m'),
`--profile memory-cells' (`-M') and `--profile time' (`-t').
Thes options make the profiler select a different count file,
Prof.MemoryWords or Prof.MemoryCells instead of Prof.Counts.
specific to time profiling.
profiler/read.m:
profiler/process_file.m:
profiler/prof_info.m:
profiler/generate_output.m:
Update to handle the new format of the counts file.
When reading the counts file, look at the first line of
the file to determine what is being profiled.
profiler/globals.m:
Add a new global variable `what_to_profile' that records
what is being profiled.
profiler/output.m:
Change the headings to reflect what is being profiled.
doc/user_guide.texi:
Document memory profiling.
Document new options.
doc/user_guide.texi:
compiler/options.m:
Comment out the documentation for `.proftime'/`--profile-time',
since doing time and call profiling seperately doesn't work,
because the code addresses change when you recompile with a
different grade. Ditto for `.profmem'/`--profile-memory'.
Also comment out the documentation for
`.profcalls'/`--profile-calls', since it is redundant --
`.memprof' produces the same information and more.
configure.in:
Build a `.memprof' grade. (Hmm, should we do this only
if `--enable-all-grades' is specified?)
Don't ever build a `.profcalls' grade.