Estimated hours taken: 0.5
runtime/imp.h:
Temporarily resurrected, for bootstrapping reasons.
(Can't remove this until the change to make llds_out.m
reference mercury_imp.h instead of imp.h has been installed.)
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.
Estimated hours taken: 0.25
runtime/imp.h:
Fix a bug in the ordering of the #include statements
that caused problems when using DLLs on Windows.
runtime/conf.h.in:
Add a comment.
configure.in:
runtime/conf.h.in:
Define USE_DLLS in conf.h.
runtime/imp.h:
runtime/init.h:
runtime/memory.c:
runtime/table.c:
util/mkinit.c:
boehm_gc/gc.h:
Conditionalize things on `#ifdef(USE_DLLS)' rather than on
`#ifdef(__CYGWIN32__)'. Testing for specific systems tends
to lead to code that is difficult to maintain.
util/mkinit.c:
Fix a bug: it was checking `#if defined(libmer_USE_DLL)', but it
should have been checking `#if !defined(libmer_DEFINE_DLL)'.
Estimated hours taken: 24
Implement support for DLLs on Windows.
The changes consisted of
1. Adding `Makefile.DLLs', which is a file I wrote contains
GNU Make rules for building DLLs. Making sure that
the various Mmakefiles include that one.
2. Making sure we #include the "libfoo_dll.h" header file
generated by `Makefile.DLLs' before every place that
references a global variable.
3. Making sure that code which defines the DLLs is
compiled with -Dlibfoo_DEFINE_DLL.
5. Changing various places to explicitly register the data
segment as a root set with the conservative garbage collector.
This was necessary to get GC working with DLLs under Windows
(there doesn't seem to be any way of automatically finding
the data segments of DLLs under win32).
6. Changing the way names are mangled to ensure that the assembler
names always contain a leading underscore, since `dlltool'
on gnu-win32 requires this.
TODO:
- Document how users can create their own DLLs.
- Add support for that to Mmake.
configure.in:
Mmake.common.in:
Add USE_DLLS variable. (Most of the Makefile changes below are
conditionalized on this variable.)
boehm_gc/Makefile:
Add dependency $(OBJS) : libgc_dll.h.
Add `-DGC_DEFINE_DLL' to CFLAGS.
Include Mmakefile.DLLs.
Add new targets `dll' and `test_dll'.
boehm_gc/Mmakefile:
Add stuff to install libgc_dll.h and libgc_globals.h.
boehm_gc/gc.h:
For __CYGWIN32__, #include "libgc_dll.h".
This is necessary to handle global variables in DLLs on Windows.
For __CYGWIN32__, define GC_INIT() to add the
data segment of the current DLL or executable as
a new root set.
library/Mmakefile:
Add stuff needed for building DLLs.
runtime/wrapper.mod:
library/io.m:
Add call to GC_INIT() to register the root set for
libmer.dll and libmercury.dll respectively.
In wrapper.mod, move the call to GC_is_visible
_after_ the calls to GC_INIT().
runtime/Mmakefile:
Add stuff needed for building DLLs.
runtime/init.h:
runtime/imp.h:
runtime/dummy.c:
runtime/label.c:
runtime/memory.c:
runtime/table.c:
For __CYGWIN32__, make sure we #include "libmer_dll.h".
before defining global variables.
This is necessary to handle global variables in DLLs
on Windows.
runtime/goto.h:
util/mdemangle.c:
prof/demangle.m:
Change the way names are mangled to ensure that the assembler
names always contain a leading underscore, since `dlltool'
on gnu-win32 requires this.
util/mkinit.c:
For __CYGIN32__, when using DLLs, make sure we initialize the
_impure_ptr of the DLLs that we're using.
library/Mmake:
runtime/Mmake:
Compile with -Dlibfoo_USE_DLL options.
Add code to install libfoo_dll.h and libfoo_globals.h.
Include Mmakefile.DLLs.
Estimated hours taken: 8
Generalize the current support for trailing.
Previously, the trail was hardwired, either for interfacing to CLP(R),
or (in my alternative not-checked-in version) for backtrackable destructive
arrays. But it couldn't handle both of these at the same time and it
couldn't be extended. So we have replaced this with a more generic
trail. The trail has two sorts of entries, value trail entries and
function trail entries.
runtime/mercury_trail.h:
runtime/mercury_trail.c:
New files. They provide macros MR_trail_value(),
MR_trail_function(), etc. which are the new interface to
the Mercury trail. (All the trailing stuff is done inside
`#ifdef MR_USE_TRAIL'.)
These files also implement the save_ticket(), restore_ticket(),
and discard_ticket() macros that are used in the C code that
the Mercury compiler generates, except that I've renamed them
and changed the interface slightly.
These files also define the trail memory zone MR_trail_zone,
and the new virtual machine registers MR_trail_ptr and
MR_ticket_counter. (Perhaps these should instead be in memory.c
and regs.h respectively?)
runtime/mercury_solver_backtrack.h:
Deleted, since this file has been replaced by mercury_trail.h.
runtime/imp.h:
#include "mercury_trail.h" rather than "mercury_solver_backtrack.h"
runtime/Mmakefile:
Add mercury_trail.c and mercury_trail.h.
Remove mercury_solver_backtrack.h.
runtime/context.h:
Add new fields to the Context struct to hold MR_trail_zone,
MR_trail_ptr and MR_ticket_counter. Add code to handle these
in save_context()/load_context().
runtime/context.mod:
Add code to new_context() to initialize the trail.
runtime/wrapper.h:
runtime/wrapper.mod:
runtime/memory.c:
Add code to handle setting the trail size via the
MERCURY_OPTIONS environment variable.
Remove old stuff to support the solver_stack.
runtime/wrapper.mod:
runtime/regs.h:
runtime/regorder.h:
Count the usage of the new virtual machine registers
MR_trail_ptr and MR_ticket_counter.
(Currently they are implemented just as global variables,
not registers.)
Estimated hours taken: 0.2
runtime/context.mod:
runtime/debug.h:
runtime/dlist.c:
runtime/imp.h:
runtime/regs.h:
runtime/std.h:
runtime/wrapper.mod:
Replaced all occurences of assert() with the new macro
MR_assert(), which does nothing if SPEED is defined.
Previously, we defined NDEBUG if SPEED was defined, which
had the unfortunate consequence of turning off assertions
in the code of Mercury users that includes the standard
Mercury headers. Users' assertions no longer get turned off
inadvertently.
Estimated hours taken: 6
A general cleanup of the code in the runtime directory, aimed at
formulating a more coherent header file inclusion policy. This change
fixes a couple of bugs that prevented the runtime from compiling in
certain configurations (e.g. on muse) due to missing #includes, and
also fixes a few minor unrelated things such as the use of `size_t'
instead of `unsigned'.
Our header file inclusion policy is that every header file should
#include any other header files needed by the declarations or by the
macros it defines. Cyclic interface dependencies, where two header
files each #include the other, must be avoided (by splitting up header
files into smaller indepdent units, if necessary).
At some stage in the future we should rename all the header files to
`mercury_*.h', to avoid any possible name clashes with system or user
header files.
runtime/Mmake:
Add a new target `check_headers' to check that each
header file is syntactically valid in isolation.
runtime/imp.h:
runtime/mercury_float.h:
runtime/mercury_string.h:
runtime/mercury_types.h:
runtime/calls.h:
Move the code in "imp.h" into new header files.
"imp.h" now contains nothing but #includes.
runtime/conf.h.in:
runtime/*.h:
runtime/{label,prof,prof_mem}.c:
runtime/*.mod:
Update the #includes to reflect the new header file structure.
Add some missing header guards. Add some comments.
Put the correct years in most of the copyright notices.
runtime/heap.h:
Fix a bug: add #include "context.h", needed for
min_heap_reclamation_point.
runtime/context.h:
Fix a bug: add #include "memory.h", needed for MemoryZone.
Move the general description comment to the top of the file.
Fix the indentation of some comments. Add a couple of new comments.
runtime/context.mod:
Delete a couple of unnecessary declarations.
runtime/wrapper.mod:
Change the type used for memory sizes from `unsigned' to `size_t'.
Change the `-p' (primary cache size) option so that it is always
a size in kilobytes, rather than being schitzophrenic about
whether it is bytes or kilobytes.
runtime/regorder_base.h:
Removed, since it not used (and constitutes a
double-maintenance problem).
Estimated hours taken: 2
The following diff fixes a few bugs in Tom's recent changes,
some of which meant that it didn't compile on Solaris.
It also fixes a few stylistic things, e.g. using a
higher level of abstraction and avoiding the use of `Word'
where it is not needed.
I also changed several of the types in some of the existing
code in the runtime: the stuff for computing memory sizes,
offsets, etc., should use `size_t', not `unsigned',
and the `num_uses' array can be `unsigned long', not `Word'.
runtime/Mmake:
Add missing entries for context.h, spinlock.h, and spinlock.c.
runtime/context.h:
Delete an unnecessary #include.
Use `typedef Word AtomicBool' rather than spreading that
particular assumption throughout the code.
runtime/context.mod:
Don't forget to #include "context.h".
Use AtomicBool and SpinLock rather than Word.
Use allocate_object() and allocate_array()
rather than allocate_byte() and allocate_word().
Fix a bug in some calls to get_lock() and release_lock()
where it was passing the SpinLock itself rather than the
SpinLock's address. Add casts from `Word *' to `SpinLock *'
to avoid depending on the assumption that SpinLock == Word.
runtime/imp.h:
Delete the typedef for SpinLock, since it belongs in
spinlock.h, not here.
runtime/memory.h:
Define allocate_object() and allocate_array() macros.
Delete the allocate_words() function, since allocate_array()
should be used instead.
Delete allocate_spinlock(), since that belongs in spinlock.h,
not here.
Use `size_t' rather than `unsigned' for counting memory sizes
and offsets.
runtime/memory.c:
Change the type of num_uses from `Word[]' to `unsigned long[]'.
Use `size_t' rather than `unsigned' for counting memory sizes
and offsets. Use `int' rather than `Word' for the offset_count.
Use SpinLock rather than Word for the offset_lock.
Use allocate_object() and allocate_array()
rather than allocate_byte() and allocate_word().
Fix the indentation in a couple of places.
Fix the syntax of a #error directive.
runtime/spinlock.c:
Fix a syntax error. This file had never been compiled.
runtime/spinlock.h:
Add allocate_spinlock(), which was previous in memory.h.
Add deallocate_spinlock().
Separate out the interface and the implementation
details and document the interface.
Add missing #include statements that are needed
to define things used in this file.
Change the get_lock() and release_lock() macros so that
they do not cast their argument; instead, the caller
should cast it, if necessary.
runtime/wrapper.mod:
Eliminate a cast which is no longer necessary.
Estimated hours taken: 40
This change is a major reorganisation of the runtime engine.
The main point of this change is to make the Mercury engine
multithreaded - so that more than one goal can be evaluated
at a time.
runtime/*.{c,h,mod}:
Lots of changes - new files: context.{h,mod} spinlock.{c,h}
library/std_util.m:
Fix solitons to work in the presence of multiple contexts.
Estimated hours taken: 0.5
runtime/imp.h:
Fix five bugs in the make_aligned_string() macro:
- the sense of the test was inverted
- in one spot, one of the arguments was not enclosed in parentheses
- it had a bogus trailing semicolon
- the first argument to incr_hp_atomic should have been
cast (using LVALUE_CAST) to type Word
- the second argument to incr_hp_atomic was not parenthesized
properly -- the precedence of division is higher than that
of addition -- causing it to allocate too much memory.
I also made a couple of minor changes to make it more readable.
Estimated hours taken: 45
Implementation of
functor/3
arg/3 (and det_arg/3)
expand/4 (like Prolog's =..)
runtime/imp.h:
Add macro `make_aligned_string' which copies strings onto the
heap if they are unaligned.
runtime/type_info.h:
Add definitions of offsets for finding functors and arities.
Estimated hours taken: 2
If `double' is the same size as `void *', then don't box floats.
runtime/imp.h:
Remove the unconditional `#define BOXED_FLOAT'.
runtime/conf.h.in:
Add BOXED_FLOAT.
Estimated hours taken: 50
Create base_type_layout structures, which store information about how
Mercury data is represented in memory.
runtime/type_info.h:
Use USE_TYPE_TO_TERM to determine whether we are using type-to-term,
rather than checking the offset of ARG_TYPE_INFOS.
Set the offsets according to USE_TYPE_TO_TERM (presently #undefed).
Add macros and defintions for constants used in layout tables.
runtime/imp.h:
Add type_info.h to the list of standard #includes.
Estimated hours taken: 0.1
imp.h:
Put back the definitions of call_{det,semidet,nondet}_closure
until the code generation changes have been reflected in all
the installed compilers.
Estimated hours taken: 0.2
imp.h:
Removed the call_{det,semidet,nondet}_closure macros, since they are
not needed anymore.
solutions:
Use the new method of calling closures.
call.mod:
Cosmetic changes.
Estimated hours taken: 0.1
runtime/imp.h:
Fix a problem with the definition of float_to_word and word_to_float
for the case of USE_SINGLE_PREC_FLOAT; gcc didn't like the cast
from Integer to union FloatWord - it wanted a cast from Integer
to Word first.
Estimated hours taken: 24
Add inline assembler hacks for restoring the $gp register on the alpha,
to make the `asm_fast.gc' grade work on the alpha.
runtime/goto.h:
For the alpha, change the GOTO macro so that it sets up
register $27 (the "procedure value" register) to contain the
address to which you are going to jump, and change the
Define_{entry,local,static} macros so that they have a `ldgp'
instruction after the label which restores the gp register from
$27.
runtime/call.mod:
For the alpha, change the call macro so that it uses a `ldgp'
instruction to restore the gp register on return from a call.
Add new call_localret macro, for the case when the continuation
label is a local label (this is like the inverse of the localcall
macro), because a call_localret is two instructions cheaper
than the equivalent call would be.
runtime/engine.mod:
In call_engine(), we need to use `Define_label(engine_done)'
rather than just `engine_done:', so that it works on the alpha.
These changes improve the speed of the compiler by about 21%,
and cut executable size by about 24%.
There's still a fair bit of room for improving efficiency by
avoiding moves to $27 and `ldgp' instructions in situations
where they aren't needed.
Estimated hours taken: 0.25
Fix a problem noticed by Andreas Kuehlmann.
runtime/{imp.h,aux.c}:
Define hash_string() as a function in aux.c unconditionally,
even if we're not using gcc. This avoids trouble when linking
programs compiled with cc with a runtime library that was
compiled with gcc.
Estimated hours taken: 1 summer studentship
This is the implementation of the constraint solver interface runtime stuff.
We maintain a stack of tickets, accessible via mercury_solver_sp.
runtime/aux.[ch]
Introduce a new memory allocation function, checked_malloc(). This is
similar to newmem(), except that it always uses malloc(), not
GC_malloc(), regardless of the grade. This is useful when allocating
memory for the ticket stack as the garbage collector needn't know
about the ticket stack - it never contains pointers into gc'ed memory.
runtime/imp.h
Include mercury_solver_backtrack.h if we are in an appropriate grade.
runtime/wrapper.mod
Initialise the ticket stack, call the solver initialisation macro.
runtime/mercury_solver_backtrack.h
Implement the ticket macros, and the solver initialisation macro. This
file is currently specific to the CLP(R) solver; to interface to a
different solver, only the macros etc. in this file need be altered.
Estimated hours taken: 1
imp.h, prof.h:
Fix the byzantine inclusion relationship between prof.h and imp.h.
prof.c:
Fix the hashing function for code addresses so that it doesn't waste
three quarters of the hash table.
In each hash slot, use a binary search tree instead of an unordered
list of entries. This can be expected to handle high loads better,
which is necessary because the hash table size is not adaptive.
(Making it adaptive would be a better fix.)
Instead of turning signals off and on in the handler of profiling
signals, simply set a volatile variable to detect cases when two
profiling signals arrive too closely.
Estimated hours taken: 1
library/io.m:
Moved the profiling initialisation code so that it sits around
the call to main/2(0). Thus the profiler will now begin all it's
profiles from main not from call_engine.
profiler/read.m:
The profiler now expects that it's address are written out in decimal.
read.m now assumes that an address is a decimal, but if it can't parse
it, it will then read it in as a hexadecimal. Thus the profiler will
still be able to read it's old files.
NB. A possible bug with this is that two numbers will get converted to
the same number if one is treated as hex and the other decimal.
profiler/.cvsignore:
Some more files to ignore.
runtime/{engine, wrapper}.mod:
Remove the profiling initialisation code.
runtime/imp.h:
Add a new call macro noprof_call() which doesn't record an arc
in the call graph for profiling ever. This is used to ignore some
of the initial system set-up calls.
runtime/prof.c:
Output integers instead of hexs for the addresses.
Estimated hours taken: 0.75
runtime/imp.h:
Fix a bug in the code for float_to_word() in non-gc grades:
the part which was supposed to ensure correct alignment
of floats allocated on the heap was not working correctly.
to inside pragma(c_code) declarations in the `library' directory sources.
runtime/{Mmake,{math,io}_rt.mod}:
Remove math_rt.mod and io_rt.mod, since the code has been moved
into `.m' files in the library directory.
runtime/main.mod:
Remove this file, since it wasn't used.
runtime/imp.h:
Add SUCCESS_INDICATOR as a macro for r1, for use by
pragma_c_code.
Also a few minor unrelated changes:
runtime/imp.h:
Avoid code duplication in hash_string macros.
runtime/tags.h:
Use sizeof(Word) rather than WORD_SIZE (in this old code, the
extra level of indirection only obfuscated things).
runtime/{aux.c,aux.h,prof.c}:
Add some more #ifdefs to avoid including debugging/profiling
code in the non-debugging/non-profiling version of the library.
Estimated hours taken: 0.5
Fix problem on Linux where global register declarations occur after
inline function definitions in system header files.
runtime/imp.h:
Make sure that "reg.h" is the first header file included.
Estimated hours taken: 0.25
runtime/imp.h:
Suppress a spurious warning about `cast from pointer to integer
of different size' when compiling in a non-gc grade on the alpha.
runtime/imp.h:
When not using conservative GC, ensure appropriate alignment of
floating point constants. Also fix a couple of missing
parentheses in the float_to_word macro.
runtime/imp.h:
Add #include of <string.h> for strcmp().
(This missing #include was not previously noted because gcc has
a builtin-declaration for strcmp() - it only caused a warning
when compiled with `-fno-builtin'.)
imp.h, engine.mod, io_rt.mod:
Reorder #include lines so that "regs.h" gets included
before any of the system header files (other than <stddef.h>).
This is necessary because on some systems, the system header files
contain inline functions, and the global register variable
declarations must precede these.
regs.h:
Add case for i386, since global register variables now work
on the 386 (the problem was just that we needed -fno-builtin).
label.c, wrapper.mod:
Add #include of <string.h> for strcmp().
(These missing #include were not previously noted because gcc has
a builtin-declaration for strcmp() - it only caused a warning
when I compiled with `-fno-builtin'.)
regorder.h:
Change the register allocation order so that `sp' gets
allocated first, since for the compiler, 36% of all Mercury
register references are to `sp'.
memory.c:
With `-dm', if we're using CONSERVATIVE_GC, don't output the
size etc. for the heap, since they will all be zero - the
heap gets allocated by the Boehm collector.
runtime/aux.c:
Make oldmem() call GC_FREE() if CONSERVATIVE_GC is defined.
Improve the error messages from fatal_error().
runtime/{imp.h,label.c}
Use `Unsigned' rather than `Uinteger'.
runtime/dlist.c:
Fix incorrect comment.
runtime/memory.c:
Various portability fixes for the Alpha, mostly to do with
mixing integers and pointers of different sizes.
Also make sure we only use PC_INDEX if it is defined.
runtime/prof.c:
Another portability fix for the Alpha: use `sysconf(_SC_CLK_TCK)'
if `HZ' is not available.
Also a major clean-up:
Tidy up the code. Avoid memory leaks. Remember to close files.
Tidy up the error messages for when fopen() fails.
Check the return values from fclose().
(XXX still need to check return values of signal() and setitimer().)
runtime/regs.h:
Add alpha_regs.h.
aux.c, label.c:
Changed format fields to use %ld in most cases of printing integers.
imp.h:
Added a new type Uinteger.
list.c:
This has been renamed dlist.c a long time ago.
conf.h.in:
Set up the type of Word at configuration time.
imp.h:
Changed definition of Word. Also gathered two of the three
definitions of hash_string into one place, defining a macro
for use by aux.c.
aux.c:
Use the macro in imp.h for the body of hash_string.
engine.mod:
Minor formatting change.
memory.c:
Now memory diagnostics are printed on stderr.
wrapper.mod, memory.c:
Convert whens to cases and ors to else ifs.
other files:
copyright notices.
checking for higher-order preds, though, so the compiler doesn't
diagnose errors correctly - if you use the wrong mode you will probably
just get a core dump.)
imp.h:
Add incr_hp_atomic macro, which for USE_CONSERVATIVE_GC
invokes GC_MALLOC_ATOMIC() rather than GC_MALLOC().
io.mod:
Use the new incr_hp_atomic() macro for allocating strings.
Add implementations of string__index/2, string__length/2,
and string__append/3.
Note - these changes sped up the compiler by nearly 40%!