Estimated hours taken: 2
Branches: main
runtime/mercury_prof_mem.h:
runtime/mercury_prof_mem.c:
Align memory allocated with MR_prof_malloc() to
double-word boundaries, rather than word boundaries.
This is needed to avoid bus errors on Solaris,
now that we use `long long' for MR_Dword.
Estimated hours taken: 0.25
runtime/mercury_prof_mem.h:
runtime/mercury_prof_mem.c:
Improve the documentation about the use of -DNO_SIGNALS and
the use of malloc/GC_malloc in the profiling signal handler.
boehm_gc/Makefile:
scripts/mgnuc.in:
Add pointers to the documentation in runtime/mercury_prof_mem.h.
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: 0.25
runtime/mercury_dlist.c:
runtime/mercury_prof_mem.c:
Add `#include "mercury_imp.h"' at the start,
to avoid compilation errors from gcc due to
"global register variable follows a function definition".
Estimated hours taken: 8
Reorganize the routines for allocating and deallocating memory:
runtime/mercury_std.h:
runtime/mercury_misc.c:
runtime/mercury_memory.h:
runtime/mercury_memory.c:
- Put the routines in the proper place.
Previously the declarations and definitions of the memory
allocation/deallocation routines were spread amoungst
all four of these files; I moved the ones in mercury_std.h
and mercury_misc.c so that they are now all defined
in mercury_memory.{h,c}
- Avoid unnecessary duplication
The following routines did exactly the same thing,
modulo bugs(!):
allocate_bytes() and newmem()
deallocate_bytes() and oldmem()
make() and allocate_object()
make_many() and allocate_array()
- Use appropriate names.
I added `MR_' prefixes, and ensured that macros that are not
function-like macros use all uppercase. I also used a more
consistent naming scheme.
Previously the names used were
(1) checked_malloc, checked_realloc
(2a) allocate_bytes, deallocate_bytes, reallocate_bytes,
allocate_object, allocate_array, resize_array
(2b) newmem, oldmem, resizemem,
make, make_many, resize_many
The new names are
(1) MR_malloc, MR_free, MR_realloc,
MR_NEW, MR_NEW_ARRAY, MR_RESIZE_ARRAY
(2) MR_GC_malloc, MR_GC_free, MR_GC_realloc,
MR_GC_NEW, MR_GC_NEW_ARRAY, MR_GC_RESIZE_ARRAY
runtime/*.[ch]:
trace/*.[ch]:
library/array.m:
library/benchmarking.m:
library/io.m:
library/std_util.m:
extras/odbc/odbc.m:
extras/aditi/aditi.m:
Use the new names.
Estimated hours taken: 0.25
runtime/mercury_prof_mem.h:
runtime/mercury_prof_mem.c:
Change MR_prof_malloc() to ensure that the memory that it
allocates will be Word-aligned. This change is needed
as a result of my previous change to mercury_heap_profile.c
which made it allocate strings using MR_prof_malloc().
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.
Estimated hours taken: 1
runtime/*.h:
runtime/*.c:
runtime/mercury_conf.h.in:
Remove old .h files.
Update #includes to refer to mercury_*.h
Update #ifdef MODULE_H to be #ifdef MERCURY_MODULE_H
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.