Estimated hours taken: 48
Use Win32 exceptions to report problems when Win32 structured exceptions
are available.
configure.in:
runtime/mercury_conf.h.in:
No longer define MR_WIN32, just because we are using a Microsoft
compiler, instead we use _WIN32 to detect the presence of the Win32
API.
runtime/mercury_conf_param.h:
Define the following symbolic constants:
MR_WIN32 which is true if the Win32 API is available.
MR_WIN32_GETSYSTEMINFO which is true if GetSystemInfo() is
availabe.
MR_WIN32_VIRTUALALLOC which is true if VirtualAlloc() is
availabe.
MR_MSVC_STRUCTURED_EXCEPTIONS if we can use Microsoft Visual C
structured exceptions.
MR_PROTECTPAGE if can provide mprotect like functionality.
All of the above are assumed true if the Win32 API is available.
MR_CHECK_OVERFLOW_VIA_MPROTECT is also true if MR_WIN32, because the
Win32 API provides mprotect like functionality.
runtime/mercury_memory_zones.c:
Define a function MR_protect_pages() which has the same interface as
mprotect. It just calls mprotect when it exists or equivalent code
to emulate it under Win32.
Use MR_PROTECTPAGE in place of HAVE_MPROTECT, and replace all calls
to mprotect() with MR_protect_pages().
Define a Win32 version of memalign.
runtime/mercury_memory_handlers.c:
Use MR_protect_pages() instead of mprotect().
Don't use signal handlers when in a Win32 structured exceptions are
available.
Code to explain Win32 exceptions on stderr.
runtime/mercury_memory_handlers.h:
Export MR_filter_win32_exception for use in mercury_wrapper.c
runtime/mercury_memory_zones.h:
Use MR_PROTECTPAGE in place of HAVE_MPROTECT.
Define PROT_{NONE,READ,WRITE} if we the Win32 API is available and
they are not already defined.
Export the definition of MR_protect_pages().
runtime/mercury_wrapper.c:
Wrap the call to main in a __try __except block if we are using
Win32 structured exceptions, so that any exceptions generated are
caught and debugging info about them printed to stderr.
runtime/mercury_memory.c:
Add a Win32 version of getpagesize().
Estimated hours taken: 40
Allow compilation of the mercury compiler *ONLY* in the grade hlc.gc
using the Microsoft Visual C++ compiler (MSVC). This is still
work-in-progress.
configure.in:
Test to see whether or not we are using the Microsoft compiler.
Don't fail if we can't interpret return values from system.
boehm_gc/Mmakefile:
Use NT_MAKEFILE if we are using MSVC.
boehm_gc/NT_MAKEFILE:
Apply the the changes to boehm_gc/Makefile to this file.
browser/Mmakefile:
library/Mmakefile:
runtime/Mmakefile:
trace/Mmakefile:
Use the correct executable to create libraries.
Use AR_LIBFILE_OPT to name the library.
compiler/llds_out.m:
Export output_c_file_intro_and_grade so that the correct header can
be placed at the start of each C file.
compiler/mlds_to_c.m:
Output the header at the start of each C file, so that configure
doesn't delete the file when checking the compatability with
the configured settings.
When initializing empty arrays place a dummy entry in the array, so
that the MSVC compiler generates a symbol for that array.
compiler/passes_aux.m:
Add invoke_shell_command. This predicate wraps commands with
a bash -c 'command ' when shell scripts aren't supported by the
target system.
compiler/mercury_compile.m:
compiler/modules.m:
Use invoke_shell_command instead of invoke_system_command for shell
scripts.
library/io.m:
Call _unlink in io_rename_file, when compiling with MSVC.
runtime/mercury_wrapper.c:
Initialise MR_runqueue_head so that the segment containing this
variable is registered with the garbage collector. This stops
intermittent failures of the GC_is_visible() test.
runtime/mercury_conf.h.in:
Define MR_WIN32 when we are using MSVC.
runtime/mercury_memory.c:
runtime/mercury_memory_handlers.c:
runtime/mercury_memory_zones.c:
runtime/mercury_prof.c:
runtime/mercury_reg_workarounds.c:
runtime/mercury_reg_workarounds.h:
runtime/mercury_signal.c:
runtime/mercury_timing.c:
runtime/mercury_timing.h:
runtime/mercury_trace_base.c:
util/mkinit.c:
Only include unistd.h and sys/times.h when they exist.
MSVC doesn't have SIGBUS so #ifdef sections which refer to it.
scripts/Mmake.rules:
Use /Fo instead of -o to generate .o files if compiling with MSVC.
scripts/Mmake.vars.in:
Define AR to use the autoconfed executable for linking.
scripts/mgnuc.in:
Only add option -Wno-uninitialized if we are using gcc.
util/Mmakefile:
Explicitly locate the getopt src, and use it in compiling the
utilities.
Estimated hours taken: 20
Port to Linux-m68k. A lot of this work was done by Roman Hodek,
<Roman.Hodek@informatik.uni-erlangen.de>.
README.Linux-m68k:
Mention that we have a port to the 68k.
configure.in:
Add a test for two different sorts of signal handlers
void handler(int signum, struct sigcontext_struct context)
and
void handler(int signum, int code, struct sigcontext_struct context)
Set HAVE_SIGCONTEXT_STRUCT_2ARG or HAVE_SIGCONTEXT_STRUCT_3ARG
appropriately.
Add support for shared libraries on the m68k as they should
work.
Make "working struct sigcontext" tests use MR_GET_FAULT_ADDR.
boehm_gc/config.h:
Add some definitions for the m68k.
boehm_gc/os_dep.c:
Get fault addresses using m68k specific code.
runtime/mercury_conf.h.in:
Add new configuration definitions HAVE_SIGCONTEXT_STRUCT_2ARG,
and HAVE_SIGCONTEXT_STRUCT_3ARG.
runtime/mercury_faultaddr.h:
Add MR_GET_FAULT_ADDR.
runtime/mercury_goto.h:
Add support for non-local gotos with Linux-68k.
runtime/mercury_memory_handlers.c:
Handle 2 or 3 argument signal handlers.
Estimated hours taken: 10
Introduce two new directories, trace and browser, containing libraries
holding the C and Mercury code of the debugger respectively. (Although
the browser directory does not have a browser in it yet, the browser
should soon become its biggest component.) Take the opportunity to
rename the existing libraries, for consistency.
After this change, the linking order becomes:
the object of the auto-generated init file
program object files
trace library (libmer_trace.a)
browser library (libmer_browser.a)
standard library (libmer_std.a)
runtime library (libmer_rt.a)
Boehm collector (libgc.a)
To avoid circularities, libraries cannot contain direct calls to
any routines that are defined in libraries (or object files) that
occur earlier in the above list. Any such calls must be made into
indirect calls via function pointers.
In particular, there was a circularity caused by the library calling
MR_trace() which invokes the tracer which in turn invokes the
library. This circularity was broken by having MR_trace(),
which is defined in the runtime, call the tracer indirectly via
a global variable named MR_trace_func_ptr. This global variable
is initialized by the auto-generated *_init.c file.
To avoid linking in the tracer even when it is not being used,
this global variable is only set to point to MR_trace_real()
if you're using a debugging grade or if c2init was invoked
with the `-t' flag. Otherwise it is set to MR_trace_fake()
which just prints an error message telling the user to
rebuild the executable with debugging enabled.
Makefile.DLLs:
Reserve random locations for the two new libraries. Whether they work
will be decided by testing on Windows.
Mmake.common.in:
Add variables naming the new directories, and create variables
naming the libraries.
Mmakefile:
Add targets for the new directories, and modify existing rules
as appropriate.
browser/Mmakefile:
Mmakefile for the new directory, modelled on library/Mmakefile.
browser/browser_library.m:
Umbrella file for the new directory, modelled on library/library.m.
{browser,library}/debugger_interface.m:
Moved this file from library to browser without change.
browser/help.m:
A new module for the help system of the debugger. Not yet used.
compiler/Mmakefile:
Update to refer to the new directories and libraries where
appropriate.
compiler/mercury_compile.m:
If we are doing tracing, then pass -t instead of -i to c2init.
compiler/modules.m:
When generating the .dep file, get the grade flags passed to c2init.
doc/Mmakefile:
Remove the special treatment of library/debugger_interface.m.
library/Mmakefile:
Update to refer to the new directories and libraries where
appropriate, and to conform to the new name of the library.
library/library.m:
Do not import debugger_interface.
profiler/Mmakefile:
Update to refer to the new directories and libraries where
appropriate.
runtime/Mmakefile:
Update to refer to the new directories and libraries where
appropriate, and to conform to the new name of the library.
Remove references to files being moved to the trace directory.
runtime/mercury_init.h:
Refer to the automatically generated dll header file by its new name
(renamed because the runtime library is renamed).
Add declarations to support the new global variable MR_trace_func_ptr.
runtime/mercury_memory_handlers.c:
runtime/mercury_memory_zones.c:
runtime/mercury_misc.c:
Remove inappropriate #includes of "mercury_trace.h", and substitute
a #include of "mercury_trace_base.h" if necessary.
{runtime,trace}/mercury_trace.[ch]:
{runtime,trace}/mercury_trace_external.[ch]:
{runtime,trace}/mercury_trace_internal.[ch]:
Move these files from the runtime to the trace directory.
The only changes are the removal from mercury_trace.h of declarations
added to runtime/mercury_trace_base.h, and the change from MR_trace
to MR_trace_real.
runtime/mercury_trace_base.[ch]:
Define MR_trace(), which does an indirect call through
MR_trace_func_ptr if the event should be traced.
Define MR_trace_fake, which just prints an error message.
Its address will be assigned to MR_trace_func_ptr if tracing
is not enabled.
Define the types needed by the signature of MR_trace.
Fix an old bug: s/MERCURY_TRACE_PERMANENT_H/MERCURY_TRACE_BASE_H/.
runtime/mercury_wrapper.[ch]:
Add the new global variable MR_trace_func_ptr.
scripts/c2init.in:
Add a new option, -t/--trace, which enables tracing by causing the
address of MR_trace_real to be assigned to MR_trace_func_ptr.
Have this option be implied by the grade. Also have the old option
-i (need initialization code) be implied by the grade, as well as by
-t.
scripts/ml.in:
Include the new libraries in the link command.
tests/debugger/Mmakefile:
Include -t instead of -i in the list of c2init options. (-t implies
-i.)
tools/bootcheck:
Copy and build the new directories as appropriate. The trace directory
is treated like the runtime, the browser directory is treated like the
library.
trace/Mmakefile:
Mmakefile for the new directory, modelled on runtime/Mmakefile.
util/mkinit.c:
Add the new option -t, as discussed above.
Mmakefile for the new directory, modelled on runtime/Mmakefile.
util/Mmakefile:
Specify -O0, since with the default optimization level, gcc on
cyclone ignores the assignment of TRUE to need_tracing when -t is
given (!!!).
Estimated hours taken: 6
Fix some bugs in tabling, to enable the boyer test case to work.
runtime/mercury_tabling.h:
Add a new set of macros that optionally print debugging info at
tabling actions. Debugging recquires compilation with -DMR_TABLE_DEBUG
and -dT in MERCURY_OPTIONS.
runtime/mercury_table_any.c:
Use the debugging macros. Fix two bugs, one found with their help.
One is that a tagged pointer to the table giving information about
remote secondary tags did not have its tag stripped before use.
The other is that the extraction of local secondary tags from words
was done by subtracting the tag, and not by shifting out the tag,
leaving the secondary tag value too high by a factor of 4 or 8.
runtime/mercury_table_any.[ch]:
runtime/mercury_table_enum.[ch]:
Change the order of some function arguments to be consistent with
the orders in the macros that call these functions.
runtime/mercury_table_enum.c:
Add an optional sanity check that detects the second bug above.
runtime/mercury_engine.[ch]:
Add a new debug flag, MR_tabledebug. Rename the flags so they always
start with MR_.
runtime/mercury_wrapper.c:
Allow -dT in MERCURY_OPTIONS to set MR_tabledebug.
runtime/*.[ch]:
Trivial changes for the new names of the debug flags.
runtime/Mmakefile:
Reimpose alphabetical order on the list of C files.
library/private_builtin.m:
Use the new debugging macros in the C code that does tabling.
Expose the equivalence between ml_table, ml_subgoal_table_node etc
and c_pointer. The reason is
% These equivalences should be local to private_builtin. However,
% at the moment table_gen.m assumes that it can use a single variable
% sometimes as an ml_table and other times as an ml_subgoal_table_node
% (e.g. by giving the output of table_lookup_insert_int as input to
% table_have_all_ans). The proper fix would be for table_gen.m to
% use additional variables and insert unsafe casts. However, this
% would require significant work for no real gain, so for now
% we fix the problem by exposing the equivalences to code generated
% by table_gen.m.
library/mercury_builtin.m:
Delete the contents of this obsolete file, leaving only a pointer
to builtin.m and private_builtin.m.
tests/tabling/Mmakefile:
Enable the boyer benchmark, since we now pass it.
Estimated hours taken: 0.5
Fix a bug in get_pc_from_context that was causing compile
errors on IRIX and Solaris.
runtime/mercury_memory_handlers.c:
Fix a bug in get_pc_from_context -- it wasn't using the correct
type (ucontext_t) for the context.
Estimated hours taken: 90
An initial implementation of the accurate garbage collector.
WORK_IN_PROGRESS:
Add an entry for the accurate garbage collector.
library/builtin.m:
library/mercury_builtin.m:
library/std_util.m:
runtime/mercury_tabling.h:
Deep copy terms using the address of the value instead of
just the value.
library/io.m:
Initialize the garbage collector's rootset with the globals.
runtime/Mmakefile:
Add new files to the Mmakefile.
runtime/mercury_accurate_gc.h:
runtime/mercury_accurate_gc.c:
The new garbage collector.
runtime/mercury_agc_debug.c:
runtime/mercury_agc_debug.h:
Debugging utilities for the new garbage collector.
runtime/mercury_deep_copy.c:
runtime/mercury_deep_copy.h:
runtime/mercury_deep_copy_body.h:
Put the deep copy code in mercury_deep_copy_body.h, and #include
it with appropriate #defines in order to get a variant for
deep_copy(), and one for agc_deep_copy().
agc_deep_copy() forwards pointers as it copies.
Also, deep_copy (all variants) have been modified to take
a pointer to the data to be copied, because some variants
need to be able to modify it.
runtime/mercury_engine.c:
runtime/mercury_engine.h:
Add a second heap_zone which is the to-space of
the copying collector.
Add a debug_heap_zone, which is used as a scratch
heap for debugging.
runtime/mercury_label.c:
Instead of
realloc(entry_table, ....)
do
entry_table = realloc(entry_table, ....)
to avoid horrible bugs.
Also, make sure the tables get initialized before looking up
an entry label.
runtime/mercury_imp.h:
Include mercury_debug.h before most of the modules.
(mercury_engine.h adds a new MemoryZone only if we are
debugging accurate GC).
runtime/mercury_memory.c:
Setup the debug_memory_zone sizes.
Remove an unnecessary prototype.
runtime/mercury_memory_handlers.c:
Add code to get the program counter and the stack pointer
from the signal context.
Call MR_schedule_agc() from default_handler() if doing accurate gc.
runtime/mercury_memory_zones.c:
Setup the hardzone regardless of whether redzones are used.
Add some more debugging information.
runtime/mercury_regorder.h:
runtime/machdeps/alpha_regs.h:
runtime/machdeps/i386_regs.h:
Add definitions to make the real machine registers name/number
for MR_sp available.
runtime/mercury_trace_internal.c:
runtime/mercury_trace_util.c:
runtime/mercury_trace_util.h:
Add MR_trace_write_variable(), which writes terms given their
value and type_info.
runtime/mercury_wrapper.c:
runtime/mercury_wrapper.h:
Change the size of the heap redzone when doing accurate GC.
Use a small heap when debugging agc.
runtime/mercury_debug.h:
runtime/mercury_conf_param.h:
Add new debugging macros and document them.
runtime/mercury_type_info.c:
Add const to the pointer arguments of MR_make_type_info.
Estimated hours taken: 3
Fix some problems that caused compilation errors when compiling with
C compilers other than gcc.
runtime/mercury_engine.c:
runtime/mercury_ho_call.c:
runtime/mercury_memory_handlers.c:
runtime/mercury_signal.c:
runtime/mercury_table_builtins.c:
Add casts to fix various type errors.
runtime/mercury_heap.h:
Add LVALUE_CAST()s in hp_alloc() and hp_alloc_atomic()
to cast MR_hp to Word when calling incr_hp() and incr_hp_atomic().
runtime/mercury_ho_call.c:
runtime/mercury_wrapper.c:
runtime/mercury_engine.c:
runtime/mercury_type_info.c:
runtime/mercury_wrapper.c:
Delete extraneous semicolons after occurrences
of the MR_MAKE_STACK_LAYOUT_* macros.
runtime/mercury_tabling.h:
Delete extraneous semicolons in the definitions of the
table_allocate(), table_reallocate(), and table_free() macros.
Use <stdarg.h> instead of <varargs.h> and add missing call
to va_end().
runtime/mercury_goto.h:
Change the ANSI C versions of the ENTRY(), STATIC(), LOCAL(),
and LABEL() macros to cast their results to type `Code *'.
The reason is that although the `Code *' type is actually `void *',
there is no implicit conversion from pointer to function
to pointer to void in ANSI C.
runtime/mercury_tabling.h:
runtime/mercury_context.h:
runtime/mercury_context.c:
`free_context_list' was declared extern in the header file
but also declared static in the `.c' file, so I deleted
the declaration in the header file, and moved the comment
there into the `.c' file.
runtime/mercury_deep_copy.c:
Add a missing `static' on the declaration of deep_copy_type_info().
runtime/mercury_trace_external.c:
Avoid unterminated string literals even inside `#if 0 ... #endif'.
runtime/mercury_types.h:
Minor changes to a couple of comments.
Estimated hours taken: 5
More cleanup of the memory management code.
This time we clean up the signal handler setup code.
runtime/Mmakefile:
Add new files.
runtime/mercury_memory.c:
Rename setup_signal() to setup_signals().
runtime/mercury_memory_handlers.c:
runtime/mercury_memory_handlers.h:
Clean up signal handling.
Use MR_setup_signal to setup signal handlers.
Define bus_handler and segv_handler signal handlers, the
old signal handlers are just one or the other (or both).
runtime/mercury_prof.c:
Use MR_setup_signal to setup signal handler.
runtime/mercury_signal.c:
runtime/mercury_signal.h:
New files -- a standard interface for setting up signal
handlers (a porting base, if you like).
Estimated hours taken: 5
Clean up memory management code. This mostly involves cleaning up
the #defines and removing duplicate code. This is just an incremental
improvement, more changes are expected.
runtime/mercury_conf_param.h:
Add definitions for MR_CAN_GET_PC_AT_SIGNAL and
MR_CHECK_OVERFLOW_VIA_MPROTECT.
runtime/mercury_context.c:
Rename reset_zone() as reset_redzone().
runtime/mercury_memory_handlers.c:
Define one set of functions with conditional bodies, rather
than conditional defintions of functions.
runtime/mercury_memory_zones.c:
Use MR_CHECK_OVERFLOW_VIA_MPROTECT rather than just looking
for HAVE_MPROTECT and HAVE_SIGINFO.
runtime/mercury_memory_zones.h:
Only use redzones with MR_CHECK_OVERFLOW_VIA_MPROTECT.
Correct a comment about how much memory is should be
given to construct_zone.
The correct caculation is
size + unit (for offset) + unit (for hardmax)
Rename reset_zone as reset_redzone.
Estimated hours taken: 5
Split mercury_memory.{c,h} into several files. Added a few
comments about functions whose declarations have been moved into
the header files, otherwise the content is unchanged.
runtime/Mmakefile:
Add new files.
runtime/mercury_context.c:
Add a #include "mercury_memory_handlers.h" as this module
creates new zones using default_handler.
runtime/mercury_memory.c:
runtime/mercury_memory.h:
Other code (mostly code to set up the actual memory
zones we use in the Mercury runtime).
runtime/mercury_memory_handlers.c:
runtime/mercury_memory_handlers.h:
Signal handlers for memory access violations.
runtime/mercury_memory_zones.c:
runtime/mercury_memory_zones.h:
The implementation MemoryZone data type.