Larceny can be configured to use the Boehm-Demers-Weiser conservative garbage collector (in the following called "the collector"). The collector is covered by the following copyright notice:
Copyright 1988, 1989 Hans-J. Boehm, Alan J. Demers
Copyright (c) 1991-1996 by Xerox Corporation. All rights reserved.
Copyright (c) 1996-1998 by Silicon Graphics. All rights reserved.
THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED OR IMPLIED. ANY USE IS AT YOUR OWN RISK.
Permission is hereby granted to use or copy this program for any purpose, provided the above notices are retained on all copies. Permission to modify the code and to distribute modified code is granted, provided the above notices are retained, and a notice that the code was modified is included with the above copyright notice.
I have tested version 4.14 of the collector with Larceny. Integration is straightforward, although you must build a separate version of larceny (called bdwlarceny) that uses the collector - you can't build a Grand Unified executable that lets you select the conservative collector with a command line switch.
The collector is not part of the Larceny distribution file - you must get it and install it separately.
Download the collector from Hans Boehm's web site at http://www.hpl.hp.com/personal/Hans_Boehm/gc/, and give it a name; I usually call it something like bdw-gc-4.14.tar.gz. Whatever you call it, you should have a .tar.gz file, and you should place it in the directory $LARCENY (cf. the setup instructions). Edit the file $LARCENY/Makefile so that the value of the variable BDW_DIST corresponds to the name of the archive that holds the collector.
When in $LARCENY, type
make bdw_unpackand the archive will be unpacked and moved to the correct location, which is the directory $LARCENY/Rts/bdw-gc.
The file Rts/bdw-gc/Makefile as distributed by Boehm defines the C compiler to be 'cc'. You may want to change this to be the compiler you use to compile Larceny, which, on SunOS systems, will most certainly not be the standard 'cc'. I've been using gcc without problems.
In the definition of CFLAGS near the top of the Makefile:
(This is optional, but recommended.)
The collector does not itself provide a mechanism whereby user code can be called at the beginning and end of garbage collections, so I've created one. It requires some trivial code modification.
Add the line
#include "../Sys/bdw.h"to the file Rts/bdw-gc/alloc.c, following the other include files. This header file redefines two macros used by the collector, STOP_WORLD and START_WORLD, and makes them call the procedures bdw_before_gc and bdw_after_gc, respectively. (Those are defined in Rts/Sys/bdw-collector.c.)
Performing this step is recommended because it enables performance measurements, detection of in-line allocation, and clearing of the unused portion of the stack before each collection. Even so, not all GC time is accounted for, in particular any time spent in lazy sweeping is not recorded.
The collector will now be built when you build bdwlarceny: go to $LARCENY and type
It is probable that any newer version of the collector can be subsitituted for version 4.14. If you do use a newer version, check the collector's config.h file to make sure that the symbol ALIGN_DOUBLE is defined for the SPARC architecture (on line 477 in version 4.14).
You may not run Scheme code that has been compiled with in-line allocation. In its default configuration, and if the hooks have been installed as explained above, the run-time system will detect such attempts (after the fact, but in a reliable manner), and abort the program. While it would be possible for the system to recover from such attempts, the performance of the resulting programs would most likely be very poor, and I'm not going to bother.
It is in your best interest to use split heaps, as explained in the manual (Reorganizing a heap image), but this is not required.
Larceny's interface to the collector is not yet full-fledged; many run-time statistics are not gathered because the collector does not provide the necessary hooks. In an effort to make it possible to learn at least something about performance, the previously mentioned hooks have been provided.
The collector uses lazy sweeping, so the time measurements you get are at best a lower bound on GC time, and probably not an accurate statistic. It's better than nothing. It is also reasonably straightforward to account for the time spent in lazy sweeping, but outside the scope of this release.