/*
MacOS_Test_config.h
-
+
Configuration flags for Macintosh development systems.
-
+
Test version.
-
+
<Revision History>
11/16/95 pcb Updated compilation flags to reflect latest 4.6 Makefile.
-
+
by Patrick C. Beard.
*/
/* Boehm, November 17, 1995 12:05 pm PST */
// is normally more than one byte due to alignment constraints.)
// -DDONT_ADD_BYTE_AT_END disables the padding.
// -DNO_SIGNALS does not disable signals during critical parts of
-// the GC process. This is no less correct than many malloc
+// the GC process. This is no less correct than many malloc
// implementations, and it sometimes has a significant performance
// impact. However, it is dangerous for many not-quite-ANSI C
// programs that call things like printf in asynchronous signal handlers.
/*
MacOS_config.h
-
+
Configuration flags for Macintosh development systems.
-
+
<Revision History>
-
+
11/16/95 pcb Updated compilation flags to reflect latest 4.6 Makefile.
-
+
by Patrick C. Beard.
*/
/* Boehm, November 17, 1995 12:10 pm PST */
// is normally more than one byte due to alignment constraints.)
// -DDONT_ADD_BYTE_AT_END disables the padding.
// -DNO_SIGNALS does not disable signals during critical parts of
-// the GC process. This is no less correct than many malloc
+// the GC process. This is no less correct than many malloc
// implementations, and it sometimes has a significant performance
// impact. However, it is dangerous for many not-quite-ANSI C
// programs that call things like printf in asynchronous signal handlers.
/*
dataend.c
-
+
A hack to get the extent of global data for the Macintosh.
-
+
by Patrick C. Beard.
*/
/*
datastart.c
-
+
A hack to get the extent of global data for the Macintosh.
-
+
by Patrick C. Beard.
*/
END
-DE MENU
+DE MENU
BEGIN
POPUP "&File"
BEGIN
MENUITEM "Delete F&orward\tDEL", IDM_EDITDEL
MENUITEM "&Top\t^T", IDM_EDITTOP
END
-
+
POPUP "&Help"
BEGIN
MENUITEM "&Contents", IDM_HELPCONTENTS
MENUITEM "&About...", IDM_HELPABOUT
END
-
+
MENUITEM "Page_&Down", IDM_EDITPDOWN
MENUITEM "Page_&Up", IDM_EDITPUP
END
-DE ACCELERATORS
+DE ACCELERATORS
BEGIN
"^R", IDM_EDITREPEAT
"^N", IDM_EDITDOWN
/* DE ICON cord\de_win.ICO */
-
1) You compile the collector with -DGC_IRIX_THREADS specified in the Makefile.
-2) You have the latest pthreads patches installed.
+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
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.
-
{
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);
</ol>
</body>
</html>
-
-
-
-
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.
+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
<UL>
<LI> Programs with a large root set size and
little live heap memory will expand the heap to amortize the cost of
-scanning the roots.
+scanning the roots.
<LI> 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
<TT>gcconfig.h</tt>. 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 <TT>dyn_load.c</tt>.
-</ul>
+</ul>
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,
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.
+end of a mark cycle.
<P>
The collector makes an initial pass over the table of finalizable objects,
pushing the contents of unmarked objects onto the mark stack.
(<TT>PCR_VDB</tt>) By relying on an external dirty bit implementation, in this
case the one in Xerox PCR.
<LI>
-(<TT>DEFAULT_VDB</tt>) By treating all pages as dirty. This is the default if
+(<TT>DEFAULT_VDB</tt>) By treating all pages as dirty. This is the default if
none of the other techniques is known to be usable, and
<TT>GC_malloc_stubborn</tt> is not used. Practical only for testing, or if
the vast majority of objects use <TT>GC_malloc_stubborn</tt>.
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.
+small pointerfree objects.
<P>
The collector understands two different kinds of black-listing. A
page may be black listed for interior pointer references
versions, win32 if the collector was suitably built) or if "stubborn"
allocation is used (see
<A HREF="http://www.hpl.hp.com/personal/Hans_Boehm/gc/gc_source/gch.txt">gc.h</a>).
-On many platforms this interacts poorly with system calls
+On many platforms this interacts poorly with system calls
that write to the garbage collected heap.
<DT> <B> GC_warn_proc GC_set_warn_proc(GC_warn_proc <I>p</i>) </b>
<DD>
<LI> <TT>gc_allocator</tt>
</ul>
which may be used either directly to allocate memory or to instantiate
-container templates.
+container templates.
The former allocates uncollectable but traced memory.
The latter allocates garbage-collected memory.
<P>
memory.
<DT> <B> C interface </b>
<DD>
-It is also possible to use the C interface from
+It is also possible to use the C interface from
<A HREF="http://hpl.hp.com/personal/Hans_Boehm/gc/gc_source/gch.txt">gc.h</a> 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
<tt>malloc</tt> with <tt>GC_malloc</tt> calls,
replacing <tt>realloc</tt> with <tt>GC_realloc</tt> calls, and removing
free calls. Exceptions are discussed
-in <a href="http://www.hpl.hp.com/personal/Hans_Boehm/gc/issues.html">issues.html</a>.
+in <a href="http://www.hpl.hp.com/personal/Hans_Boehm/gc/issues.html">issues.html</a>.
</p><h2><a name="platforms">Platforms</a></h2>
The collector is not completely portable, but the distribution
includes ports to most standard PC and UNIX/Linux platforms.
(<a href="mailto:Hans_Boehm@hp.com">Hans.Boehm@hp.com</a>) or
(<a href="mailto:boehm@acm.org">boehm@acm.org</a>), but the gc
mailing list is usually preferred.
-
+
</p></body></html>
cases, sometimes drastically so.
<H2>Options for enhanced scalability</h2>
Version 6.0 of the collector adds two facilities to enhance collector
-scalability on multiprocessors. As of 6.0alpha1, these are supported
+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.
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
+locking. The thread-local free lists are refilled using
<TT>GC_malloc_many</tt>.
<P>
An important side effect of this flag is to replace the default
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).
+consequences (e.g. a factor of 10 slowdown).
<H2>Performance</h2>
We conducted some simple experiments with a version of
<A HREF="gc_bench.html">our GC benchmark</a> that was slightly modified to
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.
+proportion to the number of processors.
<P>
These results are likely to be very sensitive to both hardware and OS
issues. Preliminary experiments with an older Pentium Pro machine running
<TT>bottom_index</tt> data structure. This structure in turn consists
mostly of an array <TT>index</tt> indexed by the middle bits of
the candidate pointer. The <TT>index</tt> array contains the actual
-<TT>hdr</tt> pointers.
+<TT>hdr</tt> pointers.
<P>
Thus a pointer lookup consists primarily of a handful of memory references,
and can be quite fast:
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-------------------/
+ \------------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() | |
- --- +->+--------------+ | |
+ 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 \ +-+-+-----+-+-+-+-+ |
+ | +--<| index[] | |
+ | | +--------------+ GC_obj_map: v
+ | | | | from / +-+-+-----+-+-+-+-+ ---
+ v | | | GC_add < 0| | | | | | | | ^
+ --- | +--------------+ _map_entry \ +-+-+-----+-+-+-+-+ |
| | asc_link | +-+-+-----+-+-+-+-+ MAXOBJSZ
- | +--------------+ +-->| | | j | | | | | +1
- | | key | | +-+-+-----+-+-+-+-+ |
- | +--------------+ | +-+-+-----+-+-+-+-+ |
- | | hash_link | | | | | | | | | | v
+ | +--------------+ +-->| | | j | | | | | +1
+ | | key | | +-+-+-----+-+-+-+-+ |
+ | +--------------+ | +-+-+-----+-+-+-+-+ |
+ | | hash_link | | | | | | | | | | v
| +--------------+ | +-+-+-----+-+-+-+-+ ---
- | | |<--MAX_OFFSET--->|
+ | | |<--MAX_OFFSET--->|
| | (bytes)
-HDR(p)| GC_find_header(p) | |<--MAP_ENTRIES-->|
- | \ from | =HBLKSIZE/WORDSZ
+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) | |
- +----------------------+ |
+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 |
- --- +----------------------+
+ +----------------------+
+ | 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
+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)
+ (struct hblk)
--- +----------------------+ < HBLKSIZE --- --- DISCARD_
^ |garbage[DISCARD_WORDS]| aligned ^ ^ HDR_BYTES WORDS
| | | | v (bytes) (words)
- | +-----hb_body----------+ < WORDSZ | --- ---
+ | +-----hb_body----------+ < WORDSZ | --- ---
| | | aligned | ^ ^
| | Object 0 | | hb_sz |
| | | i |(word- (words)|
| | | (bytes)|aligned) v |
| + - - - - - - - - - - -+ --- | --- |
| | | ^ | ^ |
- n * | | j (words) | hb_sz BODY_SZ
+ n * | | j (words) | hb_sz BODY_SZ
HBLKSIZE | Object 1 | v v | (words)
(bytes) | |--------------- v MAX_OFFSET
| + - - - - - - - - - - -+ --- (bytes)
ptr_t GC_get_main_stack_base()
{
struct Process *proc = (struct Process*)SysBase->ThisTask;
-
+
/* Reference: Amiga Guru Book Pages: 42,567,574 */
if (proc->pr_Task.tc_Node.ln_Type==NT_PROCESS
&& proc->pr_CLI != NULL) {
struct CommandLineInterface *cli;
BPTR myseglist;
ULONG *data;
-
+
int num;
}
#endif //GC_AMIGA_AM
-
-
/*
MacOS.c
-
+
Some routines for the Macintosh OS port of the Hans-J. Boehm, Alan J. Demers
garbage collector.
-
+
<Revision History>
-
+
11/22/94 pcb StripAddress the temporary memory handle for 24-bit mode.
11/30/94 pcb Tracking all memory usage so we can deallocate it all at once.
02/10/96 pcb Added routine to perform a final collection when
unloading shared library.
-
+
by Patrick C. Beard.
*/
/* Boehm, February 15, 1996 2:55 pm PST */
(**tempMemBlock).nextBlock = theTemporaryMemory;
theTemporaryMemory = tempMemBlock;
}
-
+
# if !defined(SHARED_LIBRARY_BUILD)
// install an exit routine to clean up the memory used at the end.
if (firstTime) {
firstTime = false;
}
# endif
-
+
return tempPtr;
}
-extern word GC_fo_entries;
+extern word GC_fo_entries;
static void perform_final_collection()
{
unsigned i;
word last_fo_entries = 0;
-
+
/* adjust the stack bottom, because CFM calls us from another stack
location. */
GC_stackbottom = (ptr_t)&i;
/* Note that this is almost the only real function, and it is */
/* implemented in 6 lines in cordxtra.c */
void CORD_ec_flush_buf(CORD_ec x);
-
+
/* Convert an extensible cord to a cord. */
# define CORD_ec_to_cord(x) (CORD_ec_flush_buf(x), (x)[0].ec_cord)
-/*
+/*
* Copyright (c) 1999-2005 Hewlett-Packard Development Company, L.P.
*
* THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED
* However, global free lists are known to the GC. "Tiny" free lists
* are basically private to the client. Their contents are viewed as
* "in use" and marked accordingly by the core of the GC.
- *
+ *
* Note that inlined code might know about the layout of these and the constants
* involved. Thus any change here may invalidate clients, and such changes should
* be avoided. Hence we keep this as simple as possible.
-/*
+/*
* Copyright (c) 1991-1994 by Xerox Corporation. All rights reserved.
*
* THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED
word descr;
# error This code was updated without testing.
# error and its precursor was clearly broken.
-
+
hhdr = HDR(h);
descr = hhdr -> hb_descr;
sz = hhdr -> hb_sz;
)
{
enumerate_data ed;
-
+
ed.ed_proc = proc;
ed.ed_pointerfree = ptrFree;
ed.ed_fail_code = PCR_ERes_okay;
mov r8=ar.bsp
br.ret.sptk.few rp
.endp GC_save_regs_in_stack
-
mov %sp,%o0
retl
nop
-
+
.globl _C_LABEL(GC_clear_stack_inner)
_C_LABEL(GC_clear_stack_inner):
mov %sp,%o2 ! Save sp
mov %sp,%o0
retl
nop
-
+
.globl _GC_clear_stack_inner
_GC_clear_stack_inner:
mov %sp,%o2 ! Save sp
add %o3,-8,%o3 ! p -= 8 (delay slot)
retl
mov %o2,%sp ! Restore sp., delay slot
-
-
-
-
-
-
# include <stdio.h>
# include <gc.h>
-
+
int main(argc, argv, envp)
int argc;
char ** argv;
char ** envp;
{
int i;
-
+
for (i = 1; i < argc; i++) {
if (GC_ALPHA_VERSION == GC_NOT_ALPHA) {
printf("gc%d.%d/%s ", GC_VERSION_MAJOR, GC_VERSION_MINOR, argv[i]);
fflush(stdout);
execvp(argv[3], argv+3);
perror("Couldn't execute");
-
+
Usage:
fprintf(stderr, "Usage: %s mach_type os_type command\n", argv[0]);
fprintf(stderr, "Currently mach_type = %s, os_type = %s\n",
MACH_TYPE, OS_TYPE);
return(1);
}
-
fflush(stdout);
execvp(argv[2], argv+2);
exit(1);
-
+
Usage:
fprintf(stderr, "Usage: %s file_name command\n", argv[0]);
return(1);
}
-