From 554fd8c5195424bdbcabf5de30fdc183aba391bd Mon Sep 17 00:00:00 2001 From: upstream source tree Date: Sun, 15 Mar 2015 20:14:05 -0400 Subject: obtained gcc-4.6.4.tar.bz2 from upstream website; verified gcc-4.6.4.tar.bz2.sig; imported gcc-4.6.4 source tree from verified upstream tarball. downloading a git-generated archive based on the 'upstream' tag should provide you with a source tree that is binary identical to the one extracted from the above tarball. if you have obtained the source via the command 'git clone', however, do note that line-endings of files in your working directory might differ from line-endings of the respective files in the upstream repository. --- boehm-gc/doc/README | 622 +++++++++++ boehm-gc/doc/README.DGUX386 | 215 ++++ boehm-gc/doc/README.Mac | 385 +++++++ boehm-gc/doc/README.MacOSX | 1 + boehm-gc/doc/README.OS2 | 6 + boehm-gc/doc/README.amiga | 322 ++++++ boehm-gc/doc/README.arm.cross | 68 ++ boehm-gc/doc/README.autoconf | 59 + boehm-gc/doc/README.changes | 2278 ++++++++++++++++++++++++++++++++++++++ boehm-gc/doc/README.contributors | 57 + boehm-gc/doc/README.cords | 53 + boehm-gc/doc/README.darwin | 141 +++ boehm-gc/doc/README.dj | 12 + boehm-gc/doc/README.environment | 151 +++ boehm-gc/doc/README.ews4800 | 81 ++ boehm-gc/doc/README.hp | 18 + boehm-gc/doc/README.linux | 132 +++ boehm-gc/doc/README.macros | 94 ++ boehm-gc/doc/README.rs6000 | 9 + boehm-gc/doc/README.sgi | 41 + boehm-gc/doc/README.solaris2 | 60 + boehm-gc/doc/README.uts | 2 + boehm-gc/doc/README.win32 | 215 ++++ boehm-gc/doc/barrett_diagram | 106 ++ boehm-gc/doc/debugging.html | 306 +++++ boehm-gc/doc/gc.man | 97 ++ boehm-gc/doc/gcdescr.html | 560 ++++++++++ boehm-gc/doc/gcinterface.html | 248 +++++ boehm-gc/doc/leak.html | 197 ++++ boehm-gc/doc/scale.html | 210 ++++ boehm-gc/doc/simple_example.html | 202 ++++ boehm-gc/doc/tree.html | 199 ++++ 32 files changed, 7147 insertions(+) create mode 100644 boehm-gc/doc/README create mode 100644 boehm-gc/doc/README.DGUX386 create mode 100644 boehm-gc/doc/README.Mac create mode 100644 boehm-gc/doc/README.MacOSX create mode 100644 boehm-gc/doc/README.OS2 create mode 100644 boehm-gc/doc/README.amiga create mode 100644 boehm-gc/doc/README.arm.cross create mode 100644 boehm-gc/doc/README.autoconf create mode 100644 boehm-gc/doc/README.changes create mode 100644 boehm-gc/doc/README.contributors create mode 100644 boehm-gc/doc/README.cords create mode 100644 boehm-gc/doc/README.darwin create mode 100644 boehm-gc/doc/README.dj create mode 100644 boehm-gc/doc/README.environment create mode 100644 boehm-gc/doc/README.ews4800 create mode 100644 boehm-gc/doc/README.hp create mode 100644 boehm-gc/doc/README.linux create mode 100644 boehm-gc/doc/README.macros create mode 100644 boehm-gc/doc/README.rs6000 create mode 100644 boehm-gc/doc/README.sgi create mode 100644 boehm-gc/doc/README.solaris2 create mode 100644 boehm-gc/doc/README.uts create mode 100644 boehm-gc/doc/README.win32 create mode 100644 boehm-gc/doc/barrett_diagram create mode 100644 boehm-gc/doc/debugging.html create mode 100644 boehm-gc/doc/gc.man create mode 100644 boehm-gc/doc/gcdescr.html create mode 100644 boehm-gc/doc/gcinterface.html create mode 100644 boehm-gc/doc/leak.html create mode 100644 boehm-gc/doc/scale.html create mode 100644 boehm-gc/doc/simple_example.html create mode 100644 boehm-gc/doc/tree.html (limited to 'boehm-gc/doc') diff --git a/boehm-gc/doc/README b/boehm-gc/doc/README new file mode 100644 index 000000000..a19cb3021 --- /dev/null +++ b/boehm-gc/doc/README @@ -0,0 +1,622 @@ +Copyright (c) 1988, 1989 Hans-J. Boehm, Alan J. Demers +Copyright (c) 1991-1996 by Xerox Corporation. All rights reserved. +Copyright (c) 1996-1999 by Silicon Graphics. All rights reserved. +Copyright (c) 1999-2004 Hewlett-Packard Development Company, L.P. + +The file linux_threads.c is also +Copyright (c) 1998 by Fergus Henderson. All rights reserved. + +The files Makefile.am, and configure.in are +Copyright (c) 2001 by Red Hat Inc. All rights reserved. + +Several files supporting GNU-style builds are copyrighted by the Free +Software Foundation, and carry a different license from that given +below. + +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. + +A few of the files needed to use the GNU-style build procedure come with +slightly different licenses, though they are all similar in spirit. A few +are GPL'ed, but with an exception that should cover all uses in the +collector. (If you are concerned about such things, I recommend you look +at the notice in config.guess or ltmain.sh.) + +This is version 6.6 of a conservative garbage collector for C and C++. + +You might find a more recent version of this at + +http://www.hpl.hp.com/personal/Hans_Boehm/gc + +OVERVIEW + + This is intended to be a general purpose, garbage collecting storage +allocator. The algorithms used are described in: + +Boehm, H., and M. Weiser, "Garbage Collection in an Uncooperative Environment", +Software Practice & Experience, September 1988, pp. 807-820. + +Boehm, H., A. Demers, and S. Shenker, "Mostly Parallel Garbage Collection", +Proceedings of the ACM SIGPLAN '91 Conference on Programming Language Design +and Implementation, SIGPLAN Notices 26, 6 (June 1991), pp. 157-164. + +Boehm, H., "Space Efficient Conservative Garbage Collection", Proceedings +of the ACM SIGPLAN '91 Conference on Programming Language Design and +Implementation, SIGPLAN Notices 28, 6 (June 1993), pp. 197-206. + +Boehm H., "Reducing Garbage Collector Cache Misses", Proceedings of the +2000 International Symposium on Memory Management. + + Possible interactions between the collector and optimizing compilers are +discussed in + +Boehm, H., and D. Chase, "A Proposal for GC-safe C Compilation", +The Journal of C Language Translation 4, 2 (December 1992). + +and + +Boehm H., "Simple GC-safe Compilation", Proceedings +of the ACM SIGPLAN '96 Conference on Programming Language Design and +Implementation. + +(Some of these are also available from +http://www.hpl.hp.com/personal/Hans_Boehm/papers/, among other places.) + + Unlike the collector described in the second reference, this collector +operates either with the mutator stopped during the entire collection +(default) or incrementally during allocations. (The latter is supported +on only a few machines.) On the most common platforms, it can be built +with or without thread support. On a few platforms, it can take advantage +of a multiprocessor to speed up garbage collection. + + Many of the ideas underlying the collector have previously been explored +by others. Notably, some of the run-time systems developed at Xerox PARC +in the early 1980s conservatively scanned thread stacks to locate possible +pointers (cf. Paul Rovner, "On Adding Garbage Collection and Runtime Types +to a Strongly-Typed Statically Checked, Concurrent Language" Xerox PARC +CSL 84-7). Doug McIlroy wrote a simpler fully conservative collector that +was part of version 8 UNIX (tm), but appears to not have received +widespread use. + + Rudimentary tools for use of the collector as a leak detector are included +(see http://www.hpl.hp.com/personal/Hans_Boehm/gc/leak.html), +as is a fairly sophisticated string package "cord" that makes use of the +collector. (See doc/README.cords and H.-J. Boehm, R. Atkinson, and M. Plass, +"Ropes: An Alternative to Strings", Software Practice and Experience 25, 12 +(December 1995), pp. 1315-1330. This is very similar to the "rope" package +in Xerox Cedar, or the "rope" package in the SGI STL or the g++ distribution.) + +Further collector documantation can be found at + +http://www.hpl.hp.com/personal/Hans_Boehm/gc + + +GENERAL DESCRIPTION + + This is a garbage collecting storage allocator that is intended to be +used as a plug-in replacement for C's malloc. + + Since the collector does not require pointers to be tagged, it does not +attempt to ensure that all inaccessible storage is reclaimed. However, +in our experience, it is typically more successful at reclaiming unused +memory than most C programs using explicit deallocation. Unlike manually +introduced leaks, the amount of unreclaimed memory typically stays +bounded. + + In the following, an "object" is defined to be a region of memory allocated +by the routines described below. + + Any objects not intended to be collected must be pointed to either +from other such accessible objects, or from the registers, +stack, data, or statically allocated bss segments. Pointers from +the stack or registers may point to anywhere inside an object. +The same is true for heap pointers if the collector is compiled with + ALL_INTERIOR_POINTERS defined, as is now the default. + +Compiling without ALL_INTERIOR_POINTERS may reduce accidental retention +of garbage objects, by requiring pointers from the heap to to the beginning +of an object. But this no longer appears to be a significant +issue for most programs. + +There are a number of routines which modify the pointer recognition +algorithm. GC_register_displacement allows certain interior pointers +to be recognized even if ALL_INTERIOR_POINTERS is nor defined. +GC_malloc_ignore_off_page allows some pointers into the middle of large objects +to be disregarded, greatly reducing the probablility of accidental +retention of large objects. For most purposes it seems best to compile +with ALL_INTERIOR_POINTERS and to use GC_malloc_ignore_off_page if +you get collector warnings from allocations of very large objects. +See README.debugging for details. + + WARNING: pointers inside memory allocated by the standard "malloc" are not +seen by the garbage collector. Thus objects pointed to only from such a +region may be prematurely deallocated. It is thus suggested that the +standard "malloc" be used only for memory regions, such as I/O buffers, that +are guaranteed not to contain pointers to garbage collectable memory. +Pointers in C language automatic, static, or register variables, +are correctly recognized. (Note that GC_malloc_uncollectable has semantics +similar to standard malloc, but allocates objects that are traced by the +collector.) + + WARNING: the collector does not always know how to find pointers in data +areas that are associated with dynamic libraries. This is easy to +remedy IF you know how to find those data areas on your operating +system (see GC_add_roots). Code for doing this under SunOS, IRIX 5.X and 6.X, +HP/UX, Alpha OSF/1, Linux, and win32 is included and used by default. (See +README.win32 for win32 details.) On other systems pointers from dynamic +library data areas may not be considered by the collector. +If you're writing a program that depends on the collector scanning +dynamic library data areas, it may be a good idea to include at least +one call to GC_is_visible() to ensure that those areas are visible +to the collector. + + Note that the garbage collector does not need to be informed of shared +read-only data. However if the shared library mechanism can introduce +discontiguous data areas that may contain pointers, then the collector does +need to be informed. + + Signal processing for most signals may be deferred during collection, +and during uninterruptible parts of the allocation process. +Like standard ANSI C mallocs, by default it is unsafe to invoke +malloc (and other GC routines) from a signal handler while another +malloc call may be in progress. Removing -DNO_SIGNALS from Makefile +attempts to remedy that. But that may not be reliable with a compiler that +substantially reorders memory operations inside GC_malloc. + + The allocator/collector can also be configured for thread-safe operation. +(Full signal safety can also be achieved, but only at the cost of two system +calls per malloc, which is usually unacceptable.) +WARNING: the collector does not guarantee to scan thread-local storage +(e.g. of the kind accessed with pthread_getspecific()). The collector +does scan thread stacks, though, so generally the best solution is to +ensure that any pointers stored in thread-local storage are also +stored on the thread's stack for the duration of their lifetime. +(This is arguably a longstanding bug, but it hasn't been fixed yet.) + +INSTALLATION AND PORTABILITY + + As distributed, the macro SILENT is defined in Makefile. +In the event of problems, this can be removed to obtain a moderate +amount of descriptive output for each collection. +(The given statistics exhibit a few peculiarities. +Things don't appear to add up for a variety of reasons, most notably +fragmentation losses. These are probably much more significant for the +contrived program "test.c" than for your application.) + + Note that typing "make test" will automatically build the collector +and then run setjmp_test and gctest. Setjmp_test will give you information +about configuring the collector, which is useful primarily if you have +a machine that's not already supported. Gctest is a somewhat superficial +test of collector functionality. Failure is indicated by a core dump or +a message to the effect that the collector is broken. Gctest takes about +35 seconds to run on a SPARCstation 2. It may use up to 8 MB of memory. (The +multi-threaded version will use more. 64-bit versions may use more.) +"Make test" will also, as its last step, attempt to build and test the +"cord" string library. This will fail without an ANSI C compiler, but +the garbage collector itself should still be usable. + + The Makefile will generate a library gc.a which you should link against. +Typing "make cords" will add the cord library to gc.a. +Note that this requires an ANSI C compiler. + + It is suggested that if you need to replace a piece of the collector +(e.g. GC_mark_rts.c) you simply list your version ahead of gc.a on the +ld command line, rather than replacing the one in gc.a. (This will +generate numerous warnings under some versions of AIX, but it still +works.) + + All include files that need to be used by clients will be put in the +include subdirectory. (Normally this is just gc.h. "Make cords" adds +"cord.h" and "ec.h".) + + The collector currently is designed to run essentially unmodified on +machines that use a flat 32-bit or 64-bit address space. +That includes the vast majority of Workstations and X86 (X >= 3) PCs. +(The list here was deleted because it was getting too long and constantly +out of date.) + It does NOT run under plain 16-bit DOS or Windows 3.X. There are however +various packages (e.g. win32s, djgpp) that allow flat 32-bit address +applications to run under those systemsif the have at least an 80386 processor, +and several of those are compatible with the collector. + + In a few cases (Amiga, OS/2, Win32, MacOS) a separate makefile +or equivalent is supplied. Many of these have separate README.system +files. + + Dynamic libraries are completely supported only under SunOS/Solaris, +(and even that support is not functional on the last Sun 3 release), +Linux, FreeBSD, NetBSD, IRIX 5&6, HP/UX, Win32 (not Win32S) and OSF/1 +on DEC AXP machines plus perhaps a few others listed near the top +of dyn_load.c. On other machines we recommend that you do one of +the following: + + 1) Add dynamic library support (and send us the code). + 2) Use static versions of the libraries. + 3) Arrange for dynamic libraries to use the standard malloc. + This is still dangerous if the library stores a pointer to a + garbage collected object. But nearly all standard interfaces + prohibit this, because they deal correctly with pointers + to stack allocated objects. (Strtok is an exception. Don't + use it.) + + In all cases we assume that pointer alignment is consistent with that +enforced by the standard C compilers. If you use a nonstandard compiler +you may have to adjust the alignment parameters defined in gc_priv.h. +Note that this may also be an issue with packed records/structs, if those +enforce less alignment for pointers. + + A port to a machine that is not byte addressed, or does not use 32 bit +or 64 bit addresses will require a major effort. A port to plain MSDOS +or win16 is hard. + + For machines not already mentioned, or for nonstandard compilers, the +following are likely to require change: + +1. The parameters in gcconfig.h. + The parameters that will usually require adjustment are + STACKBOTTOM, ALIGNMENT and DATASTART. Setjmp_test + prints its guesses of the first two. + DATASTART should be an expression for computing the + address of the beginning of the data segment. This can often be + &etext. But some memory management units require that there be + some unmapped space between the text and the data segment. Thus + it may be more complicated. On UNIX systems, this is rarely + documented. But the adb "$m" command may be helpful. (Note + that DATASTART will usually be a function of &etext. Thus a + single experiment is usually insufficient.) + STACKBOTTOM is used to initialize GC_stackbottom, which + should be a sufficient approximation to the coldest stack address. + On some machines, it is difficult to obtain such a value that is + valid across a variety of MMUs, OS releases, etc. A number of + alternatives exist for using the collector in spite of this. See the + discussion in gcconfig.h immediately preceding the various + definitions of STACKBOTTOM. + +2. mach_dep.c. + The most important routine here is one to mark from registers. + The distributed file includes a generic hack (based on setjmp) that + happens to work on many machines, and may work on yours. Try + compiling and running setjmp_t.c to see whether it has a chance of + working. (This is not correct C, so don't blame your compiler if it + doesn't work. Based on limited experience, register window machines + are likely to cause trouble. If your version of setjmp claims that + all accessible variables, including registers, have the value they + had at the time of the longjmp, it also will not work. Vanilla 4.2 BSD + on Vaxen makes such a claim. SunOS does not.) + If your compiler does not allow in-line assembly code, or if you prefer + not to use such a facility, mach_dep.c may be replaced by a .s file + (as we did for the MIPS machine and the PC/RT). + At this point enough architectures are supported by mach_dep.c + that you will rarely need to do more than adjust for assembler + syntax. + +3. os_dep.c (and gc_priv.h). + Several kinds of operating system dependent routines reside here. + Many are optional. Several are invoked only through corresponding + macros in gc_priv.h, which may also be redefined as appropriate. + The routine GC_register_data_segments is crucial. It registers static + data areas that must be traversed by the collector. (User calls to + GC_add_roots may sometimes be used for similar effect.) + Routines to obtain memory from the OS also reside here. + Alternatively this can be done entirely by the macro GET_MEM + defined in gc_priv.h. Routines to disable and reenable signals + also reside here if they are need by the macros DISABLE_SIGNALS + and ENABLE_SIGNALS defined in gc_priv.h. + In a multithreaded environment, the macros LOCK and UNLOCK + in gc_priv.h will need to be suitably redefined. + The incremental collector requires page dirty information, which + is acquired through routines defined in os_dep.c. Unless directed + otherwise by gcconfig.h, these are implemented as stubs that simply + treat all pages as dirty. (This of course makes the incremental + collector much less useful.) + +4. dyn_load.c + This provides a routine that allows the collector to scan data + segments associated with dynamic libraries. Often it is not + necessary to provide this routine unless user-written dynamic + libraries are used. + + For a different version of UN*X or different machines using the +Motorola 68000, Vax, SPARC, 80386, NS 32000, PC/RT, or MIPS architecture, +it should frequently suffice to change definitions in gcconfig.h. + + +THE C INTERFACE TO THE ALLOCATOR + + The following routines are intended to be directly called by the user. +Note that usually only GC_malloc is necessary. GC_clear_roots and GC_add_roots +calls may be required if the collector has to trace from nonstandard places +(e.g. from dynamic library data areas on a machine on which the +collector doesn't already understand them.) On some machines, it may +be desirable to set GC_stacktop to a good approximation of the stack base. +(This enhances code portability on HP PA machines, since there is no +good way for the collector to compute this value.) Client code may include +"gc.h", which defines all of the following, plus many others. + +1) GC_malloc(nbytes) + - allocate an object of size nbytes. Unlike malloc, the object is + cleared before being returned to the user. Gc_malloc will + invoke the garbage collector when it determines this to be appropriate. + GC_malloc may return 0 if it is unable to acquire sufficient + space from the operating system. This is the most probable + consequence of running out of space. Other possible consequences + are that a function call will fail due to lack of stack space, + or that the collector will fail in other ways because it cannot + maintain its internal data structures, or that a crucial system + process will fail and take down the machine. Most of these + possibilities are independent of the malloc implementation. + +2) GC_malloc_atomic(nbytes) + - allocate an object of size nbytes that is guaranteed not to contain any + pointers. The returned object is not guaranteed to be cleared. + (Can always be replaced by GC_malloc, but results in faster collection + times. The collector will probably run faster if large character + arrays, etc. are allocated with GC_malloc_atomic than if they are + statically allocated.) + +3) GC_realloc(object, new_size) + - change the size of object to be new_size. Returns a pointer to the + new object, which may, or may not, be the same as the pointer to + the old object. The new object is taken to be atomic iff the old one + was. If the new object is composite and larger than the original object, + then the newly added bytes are cleared (we hope). This is very likely + to allocate a new object, unless MERGE_SIZES is defined in gc_priv.h. + Even then, it is likely to recycle the old object only if the object + is grown in small additive increments (which, we claim, is generally bad + coding practice.) + +4) GC_free(object) + - explicitly deallocate an object returned by GC_malloc or + GC_malloc_atomic. Not necessary, but can be used to minimize + collections if performance is critical. Probably a performance + loss for very small objects (<= 8 bytes). + +5) GC_expand_hp(bytes) + - Explicitly increase the heap size. (This is normally done automatically + if a garbage collection failed to GC_reclaim enough memory. Explicit + calls to GC_expand_hp may prevent unnecessarily frequent collections at + program startup.) + +6) GC_malloc_ignore_off_page(bytes) + - identical to GC_malloc, but the client promises to keep a pointer to + the somewhere within the first 256 bytes of the object while it is + live. (This pointer should nortmally be declared volatile to prevent + interference from compiler optimizations.) This is the recommended + way to allocate anything that is likely to be larger than 100Kbytes + or so. (GC_malloc may result in failure to reclaim such objects.) + +7) GC_set_warn_proc(proc) + - Can be used to redirect warnings from the collector. Such warnings + should be rare, and should not be ignored during code development. + +8) GC_enable_incremental() + - Enables generational and incremental collection. Useful for large + heaps on machines that provide access to page dirty information. + Some dirty bit implementations may interfere with debugging + (by catching address faults) and place restrictions on heap arguments + to system calls (since write faults inside a system call may not be + handled well). + +9) Several routines to allow for registration of finalization code. + User supplied finalization code may be invoked when an object becomes + unreachable. To call (*f)(obj, x) when obj becomes inaccessible, use + GC_register_finalizer(obj, f, x, 0, 0); + For more sophisticated uses, and for finalization ordering issues, + see gc.h. + + The global variable GC_free_space_divisor may be adjusted up from its +default value of 4 to use less space and more collection time, or down for +the opposite effect. Setting it to 1 or 0 will effectively disable collections +and cause all allocations to simply grow the heap. + + The variable GC_non_gc_bytes, which is normally 0, may be changed to reflect +the amount of memory allocated by the above routines that should not be +considered as a candidate for collection. Careless use may, of course, result +in excessive memory consumption. + + Some additional tuning is possible through the parameters defined +near the top of gc_priv.h. + + If only GC_malloc is intended to be used, it might be appropriate to define: + +#define malloc(n) GC_malloc(n) +#define calloc(m,n) GC_malloc((m)*(n)) + + For small pieces of VERY allocation intensive code, gc_inl.h +includes some allocation macros that may be used in place of GC_malloc +and friends. + + All externally visible names in the garbage collector start with "GC_". +To avoid name conflicts, client code should avoid this prefix, except when +accessing garbage collector routines or variables. + + There are provisions for allocation with explicit type information. +This is rarely necessary. Details can be found in gc_typed.h. + +THE C++ INTERFACE TO THE ALLOCATOR: + + The Ellis-Hull C++ interface to the collector is included in +the collector distribution. If you intend to use this, type +"make c++" after the initial build of the collector is complete. +See gc_cpp.h for the definition of the interface. This interface +tries to approximate the Ellis-Detlefs C++ garbage collection +proposal without compiler changes. + +Cautions: +1. Arrays allocated without new placement syntax are +allocated as uncollectable objects. They are traced by the +collector, but will not be reclaimed. + +2. Failure to use "make c++" in combination with (1) will +result in arrays allocated using the default new operator. +This is likely to result in disaster without linker warnings. + +3. If your compiler supports an overloaded new[] operator, +then gc_cpp.cc and gc_cpp.h should be suitably modified. + +4. Many current C++ compilers have deficiencies that +break some of the functionality. See the comments in gc_cpp.h +for suggested workarounds. + +USE AS LEAK DETECTOR: + + The collector may be used to track down leaks in C programs that are +intended to run with malloc/free (e.g. code with extreme real-time or +portability constraints). To do so define FIND_LEAK in Makefile +This will cause the collector to invoke the report_leak +routine defined near the top of reclaim.c whenever an inaccessible +object is found that has not been explicitly freed. Such objects will +also be automatically reclaimed. + Productive use of this facility normally involves redefining report_leak +to do something more intelligent. This typically requires annotating +objects with additional information (e.g. creation time stack trace) that +identifies their origin. Such code is typically not very portable, and is +not included here, except on SPARC machines. + If all objects are allocated with GC_DEBUG_MALLOC (see next section), +then the default version of report_leak will report the source file +and line number at which the leaked object was allocated. This may +sometimes be sufficient. (On SPARC/SUNOS4 machines, it will also report +a cryptic stack trace. This can often be turned into a sympolic stack +trace by invoking program "foo" with "callprocs foo". Callprocs is +a short shell script that invokes adb to expand program counter values +to symbolic addresses. It was largely supplied by Scott Schwartz.) + Note that the debugging facilities described in the next section can +sometimes be slightly LESS effective in leak finding mode, since in +leak finding mode, GC_debug_free actually results in reuse of the object. +(Otherwise the object is simply marked invalid.) Also note that the test +program is not designed to run meaningfully in FIND_LEAK mode. +Use "make gc.a" to build the collector. + +DEBUGGING FACILITIES: + + The routines GC_debug_malloc, GC_debug_malloc_atomic, GC_debug_realloc, +and GC_debug_free provide an alternate interface to the collector, which +provides some help with memory overwrite errors, and the like. +Objects allocated in this way are annotated with additional +information. Some of this information is checked during garbage +collections, and detected inconsistencies are reported to stderr. + + Simple cases of writing past the end of an allocated object should +be caught if the object is explicitly deallocated, or if the +collector is invoked while the object is live. The first deallocation +of an object will clear the debugging info associated with an +object, so accidentally repeated calls to GC_debug_free will report the +deallocation of an object without debugging information. Out of +memory errors will be reported to stderr, in addition to returning +NIL. + + GC_debug_malloc checking during garbage collection is enabled +with the first call to GC_debug_malloc. This will result in some +slowdown during collections. If frequent heap checks are desired, +this can be achieved by explicitly invoking GC_gcollect, e.g. from +the debugger. + + GC_debug_malloc allocated objects should not be passed to GC_realloc +or GC_free, and conversely. It is however acceptable to allocate only +some objects with GC_debug_malloc, and to use GC_malloc for other objects, +provided the two pools are kept distinct. In this case, there is a very +low probablility that GC_malloc allocated objects may be misidentified as +having been overwritten. This should happen with probability at most +one in 2**32. This probability is zero if GC_debug_malloc is never called. + + GC_debug_malloc, GC_malloc_atomic, and GC_debug_realloc take two +additional trailing arguments, a string and an integer. These are not +interpreted by the allocator. They are stored in the object (the string is +not copied). If an error involving the object is detected, they are printed. + + The macros GC_MALLOC, GC_MALLOC_ATOMIC, GC_REALLOC, GC_FREE, and +GC_REGISTER_FINALIZER are also provided. These require the same arguments +as the corresponding (nondebugging) routines. If gc.h is included +with GC_DEBUG defined, they call the debugging versions of these +functions, passing the current file name and line number as the two +extra arguments, where appropriate. If gc.h is included without GC_DEBUG +defined, then all these macros will instead be defined to their nondebugging +equivalents. (GC_REGISTER_FINALIZER is necessary, since pointers to +objects with debugging information are really pointers to a displacement +of 16 bytes form the object beginning, and some translation is necessary +when finalization routines are invoked. For details, about what's stored +in the header, see the definition of the type oh in debug_malloc.c) + +INCREMENTAL/GENERATIONAL COLLECTION: + +The collector normally interrupts client code for the duration of +a garbage collection mark phase. This may be unacceptable if interactive +response is needed for programs with large heaps. The collector +can also run in a "generational" mode, in which it usually attempts to +collect only objects allocated since the last garbage collection. +Furthermore, in this mode, garbage collections run mostly incrementally, +with a small amount of work performed in response to each of a large number of +GC_malloc requests. + +This mode is enabled by a call to GC_enable_incremental(). + +Incremental and generational collection is effective in reducing +pause times only if the collector has some way to tell which objects +or pages have been recently modified. The collector uses two sources +of information: + +1. Information provided by the VM system. This may be provided in +one of several forms. Under Solaris 2.X (and potentially under other +similar systems) information on dirty pages can be read from the +/proc file system. Under other systems (currently SunOS4.X) it is +possible to write-protect the heap, and catch the resulting faults. +On these systems we require that system calls writing to the heap +(other than read) be handled specially by client code. +See os_dep.c for details. + +2. Information supplied by the programmer. We define "stubborn" +objects to be objects that are rarely changed. Such an object +can be allocated (and enabled for writing) with GC_malloc_stubborn. +Once it has been initialized, the collector should be informed with +a call to GC_end_stubborn_change. Subsequent writes that store +pointers into the object must be preceded by a call to +GC_change_stubborn. + +This mechanism performs best for objects that are written only for +initialization, and such that only one stubborn object is writable +at once. It is typically not worth using for short-lived +objects. Stubborn objects are treated less efficiently than pointerfree +(atomic) objects. + +A rough rule of thumb is that, in the absence of VM information, garbage +collection pauses are proportional to the amount of pointerful storage +plus the amount of modified "stubborn" storage that is reachable during +the collection. + +Initial allocation of stubborn objects takes longer than allocation +of other objects, since other data structures need to be maintained. + +We recommend against random use of stubborn objects in client +code, since bugs caused by inappropriate writes to stubborn objects +are likely to be very infrequently observed and hard to trace. +However, their use may be appropriate in a few carefully written +library routines that do not make the objects themselves available +for writing by client code. + + +BUGS: + + Any memory that does not have a recognizable pointer to it will be +reclaimed. Exclusive-or'ing forward and backward links in a list +doesn't cut it. + Some C optimizers may lose the last undisguised pointer to a memory +object as a consequence of clever optimizations. This has almost +never been observed in practice. Send mail to boehm@acm.org +for suggestions on how to fix your compiler. + This is not a real-time collector. In the standard configuration, +percentage of time required for collection should be constant across +heap sizes. But collection pauses will increase for larger heaps. +(On SPARCstation 2s collection times will be on the order of 300 msecs +per MB of accessible memory that needs to be scanned. Your mileage +may vary.) The incremental/generational collection facility helps, +but is portable only if "stubborn" allocation is used. + Please address bug reports to boehm@acm.org. If you are +contemplating a major addition, you might also send mail to ask whether +it's already been done (or whether we tried and discarded it). + diff --git a/boehm-gc/doc/README.DGUX386 b/boehm-gc/doc/README.DGUX386 new file mode 100644 index 000000000..9d6d84788 --- /dev/null +++ b/boehm-gc/doc/README.DGUX386 @@ -0,0 +1,215 @@ + Garbage Collector (parallel iversion) for ix86 DG/UX Release R4.20MU07 + + + *READ* the file README.QUICK. + + You need the GCC-3.0.3 rev (DG/UX) compiler to build this tree. + This compiler has the new "dgux386" threads package implemented. + It also supports the switch "-pthread" needed to link correctly + the DG/UX's -lrte -lthread with -lgcc and the system's -lc. + Finally we support parralleli-mark for the SMP DG/UX machines. + To build the garbage collector do: + + ./configure --enable-parallel-mark + make + make gctest + + Before you run "gctest" you need to set your LD_LIBRARY_PATH + correctly so that "gctest" can find the shared library libgc. + Alternatively you can do a configuration + + ./configure --enable-parallel-mark --disable-shared + + to build only the static version of libgc. + + To enable debugging messages please do: + 1) Add the "--enable-full-debug" flag during configuration. + 2) Edit the file linux-threads.c and uncommnect the line: + + /* #define DEBUG_THREADS 1 */ to ---> + + #define DEBUG_THREADS 1 + + Then give "make" as usual. + + In a machine with 4 CPUs (my own machine) the option parallel + mark (aka --enable-parallel-mark) makes a BIG difference. + + Takis Psarogiannakopoulos + University of Cambridge + Centre for Mathematical Sciences + Department of Pure Mathematics + Wilberforce Road + Cambridge CB3 0WB ,UK , + January 2002 + + +Note (HB): + The integration of this patch is currently not complete. + The following patches against 6.1alpha3 where hard to move + to alpha4, and are not integrated. There may also be minor + problems with stylistic corrections made by me. + + +--- ltconfig.ORIG Mon Jan 28 20:22:18 2002 ++++ ltconfig Mon Jan 28 20:44:00 2002 +@@ -689,6 +689,11 @@ + pic_flag=-Kconform_pic + fi + ;; ++ dgux*) ++ pic_flag='-fPIC' ++ link_static='-Bstatic' ++ wl='-Wl,' ++ ;; + *) + pic_flag='-fPIC' + ;; +@@ -718,6 +723,12 @@ + # We can build DLLs from non-PIC. + ;; + ++ dgux*) ++ pic_flag='-KPIC' ++ link_static='-Bstatic' ++ wl='-Wl,' ++ ;; ++ + osf3* | osf4* | osf5*) + # All OSF/1 code is PIC. + wl='-Wl,' +@@ -1154,6 +1165,22 @@ + fi + ;; + ++ dgux*) ++ ld_shlibs=yes ++ # For both C/C++ ommit the deplibs. This is because we relying on the fact ++ # that compilation of execitables will put them in correct order ++ # in any case and sometimes are wrong when listed as deplibs (or missing some deplibs) ++ # However when GNU ld and --whole-archive needs to be used we have the problem ++ # that if the -fPIC *_s.a archive is linked through deplibs list we ommiting crucial ++ # .lo/.o files from the created shared lib. This I think is not the case here. ++ archive_cmds='$CC -shared -h $soname -o $lib $libobjs $linkopts' ++ thread_safe_flag_spec='-pthread' ++ wlarc= ++ hardcode_libdir_flag_spec='-L$libdir' ++ hardcode_shlibpath_var=no ++ ac_cv_archive_cmds_needs_lc=no ++ ;; ++ + cygwin* | mingw*) + # hardcode_libdir_flag_spec is actually meaningless, as there is + # no search path for DLLs. +@@ -1497,7 +1524,7 @@ + ;; + + dgux*) +- archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linkopts' ++ archive_cmds='$CC -shared -h $soname -o $lib $libobjs $linkopts' + hardcode_libdir_flag_spec='-L$libdir' + hardcode_shlibpath_var=no + ;; +@@ -2092,12 +2119,17 @@ + ;; + + dgux*) +- version_type=linux ++ version_type=dgux + need_lib_prefix=no + need_version=no +- library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major $libname.so' +- soname_spec='${libname}${release}.so$major' ++ library_names_spec='$libname.so$versuffix' ++ soname_spec='$libname.so$versuffix' + shlibpath_var=LD_LIBRARY_PATH ++ thread_safe_flag_spec='-pthread' ++ wlarc= ++ hardcode_libdir_flag_spec='-L$libdir' ++ hardcode_shlibpath_var=no ++ ac_cv_archive_cmds_needs_lc=no + ;; + + sysv4*MP*) + + +--- ltmain.sh.ORIG Mon Jan 28 20:31:18 2002 ++++ ltmain.sh Tue Jan 29 00:11:29 2002 +@@ -1072,11 +1072,38 @@ + esac + ;; + ++ -thread*) ++ # DG/UX GCC 2.95.x, 3.x.x rev (DG/UX) links -lthread ++ # with the switch -threads ++ if test "$arg" = "-threads"; then ++ case "$host" in ++ i[3456]86-*-dgux*) ++ deplibs="$deplibs $arg" ++ continue ++ ;; ++ esac ++ fi ++ ;; ++ ++ -pthread*) ++ # DG/UX GCC 2.95.x, 3.x.x rev (DG/UX) links -lthread ++ # with the switch -pthread ++ if test "$arg" = "-pthread"; then ++ case "$host" in ++ i[3456]86-*-dgux*) ++ deplibs="$deplibs $arg" ++ continue ++ ;; ++ esac ++ fi ++ ;; ++ + -l*) + if test "$arg" = "-lc"; then + case "$host" in +- *-*-cygwin* | *-*-mingw* | *-*-os2* | *-*-beos*) ++ *-*-cygwin* | *-*-mingw* | *-*-os2* | *-*-beos* | i[3456]86-*-dgux*) + # These systems don't actually have c library (as such) ++ # It is wrong in DG/UX to add -lc when creating shared/dynamic objs/libs + continue + ;; + esac +@@ -1248,6 +1275,12 @@ + temp_deplibs= + for deplib in $dependency_libs; do + case "$deplib" in ++ -thread*) ++ temp_deplibs="$temp_deplibs $deplib" ++ ;; ++ -pthread) ++ temp_deplibs="$temp_deplibs $deplib" ++ ;; + -R*) temp_xrpath=`$echo "X$deplib" | $Xsed -e 's/^-R//'` + case " $rpath $xrpath " in + *" $temp_xrpath "*) ;; +@@ -1709,6 +1742,13 @@ + done + ;; + ++ dgux) ++ # Leave mostly blank for DG/UX ++ major= ++ versuffix=".$current.$revision"; ++ verstring= ++ ;; ++ + linux) + major=.`expr $current - $age` + versuffix="$major.$age.$revision" +@@ -1792,8 +1832,9 @@ + + dependency_libs="$deplibs" + case "$host" in +- *-*-cygwin* | *-*-mingw* | *-*-os2* | *-*-beos*) ++ *-*-cygwin* | *-*-mingw* | *-*-os2* | *-*-beos* | i[3456]86-*-dgux*) + # these systems don't actually have a c library (as such)! ++ # It is wrong in DG/UX to add -lc when creating shared/dynamic objs/libs + ;; + *) + # Add libc to deplibs on all other systems. diff --git a/boehm-gc/doc/README.Mac b/boehm-gc/doc/README.Mac new file mode 100644 index 000000000..04f468251 --- /dev/null +++ b/boehm-gc/doc/README.Mac @@ -0,0 +1,385 @@ +Patrick Beard's Notes for building GC v4.12 with CodeWarrior Pro 2: +---------------------------------------------------------------------------- +The current build environment for the collector is CodeWarrior Pro 2. +Projects for CodeWarrior Pro 2 (and for quite a few older versions) +are distributed in the file Mac_projects.sit.hqx. The project file +:Mac_projects:gc.prj builds static library versions of the collector. +:Mac_projects:gctest.prj builds the GC test suite. + +Configuring the collector is still done by editing the files +:Mac_files:MacOS_config.h and :Mac_files:MacOS_Test_config.h. + +Lars Farm's suggestions on building the collector: +---------------------------------------------------------------------------- +Garbage Collection on MacOS - a manual 'MakeFile' +------------------------------------------------- + +Project files and IDE's are great on the Macintosh, but they do have +problems when used as distribution media. This note tries to provide +porting instructions in pure TEXT form to avoid those problems. A manual +'makefile' if you like. + + GC version: 4.12a2 + Codewarrior: CWPro1 + date: 18 July 1997 + +The notes may or may not apply to earlier or later versions of the +GC/CWPro. Actually, they do apply to earlier versions of both except that +until recently a project could only build one target so each target was a +separate project. The notes will most likely apply to future versions too. +Possibly with minor tweaks. + +This is just to record my experiences. These notes do not mean I now +provide a supported port of the GC to MacOS. It works for me. If it works +for you, great. If it doesn't, sorry, try again...;-) Still, if you find +errors, please let me know. + + mailto: lars.farm@ite.mh.se + + address: Lars Farm + Krönvägen 33b + 856 44 Sundsvall + Sweden + +Porting to MacOS is a bit more complex than it first seems. Which MacOS? +68K/PowerPC? Which compiler? Each supports both 68K and PowerPC and offer a +large number of (unique to each environment) compiler settings. Each +combination of compiler/68K/PPC/settings require a unique combination of +standard libraries. And the IDE's does not select them for you. They don't +even check that the library is built with compatible setting and this is +the major source of problems when porting the GC (and otherwise too). + +You will have to make choices when you configure the GC. I've made some +choices here, but there are other combinations of settings and #defines +that work too. + +As for target settings the major obstacles may be: +- 68K Processor: check "4-byte Ints". +- PPC Processor: uncheck "Store Static Data in TOC". + +What you need to do: +=================== + +1) Build the GC as a library +2) Test that the library works with 'test.c'. +3) Test that the C++ interface 'gc_cpp.cc/h' works with 'test_cpp.cc'. + +1) The Libraries: +================= +I made one project with four targets (68K/PPC tempmem or appheap). One target +will suffice if you're able to decide which one you want. I wasn't... + +Codewarrior allows a large number of compiler/linker settings. I used these: + +Settings shared by all targets: +------------------------------ +o Access Paths: + - User Paths: the GC folder + - System Paths: {Compiler}:Metrowerks Standard Library: + {Compiler}:MacOS Support:Headers: + {Compiler}:MacOS Support:MacHeaders: +o C/C++ language: + - inlining: normal + - direct to SOM: off + - enable/check: exceptions, RTTI, bool (and if you like pool strings) + +PowerPC target settings +----------------------- +o Target Settings: + - name of target + - MacOS PPC Linker +o PPC Target + - name of library +o C/C++ language + - prefix file as described below +o PPC Processor + - Struct Alignment: PowerPC + - uncheck "Store Static Data in TOC" -- important! + I don't think the others matter, I use full optimization and its ok +o PPC Linker + - Factory Settings (SYM file with full paths, faster linking, dead-strip + static init, Main: __start) + + +68K target settings +------------------- +o Target Settings: + - name of target + - MacOS 68K Linker +o 68K Target + - name of library + - A5 relative data +o C/C++ language + - prefix file as described below +o 68K Processor + - Code model: smart + - Struct alignment: 68K + - FP: SANE + - enable 4-Byte Ints -- important! + I don't think the others matter. I selected... + - enable: 68020 + - enable: global register allocation +o IR Optimizer + - enable: Optimize Space, Optimize Speed + I suppose the others would work too, but haven't tried... +o 68K Linker + - Factory Settings (New Style MacsBug,SYM file with full paths, + A6 Frames, fast link, Merge compiler glue into segment 1, + dead-strip static init) + +Prefix Files to configure the GC sources +---------------------------------------- +The Codewarrior equivalent of commandline compilers -DNAME=X is to use +prefix-files. A TEXT file that is automatically #included before the first byte +of every source file. I used these: + +---- ( cut here ) ---- gc_prefix_tempmem.h -- 68K and PPC ----- + #include "gc_prefix_common.h" + #undef USE_TEMPORARY_MEMORY + #define USE_TEMPORARY_MEMORY +---- ( cut here ) ---- gc_prefix_appmem.h -- 68K and PPC ----- + #include "gc_prefix_common.h" + #undef USE_TEMPORARY_MEMORY +// #define USE_TEMPORARY_MEMORY + +---- ( cut here ) ---- gc_prefix_common.h -------------------- +// gc_prefix_common.h +// ------------------ +// Codewarrior prefix file to configure the GC libraries +// +// prefix files are the Codewarrior equivalent of the +// command line option -Dname=x frequently seen in makefiles + +#if !__MWERKS__ + #error only tried this with Codewarrior +#endif + +#if macintosh + #define MSL_USE_PRECOMPILED_HEADERS 0 + #include + #ifndef __STDC__ + #define __STDC__ 0 + #endif + + // See list of #defines to configure the library in: 'MakeFile' + // see also README + + #define SILENT // no collection messages. In case + // of trouble you might want this off + #define ALL_INTERIOR_POINTERS // follows interior pointers. +//#define DONT_ADD_BYTE_AT_END // disables the padding if defined. +//#define SMALL_CONFIG // whether to use a smaller heap. + #define NO_SIGNALS // signals aren't real on the Macintosh. + #define ATOMIC_UNCOLLECTABLE // GC_malloc_atomic_uncollectable() + + // define either or none as per personal preference + // used in malloc.c + #define REDIRECT_MALLOC GC_malloc +//#define REDIRECT_MALLOC GC_malloc_uncollectable + // if REDIRECT_MALLOC is #defined make sure that the GC library + // is listed before the ANSI/ISO libs in the Codewarrior + // 'Link order' panel +//#define IGNORE_FREE + + // mac specific configs +//#define USE_TEMPORARY_MEMORY // use Macintosh temporary memory. +//#define SHARED_LIBRARY_BUILD // build for use in a shared library. + +#else + // could build Win32 here too, or in the future + // Rhapsody PPC-mach, Rhapsody PPC-MacOS, + // Rhapsody Intel-mach, Rhapsody Intel-Win32,... + // ... ugh this will get messy ... +#endif + +// make sure ints are at least 32-bit +// ( could be set to 16-bit by compiler settings (68K) ) + +struct gc_private_assert_intsize_{ char x[ sizeof(int)>=4 ? 1 : 0 ]; }; + +#if __powerc + #if __option(toc_data) + #error turn off "store static data in TOC" when using GC + // ... or find a way to add TOC to the root set...(?) + #endif +#endif +---- ( cut here ) ---- end of gc_prefix_common.h ----------------- + +Files to build the GC libraries: +-------------------------------- + allchblk.c + alloc.c + blacklst.c + checksums.c + dbg_mlc.c + finalize.c + headers.c + mach_dep.c + MacOS.c -- contains MacOS code + malloc.c + mallocx.c + mark.c + mark_rts.c + misc.c + new_hblk.c + obj_map.c + os_dep.c -- contains MacOS code + ptr_chck.c + reclaim.c + stubborn.c + typd_mlc.c + gc++.cc -- this is 'gc_cpp.cc' with less 'inline' and + -- throw std::bad_alloc when out of memory + -- gc_cpp.cc works just fine too + +2) Test that the library works with 'test.c'. +============================================= + +The test app is just an ordinary ANSI-C console app. Make sure settings +match the library you're testing. + +Files +----- + test.c + the GC library to test -- link order before ANSI libs + suitable Mac+ANSI libraries + +prefix: +------ +---- ( cut here ) ---- gc_prefix_testlib.h -- all libs ----- +#define MSL_USE_PRECOMPILED_HEADERS 0 +#include +#undef NDEBUG + +#define ALL_INTERIOR_POINTERS /* for GC_priv.h */ +---- ( cut here ) ---- + +3) Test that the C++ interface 'gc_cpp.cc/h' works with 'test_cpp.cc'. + +The test app is just an ordinary ANSI-C console app. Make sure settings match +the library you're testing. + +Files +----- + test_cpp.cc + the GC library to test -- link order before ANSI libs + suitable Mac+ANSI libraries + +prefix: +------ +same as for test.c + +For convenience I used one test-project with several targets so that all +test apps are build at once. Two for each library to test: test.c and +gc_app.cc. When I was satisfied that the libraries were ok. I put the +libraries + gc.h + the c++ interface-file in a folder that I then put into +the MSL hierarchy so that I don't have to alter access-paths in projects +that use the GC. + +After that, just add the proper GC library to your project and the GC is in +action! malloc will call GC_malloc and free GC_free, new/delete too. You +don't have to call free or delete. You may have to be a bit cautious about +delete if you're freeing other resources than RAM. See gc_cpp.h. You can +also keep coding as always with delete/free. That works too. If you want, +"include and tweak it's use a bit. + +Symantec SPM +============ +It has been a while since I tried the GC in SPM, but I think that the above +instructions should be sufficient to guide you through in SPM too. SPM +needs to know where the global data is. Use the files 'datastart.c' and +'dataend.c'. Put 'datastart.c' at the top of your project and 'dataend.c' +at the bottom of your project so that all data is surrounded. This is not +needed in Codewarrior because it provides intrinsic variables +__datastart__, __data_end__ that wraps all globals. + +Source Changes (GC 4.12a2) +========================== +Very few. Just one tiny in the GC, not strictly needed. +- MacOS.c line 131 in routine GC_MacFreeTemporaryMemory() + change # if !defined(SHARED_LIBRARY_BUILD) + to # if !defined(SILENT) && !defined(SHARED_LIBRARY_BUILD) + To turn off a message when the application quits (actually, I faked + this change by #defining SHARED_LIBRARY_BUILD in a statically linked + library for more than a year without ill effects but perhaps this is + better). + +- test_cpp.cc + made the first lines of main() look like this: + ------------ + int main( int argc, char* argv[] ) { + #endif + #if macintosh // MacOS + char* argv_[] = {"test_cpp","10"}; // doesn't + argv=argv_; // have a + argc = sizeof(argv_)/sizeof(argv_[0]); // commandline + #endif // + + int i, iters, n; + # ifndef __GNUC__ + alloc dummy_to_fool_the_compiler_into_doing_things_it_currently_cant_handle; + ------------ + +- config.h [now gcconfig.h] + __MWERKS__ does not have to mean MACOS. You can use Codewarrior to + build a Win32 or BeOS library and soon a Rhapsody library. You may + have to change that #if... + + + + It worked for me, hope it works for you. + + Lars Farm + 18 July 1997 +---------------------------------------------------------------------------- + + +Patrick Beard's instructions (may be dated): + +v4.3 of the collector now runs under Symantec C++/THINK C v7.0.4, and +Metrowerks C/C++ v4.5 both 68K and PowerPC. Project files are provided +to build and test the collector under both development systems. + +Configuration +------------- + +To configure the collector, under both development systems, a prefix file +is used to set preprocessor directives. This file is called "MacOS_config.h". +Also to test the collector, "MacOS_Test_config.h" is provided. + +Testing +------- + +To test the collector (always a good idea), build one of the gctest projects, +gctest.¹ (Symantec C++/THINK C), mw/gctest.68K.¹, or mw/gctest.PPC.¹. The +test will ask you how many times to run; 1 should be sufficient. + +Building +-------- + +For your convenience project files for the major Macintosh development +systems are provided. + +For Symantec C++/THINK C, you must build the two projects gclib-1.¹ and +gclib-2.¹. It has to be split up because the collector has more than 32k +of static data and no library can have more than this in the Symantec +environment. (Future versions will probably fix this.) + +For Metrowerks C/C++ 4.5 you build gc.68K.¹/gc.PPC.¹ and the result will +be a library called gc.68K.lib/gc.PPC.lib. + +Using +----- + +Under Symantec C++/THINK C, you can just add the gclib-1.¹ and gclib-2.¹ +projects to your own project. Under Metrowerks, you add gc.68K.lib or +gc.PPC.lib and two additional files. You add the files called datastart.c +and dataend.c to your project, bracketing all files that use the collector. +See mw/gctest.¹ for an example. + +Include the projects/libraries you built above into your own project, +#include "gc.h", and call GC_malloc. You don't have to call GC_free. + + +Patrick C. Beard +January 4, 1995 diff --git a/boehm-gc/doc/README.MacOSX b/boehm-gc/doc/README.MacOSX new file mode 100644 index 000000000..f5333d51a --- /dev/null +++ b/boehm-gc/doc/README.MacOSX @@ -0,0 +1 @@ +See README.darwin for the latest Darwin/MacOSX information. diff --git a/boehm-gc/doc/README.OS2 b/boehm-gc/doc/README.OS2 new file mode 100644 index 000000000..5345bbd0f --- /dev/null +++ b/boehm-gc/doc/README.OS2 @@ -0,0 +1,6 @@ +The code assumes static linking, and a single thread. The editor de has +not been ported. The cord test program has. The supplied OS2_MAKEFILE +assumes the IBM C Set/2 environment, but the code shouldn't. + +Since we haven't figured out hoe to do perform partial links or to build static +libraries, clients currently need to link against a long list of executables. diff --git a/boehm-gc/doc/README.amiga b/boehm-gc/doc/README.amiga new file mode 100644 index 000000000..730dce3fe --- /dev/null +++ b/boehm-gc/doc/README.amiga @@ -0,0 +1,322 @@ +=========================================================================== + Kjetil S. Matheussen's notes (28-11-2000) +=========================================================================== +Compiles under SAS/C again. Should allso still compile under other +amiga compilers without big changes. I haven't checked if it still +works under gcc, because I don't have gcc for amiga. But I have +updated 'Makefile', and hope it compiles fine. + + +WHATS NEW: + +1. + Made a pretty big effort in preventing GCs allocating-functions from returning + chip-mem. + + The lower part of the new file AmigaOS.c does this in various ways, mainly by + wrapping GC_malloc, GC_malloc_atomic, GC_malloc_uncollectable, + GC_malloc_atomic_uncollectable, GC_malloc_stubborn, GC_malloc_ignore_off_page + and GC_malloc_atomic_ignore_off_page. GC_realloc is allso wrapped, but + doesn't do the same effort in preventing to return chip-mem. + Other allocating-functions (f.ex. GC_*_typed_) can probably be + used without any problems, but beware that the warn hook will not be called. + In case of problems, don't define GC_AMIGA_FASTALLOC. + + Programs using more time actually using the memory allocated + (instead of just allocate and free rapidly) have + the most to earn on this, but even gctest now normally runs twice + as fast and uses less memory, on my poor 8MB machine. + + The changes have only effect when there is no more + fast-mem left. But with the way GC works, it + could happen quite often. Beware that an atexit handler had to be added, + so using the abort() function will make a big memory-loss. + If you absolutely must call abort() instead of exit(), try calling + the GC_amiga_free_all_mem function before abort(). + + New amiga-spesific compilation flags: + + GC_AMIGA_FASTALLOC - By NOT defining this option, GC will work like before, + it will not try to force fast-mem out of the OS, and + it will use normal calloc for allocation, and the rest + of the following flags will have no effect. + + GC_AMIGA_ONLYFAST - Makes GC never to return chip-mem. GC_AMIGA_RETRY have + no effect if this flag is set. + + GC_AMIGA_GC - If gc returns NULL, do a GC_gcollect, and try again. This + usually is a success with the standard GC configuration. + It is allso the most important flag to set to prevent + GC from returning chip-mem. Beware that it slows down a lot + when a program is rapidly allocating/deallocating when + theres either very little fast-memory left or verly little + chip-memory left. Its not a very common situation, but gctest + sometimes (very rare) use many minutes because of this. + + GC_AMIGA_RETRY - If gc succeed allocating memory, but it is chip-mem, + try again and see if it is fast-mem. Most of the time, + it will actually return fast-mem for the second try. + I have set max number of retries to 9 or size/5000. You + can change this if you like. (see GC_amiga_rec_alloc()) + + GC_AMIGA_PRINTSTATS - Gather some statistics during the execution of a + program, and prints out the info when the atexit-handler + is called. + + My reccomendation is to set all this flags, except GC_AMIGA_PRINTSTATS and + GC_AMIGA_ONLYFAST. + + If your program demands high response-time, you should + not define GC_AMIGA_GC, and possible allso define GC_AMIGA_ONLYFAST. + GC_AMIGA_RETRY does not seem to slow down much. + + Allso, when compiling up programs, and GC_AMIGA_FASTALLOC was not defined when + compilling gc, you can define GC_AMIGA_MAKINGLIB to avoid having these allocation- + functions wrapped. (see gc.h) + + Note that GC_realloc must not be called before any of + the other above mentioned allocating-functions have been called. (shouldn't be + any programs doing so either, I hope). + + Another note. The allocation-function is wrapped when defining + GC_AMIGA_FASTALLOC by letting the function go thru the new + GC_amiga_allocwrapper_do function-pointer (see gc.h). Means that + sending function-pointers, such as GC_malloc, GC_malloc_atomic, etc., + for later to be called like f.ex this, (*GC_malloc_functionpointer)(size), + will not wrap the function. This is normally not a big problem, unless + all allocation function is called like this, which will cause the + atexit un-allocating function never to be called. Then you either + have to manually add the atexit handler, or call the allocation- + functions function-pointer functions like this; + (*GC_amiga_allocwrapper_do)(size,GC_malloc_functionpointer). + There are probably better ways this problem could be handled, unfortunately, + I didn't find any without rewriting or replacing a lot of the GC-code, which + I really didn't want to. (Making new GC_malloc_* functions, and just + define f.ex GC_malloc as GC_amiga_malloc should allso work). + + + New amiga-spesific function: + + void GC_amiga_set_toany(void (*func)(void)); + + 'func' is a function that will be called right before gc has to change + allocation-method from MEMF_FAST to MEMF_ANY. Ie. when it is likely + it will return chip-mem. + + +2. A few small compiler-spesific additions to make it compile with SAS/C again. + +3. Updated and rewritten the smakefile, so that it works again and that + the "unnecesarry" 'SCOPTIONS' files could be removed. Allso included + the cord-smakefile stuff in the main smakefile, so that the cord smakefile + could be removed too. By writing smake -f Smakefile.smk, both gc.lib and + cord.lib will be made. + + + +STILL MISSING: + +Programs can not be started from workbench, at least not for SAS/C. (Martin +Tauchmanns note about that it now works with workbench is definitely wrong +when concerning SAS/C). I guess it works if you use the old "#if 0'ed"-code, +but I haven't tested it. I think the reason for MT to replace the +"#if 0'ed"-code was only because it was a bit to SAS/C-spesific. But I +don't know. An iconx-script solves this problem anyway. + + +BEWARE! + +-To run gctest, set the stack to around 200000 bytes first. +-SAS/C-spesific: cord will crash if you compile gc.lib with + either parm=reg or parm=both. (missing legal prototypes for + function-pointers someplace is the reason I guess.). + + +tested with software: Radium, http://www.stud.ifi.uio.no/~ksvalast/radium/ + +tested with hardware: MC68060 + + +-ksvalast@ifi.uio.no + + +=========================================================================== + Martin Tauchmann's notes (1-Apr-99) +=========================================================================== + +Works now, also with the GNU-C compiler V2.7.2.1. +Modify the `Makefile` +CC=cc $(ABI_FLAG) +to +CC=gcc $(ABI_FLAG) + +TECHNICAL NOTES + +- `GC_get_stack_base()`, `GC_register_data_segments()` works now with every + C compiler; also Workbench. + +- Removed AMIGA_SKIP_SEG, but the Code-Segment must not be scanned by GC. + + +PROBLEMS +- When the Linker, does`t merge all Code-Segments to an single one. LD of GCC + do it always. + +- With ixemul.library V47.3, when an GC program launched from another program + (example: `Make` or `if_mach M68K AMIGA gctest`), `GC_register_data_segments()` + found the Segment-List of the caller program. + Can be fixed, if the run-time initialization code (for C programs, usually *crt0*) + support `__data` and `__bss`. + +- PowerPC Amiga currently not supported. + +- Dynamic libraries (dyn_load.c) not supported. + + +TESTED WITH SOFTWARE + +`Optimized Oberon 2 C` (oo2c) + + +TESTED WITH HARDWARE + +MC68030 + + +CONTACT + +Please, contact me at , when you change the +Amiga port. + +=========================================================================== + Michel Schinz's notes +=========================================================================== +WHO DID WHAT + +The original Amiga port was made by Jesper Peterson. I (Michel Schinz) +modified it slightly to reflect the changes made in the new official +distributions, and to take advantage of the new SAS/C 6.x features. I also +created a makefile to compile the "cord" package (see the cord +subdirectory). + +TECHNICAL NOTES + +In addition to Jesper's notes, I have the following to say: + +- Starting with version 4.3, gctest checks to see if the code segment is + added to the root set or not, and complains if it is. Previous versions + of this Amiga port added the code segment to the root set, so I tried to + fix that. The only problem is that, as far as I know, it is impossible to + know which segments are code segments and which are data segments (there + are indeed solutions to this problem, like scanning the program on disk + or patch the LoadSeg functions, but they are rather complicated). The + solution I have chosen (see os_dep.c) is to test whether the program + counter is in the segment we are about to add to the root set, and if it + is, to skip the segment. The problems are that this solution is rather + awkward and that it works only for one code segment. This means that if + your program has more than one code segment, all of them but one will be + added to the root set. This isn't a big problem in fact, since the + collector will continue to work correctly, but it may be slower. + + Anyway, the code which decides whether to skip a segment or not can be + removed simply by not defining AMIGA_SKIP_SEG. But notice that if you do + so, gctest will complain (it will say that "GC_is_visible produced wrong + failure indication"). However, it may be useful if you happen to have + pointers stored in a code segment (you really shouldn't). + + If anyone has a good solution to the problem of finding, when a program + is loaded in memory, whether a segment is a code or a data segment, + please let me know. + +PROBLEMS + +If you have any problem with this version, please contact me at +schinz@alphanet.ch (but do *not* send long files, since we pay for +every mail!). + +=========================================================================== + Jesper Peterson's notes +=========================================================================== + +ADDITIONAL NOTES FOR AMIGA PORT + +These notes assume some familiarity with Amiga internals. + +WHY I PORTED TO THE AMIGA + +The sole reason why I made this port was as a first step in getting +the Sather(*) language on the Amiga. A port of this language will +be done as soon as the Sather 1.0 sources are made available to me. +Given this motivation, the garbage collection (GC) port is rather +minimal. + +(*) For information on Sather read the comp.lang.sather newsgroup. + +LIMITATIONS + +This port assumes that the startup code linked with target programs +is that supplied with SAS/C versions 6.0 or later. This allows +assumptions to be made about where to find the stack base pointer +and data segments when programs are run from WorkBench, as opposed +to running from the CLI. The compiler dependent code is all in the +GC_get_stack_base() and GC_register_data_segments() functions, but +may spread as I add Amiga specific features. + +Given that SAS/C was assumed, the port is set up to be built with +"smake" using the "SMakefile". Compiler options in "SCoptions" can +be set with "scopts" program. Both "smake" and "scopts" are part of +the SAS/C commercial development system. + +In keeping with the porting philosophy outlined above, this port +will not behave well with Amiga specific code. Especially not inter- +process comms via messages, and setting up public structures like +Intuition objects or anything else in the system lists. For the +time being the use of this library is limited to single threaded +ANSI/POSIX compliant or near-complient code. (ie. Stick to stdio +for now). Given this limitation there is currently no mechanism for +allocating "CHIP" or "PUBLIC" memory under the garbage collector. +I'll add this after giving it considerable thought. The major +problem is the entire physical address space may have to me scanned, +since there is no telling who we may have passed memory to. + +If you allocate your own stack in client code, you will have to +assign the pointer plus stack size to GC_stackbottom. + +The initial stack size of the target program can be compiled in by +setting the __stack symbol (see SAS documentaion). It can be over- +ridden from the CLI by running the AmigaDOS "stack" program, or from +the WorkBench by setting the stack size in the tool types window. + +SAS/C COMPILER OPTIONS (SCoptions) + +You may wish to check the "CPU" code option is appropriate for your +intended target system. + +Under no circumstances set the "StackExtend" code option in either +compiling the library or *ANY* client code. + +All benign compiler warnings have been suppressed. These mainly +involve lack of prototypes in the code, and dead assignments +detected by the optimizer. + +THE GOOD NEWS + +The library as it stands is compatible with the GigaMem commercial +virtual memory software, and probably similar PD software. + +The performance of "gctest" on an Amiga 2630 (68030 @ 25Mhz) +compares favourably with an HP9000 with similar architecture (a 325 +with a 68030 I think). + +----------------------------------------------------------------------- + +The Amiga port has been brought to you by: + +Jesper Peterson. + +jep@mtiame.mtia.oz.au (preferred, but 1 week turnaround) +jep@orca1.vic.design.telecom.au (that's orca, 1 day turnaround) + +At least one of these addresses should be around for a while, even +though I don't work for either of the companies involved. + diff --git a/boehm-gc/doc/README.arm.cross b/boehm-gc/doc/README.arm.cross new file mode 100644 index 000000000..96744edaf --- /dev/null +++ b/boehm-gc/doc/README.arm.cross @@ -0,0 +1,68 @@ +From: Margaret Fleck + +Here's the key details of what worked for me, in case anyone else needs them. +There may well be better ways to do some of this, but .... + -- Margaret + + +The badge4 has a StrongArm-1110 processor and a StrongArm-1111 coprocessor. + +Assume that the garbage collector distribution is unpacked into /home/arm/gc6.0, +which is visible to both the ARM machine and a linux desktop (e.g. via NFS mounting). + +Assume that you have a file /home/arm/config.site with contents something like the +example attached below. Notice that our local ARM toolchain lives in +/skiff/local. + +Go to /home/arm/gc6.0 directory. Do + CONFIG_SITE=/home/arm/config.site ./configure --target=arm-linux +--prefix=/home/arm/gc6.0 + +On your desktop, do: + make + make install +The main garbage collector library should now be in ../gc6.0/lib/libgc.so. + +To test the garbage collector, first do the following on your desktop + make gctest + ./gctest +Then do the following on the ARM machine + cd .libs + ./lt-gctest + +Do not try to do "make test" (the usual way of running the test +program). This does not work and seems to erase some of the important +files. + +The gctest program claims to have succeeded. Haven't run any further tests +with it, though I'll be doing so in the near future. + +------------------------------- +# config.site for configure + +# Modified from the one provided by Bradley D. LaRonde +# Edited by Andrej Cedilnik +# Used some of solutions by Tilman Vogel +# Ported for iPAQ Familiar by Oliver Kurth +# Further modified by Margaret Fleck for the badge4 + +HOSTCC=gcc + +# Names of the cross-compilers +CC=/skiff/local/bin/arm-linux-gcc +CXX=/skiff/local/bin/arm-linux-gcc + +# The cross compiler specific options +CFLAGS="-O2 -fno-exceptions" +CXXFLAGS="-O2 -fno-exceptions" +CPPFLAGS="-O2 -fno-exceptions" +LDFLAGS="" + +# Some other programs +AR=/skiff/local/bin/arm-linux-ar +RANLIB=/skiff/local/bin/arm-linux-ranlib +NM=/skiff/local/bin/arm-linux-nm +ac_cv_path_NM=/skiff/local/bin/arm-linux-nm +ac_cv_func_setpgrp_void=yes +x_includes=/skiff/local/arm-linux/include/X11 +x_libraries=/skiff/local/arm-linux/lib/X11 diff --git a/boehm-gc/doc/README.autoconf b/boehm-gc/doc/README.autoconf new file mode 100644 index 000000000..53fcf5a50 --- /dev/null +++ b/boehm-gc/doc/README.autoconf @@ -0,0 +1,59 @@ +As of GC6.0alpha8, we attempt to support GNU-style builds based on automake, +autoconf and libtool. This is based almost entirely on Tom Tromey's work +with gcj. + +To build and install libraries use + +configure; make; make install + +The advantages of this process are: + +1) It should eventually do a better job of automatically determining the +right compiler to use, etc. It probably already does in some cases. + +2) It tries to automatically set a good set of default GC parameters for +the platform (e.g. thread support). It provides an easier way to configure +some of the others. + +3) It integrates better with other projects using a GNU-style build process. + +4) It builds both dynamic and static libraries. + +The known disadvantages are: + +1) The build scripts are much more complex and harder to debug (though largely +standard). I don't understand them all, and there's probably lots of redundant +stuff. + +2) It probably doesn't work on all Un*x-like platforms yet. It probably will +never work on the rest. + +3) The scripts are not yet complete. Some of the standard GNU targets don't +yet work. (Corrections/additions are very welcome.) + +The distribution should contain all files needed to run "configure" and "make", +as well as the sources needed to regenerate the derived files. (If I missed +some, please let me know.) + +Note that the distribution comes with a "Makefile" which will be overwritten +by "configure" with one that is not at all equiavelent to the original. The +distribution contains a copy of the original "Makefile" in "Makefile.direct". + +Important options to configure: + + --prefix=PREFIX install architecture-independent files in PREFIX + [/usr/local] + --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX + [same as prefix] + --enable-threads=TYPE choose threading package + --enable-parallel-mark parallelize marking and free list construction + --enable-full-debug include full support for pointer backtracing etc. + +Unless --prefix is set (or --exec-prefix or one of the more obscure options), +make install will install libgc.a and libgc.so in /usr/local/bin, which +would typically require the "make install" to be run as root. + +Most commonly --enable-threads=posix or will be needed. --enable-parallel-mark +is recommended for multiprocessors if it is supported on the platform. + + diff --git a/boehm-gc/doc/README.changes b/boehm-gc/doc/README.changes new file mode 100644 index 000000000..97b0b684d --- /dev/null +++ b/boehm-gc/doc/README.changes @@ -0,0 +1,2278 @@ +This is a rough history of garbage collector bugs and versions. + +This has been maintained with varying diligence over the years. + +I made an attempt to include recent contributors here. I apologize for any +omissions. + +------------------------- + + Version 1.3 and immediately preceding versions contained spurious +assembly language assignments to TMP_SP. Only the assignment in the PC/RT +code is necessary. On other machines, with certain compiler options, +the assignments can lead to an unsaved register being overwritten. +Known to cause problems under SunOS 3.5 WITHOUT the -O option. (With +-O the compiler recognizes it as dead code. It probably shouldn't, +but that's another story.) + + Version 1.4 and earlier versions used compile time determined values +for the stack base. This no longer works on Sun 3s, since Sun 3/80s use +a different stack base. We now use a straightforward heuristic on all +machines on which it is known to work (incl. Sun 3s) and compile-time +determined values for the rest. There should really be library calls +to determine such values. + + Version 1.5 and earlier did not ensure 8 byte alignment for objects +allocated on a sparc based machine. + + Version 1.8 added ULTRIX support in gc_private.h. + + Version 1.9 fixed a major bug in gc_realloc. + + Version 2.0 introduced a consistent naming convention for collector +routines and added support for registering dynamic library data segments +in the standard mark_roots.c. Most of the data structures were revamped. +The treatment of interior pointers was completely changed. Finalization +was added. Support for locking was added. Object kinds were added. +We added a black listing facility to avoid allocating at addresses known +to occur as integers somewhere in the address space. Much of this +was accomplished by adapting ideas and code from the PCR collector. +The test program was changed and expanded. + + Version 2.1 was the first stable version since 1.9, and added support +for PPCR. + + Version 2.2 added debugging allocation, and fixed various bugs. Among them: +- GC_realloc could fail to extend the size of the object for certain large object sizes. +- A blatant subscript range error in GC_printf, which unfortunately + wasn't exercised on machines with sufficient stack alignment constraints. +- GC_register_displacement did the wrong thing if it was called after + any allocation had taken place. +- The leak finding code would eventually break after 2048 byte + byte objects leaked. +- interface.c didn't compile. +- The heap size remained much too small for large stacks. +- The stack clearing code behaved badly for large stacks, and perhaps + on HP/PA machines. + + Version 2.3 added ALL_INTERIOR_POINTERS and fixed the following bugs: +- Missing declaration of etext in the A/UX version. +- Some PCR root-finding problems. +- Blacklisting was not 100% effective, because the plausible future + heap bounds were being miscalculated. +- GC_realloc didn't handle out-of-memory correctly. +- GC_base could return a nonzero value for addresses inside free blocks. +- test.c wasn't really thread safe, and could erroneously report failure + in a multithreaded environment. (The locking primitives need to be + replaced for other threads packages.) +- GC_CONS was thoroughly broken. +- On a SPARC with dynamic linking, signals stayed diabled while the + client code was running. + (Thanks to Manuel Serrano at INRIA for reporting the last two.) + + Version 2.4 added GC_free_space_divisor as a tuning knob, added + support for OS/2 and linux, and fixed the following bugs: +- On machines with unaligned pointers (e.g. Sun 3), every 128th word could + fail to be considered for marking. +- Dynamic_load.c erroneously added 4 bytes to the length of the data and + bss sections of the dynamic library. This could result in a bad memory + reference if the actual length was a multiple of a page. (Observed on + Sun 3. Can probably also happen on a Sun 4.) + (Thanks to Robert Brazile for pointing out that the Sun 3 version + was broken. Dynamic library handling is still broken on Sun 3s + under 4.1.1U1, but apparently not 4.1.1. If you have such a machine, + use -Bstatic.) + + Version 2.5 fixed the following bugs: +- Removed an explicit call to exit(1) +- Fixed calls to GC_printf and GC_err_printf, so the correct number of + arguments are always supplied. The OS/2 C compiler gets confused if + the number of actuals and the number of formals differ. (ANSI C + doesn't require this to work. The ANSI sanctioned way of doing things + causes too many compatibility problems.) + + Version 3.0 added generational/incremental collection and stubborn + objects. + + Version 3.1 added the following features: +- A workaround for a SunOS 4.X SPARC C compiler + misfeature that caused problems when the collector was turned into + a dynamic library. +- A fix for a bug in GC_base that could result in a memory fault. +- A fix for a performance bug (and several other misfeatures) pointed + out by Dave Detlefs and Al Dosser. +- Use of dirty bit information for static data under Solaris 2.X. +- DEC Alpha/OSF1 support (thanks to Al Dosser). +- Incremental collection on more platforms. +- A more refined heap expansion policy. Less space usage by default. +- Various minor enhancements to reduce space usage, and to reduce + the amount of memory scanned by the collector. +- Uncollectable allocation without per object overhead. +- More conscientious handling of out-of-memory conditions. +- Fixed a bug in debugging stubborn allocation. +- Fixed a bug that resulted in occasional erroneous reporting of smashed + objects with debugging allocation. +- Fixed bogus leak reports of size 4096 blocks with FIND_LEAK. + + Version 3.2 fixed a serious and not entirely repeatable bug in + the incremental collector. It appeared only when dirty bit info + on the roots was available, which is normally only under Solaris. + It also added GC_general_register_disappearing_link, and some + testing code. Interface.c disappeared. + + Version 3.3 fixes several bugs and adds new ports: +- PCR-specific bugs. +- Missing locking in GC_free, redundant FASTUNLOCK + in GC_malloc_stubborn, and 2 bugs in + GC_unregister_disappearing_link. + All of the above were pointed out by Neil Sharman + (neil@cs.mu.oz.au). +- Common symbols allocated by the SunOS4.X dynamic loader + were not included in the root set. +- Bug in GC_finalize (reported by Brian Beuning and Al Dosser) +- Merged Amiga port from Jesper Peterson (untested) +- Merged NeXT port from Thomas Funke (significantly + modified and untested) + + Version 3.4: +- Fixed a performance bug in GC_realloc. +- Updated the amiga port. +- Added NetBSD and 386BSD ports. +- Added cord library. +- Added trivial performance enhancement for + ALL_INTERIOR_POINTERS. (Don't scan last word.) + + Version 3.5 +- Minor collections now mark from roots only once, if that + doesn't cause an excessive pause. +- The stack clearing heuristic was refined to prevent anomalies + with very heavily recursive programs and sparse stacks. +- Fixed a bug that prevented mark stack growth in some cases. + GC_objects_are_marked should be set to TRUE after a call + to GC_push_roots and as part of GC_push_marked, since + both can now set mark bits. I think this is only a performance + bug, but I wouldn't bet on it. It's certainly very hard to argue + that the old version was correct. +- Fixed an incremental collection bug that prevented it from + working at all when HBLKSIZE != getpagesize() +- Changed dynamic_loading.c to include gc_priv.h before testing + DYNAMIC_LOADING. SunOS dynamic library scanning + must have been broken in 3.4. +- Object size rounding now adapts to program behavior. +- Added a workaround (provided by Manuel Serrano and + colleagues) to a long-standing SunOS 4.X (and 3.X?) ld bug + that I had incorrectly assumed to have been squished. + The collector was broken if the text segment size was within + 32 bytes of a multiple of 8K bytes, and if the beginning of + the data segment contained interesting roots. The workaround + assumes a demand-loadable executable. The original may have + have "worked" in some other cases. +- Added dynamic library support under IRIX5. +- Added support for EMX under OS/2 (thanks to Ari Huttunen). + +Version 3.6: +- fixed a bug in the mark stack growth code that was introduced + in 3.4. +- fixed Makefile to work around DEC AXP compiler tail recursion + bug. + +Version 3.7: +- Added a workaround for an HP/UX compiler bug. +- Fixed another stack clearing performance bug. Reworked + that code once more. + +Version 4.0: +- Added support for Solaris threads (which was possible + only by reimplementing some fraction of Solaris threads, + since Sun doesn't currently make the thread debugging + interface available). +- Added non-threads win32 and win32S support. +- (Grudgingly, with suitable muttering of obscenities) renamed + files so that the collector distribution could live on a FAT + file system. Files that are guaranteed to be useless on + a PC still have long names. Gc_inline.h and gc_private.h + still exist, but now just include gc_inl.h and gc_priv.h. +- Fixed a really obscure bug in finalization that could cause + undetected mark stack overflows. (I would be surprised if + any real code ever tickled this one.) +- Changed finalization code to dynamically resize the hash + tables it maintains. (This probably does not matter for well- + -written code. It no doubt does for C++ code that overuses + destructors.) +- Added typed allocation primitives. Rewrote the marker to + accommodate them with more reasonable efficiency. This + change should also speed up marking for GC_malloc allocated + objects a little. See gc_typed.h for new primitives. +- Improved debugging facilities slightly. Allocation time + stack traces are now kept by default on SPARC/SUNOS4. + (Thanks to Scott Schwartz.) +- Added better support for small heap applications. +- Significantly extended cord package. Fixed a bug in the + implementation of lazily read files. Printf and friends now + have cord variants. Cord traversals are a bit faster. +- Made ALL_INTERIOR_POINTERS recognition the default. +- Fixed de so that it can run in constant space, independent + of file size. Added simple string searching to cords and de. +- Added the Hull-Ellis C++ interface. +- Added dynamic library support for OSF/1. + (Thanks to Al Dosser and Tim Bingham at DEC.) +- Changed argument to GC_expand_hp to be expressed + in units of bytes instead of heap blocks. (Necessary + since the heap block size now varies depending on + configuration. The old version was never very clean.) +- Added GC_get_heap_size(). The previous "equivalent" + was broken. +- Restructured the Makefile a bit. + +Since version 4.0: +- Changed finalization implementation to guarantee that + finalization procedures are called outside of the allocation + lock, making direct use of the interface a little less dangerous. + MAY BREAK EXISTING CLIENTS that assume finalizers + are protected by a lock. Since there seem to be few multithreaded + clients that use finalization, this is hopefully not much of + a problem. +- Fixed a gross bug in CORD_prev. +- Fixed a bug in blacklst.c that could result in unbounded + heap growth during startup on machines that do not clear + memory obtained from the OS (e.g. win32S). +- Ported de editor to win32/win32S. (This is now the only + version with a mouse-sensitive UI.) +- Added GC_malloc_ignore_off_page to allocate large arrays + in the presence of ALL_INTERIOR_POINTERS. +- Changed GC_call_with_alloc_lock to not disable signals in + the single-threaded case. +- Reduced retry count in GC_collect_or_expand for garbage + collecting when out of memory. +- Made uncollectable allocations bypass black-listing, as they + should. +- Fixed a bug in typed_test in test.c that could cause (legitimate) + GC crashes. +- Fixed some potential synchronization problems in finalize.c +- Fixed a real locking problem in typd_mlc.c. +- Worked around an AIX 3.2 compiler feature that results in + out of bounds memory references. +- Partially worked around an IRIX5.2 beta problem (which may + or may not persist to the final release). +- Fixed a bug in the heap integrity checking code that could + result in explicitly deallocated objects being identified as + smashed. Fixed a bug in the dbg_mlc stack saving code + that caused old argument pointers to be considered live. +- Fixed a bug in CORD_ncmp (and hence CORD_str). +- Repaired the OS2 port, which had suffered from bit rot + in 4.0. Worked around what appears to be CSet/2 V1.0 + optimizer bug. +- Fixed a Makefile bug for target "c++". + +Since version 4.1: +- Multiple bug fixes/workarounds in the Solaris threads version. + (It occasionally failed to locate some register contents for + marking. It also turns out that thr_suspend and friends are + unreliable in Solaris 2.3. Dirty bit reads appear + to be unreliable under some weird + circumstances. My stack marking code + contained a serious performance bug. The new code is + extremely defensive, and has not failed in several cpu + hours of testing. But no guarantees ...) +- Added MacOS support (thanks to Patrick Beard.) +- Fixed several syntactic bugs in gc_c++.h and friends. (These + didn't bother g++, but did bother most other compilers.) + Fixed gc_c++.h finalization interface. (It didn't.) +- 64 bit alignment for allocated objects was not guaranteed in a + few cases in which it should have been. +- Added GC_malloc_atomic_ignore_off_page. +- Added GC_collect_a_little. +- Added some prototypes to gc.h. +- Some other minor bug fixes (notably in Makefile). +- Fixed OS/2 / EMX port (thanks to Ari Huttunen). +- Fixed AmigaDOS port. (thanks to Michel Schinz). +- Fixed the DATASTART definition under Solaris. There + was a 1 in 16K chance of the collector missing the first + 64K of static data (and thus crashing). +- Fixed some blatant anachronisms in the README file. +- Fixed PCR-Makefile for upcoming PPCR release. + +Since version 4.2: +- Fixed SPARC alignment problem with GC_DEBUG. +- Fixed Solaris threads /proc workaround. The real + problem was an interaction with mprotect. +- Incorporated fix from Patrick Beard for gc_c++.h (now gc_cpp.h). +- Slightly improved allocator space utilization by + fixing the GC_size_map mechanism. +- Integrated some Sony News and MIPS RISCos 4.51 + patches. (Thanks to Nobuyuki Hikichi of + Software Research Associates, Inc. Japan) +- Fixed HP_PA alignment problem. (Thanks to + xjam@cork.cs.berkeley.edu.) +- Added GC_same_obj and friends. Changed GC_base + to return 0 for pointers past the end of large objects. + Improved GC_base performance with ALL_INTERIOR_POINTERS + on machines with a slow integer mod operation. + Added GC_PTR_ADD, GC_PTR_STORE, etc. to prepare + for preprocessor. +- changed the default on most UNIX machines to be that + signals are not disabled during critical GC operations. + This is still ANSI-conforming, though somewhat dangerous + in the presence of signal handlers. But the performance + cost of the alternative is sometimes problematic. + Can be changed back with a minor Makefile edit. +- renamed IS_STRING in gc.h, to CORD_IS_STRING, thus + following my own naming convention. Added the function + CORD_to_const_char_star. +- Fixed a gross bug in GC_finalize. Symptom: occasional + address faults in that function. (Thanks to Anselm + Baird-Smith (Anselm.BairdSmith@inria.fr) +- Added port to ICL DRS6000 running DRS/NX. Restructured + things a bit to factor out common code, and remove obsolete + code. Collector should now run under SUNOS5 with either + mprotect or /proc dirty bits. (Thanks to Douglas Steel + (doug@wg.icl.co.uk)). +- More bug fixes and workarounds for Solaris 2.X. (These were + mostly related to putting the collector in a dynamic library, + which didn't really work before. Also SOLARIS_THREADS + didn't interact well with dl_open.) Thanks to btlewis@eng.sun.com. +- Fixed a serious performance bug on the DEC Alpha. The text + segment was getting registered as part of the root set. + (Amazingly, the result was still fast enough that the bug + was not conspicuous.) The fix works on OSF/1, version 1.3. + Hopefully it also works on other versions of OSF/1 ... +- Fixed a bug in GC_clear_roots. +- Fixed a bug in GC_generic_malloc_words_small that broke + gc_inl.h. (Reported by Antoine de Maricourt. I broke it + in trying to tweak the Mac port.) +- Fixed some problems with cord/de under Linux. +- Fixed some cord problems, notably with CORD_riter4. +- Added DG/UX port. + Thanks to Ben A. Mesander (ben@piglet.cr.usgs.gov) +- Added finalization registration routines with weaker ordering + constraints. (This is necessary for C++ finalization with + multiple inheritance, since the compiler often adds self-cycles.) +- Filled the holes in the SCO port. (Thanks to Michael Arnoldus + .) +- John Ellis' additions to the C++ support: From John: + +* I completely rewrote the documentation in the interface gc_c++.h +(later renamed gc_cpp.h). I've tried to make it both clearer and more +precise. + +* The definition of accessibility now ignores pointers from an +finalizable object (an object with a clean-up function) to itself. +This allows objects with virtual base classes to be finalizable by the +collector. Compilers typically implement virtual base classes using +pointers from an object to itself, which under the old definition of +accessibility prevented objects with virtual base classes from ever +being collected or finalized. + +* gc_cleanup now includes gc as a virtual base. This was enabled by +the change in the definition of accessibility. + +* I added support for operator new[]. Since most (all?) compilers +don't yet support operator new[], it is conditionalized on +-DOPERATOR_NEW_ARRAY. The code is untested, but its trivial and looks +correct. + +* The test program test_gc_c++ (later renamed test_cpp.cc) +tries to test for the C++-specific functionality not tested by the +other programs. +- Added include to misc.c. (Needed for ppcr.) +- Added PowerMac port. (Thanks to Patrick Beard again.) +- Fixed "srcdir"-related Makefile problems. Changed things so + that all externally visible include files always appear in the + include subdirectory of the source. Made gc.h directly + includable from C++ code. (These were at Per + Bothner's suggestion.) +- Changed Intel code to also mark from ebp (Kevin Warne's + suggestion). +- Renamed C++ related files so they could live in a FAT + file system. (Charles Fiterman's suggestion.) +- Changed Windows NT Makefile to include C++ support in + gc.lib. Added C++ test as Makefile target. + +Since version 4.3: + - ASM_CLEAR_CODE was erroneously defined for HP + PA machines, resulting in a compile error. + - Fixed OS/2 Makefile to create a library. (Thanks to + Mark Boulter (mboulter@vnet.ibm.com)). + - Gc_cleanup objects didn't work if they were created on + the stack. Fixed. + - One copy of Gc_cpp.h in the distribution was out of + synch, and failed to document some known compiler + problems with explicit destructor invocation. Partially + fixed. There are probably other compilers on which + gc_cleanup is miscompiled. + - Fixed Makefile to pass C compiler flags to C++ compiler. + - Added Mac fixes. + - Fixed os_dep.c to work around what appears to be + a new and different VirtualQuery bug under newer + versions of win32S. + - GC_non_gc_bytes was not correctly maintained by + GC_free. Fixed. Thanks to James Clark (jjc@jclark.com). + - Added GC_set_max_heap_size. + - Changed allocation code to ignore blacklisting if it is preventing + use of a very large block of memory. This has the advantage + that naive code allocating very large objects is much more + likely to work. The downside is you might no + longer find out that such code should really use + GC_malloc_ignore_off_page. + - Changed GC_printf under win32 to close and reopen the file + between calls. FAT file systems otherwise make the log file + useless for debugging. + - Added GC_try_to_collect and GC_get_bytes_since_gc. These + allow starting an abortable collection during idle times. + This facility does not require special OS support. (Thanks to + Michael Spertus of Geodesic Systems for suggesting this. It was + actually an easy addition. Kumar Srikantan previously added a similar + facility to a now ancient version of the collector. At the time + this was much harder, and the result was less convincing.) + - Added some support for the Borland development environment. (Thanks + to John Ellis and Michael Spertus.) + - Removed a misfeature from checksums.c that caused unexpected + heap growth. (Thanks to Scott Schwartz.) + - Changed finalize.c to call WARN if it encounters a finalization cycle. + WARN is defined in gc_priv.h to write a message, usually to stdout. + In many environments, this may be inappropriate. + - Renamed NO_PARAMS in gc.h to GC_NO_PARAMS, thus adhering to my own + naming convention. + - Added GC_set_warn_proc to intercept warnings. + - Fixed Amiga port. (Thanks to Michel Schinz (schinz@alphanet.ch).) + - Fixed a bug in mark.c that could result in an access to unmapped + memory from GC_mark_from_mark_stack on machines with unaligned + pointers. + - Fixed a win32 specific performance bug that could result in scanning of + objects allocated with the system malloc. + - Added REDIRECT_MALLOC. + +Since version 4.4: + - Fixed many minor and one major README bugs. (Thanks to Franklin Chen + (chen@adi.com) for pointing out many of them.) + - Fixed ALPHA/OSF/1 dynamic library support. (Thanks to Jonathan Bachrach + (jonathan@harlequin.com)). + - Added incremental GC support (MPROTECT_VDB) for Linux (with some + help from Bruno Haible). + - Altered SPARC recognition tests in gc.h and config.h (mostly as + suggested by Fergus Henderson). + - Added basic incremental GC support for win32, as implemented by + Windows NT and Windows 95. GC_enable_incremental is a noop + under win32s, which doesn't implement enough of the VM interface. + - Added -DLARGE_CONFIG. + - Fixed GC_..._ignore_off_page to also function without + -DALL_INTERIOR_POINTERS. + - (Hopefully) fixed RS/6000 port. (Only the test was broken.) + - Fixed a performance bug in the nonincremental collector running + on machines supporting incremental collection with MPROTECT_VDB + (e.g. SunOS 4, DEC AXP). This turned into a correctness bug under + win32s with win32 incremental collection. (Not all memory protection + was disabled.) + - Fixed some ppcr related bit rot. + - Caused dynamic libraries to be unregistered before reregistering. + The old way turned out to be a performance bug on some machines. + - GC_root_size was not properly maintained under MSWIN32. + - Added -DNO_DEBUGGING and GC_dump. + - Fixed a couple of bugs arising with SOLARIS_THREADS + + REDIRECT_MALLOC. + - Added NetBSD/M68K port. (Thanks to Peter Seebach + .) + - Fixed a serious realloc bug. For certain object sizes, the collector + wouldn't scan the expanded part of the object. (Thanks to Clay Spence + (cds@peanut.sarnoff.com) for noticing the problem, and helping me to + track it down.) + +Since version 4.5: + - Added Linux ELF support. (Thanks to Arrigo Triulzi .) + - GC_base crashed if it was called before any other GC_ routines. + This could happen if a gc_cleanup object was allocated outside the heap + before any heap allocation. + - The heap expansion heuristic was not stable if all objects had finalization + enabled. Fixed finalize.c to count memory in finalization queue and + avoid explicit deallocation. Changed alloc.c to also consider this count. + (This is still not recommended. It's expensive if nothing else.) Thanks + to John Ellis for pointing this out. + - GC_malloc_uncollectable(0) was broken. Thanks to Phong Vo for pointing + this out. + - The collector didn't compile under Linux 1.3.X. (Thanks to Fred Gilham for + pointing this out.) The current workaround is ugly, but expected to be + temporary. + - Fixed a formatting problem for SPARC stack traces. + - Fixed some '=='s in os_dep.c that should have been assignments. + Fortunately these were in code that should never be executed anyway. + (Thanks to Fergus Henderson.) + - Fixed the heap block allocator to only drop blacklisted blocks in small + chunks. Made BL_LIMIT self adjusting. (Both of these were in response + to heap growth observed by Paul Graham.) + - Fixed the Metrowerks/68K Mac code to also mark from a6. (Thanks + to Patrick Beard.) + - Significantly updated README.debugging. + - Fixed some problems with longjmps out of signal handlers, especially under + Solaris. Added a workaround for the fact that siglongjmp doesn't appear to + do the right thing with -lthread under Solaris. + - Added MSDOS/djgpp port. (Thanks to Mitch Harris (maharri@uiuc.edu).) + - Added "make reserved_namespace" and "make user_namespace". The + first renames ALL "GC_xxx" identifiers as "_GC_xxx". The second is the + inverse transformation. Note that doing this is guaranteed to break all + clients written for the other names. + - descriptor field for kind NORMAL in GC_obj_kinds with ADD_BYTE_AT_END + defined should be -ALIGNMENT not WORDS_TO_BYTES(-1). This is + a serious bug on machines with pointer alignment of less than a word. + - GC_ignore_self_finalize_mark_proc didn't handle pointers to very near the + end of the object correctly. Caused failures of the C++ test on a DEC Alpha + with g++. + - gc_inl.h still had problems. Partially fixed. Added warnings at the + beginning to hopefully specify the remaining dangers. + - Added DATAEND definition to config.h. + - Fixed some of the .h file organization. Fixed "make floppy". + +Since version 4.6: + - Fixed some compilation problems with -DCHECKSUMS (thanks to Ian Searle) + - Updated some Mac specific files to synchronize with Patrick Beard. + - Fixed a serious bug for machines with non-word-aligned pointers. + (Thanks to Patrick Beard for pointing out the problem. The collector + should fail almost any conceivable test immediately on such machines.) + +Since version 4.7: + - Changed a "comment" in a MacOS specific part of mach-dep.c that caused + gcc to fail on other platforms. + +Since version 4.8 + - More README.debugging fixes. + - Objects ready for finalization, but not finalized in the same GC + cycle, could be prematurely collected. This occasionally happened + in test_cpp. + - Too little memory was obtained from the system for very large + objects. That could cause a heap explosion if these objects were + not contiguous (e.g. under PCR), and too much of them was blacklisted. + - Due to an improper initialization, the collector was too hesitant to + allocate blacklisted objects immediately after system startup. + - Moved GC_arrays from the data into the bss segment by not explicitly + initializing it to zero. This significantly + reduces the size of executables, and probably avoids some disk accesses + on program startup. It's conceivable that it might break a port that I + didn't test. + - Fixed EMX_MAKEFILE to reflect the gc_c++.h to gc_cpp.h renaming which + occurred a while ago. + +Since 4.9: + - Fixed a typo around a call to GC_collect_or_expand in alloc.c. It broke + handling of out of memory. (Thanks to Patrick Beard for noticing.) + +Since 4.10: + - Rationalized (hopefully) GC_try_to_collect in an incremental collection + environment. It appeared to not handle a call while a collection was in + progress, and was otherwise too conservative. + - Merged GC_reclaim_or_delete_all into GC_reclaim_all to get rid of some + code. + - Added Patrick Beard's Mac fixes, with substantial completely untested + modifications. + - Fixed the MPROTECT_VDB code to deal with large pages and imprecise + fault addresses (as on an UltraSPARC running Solaris 2.5). Note that this + was not a problem in the default configuration, which uses PROC_VDB. + - The DEC Alpha assembly code needed to restore $gp between calls. + Thanks to Fergus Henderson for tracking this down and supplying a + patch. + - The write command for "de" was completely broken for large files. + I used the easiest portable fix, which involved changing the semantics + so that f.new is written instead of overwriting f. That's safer anyway. + - Added README.solaris2 with a discussion of the possible problems of + mixing the collector's sbrk allocation with malloc/realloc. + - Changed the data segment starting address for SGI machines. The + old code failed under IRIX6. + - Required double word alignment for MIPS. + - Various minor fixes to remove warnings. + - Attempted to fix some Solaris threads problems reported by Zhiying Chen. + In particular, the collector could try to fork a thread with the + world stopped as part of GC_thr_init. It also failed to deal with + the case in which the original thread terminated before the whole + process did. + - Added -DNO_EXECUTE_PERMISSION. This has a major performance impact + on the incremental collector under Irix, and perhaps under other + operating systems. + - Added some code to support allocating the heap with mmap. This may + be preferable under some circumstances. + - Integrated dynamic library support for HP. + (Thanks to Knut Tvedten .) + - Integrated James Clark's win32 threads support, and made a number + of changes to it, many of which were suggested by Pontus Rydin. + This is still not 100% solid. + - Integrated Alistair Crooks' support for UTS4 running on an Amdahl + 370-class machine. + - Fixed a serious bug in explicitly typed allocation. Objects requiring + large descriptors where handled in a way that usually resulted in + a segmentation fault in the marker. (Thanks to Jeremy Fitzhardinge + for helping to track this down.) + - Added partial support for GNU win32 development. (Thanks to Fergus + Henderson.) + - Added optional support for Java-style finalization semantics. (Thanks + to Patrick Bridges.) This is recommended only for Java implementations. + - GC_malloc_uncollectable faulted instead of returning 0 when out of + memory. (Thanks to dan@math.uiuc.edu for noticing.) + - Calls to GC_base before the collector was initialized failed on a + DEC Alpha. (Thanks to Matthew Flatt.) + - Added base pointer checking to GC_REGISTER_FINALIZER in debugging + mode, at the suggestion of Jeremy Fitzhardinge. + - GC_debug_realloc failed for uncollectable objects. (Thanks to + Jeremy Fitzhardinge.) + - Explicitly typed allocation could crash if it ran out of memory. + (Thanks to Jeremy Fitzhardinge.) + - Added minimal support for a DEC Alpha running Linux. + - Fixed a problem with allocation of objects whose size overflowed + ptrdiff_t. (This now fails unconditionally, as it should.) + - Added the beginning of Irix pthread support. + - Integrated Xiaokun Zhu's fixes for djgpp 2.01. + - Added SGI-style STL allocator support (gc_alloc.h). + - Fixed a serious bug in README.solaris2. Multithreaded programs must include + gc.h with SOLARIS_THREADS defined. + - Changed GC_free so it actually deallocates uncollectable objects. + (Thanks to Peter Chubb for pointing out the problem.) + - Added Linux ELF support for dynamic libararies. (Thanks again to + Patrick Bridges.) + - Changed the Borland cc configuration so that the assembler is not + required. + - Fixed a bug in the C++ test that caused it to fail in 64-bit + environments. + +Since 4.11: + - Fixed ElfW definition in dyn_load.c. (Thanks to Fergus Henderson.) + This prevented the dynamic library support from compiling on some + older ELF Linux systems. + - Fixed UTS4 port (which I apparently mangled during the integration) + (Thanks to again to Alistair Crooks.) + - "Make C++" failed on Suns with SC4.0, due to a problem with "bool". + Fixed in gc_priv.h. + - Added more pieces for GNU win32. (Thanks to Timothy N. Newsham.) + The current state of things should suffice for at least some + applications. + - Changed the out of memory retry count handling as suggested by + Kenjiro Taura. (This matters only if GC_max_retries > 0, which + is no longer the default.) + - If a /proc read failed repeatedly, GC_written_pages was not updated + correctly. (Thanks to Peter Chubb for diagnosing this.) + - Under unlikely circumstances, the allocator could infinite loop in + an out of memory situation. (Thanks again to Kenjiro Taura for + identifying the problem and supplying a fix.) + - Fixed a syntactic error in the DJGPP code. (Thanks to Fergus + Henderson for finding this by inspection.) Also fixed a test program + problem with DJGPP (Thanks to Peter Monks.) + - Atomic uncollectable objects were not treated correctly by the + incremental collector. This resulted in weird log statistics and + occasional performance problems. (Thanks to Peter Chubb for pointing + this out.) + - Fixed some problems resulting from compilers that dont define + __STDC__. In this case void * and char * were used inconsistently + in some cases. (Void * should not have been used at all. If + you have an ANSI superset compiler that does not define __STDC__, + please compile with -D__STDC__=0. Thanks to Manuel Serrano and others + for pointing out the problem.) + - Fixed a compilation problem on Irix with -n32 and -DIRIX_THREADS. + Also fixed some other IRIX_THREADS problems which may or may not have + had observable symptoms. + - Fixed an HP PA compilation problem in dyn_load.c. (Thanks to + Philippe Queinnec.) + - SEGV fault handlers sometimes did not get reset correctly. (Thanks + to David Pickens.) + - Added a fix for SOLARIS_THREADS on Intel. (Thanks again to David + Pickens.) This probably needs more work to become functional. + - Fixed struct sigcontext_struct in os_dep.c for compilation under + Linux 2.1.X. (Thanks to Fergus Henderson.) + - Changed the DJGPP STACKBOTTOM and DATASTART values to those suggested + by Kristian Kristensen. These may still not be right, but it is + it is likely to work more often than what was there before. They may + even be exactly right. + - Added a #include to test_cpp.cc. This appears to help + with HP/UX and gcc. (Thanks to assar@sics.se.) + - Version 4.11 failed to run in incremental mode on recent 64-bit Irix + kernels. This was a problem related to page unaligned heap segments. + Changed the code to page align heap sections on all platforms. + (I had mistakenly identified this as a kernel problem earlier. + It was not.) + - Version 4.11 did not make allocated storage executable, except on + one or two platforms, due to a bug in a #if test. (Thanks to Dave + Grove for pointing this out.) + - Added sparc_sunos4_mach_dep.s to support Sun's compilers under SunOS4. + - Added GC_exclude_static_roots. + - Fixed the object size mapping algorithm. This shouldn't matter, + but the old code was ugly. + - Heap checking code could die if one of the allocated objects was + larger than its base address. (Unsigned underflow problem. Thanks + to Clay Spence for isolating the problem.) + - Added RS6000 (AIX) dynamic library support and fixed STACK_BOTTOM. + (Thanks to Fred Stearns.) + - Added Fergus Henderson's patches for improved robustness with large + heaps and lots of blacklisting. + - Added Peter Chubb's changes to support Solaris Pthreads, to support + MMAP allocation in Solaris, to allow Solaris to find dynamic libraries + through /proc, to add malloc_typed_ignore_off_page, and a few other + minor features and bug fixes. + - The Solaris 2 port should not use sbrk. I received confirmation from + Sun that the use of sbrk and malloc in the same program is not + supported. The collector now defines USE_MMAP by default on Solaris. + - Replaced the djgpp makefile with Gary Leavens' version. + - Fixed MSWIN32 detection test. + - Added Fergus Henderson's patches to allow putting the collector into + a DLL under GNU win32. + - Added Ivan V. Demakov's port to Watcom C on X86. + - Added Ian Piumarta's Linux/PowerPC port. + - On Brian Burton's suggestion added PointerFreeGC to the placement + options in gc_cpp.h. This is of course unsafe, and may be controversial. + On the other hand, it seems to be needed often enough that it's worth + adding as a standard facility. + +Since 4.12: + - Fixed a crucial bug in the Watcom port. There was a redundant decl + of GC_push_one in gc_priv.h. + - Added FINALIZE_ON_DEMAND. + - Fixed some pre-ANSI cc problems in test.c. + - Removed getpagesize() use for Solaris. It seems to be missing in one + or two versions. + - Fixed bool handling for SPARCCompiler version 4.2. + - Fixed some files in include that had gotten unlinked from the main + copy. + - Some RS/6000 fixes (missing casts). Thanks to Toralf Foerster. + - Fixed several problems in GC_debug_realloc, affecting mostly the + FIND_LEAK case. + - GC_exclude_static_roots contained a buggy unsigned comparison to + terminate a loop. (Thanks to Wilson Ho.) + - CORD_str failed if the substring occurred at the last possible position. + (Only affects cord users.) + - Fixed Linux code to deal with RedHat 5.0 and integrated Peter Bigot's + os_dep.c code for dealing with various Linux versions. + - Added workaround for Irix pthreads sigaction bug and possible signal + misdirection problems. +Since alpha1: + - Changed RS6000 STACKBOTTOM. + - Integrated Patrick Beard's Mac changes. + - Alpha1 didn't compile on Irix m.n, m < 6. + - Replaced Makefile.dj with a new one from Gary Leavens. + - Added Andrew Stitcher's changes to support SCO OpenServer. + - Added PRINT_BLACK_LIST, to allow debugging of high densities of false + pointers. + - Added code to debug allocator to keep track of return address + in GC_malloc caller, thus giving a bit more context. + - Changed default behavior of large block allocator to more + aggressively avoid fragmentation. This is likely to slow down the + collector when it succeeds at reducing space cost. + - Integrated Fergus Henderson's CYGWIN32 changes. They are untested, + but needed for newer versions. + - USE_MMAP had some serious bugs. This caused the collector to fail + consistently on Solaris with -DSMALL_CONFIG. + - Added Linux threads support, thanks largely to Fergus Henderson. +Since alpha2: + - Fixed more Linux threads problems. + - Changed default GC_free_space_divisor to 3 with new large block allocation. + (Thanks to Matthew Flatt for some measurements that suggest the old + value sometimes favors space too much over time.) + - More CYGWIN32 fixes. + - Integrated Tyson-Dowd's Linux-M68K port. + - Minor HP PA and DEC UNIX fixes from Fergus Henderson. + - Integrated Christoffe Raffali's Linux-SPARC changes. + - Allowed for one more GC fixup iteration after a full GC in incremental + mode. Some quick measurements suggested that this significantly + reduces pause times even with smaller GC_RATE values. + - Moved some more GC data structures into GC_arrays. This decreases + pause times and GC overhead, but makes debugging slightly less convenient. + - Fixed namespace pollution problem ("excl_table"). + - Made GC_incremental a constant for -DSMALL_CONFIG, hopefully shrinking + that slightly. + - Added some win32 threads fixes. + - Integrated Ivan Demakov and David Stes' Watcom fixes. + - Various other minor fixes contributed by many people. + - Renamed config.h to gcconfig.h, since config.h tends to be used for + many other things. + - Integrated Matthew Flatt's support for 68K MacOS "far globals". + - Fixed up some of the dynamic library Makefile targets for consistency + across platforms. + - Fixed a USE_MMAP typo that caused out-of-memory handling to fail + on Solaris. + - Added code to test.c to test thread creation a bit more. + - Integrated GC_win32_free_heap, as suggested by Ivan Demakov. + - Fixed Solaris 2.7 stack base finding problem. (This may actually + have been done in an earlier alpha release.) +Since alpha3: + - Fixed MSWIN32 recognition test, which interfered with cygwin. + - Removed unnecessary gc_watcom.asm from distribution. Removed + some obsolete README.win32 text. + - Added Alpha Linux incremental GC support. (Thanks to Philipp Tomsich + for code for retrieving the fault address in a signal handler.) + Changed Linux signal handler context argument to be a pointer. + - Took care of some new warnings generated by the 7.3 SGI compiler. + - Integrated Phillip Musumeci's FreeBSD/ELF fixes. + - -DIRIX_THREADS was broken with the -o32 ABI (typo in gc_priv.h> + +Since 4.13: + - Fixed GC_print_source_ptr to not use a prototype. + - generalized CYGWIN test. + - gc::new did the wrong thing with PointerFreeGC placement. + (Thanks to Rauli Ruohonen.) + - In the ALL_INTERIOR_POINTERS (default) case, some callee-save register + values could fail to be scanned if the register was saved and + reused in a GC frame. This showed up in verbose mode with gctest + compiled with an unreleased SGI compiler. I vaguely recall an old + bug report that may have been related. The bug was probably quite old. + (The problem was that the stack scanning could be deferred until + after the relevant frame was overwritten, and the new save location + might be outside the scanned area. Fixed by more eager stack scanning.) + - PRINT_BLACK_LIST had some problems. A few source addresses were garbage. + - Replaced Makefile.dj and added -I flags to cord make targets. + (Thanks to Gary Leavens.) + - GC_try_to_collect was broken with the nonincremental collector. + - gc_cleanup destructors could pass the wrong address to + GC_register_finalizer_ignore_self in the presence of multiple + inheritance. (Thanks to Darrell Schiebel.) + - Changed PowerPC Linux stack finding code. + +Since 4.14alpha1 + - -DSMALL_CONFIG did not work reliably with large (> 4K) pages. + Recycling the mark stack during expansion could result in a size + zero heap segment, which confused things. (This was probably also an + issue with the normal config and huge pages.) + - Did more work to make sure that callee-save registers were scanned + completely, even with the setjmp-based code. Added USE_GENERIC_PUSH_REGS + macro to facilitate testing on machines I have access to. + - Added code to explicitly push register contents for win32 threads. + This seems to be necessary. (Thanks to Pierre de Rop.) + +Since 4.14alpha2 + - changed STACKBOTTOM for DJGPP (Thanks to Salvador Eduardo Tropea). + +Since 4.14 + - Reworked large block allocator. Now uses multiple doubly linked free + lists to approximate best fit. + - Changed heap expansion heuristic. Entirely free blocks are no longer + counted towards the heap size. This seems to have a major impact on + heap size stability; the old version could expand the heap way too + much in the presence of large block fragmentation. + - added -DGC_ASSERTIONS and some simple assertions inside the collector. + This is mainlyt for collector debugging. + - added -DUSE_MUNMAP to allow the heap to shrink. Suupported on only + a few UNIX-like platforms for now. + - added GC_dump_regions() for debugging of fragmentation issues. + - Changed PowerPC pointer alignment under Linux to 4. (This needs + checking by someone who has one. The suggestions came to me via a + rather circuitous path.) + - Changed the Linux/Alpha port to walk the data segment backwards until + it encounters a SIGSEGV. The old way to find the start of the data + segment broke with a recent release. + - cordxtra.c needed to call GC_REGISTER_FINALIZER instead of + GC_register_finalizer, so that it would continue to work with GC_DEBUG. + - allochblk sometimes cleared the wrong block for debugging purposes + when it dropped blacklisted blocks. This could result in spurious + error reports with GC_DEBUG. + - added MACOS X Server support. (Thanks to Andrew Stone.) + - Changed the Solaris threads code to ignore stack limits > 8 MB with + a warning. Empirically, it is not safe to access arbitrary pages + in such large stacks. And the dirty bit implementation does not + guarantee that none of them will be accessed. + - Integrated Martin Tauchmann's Amiga changes. + - Integrated James Dominy's OpenBSD/SPARC port. + +Since 5.0alpha1 + - Fixed bugs introduced in alpha1 (OpenBSD & large block initialization). + - Added -DKEEP_BACK_PTRS and backptr.h interface. (The implementation + idea came from Al Demers.) + +Since 5.0alpha2 + - Added some highly incomplete code to support a copied young generation. + Comments on nursery.h are appreciated. + - Changed -DFIND_LEAK, -DJAVA_FINALIZATION, and -DFINALIZE_ON_DEMAND, + so the same effect could be obtained with a runtime switch. This is + a step towards standardizing on a single dynamic GC library. + - Significantly changed the way leak detection is handled, as a consequence + of the above. + +Since 5.0 alpha3 + - Added protection fault handling patch for Linux/M68K from Fergus + Henderson and Roman Hodek. + - Removed the tests for SGI_SOURCE in new_gc_alloc.h. This was causing that + interface to fail on nonSGI platforms. + - Changed the Linux stack finding code to use /proc, after changing it + to use HEURISTIC1. (Thanks to David Mossberger for pointing out the + /proc hook.) + - Added HP/UX incremental GC support and HP/UX 11 thread support. + Thread support is currently still flakey. + - Added basic Linux/IA64 support. + - Integrated Anthony Green's PicoJava support. + - Integrated Scott Ananian's StrongARM/NetBSD support. + - Fixed some fairly serious performance bugs in the incremental + collector. These have probably been there essentially forever. + (Mark bits were sometimes set before scanning dirty pages. + The reclaim phase unnecessarily dirtied full small object pages.) + - Changed the reclaim phase to ignore nearly full pages to avoid + touching them. + - Limited GC_black_list_spacing to roughly the heap growth increment. + - Changed full collection triggering heuristic to decrease full GC + frequency by default, but to explicitly trigger full GCs during + heap growth. This doesn't always improve things, but on average it's + probably a win. + - GC_debug_free(0, ...) failed. Thanks to Fergus Henderson for the + bug report and fix. + +Since 5.0 alpha4 + - GC_malloc_explicitly_typed and friends sometimes failed to + initialize first word. + - Added allocation routines and support in the marker for mark descriptors + in a type structure referenced by the first word of an object. This was + introduced to support gcj, but hopefully in a way that makes it + generically useful. + - Added GC_requested_heapsize, and inhibited collections in nonincremental + mode if the actual used heap size is less than what was explicitly + requested. + - The Solaris pthreads version of GC_pthread_create didn't handle a NULL + attribute pointer. Solaris thread support used the wrong default thread + stack size. (Thanks to Melissa O'Neill for the patch.) + - Changed PUSH_CONTENTS macro to no longer modify first parameter. + This usually doesn't matter, but it was certainly an accident waiting + to happen ... + - Added GC_register_finalizer_no_order and friends to gc.h. They're + needed by Java implementations. + - Integrated a fix for a win32 deadlock resulting from clock() calling + malloc. (Thanks to Chris Dodd.) + - Integrated Hiroshi Kawashima's port to Linux/MIPS. This was designed + for a handheld platform, and may or may not be sufficient for other + machines. + - Fixed a va_arg problem with the %c specifier in cordprnt.c. It appears + that this was always broken, but recent versions of gcc are the first to + report the (statically detectable) bug. + - Added an attempt at a more general solution to dlopen races/deadlocks. + GC_dlopen now temporarily disables collection. Still not ideal, but ... + - Added -DUSE_I686_PREFETCH, -DUSE_3DNOW_PREFETCH, and support for IA64 + prefetch instructions. May improve performance measurably, but I'm not + sure the code will run correctly on processors that don't support the + instruction. Won't build except with very recent gcc. + - Added caching for header lookups in the marker. This seems to result + in a barely measurable performance gain. Added support for interleaved + lookups of two pointers, but unconfigured that since the performance + gain is currently near zero, and it adds to code size. + - Changed Linux DATA_START definition to check both data_start and + __data_start, since nothing else seems to be portable. + - Added -DUSE_LD_WRAP to optionally take advantage of the GNU ld function + wrapping mechanism. Probably currently useful only on Linux. + - Moved some variables for the scratch allocator into GC_arrays, on + Martin Hirzel's suggestion. + - Fixed a win32 threads bug that caused the collector to not look for + interior pointers from one of the thread stacks without + ALL_INTERIOR_POINTERS. (Thanks to Jeff Sturm.) + - Added Mingw32 support. (Thanks again to Jeff Sturm for the patch.) + - Changed the alpha port to use the generic register scanning code instead + of alpha_mach_dep.s. Alpha_mach_dep.s doesn't look for pointers in fp + registers, but gcc sometimes spills pointers there. (Thanks to Manuel + Serrano for helping me debug this by email.) Changed the IA64 code to + do something similar for similar reasons. + +[5.0alpha5 doesn't really exist, but it may have escaped.] + +Since 5.0alpha6: + - -DREDIRECT_MALLOC was broken in alpha6. Fixed. + - Cleaned up gc_ccp.h slightly, thus also causing the HP C++ compiler to + accept it. + - Removed accidental reference to dbg_mlc.c, which caused dbg_mlc.o to be + linked into every executable. + - Added PREFETCH to bitmap marker. Changed it to use the header cache. + - GC_push_marked sometimes pushed one object too many, resulting in a + segmentation fault in GC_mark_from_mark_stack. This was probably an old + bug. It finally showed up in gctest on win32. + - Gc_priv.h erroneously #defined GC_incremental to be TRUE instead of FALSE + when SMALL_CONFIG was defined. This was no doubt a major performance bug for + the default win32 configuration. + - Removed -DSMALL_CONFIG from NT_MAKEFILE. It seemed like an anchronism now + that the average PC has 64MB or so. + - Integrated Bryce McKinley's patches for linux threads and dynamic loading + from the libgcj tree. Turned on dynamic loading support for Linux/PPC. + - Changed the stack finding code to use environ on HP/UX. (Thanks + to Gustavo Rodriguez-Rivera for the suggestion.) This should probably + be done on other platforms, too. Since I can't test those, that'll + wait until after 5.0. + +Since 5.0alpha7: + - Fixed threadlibs.c for linux threads. -DUSE_LD_WRAP was broken and + -ldl was omitted. Fixed Linux stack finding code to handle + -DUSE_LD_WRAP correctly. + - Added MSWIN32 exception handler around marker, so that the collector + can recover from root segments that are unmapped during the collection. + This caused occasional failures under Windows 98, and may also be + an issue under Windows NT/2000. + +Since 5.0 + - Fixed a gc.h header bug which showed up under Irix. (Thanks to + Dan Sullivan.) + - Fixed a typo in GC_double_descr in typd_mlc.c. + This probably could result in objects described by array descriptors not + getting traced correctly. (Thanks to Ben Hutchings for pointing this out.) + - The block nearly full tests in reclaim.c were not correct for 64 bit + environments. This could result in unnecessary heap growth under unlikely + conditions. + +Since 5.1 + - dyn_load.c declared GC_scratch_last_end_ptr as an extern even if it + was defined as a macro. This prevented the collector from building on + Irix. + - We quietly assumed that indirect mark descriptors were never 0. + Our own typed allocation interface violated that. This could result + in segmentation faults in the marker with typed allocation. + - Fixed a _DUSE_MUNMAP bug in the heap block allocation code. + (Thanks to Ben Hutchings for the patch.) + - Taught the collector about VC++ handling array operator new. + (Thanks again to Ben Hutchings for the patch.) + - The two copies of gc_hdrs.h had diverged. Made one a link to the other + again. + +Since 5.2 (A few 5.2 patches are not in 6.0alpha1) + - Fixed _end declaration for OSF1. + - There were lots of spurious leak reports in leak detection mode, caused + by the fact that some pages were not being swept, and hence unmarked + objects weren't making it onto free lists. (This bug dated back to 5.0.) + - Fixed a typo in the liblinuxgc.so Makefile rule. + - Added the GetExitCodeThread to Win32 GC_stop_world to (mostly) work + around a Windows 95 GetOpenFileName problem. (Thanks to Jacob Navia.) + +Since 5.3 + - Fixed a typo that prevented compilation with -DUSE_3DNOW_PREFETCH. + (Thanks to Shawn Wagner for actually testing this.) + - Fixed GC_is_thread_stack in solaris_threads.c. It forgot to return a value + in the common case. I wonder why nobody noticed? + - Fixed another silly syntax problem in GC_double_descr. (Thanks to + Fergus Henderson for finding it.) + - Fixed a GC_gcj_malloc bug: It tended to release the allocator lock twice. + +Since 5.4 (A few 5.3 patches are not in 6.0alpha2) + - Added HP/PA prefetch support. + - Added -DDBG_HDRS_ALL and -DSHORT_DBG_HDRS to reduce the cost and improve + the reliability of generating pointer backtrace information, e.g. in + the Bigloo environment. + - Added parallel marking support (-DPARALLEL_MARK). This currently + works only under IA32 and IA64 Linux, but it shouldn't be hard to adapt + to other platforms. This is intended to be a lighter-weight (less + new code, probably not as scalable) solution than the work by Toshio Endo + et al, at the University of Tokyo. A number of their ideas were + reused, though the code wasn't, and the underlying data structure + is significantly different. In particular, we keep the global mark + stack as a single shared data structure, but most of the work is done + on smaller thread-local mark stacks. + - Changed GC_malloc_many to be cheaper, and to require less mutual exclusion + with -DPARALLEL_MARK. + - Added full support for thread local allocation under Linux + (-DTHREAD_LOCAL_ALLOC). This is a thin veneer on GC_malloc_many, and + should be easily portable to other platforms, especially those that + support pthreads. + - CLEAR_DOUBLE was not always getting invoked when it should have been. + - GC_gcj_malloc and friends used different out of memory handling than + everything else, probably because I forgot about one when I implemented + the other. They now both call GC_oom_fn(), not GC_oom_action(). + - Integrated Jakub Jelinek's fixes for Linux/SPARC. + - Moved GC_objfreelist, GC_aobjfreelist, and GC_words_allocd out of + GC_arrays, and separately registered the first two as excluded roots. + This makes code compiled with gc_inl.h less dependent on the + collector version. (It would be nice to remove the inclusion of + gc_priv.h by gc_inl.h completely, but we're not there yet. The + locking definitions in gc_priv.h are still referenced.) + This change was later coniditoned on SEPARATE_GLOBALS, which + is not defined by default, since it involves a performance hit. + - Register GC_obj_kinds separately as an excluded root region. The + attempt to register it with GC_arrays was usually failing. (This wasn't + serious, but seemed to generate some confusion.) + - Moved backptr.h to gc_backptr.h. + +Since 6.0alpha1 + - Added USE_MARK_BYTES to reduce the need for compare-and-swap on platforms + for which that's expensive. + - Fixed a locking bug ib GC_gcj_malloc and some locking assertion problems. + - Added a missing volatile to OR_WORD and renamed the parameter to + GC_compare_and_swap so it's not a C++ reserved word. (Thanks to + Toshio Endo for pointing out both of those.) + - Changed Linux dynamic library registration code to look at /proc/self/maps + instead of the rld data structures when REDIRECT_MALLOC is defined. + Otherwise some of the rld data data structures may be prematurely garbage + collected. (Thanks to Eric Benson for helping to track this down.) + - Fixed USE_LD_WRAP a bit more, so it should now work without threads. + - Renamed XXX_THREADS macros to GC_XXX_THREADS for namespace correctness. + Tomporarily added some backward compatibility definitions. Renamed + USE_LD_WRAP to GC_USE_LD_WRAP. + - Many MACOSX POWERPC changes, some additions to the gctest output, and + a few minor generic bug fixes. (Thanks to Dietmar Planitzer.) + +Since 6.0 alpha2 + - Fixed the /proc/self/maps code to not seek, since that apparently is not + reliable across all interesting kernels. + - Fixed some compilation problems in the absence of PARALLEL_MARK + (introduced in alpha2). + - Fixed an algorithmic problem with PARALLEL_MARK. If work needs to + be given back to the main mark "stack", the BOTTOM entries of the local + stack should be given away, not the top ones. This has substantial + performance impact, especially for > 2 processors, from what I can tell. + - Extracted gc_lock.h from gc_priv.h. This should eventually make it a + bit easier to avoid including gc_priv.h in clients. + - Moved all include files to include/ and removed duplicate links to the + same file. The old scheme was a bad idea because it was too easy to get the + copies out of sync, and many systems don't support hard links. + Unfortunately, it's likely that I broke some of the non-Unix Makefiles in + the process, although I tried to update them appropriately. + - Removed the partial support for a copied nursery. It's not clear that + this would be a tremendous win, since we don't consistently lose to + generational copying collectors. And it would significantly complicate + many things. May be reintroduced if/when it really turns out to win. + - Removed references to IRIX_JDK_THREADS, since I believe there never + were and never will be any clients. + - Added some code to linux_threads.c to possibly support HPUX threads + using the Linux code. Unfortunately, it doesn't work yet, and is + currently disabled. + - Added support under Linux/X86 for saving the call chain, both in (debug) + objects for client debugging, and in GC_arrays._last_stack for GC + debugging. This was previously supported only under Solaris. It is + not enabled by default under X86, since it requires that code be compiled + to explicitly dave frame pointers on the call stack. (With gcc this + currently happens by default, but is often turned off explicitly.) + To turn it on, define SAVE_CALL_CHAIN. + +Since 6.0 alpha3 + - Moved up the detection of mostly full blocks to the initiatiation of the + sweep phase. This eliminates some lock conention in the PARALLEL_MARK case, + as multiple threads try to look at mostly full blocks concurrently. + - Restored the code in GC_malloc_many that grabs a prefix of the global + free list. This avoids the case in which every GC_malloc_many call + tries and fails to allocate a new heap block, and the returns a single + object from the global free list. + - Some minor fixes in new_hblk.c. (Attempted to build free lists in order + of increasing addresses instead of decreasing addresses for cache performance + reasons. But this seems to be only a very minor gain with -DEAGER_SWEEP, + and a loss in other cases. So the change was backed out.) + - Fixed some of the documentation. (Thanks in large part to Fergus + Henderson.) + - Fixed the Linux USE_PROC_FOR_LIBRARIES code to deal with apps that perform + large numbers of mmaps. (Thanks to Eric Benson.) Also fixed that code to + deal with short reads. + - Added GC_get_total_bytes(). + - Fixed leak detection mode to avoid spurious messages under linuxthreads. + (This should also now be easy for the other supported threads packages. + But the code is tricky enough that I'm hesitant to do it without being able + to test. Everything allocated in the GC thread support itself should be + explicitly deallocated.) + - Made it possible (with luck) to redirect malloc to GC_local_malloc. + +Since 6.0 alpha4 + - Changed the definition of GC_pause in linux_threads.c to use a volatile + asm. Some versions of gcc apparently optimize away writes to local volatile + variables. This caused poor locking behaviour starting at about + 4 processors. + - Added GC_start_blocking(), GC_end_blocking() calls and wrapper for sleep + to linux_threads.c. + The first two calls could be used to generally avoid sending GC signals to + blocked threads, avoiding both premature wakeups and unnecessary overhead. + - Fixed a serious bug in thread-local allocation. At thread termination, + GC_free could get called on small integers. Changed the code for thread + termination to more efficiently return left-over free-lists. + - Integrated Kjetil Matheussen's BeOS support. + - Rearranged the directory structure to create the doc and tests + subdirectories. + - Sort of integrated Eric Benson's patch for OSF1. This provided basic + OSF1 thread support by suitably extending hpux_irix_threads.c. Based + on earlier email conversations with David Butenhof, I suspect that it + will be more reliable in the long run to base this on linux_threads.c + instead. Thus I attempted to patch up linux_threads.c based on Eric's code. + The result is almost certainly broken, but hopefully close enough that + someone with access to a machine can pick it up. + - Integrated lots of minor changes from the NetBSD distribution. (These + were supplied by David Brownlee. I'm not sure about the original + authors.) + - Hacked a bit more on the HP/UX thread-support in linux_threads.c. It + now appears to work in the absence of incremental collection. Renamed + hpux_irix_threads.c back to irix_threads.c, and removed the attempt to + support HPUX there. + - Changed gc.h to define _REENTRANT in cases in which it should already + have been defined. It is still safer to also define it on the command + line. + +Since 6.0alpha5: + - Changed the definition of DATASTART on ALPHA and IA64, where data_start + and __data_start are not defined by earlier versions of glibc. This might + need to be fixed on other platforms as well. + - Changed the way the stack base and backing store base are found on IA64. + This should now remain reliable on future kernels. But since it relies + on /proc, it will no longer work in the simulated NUE environment. + - Made the call to random() in dbg_mlc.c with -DKEEP_BACK_PTRS dependent + on the OS. On non-Unix systems, rand() should be used instead. Handled + small RAND_MAX. (Thanks to Peter Ross for pointing this out.) + - Fixed the cord make rules to create the cord subdirectory, if necessary. + (Thanks to Doug Moen.) + - Changed fo_object_size calculation in finalize.c. Turned finalization + of nonheap object into a no-op. Removed anachronism from GC_size() + implementation. + - Changed GC_push_dirty call in solaris_threads.c to GC_push_selected. + It was missed in a previous renaming. (Thanks to Vladimir Tsichevski + for pointing this out.) + - Arranged to not not mask SIGABRT in linux_threads.c. (Thanks to Bryce + McKinlay.) + - Added GC_no_dls hook for applications that want to register their own + roots. + - Integrated Kjetil Matheussen's Amiga changes. + - Added FREEBSD_STACKBOTTOM. Changed the X86/FreeBSD port to use it. + (Thanks to Matthew Flatt.) + - Added pthread_detach interception for platforms supported by linux_threads.c + and irix_threads.c. Should also be added for Solaris? + - Changed the USE_MMAP code to check for the case in which we got the + high end of the address space, i.e. mem_ptr + mem_sz == 0. It appears + that this can happen under Solaris 7. It seems to be allowed by what + I would claim is an oversight in the mmap specification. (Thanks to Toshio + Endo for pointing out the problem.) + - Cleanup of linux_threads.c. Some code was originally cloned from + irix_threads.c and now unnecessary. Some comments were obviously wrong. + - (Mostly) fixed a longstanding problem with setting of dirty bits from + a signal handler. In the presence of threads, dirty bits could get lost, + since the etting of a bit in the bit vector was not atomic with respect + to other updates. The fix is 100% correct only for platforms for which + GC_test_and_set is defined. The goal is to make that all platforms with + thread support. Matters only if incremental GC and threads are both + enabled. + - made GC_all_interior_pointers (a.k.a. ALL_INTERIOR_POINTERS) an + initialization time, instead of build-time option. This is a + nontrivial, high risk change. It should slow down the code measurably + only if MERGE_SIZES is not defined, which is a very nonstandard + configuration. + - Added doc/README.environment, and implemented what it describes. This + allows a number of additional configuration options to be set through + the environment. It documents a few previously undocumented options. + - Integrated Eric Benson's leak testing improvements. + - Removed the option to throw away the beginning of each page (DISCARD_WORDS). + This became less and less useful as processors enforce stricter alignment. + And it hadn't been tested in ages, and was thus probably broken anyway. + +Since 6.0alpha6: + - Added GC_finalizer_notifier. Fixed GC_finalize_on_demand. (The variable + actually wasn't being tested at the right points. The build-time flag + was.) + - Added Tom Tromey's S390 Linux patch. + - Added code to push GC_finalize_now in GC_push_finalizer_structures. + (Thanks to Matthew Flatt.) + - Added GC_push_gc_structures() to push all GC internal roots. + - Integrated some FreeBSD changes from Matthew Flatt. + - It looks like USRSTACK is not always correctly defined under Solaris. + Hacked gcconfig.h to attempt to work around the problem. The result + is not well tested. (Thanks again to Matthew Flatt for pointing this + out. The gross hack is mine. - HB) + - Added Ji-Yong Chung's win32 threads and C++ fixes. + - Arranged for hpux_test_and_clear.s to no longer be needed or built. + It was causing build problems with gas, and it's not clear this is + better than the pthreads alternative on this platform. + - Some MINGW32 fixes from Hubert Garavel. + - Added Initial Hitachi SH4 port from Kaz Kojima. + - Ported thread-local allocation and parallel mark code to HP/UX on PA_RISC. + - Made include/gc_mark.h more public and separated out the really private + pieces. This is probably still not quite sufficient for clients that + want to supply their own kind of type information. But it's a start. + This involved lots of identifier renaming to make it namespace clean. + - Added GC_dont_precollect for clients that need complete control over + the root set. + - GC_is_visible didn't do the right thing with gcj objects. (Not that + many people are likely to care, but ...) + - Don't redefine read with GC_USE_LD_WRAP. + - Initial port to LINUX/HP_PA. Incremental collection and threads are not + yet supported. (Incremental collection should work if you have the + right kernel. Threads may work with a sufficiently patched pthread + library.) + - Changed gcconfig.h to recognize __i386__ as an alternative to i386 in + many places. (Thanks to Benjamin Lerman.) + - Made win32_threads.c more tolerant of detaching a thread that it didn't + know about. (Thanks to Paul Nash.) + - Added Makefile.am and configure.in from gcc to the distribution, with + minimal changes. For the moment, those are just placeholders. In the + future, we're planning to switch to a GNU-style build environment for + Un*x-like systems, though the old Makefile will remain as a backup. + - Turned off STUBBORN_ALLOC by default, and added it back as a Makefile + option. + - Redistributed some functions between malloc.c and mallocx.c, so that + simple statically linked apps no longer pull in mallocx.o. + - Changed large object allocation to clear the first and last few words + of each block before releassing the lock. Otherwise the marker could see + objects with nonsensical type descriptors. + - Fixed a couple of subtle problems that could result in not recognizing + interior pointers from the stack. (I believe these were introduced + in 6.0alpha6.) + - GC_debug_free_inner called GC_free, which tried to reacquire the + allocator lock, and hence deadlocked. (DBG_HDRS_ALL probably never worked + with threads?) + - Fixed several problems with back traces. Accidental references to a free + list could cause the free list pointer to be overwritten by a back pointer. + There seemed to be some problems with the encoding of root and finalizer + references. + +Since 6.0alpha7: + - Changed GC_debug_malloc_replacement and GC_debug_realloc_replacement + so that they compile under Irix. (Thanks to Dave Love.) + - Updated powerpc_macosx_mach_dep.s so that it works if the collector + is in a dynamic library. (Thanks to Andrew Begel.) + - Transformed README.debugging into debugging.html, updating and + expanding it in the process. Added gcdescr.html and tree.html + from the web site to the GC distribution. + - Fixed several problems related to PRINT_BLACK_LIST. This involved + restructuring some of the marker macros. + - Fixed some problems with the sizing of objects with debug information. + Finalization was broken KEEP_BACK_PTRS or PRINT_BLACK_LIST. Reduced the + object size with SHORT_DEBUG_HDRS by another word. + - The "Needed to allocate blacklisted ..." warning had inadvertently + been turned off by default, due to a buggy test in allchblk.c. Turned + it back on. + - Removed the marker macros to deal with 2 pointers in interleaved fashion. + They were messy and the performance improvement seemed minimal. We'll + leave such scheduling issues to the compiler. + - Changed Linux/PowerPC test to also check for __powerpc__ in response + to a discussion on the gcc mailing list. + - On Matthew Flatt's suggestion removed the "static" from the jmp_buf + declaration in GC_generic_push_regs. This was causing problems in + systems that register all of their own roots. It looks far more correct + to me without the "static" anyway. + - Fixed several problems with thread local allocation of pointerfree or + typed objects. The collector was reclaiming thread-local free lists, since + it wasn't following the link fields. + - There was apparently a long-standing race condition related to multithreaded + incremental collection. A collection could be started and a thread stopped + between the memory unprotect system call and the setting of the + corresponding dirt bit. I believe this did not affect Solaris or PCR, which + use a different dirty-bit implementation. Fixed this by installing + signal handlers with sigaction instead of signal, and disabling the thread + suspend signal while in the write-protect handler. (It is unclear + whether this scenario ever actually occurred. I found it while tracking + down the following:) + - Incremental collection did not cooperate correctly with the PARALLEL_MARK + implementation of GC_malloc_many or the local_malloc primitves. It still + doesn't work well, but it shouldn't lose memory anymore. + - Integrated some changes from the gcc source tree that I had previously + missed. (Thanks to Bryce McKinley for the reminder/diff.) + - Added Makefile.direct as a copy of the default Makefile, which would + normally be overwritten if configure is run. + - Changed the gc.tar target in Makefile.direct to embed the version number + in the gc directory name. This will affect future tar file distributions. + - Changed the Irix dynamic library finding code to no longer try to + eliminate writable text segments under Irix6.x, since that is probably no + longer necessary, and can apparently be unsafe on occasion. (Thanks to + Shiro Kawai for pointing this out.) + - GC_cleanup with GC_DEBUG enabled passed a real object base address to + GC_debug_register_finalizer_ignore_self, which expected a pointer past the + debug header. Call GC_register_finalizer_ignore_self instead, even with + debugging enabled. (Thanks to Jean-Daniel Fekete for catching this.) + - The collector didn't build with call chain saving enabled but NARGS=0. + (Thanks to Maarten Thibaut.) + - Fixed up the GNU-style build files enough so that they work in some + obvious cases. + - Added initial port to Digital Mars compiler for win32. (Thanks to Walter + Bright.) + +Since 6.0alpha8: + - added README.macros. + - Made gc.mak a symbolic link to work around winzip's tendency to ignore + hard links. + - Simplified the setting of NEED_FIND_LIMIT in os_dep.c, possibly breaking + it on untested platforms. + - Integrated initial GNU HURD port. (Thanks to Chris Lingard and Igor + Khavkine.) + - A few more fixes for Digital Mars compiler (Walter Bright). + - Fixed gcc version recognition. Renamed OPERATOR_NEW_ARRAY to + GC_OPERATOR_NEW_ARRAY. Changed GC_OPERATOR_NEW_ARRAY to be the default. + It can be overridden with -DGC_NO_OPERATOR_NEW_ARRAY. (Thanks to + Cesar Eduardo Barros.) + - Changed the byte size to free-list mapping in thread local allocation + so that size 0 allocations are handled correctly. + - Fixed Linux/MIPS stackbottom for new toolchain. (Thanks to Ryan Murray.) + - Changed finalization registration to invoke GC_oom_fn when it runs out + of memory. + - Removed lvalue cast in finalize.c. This caused some debug configurations + not to build with some non-gcc compilers. + +Since 6.0alpha9: + - Two more bug fixes for KEEP_BACK_PTRS and DBG_HDRS_ALL. + - Fixed a stack clearing problem that resulted in SIGILL with a + misaligned stack pointer for multithreaded SPARC builds. + - Integrated another HURD patch (thanks to Igor Khavkine). + +Since 6.0: + - Non-debug, atomic allocations could result in bogus smashed object + reports with debugging on. (Thanks to Patrick Doyle for the small + test case.) + - Fixed GC_get_register_stack_base (Itanium only) to work around a glibc + 2.2.4 bug. + - Initial port to HP/UX on Itanium. Thread support and both 32 and 64 + bit ABIs appear to work. Parallel mark support doesn't yet, due to + some inline assembly code issues. Thread local allocation does appear + to work. + - ifdef'ed out glibc2.1/Itanium workaround. I suspect nobody is using + that combination anymore. + - Added a patch to make new_gc_alloc.h usable with gcc3.0. (Thanks to + Dimitris Vyzovitis for the patch.) + - Debugged 64-bit support on HP/UX PA-RISC. + - Turned on dynamic loading support for FreeBSD/ELF. (Thanks to Peter + Housel.) + - Unregistering of finalizers with debugging allocation was broken. + (Thanks to Jani Kajala for the test case.) + - Old finalizers were not returned correctly from GC_debug_register_finalizer. + - Disabled MPROTECT_VDB for Linux/M68K based on a report that it doesn't work. + - Cleaned up some statistics gathering code in reclaim.c (Thanks to Walter + Bright.) + - Added some support for OpenBSD/ELF/Linux. (Thanks to Suzuki Toshiya.) + - Added Jakub Jelinek's patch to use dl_iterate_phdr for dynamic library + traversal to dyn_load.c. Changed it to weakly reference dl_iterate_phdr, + so that the old code is stilll used with old versions of glibc. + - Cleaned up feature test macros for various threads packages and + integrated (partially functional) FreeBSD threads code from Loren Rittle. + It's likely that the cleanup broke something, since it touched lots of + code. It's also likelly that it fixed some unreported bugs in the + less common thread implementations, since some of the original code + didn't stand up to close scrutiny. Support for the next pthreads + implementation should be easier to add. + +Since 6.1alpha1: + - No longer wrap read by default in multithreaded applications. It was + pointed out on the libgcj list that this holds the allocation lock for + way too long if the read blocks. For now, reads into the heap are + broken with incremental collection. It's possible to turn this back on + if you make sure that read calls don't block (e.g. by calling select + first). + - Fix ifdef in Solaris_threads.h to refer to GC_SOLARIS_THREADS. + - Added check for environment variable GC_IGNORE_GCJ_INFO. + - Added printing of stop-the-world GC times if GC_PRINT_STATS environment + variable is set. + - The calloc definition in leak_detector.h was missing parentheses, and + realloc was missing a second argument to GC_REALLOC. + (Thanks to Elrond (elrondsamba-tng.org).) + - Added GC_PRINT_BACK_HEIGHT environment variable and associated + code, mostly in the new file backgraph.c. See doc/README.environment. + - Added -DUSE_GLOBAL_ALLOC to work around a Windows NT issue. (Thanks to + Jonathan Clark.) + - Integrated port to NEC EWS4800 (MIPS-based workstation, with somewhat + different address-space layout). This may help for other machines with + holes in the data segment. (Thanks to Hironori Sakamoto.) + - Changed the order in which GC_push_roots and friends push things onto + the mark stack. GC_push_all calls need to come first, since we can't + necessarily recovere if those overflow the mark stack. (Thanks to + Matthew Flatt for tracking down the problem.) + - Some minor cleanups to mostly support the Intel compiler on Linux/IA64. + +Since 6.1 alpha2: + - Minor cleanup on the gcconfig.h section for SPARC. + - Minor fix to support Intel compiler for I386/Linux. (Thanks to Sven + Hartrumpf.) + - Added SPARC V9 (64-bit) support. (Thanks to Jeff Sturm.) + - Restructured the way in which we determine whether or not to keep + call stacks for debug allocation. By default SAVE_CALL_COUNT is + now zero on all platforms. Added SAVE_CALL_NARGS parameters. + If possible, use execinfo.h to capture call stack. (This should + add support for a number of new platforms, though often at + considerable runtime expense.) + - Try to print symbolic information for call stacks. On Linux, we + do this with a combination of execinfo.h and running addr2line in + a separate process. This is both much more expensive and much more + useful. Amazingly, it seems to be fast enough for most purposes. + - Redefined strdup if -DREDIRECT_MALLOC is given. + - Changed incremental collector and MPROTECT_VDB implementation so that, + under favorable conditions, pointerfree objects are not protected. + Added GC_incremental_protection_needs() to determine ahead of time whether + pointerfree objects may be protected. Replaced GC_write_hint() with + GC_remove_protection(). + - Added test for GC_ENABLE_INCREMENTAL environment variable. + - Made GC_time_limit runtime configurable. Added GC_PAUSE_TIME_TARGET + environment variable. + - Eliminated GC_page_sz, a duplicate of GC_page_size. + - Caused the Solaris and Irix thread creation primitives to call + GC_init_inner(). + +Since 6.1alpha3: + - Fixed typo in sparc_mach_dep.S, preventing the 64-bit version from + building. Increased 64-bit heap size limit in test.c slightly, since + a functional SPARC collector seems to slightly exceed the old limits. + (Thanks again to Jeff Sturm.) + - Use NPRGREG in solaris_threads.c, thus printing all registers if things + go wrong. + - Added GC_MARKERS environment variable to allow use of a single marker + thread on an MP without confusing the lock implementation. + - Collect much less aggressively in incremental mode with GC_TIME_UNLIMITED. + This is really a purely generational mode, and we can afford to + postpone the collection until the heap is (nearly) full. + - Remove read() wrapper for MPROTECT_VDB. It was causing more harm than + good. It is often no longer needed if system calls avoid writing to + pointerfull heap objects. + - Fix MACOSX test in gcconfig.h. (Thanks to John Clements.) + - Change GC_test_and_set so that it consistently has one argument. + Add spaces to ::: in powerpc assembly code in gc_locks.h. + (Thanks to Ryan Murray.) + - Fixed a formatting error in dbg_mlc.c. Added prototype to GC_abort() + declaration. (Thanks to Michael Smith.) + - Removed "source" argument to GC_find_start(). Eliminate GC_FIND_START(). + - Added win32 recognition code in configure.in. Changed some of the + dllimport/export defines in gc.h. (Thanks to Adam Megacz.) + - GC_malloc_many didn't set hb_last_reclaimed when it called + GC_reclaim_generic. (I'm not sure this matters much, but ...) + - Allocating uncollectable objects with debug information sometimes + allocated objects that were one byte too small, since uncollectable + objects don't have the extra byte added at the end. (Thanks to + Wink Saville for pointing this out.) + - Added a bit more assertion checking to make sure that gcj objects + on free lists never have a nonzero second word. + - Replaced BCC_MAKEFILE with an up-to-date one. (Thanks to + Andre Leiradella.) + - Upgraded libtool, cinfigure.in and some related files to hopefully + support NetBSD/SPARC. (Thanks to Adrian Bunk.) Unfortunately, + libtool 1.4.2 seemed to be buggy due to missing quotes in several + "test" invocations. Fixed those in the ltmain.sh script. + - Some win32-specific patches, including the introduction of + GC_CreateThread. (Thanks to Adam Megacz.) + - Merged in gcj changes from Anthony Green to support embedded systems. + - Tried to consistently rename preprocessed assembly files with a capital + .S extension. + - Use alpha_mach_dep.S on ALPHA again. It doesn't really matter, but this + makes our distribution consistent with the gcc one, avoiding future merge + problems. + - Move GET_MEM definition into gcconfig.h. Include gcconfig.h slightly + later in gc_priv.h to avoid forward references to ptr_t. + - Add some testing of local allocation to test.c. + - Change definition of INVALID_QTID in specific.h. The -1 value was used + inconsistently, and too likely to collide with a valid stack address. + Some general clean-up of specific.[ch]. Added assertions. (Thanks + to Michael Smith for tracking down an intermittent bug to this + general area. I'm not sure it has been squashed yet, however.) + - On Pthread systems it was not safe to call GC_malloc() between fork() + and exec(). According to the applicable standards, it doesn't appear + to be safe to call malloc() or many other libc functions either, thus + it's not clear this is fixable. Added experimental support for + -DHANDLE_FORK in linux_threads.c which tries to support it. It may + succeed if libc does the right thing. I'm not sure whether it does. + (Thanks to Kenneth Schalk for pointing out this issue.) + - Documented thread local allocation primitives to require an + explicit GC_init call. GC_init_parallel is no longer declared to + be a constructor function, since that isn't portable and often + seems to lead to initialization order problems. + - Changed gc_cpp.cc and gc_cpp.h in one more attempt to make them + compatible with Visual C++ 6. (Thanks to Wink Saville for the + patch.) + - Some more patches for Linux on HP PA-RISC. + - Added include/gc_allocator.h. It implements (hopefully) standard + conforming (as opposed to SGI-style) allocators that allocate + collectable (gc_allocator) or GC-traceable, but not collectable + (traceable_allocator) objects. This borrows heavily from libstc++, + which borrows heavily from the SGI implementation, this part of + which was written by Matt Austern. Changed test_cpp.cc to very + minimally test this. + - On Linux/X86, retry mmap with a different start argument. That should + allow the collector to use more (closer to 3GB) of the address space. + (Thanks to Jeffrey Mark Siskind for tracking this down.) + - Force 64 bit alignment with GCJ support. (Reflects Bryce McKinley's + patch to the gcc tree.) + - Refined the choice of sa_handler vs. sa_sigaction in GC_dirty_init + to accomodate some glibc5 systems. (Thanks to Dan Fandrich for the + patch.) + - Compensated for the fact that current versions of glibc set + __libc_stack_end incorrectly on Linux/IA64 while initialization code + is running. This could cause the collector to miss 16 bytes of + the memory stack if GC_malloc or friends where called before main(). + - Mostly integrated Takis Psarogiannakopoulos' port to DG/UX Inix 86. + This will probably take another iteration to work, since his + patch conflicted with the libtool upgrade. + - Added README.arm.cross containing some information about cross- + compiling to an ARM processor from Margaret Fleck. + +Since 6.1alpha4: + - Added GC_finalizer_mem_freed, and changed some of the code that + decided on heap expansion to look at it. Memory explicitly + deallocated by finalizers essentially needs to be counted as reclaimed + by the GC. Otherwise there are cases in which the heap can grow + unboundedly. (Thanks to Mark Reichert for the test case.) + - Integrated Adam Megacz patches to not scan dynamic libraries if + we are compiling with gcc on win32. Otherwise we need structured + exception handling to deal with asynchronously unmapped root + segments, and gcc doesn't directly support that. + - Integrated Anthony Green's patch to support Wine. + - GC_OPERATOR_NEW_ARRAY was misspelled OPERATOR_NEW_ARRAY in several + places, including gc_cpp.cc. (Thanks to Wink Saville for pointing + this out.) + - Integrated Loren James Rittle's Alpha FreeBSD patches. In + response to Richard Henderson's suggestion, these also + changed the declarations of symbols like _end on many platforms to + that they wouldn't mistakenly be declared as short data symbols. + - Integrated changes from the Debian distribution. (Thanks to Ryan Murray + for pointing these out.) Fix C++ comments in POWERPC port. Add ARM32 + incremental GC support. Get rid of USE_GENERIC_PUSH_REGS for alpha/Linux, + this time for real. Use va_copy to get rid of cord printf problems + (finally). + - Close file descriptor used to count cpus. Thanks to Jeff Sturm for + pointing out the omission. + - Don't just drop gcj free lists in GC_start_reclaim, since that can + eventually cause the marker to see a bogus mark descriptor in the + dropped objects. The usual symptom was a very intermittent segmentation + fault in the marker. This mattered only if one of the GC_gcj_malloc + variants was used. (Thanks to Michael Smith, Jeff Sturm, Bryce + McKinley and Tom Tromey for helping to track this down.) + - Fixed Linux and Solaris/64 SPARC configuration. (Thanks to David Miller, + Jeff Sturm, Tom Tromey, and Christian Joensson.) + - Fixed a typo in strdup definition. (Thanks to Gerard A Allan.) + - Changed Makefile.direct to invoke $(CC) to assemble alpha_mach_dep.S. + This is needed on Linux. I'm not sure whether it's better or worse + on Tru64. + - Changed gc_cpp.h once more to declare operator new and friends only in + a Microsoft environment. This may need further fine tuning. (Thanks to + Johannes Schmidt for pointing out that the older code breaks on gcc3.0.4.) + - Don't ever override strdup if it's already macro defined. (Thanks to + Adnan Ali for pointing out the problem.) + - Changed gc_cpp.h yet again to also overload placement new. Due to the + C++ overloading rules, the other overloaded new operations otherwise hide + placement new, which causes many STL uses to break. (Thanks to Reza + Shahidi for reporting this, and to Matt Austern for proposing a fix.) + - Integrated cygwin pthreads support from Dan Bonachea. + - Turn on DYNAMIC_LOADING for NetBSD. (Thanks to Krister Walfridsson.) + - Changed printing code to print more complete GC times. + - Applied Mark Mitchell's Irix patch to correct some bitrot. + - Clarified which object-printing routines in dbg_mlc.c should hold + the allocation lock. Restructured the code to allow reasonable object + printing with -DREDIRECT_MALLOC. + - Fix the Linux mmap code to always start with 0x1000 as the initial hint. + Minor patches for 64-bit AIX, particularly to STACKBOTTOM. + (Thanks again to Jeffrey Mark Siskind.) + - Renamed "SUSPENDED" flag for Solaris threads support to avoid a conflict + with a system header. (Thanks to Philp Brown.) + - Cause win32_threads.c to handle an out of range stack pointer correctly, + though currently with a warning. (Thanks to Jonathan Clark for + observing that win32 applications may temporarily use the stack + pointer for other purposes, and suggesting a fix. Unfortunately, it's + not clear that there is a complete solution to this problem.) + +Since 6.1alpha5: + - Added GC_MAXIMUM_HEAP_SIZE environment variable. + - Fix configure.in for MIPS/LINUX. (Thanks to H.J. Lu.) + - Double page hash table size for -DLARGE_CONFIG. + - Integrated Bo Thorsen's X86-64 support. + - STACKBOTTOM definition for LINUX/MIPS was partially changed back. + (Thanks to H.J. Lu and Hiroshi Kawashima for resolving this.) + - Replaced all occurrences of LINUX_DATA_START in gcconfig.h with + SEARCH_FOR_DATA_START. It doesn't hurt to falll back to a search. + And __data_start doesn't seem to get defined correctly of the GC + library is loaded with LD_PRELOAD, e.g. for leak detection. + - If the GC_find_leak environment variable is set, do a + atexit(GC_gcollect) to give us at least one chance to detect leaks. + This may report some very benign leaks, but ... + - Addeded REDIRECT_FREE. It's necessary if we want leak detection with + LD_PRELOAD. + - Defer printing of leaked objects, as for smashed objects. + - Fixed process and descriptor leak in GC_print_callers. Try for + line number even if we got function name.) + - Ported parallel GC support and thread local allocation to Alpha. + Not yet well-tested. + - Added GC_DUMP_REGULARLY and added finalization statistics to GC_dump(). + - Fixed Makefile.am to mention alpha_mach_dep.S instead of the defunct + alpha_mach_dep.s. (Thanks to Fergus Henderson.) + - Incorporated a change to new_gc_alloc.h, suggested by Johannes Schmidt, + which should make it work with gcc3.1. (I would still like to encourage + use of gc_allocator.h instead.) + - Use alpha_mach_dep.S only on Linux. (It's not clear that this is + optimal, but it otherwise didn't build on Tru64. Thanks to Fergus + Henderson.) + - Added ifdef to guard free() in os_dep.c. Otherwise we get a + compilation error on Irix. (Thanks to Dai Sato.) + - Added an experimental version of GC_memalign to mallocx.c. This can't + always work, since we don't handle alignment requests in the hblk-level + allocator, and we can't handle arbitrary pointer displacements unless + GC_all_interior_pointers is enabled. But it should work for alignment + requests up to HBLKSIZE. This is not yet documented in the standard + places. + - Finally debugged the OSF1/Tru64 thread support. This needs more testing, + since I needed to add a somewhat unconvincing workaround for signal + delivery issues that I don't yet completely understand. But it does + pass my tests, even in parallel GC mode. Incremental GC support is + disabled if thread support is enabled, due to the signal issues. + - Eliminated name-space-incorrect definition of _cdecl from gc_cpp.h. + - Added GC_debug_malloc_replacement and GC_debug_realloc_replacement + declarations to gc.h. On IA64, this is required for REDIRECT_MALLOC + to work correctly with these. + - Fixed Linux USE_PROC_FOR_LIBRARIES to work with a 64-bit /proc format. + +Since 6.1: + - Guard the test for GC_DUMP_REGULARLY in misc.c with + "#ifndef NO_DEBUGGING". Otherwise it fails to build with NO_DEBUGGING + defined. (Thanks to Manuel Serrano.) + - Message about retrying suspend signals was incorrectly generated even when + flag was not set. + - Cleaned up MACOSX/NEXT root registration code. There was apparently a + separate ifdef case in GC_register_data_segments() for no reason. + - Removed MPROTECT_VDB for MACOSX port, based on one negative report. + - Arrange for gc.h and friends to be correctly installed with GNU-style + "make install". + - Enable the GNU-style build facility include C++ support in the library + with --enable-cplusplus. (Thanks to Thomas Maier for some of the patch.) + - Mark from GC_thread_key in linux_threads.c, in case that's allocated + from the garbage collected heap, as it is with our own thread-specific + storage implementation. (Thanks to Jeff Sturm.) + - Mark all free list header blocks if they are heap allocated. This avoids + some unnecessary tracing. And it remains correct if we clear the + root set. (Thanks to Jeff Sturm for identifying the bug.) + - Improved S390/Linux support. Add S390/Linux 64-bit support. (Thanks + to Ulrich Weigand.) + - Corrected the spelling of GC_{M,C}ALLOC_EXPLICTLY_TYPED to + GC_{M,C}ALLOC_EXPLICITLY_TYPED in gc_typed.h. This is technically + an interface change. Based on the fact that nobody reported this, + I suspect/hope there were no clients. + - Cleaned up gc_typed.h so that (1) it adds an extern "C" declaration + when appropriate, (2) doesn't generate references to undefined internal + macros, and (3) allows easier manual construction of descriptors. + - Close the file descriptor used by GC_print_address_map(). + - Set the "close-on-exec" bit for various file descriptors maintained + for the collector's internal use. + - Added a hack to find memory segments owned by the system allocator + under win32. Based on my tests, this tends to eventually find all + segments, though it may take a while. There appear to be cleaner, + but slower solutions under NT/XP. But they rely on an API that's + unsupported under 9X. + - Changed Linux PowerPC stack finding to LINUX_STACKBOTTOM. (Thanks + to Akira Tagoh for pointing out that HEURISTIC1 doesn't work on + 64-bit kernels.) + - Added GC_set_free_space_divisor to avoid some Windows dll issues. + - Added FIXUP_POINTER, POINTER_SHIFT, POINTER_MASK to allow preprocessing + of candidate pointers for tagging, etc. + - Always lock around GC_notify_full_gc(). Simplified code for + invoking GC_notify_full_gc(). + - Changed the way DATASTART is defined on FreeBSD to be robust against + an unmapped page after etext. (Thanks to Hironori Sakamoto for + tracking down the intermittent failure.) + - Made GC_enable() and GC_disable() official. Deprecated direct update + of GC_dont_gc. Changed GC_gcollect to be a noop when garbage collection + is disabled. + - Call GC_register_dynamic_libraries before stopping the world on Linux, + in order to avoid a potential deadlock due to the dl_iterate_phdr lock. + - Introduced a more general mechanism for platform-dependent code to + decide whether the main data segment should be handled separately + from dynamic libraries, or registered by GC_register_dynamic_libraries. + The latter is more reliable and easier on Linux with dl_iterate_phdr. + +Since 6.2alpha1: + - Fixed the completely broken FreeBSD code in 6.2alpha1. (Thanks to + Hironori Sakamoto for the patch.) + - Changed IRIX reference in dbg_mlc.c to IRIX5. (Thanks to Marcus Herbert.) + - Attempted to work around the problems with .S filenames and the SGI + compiler. (Reported by several people. Untested.) + - Worked around an HP/UX make issue with the GNU-style build process. + - Fixed the --enable-cplusplus build machinery to allow builds without + a C++ compiler. (That was always the intent ...) + - Changed the debugging allocation macros to explicitly pass the return + address for Linux and XXXBSD on hardware for which we can't get stack + traces. Use __builtin_return_address(0) to generate it when possible. + Some of the configuration work was cleaned up (good) and moved to gc.h + (bad, but necessary). This should make leak detection more useful + on a number of platforms. (Thanks to Fabian Thylman for the suggestion.) + - Fixed compilation problems in dbg_mlc.c with GC_ADD_CALLER. + - Bumped revision number for dynamic library. + +Since 6.2alpha2: + - Don't include execinfo.h in os_dep.c when it's not needed, and may not exist. + +Since 6.2alpha3: + - Use LINUX_STACKBOTTOM for >= glibc2.2 on Linux/MIPS. (See Debian bug + # 177204) + - Integrated Jeff Sturm and Jesse Rosenstock's MACOSX threads patches. + - Integrated Grzegorz Jakacki's substantial GNU build patch. "Make dist" + should now work for the GNU build process. Documentation files + are installed under share/gc. + - Tweaked gc_cpp.h to again support the Borland compiler. (Thanks to + Rene Girard for pointing out the problems.) + - Updated BCC_MAKEFILE (thanks to Rene Girard). + - Added GC_ASSERT check for minimum thread stack size. + - Added --enable-gc-assertions. + - Added some web documentation to the distribution. Updated it in the + process. + - Separate gc_conf_macros.h from gc.h. + - Added generic GC_THREADS client-defined macro to set the appropriate + GC_XXX_THREADS internal macro. (gc_config_macros.h.) + - Add debugging versions of _ignore_off_page allocation primitves. + - Moved declarations of GC_make_closure and GC_debug_invoke_finalizer + from gc.h to gc_priv.h. + - Reset GC_fail_count even if only a small allocation succeeds. + - Integrated Brian Alliet's patch for dynamic library support on Darwin. + - gc_cpp.h's gc_cleanup destructor called GC_REGISTER_FINALIZER_IGNORE_SELF + when it should have called the lower case version, since it was + explicitly computing a base pointer. + +Since 6.2alpha4: + - GC_invoke_finalizers could, under rare conditions, set + GC_finalizer_mem_freed to an essentially random value. This could + possibly cause unbounded heap growth for long-running applications + under some conditions. (The bug was introduced in 6.1alpha5, and + is not in gcc3.3. Thanks to Ben Hutchings for finding it.) + - Attempted to sanitize the various DLL macros. GC_USE_DLL disappeared. + GC_DLL is used instead. All internal tests are now on GC_DLL. + README.macros is now more precise about the intended meaning. + - Include DllMain in the multithreaded win32 version only if the + collector is actually built as a dll. (Thanks to Mohan Embar for + a version of the patch.) + - Hide the cygwin threadAttach/Detach functions. They were violating our + namespace rules. + - Fixed an assertion in GC_check_heap_proc. Added GC_STATIC_ASSERT. + (Thanks again to Ben Hutchings.) + - Removed some obsolete definitions for Linux/PowerPC in gcconfig.h. + - CORD_cat was not rebalancing unbalanced trees in some cases, violating + a CORD invariant. Also tweaked the rebalancing rule for + CORD_cat_char_star. (Thanks to Alexandr Petrosian for the bug report + and patch.) + - Added hand-coded structured exception handling support to mark.c. + This should enable support of dynamic libraries under win32 with + gcc-compiled code. (Thanks to Ranjit Mathew for the patch.) + Turned on dynamic library scanning for win32/gcc. + - Removed some remnants of read wrapping. (Thanks to Kenneth Schalk.) + GC_USE_LD_WRAP ws probably broken in recent versions. + - The build could fail on some platforms since gcconfig.h could include + declarations mentioning ptr_t, which was not defined, e.g. when if_mach + was built. (Thanks to Yann Dirson for pointing this out.) Also + cleaned up tests for GC_PRIVATE_H in gcconfig.h a bit. + - The GC_LOOP_ON_ABORT environment variable interfered with incremental + collection, since the write fault handler was erroneously overridden. + Handlers are now set up in the correct order. + - It used to be possible to call GC_mark_thread_local_free_lists() while + the world was not stopped during an incremental GC. This was not safe. + Fortunately, it was also unnecessary. Added GC_world_stopped flag + to avoid it. (This caused occasional crashes in GC_set_fl_marks + with thread local allocation and incremental GC. This probably happened + primarily on old, slow multiprocessors.) + - Allowed overriding of MAX_THREADS in win32_threads.c from the build + command line. (Patch from Yannis Bres.) + - Taught the IA64/linux code to determine the register backing store base from + /proc/self/maps after checking the __libc symbol, but before guessing. + (__libc symbols are on the endangered list, and the guess is likely to not + always be right for 2.6 kernels.) Restructured the code to read and parse + /proc/self/maps so it only exists in one place (all platforms). + - The -DUSE_PROC_FOR_LIBRARIES code was broken on Linux. It claimed that it + also registered the main data segment, but didn't actually do so. (I don't + think anyone actually uses this configuration, but ...) + - Made another attempt to get --enablecplusplus to do the right thing. + Since there are unavoidable problems with C programs linking against a + dynamic library that includes C++ code, I separated out the c++ code into + libgccpp. + +Since 6.2alpha5: + - There was an extra underscore in the name of GC_save_registers_in_stack + for NetBSD/SPARC. (Thanks to Jaap Boender for the patch.) + - Integrated Brian Alliet's patch for Darwin. This restructured the + linuxthreads/pthreads support to separate generic pthreads support + from more the system-dependent thread-stopping code. I believe this + should make it easier to eliminate the code duplication between + pthreads platforms in the future. The patch included some other + code cleanups. + - Integrated Dan Bonachea's patch to support AIX threads. This required + substantial manual integration, mostly due to conflicts with other + recent threads changes. It may take another iteration to + get it to work. + - Removed HPUX/PA-RISC support from aix_irix_threads.c. It wasn't used + anyway and it cluttered up the code. And anything we can do to migrate + towards generic pthreads support is a good thing. + - Added a more explicit test for tracing of function arguments to test.c. + (Thanks to Dan Grayson.) + - Added Akira Tagoh's PowerPC64 patch. + - Fixed some bit rot in the Cygwin port. (Thanks to Dan Bonachea for + pointing it out.) Gc.h now includes just windows.h, not winbase.h. + - Declared GC_save_regs_in_stack() in gc_priv.h. Remove other declarations. + - Changed --enable-cplusplus to use automake consitionals. The old way + confused libtool. "Make install" didn't work correctly for the old version. + Previously --enable-cplusplus was broken on cygwin. + - Changed the C version of GC_push_regs to fail at compile time if it is + generated with an empty body. This seems to have been the cause of one + or two subtle failures on unusual platforms. Those failures should + now occur at build time and be easily fixable. + +Since 6.2alpha6: + - Integrated a second round of Irix/AIX patches from Dan Bonachea. + Renamed mips_sgi_mach_dep.S back to mips_sgi_mach_dep.s, since it requires + the Irix assembler to do the C preprocessing; gcc -E doesn't work. + - Fixed Makefile.direct for DARWIN. (Thanks to Manuel Serrano.) + - There was a race between GC_pthread_detach and thread exit that could + result in a thread structure being deallocated by GC_pthread_detach + eventhough it was still needed by the thread exit code. (Thanks to + Dick Porter for the small test case that allowed this to be debugged.) + - Fixed version parsing for non-alpha versions in acinclude.m4 and + version checking in version.h. + +Since 6.2: + - Integrated some NetBSD patches forwarded to me by Marc Recht. These + were already in the NetBSD package. + - GC_pthread_create waited for the semaphore even if pthread_create failed. + Thanks to Dick Porter for the pthread_support.c patch. Applied the + analogous fix for aix_irix_threads.c. + - Added Rainer Orth's Tru64 fixes. + - The check for exceeding the thread table size in win32 threadDetach + was incorrect. (Thanks to Alexandr Petrosian for the patch.) + - Applied Andrew Begel's patch to correct some reentrancy issues + with dynamic loading on Darwin. + - GC_CreateThread() was neglecting to duplicate the thread handle in + the table. (Thanks to Tum Nguyen for the patch.) + - Pass +ESdbgasm only on PA-RISC machines with vendor compiler. + (Thanks to Roger Sayle for the patch.) + - Applied more AIX threads patches from Scott Ananian. + +Since 6.3alpha1: + - Reenabled I_HOLD_LOCK assertion in aix_irix_threads.h. + - Put back the WINABI qualifier for GC_CreateThread. (Thanks to + Danny Smith for the patch. 6.3alpha1 had the qualifier in one place + but not elsewhere, which was clearly wrong.) + - Sometimes explicitly define __private_extern__ before DARWIN dyld.h + include. (Thanks to Andreas Tobker for postting the patch.) + - Included signal.h from pthread_support.c. Removed GC_looping_handler, + which was dead code. + - GC_find_start was misdeclared by gc_pmark.h if PRINT_BLACK_LIST was + defined. (Thanks to Glauco Masotti for testing and reporting this.) + Changed GC_find_start to never just return 0. According to its + comment it doesn't, and it's unclear that's correct. + - GC_alloc_large had several largely compensating bugs in the + computation of GC_words_wasted. (It was confused about bytes vs. + words in two places.) + - Integrated Slava Sysoltev's patch to support more recent versions of + the Intel compiler on IA64/Linux. + - Changed win32 spinlock initialization to conditionally set a spin count. + (Emmanual Stumpf pointed out that enabling this makes a large performance + difference on win32 multiprocessors.) Also cleaned up the win32 spinlock + initialization code a bit. + - Fixed thread support for HP/UX/IA64. The register backing store base for + the main thread was sometimes not set correctly. (Thanks to Laurent + Morichetti.) + - Added -DEMPTY_GETENV_RESULTS flag to work around Wine problem. + - Declare GC_stack_alloc and GC_stack_free in solaris_threads.h to + avoid 64-bit size mismatches. (Thanks to Bernie Solomon.) + - Fixed GC_generic_push_regs to avoid a potential and very unfortunate + tail call optimization. This could lead to prematurely reclaimed + objects on configurations that used the generic routine and the new + build infrastructure (which potentially optimizes mach_dep.c). + This was a serious bug, but it's unclear whether it has resulted in + any real failures. + - Fixed CORD_str to deal with signed characters. (Thanks to Alexandr + Petrosian for noticing the problem and supplying the patch.) + - Merged a couple of NOSYS/ECOS tests into os_dep.c from gcj. (Thanks + to Anthony Green.) + - Partially merged a win32 patch from Ben Hutchings, and substantially + revised other parts of win32_threads.c. It had several problems. + Under MinGW with a statically linked library, the main thread was + not registered. Cygwin detached threads leaked thread descriptors. + There were several race conditions. For now, unfortunately the + static threads limit remains, though we increased it, and made table + traversal cost depend on the actual thread count. + There is also still some code duplication with pthread_support.c. + (Thread descriptors did become much smaller, since Ben Hutchings + removed the thread context from them.) + - Integrated a Solaris configure.in patch from Rainer Orth. + - Added GC_IGNORE_FB and associated warning to very partially address + the issue of the collector treating a mapped frame buffer as part + of the root set. (Thanks to David Peroutka for providing some + insight. More would be helpful. Is there anything that can be used + to at least partially identify such memory segments?) + +Since 6.3alpha2: + - Removed -DSMALL_CONFIG from BCC_MAKEFILE. + - Changed macros to test for an ARM processor (Patch from Richard Earnshaw.) + - Mostly applied a DJGPP patch from Doug Kaufman. Especially Makefile.dj + had suffered from serious bit rot. + - Rewrote GC_apply_to_maps, eliminating an off-by-one subscript error, + and a call to alloca (for lcc compatibility). + - Changed USE_MUNMAP behavior on posixy platforms to immediately remap + the memory with PROT_NONE instead of unmapping it. The latter risks + an intervening mmap grabbing the address space out from underneath us. + Updated this code to reflect a cleaner patch from Ulrich Drepper. + - Replaced _T with _Tp in new_gc_alloc.h to avoid a MACOS X conflict. + (Patch from Andrew Begel.) + - Dynamically choose whether or not lock should spin on win32. (Thanks + to Maurizio Vairani for the patch.) This may be a significant performance + improvement for win32. + - Fix Makefile.direct to actually include NT_STATIC_THREADS_MAKEFILE + in the distribution. (Again thanks to Maurizio Vairani.) + - Maybe_install_looping_handler() was accidentally exported, violating + our name space convention. + - Made os_dep.c use sigsetjmp and SA_NODEFER for NetBSD. (Thanks to + Christian Limpach.) (I generalized the patch to use sigsetjmp on all + UNIX_LIKE platforms, admittedly a slightly risky move. But it may avoid + similar problems on some other platforms. I also cleaned up the defn + of UNIX_LIKE a bit. - Hans) + - Integrated Andrew Begel's Darwin threads patch, adjusted according to + some of Fergus Hendersons's comments. (Patch didn't apply cleanly, + errors are possible.) + - Added another test or two for the Intel 8.0 compiler to avoid + confusing it with gcc. The single-threaded collector should now build + with icc, at least on ia64. + +Since 6.3alpha3: + - USE_MMAP was broken by confusion in the code dealing with USE_MMAP_ANON. + (This was pointed out, and fixes were suggested by several other people.) + - Darwin supprt was broken in alpha3 as a result of my misintegration of + Andrew Begel's patches. Fixed with another patch from Andrew Begel. + - A new sanity check in pthread_stop_world.c:GC_push_all_stacks() was + overly aggressive. We may collect from an unregistered thread during + thread creation. Fixed by explicitly checking for that case. (Added + GC_in_thread_creation.) + +Since 6.3alpha4: + - Fix & vs && typo in GC_generic_malloc and + GC_generic_malloc_ignore_off_page. (Propagated from the gcc tree.) + - Removed SA_NODEFER hack from NetBSD and Solaris write-protect handler. + (According to Christian Limpach, the NetBSD problem is fixed. + Presumably so is the Solaris 2.3 problem.) + - Removed placement delete from gc_cpp.h for the SGI compiler. + (Thanks to Simon Gornall for the patch.) + - Changed semantics of the GC_IGNORE_FB environment variable, based + on experimentation by Nicolas Cannasse pointing out that the old + interpretation was useless. We still need help in identifying win32 + graphics memory mappings. The current "solution" is a hack. + - Removed "MAKEOVERRIDES =" from Makefile.am and thus Makefile.in. + It probably made more sense in the gcc context. + - Explicitly ensure that NEED_FIND_LIMIT is defined for {Open,Net}BSD/ELF. + - Replaced USE_HPUX_TLS macro by USE_COMPILER_TLS, since gcc often + supports the same extension on various platforms. + - Added some basic (completely untested) defines for win64, in support + of future work. + - Declared GC_jmp_buf in os_dep.s as JMP_BUF instead of jmp_buf, fixing + a memory overwrite bug on Solaris and perhaps other platforms. + - Added 0 != __libc_stack_end test to GC_linux_stack_base. (Thanks to Jakub + Jelinek, both for the patch, and for explaining the problem to me.) + Otherwise "prelink"ing could cause the collector to fail. + - Changed default thread local storage implementation to USE_PTHREAD_SPECIFIC + for HP/UX with gcc. The compiler-based implementation appears to work + only with the vendor compiler. + - Export GC_debug_header_size and GC_USR_PTR_FROM_BASE from gc_mark.h, + making client mark code cleaner and less dependent on GC version. + - Export several new procedures and GC_generic_malloc from gc_mark.h + to support user-defined kinds. Use the new procedures to replace existing + code in gcj_mlc.c and typd_mlc.c. + - Added support for GC_BACKTRACES. + - Fixed a remaining problem in CORD_str with signed characters. (Thanks + to Alexandr Petrosian for the patch.) + - Removed supposedly redundant, but very buggy, definitions of finalizer + macros from javaxfc.h. Fortunately this file probably has no users. + The correct declarations were already in gc.h. + - Also need to set GC_in_thread_creation while waiting for GC during + thread termination, since it is also possible to collect from an + unregistered thread in that case. + - Define NO_GETENV for Windows CE, since getenv doesn't appear to exist. + + some other minor WinCE fixes. (Thanks to Alain Novak.) + - Added GC_register_describe_type_fn. + - Arrange for debugging finalizer registration to ignore non-heap + registrations, since the regular version of the routine also behaves + that way. + - GC_gcj_malloc and friends need to check for finalizers waiting to be run. + One of the more obscure allocation routines with missing a LOCK() call. + - Fixed cvtres invocations in NT_MAKEFILE and NT_STATIC_THREADS_MAKEFILE + to work with VS.NET. + - Cleaned up GC_INIT calls in test. Updated gc.man to encourage GC_INIT + use in portable code. + - Taught the GC to use libunwind if --enable-full-debug is specified on + IA64 and libunwind is present. + - The USE_MUNMAP code could get confused about the age of a block and + prematurely unmap it. GC_unmap_old had a bug related to wrapping of + GC_gc_no. GC_freehblk and GC_merge_unmapped didn't maintain + hb_last_reclaimed reasonably when blocks were merged. The code was + fixed to reflect original intent, but that may not always be an + improvement. See todo list item. + +Since 6.3alpha5: + - Define USE_GENERIC_PUSH_REGS for NetBSD/M68K. + - Fixed the X86_64 PREFETCH macros to correctly handle ia32e (which uses + different prefetch instructions from AMD64). (Thanks to H.J. Lu.) + - GC_config_macros.h did not correctly define GC_WIN32_THREADS from + GC_THREADS. + - Added simple_example.html. + - Merged Andrew Gray's patch to correctly restore signal handlers on + FreeBSD. + - Merged a patch from Andreas Jaeger to deal with prefetch-related warnings + on x86-64. Added some other casts so that the PREFETCH macros + always get a ptr_t argument. Removed some casts inthe PREFETCH + implementations. + - At Jesse Jones suggestion: Added a header guard for gc_allocator.h + and changed GC_debug_free to clobber contents of deallocated object. + - The signal masking code in pthread_stop_world.c contained some errors. + In particular SIGSEGV was masked in the handler, in spite of the fact that + it wrote to the heap. This could lead to an uncaught SIGSEGV, which + apparently became much more likely in Linux 2.6. Also fixed some + typos, and reduced code duplication in the same area. + - Remove ltconfig, clean up configure messages for DGUX (thanks to + Adrian Bunk for the patches). + - Integrated NetBSD/OpenBSD patches from Marc Recht and Matthias Drochner. + +Since gc6.3alpha6: + - Compile test_cpp.cc with CXXCOMPILE instead of COMPILE. + - Very large allocations could cause a collector hang. Correct + calculation of GC_collect_at_heapsize. + - GC_print_hblkfreelist printed some bogus results if USE_MUNMAP + was defined. + - The generic GC_THREADS macro didn't work correctly on Solaris, + since the implementation failed to include gc_config_macros.h + before deciding whether or not to compile the rest of the file. + - Threadlibs.c failed to expand the generic GC_THREADS macro. + - Correct MacOSX thread stop code. (Thanks to Dick Porter.) + - SMALL_OBJ definition was off by one. This could cause crashes + at startup. (Thanks to Zoltan Varga for narrowing this down to + a trivial test case.) + - Integrate Paolo Molara's patch to deal with a race in the Darwin + thread stopping code. + - Changed X86_64 implementation to use SA_SIGINFO in the MPROTECT_VDB + implementation. The old approach appears to have been broken by + recent kernels. + - Add GC_ATTR_UNUSED to eliminate a warning in gc_allocator.h. (Thanks + to Andrew Begel.) + - Fix GC_task_self declaration in os_dep.c. (Thanks to Andrew Pinski.) + - Increase INITIAL_BUF_SZ in os_dep.c for Solaris /proc reads. + +Since 6.3: + - Merge gcconfig.h changes from gcc tree. + - Unconditionally include gc_priv.h in solaris_pthreads.c, win32_threads.h, + aix_irix_threads.c, and solaris_threads.c to get thread definitions. + - Start marker threads in GC_thr_init, so that they get started even + if no other threads are ever started. (Oddly enough, the parallel + collector worked correctly, though not well, with no helper threads.) + - Go ahead and split large blocks in GC_allochblk_nth if GC_dont_gc + is set. (Thanks to Alexander Petrossian.) + - GC_PRINT_BACK_HEIGHT would deadlock with thread support. + - Let in_progress_space in backgraph.s grow dynamically. + - Fix README.solaris2. The GC_thr_init() hack doesn't work anymore. + - Convert GC_finalizer_mem_freed to bytes in allchblk.c. + - Add missing declaration for GC_generic_malloc_words_small_inner. + Without it, s390x breaks. (Thanks to Ulrich Weigand.) + - Applied several MacOSX patches to support older tool chains. + (Thanks to Stefan Ring.) + - Bug fix for NetBSD/amd64. (Thanks to Marc Recht.) Add NetBSD/sh3 + support. (Thanks to Uchiyama Yasushi.) + - Fixed an uninitialized variable in cordprnt.c. (Thanks to gcc for + providing the warning.) + - Eliminated some, but not all, gcc -Wall warnings. + - Changed some old style casts to reinterpret_cast in new_gc_alloc.h. + (Thanks to Dan Grayson.) + - GC_extend_size_map shouldn't adjust for GC_all_interior_pointers if + GC_DONT_ADD_BYTE_AT_END is set. + - Changed some (long) casts to (word) in preparation for win64. + (Thanks to Peter Colson.) + - Changed "int stack_size" declaration in pthread_support.c to use + size_t. (Only mattered with GC_ASSERTIONS enabled.) + - Added CRIS (etrax) support. (Thanks to Simon Posnjak and + Hans-Peter Nilsson.) + - Removed GC_IGNORE_FB frame buffer recognition, and replaced + it with a check that the mapping type is MEM_IMAGE. + In theory, this should work much better, but it is a high + risk change for win32. (Thanks to Ashley Bone for the crucial + experimental data behind this, and to Rutger Ovidus for + some further experiments.) + - Fixed print_block_list to print the correct kind number for + STUBBORN. (Thanks to Rutger Ovidus.) + - GC_allochblk_nth incremented GC_words_wasted by bytes rather than + words. + - Consider GC_words_wasted in GC_adj_words_allocd only if it is within + reason. (A hack to avoid some extremely unlikely scenarios in which + we manage to allocate only "wasted" space. 7.0 has a better fix.) + - Changed PowerPC GC_clear implementation to use lwsync instead of + eieio, since the documentation recommends against eieio, and + it seems to be incorrect if the preceding memory op is a load. + - Fixed print_block_list to print the correct kind number for + STUBBORN. (Thanks to Rutger Ovidus.) + - Have configure.in generate an error if it is asked to support + pthreads, but doesn't know how to. + - Added Kazuhiro Inaoka's patch for Renesas M32R support. + - Have the GNU build mechanism link with -ldl. Rename THREADLIBS + to THREADDLLIBS to reflect this. (Thanks to Sven Verdoolaege.) + - Added Hannes Mehnert's patch for FreeBSD/SPARC support. + - Merged some FreeBSD specific patches to threadlibs.c and dyn_load.c. + (Thanks tp John Merryweather Cooper.) + - Define MPROTECT_VDB on MACOSX only if threads are being used, since the + dirty page tracking mechanism uses threads. (This avoids an undefined + reference to _GC_darwin_register_mach_handler_thread.) + - By popular demand, use __libc symbols only if we are built with + USE_LIBC_PRIVATES, which is off by default, and not otherwise documented. + - Ignore GC_enable_incremental() requests when KEEP_BACK_PTRS is set. + The GC itself will dirty lots of pages in this cases, probably making + it counterproductive on all platforms. And the DARWIN port crashes. + +Since GC6.4: + - Integrated Paolo Molaro's patch to deal with EINTR in sem_wait. + - Make GC_approx_sp() write to dummy location to ensure that stack + is grown here, when sp looks reasonable, rather than later, when + it might look like a bad memory reference. (Problem was never + observed that I know of. But on rereading the code it seemed + dubious.) + - Separate out GC_with_callee_saves_pushed and sometimes call + it from GC_suspend_handler in pthread_stop_world.c. Callee-save + register values sometimes failed to get traced under HP/UX on + PA-RISC. Linux/IA64 had the same problem, though non-stacked + callee-save registers seem to be so rarely used there that nobody + ever noticed. + - Integrated an ancient Darwin powerpc_darwin_machine_dep.s patch + from Andreas Tobler, which I had lost. + - Fix compare_and_exchange implementation for gcc/IA64 to deal with + pickier compiler versions. + - Fixed Itanium 32-bit ABI support (HP/UX). In particular, the + compare_and_exchange implementation didn't consider that possibility. + - Undefine GC_pthread_detach in win32_threads.c. (Thanks to + Tagliapietra Tommaso.) + - Fixed inclusion of frame.h for NETBSD in os_dep.c. + - Applied Dan Bonachea's patch to use mmap on AIX. + - Several fixes to resurrect the Irix port on recent OS versions. + - Change ALPHA to use LINUX_STACKBOTTOM. + - Change SPARC64/LINUX to also use LINUX_STACKBOTTOM. Deal with potential + bad values of __libc_stack_end on that platform. (Thanks to David Miller.) + - Relax gctest to allow larger heap if ALIGN_DOUBLE isn't set. + (Unnecessary in 7.0) + - Force a define of __STDC__=0 for the IBM compiler on AIX, so that + we get prototypes. (Unnecessary in 7.0) + - GC_INIT definition for AIX and CYGWIN referred to DATASTART and DATAEND + which are only defined in private include files. + - Integrated some small gcconfig.h patches from Dan Bonachea. Also + relaxed assertion about FreeBSD stack size in pthread_support.c. + - Integrated Andrew Begel's darwin_stop_world.c patch for 64-bit + support. This may need additional work. + - Avoided potentially infinite recursion in GC_save_callers if + the system backtrace calls malloc. The workaround currently requires + __thread support if this code is used with threads. + - Avoided another similar infinite recursion by conditionally + invoking GC_save_callers in alloc.c. (Thanks to Matthias Andree + for helping to track down both of these.) + - Removed all traces of aix_irix_threads.c. AIX and Irix now use + pthread_support.c and pthread_stop_world.c. The old code appeared + to be unreliable for AIX, and was not regularly maintained. + - On Irix, ignore segments with MA_FETCHOP or MA_NOTCACHED attributed; + they're not always safe to read. + - Fixed a previously vacuous assertion (diagnosed by the SGI compiler) + in GC_remove_from_fl. + - Fix stack_size assertion in GC_pthread_create. + - Fix assertion in GC_steal_mark_stack. + +Since 6.5 + - Fix CPU count detection for Irix and FreeBSD. (Thanks to Dan Bonachea.) + - Integrate Dan Bonachea's patch for the IBM XLC compiler on Darwin. + - Integrated Andreas Tobler's FreeBSD/PowerPC patch. + - Don't access the GC thread structure from the restart handler. It's + unsafe, since the handler may run too late. (Thanks to Ben Maurer for + tracking this down.) + - Applied Christian Thalinger's patch to change comment syntax in + alpha_mach_dep.S. + - Added test for GC_no_dls in GC_dyld_image_add for DARWIN. (Thanks to + Juan Jose Garcia Ripoli). + - Use LINUX_STACKBOTTOM for Linux/SH and LINUX/ARM. (Thanks to Sugioka + Toshinobu and Christian Thalinger.) + - Rewrote GC_parse_map_entry. This assumed a fixed column layout of + /proc/self/maps on Linux. This ceased to be true about 2 years ago. + The old code is probably quite problemetic with -DREDIRECT_MALLOC. It + is also used by default for IA64, though I haven't seen actual failures + there. + - More consistently define HBLKSIZE to 4096 on 64 bit architectures with + 4K pages. (Thanks to Andrew Haley.) + - With win32 threads, GC_stop_world needs to acquire GC_write_cs. (Thanks + to Ben Hutchings for the observation and patch.) + - Move up struct callinfo declaration to make gcc 4.0.2. happy. + +To do: + - The USE_MUNMAP code should really use a separate data structure + indexed by physical page to keep track of time since last use of + a page. Using hblk headers means we lose track of ages when + blocks are merged, and we can't unmap pages that have been allocated and + dropped by the blacklisting code. I suspect both of these matter. + - A dynamic libgc.so references dlopen unconditionally, but doesn't link + against libdl. + - GC_proc_fd for Solaris is not correctly updated in response to a + fork() call. Thus incremental collection in the child won't work + correctly. (Thanks to Ben Cottrell for pointing this out.) + - --enable-redirect-malloc is mostly untested and known not to work + on some platforms. + - There seem to be outstanding issues on Solaris/X86, possibly with + finding the data segment starting address. Information/patches would + be appreciated. + - Very large root set sizes (> 16 MB or so) could cause the collector + to abort with an unexpected mark stack overflow. (Thanks again to + Peter Chubb.) NOT YET FIXED. Workaround is to increase the initial + size. + - The SGI version of the collector marks from mmapped pages, even + if they are not part of dynamic library static data areas. This + causes performance problems with some SGI libraries that use mmap + as a bitmap allocator. NOT YET FIXED. It may be possible to turn + off DYNAMIC_LOADING in the collector as a workaround. It may also + be possible to conditionally intercept mmap and use GC_exclude_static_roots. + The real fix is to walk rld data structures, which looks possible. + - Incremental collector should handle large objects better. Currently, + it looks like the whole object is treated as dirty if any part of it + is. + diff --git a/boehm-gc/doc/README.contributors b/boehm-gc/doc/README.contributors new file mode 100644 index 000000000..fd5c95f22 --- /dev/null +++ b/boehm-gc/doc/README.contributors @@ -0,0 +1,57 @@ +This is an attempt to acknowledge early contributions to the garbage +collector. Later contributions should instead be mentioned in +README.changes. + +HISTORY - + + Early versions of this collector were developed as a part of research +projects supported in part by the National Science Foundation +and the Defense Advance Research Projects Agency. + +The garbage collector originated as part of the run-time system for +the Russell programming language implementation. The first version of the +garbage collector was written primarily by Al Demers. It was then refined +and mostly rewritten, primarily by Hans-J. Boehm, at Cornell U., +the University of Washington, Rice University (where it was first used for +C and assembly code), Xerox PARC, SGI, and HP Labs. However, significant +contributions have also been made by many others. + +Some other contributors: + +More recent contributors are mentioned in the modification history in +README.changes. My apologies for any omissions. + +The SPARC specific code was originally contributed by Mark Weiser. +The Encore Multimax modifications were supplied by +Kevin Kenny (kenny@m.cs.uiuc.edu). The adaptation to the IBM PC/RT is largely +due to Vernon Lee, on machines made available to Rice by IBM. +Much of the HP specific code and a number of good suggestions for improving the +generic code are due to Walter Underwood. +Robert Brazile (brazile@diamond.bbn.com) originally supplied the ULTRIX code. +Al Dosser (dosser@src.dec.com) and Regis Cridlig (Regis.Cridlig@cl.cam.ac.uk) +subsequently provided updates and information on variation between ULTRIX +systems. Parag Patel (parag@netcom.com) supplied the A/UX code. +Jesper Peterson(jep@mtiame.mtia.oz.au), Michel Schinz, and +Martin Tauchmann (martintauchmann@bigfoot.com) supplied the Amiga port. +Thomas Funke (thf@zelator.in-berlin.de(?)) and +Brian D.Carlstrom (bdc@clark.lcs.mit.edu) supplied the NeXT ports. +Douglas Steel (doug@wg.icl.co.uk) provided ICL DRS6000 code. +Bill Janssen (janssen@parc.xerox.com) supplied the SunOS dynamic loader +specific code. Manuel Serrano (serrano@cornas.inria.fr) supplied linux and +Sony News specific code. Al Dosser provided Alpha/OSF/1 code. He and +Dave Detlefs(detlefs@src.dec.com) also provided several generic bug fixes. +Alistair G. Crooks(agc@uts.amdahl.com) supplied the NetBSD and 386BSD ports. +Jeffrey Hsu (hsu@soda.berkeley.edu) provided the FreeBSD port. +Brent Benson (brent@jade.ssd.csd.harris.com) ported the collector to +a Motorola 88K processor running CX/UX (Harris NightHawk). +Ari Huttunen (Ari.Huttunen@hut.fi) generalized the OS/2 port to +nonIBM development environments (a nontrivial task). +Patrick Beard (beard@cs.ucdavis.edu) provided the initial MacOS port. +David Chase, then at Olivetti Research, suggested several improvements. +Scott Schwartz (schwartz@groucho.cse.psu.edu) supplied some of the +code to save and print call stacks for leak detection on a SPARC. +Jesse Hull and John Ellis supplied the C++ interface code. +Zhong Shao performed much of the experimentation that led to the +current typed allocation facility. (His dynamic type inference code hasn't +made it into the released version of the collector, yet.) + diff --git a/boehm-gc/doc/README.cords b/boehm-gc/doc/README.cords new file mode 100644 index 000000000..3485e0145 --- /dev/null +++ b/boehm-gc/doc/README.cords @@ -0,0 +1,53 @@ +Copyright (c) 1993-1994 by Xerox Corporation. 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. + +Please send bug reports to Hans-J. Boehm (Hans_Boehm@hp.com or +boehm@acm.org). + +This is a string packages that uses a tree-based representation. +See cord.h for a description of the functions provided. Ec.h describes +"extensible cords", which are essentially output streams that write +to a cord. These allow for efficient construction of cords without +requiring a bound on the size of a cord. + +More details on the data structure can be found in + +Boehm, Atkinson, and Plass, "Ropes: An Alternative to Strings", +Software Practice and Experience 25, 12, December 1995, pp. 1315-1330. + +A fundamentally similar "rope" data structure is also part of SGI's standard +template library implementation, and its descendents, which include the +GNU C++ library. That uses reference counting by default. +There is a short description of that data structure at +http://reality.sgi.com/boehm/ropeimpl.html . (The more official location +http://www.sgi.com/tech/stl/ropeimpl.html is missing a figure.) + +All of these are descendents of the "ropes" in Xerox Cedar. + +de.c is a very dumb text editor that illustrates the use of cords. +It maintains a list of file versions. Each version is simply a +cord representing the file contents. Nonetheless, standard +editing operations are efficient, even on very large files. +(Its 3 line "user manual" can be obtained by invoking it without +arguments. Note that ^R^N and ^R^P move the cursor by +almost a screen. It does not understand tabs, which will show +up as highlighred "I"s. Use the UNIX "expand" program first.) +To build the editor, type "make cord/de" in the gc directory. + +This package assumes an ANSI C compiler such as gcc. It will +not compile with an old-style K&R compiler. + +Note that CORD_printf iand friends use C functions with variable numbers +of arguments in non-standard-conforming ways. This code is known to +break on some platforms, notably PowerPC. It should be possible to +build the remainder of the library (everything but cordprnt.c) on +any platform that supports the collector. + diff --git a/boehm-gc/doc/README.darwin b/boehm-gc/doc/README.darwin new file mode 100644 index 000000000..70954971f --- /dev/null +++ b/boehm-gc/doc/README.darwin @@ -0,0 +1,141 @@ +6.5 update: +I disabled incremental GC on Darwin in this version, since I couldn't +get gctest to pass when the GC was built as a dynamic library. Building +with -DMPROTECT_VDB (and threads) on the command line should get you +back to the old state. - HB + +./configure --enable-cplusplus results in a "make check" failure, probably +because the ::delete override ends up in a separate dl, and Darwin dynamic +loader semantics appear to be such that this is not really visible to the +main program, unlike on ELF systems. Someone who understands dynamic +loading needs to lookat this. For now, gc_cpp.o needs to be linked +statically, if needed. - HB + +Darwin/MacOSX Support - December 16, 2003 +========================================= + +Important Usage Notes +===================== + +GC_init() MUST be called before calling any other GC functions. This +is necessary to properly register segments in dynamic libraries. This +call is required even if you code does not use dynamic libraries as the +dyld code handles registering all data segments. + +When your use of the garbage collector is confined to dylibs and you +cannot call GC_init() before your libraries' static initializers have +run and perhaps called GC_malloc(), create an initialization routine +for each library to call GC_init(): + +#include +extern "C" void my_library_init() { GC_init(); } + +Compile this code into a my_library_init.o, and link it into your +dylib. When you link the dylib, pass the -init argument with +_my_library_init (e.g. gcc -dynamiclib -o my_library.dylib a.o b.o c.o +my_library_init.o -init _my_library_init). This causes +my_library_init() to be called before any static initializers, and +will initialize the garbage collector properly. + +Note: It doesn't hurt to call GC_init() more than once, so it's best, +if you have an application or set of libraries that all use the +garbage collector, to create an initialization routine for each of +them that calls GC_init(). Better safe than sorry. + +The incremental collector is still a bit flaky on darwin. It seems to +work reliably with workarounds for a few possible bugs in place however +these workaround may not work correctly in all cases. There may also +be additional problems that I have not found. + +Thread-local GC allocation will not work with threads that are not +created using the GC-provided override of pthread_create(). Threads +created without the GC-provided pthread_create() do not have the +necessary data structures in the GC to store this data. + + +Implementation Information +========================== +Darwin/MacOSX support is nearly complete. Thread support is reliable on +Darwin 6.x (MacOSX 10.2) and there have been reports of success on older +Darwin versions (MacOSX 10.1). Shared library support had also been +added and the gc can be run from a shared library. There is currently only +support for Darwin/PPC although adding x86 support should be trivial. + +Thread support is implemented in terms of mach thread_suspend and +thread_resume calls. These provide a very clean interface to thread +suspension. This implementation doesn't rely on pthread_kill so the +code works on Darwin < 6.0 (MacOSX 10.1). All the code to stop and +start the world is located in darwin_stop_world.c. + +Since not all uses of the GC enable clients to override pthread_create() +before threads have been created, the code for stopping the world has +been rewritten to look for threads using Mach kernel calls. Each +thread identified in this way is suspended and resumed as above. In +addition, since Mach kernel threads do not contain pointers to their +stacks, a stack-walking function has been written to find the stack +limits. Given an initial stack pointer (for the current thread, a +pointer to a stack-allocated local variable will do; for a non-active +thread, we grab the value of register 1 (on PowerPC)), it +will walk the PPC Mach-O-ABI compliant stack chain until it reaches the +top of the stack. This appears to work correctly for GCC-compiled C, +C++, Objective-C, and Objective-C++ code, as well as for Java +programs that use JNI. If you run code that does not follow the stack +layout or stack pointer conventions laid out in the PPC Mach-O ABI, +then this will likely crash the garbage collector. + +The original incremental collector support unfortunatelly no longer works +on recent Darwin versions. It also relied on some undocumented kernel +structures. Mach, however, does have a very clean interface to exception +handing. The current implementation uses Mach's exception handling. + +Much thanks goes to Andrew Stone, Dietmar Planitzer, Andrew Begel, +Jeff Sturm, and Jesse Rosenstock for all their work on the +Darwin/OS X port. + +-Brian Alliet +brian@brianweb.net + + +Older Information (Most of this no longer applies to the current code) +====================================================================== + +While the GC should work on MacOS X Server, MacOS X and Darwin, I only tested +it on MacOS X Server. +I've added a PPC assembly version of GC_push_regs(), thus the setjmp() hack is +no longer necessary. Incremental collection is supported via mprotect/signal. +The current solution isn't really optimal because the signal handler must decode +the faulting PPC machine instruction in order to find the correct heap address. +Further, it must poke around in the register state which the kernel saved away +in some obscure register state structure before it calls the signal handler - +needless to say the layout of this structure is no where documented. +Threads and dynamic libraries are not yet supported (adding dynamic library +support via the low-level dyld API shouldn't be that hard). + +The original MacOS X port was brought to you by Andrew Stone. + + +June, 1 2000 + +Dietmar Planitzer +dave.pl@ping.at + +Note from Andrew Begel: + +One more fix to enable gc.a to link successfully into a shared library for +MacOS X. You have to add -fno-common to the CFLAGS in the Makefile. MacOSX +disallows common symbols in anything that eventually finds its way into a +shared library. (I don't completely understand why, but -fno-common seems to +work and doesn't mess up the garbage collector's functionality). + +Feb 26, 2003 + +Jeff Sturm and Jesse Rosenstock provided a patch that adds thread support. +GC_MACOSX_THREADS should be defined in the build and in clients. Real +dynamic library support is still missing, i.e. dynamic library data segments +are still not scanned. Code that stores pointers to the garbage collected +heap in statically allocated variables should not reside in a dynamic +library. This still doesn't appear to be 100% reliable. + +Mar 10, 2003 +Brian Alliet contributed dynamic library support for MacOSX. It could also +use more testing. diff --git a/boehm-gc/doc/README.dj b/boehm-gc/doc/README.dj new file mode 100644 index 000000000..613bc423c --- /dev/null +++ b/boehm-gc/doc/README.dj @@ -0,0 +1,12 @@ +[Original version supplied by Xiaokun Zhu ] +[This version came mostly from Gary Leavens. ] + +Look first at Makefile.dj, and possibly change the definitions of +RM and MV if you don't have rm and mv installed. +Then use Makefile.dj to compile the garbage collector. +For example, you can do: + + make -f Makefile.dj test + +All the tests should work fine. + diff --git a/boehm-gc/doc/README.environment b/boehm-gc/doc/README.environment new file mode 100644 index 000000000..686e94825 --- /dev/null +++ b/boehm-gc/doc/README.environment @@ -0,0 +1,151 @@ +The garbage collector looks at a number of environment variables which are +then used to affect its operation. These are examined only on Un*x-like +platforms and win32. + +GC_INITIAL_HEAP_SIZE= - Initial heap size in bytes. May speed up + process start-up. + +GC_MAXIMUM_HEAP_SIZE= - Maximum collected heap size. + +GC_LOOP_ON_ABORT - Causes the collector abort routine to enter a tight loop. + This may make it easier to debug, such a process, especially + for multithreaded platforms that don't produce usable core + files, or if a core file would be too large. On some + platforms, this also causes SIGSEGV to be caught and + result in an infinite loop in a handler, allowing + similar debugging techniques. + +GC_PRINT_STATS - Turn on as much logging as is easily feasible without + adding signifcant runtime overhead. Doesn't work if + the collector is built with SMALL_CONFIG. Overridden + by setting GC_quiet. On by default if the collector + was built without -DSILENT. + +GC_DUMP_REGULARLY - Generate a GC debugging dump GC_dump() on startup + and during every collection. Very verbose. Useful + if you have a bug to report, but please include only the + last complete dump. + +GC_BACKTRACES= - Generate n random backtraces (for heap profiling) after + each GC. Collector must have been built with + KEEP_BACK_PTRS. This won't generate useful output unless + most objects in the heap were allocated through debug + allocators. This is intended to be only a statistical + sample; individual traces may be erroneous due to + concurrent heap mutation. + +GC_PRINT_ADDRESS_MAP - Linux only. Dump /proc/self/maps, i.e. various address + maps for the process, to stderr on every GC. Useful for + mapping root addresses to source for deciphering leak + reports. + +GC_NPROCS= - Linux w/threads only. Explicitly sets the number of processors + that the GC should expect to use. Note that setting this to 1 + when multiple processors are available will preserve + correctness, but may lead to really horrible performance, + since the lock implementation will immediately yield without + first spinning. + +GC_MARKERS= - Linux w/threads and parallel marker only. Set the number + of marker threads. This is normaly set to the number of + processors. It is safer to adjust GC_MARKERS than GC_NPROCS, + since GC_MARKERS has no impact on the lock implementation. + +GC_NO_BLACKLIST_WARNING - Prevents the collector from issuing + warnings about allocations of very large blocks. + Deprecated. Use GC_LARGE_ALLOC_WARN_INTERVAL instead. + +GC_LARGE_ALLOC_WARN_INTERVAL= - Print every nth warning about very large + block allocations, starting with the nth one. Small values + of n are generally benign, in that a bounded number of + such warnings generally indicate at most a bounded leak. + For best results it should be set at 1 during testing. + Default is 5. Very large numbers effectively disable the + warning. + +GC_IGNORE_GCJ_INFO - Ignore the type descriptors implicitly supplied by + GC_gcj_malloc and friends. This is useful for debugging + descriptor generation problems, and possibly for + temporarily working around such problems. It forces a + fully conservative scan of all heap objects except + those known to be pointerfree, and may thus have other + adverse effects. + +GC_PRINT_BACK_HEIGHT - Print max length of chain through unreachable objects + ending in a reachable one. If this number remains + bounded, then the program is "GC robust". This ensures + that a fixed number of misidentified pointers can only + result in a bounded space leak. This currently only + works if debugging allocation is used throughout. + It increases GC space and time requirements appreciably. + This feature is still somewhat experimental, and requires + that the collector have been built with MAKE_BACK_GRAPH + defined. For details, see Boehm, "Bounding Space Usage + of Conservative Garbage Collectors", POPL 2001, or + http://lib.hpl.hp.com/techpubs/2001/HPL-2001-251.html . + +GC_RETRY_SIGNALS, GC_NO_RETRY_SIGNALS - Try to compensate for lost + thread suspend signals in linux_threads.c. On by + default for GC_OSF1_THREADS, off otherwise. Note + that this does not work around a possible loss of + thread restart signals. This seems to be necessary for + some versions of Tru64. Since we've previously seen + similar issues on some other operating systems, it + was turned into a runtime flag to enable last-minute + work-arounds. + +GC_IGNORE_FB[=] - (Win32 only.) Try to avoid treating a mapped + frame buffer as part of the root set. Certain (higher end?) + graphics cards seems to result in the graphics memory mapped + into the user address space as writable memory. + Unfortunately, there seems to be no systematic way to + identify such memory. Setting the environment variable to n + causes the collector to ignore mappings longer than n MB. + The default value of n is currently 15. (This should cover + a 16 MB graphics card, since the mapping appears to be slightly + shorter than all of graphics memory. It will fail if a dll + writes pointers to collectable objects into a data segment + whose length is >= 15MB. Empirically that's rare, but + certainly possible.) WARNING: Security sensitive applications + should probably disable this feature by setting + GC_disallow_ignore_fb, or by building with -DNO_GETENV, + since small values could force collection of reachable + objects, which is conceivably a (difficult to exploit) + security hole. GC_IGNORE_FB values less than 3 MB + are never honored, eliminating this risk for most, + but not all, applications. This feature is likely to disappear + if/when we find a less disgusting "solution". + IN VERSION 6.4 AND LATER, THIS SHOULD BE UNNECESSARY. + +The following turn on runtime flags that are also program settable. Checked +only during initialization. We expect that they will usually be set through +other means, but this may help with debugging and testing: + +GC_ENABLE_INCREMENTAL - Turn on incremental collection at startup. Note that, + depending on platform and collector configuration, this + may involve write protecting pieces of the heap to + track modifications. These pieces may include pointerfree + objects or not. Although this is intended to be + transparent, it may cause unintended system call failures. + Use with caution. + +GC_PAUSE_TIME_TARGET - Set the desired garbage collector pause time in msecs. + This only has an effect if incremental collection is + enabled. If a collection requires appreciably more time + than this, the client will be restarted, and the collector + will need to do additional work to compensate. The + special value "999999" indicates that pause time is + unlimited, and the incremental collector will behave + completely like a simple generational collector. If + the collector is configured for parallel marking, and + run on a multiprocessor, incremental collection should + only be used with unlimited pause time. + +GC_FIND_LEAK - Turns on GC_find_leak and thus leak detection. Forces a + collection at program termination to detect leaks that would + otherwise occur after the last GC. + +GC_ALL_INTERIOR_POINTERS - Turns on GC_all_interior_pointers and thus interior + pointer recognition. + +GC_DONT_GC - Turns off garbage collection. Use cautiously. diff --git a/boehm-gc/doc/README.ews4800 b/boehm-gc/doc/README.ews4800 new file mode 100644 index 000000000..80bca2b3d --- /dev/null +++ b/boehm-gc/doc/README.ews4800 @@ -0,0 +1,81 @@ +GC on EWS4800 +------------- + +1. About EWS4800 + EWS4800 is 32bit/64bit workstation. + + Vender: NEC Corporation + OS: UX/4800 R9.* - R13.* (SystemV R4.2) + CPU: R4000, R4400, R10000 (MIPS) + +2. Compiler + + 32bit: + Use ANSI C compiler. + CC = /usr/abiccs/bin/cc + + 64bit: + Use 64bit ANSI C compiler. + CC = /usr/ccs64/bin/cc + AR = /usr/ccs64/bin/ar + +3. ELF file format + *** Caution: The following infomation is empirical. *** + + 32bit: + ELF file has an unique format. (See a.out(4) and end(3C).) + + &_start + : text segment + &etext + DATASTART + : data segment (initialized) + &edata + DATASTART2 + : data segment (uninitialized) + &end + + Here, DATASTART and DATASTART2 are macros of GC, and are defined as + the following equations. (See include/private/gcconfig.h.) + The algorithm for DATASTART is similar with the function + GC_SysVGetDataStart() in os_dep.c. + + DATASTART = ((&etext + 0x3ffff) & ~0x3ffff) + (&etext & 0xffff) + + Dynamically linked: + DATASTART2 = (&_gp + 0x8000 + 0x3ffff) & ~0x3ffff + + Statically linked: + DATASTART2 = &edata + + GC has to check addresses both between DATASTART and &edata, and + between DATASTART2 and &end. If a program accesses between &etext + and DATASTART, or between &edata and DATASTART2, the segmentation + error occurs and the program stops. + + If a program is statically linked, there is not a gap between + &edata and DATASTART2. The global symbol &_DYNAMIC_LINKING is used + for the detection. + + 64bit: + ELF file has a simple format. (See end(3C).) + + _ftext + : text segment + _etext + _fdata = DATASTART + : data segment (initialized) + _edata + _fbss + : data segment (uninitialized) + _end = DATAEND + +-- +Hironori SAKAMOTO + + +When using the new "configure; make" build process, please +run configure with the --disable-shared option. "Make check" does not +yet pass with dynamic libraries. Ther reasons for that are not yet +understood. (HB, paraphrasing message from Hironori SAKAMOTO.) + diff --git a/boehm-gc/doc/README.hp b/boehm-gc/doc/README.hp new file mode 100644 index 000000000..caa8bdd19 --- /dev/null +++ b/boehm-gc/doc/README.hp @@ -0,0 +1,18 @@ +Dynamic loading support requires that executables be linked with -ldld. +The alternative is to build the collector without defining DYNAMIC_LOADING +in gcconfig.h and ensuring that all garbage collectable objects are +accessible without considering statically allocated variables in dynamic +libraries. + +The collector should compile with either plain cc or cc -Ae. Cc -Aa +fails to define _HPUX_SOURCE and thus will not configure the collector +correctly. + +Incremental collection support was reccently added, and should now work. + +In spite of past claims, pthread support under HP/UX 11 should now work. +Define GC_HPUX_THREADS for the build. Incremental collection still does not +work in combination with it. + +The stack finding code can be confused by putenv calls before collector +initialization. Call GC_malloc or GC_init before any putenv calls. diff --git a/boehm-gc/doc/README.linux b/boehm-gc/doc/README.linux new file mode 100644 index 000000000..ec4e7e641 --- /dev/null +++ b/boehm-gc/doc/README.linux @@ -0,0 +1,132 @@ +See README.alpha for Linux on DEC AXP info. + +This file applies mostly to Linux/Intel IA32. Ports to Linux on an M68K, IA64, +SPARC, MIPS, Alpha and PowerPC are also integrated. They should behave +similarly, except that the PowerPC port lacks incremental GC support, and +it is unknown to what extent the Linux threads code is functional. +See below for M68K specific notes. + +Incremental GC is generally supported. + +Dynamic libraries are supported on an ELF system. A static executable +should be linked with the gcc option "-Wl,-defsym,_DYNAMIC=0". + +The collector appears to work reliably with Linux threads, but beware +of older versions of glibc and gdb. + +The garbage collector uses SIGPWR and SIGXCPU if it is used with +Linux threads. These should not be touched by the client program. + +To use threads, you need to abide by the following requirements: + +1) You need to use LinuxThreads or NPTL (which are included in libc6). + + The collector relies on some implementation details of the LinuxThreads + package. This code may not work on other + pthread implementations (in particular it will *not* work with + MIT pthreads). + +2) You must compile the collector with -DGC_LINUX_THREADS and -D_REENTRANT + specified in the Makefile. + +3a) Every file that makes thread calls should define GC_LINUX_THREADS and + _REENTRANT and then include gc.h. Gc.h redefines some of the + pthread primitives as macros which also provide the collector with + information it requires. + +3b) A new alternative to (3a) is to build the collector and compile GC clients + with -DGC_USE_LD_WRAP, and to link the final program with + + (for ld) --wrap read --wrap dlopen --wrap pthread_create \ + --wrap pthread_join --wrap pthread_detach \ + --wrap pthread_sigmask --wrap sleep + + (for gcc) -Wl,--wrap -Wl,read -Wl,--wrap -Wl,dlopen -Wl,--wrap \ + -Wl,pthread_create -Wl,--wrap -Wl,pthread_join -Wl,--wrap \ + -Wl,pthread_detach -Wl,--wrap -Wl,pthread_sigmask \ + -Wl,--wrap -Wl,sleep + + In any case, _REENTRANT should be defined during compilation. + +4) Dlopen() disables collection during its execution. (It can't run + concurrently with the collector, since the collector looks at its + data structures. It can't acquire the allocator lock, since arbitrary + user startup code may run as part of dlopen().) Under unusual + conditions, this may cause unexpected heap growth. + +5) The combination of GC_LINUX_THREADS, REDIRECT_MALLOC, and incremental + collection fails in seemingly random places. This hasn't been tracked + down yet, but is perhaps not completely astonishing. The thread package + uses malloc, and thus can presumably get SIGSEGVs while inside the + package. There is no real guarantee that signals are handled properly + at that point. + +6) Thread local storage may not be viewed as part of the root set by the + collector. This probably depends on the linuxthreads version. For the + time being, any collectable memory referenced by thread local storage should + also be referenced from elsewhere, or be allocated as uncollectable. + (This is really a bug that should be fixed somehow.) + + +M68K LINUX: +(From Richard Zidlicky) +The bad news is that it can crash every linux-m68k kernel on a 68040, +so an additional test is needed somewhere on startup. I have meanwhile +patches to correct the problem in 68040 buserror handler but it is not +yet in any standard kernel. + +Here is a simple test program to detect whether the kernel has the +problem. It could be run as a separate check in configure or tested +upon startup. If it fails (return !0) than mprotect can't be used +on that system. + +/* + * test for bug that may crash 68040 based Linux + */ + +#include +#include +#include +#include +#include + + +char *membase; +int pagesize=4096; +int pageshift=12; +int x_taken=0; + +int sighandler(int sig) +{ + mprotect(membase,pagesize,PROT_READ|PROT_WRITE); + x_taken=1; +} + +main() +{ + long l; + + signal(SIGSEGV,sighandler); + l=(long)mmap(NULL,pagesize,PROT_READ,MAP_PRIVATE | MAP_ANON,-1,0); + if (l==-1) + { + perror("mmap/malloc"); + abort(); + } + membase=(char*)l; + *(long*)(membase+sizeof(long))=123456789; + if (*(long*)(membase+sizeof(long)) != 123456789 ) + { + fprintf(stderr,"writeback failed !\n"); + exit(1); + } + if (!x_taken) + { + fprintf(stderr,"exception not taken !\n"); + exit(1); + } + fprintf(stderr,"vmtest Ok\n"); + exit(0); +} + + diff --git a/boehm-gc/doc/README.macros b/boehm-gc/doc/README.macros new file mode 100644 index 000000000..df0ef2cda --- /dev/null +++ b/boehm-gc/doc/README.macros @@ -0,0 +1,94 @@ +The collector uses a large amount of conditional compilation in order to +deal with platform dependencies. This violates a number of known coding +standards. On the other hand, it seems to be the only practical way to +support this many platforms without excessive code duplication. + +A few guidelines have mostly been followed in order to keep this manageable: + +1) #if and #ifdef directives are properly indented whenever easily possible. +All known C compilers allow whitespace between the "#" and the "if" to make +this possible. ANSI C also allows white space before the "#", though we +avoid that. It has the known disadvantages that it differs from the normal +GNU conventions, and that it makes patches larger than otherwise necessary. +In my opinion, it's still well worth it, for the same reason that we indent +ordinary "if" statements. + +2) Whenever possible, tests are performed on the macros defined in gcconfig.h +instead of directly testing patform-specific predefined macros. This makes it +relatively easy to adapt to new compilers with a different set of predefined +macros. Currently these macros generally identify platforms instead of +features. In many cases, this is a mistake. + +3) The code currently avoids #elif, eventhough that would make it more +readable. This was done since #elif would need to be understood by ALL +compilers used to build the collector, and that hasn't always been the case. +It makes sense to reconsider this decision at some point, since #elif has been +standardized at least since 1989. + +Many of the tested configuration macros are at least somewhat defined in +either include/private/gcconfig.h or in Makefile.direct. Here is an attempt +at defining some of the remainder: (Thanks to Walter Bright for suggesting +this. This is a work in progress) + +MACRO EXPLANATION +----- ----------- + +__DMC__ Always #define'd by the Digital Mars compiler. Expands + to the compiler version number in hex, i.e. 0x810 is + version 8.1b0 + +_ENABLE_ARRAYNEW + #define'd by the Digital Mars C++ compiler when + operator new[] and delete[] are separately + overloadable. Used in gc_cpp.h. + +_MSC_VER Expands to the Visual C++ compiler version. Assumed to + not be defined for other compilers (at least if they behave + appreciably differently). + +_DLL Defined by Visual C++ if dynamic libraries are being built + or used. Used to test whether __declspec(dllimport) or + __declspec(dllexport) needs to be added to declarations + to support the case in which the collector is in a dll. + +GC_DLL User-settable macro that forces the effect of _DLL. Set + by gc.h if _DLL is defined and GC_NOT_DLL is undefined. + This is the macro that is tested internally to determine + whether the GC is in its own dynamic library. May need + to be set by clients before including gc.h. Note that + inside the GC implementation it indicates that the + collector is in its own dynamic library, should export + its symbols, etc. But in clients it indicates that the + GC resides in a different DLL, its entry points should + be referenced accordingly, and precautions may need to + be taken to properly deal with statically allocated + variables in the main program. Used only for MS Windows. + +GC_NOT_DLL User-settable macro that overrides _DLL, e.g. if dynamic + libraries are used, but the collector is in a static library. + +__STDC__ Assumed to be defined only by compilers that understand + prototypes and other C89 features. Its value is generally + not used, since we are fine with most nonconforming extensions. + +SUNOS5SIGS Solaris-like signal handling. This is probably misnamed, + since it really doesn't guarantee much more than Posix. + Currently set only for Solaris2.X, HPUX, and DRSNX. Should + probably be set for some other platforms. + +PCR Set if the collector is being built as part of the Xerox + Portable Common Runtime. + +SRC_M3 Set if the collector is being built as a replacement of the + one in the DEC/Compaq SRC Modula-3 runtime. I suspect this + was last used around 1994, and no doubt broke a long time ago. + It's there primarily incase someone wants to port to a similar + system. + +USE_COMPILER_TLS Assume the existence of __thread-style thread-local + storage. Set automatically for thread-local allocation with + the HP/UX vendor compiler. Usable with gcc on sufficiently + up-to-date ELF platforms. + + + diff --git a/boehm-gc/doc/README.rs6000 b/boehm-gc/doc/README.rs6000 new file mode 100644 index 000000000..f5630b20a --- /dev/null +++ b/boehm-gc/doc/README.rs6000 @@ -0,0 +1,9 @@ +We have so far failed to find a good way to determine the stack base. +It is highly recommended that GC_stackbottom be set explicitly on program +startup. The supplied value sometimes causes failure under AIX 4.1, though +it appears to work under 3.X. HEURISTIC2 seems to work under 4.1, but +involves a substantial performance penalty, and will fail if there is +no limit on stack size. + +There is no thread support. (I assume recent versions of AIX provide +pthreads? I no longer have access to a machine ...) diff --git a/boehm-gc/doc/README.sgi b/boehm-gc/doc/README.sgi new file mode 100644 index 000000000..7bdb50a4e --- /dev/null +++ b/boehm-gc/doc/README.sgi @@ -0,0 +1,41 @@ +Performance of the incremental collector can be greatly enhanced with +-DNO_EXECUTE_PERMISSION. + +The collector should run with all of the -32, -n32 and -64 ABIs. Remember to +define the AS macro in the Makefile to be "as -64", or "as -n32". + +If you use -DREDIRECT_MALLOC=GC_malloc with C++ code, your code should make +at least one explicit call to malloc instead of new to ensure that the proper +version of malloc is linked in. + +Sproc threads are not supported in this version, though there may exist other +ports. + +Pthreads support is provided. This requires that: + +1) You compile the collector with -DGC_IRIX_THREADS specified in the Makefile. + +2) You have the latest pthreads patches installed. + +(Though the collector makes only documented pthread calls, +it relies on signal/threads interactions working just right in ways +that are not required by the standard. It is unlikely that this code +will run on other pthreads platforms. But please tell me if it does.) + +3) Every file that makes thread calls should define IRIX_THREADS and then +include gc.h. Gc.h redefines some of the pthread primitives as macros which +also provide the collector with information it requires. + +4) pthread_cond_wait and pthread_cond_timed_wait should be prepared for +premature wakeups. (I believe the pthreads and realted standards require this +anyway. Irix pthreads often terminate a wait if a signal arrives. +The garbage collector uses signals to stop threads.) + +5) It is expensive to stop a thread waiting in IO at the time the request is +initiated. Applications with many such threads may not exhibit acceptable +performance with the collector. (Increasing the heap size may help.) + +6) The collector should not be compiled with -DREDIRECT_MALLOC. This +confuses some library calls made by the pthreads implementation, which +expect the standard malloc. + diff --git a/boehm-gc/doc/README.solaris2 b/boehm-gc/doc/README.solaris2 new file mode 100644 index 000000000..31e750038 --- /dev/null +++ b/boehm-gc/doc/README.solaris2 @@ -0,0 +1,60 @@ +The collector supports both incremental collection and threads under +Solaris 2. The incremental collector normally retrieves page dirty information +through the appropriate /proc calls. But it can also be configured +(by defining MPROTECT_VDB instead of PROC_VDB in gcconfig.h) to use mprotect +and signals. This may result in shorter pause times, but it is no longer +safe to issue arbitrary system calls that write to the heap. + +Under other UNIX versions, +the collector normally obtains memory through sbrk. There is some reason +to expect that this is not safe if the client program also calls the system +malloc, or especially realloc. The sbrk man page strongly suggests this is +not safe: "Many library routines use malloc() internally, so use brk() +and sbrk() only when you know that malloc() definitely will not be used by +any library routine." This doesn't make a lot of sense to me, since there +seems to be no documentation as to which routines can transitively call malloc. +Nonetheless, under Solaris2, the collector now (since 4.12) allocates +memory using mmap by default. (It defines USE_MMAP in gcconfig.h.) +You may want to reverse this decisions if you use -DREDIRECT_MALLOC=... + + +SOLARIS THREADS: + +The collector must be compiled with -DGC_SOLARIS_THREADS (thr_ functions) +or -DGC_SOLARIS_PTHREADS (pthread_ functions) to be thread safe. +It is also essential that gc.h be included in files that call thr_create, +thr_join, thr_suspend, thr_continue, or dlopen. Gc.h macro defines +these to also do GC bookkeeping, etc. Gc.h must be included with +one or both of these macros defined, otherwise +these replacements are not visible. +A collector built in this way way only be used by programs that are +linked with the threads library. + +In this mode, the collector contains various workarounds for older Solaris +bugs. Mostly, these should not be noticeable unless you look at system +call traces. However, it cannot protect a guard page at the end of +a thread stack. If you know that you will only be running Solaris2.5 +or later, it should be possible to fix this by compiling the collector +with -DSOLARIS23_MPROTECT_BUG_FIXED. + +Since 5.0 alpha5, dlopen disables collection temporarily, +unless USE_PROC_FOR_LIBRARIES is defined. In some unlikely cases, this +can result in unpleasant heap growth. But it seems better than the +race/deadlock issues we had before. + +If solaris_threads are used on an X86 processor with malloc redirected to +GC_malloc a deadlock is likely to result. + +It appears that there is a problem in using gc_cpp.h in conjunction with +Solaris threads and Sun's C++ runtime. Apparently the overloaded new operator +is invoked by some iostream initialization code before threads are correctly +initialized. As a result, call to thr_self() in garbage collector +initialization segfaults. Currently the only known workaround is to not +invoke the garbage collector from a user defined global operator new, or to +have it invoke the garbage-collector's allocators only after main has started. +(Note that the latter requires a moderately expensive test in operator +delete.) + +Hans-J. Boehm +(The above contains my personal opinions, which are probably not shared +by anyone else.) diff --git a/boehm-gc/doc/README.uts b/boehm-gc/doc/README.uts new file mode 100644 index 000000000..6be49667d --- /dev/null +++ b/boehm-gc/doc/README.uts @@ -0,0 +1,2 @@ +Alistair Crooks supplied the port. He used Lexa C version 2.1.3 with +-Xa to compile. diff --git a/boehm-gc/doc/README.win32 b/boehm-gc/doc/README.win32 new file mode 100644 index 000000000..6f57db117 --- /dev/null +++ b/boehm-gc/doc/README.win32 @@ -0,0 +1,215 @@ +The collector has at various times been compiled under Windows 95 & later, NT, +and XP, with the original Microsoft SDK, with Visual C++ 2.0, 4.0, and 6, with +the GNU win32 tools, with Borland 4.5, with Watcom C, and recently +with the Digital Mars compiler. It is likely that some of these have been +broken in the meantime. Patches are appreciated. + +For historical reasons, +the collector test program "gctest" is linked as a GUI application, +but does not open any windows. Its output appears in the file +"gc.log". It may be started from the file manager. The hour glass +cursor may appear as long as it's running. If it is started from the +command line, it will usually run in the background. Wait a few +minutes (a few seconds on a modern machine) before you check the output. +You should see either a failure indication or a "Collector appears to +work" message. + +The cord test program has not been ported (but should port +easily). A toy editor (cord/de.exe) based on cords (heavyweight +strings represented as trees) has been ported and is included. +It runs fine under either win32 or win32S. It serves as an example +of a true Windows application, except that it was written by a +nonexpert Windows programmer. (There are some peculiarities +in the way files are displayed. The is displayed explicitly +for standard DOS text files. As in the UNIX version, control +characters are displayed explicitly, but in this case as red text. +This may be suboptimal for some tastes and/or sets of default +window colors.) + +In general -DREDIRECT_MALLOC is unlikely to work unless the +application is completely statically linked. + +The collector normally allocates memory from the OS with VirtualAlloc. +This appears to cause problems under Windows NT and Windows 2000 (but +not Windows 95/98) if the memory is later passed to CreateDIBitmap. +To work around this problem, build the collector with -DUSE_GLOBAL_ALLOC. +This is currently incompatible with -DUSE_MUNMAP. (Thanks to Jonathan +Clark for tracking this down. There's some chance this may be fixed +in 6.1alpha4, since we now separate heap sections with an unused page.) + +Microsoft Tools +--------------- +For Microsoft development tools, rename NT_MAKEFILE as +MAKEFILE. (Make sure that the CPU environment variable is defined +to be i386.) In order to use the gc_cpp.h C++ interface, all +client code should include gc_cpp.h. + +For historical reasons, +the collector test program "gctest" is linked as a GUI application, +but does not open any windows. Its output appears in the file +"gc.log". It may be started from the file manager. The hour glass +cursor may appear as long as it's running. If it is started from the +command line, it will usually run in the background. Wait a few +minutes (a few seconds on a modern machine) before you check the output. +You should see either a failure indication or a "Collector appears to +work" message. + +If you would prefer a VC++.NET project file, ask boehm@acm.org. One has +been contributed, but it seems to contain some absolute paths etc., so +it can presumably only be a starting point, and is not in the standard +distribution. It is unclear (to me, Hans Boehm) whether it is feasible to +change that. + +Clients may need to define GC_NOT_DLL before including gc.h, if the +collector was built as a static library (as it normally is in the +absence of thread support). + +GNU Tools +--------- +For GNU-win32, use the regular makefile, possibly after uncommenting +the line "include Makefile.DLLs". The latter should be necessary only +if you want to package the collector as a DLL. +[Is the following sentence obsolete? -HB] The GNU-win32 port is +believed to work only for b18, not b19, probably due to linker changes +in b19. This is probably fixable with a different definition of +DATASTART and DATAEND in gcconfig.h. + +The collector should also be buildable under Cygwin with either the +old standard Makefile, or with the "configure;make" machinery. + +Borland Tools +------------- +[Rarely tested.] +For Borland tools, use BCC_MAKEFILE. Note that +Borland's compiler defaults to 1 byte alignment in structures (-a1), +whereas Visual C++ appears to default to 8 byte alignment (/Zp8). +The garbage collector in its default configuration EXPECTS AT +LEAST 4 BYTE ALIGNMENT. Thus the BORLAND DEFAULT MUST +BE OVERRIDDEN. (In my opinion, it should usually be anyway. +I expect that -a1 introduces major performance penalties on a +486 or Pentium.) Note that this changes structure layouts. (As a last +resort, gcconfig.h can be changed to allow 1 byte alignment. But +this has significant negative performance implications.) +The Makefile is set up to assume Borland 4.5. If you have another +version, change the line near the top. By default, it does not +require the assembler. If you do have the assembler, I recommend +removing the -DUSE_GENERIC. + +Incremental Collection +---------------------- +There is some support for incremental collection. This is +currently pretty simple-minded. Pages are protected. Protection +faults are caught by a handler installed at the bottom of the handler +stack. This is both slow and interacts poorly with a debugger. +Whenever possible, I recommend adding a call to +GC_enable_incremental at the last possible moment, after most +debugging is complete. Unlike the UNIX versions, no system +calls are wrapped by the collector itself. It may be necessary +to wrap ReadFile calls that use a buffer in the heap, so that the +call does not encounter a protection fault while it's running. +(As usual, none of this is an issue unless GC_enable_incremental +is called.) + +Note that incremental collection is disabled with -DSMALL_CONFIG. + +Threads +------- + +James Clark has contributed the necessary code to support win32 threads +with the collector in a DLL. +Use NT_THREADS_MAKEFILE (a.k.a gc.mak) instead of NT_MAKEFILE +to build this version. Note that this requires some files whose names +are more than 8 + 3 characters long. Thus you should unpack the tar file +so that long file names are preserved. To build the garbage collector +test with VC++ from the command line, use + +nmake /F ".\gc.mak" CFG="gctest - Win32 Release" + +This requires that the subdirectory gctest\Release exist. +The test program and DLL will reside in the Release directory. + +This version relies on the collector residing in a dll. + +This version currently supports incremental collection only if it is +enabled before any additional threads are created. + +Since 6.3alpha2, threads are also better supported in static library builds +with Microsoft tools (use NT_STATIC_THREADS_MAKEFILE) and with the GNU +tools. In all cases,the collector must be built with GC_WIN32_THREADS +defined, even if the Cygwin pthreads interface is used. +(NT_STATIC_THREADS_MAKEFILE does this implicitly. Under Cygwin, +./configure --enable-threads=posix defines GC_WIN32_THREADS.) Threads must be +created with GC_CreateThread. This can be accomplished by +including gc.h and then calling CreateThread, which is redefined +by gc.h. + +For the statically linked versions, it is required that GC_init() +be called before other GC calls, since there seems to be no implicit way +to initialize the allocation lock. The easiest way to ensure this in +portable code is to call GC_INIT() from the main executable (not +a dynamic library) before calling any other GC_ routines. + +We strongly advise against using the TerminateThread() win32 API call, +especially with the garbage collector. Any use is likely to provoke a +crash in the GC, since it makes it impossible for the collector to +correctly track threads. + + +Watcom compiler +--------------- + +Ivan V. Demakov's README for the Watcom port: + +The collector has been compiled with Watcom C 10.6 and 11.0. +It runs under win32, win32s, and even under msdos with dos4gw +dos-extender. It should also run under OS/2, though this isn't +tested. Under win32 the collector can be built either as dll +or as static library. + +Note that all compilations were done under Windows 95 or NT. +For unknown reason compiling under Windows 3.11 for NT (one +attempt has been made) leads to broken executables. + +Incremental collection is not supported. + +cord is not ported. + +Before compiling you may need to edit WCC_MAKEFILE to set target +platform, library type (dynamic or static), calling conventions, and +optimization options. + +To compile the collector and testing programs use the command: + wmake -f WCC_MAKEFILE + +All programs using gc should be compiled with 4-byte alignment. +For further explanations on this see comments about Borland. + +If the gc is compiled as dll, the macro ``GC_DLL'' should be defined before +including "gc.h" (for example, with -DGC_DLL compiler option). It's +important, otherwise resulting programs will not run. + +Ivan Demakov (email: ivan@tgrad.nsk.su) + +Win32S +------ + +[The following is probably obsolete. The win32s support is still in the +collector, but I doubt anyone cares, or has tested it recently.] + +The collector runs under both win32s and win32, but with different semantics. +Under win32, all writable pages outside of the heaps and stack are +scanned for roots. Thus the collector sees pointers in DLL data +segments. Under win32s, only the main data segment is scanned. +(The main data segment should always be scanned. Under some +versions of win32s, other regions may also be scanned.) +Thus all accessible objects should be accessible from local variables +or variables in the main data segment. Alternatively, other data +segments (e.g. in DLLs) may be registered with the collector by +calling GC_init() and then GC_register_root_section(a), where +a is the address of some variable inside the data segment. (Duplicate +registrations are ignored, but not terribly quickly.) + +(There are two reasons for this. We didn't want to see many 16:16 +pointers. And the VirtualQuery call has different semantics under +the two systems, and under different versions of win32s.) + diff --git a/boehm-gc/doc/barrett_diagram b/boehm-gc/doc/barrett_diagram new file mode 100644 index 000000000..27e80dc15 --- /dev/null +++ b/boehm-gc/doc/barrett_diagram @@ -0,0 +1,106 @@ +This is an ASCII diagram of the data structure used to check pointer +validity. It was provided by Dave Barrett , +and should be of use to others attempting to understand the code. +The data structure in GC4.X is essentially the same. -HB + + + + + Data Structure used by GC_base in gc3.7: + 21-Apr-94 + + + + + 63 LOG_TOP_SZ[11] LOG_BOTTOM_SZ[10] LOG_HBLKSIZE[13] + +------------------+----------------+------------------+------------------+ + p:| | TL_HASH(hi) | | HBLKDISPL(p) | + +------------------+----------------+------------------+------------------+ + \-----------------------HBLKPTR(p)-------------------/ + \------------hi-------------------/ + \______ ________/ \________ _______/ \________ _______/ + V V V + | | | + GC_top_index[] | | | + --- +--------------+ | | | + ^ | | | | | + | | | | | | + TOP +--------------+<--+ | | + _SZ +-<| [] | * | | +(items)| +--------------+ if 0 < bi< HBLKSIZE | | + | | | | then large object | | + | | | | starts at the bi'th | | + v | | | HBLK before p. | i | + --- | +--------------+ | (word- | + v | aligned) | + bi= |GET_BI(p){->hash_link}->key==hi | | + v | | + | (bottom_index) \ scratch_alloc'd | | + | ( struct bi ) / by get_index() | | + --- +->+--------------+ | | + ^ | | | | + ^ | | | | + BOTTOM | | ha=GET_HDR_ADDR(p) | | +_SZ(items)+--------------+<----------------------+ +-------+ + | +--<| index[] | | + | | +--------------+ GC_obj_map: v + | | | | from / +-+-+-----+-+-+-+-+ --- + v | | | GC_add < 0| | | | | | | | ^ + --- | +--------------+ _map_entry \ +-+-+-----+-+-+-+-+ | + | | asc_link | +-+-+-----+-+-+-+-+ MAXOBJSZ + | +--------------+ +-->| | | j | | | | | +1 + | | key | | +-+-+-----+-+-+-+-+ | + | +--------------+ | +-+-+-----+-+-+-+-+ | + | | hash_link | | | | | | | | | | v + | +--------------+ | +-+-+-----+-+-+-+-+ --- + | | |<--MAX_OFFSET--->| + | | (bytes) +HDR(p)| GC_find_header(p) | |<--MAP_ENTRIES-->| + | \ from | =HBLKSIZE/WORDSZ + | (hdr) (struct hblkhdr) / alloc_hdr() | (1024 on Alpha) + +-->+----------------------+ | (8/16 bits each) +GET_HDR(p)| word hb_sz (words) | | + +----------------------+ | + | struct hblk *hb_next | | + +----------------------+ | + |mark_proc hb_mark_proc| | + +----------------------+ | + | char * hb_map |>-------------+ + +----------------------+ + | ushort hb_obj_kind | + +----------------------+ + | hb_last_reclaimed | + --- +----------------------+ + ^ | | + MARK_BITS| hb_marks[] | *if hdr is free, hb_sz + DISCARD_WORDS +_SZ(words)| | is the size of a heap chunk (struct hblk) + v | | of at least MININCR*HBLKSIZE bytes (below), + --- +----------------------+ otherwise, size of each object in chunk. + +Dynamic data structures above are interleaved throughout the heap in blocks of +size MININCR * HBLKSIZE bytes as done by gc_scratch_alloc which cannot be +freed; free lists are used (e.g. alloc_hdr). HBLKs's below are collected. + + (struct hblk) + --- +----------------------+ < HBLKSIZE --- --- DISCARD_ + ^ |garbage[DISCARD_WORDS]| aligned ^ ^ HDR_BYTES WORDS + | | | | v (bytes) (words) + | +-----hb_body----------+ < WORDSZ | --- --- + | | | aligned | ^ ^ + | | Object 0 | | hb_sz | + | | | i |(word- (words)| + | | | (bytes)|aligned) v | + | + - - - - - - - - - - -+ --- | --- | + | | | ^ | ^ | + n * | | j (words) | hb_sz BODY_SZ + HBLKSIZE | Object 1 | v v | (words) + (bytes) | |--------------- v MAX_OFFSET + | + - - - - - - - - - - -+ --- (bytes) + | | | !All_INTERIOR_PTRS ^ | + | | | sets j only for hb_sz | + | | Object N | valid object offsets. | | + v | | All objects WORDSZ v v + --- +----------------------+ aligned. --- --- + +DISCARD_WORDS is normally zero. Indeed the collector has not been tested +with another value in ages. diff --git a/boehm-gc/doc/debugging.html b/boehm-gc/doc/debugging.html new file mode 100644 index 000000000..7c65f2bb4 --- /dev/null +++ b/boehm-gc/doc/debugging.html @@ -0,0 +1,306 @@ + + +Debugging Garbage Collector Related Problems + + +

Debugging Garbage Collector Related Problems

+This page contains some hints on +debugging issues specific to +the Boehm-Demers-Weiser conservative garbage collector. +It applies both to debugging issues in client code that manifest themselves +as collector misbehavior, and to debugging the collector itself. +

+If you suspect a bug in the collector itself, it is strongly recommended +that you try the latest collector release, even if it is labelled as "alpha", +before proceeding. +

Bus Errors and Segmentation Violations

+

+If the fault occurred in GC_find_limit, or with incremental collection enabled, +this is probably normal. The collector installs handlers to take care of +these. You will not see these unless you are using a debugger. +Your debugger should allow you to continue. +It's often preferable to tell the debugger to ignore SIGBUS and SIGSEGV +("handle SIGSEGV SIGBUS nostop noprint" in gdb, +"ignore SIGSEGV SIGBUS" in most versions of dbx) +and set a breakpoint in abort. +The collector will call abort if the signal had another cause, +and there was not other handler previously installed. +

+We recommend debugging without incremental collection if possible. +(This applies directly to UNIX systems. +Debugging with incremental collection under win32 is worse. See README.win32.) +

+If the application generates an unhandled SIGSEGV or equivalent, it may +often be easiest to set the environment variable GC_LOOP_ON_ABORT. On many +platforms, this will cause the collector to loop in a handler when the +SIGSEGV is encountered (or when the collector aborts for some other reason), +and a debugger can then be attached to the looping +process. This sidesteps common operating system problems related +to incomplete core files for multithreaded applications, etc. +

Other Signals

+On most platforms, the multithreaded version of the collector needs one or +two other signals for internal use by the collector in stopping threads. +It is normally wise to tell the debugger to ignore these. On Linux, +the collector currently uses SIGPWR and SIGXCPU by default. +

Warning Messages About Needing to Allocate Blacklisted Blocks

+The garbage collector generates warning messages of the form +
+Needed to allocate blacklisted block at 0x...
+
+or +
+Repeated allocation of very large block ...
+
+when it needs to allocate a block at a location that it knows to be +referenced by a false pointer. These false pointers can be either permanent +(e.g. a static integer variable that never changes) or temporary. +In the latter case, the warning is largely spurious, and the block will +eventually be reclaimed normally. +In the former case, the program will still run correctly, but the block +will never be reclaimed. Unless the block is intended to be +permanent, the warning indicates a memory leak. +
    +
  1. Ignore these warnings while you are using GC_DEBUG. Some of the routines +mentioned below don't have debugging equivalents. (Alternatively, write +the missing routines and send them to me.) +
  2. Replace allocator calls that request large blocks with calls to +GC_malloc_ignore_off_page or +GC_malloc_atomic_ignore_off_page. You may want to set a +breakpoint in GC_default_warn_proc to help you identify such calls. +Make sure that a pointer to somewhere near the beginning of the resulting block +is maintained in a (preferably volatile) variable as long as +the block is needed. +
  3. +If the large blocks are allocated with realloc, we suggest instead allocating +them with something like the following. Note that the realloc size increment +should be fairly large (e.g. a factor of 3/2) for this to exhibit reasonable +performance. But we all know we should do that anyway. +
    +void * big_realloc(void *p, size_t new_size)
    +{
    +    size_t old_size = GC_size(p);
    +    void * result;
    + 
    +    if (new_size <= 10000) return(GC_realloc(p, new_size));
    +    if (new_size <= old_size) return(p);
    +    result = GC_malloc_ignore_off_page(new_size);
    +    if (result == 0) return(0);
    +    memcpy(result,p,old_size);
    +    GC_free(p);
    +    return(result);
    +}
    +
    + +
  4. In the unlikely case that even relatively small object +(<20KB) allocations are triggering these warnings, then your address +space contains lots of "bogus pointers", i.e. values that appear to +be pointers but aren't. Usually this can be solved by using GC_malloc_atomic +or the routines in gc_typed.h to allocate large pointer-free regions of bitmaps, etc. Sometimes the problem can be solved with trivial changes of encoding +in certain values. It is possible, to identify the source of the bogus +pointers by building the collector with -DPRINT_BLACK_LIST, +which will cause it to print the "bogus pointers", along with their location. + +
  5. If you get only a fixed number of these warnings, you are probably only +introducing a bounded leak by ignoring them. If the data structures being +allocated are intended to be permanent, then it is also safe to ignore them. +The warnings can be turned off by calling GC_set_warn_proc with a procedure +that ignores these warnings (e.g. by doing absolutely nothing). +
+ +

The Collector References a Bad Address in GC_malloc

+ +This typically happens while the collector is trying to remove an entry from +its free list, and the free list pointer is bad because the free list link +in the last allocated object was bad. +

+With > 99% probability, you wrote past the end of an allocated object. +Try setting GC_DEBUG before including gc.h and +allocating with GC_MALLOC. This will try to detect such +overwrite errors. + +

Unexpectedly Large Heap

+ +Unexpected heap growth can be due to one of the following: +
    +
  1. Data structures that are being unintentionally retained. This +is commonly caused by data structures that are no longer being used, +but were not cleared, or by caches growing without bounds. +
  2. Pointer misidentification. The garbage collector is interpreting +integers or other data as pointers and retaining the "referenced" +objects. A common symptom is that GC_dump() shows much of the heap +as black-listed. +
  3. Heap fragmentation. This should never result in unbounded growth, +but it may account for larger heaps. This is most commonly caused +by allocation of large objects. On some platforms it can be reduced +by building with -DUSE_MUNMAP, which will cause the collector to unmap +memory corresponding to pages that have not been recently used. +
  4. Per object overhead. This is usually a relatively minor effect, but +it may be worth considering. If the collector recognizes interior +pointers, object sizes are increased, so that one-past-the-end pointers +are correctly recognized. The collector can be configured not to do this +(-DDONT_ADD_BYTE_AT_END). +

    +The collector rounds up object sizes so the result fits well into the +chunk size (HBLKSIZE, normally 4K on 32 bit machines, 8K +on 64 bit machines) used by the collector. Thus it may be worth avoiding +objects of size 2K + 1 (or 2K if a byte is being added at the end.) +

+The last two cases can often be identified by looking at the output +of a call to GC_dump(). Among other things, it will print the +list of free heap blocks, and a very brief description of all chunks in +the heap, the object sizes they correspond to, and how many live objects +were found in the chunk at the last collection. +

+Growing data structures can usually be identified by +

    +
  1. Building the collector with -DKEEP_BACK_PTRS, +
  2. Preferably using debugging allocation (defining GC_DEBUG +before including gc.h and allocating with GC_MALLOC), +so that objects will be identified by their allocation site, +
  3. Running the application long enough so +that most of the heap is composed of "leaked" memory, and +
  4. Then calling GC_generate_random_backtrace() from backptr.h +a few times to determine why some randomly sampled objects in the heap are +being retained. +
+

+The same technique can often be used to identify problems with false +pointers, by noting whether the reference chains printed by +GC_generate_random_backtrace() involve any misidentified pointers. +An alternate technique is to build the collector with +-DPRINT_BLACK_LIST which will cause it to report values that +are almost, but not quite, look like heap pointers. It is very likely that +actual false pointers will come from similar sources. +

+In the unlikely case that false pointers are an issue, it can usually +be resolved using one or more of the following techniques: +

    +
  1. Use GC_malloc_atomic for objects containing no pointers. +This is especially important for large arrays containing compressed data, +pseudo-random numbers, and the like. It is also likely to improve GC +performance, perhaps drastically so if the application is paging. +
  2. If you allocate large objects containing only +one or two pointers at the beginning, either try the typed allocation +primitives is gc_typed.h, or separate out the pointerfree component. +
  3. Consider using GC_malloc_ignore_off_page() +to allocate large objects. (See gc.h and above for details. +Large means > 100K in most environments.) +
  4. If your heap size is larger than 100MB or so, build the collector with +-DLARGE_CONFIG. This allows the collector to keep more precise black-list +information. +
  5. If you are using heaps close to, or larger than, a gigabyte on a 32-bit +machine, you may want to consider moving to a platform with 64-bit pointers. +This is very likely to resolve any false pointer issues. +
+

Prematurely Reclaimed Objects

+The usual symptom of this is a segmentation fault, or an obviously overwritten +value in a heap object. This should, of course, be impossible. In practice, +it may happen for reasons like the following: +
    +
  1. The collector did not intercept the creation of threads correctly in +a multithreaded application, e.g. because the client called +pthread_create without including gc.h, which redefines it. +
  2. The last pointer to an object in the garbage collected heap was stored +somewhere were the collector couldn't see it, e.g. in an +object allocated with system malloc, in certain types of +mmaped files, +or in some data structure visible only to the OS. (On some platforms, +thread-local storage is one of these.) +
  3. The last pointer to an object was somehow disguised, e.g. by +XORing it with another pointer. +
  4. Incorrect use of GC_malloc_atomic or typed allocation. +
  5. An incorrect GC_free call. +
  6. The client program overwrote an internal garbage collector data structure. +
  7. A garbage collector bug. +
  8. (Empirically less likely than any of the above.) A compiler optimization +that disguised the last pointer. +
+The following relatively simple techniques should be tried first to narrow +down the problem: +
    +
  1. If you are using the incremental collector try turning it off for +debugging. +
  2. If you are using shared libraries, try linking statically. If that works, +ensure that DYNAMIC_LOADING is defined on your platform. +
  3. Try to reproduce the problem with fully debuggable unoptimized code. +This will eliminate the last possibility, as well as making debugging easier. +
  4. Try replacing any suspect typed allocation and GC_malloc_atomic +calls with calls to GC_malloc. +
  5. Try removing any GC_free calls (e.g. with a suitable +#define). +
  6. Rebuild the collector with -DGC_ASSERTIONS. +
  7. If the following works on your platform (i.e. if gctest still works +if you do this), try building the collector with +-DREDIRECT_MALLOC=GC_malloc_uncollectable. This will cause +the collector to scan memory allocated with malloc. +
+If all else fails, you will have to attack this with a debugger. +Suggested steps: +
    +
  1. Call GC_dump() from the debugger around the time of the failure. Verify +that the collectors idea of the root set (i.e. static data regions which +it should scan for pointers) looks plausible. If not, i.e. if it doesn't +include some static variables, report this as +a collector bug. Be sure to describe your platform precisely, since this sort +of problem is nearly always very platform dependent. +
  2. Especially if the failure is not deterministic, try to isolate it to +a relatively small test case. +
  3. Set a break point in GC_finish_collection. This is a good +point to examine what has been marked, i.e. found reachable, by the +collector. +
  4. If the failure is deterministic, run the process +up to the last collection before the failure. +Note that the variable GC_gc_no counts collections and can be used +to set a conditional breakpoint in the right one. It is incremented just +before the call to GC_finish_collection. +If object p was prematurely recycled, it may be helpful to +look at *GC_find_header(p) at the failure point. +The hb_last_reclaimed field will identify the collection number +during which its block was last swept. +
  5. Verify that the offending object still has its correct contents at +this point. +Then call GC_is_marked(p) from the debugger to verify that the +object has not been marked, and is about to be reclaimed. Note that +GC_is_marked(p) expects the real address of an object (the +address of the debug header if there is one), and thus it may +be more appropriate to call GC_is_marked(GC_base(p)) +instead. +
  6. Determine a path from a root, i.e. static variable, stack, or +register variable, +to the reclaimed object. Call GC_is_marked(q) for each object +q along the path, trying to locate the first unmarked object, say +r. +
  7. If r is pointed to by a static root, +verify that the location +pointing to it is part of the root set printed by GC_dump(). If it +is on the stack in the main (or only) thread, verify that +GC_stackbottom is set correctly to the base of the stack. If it is +in another thread stack, check the collector's thread data structure +(GC_thread[] on several platforms) to make sure that stack bounds +are set correctly. +
  8. If r is pointed to by heap object s, check that the +collector's layout description for s is such that the pointer field +will be scanned. Call *GC_find_header(s) to look at the descriptor +for the heap chunk. The hb_descr field specifies the layout +of objects in that chunk. See gc_mark.h for the meaning of the descriptor. +(If it's low order 2 bits are zero, then it is just the length of the +object prefix to be scanned. This form is always used for objects allocated +with GC_malloc or GC_malloc_atomic.) +
  9. If the failure is not deterministic, you may still be able to apply some +of the above technique at the point of failure. But remember that objects +allocated since the last collection will not have been marked, even if the +collector is functioning properly. On some platforms, the collector +can be configured to save call chains in objects for debugging. +Enabling this feature will also cause it to save the call stack at the +point of the last GC in GC_arrays._last_stack. +
  10. When looking at GC internal data structures remember that a number +of GC_xxx variables are really macro defined to +GC_arrays._xxx, so that +the collector can avoid scanning them. +
+ + + + + + diff --git a/boehm-gc/doc/gc.man b/boehm-gc/doc/gc.man new file mode 100644 index 000000000..2a550c712 --- /dev/null +++ b/boehm-gc/doc/gc.man @@ -0,0 +1,97 @@ +.TH GC_MALLOC 1L "2 October 2003" +.SH NAME +GC_malloc, GC_malloc_atomic, GC_free, GC_realloc, GC_enable_incremental, GC_register_finalizer, GC_malloc_ignore_off_page, GC_malloc_atomic_ignore_off_page, GC_set_warn_proc \- Garbage collecting malloc replacement +.SH SYNOPSIS +#include "gc.h" +.br +void * GC_malloc(size_t size); +.br +void GC_free(void *ptr); +.br +void * GC_realloc(void *ptr, size_t size); +.br +.sp +cc ... gc.a +.LP +.SH DESCRIPTION +.I GC_malloc +and +.I GC_free +are plug-in replacements for standard malloc and free. However, +.I +GC_malloc +will attempt to reclaim inaccessible space automatically by invoking a conservative garbage collector at appropriate points. The collector traverses all data structures accessible by following pointers from the machines registers, stack(s), data, and bss segments. Inaccessible structures will be reclaimed. A machine word is considered to be a valid pointer if it is an address inside an object allocated by +.I +GC_malloc +or friends. +.LP +In most cases it is preferable to call the macros GC_MALLOC, GC_FREE, etc. +instead of calling GC_malloc and friends directly. This allows debugging +versions of the routines to be substituted by defining GC_DEBUG before +including gc.h. +.LP +See the documentation in the include file gc_cpp.h for an alternate, C++ specific interface to the garbage collector. +.LP +Unlike the standard implementations of malloc, +.I +GC_malloc +clears the newly allocated storage. +.I +GC_malloc_atomic +does not. Furthermore, it informs the collector that the resulting object will never contain any pointers, and should therefore not be scanned by the collector. +.LP +.I +GC_free +can be used to deallocate objects, but its use is optional, and generally discouraged. +.I +GC_realloc +has the standard realloc semantics. It preserves pointer-free-ness. +.I +GC_register_finalizer +allows for registration of functions that are invoked when an object becomes inaccessible. +.LP +The garbage collector tries to avoid allocating memory at locations that already appear to be referenced before allocation. (Such apparent ``pointers'' are usually large integers and the like that just happen to look like an address.) This may make it hard to allocate very large objects. An attempt to do so may generate a warning. +.LP +.I +GC_malloc_ignore_off_page +and +.I +GC_malloc_atomic_ignore_off_page +inform the collector that the client code will always maintain a pointer to near the beginning of the object (within the first 512 bytes), and that pointers beyond that can be ignored by the collector. This makes it much easier for the collector to place large objects. These are recommended for large object allocation. (Objects expected to be larger than about 100KBytes should be allocated this way.) +.LP +It is also possible to use the collector to find storage leaks in programs destined to be run with standard malloc/free. The collector can be compiled for thread-safe operation. Unlike standard malloc, it is safe to call malloc after a previous malloc call was interrupted by a signal, provided the original malloc call is not resumed. +.LP +The collector may, on rare occasion produce warning messages. On UNIX machines these appear on stderr. Warning messages can be filtered, redirected, or ignored with +.I +GC_set_warn_proc +This is recommended for production code. See gc.h for details. +.LP +Fully portable code should call +.I +GC_INIT +from the main program before making any other GC calls. +On most platforms this does nothing and the collector is initialized on first use. +On a few platforms explicit initialization is necessary. And it can never hurt. +.LP +Debugging versions of many of the above routines are provided as macros. Their names are identical to the above, but consist of all capital letters. If GC_DEBUG is defined before gc.h is included, these routines do additional checking, and allow the leak detecting version of the collector to produce slightly more useful output. Without GC_DEBUG defined, they behave exactly like the lower-case versions. +.LP +On some machines, collection will be performed incrementally after a call to +.I +GC_enable_incremental. +This may temporarily write protect pages in the heap. See the README file for more information on how this interacts with system calls that write to the heap. +.LP +Other facilities not discussed here include limited facilities to support incremental collection on machines without appropriate VM support, provisions for providing more explicit object layout information to the garbage collector, more direct support for ``weak'' pointers, support for ``abortable'' garbage collections during idle time, etc. +.LP +.SH "SEE ALSO" +The README and gc.h files in the distribution. More detailed definitions of the functions exported by the collector are given there. (The above list is not complete.) +.LP +The web site at http://www.hpl.hp.com/personal/Hans_Boehm/gc . +.LP +Boehm, H., and M. Weiser, "Garbage Collection in an Uncooperative Environment", +\fISoftware Practice & Experience\fP, September 1988, pp. 807-820. +.LP +The malloc(3) man page. +.LP +.SH AUTHOR +Hans-J. Boehm (Hans.Boehm@hp.com). +Some of the code was written by others, most notably Alan Demers. diff --git a/boehm-gc/doc/gcdescr.html b/boehm-gc/doc/gcdescr.html new file mode 100644 index 000000000..cab6bde4f --- /dev/null +++ b/boehm-gc/doc/gcdescr.html @@ -0,0 +1,560 @@ + + + Conservative GC Algorithmic Overview + Hans-J. Boehm, HP Labs (Much of this was written at SGI) + + +

This is under construction, and may always be.

+

Conservative GC Algorithmic Overview

+

+This is a description of the algorithms and data structures used in our +conservative garbage collector. I expect the level of detail to increase +with time. For a survey of GC algorithms, see for example + Paul Wilson's +excellent paper. For an overview of the collector interface, +see here. +

+This description is targeted primarily at someone trying to understand the +source code. It specifically refers to variable and function names. +It may also be useful for understanding the algorithms at a higher level. +

+The description here assumes that the collector is used in default mode. +In particular, we assume that it used as a garbage collector, and not just +a leak detector. We initially assume that it is used in stop-the-world, +non-incremental mode, though the presence of the incremental collector +will be apparent in the design. +We assume the default finalization model, but the code affected by that +is very localized. +

Introduction

+The garbage collector uses a modified mark-sweep algorithm. Conceptually +it operates roughly in four phases, which are performed occasionally +as part of a memory allocation: + +
    + +
  1. +Preparation Each object has an associated mark bit. +Clear all mark bits, indicating that all objects +are potentially unreachable. + +
  2. +Mark phase Marks all objects that can be reachable via chains of +pointers from variables. Often the collector has no real information +about the location of pointer variables in the heap, so it +views all static data areas, stacks and registers as potentially containing +pointers. Any bit patterns that represent addresses inside +heap objects managed by the collector are viewed as pointers. +Unless the client program has made heap object layout information +available to the collector, any heap objects found to be reachable from +variables are again scanned similarly. + +
  3. +Sweep phase Scans the heap for inaccessible, and hence unmarked, +objects, and returns them to an appropriate free list for reuse. This is +not really a separate phase; even in non incremental mode this is operation +is usually performed on demand during an allocation that discovers an empty +free list. Thus the sweep phase is very unlikely to touch a page that +would not have been touched shortly thereafter anyway. + +
  4. +Finalization phase Unreachable objects which had been registered +for finalization are enqueued for finalization outside the collector. + +
+ +

+The remaining sections describe the memory allocation data structures, +and then the last 3 collection phases in more detail. We conclude by +outlining some of the additional features implemented in the collector. + +

Allocation

+The collector includes its own memory allocator. The allocator obtains +memory from the system in a platform-dependent way. Under UNIX, it +uses either malloc, sbrk, or mmap. +

+Most static data used by the allocator, as well as that needed by the +rest of the garbage collector is stored inside the +_GC_arrays structure. +This allows the garbage collector to easily ignore the collectors own +data structures when it searches for root pointers. Other allocator +and collector internal data structures are allocated dynamically +with GC_scratch_alloc. GC_scratch_alloc does not +allow for deallocation, and is therefore used only for permanent data +structures. +

+The allocator allocates objects of different kinds. +Different kinds are handled somewhat differently by certain parts +of the garbage collector. Certain kinds are scanned for pointers, +others are not. Some may have per-object type descriptors that +determine pointer locations. Or a specific kind may correspond +to one specific object layout. Two built-in kinds are uncollectable. +One (STUBBORN) is immutable without special precautions. +In spite of that, it is very likely that most C clients of the +collector currently +use at most two kinds: NORMAL and PTRFREE objects. +The gcj runtime also makes +heavy use of a kind (allocated with GC_gcj_malloc) that stores +type information at a known offset in method tables. +

+The collector uses a two level allocator. A large block is defined to +be one larger than half of HBLKSIZE, which is a power of 2, +typically on the order of the page size. +

+Large block sizes are rounded up to +the next multiple of HBLKSIZE and then allocated by +GC_allochblk. Recent versions of the collector +use an approximate best fit algorithm by keeping free lists for +several large block sizes. +The actual +implementation of GC_allochblk +is significantly complicated by black-listing issues +(see below). +

+Small blocks are allocated in chunks of size HBLKSIZE. +Each chunk is +dedicated to only one object size and kind. The allocator maintains +separate free lists for each size and kind of object. +

+Once a large block is split for use in smaller objects, it can only +be used for objects of that size, unless the collector discovers a completely +empty chunk. Completely empty chunks are restored to the appropriate +large block free list. +

+In order to avoid allocating blocks for too many distinct object sizes, +the collector normally does not directly allocate objects of every possible +request size. Instead request are rounded up to one of a smaller number +of allocated sizes, for which free lists are maintained. The exact +allocated sizes are computed on demand, but subject to the constraint +that they increase roughly in geometric progression. Thus objects +requested early in the execution are likely to be allocated with exactly +the requested size, subject to alignment constraints. +See GC_init_size_map for details. +

+The actual size rounding operation during small object allocation is +implemented as a table lookup in GC_size_map. +

+Both collector initialization and computation of allocated sizes are +handled carefully so that they do not slow down the small object fast +allocation path. An attempt to allocate before the collector is initialized, +or before the appropriate GC_size_map entry is computed, +will take the same path as an allocation attempt with an empty free list. +This results in a call to the slow path code (GC_generic_malloc_inner) +which performs the appropriate initialization checks. +

+In non-incremental mode, we make a decision about whether to garbage collect +whenever an allocation would otherwise have failed with the current heap size. +If the total amount of allocation since the last collection is less than +the heap size divided by GC_free_space_divisor, we try to +expand the heap. Otherwise, we initiate a garbage collection. This ensures +that the amount of garbage collection work per allocated byte remains +constant. +

+The above is in fact an oversimplification of the real heap expansion +and GC triggering heuristic, which adjusts slightly for root size +and certain kinds of +fragmentation. In particular: +

    +
  • Programs with a large root set size and +little live heap memory will expand the heap to amortize the cost of +scanning the roots. +
  • Versions 5.x of the collector actually collect more frequently in +nonincremental mode. The large block allocator usually refuses to split +large heap blocks once the garbage collection threshold is +reached. This often has the effect of collecting well before the +heap fills up, thus reducing fragmentation and working set size at the +expense of GC time. Versions 6.x choose an intermediate strategy depending +on how much large object allocation has taken place in the past. +(If the collector is configured to unmap unused pages, versions 6.x +use the 5.x strategy.) +
  • In calculating the amount of allocation since the last collection we +give partial credit for objects we expect to be explicitly deallocated. +Even if all objects are explicitly managed, it is often desirable to collect +on rare occasion, since that is our only mechanism for coalescing completely +empty chunks. +
+

+It has been suggested that this should be adjusted so that we favor +expansion if the resulting heap still fits into physical memory. +In many cases, that would no doubt help. But it is tricky to do this +in a way that remains robust if multiple application are contending +for a single pool of physical memory. + +

Mark phase

+ +At each collection, the collector marks all objects that are +possibly reachable from pointer variables. Since it cannot generally +tell where pointer variables are located, it scans the following +root segments for pointers: +
    +
  • The registers. Depending on the architecture, this may be done using +assembly code, or by calling a setjmp-like function which saves +register contents on the stack. +
  • The stack(s). In the case of a single-threaded application, +on most platforms this +is done by scanning the memory between (an approximation of) the current +stack pointer and GC_stackbottom. (For Itanium, the register stack +scanned separately.) The GC_stackbottom variable is set in +a highly platform-specific way depending on the appropriate configuration +information in gcconfig.h. Note that the currently active +stack needs to be scanned carefully, since callee-save registers of +client code may appear inside collector stack frames, which may +change during the mark process. This is addressed by scanning +some sections of the stack "eagerly", effectively capturing a snapshot +at one point in time. +
  • Static data region(s). In the simplest case, this is the region +between DATASTART and DATAEND, as defined in +gcconfig.h. However, in most cases, this will also involve +static data regions associated with dynamic libraries. These are +identified by the mostly platform-specific code in dyn_load.c. +
+The marker maintains an explicit stack of memory regions that are known +to be accessible, but that have not yet been searched for contained pointers. +Each stack entry contains the starting address of the block to be scanned, +as well as a descriptor of the block. If no layout information is +available for the block, then the descriptor is simply a length. +(For other possibilities, see gc_mark.h.) +

+At the beginning of the mark phase, all root segments +(as described above) are pushed on the +stack by GC_push_roots. (Registers and eagerly processed +stack sections are processed by pushing the referenced objects instead +of the stack section itself.) If ALL_INTERIOR_PTRS is not +defined, then stack roots require special treatment. In this case, the +normal marking code ignores interior pointers, but GC_push_all_stack +explicitly checks for interior pointers and pushes descriptors for target +objects. +

+The marker is structured to allow incremental marking. +Each call to GC_mark_some performs a small amount of +work towards marking the heap. +It maintains +explicit state in the form of GC_mark_state, which +identifies a particular sub-phase. Some other pieces of state, most +notably the mark stack, identify how much work remains to be done +in each sub-phase. The normal progression of mark states for +a stop-the-world collection is: +

    +
  1. MS_INVALID indicating that there may be accessible unmarked +objects. In this case GC_objects_are_marked will simultaneously +be false, so the mark state is advanced to +
  2. MS_PUSH_UNCOLLECTABLE indicating that it suffices to push +uncollectable objects, roots, and then mark everything reachable from them. +Scan_ptr is advanced through the heap until all uncollectable +objects are pushed, and objects reachable from them are marked. +At that point, the next call to GC_mark_some calls +GC_push_roots to push the roots. It the advances the +mark state to +
  3. MS_ROOTS_PUSHED asserting that once the mark stack is +empty, all reachable objects are marked. Once in this state, we work +only on emptying the mark stack. Once this is completed, the state +changes to +
  4. MS_NONE indicating that reachable objects are marked. +
+ +The core mark routine GC_mark_from, is called +repeatedly by several of the sub-phases when the mark stack starts to fill +up. It is also called repeatedly in MS_ROOTS_PUSHED state +to empty the mark stack. +The routine is designed to only perform a limited amount of marking at +each call, so that it can also be used by the incremental collector. +It is fairly carefully tuned, since it usually consumes a large majority +of the garbage collection time. +

+The fact that it perform a only a small amount of work per call also +allows it to be used as the core routine of the parallel marker. In that +case it is normally invoked on thread-private mark stacks instead of the +global mark stack. More details can be found in +scale.html +

+The marker correctly handles mark stack overflows. Whenever the mark stack +overflows, the mark state is reset to MS_INVALID. +Since there are already marked objects in the heap, +this eventually forces a complete +scan of the heap, searching for pointers, during which any unmarked objects +referenced by marked objects are again pushed on the mark stack. This +process is repeated until the mark phase completes without a stack overflow. +Each time the stack overflows, an attempt is made to grow the mark stack. +All pieces of the collector that push regions onto the mark stack have to be +careful to ensure forward progress, even in case of repeated mark stack +overflows. Every mark attempt results in additional marked objects. +

+Each mark stack entry is processed by examining all candidate pointers +in the range described by the entry. If the region has no associated +type information, then this typically requires that each 4-byte aligned +quantity (8-byte aligned with 64-bit pointers) be considered a candidate +pointer. +

+We determine whether a candidate pointer is actually the address of +a heap block. This is done in the following steps: + +

  • The candidate pointer is checked against rough heap bounds. +These heap bounds are maintained such that all actual heap objects +fall between them. In order to facilitate black-listing (see below) +we also include address regions that the heap is likely to expand into. +Most non-pointers fail this initial test. +
  • The candidate pointer is divided into two pieces; the most significant +bits identify a HBLKSIZE-sized page in the address space, and +the least significant bits specify an offset within that page. +(A hardware page may actually consist of multiple such pages. +HBLKSIZE is usually the page size divided by a small power of two.) +
  • +The page address part of the candidate pointer is looked up in a +table. +Each table entry contains either 0, indicating that the page is not part +of the garbage collected heap, a small integer n, indicating +that the page is part of large object, starting at least n pages +back, or a pointer to a descriptor for the page. In the first case, +the candidate pointer i not a true pointer and can be safely ignored. +In the last two cases, we can obtain a descriptor for the page containing +the beginning of the object. +
  • +The starting address of the referenced object is computed. +The page descriptor contains the size of the object(s) +in that page, the object kind, and the necessary mark bits for those +objects. The size information can be used to map the candidate pointer +to the object starting address. To accelerate this process, the page header +also contains a pointer to a precomputed map of page offsets to displacements +from the beginning of an object. The use of this map avoids a +potentially slow integer remainder operation in computing the object +start address. +
  • +The mark bit for the target object is checked and set. If the object +was previously unmarked, the object is pushed on the mark stack. +The descriptor is read from the page descriptor. (This is computed +from information GC_obj_kinds when the page is first allocated.) + +

    +At the end of the mark phase, mark bits for left-over free lists are cleared, +in case a free list was accidentally marked due to a stray pointer. + +

    Sweep phase

    + +At the end of the mark phase, all blocks in the heap are examined. +Unmarked large objects are immediately returned to the large object free list. +Each small object page is checked to see if all mark bits are clear. +If so, the entire page is returned to the large object free list. +Small object pages containing some reachable object are queued for later +sweeping, unless we determine that the page contains very little free +space, in which case it is not examined further. +

    +This initial sweep pass touches only block headers, not +the blocks themselves. Thus it does not require significant paging, even +if large sections of the heap are not in physical memory. +

    +Nonempty small object pages are swept when an allocation attempt +encounters an empty free list for that object size and kind. +Pages for the correct size and kind are repeatedly swept until at +least one empty block is found. Sweeping such a page involves +scanning the mark bit array in the page header, and building a free +list linked through the first words in the objects themselves. +This does involve touching the appropriate data page, but in most cases +it will be touched only just before it is used for allocation. +Hence any paging is essentially unavoidable. +

    +Except in the case of pointer-free objects, we maintain the invariant +that any object in a small object free list is cleared (except possibly +for the link field). Thus it becomes the burden of the small object +sweep routine to clear objects. This has the advantage that we can +easily recover from accidentally marking a free list, though that could +also be handled by other means. The collector currently spends a fair +amount of time clearing objects, and this approach should probably be +revisited. +

    +In most configurations, we use specialized sweep routines to handle common +small object sizes. Since we allocate one mark bit per word, it becomes +easier to examine the relevant mark bits if the object size divides +the word length evenly. We also suitably unroll the inner sweep loop +in each case. (It is conceivable that profile-based procedure cloning +in the compiler could make this unnecessary and counterproductive. I +know of no existing compiler to which this applies.) +

    +The sweeping of small object pages could be avoided completely at the expense +of examining mark bits directly in the allocator. This would probably +be more expensive, since each allocation call would have to reload +a large amount of state (e.g. next object address to be swept, position +in mark bit table) before it could do its work. The current scheme +keeps the allocator simple and allows useful optimizations in the sweeper. + +

    Finalization

    +Both GC_register_disappearing_link and +GC_register_finalizer add the request to a corresponding hash +table. The hash table is allocated out of collected memory, but +the reference to the finalizable object is hidden from the collector. +Currently finalization requests are processed non-incrementally at the +end of a mark cycle. +

    +The collector makes an initial pass over the table of finalizable objects, +pushing the contents of unmarked objects onto the mark stack. +After pushing each object, the marker is invoked to mark all objects +reachable from it. The object itself is not explicitly marked. +This assures that objects on which a finalizer depends are neither +collected nor finalized. +

    +If in the process of marking from an object the +object itself becomes marked, we have uncovered +a cycle involving the object. This usually results in a warning from the +collector. Such objects are not finalized, since it may be +unsafe to do so. See the more detailed + discussion of finalization semantics. +

    +Any objects remaining unmarked at the end of this process are added to +a queue of objects whose finalizers can be run. Depending on collector +configuration, finalizers are dequeued and run either implicitly during +allocation calls, or explicitly in response to a user request. +(Note that the former is unfortunately both the default and not generally safe. +If finalizers perform synchronization, it may result in deadlocks. +Nontrivial finalizers generally need to perform synchronization, and +thus require a different collector configuration.) +

    +The collector provides a mechanism for replacing the procedure that is +used to mark through objects. This is used both to provide support for +Java-style unordered finalization, and to ignore certain kinds of cycles, +e.g. those arising from C++ implementations of virtual inheritance. + +

    Generational Collection and Dirty Bits

    +We basically use the concurrent and generational GC algorithm described in +"Mostly Parallel Garbage Collection", +by Boehm, Demers, and Shenker. +

    +The most significant modification is that +the collector always starts running in the allocating thread. +There is no separate garbage collector thread. (If parallel GC is +enabled, helper threads may also be woken up.) +If an allocation attempt either requests a large object, or encounters +an empty small object free list, and notices that there is a collection +in progress, it immediately performs a small amount of marking work +as described above. +

    +This change was made both because we wanted to easily accommodate +single-threaded environments, and because a separate GC thread requires +very careful control over the scheduler to prevent the mutator from +out-running the collector, and hence provoking unneeded heap growth. +

    +In incremental mode, the heap is always expanded when we encounter +insufficient space for an allocation. Garbage collection is triggered +whenever we notice that more than +GC_heap_size/2 * GC_free_space_divisor +bytes of allocation have taken place. +After GC_full_freq minor collections a major collection +is started. +

    +All collections initially run interrupted until a predetermined +amount of time (50 msecs by default) has expired. If this allows +the collection to complete entirely, we can avoid correcting +for data structure modifications during the collection. If it does +not complete, we return control to the mutator, and perform small +amounts of additional GC work during those later allocations that +cannot be satisfied from small object free lists. When marking completes, +the set of modified pages is retrieved, and we mark once again from +marked objects on those pages, this time with the mutator stopped. +

    +We keep track of modified pages using one of several distinct mechanisms: +

      +
    1. +Through explicit mutator cooperation. Currently this requires +the use of GC_malloc_stubborn, and is rarely used. +
    2. +(MPROTECT_VDB) By write-protecting physical pages and +catching write faults. This is +implemented for many Unix-like systems and for win32. It is not possible +in a few environments. +
    3. +(PROC_VDB) By retrieving dirty bit information from /proc. +(Currently only Sun's +Solaris supports this. Though this is considerably cleaner, performance +may actually be better with mprotect and signals.) +
    4. +(PCR_VDB) By relying on an external dirty bit implementation, in this +case the one in Xerox PCR. +
    5. +(DEFAULT_VDB) By treating all pages as dirty. This is the default if +none of the other techniques is known to be usable, and +GC_malloc_stubborn is not used. Practical only for testing, or if +the vast majority of objects use GC_malloc_stubborn. +
    + +

    Black-listing

    + +The collector implements black-listing of pages, as described +in + +Boehm, ``Space Efficient Conservative Collection'', PLDI '93, also available +here. +

    +During the mark phase, the collector tracks ``near misses'', i.e. attempts +to follow a ``pointer'' to just outside the garbage-collected heap, or +to a currently unallocated page inside the heap. Pages that have been +the targets of such near misses are likely to be the targets of +misidentified ``pointers'' in the future. To minimize the future +damage caused by such misidentifications they will be allocated only to +small pointerfree objects. +

    +The collector understands two different kinds of black-listing. A +page may be black listed for interior pointer references +(GC_add_to_black_list_stack), if it was the target of a near +miss from a location that requires interior pointer recognition, +e.g. the stack, or the heap if GC_all_interior_pointers +is set. In this case, we also avoid allocating large blocks that include +this page. +

    +If the near miss came from a source that did not require interior +pointer recognition, it is black-listed with +GC_add_to_black_list_normal. +A page black-listed in this way may appear inside a large object, +so long as it is not the first page of a large object. +

    +The GC_allochblk routine respects black-listing when assigning +a block to a particular object kind and size. It occasionally +drops (i.e. allocates and forgets) blocks that are completely black-listed +in order to avoid excessively long large block free lists containing +only unusable blocks. This would otherwise become an issue +if there is low demand for small pointerfree objects. + +

    Thread support

    +We support several different threading models. Unfortunately Pthreads, +the only reasonably well standardized thread model, supports too narrow +an interface for conservative garbage collection. There appears to be +no completely portable way to allow the collector +to coexist with various Pthreads +implementations. Hence we currently support only the more +common Pthreads implementations. +

    +In particular, it is very difficult for the collector to stop all other +threads in the system and examine the register contents. This is currently +accomplished with very different mechanisms for some Pthreads +implementations. The Solaris implementation temporarily disables much +of the user-level threads implementation by stopping kernel-level threads +("lwp"s). The Linux/HPUX/OSF1 and Irix implementations sends signals to +individual Pthreads and has them wait in the signal handler. +

    +The Linux and Irix implementations use +only documented Pthreads calls, but rely on extensions to their semantics. +The Linux implementation linux_threads.c relies on only very +mild extensions to the pthreads semantics, and already supports a large number +of other Unix-like pthreads implementations. Our goal is to make this the +only pthread support in the collector. +

    +(The Irix implementation is separate only for historical reasons and should +clearly be merged. The current Solaris implementation probably performs +better in the uniprocessor case, but does not support thread operations in the +collector. Hence it cannot support the parallel marker.) +

    +All implementations must +intercept thread creation and a few other thread-specific calls to allow +enumeration of threads and location of thread stacks. This is current +accomplished with # define's in gc.h +(really gc_pthread_redirects.h), or optionally +by using ld's function call wrapping mechanism under Linux. +

    +Recent versions of the collector support several facilites to enhance +the processor-scalability and thread performance of the collector. +These are discussed in more detail here. +

    +Comments are appreciated. Please send mail to +boehm@acm.org or +Hans.Boehm@hp.com +

    +This is a modified copy of a page written while the author was at SGI. +The original was here. + + diff --git a/boehm-gc/doc/gcinterface.html b/boehm-gc/doc/gcinterface.html new file mode 100644 index 000000000..1716514be --- /dev/null +++ b/boehm-gc/doc/gcinterface.html @@ -0,0 +1,248 @@ + + +Garbage Collector Interface + + +

    C Interface

    +On many platforms, a single-threaded garbage collector library can be built +to act as a plug-in malloc replacement. +(Build with -DREDIRECT_MALLOC=GC_malloc -DIGNORE_FREE.) +This is often the best way to deal with third-party libraries +which leak or prematurely free objects. -DREDIRECT_MALLOC is intended +primarily as an easy way to adapt old code, not for new development. +

    +New code should use the interface discussed below. +

    +Code must be linked against the GC library. On most UNIX platforms, +depending on how the collector is built, this will be gc.a +or libgc.{a,so}. +

    +The following describes the standard C interface to the garbage collector. +It is not a complete definition of the interface. It describes only the +most commonly used functionality, approximately in decreasing order of +frequency of use. +The full interface is described in +gc.h +or gc.h in the distribution. +

    +Clients should include gc.h. +

    +In the case of multithreaded code, +gc.h should be included after the threads header file, and +after defining the appropriate GC_XXXX_THREADS macro. +(For 6.2alpha4 and later, simply defining GC_THREADS should suffice.) +The header file gc.h must be included +in files that use either GC or threads primitives, since threads primitives +will be redefined to cooperate with the GC on many platforms. +

    +
    void * GC_MALLOC(size_t nbytes) +
    +Allocates and clears nbytes of storage. +Requires (amortized) time proportional to nbytes. +The resulting object will be automatically deallocated when unreferenced. +References from objects allocated with the system malloc are usually not +considered by the collector. (See GC_MALLOC_UNCOLLECTABLE, however.) +GC_MALLOC is a macro which invokes GC_malloc by default or, +if GC_DEBUG +is defined before gc.h is included, a debugging version that checks +occasionally for overwrite errors, and the like. +
    void * GC_MALLOC_ATOMIC(size_t nbytes) +
    +Allocates nbytes of storage. +Requires (amortized) time proportional to nbytes. +The resulting object will be automatically deallocated when unreferenced. +The client promises that the resulting object will never contain any pointers. +The memory is not cleared. +This is the preferred way to allocate strings, floating point arrays, +bitmaps, etc. +More precise information about pointer locations can be communicated to the +collector using the interface in +gc_typed.h in the distribution. +
    void * GC_MALLOC_UNCOLLECTABLE(size_t nbytes) +
    +Identical to GC_MALLOC, +except that the resulting object is not automatically +deallocated. Unlike the system-provided malloc, the collector does +scan the object for pointers to garbage-collectable memory, even if the +block itself does not appear to be reachable. (Objects allocated in this way +are effectively treated as roots by the collector.) +
    void * GC_REALLOC(void *old, size_t new_size) +
    +Allocate a new object of the indicated size and copy (a prefix of) the +old object into the new object. The old object is reused in place if +convenient. If the original object was allocated with +GC_MALLOC_ATOMIC, +the new object is subject to the same constraints. If it was allocated +as an uncollectable object, then the new object is uncollectable, and +the old object (if different) is deallocated. +
    void GC_FREE(void *dead) +
    +Explicitly deallocate an object. Typically not useful for small +collectable objects. +
    void * GC_MALLOC_IGNORE_OFF_PAGE(size_t nbytes) +
    +
    void * GC_MALLOC_ATOMIC_IGNORE_OFF_PAGE(size_t nbytes) +
    +Analogous to GC_MALLOC and GC_MALLOC_ATOMIC, +except that the client +guarantees that as long +as the resulting object is of use, a pointer is maintained to someplace +inside the first 512 bytes of the object. This pointer should be declared +volatile to avoid interference from compiler optimizations. +(Other nonvolatile pointers to the object may exist as well.) +This is the +preferred way to allocate objects that are likely to be > 100KBytes in size. +It greatly reduces the risk that such objects will be accidentally retained +when they are no longer needed. Thus space usage may be significantly reduced. +
    void GC_INIT(void) +
    +On some platforms, it is necessary to invoke this +from the main executable, not from a dynamic library, before +the initial invocation of a GC routine. It is recommended that this be done +in portable code, though we try to ensure that it expands to a no-op +on as many platforms as possible. +
    void GC_gcollect(void) +
    +Explicitly force a garbage collection. +
    void GC_enable_incremental(void) +
    +Cause the garbage collector to perform a small amount of work +every few invocations of GC_MALLOC or the like, instead of performing +an entire collection at once. This is likely to increase total +running time. It will improve response on a platform that either has +suitable support in the garbage collector (Linux and most Unix +versions, win32 if the collector was suitably built) or if "stubborn" +allocation is used (see +gc.h). +On many platforms this interacts poorly with system calls +that write to the garbage collected heap. +
    GC_warn_proc GC_set_warn_proc(GC_warn_proc p) +
    +Replace the default procedure used by the collector to print warnings. +The collector +may otherwise write to sterr, most commonly because GC_malloc was used +in a situation in which GC_malloc_ignore_off_page would have been more +appropriate. See gc.h for details. +
    void GC_REGISTER_FINALIZER(...) +
    +Register a function to be called when an object becomes inaccessible. +This is often useful as a backup method for releasing system resources +(e.g. closing files) when the object referencing them becomes +inaccessible. +It is not an acceptable method to perform actions that must be performed +in a timely fashion. +See gc.h for details of the interface. +See here for a more detailed discussion +of the design. +

    +Note that an object may become inaccessible before client code is done +operating on objects referenced by its fields. +Suitable synchronization is usually required. +See here +or here +for details. +

    +

    +If you are concerned with multiprocessor performance and scalability, +you should consider enabling and using thread local allocation (e.g. +GC_LOCAL_MALLOC, see gc_local_alloc.h. If your platform +supports it, you should build the collector with parallel marking support +(-DPARALLEL_MARK, or --enable-parallel-mark). +

    +If the collector is used in an environment in which pointer location +information for heap objects is easily available, this can be passed on +to the collector using the interfaces in either gc_typed.h +or gc_gcj.h. +

    +The collector distribution also includes a string package that takes +advantage of the collector. For details see +cord.h + +

    C++ Interface

    +Usage of the collector from C++ is complicated by the fact that there +are many "standard" ways to allocate memory in C++. The default ::new +operator, default malloc, and default STL allocators allocate memory +that is not garbage collected, and is not normally "traced" by the +collector. This means that any pointers in memory allocated by these +default allocators will not be seen by the collector. Garbage-collectable +memory referenced only by pointers stored in such default-allocated +objects is likely to be reclaimed prematurely by the collector. +

    +It is the programmers responsibility to ensure that garbage-collectable +memory is referenced by pointers stored in one of +

      +
    • Program variables +
    • Garbage-collected objects +
    • Uncollected but "traceable" objects +
    +"Traceable" objects are not necessarily reclaimed by the collector, +but are scanned for pointers to collectable objects. +They are allocated by GC_MALLOC_UNCOLLECTABLE, as described +above, and through some interfaces described below. +

    +The easiest way to ensure that collectable objects are properly referenced +is to allocate only collectable objects. This requires that every +allocation go through one of the following interfaces, each one of +which replaces a standard C++ allocation mechanism: +

    +
    STL allocators +
    +Users of the SGI extended STL +can include new_gc_alloc.h before including +STL header files. +(gc_alloc.h corresponds to now obsolete versions of the +SGI STL.) +This defines SGI-style allocators +
      +
    • alloc +
    • single_client_alloc +
    • gc_alloc +
    • single_client_gc_alloc +
    +which may be used either directly to allocate memory or to instantiate +container templates. The first two allocate uncollectable but traced +memory, while the second two allocate collectable memory. +The single_client versions are not safe for concurrent access by +multiple threads, but are faster. +

    +For an example, click here. +

    +Recent versions of the collector also include a more standard-conforming +allocator implementation in gc_allocator.h. It defines +

      +
    • traceable_allocator +
    • gc_allocator +
    +Again the former allocates uncollectable but traced memory. +This should work with any fully standard-conforming C++ compiler. +
    Class inheritance based interface +
    +Users may include gc_cpp.h and then cause members of classes to +be allocated in garbage collectable memory by having those classes +inherit from class gc. +For details see gc_cpp.h. +

    +Linking against libgccpp in addition to the gc library overrides +::new (and friends) to allocate traceable memory but uncollectable +memory, making it safe to refer to collectable objects from the resulting +memory. +

    C interface +
    +It is also possible to use the C interface from +gc.h directly. +On platforms which use malloc to implement ::new, it should usually be possible +to use a version of the collector that has been compiled as a malloc +replacement. It is also possible to replace ::new and other allocation +functions suitably, as is done by libgccpp. +

    +Note that user-implemented small-block allocation often works poorly with +an underlying garbage-collected large block allocator, since the collector +has to view all objects accessible from the user's free list as reachable. +This is likely to cause problems if GC_MALLOC +is used with something like +the original HP version of STL. +This approach works well with the SGI versions of the STL only if the +malloc_alloc allocator is used. +

    + + diff --git a/boehm-gc/doc/leak.html b/boehm-gc/doc/leak.html new file mode 100644 index 000000000..91fa8ea84 --- /dev/null +++ b/boehm-gc/doc/leak.html @@ -0,0 +1,197 @@ + + +Using the Garbage Collector as Leak Detector + + +

    Using the Garbage Collector as Leak Detector

    +The garbage collector may be used as a leak detector. +In this case, the primary function of the collector is to report +objects that were allocated (typically with GC_MALLOC), +not deallocated (normally with GC_FREE), but are +no longer accessible. Since the object is no longer accessible, +there in normally no way to deallocate the object at a later time; +thus it can safely be assumed that the object has been "leaked". +

    +This is substantially different from counting leak detectors, +which simply verify that all allocated objects are eventually +deallocated. A garbage-collector based leak detector can provide +somewhat more precise information when an object was leaked. +More importantly, it does not report objects that are never +deallocated because they are part of "permanent" data structures. +Thus it does not require all objects to be deallocated at process +exit time, a potentially useless activity that often triggers +large amounts of paging. +

    +All non-ancient versions of the garbage collector provide +leak detection support. Version 5.3 adds the following +features: +

      +
    1. Leak detection mode can be initiated at run-time by +setting GC_find_leak instead of building the collector with FIND_LEAK +defined. This variable should be set to a nonzero value +at program startup. +
    2. Leaked objects should be reported and then correctly garbage collected. +Prior versions either reported leaks or functioned as a garbage collector. +
    +For the rest of this description we will give instructions that work +with any reasonable version of the collector. +

    +To use the collector as a leak detector, follow the following steps: +

      +
    1. Build the collector with -DFIND_LEAK. Otherwise use default +build options. +
    2. Change the program so that all allocation and deallocation goes +through the garbage collector. +
    3. Arrange to call GC_gcollect at appropriate points to check +for leaks. +(For sufficiently long running programs, this will happen implicitly, +but probably not with sufficient frequency.) +
    +The second step can usually be accomplished with the +-DREDIRECT_MALLOC=GC_malloc option when the collector is built, +or by defining malloc, calloc, +realloc and free +to call the corresponding garbage collector functions. +But this, by itself, will not yield very informative diagnostics, +since the collector does not keep track of information about +how objects were allocated. The error reports will include +only object addresses. +

    +For more precise error reports, as much of the program as possible +should use the all uppercase variants of these functions, after +defining GC_DEBUG, and then including gc.h. +In this environment GC_MALLOC is a macro which causes +at least the file name and line number at the allocation point to +be saved as part of the object. Leak reports will then also include +this information. +

    +Many collector features (e.g stubborn objects, finalization, +and disappearing links) are less useful in this context, and are not +fully supported. Their use will usually generate additional bogus +leak reports, since the collector itself drops some associated objects. +

    +The same is generally true of thread support. However, as of 6.0alpha4, +correct leak reports should be generated with linuxthreads. +

    +On a few platforms (currently Solaris/SPARC, Irix, and, with -DSAVE_CALL_CHAIN, +Linux/X86), GC_MALLOC +also causes some more information about its call stack to be saved +in the object. Such information is reproduced in the error +reports in very non-symbolic form, but it can be very useful with the +aid of a debugger. +

    An Example

    +The following header file leak_detector.h is included in the +"include" subdirectory of the distribution: +
    +#define GC_DEBUG
    +#include "gc.h"
    +#define malloc(n) GC_MALLOC(n)
    +#define calloc(m,n) GC_MALLOC((m)*(n))
    +#define free(p) GC_FREE(p)
    +#define realloc(p,n) GC_REALLOC((p),(n))
    +#define CHECK_LEAKS() GC_gcollect()
    +
    +

    +Assume the collector has been built with -DFIND_LEAK. (For very +new versions of the collector, we could instead add the statement +GC_find_leak = 1 as the first statement in main. +

    +The program to be tested for leaks can then look like: +

    +#include "leak_detector.h"
    +
    +main() {
    +    int *p[10];
    +    int i;
    +    /* GC_find_leak = 1; for new collector versions not 	*/
    +    /* compiled with -DFIND_LEAK.				*/
    +    for (i = 0; i < 10; ++i) {
    +	p[i] = malloc(sizeof(int)+i);
    +    }
    +    for (i = 1; i < 10; ++i) {
    +	free(p[i]);
    +    }
    +    for (i = 0; i < 9; ++i) {
    +	p[i] = malloc(sizeof(int)+i);
    +    }
    +    CHECK_LEAKS();
    +}	
    +
    +

    +On an Intel X86 Linux system this produces on the stderr stream: +

    +Leaked composite object at 0x806dff0 (leak_test.c:8, sz=4)
    +
    +(On most unmentioned operating systems, the output is similar to this. +If the collector had been built on Linux/X86 with -DSAVE_CALL_CHAIN, +the output would be closer to the Solaris example. For this to work, +the program should not be compiled with -fomit_frame_pointer.) +

    +On Irix it reports +

    +Leaked composite object at 0x10040fe0 (leak_test.c:8, sz=4)
    +        Caller at allocation:
    +                ##PC##= 0x10004910
    +
    +and on Solaris the error report is +
    +Leaked composite object at 0xef621fc8 (leak_test.c:8, sz=4)
    +        Call chain at allocation:
    +                args: 4 (0x4), 200656 (0x30FD0)
    +                ##PC##= 0x14ADC
    +                args: 1 (0x1), -268436012 (0xEFFFFDD4)
    +                ##PC##= 0x14A64
    +
    +In the latter two cases some additional information is given about +how malloc was called when the leaked object was allocated. For +Solaris, the first line specifies the arguments to GC_debug_malloc +(the actual allocation routine), The second the program counter inside +main, the third the arguments to main, and finally the program +counter inside the caller to main (i.e. in the C startup code). +

    +In the Irix case, only the address inside the caller to main is given. +

    +In many cases, a debugger is needed to interpret the additional information. +On systems supporting the "adb" debugger, the callprocs script +can be used to replace program counter values with symbolic names. +As of version 6.1, the collector tries to generate symbolic names for +call stacks if it knows how to do so on the platform. This is true on +Linux/X86, but not on most other platforms. +

    Simplified leak detection under Linux

    +Since version 6.1, it should be possible to run the collector in leak +detection mode on a program a.out under Linux/X86 as follows: +
      +
    1. Ensure that a.out is a single-threaded executable. This doesn't yet work +for multithreaded programs. +
    2. If possible, ensure that the addr2line program is installed in +/usr/bin. (It comes with RedHat Linux.) +
    3. If possible, compile a.out with full debug information. +This will improve the quality of the leak reports. With this approach, it is +no longer necessary to call GC_ routines explicitly, though that can also +improve the quality of the leak reports. +
    4. Build the collector and install it in directory foo as follows: +
        +
      • configure --prefix=foo --enable-full-debug --enable-redirect-malloc +--disable-threads +
      • make +
      • make install +
      +
    5. Set environment variables as follows: +
        +
      • LD_PRELOAD=foo/lib/libgc.so +
      • GC_FIND_LEAK +
      • You may also want to set GC_PRINT_STATS (to confirm that the collector +is running) and/or GC_LOOP_ON_ABORT (to facilitate debugging from another +window if something goes wrong). +
      Simply run a.out as you normally would. Note that if you run anything +else (e.g. your editor) with those environment variables set, +it will also be leak tested. This may or may not be useful and/or +embarrassing. It can generate +mountains of leak reports if the application wasn't designed to avoid leaks, +e.g. because it's always short-lived. +
    +This has not yet been thropughly tested on large applications, but it's known +to do the right thing on at least some small ones. + + diff --git a/boehm-gc/doc/scale.html b/boehm-gc/doc/scale.html new file mode 100644 index 000000000..2e70148df --- /dev/null +++ b/boehm-gc/doc/scale.html @@ -0,0 +1,210 @@ + + +Garbage collector scalability + + +

    Garbage collector scalability

    +In its default configuration, the Boehm-Demers-Weiser garbage collector +is not thread-safe. It can be made thread-safe for a number of environments +by building the collector with the appropriate +-DXXX-THREADS compilation +flag. This has primarily two effects: +
      +
    1. It causes the garbage collector to stop all other threads when +it needs to see a consistent memory state. +
    2. It causes the collector to acquire a lock around essentially all +allocation and garbage collection activity. +
    +Since a single lock is used for all allocation-related activity, only one +thread can be allocating or collecting at one point. This inherently +limits performance of multi-threaded applications on multiprocessors. +

    +On most platforms, the allocator/collector lock is implemented as a +spin lock with exponential back-off. Longer wait times are implemented +by yielding and/or sleeping. If a collection is in progress, the pure +spinning stage is skipped. This has the advantage that uncontested and +thus most uniprocessor lock acquisitions are very cheap. It has the +disadvantage that the application may sleep for small periods of time +even when there is work to be done. And threads may be unnecessarily +woken up for short periods. Nonetheless, this scheme empirically +outperforms native queue-based mutual exclusion implementations in most +cases, sometimes drastically so. +

    Options for enhanced scalability

    +Version 6.0 of the collector adds two facilities to enhance collector +scalability on multiprocessors. As of 6.0alpha1, these are supported +only under Linux on X86 and IA64 processors, though ports to other +otherwise supported Pthreads platforms should be straightforward. +They are intended to be used together. +
      +
    • +Building the collector with -DPARALLEL_MARK allows the collector to +run the mark phase in parallel in multiple threads, and thus on multiple +processors. The mark phase typically consumes the large majority of the +collection time. Thus this largely parallelizes the garbage collector +itself, though not the allocation process. Currently the marking is +performed by the thread that triggered the collection, together with +N-1 dedicated +threads, where N is the number of processors detected by the collector. +The dedicated threads are created once at initialization time. +

      +A second effect of this flag is to switch to a more concurrent +implementation of GC_malloc_many, so that free lists can be +built, and memory can be cleared, by more than one thread concurrently. +

    • +Building the collector with -DTHREAD_LOCAL_ALLOC adds support for thread +local allocation. It does not, by itself, cause thread local allocation +to be used. It simply allows the use of the interface in +gc_local_alloc.h. +

      +Memory returned from thread-local allocators is completely interchangeable +with that returned by the standard allocators. It may be used by other +threads. The only difference is that, if the thread allocates enough +memory of a certain kind, it will build a thread-local free list for +objects of that kind, and allocate from that. This greatly reduces +locking. The thread-local free lists are refilled using +GC_malloc_many. +

      +An important side effect of this flag is to replace the default +spin-then-sleep lock to be replace by a spin-then-queue based implementation. +This reduces performance for the standard allocation functions, +though it usually improves performance when thread-local allocation is +used heavily, and thus the number of short-duration lock acquisitions +is greatly reduced. +

    +

    +The easiest way to switch an application to thread-local allocation is to +

      +
    1. Define the macro GC_REDIRECT_TO_LOCAL, +and then include the gc.h +header in each client source file. +
    2. Invoke GC_thr_init() before any allocation. +
    3. Allocate using GC_MALLOC, GC_MALLOC_ATOMIC, +and/or GC_GCJ_MALLOC. +
    +

    The Parallel Marking Algorithm

    +We use an algorithm similar to +that developed by +Endo, Taura, and Yonezawa at the University of Tokyo. +However, the data structures and implementation are different, +and represent a smaller change to the original collector source, +probably at the expense of extreme scalability. Some of +the refinements they suggest, e.g. splitting large +objects, were also incorporated into out approach. +

    +The global mark stack is transformed into a global work queue. +Unlike the usual case, it never shrinks during a mark phase. +The mark threads remove objects from the queue by copying them to a +local mark stack and changing the global descriptor to zero, indicating +that there is no more work to be done for this entry. +This removal +is done with no synchronization. Thus it is possible for more than +one worker to remove the same entry, resulting in some work duplication. +

    +The global work queue grows only if a marker thread decides to +return some of its local mark stack to the global one. This +is done if the global queue appears to be running low, or if +the local stack is in danger of overflowing. It does require +synchronization, but should be relatively rare. +

    +The sequential marking code is reused to process local mark stacks. +Hence the amount of additional code required for parallel marking +is minimal. +

    +It should be possible to use generational collection in the presence of the +parallel collector, by calling GC_enable_incremental(). +This does not result in fully incremental collection, since parallel mark +phases cannot currently be interrupted, and doing so may be too +expensive. +

    +Gcj-style mark descriptors do not currently mix with the combination +of local allocation and incremental collection. They should work correctly +with one or the other, but not both. +

    +The number of marker threads is set on startup to the number of +available processors (or to the value of the GC_NPROCS +environment variable). If only a single processor is detected, +parallel marking is disabled. +

    +Note that setting GC_NPROCS to 1 also causes some lock acquisitions inside +the collector to immediately yield the processor instead of busy waiting +first. In the case of a multiprocessor and a client with multiple +simultaneously runnable threads, this may have disastrous performance +consequences (e.g. a factor of 10 slowdown). +

    Performance

    +We conducted some simple experiments with a version of +our GC benchmark that was slightly modified to +run multiple concurrent client threads in the same address space. +Each client thread does the same work as the original benchmark, but they share +a heap. +This benchmark involves very little work outside of memory allocation. +This was run with GC 6.0alpha3 on a dual processor Pentium III/500 machine +under Linux 2.2.12. +

    +Running with a thread-unsafe collector, the benchmark ran in 9 +seconds. With the simple thread-safe collector, +built with -DLINUX_THREADS, the execution time +increased to 10.3 seconds, or 23.5 elapsed seconds with two clients. +(The times for the malloc/ifree version +with glibc malloc +are 10.51 (standard library, pthreads not linked), +20.90 (one thread, pthreads linked), +and 24.55 seconds respectively. The benchmark favors a +garbage collector, since most objects are small.) +

    +The following table gives execution times for the collector built +with parallel marking and thread-local allocation support +(-DGC_LINUX_THREADS -DPARALLEL_MARK -DTHREAD_LOCAL_ALLOC). We tested +the client using either one or two marker threads, and running +one or two client threads. Note that the client uses thread local +allocation exclusively. With -DTHREAD_LOCAL_ALLOC the collector +switches to a locking strategy that is better tuned to less frequent +lock acquisition. The standard allocation primitives thus peform +slightly worse than without -DTHREAD_LOCAL_ALLOC, and should be +avoided in time-critical code. +

    +(The results using pthread_mutex_lock +directly for allocation locking would have been worse still, at +least for older versions of linuxthreads. +With THREAD_LOCAL_ALLOC, we first repeatedly try to acquire the +lock with pthread_mutex_try_lock(), busy_waiting between attempts. +After a fixed number of attempts, we use pthread_mutex_lock().) +

    +These measurements do not use incremental collection, nor was prefetching +enabled in the marker. We used the C version of the benchmark. +All measurements are in elapsed seconds on an unloaded machine. +

    + + + + + +
    Number of threads1 marker thread (secs.)2 marker threads (secs.)
    1 client10.457.85
    2 clients19.9512.3
    + +The execution time for the single threaded case is slightly worse than with +simple locking. However, even the single-threaded benchmark runs faster than +even the thread-unsafe version if a second processor is available. +The execution time for two clients with thread local allocation time is +only 1.4 times the sequential execution time for a single thread in a +thread-unsafe environment, even though it involves twice the client work. +That represents close to a +factor of 2 improvement over the 2 client case with the old collector. +The old collector clearly +still suffered from some contention overhead, in spite of the fact that the +locking scheme had been fairly well tuned. +

    +Full linear speedup (i.e. the same execution time for 1 client on one +processor as 2 clients on 2 processors) +is probably not achievable on this kind of +hardware even with such a small number of processors, +since the memory system is +a major constraint for the garbage collector, +the processors usually share a single memory bus, and thus +the aggregate memory bandwidth does not increase in +proportion to the number of processors. +

    +These results are likely to be very sensitive to both hardware and OS +issues. Preliminary experiments with an older Pentium Pro machine running +an older kernel were far less encouraging. + + + diff --git a/boehm-gc/doc/simple_example.html b/boehm-gc/doc/simple_example.html new file mode 100644 index 000000000..0bc0953ef --- /dev/null +++ b/boehm-gc/doc/simple_example.html @@ -0,0 +1,202 @@ + + +Using the Garbage Collector: A simple example + + +

    Using the Garbage Collector: A simple example

    +The following consists of step-by-step instructions for building and +using the collector. We'll assume a Linux/gcc platform and +a single-threaded application. The green +text contains information about other platforms or scenarios. +It can be skipped, especially on first reading. +

    Building the collector

    +If you haven't already so, unpack the collector and enter +the newly created directory with +
    +tar xvfz gc.tar.gz
    +cd gc
    +
    +

    +You can configure, build, and install the collector in a private +directory, say /home/xyz/gc, with the following commands: +

    +./configure --prefix=/home/xyz/gc --disable-threads
    +make
    +make check
    +make install
    +
    +Here the "make check" command is optional, but highly recommended. +It runs a basic correctness test which usually takes well under a minute. + +

    Other platforms

    +On non-Unix, non-Linux platforms, the collector is usually built by copying +the appropriate makefile (see the platform-specific README in doc/README.xxx +in the distribution) to the file "Makefile" (overwriting the copy of +Makefile.direct that was originally there), and then typing "make" +(or "nmake" or ...). This builds the library in the source tree. You may +want to move it and the files in the include directory to a more convenient +place. +

    +If you use a makefile that does not require running a configure script, +you should first look at the makefile, and adjust any options that are +documented there. +

    +If your platform provides a "make" utility, that is generally preferred +to platform- and compiler- dependent "project" files. (At least that is the +strong preference of the would-be maintainer of those project files.) +

    Threads

    +If you need thread support, configure the collector with +
    +--enable-threads=posix --enable-thread-local-alloc --enable-parallel-mark
    +
    +instead of +--disable-threads +If your target is a real old-fashioned uniprocessor (no "hyperthreading", +etc.) you will want to omit --enable-parallel-mark. +

    C++

    +You will need to include the C++ support, which unfortunately tends to +be among the least portable parts of the collector, since it seems +to rely on some corner cases of the language. On Linux, it +suffices to add --enable-cplusplus to the configure options. +
    +

    Writing the program

    +You will need a +
    +#include "gc.h"
    +
    +at the beginning of every file that allocates memory through the +garbage collector. Call GC_MALLOC wherever you would +have call malloc. This initializes memory to zero like +calloc; there is no need to explicitly clear the +result. +

    +If you know that an object will not contain pointers to the +garbage-collected heap, and you don't need it to be initialized, +call GC_MALLOC_ATOMIC instead. +

    +A function GC_FREE is provided but need not be called. +For very small objects, your program will probably perform better if +you do not call it, and let the collector do its job. +

    +A GC_REALLOC function behaves like the C library realloc. +It allocates uninitialized pointer-free memory if the original +object was allocated that way. +

    +The following program loop.c is a trivial example: +

    +#include "gc.h"
    +#include <assert.h>
    +#include <stdio.h>
    +
    +int main()
    +{
    +  int i;
    +
    +  GC_INIT();	/* Optional on Linux/X86; see below.  */
    +  for (i = 0; i < 10000000; ++i)
    +   {
    +     int **p = (int **) GC_MALLOC(sizeof(int *));
    +     int *q = (int *) GC_MALLOC_ATOMIC(sizeof(int));
    +     assert(*p == 0);
    +     *p = (int *) GC_REALLOC(q, 2 * sizeof(int));
    +     if (i % 100000 == 0)
    +       printf("Heap size = %d\n", GC_get_heap_size());
    +   }
    +  return 0;
    +}
    +
    + +

    Interaction with the system malloc

    +It is usually best not to mix garbage-collected allocation with the system +malloc-free. If you do, you need to be careful not to store +pointers to the garbage-collected heap in memory allocated with the system +malloc. +

    Other Platforms

    +On some other platforms it is necessary to call GC_INIT() from the main program, +which is presumed to be part of the main executable, not a dynamic library. +This can never hurt, and is thus generally good practice. + +

    Threads

    +For a multithreaded program some more rules apply: +
      +
    • +Files that either allocate through the GC or make thread-related calls +should first define the macro GC_THREADS, and then +include "gc.h". On some platforms this will redefine some +threads primitives, e.g. to let the collector keep track of thread creation. +
    • +To take advantage of fast thread-local allocation, use the following instead +of including gc.h: +
      +#define GC_REDIRECT_TO_LOCAL
      +#include "gc_local_alloc.h"
      +
      +This will cause GC_MALLOC and GC_MALLOC_ATOMIC to keep per-thread allocation +caches, and greatly reduce the number of lock acquisitions during allocation. +
    + +

    C++

    +In the case of C++, you need to be especially careful not to store pointers +to the garbage-collected heap in areas that are not traced by the collector. +The collector includes some alternate interfaces +to make that easier. + +

    Debugging

    +Additional debug checks can be performed by defining GC_DEBUG before +including gc.h. Additional options are available if the collector +is also built with --enable-full_debug and all allocations are +performed with GC_DEBUG defined. + +

    What if I can't rewrite/recompile my program?

    +You may be able to build the collector with --enable-redirect-malloc +and set the LD_PRELOAD environment variable to point to the resulting +library, thus replacing the standard malloc with its garbage-collected +counterpart. This is rather platform dependent. See the +leak detection documentation for some more details. + +
    + +

    Compiling and linking

    + +The above application loop.c test program can be compiled and linked +with + +
    +cc -I/home/xyz/gc/include loop.c /home/xyz/gc/lib/libgc.a -o loop
    +
    + +The -I option directs the compiler to the right include +directory. In this case, we list the static library +directly on the compile line; the dynamic library could have been +used instead, provided we arranged for the dynamic loader to find +it, e.g. by setting LD_LIBRARY_PATH. + + + +

    Threads

    + +On pthread platforms, you will of course also have to link with +-lpthread, +and compile with any thread-safety options required by your compiler. +On some platforms, you may also need to link with -ldl +or -lrt. +Looking at threadlibs.c in the GC build directory +should give you the appropriate +list if a plain -lpthread doesn't work. + +
    + +

    Running the executable

    + +The executable can of course be run normally, e.g. by typing + +
    +./loop
    +
    + +The operation of the collector is affected by a number of environment variables. +For example, setting GC_PRINT_STATS produces some +GC statistics on stdout. +See README.environment in the distribution for details. + + diff --git a/boehm-gc/doc/tree.html b/boehm-gc/doc/tree.html new file mode 100644 index 000000000..c46a281cc --- /dev/null +++ b/boehm-gc/doc/tree.html @@ -0,0 +1,199 @@ + + + Two-Level Tree Structure for Fast Pointer Lookup + Hans-J. Boehm, Silicon Graphics (now at HP) + + +

    Two-Level Tree Structure for Fast Pointer Lookup

    +

    +The conservative garbage collector described +here +uses a 2-level tree +data structure to aid in fast pointer identification. +This data structure is described in a bit more detail here, since +

      +
    1. Variations of the data structure are more generally useful. +
    2. It appears to be hard to understand by reading the code. +
    3. Some other collectors appear to use inferior data structures to +solve the same problem. +
    4. It is central to fast collector operation. +
    +A candidate pointer is divided into three sections, the high, +middle, and low bits. The exact division between these +three groups of bits is dependent on the detailed collector configuration. +

    +The high and middle bits are used to look up an entry in the table described +here. The resulting table entry consists of either a block descriptor +(struct hblkhdr * or hdr *) +identifying the layout of objects in the block, or an indication that this +address range corresponds to the middle of a large block, together with a +hint for locating the actual block descriptor. Such a hint consist +of a displacement that can be subtracted from the middle bits of the candidate +pointer without leaving the object. +

    +In either case, the block descriptor (struct hblkhdr) +refers to a table of object starting addresses (the hb_map field). +The starting address table is indexed by the low bits if the candidate pointer. +The resulting entry contains a displacement to the beginning of the object, +or an indication that this cannot be a valid object pointer. +(If all interior pointer are recognized, pointers into large objects +are handled specially, as appropriate.) + +

    The Tree

    +

    +The rest of this discussion focuses on the two level data structure +used to map the high and middle bits to the block descriptor. +

    +The high bits are used as an index into the GC_top_index (really +GC_arrays._top_index) array. Each entry points to a +bottom_index data structure. This structure in turn consists +mostly of an array index indexed by the middle bits of +the candidate pointer. The index array contains the actual +hdr pointers. +

    +Thus a pointer lookup consists primarily of a handful of memory references, +and can be quite fast: +

      +
    1. The appropriate bottom_index pointer is looked up in +GC_top_index, based on the high bits of the candidate pointer. +
    2. The appropriate hdr pointer is looked up in the +bottom_index structure, based on the middle bits. +
    3. The block layout map pointer is retrieved from the hdr +structure. (This memory reference is necessary since we try to share +block layout maps.) +
    4. The displacement to the beginning of the object is retrieved from the +above map. +
    +

    +In order to conserve space, not all GC_top_index entries in fact +point to distinct bottom_index structures. If no address with +the corresponding high bits is part of the heap, then the entry points +to GC_all_nils, a single bottom_index structure consisting +only of NULL hdr pointers. +

    +Bottom_index structures contain slightly more information than +just hdr pointers. The asc_link field is used to link +all bottom_index structures in ascending order for fast traversal. +This list is pointed to be GC_all_bottom_indices. +It is maintained with the aid of key field that contains the +high bits corresponding to the bottom_index. + +

    64 bit addresses

    +

    +In the case of 64 bit addresses, this picture is complicated slightly +by the fact that one of the index structures would have to be huge to +cover the entire address space with a two level tree. We deal with this +by turning GC_top_index into a chained hash table, instead of +a simple array. This adds a hash_link field to the +bottom_index structure. +

    +The "hash function" consists of dropping the high bits. This is cheap to +compute, and guarantees that there will be no collisions if the heap +is contiguous and not excessively large. + +

    A picture

    +

    +The following is an ASCII diagram of the data structure. +This was contributed by Dave Barrett several years ago. +

    +
    +		Data Structure used by GC_base in gc3.7:
    +			      21-Apr-94
    +			 
    +			
    +
    +
    +    63                  LOG_TOP_SZ[11]  LOG_BOTTOM_SZ[10]   LOG_HBLKSIZE[13]
    +   +------------------+----------------+------------------+------------------+
    + p:|                  |   TL_HASH(hi)  |                  |   HBLKDISPL(p)   |
    +   +------------------+----------------+------------------+------------------+
    +    \-----------------------HBLKPTR(p)-------------------/
    +    \------------hi-------------------/ 
    +                      \______ ________/ \________ _______/ \________ _______/
    +                             V                   V                  V
    +                             |                   |                  |
    +           GC_top_index[]    |                   |                  | 
    + ---      +--------------+   |                   |                  |  
    +  ^       |              |   |                   |                  |   
    +  |       |              |   |                   |                  |   
    + TOP      +--------------+<--+                   |                  |      
    + _SZ   +-<|      []      | *                     |                  |     
    +(items)|  +--------------+  if 0 < bi< HBLKSIZE  |                  |    
    +  |    |  |              | then large object     |                  |    
    +  |    |  |              | starts at the bi'th   |                  |    
    +  v    |  |              | HBLK before p.        |             i    |    
    + ---   |  +--------------+                       |          (word-  |    
    +       v                                         |         aligned) |    
    +   bi= |GET_BI(p){->hash_link}->key==hi          |                  |   
    +       v                                         |                  |    
    +       |   (bottom_index)  \ scratch_alloc'd     |                  |    
    +       |   ( struct  bi )  / by get_index()      |                  |    
    + ---   +->+--------------+                       |                  |    
    +  ^       |              |                       |                  |
    +  ^       |              |                       |                  |
    + BOTTOM   |              |   ha=GET_HDR_ADDR(p)  |                  |
    +_SZ(items)+--------------+<----------------------+          +-------+
    +  |   +--<|   index[]    |                                  |         
    +  |   |   +--------------+                      GC_obj_map: v              
    +  |   |   |              |              from      / +-+-+-----+-+-+-+-+  --- 
    +  v   |   |              |              GC_add   < 0| | |     | | | | |   ^  
    + ---  |   +--------------+             _map_entry \ +-+-+-----+-+-+-+-+   |  
    +      |   |   asc_link   |                          +-+-+-----+-+-+-+-+ MAXOBJSZ
    +      |   +--------------+                      +-->| | |  j  | | | | |  +1   
    +      |   |     key      |                      |   +-+-+-----+-+-+-+-+   |  
    +      |   +--------------+                      |   +-+-+-----+-+-+-+-+   | 
    +      |   |  hash_link   |                      |   | | |     | | | | |   v 
    +      |   +--------------+                      |   +-+-+-----+-+-+-+-+  ---
    +      |                                         |   |<--MAX_OFFSET--->|   
    +      |                                         |         (bytes)
    +HDR(p)| GC_find_header(p)                       |   |<--MAP_ENTRIES-->| 
    +      |                           \ from        |    =HBLKSIZE/WORDSZ   
    +      |    (hdr) (struct hblkhdr) / alloc_hdr() |    (1024 on Alpha)
    +      +-->+----------------------+              |    (8/16 bits each)
    +GET_HDR(p)| word   hb_sz (words) |              |          
    +          +----------------------+              |     
    +          | struct hblk *hb_next |              |
    +          +----------------------+              |       
    +          |mark_proc hb_mark_proc|              |
    +          +----------------------+              |
    +          | char * hb_map        |>-------------+
    +          +----------------------+           
    +          | ushort hb_obj_kind   |           
    +          +----------------------+           
    +          |   hb_last_reclaimed  |           
    + ---      +----------------------+                
    +  ^       |                      |
    + MARK_BITS|       hb_marks[]     | *if hdr is free, hb_sz + DISCARD_WORDS
    +_SZ(words)|                      |  is the size of a heap chunk (struct hblk)
    +  v       |                      |  of at least MININCR*HBLKSIZE bytes (below),
    + ---      +----------------------+  otherwise, size of each object in chunk.
    +
    +Dynamic data structures above are interleaved throughout the heap in blocks of 
    +size MININCR * HBLKSIZE bytes as done by gc_scratch_alloc which cannot be
    +freed; free lists are used (e.g. alloc_hdr).  HBLK's below are collected.
    +
    +	      (struct hblk)      
    + ---      +----------------------+ < HBLKSIZE ---         ---          DISCARD_
    +  ^       |garbage[DISCARD_WORDS]|   aligned   ^           ^ HDR_BYTES WORDS
    +  |       |                      |             |           v (bytes)   (words)
    +  |       +-----hb_body----------+ < WORDSZ    |          ---   ---   
    +  |       |                      |   aligned   |           ^     ^
    +  |       |      Object 0        |             |           hb_sz |
    +  |       |                      |           i |(word-    (words)|
    +  |       |                      |      (bytes)|aligned)   v     |
    +  |       + - - - - - - - - - - -+ ---         |          ---    |
    +  |       |                      |  ^          |           ^     |
    +  n *     |                      |  j (words)  |          hb_sz BODY_SZ 
    + HBLKSIZE |      Object 1        |  v          v           |   (words)
    + (bytes)  |                      |---------------          v   MAX_OFFSET
    +  |       + - - - - - - - - - - -+                        ---  (bytes)
    +  |       |                      | !All_INTERIOR_PTRS      ^     |
    +  |       |                      | sets j only for       hb_sz   |
    +  |       |      Object N        | valid object offsets.   |     |
    +  v       |                      | All objects WORDSZ      v     v
    + ---      +----------------------+ aligned.               ---   ---
    +
    +DISCARD_WORDS is normally zero.  Indeed the collector has not been tested
    +with another value in ages.
    +
    + -- cgit v1.2.3