Imported version version 6.0alpha7.
* README, README.Mac, README.OS2, README.QUICK, README.alpha, README.amiga, README.debugging, README.dj, README.hp, README.linux, README.rs6000, README.sgi, README.solaris2, README.uts, README.win32, SCoptions.amiga, backptr.h, barrett_diagram, dbg_mlc.h, gc.h, gc.man, gc_alloc.h, gc_cpp.h, gc_hdrs.h, gc_mark.h, gc_priv.h, gc_private.h, gc_typed.h, gcconfig.h, hpux_irix_threads.c, makefile.depend, nursery.c, solaris_threads.h, test.c, test_cpp.cc, weakpointer.h, cord/README, cord/SCOPTIONS.amiga, cord/SMakefile.amiga, cord/cord.h, cord/ec.h, cord/gc.h, cord/private/cord_pos.h, include/backptr.h, include/gc_copy_descr.h, include/gc_nursery.h: Remove obsolete/moved files. From-SVN: r42379
This commit is contained in:
parent
a6951ca5de
commit
9110a741e3
96 changed files with 5702 additions and 14777 deletions
|
@ -47,9 +47,9 @@ gc.lib: $(OBJS)
|
|||
$(XXXOBJS:XXX=+)
|
||||
|
|
||||
|
||||
gctest.exe: test.obj gc.lib
|
||||
gctest.exe: tests\test.obj gc.lib
|
||||
$(cc) @&&|
|
||||
$(cflags) -W -e$* test.obj gc.lib
|
||||
$(cflags) -W -e$* tests\test.obj gc.lib
|
||||
|
|
||||
|
||||
cord\de.obj cord\de_win.obj: cord\cord.h cord\private\cord_pos.h cord\de_win.h \
|
||||
|
@ -68,8 +68,8 @@ gc_cpp.obj: gc_cpp.h gc.h
|
|||
gc_cpp.cpp: gc_cpp.cc
|
||||
copy gc_cpp.cc gc_cpp.cpp
|
||||
|
||||
test_cpp.cpp: test_cpp.cc
|
||||
copy test_cpp.cc test_cpp.cpp
|
||||
test_cpp.cpp: tests\test_cpp.cc
|
||||
copy tests\test_cpp.cc test_cpp.cpp
|
||||
|
||||
test_cpp.exe: test_cpp.obj gc_cpp.h gc.h gc.lib
|
||||
$(cc) @&&|
|
||||
|
|
|
@ -1,3 +1,20 @@
|
|||
2001-05-21 Bryce McKinlay <bryce@waitaki.otago.ac.nz>
|
||||
|
||||
Imported version version 6.0alpha7.
|
||||
|
||||
* README, README.Mac, README.OS2, README.QUICK, README.alpha,
|
||||
README.amiga, README.debugging, README.dj, README.hp, README.linux,
|
||||
README.rs6000, README.sgi, README.solaris2, README.uts,
|
||||
README.win32, SCoptions.amiga, backptr.h, barrett_diagram,
|
||||
dbg_mlc.h, gc.h, gc.man, gc_alloc.h, gc_cpp.h, gc_hdrs.h, gc_mark.h,
|
||||
gc_priv.h, gc_private.h, gc_typed.h, gcconfig.h,
|
||||
hpux_irix_threads.c, makefile.depend, nursery.c,
|
||||
solaris_threads.h, test.c, test_cpp.cc, weakpointer.h, cord/README,
|
||||
cord/SCOPTIONS.amiga, cord/SMakefile.amiga, cord/cord.h,
|
||||
cord/ec.h, cord/gc.h, cord/private/cord_pos.h, include/backptr.h,
|
||||
include/gc_copy_descr.h, include/gc_nursery.h: Remove obsolete/moved
|
||||
files.
|
||||
|
||||
2001-05-19 Hans Boehm <hans_boehm@hp.com>
|
||||
|
||||
* configure.host: Build with -fexceptions.
|
||||
|
|
|
@ -77,7 +77,7 @@ $(OBJS) test.o: $(srcdir)/gc_priv.h $(srcdir)/gc_hdrs.h $(srcdir)/gc.h \
|
|||
# options such as -DSILENT affects the size of GC_arrays,
|
||||
# invalidating all .o files that rely on gc_priv.h
|
||||
|
||||
mark.o typd_mlc.o finalize.o: $(srcdir)/gc_mark.h
|
||||
mark.o typd_mlc.o finalize.o: $(srcdir)/include/gc_mark.h $(srcdir)/include/private/gc_pmark.h
|
||||
|
||||
gc.a: $(OBJS)
|
||||
$(AR) ru gc.a $(OBJS)
|
||||
|
@ -120,13 +120,13 @@ cord/de.exe: $(srcdir)/cord/de.c $(srcdir)/cord/cordbscs.o $(srcdir)/cord/cordxt
|
|||
$(CC) $(CFLAGS) -o cord/de.exe $(srcdir)/cord/de.c $(srcdir)/cord/cordbscs.o $(srcdir)/cord/cordxtra.o gc.a $(CURSES)
|
||||
|
||||
clean:
|
||||
rm -f gc.a test.o gctest.exe output-local output-diff $(OBJS) \
|
||||
rm -f gc.a tests/test.o gctest.exe output-local output-diff $(OBJS) \
|
||||
setjmp_test mon.out gmon.out a.out core \
|
||||
$(CORD_OBJS) cord/cordtest.exe cord/de.exe
|
||||
-rm -f *~
|
||||
|
||||
gctest.exe: test.o gc.a
|
||||
$(CC) $(CFLAGS) -o gctest.exe test.o gc.a
|
||||
gctest.exe: tests/test.o gc.a
|
||||
$(CC) $(CFLAGS) -o gctest.exe tests/test.o gc.a
|
||||
|
||||
# If an optimized setjmp_test generates a segmentation fault,
|
||||
# odds are your compiler is broken. Gctest may still work.
|
||||
|
|
|
@ -25,13 +25,11 @@ endif
|
|||
|
||||
toolexeclib_LTLIBRARIES = $(target_all)
|
||||
EXTRA_LTLIBRARIES = libgcjgc.la
|
||||
libgcjgc_la_SOURCES = allchblk.c alloc.c blacklst.c checksums.c \
|
||||
gcconfig.h dbg_mlc.c dyn_load.c finalize.c gc.h gc_alloc.h gc_cpp.h \
|
||||
gc_hdrs.h gc_mark.h gc_priv.h gc_private.h gc_typed.h gcj_mlc.c headers.c \
|
||||
hpux_irix_threads.c linux_threads.c malloc.c mallocx.c mark.c mark_rts.c \
|
||||
misc.c new_hblk.c obj_map.c os_dep.c pcr_interface.c ptr_chck.c \
|
||||
real_malloc.c reclaim.c solaris_pthreads.c solaris_threads.c \
|
||||
solaris_threads.h stubborn.c typd_mlc.c version.h weakpointer.h
|
||||
libgcjgc_la_SOURCES = allchblk.c alloc.c blacklst.c checksums.c dbg_mlc.c \
|
||||
dyn_load.c finalize.c gc_dlopen.c gcj_mlc.c headers.c irix_threads.c \
|
||||
linux_threads.c malloc.c mallocx.c mark.c mark_rts.c misc.c new_hblk.c \
|
||||
obj_map.c os_dep.c pcr_interface.c ptr_chck.c real_malloc.c reclaim.c \
|
||||
solaris_pthreads.c solaris_threads.c specific.c stubborn.c typd_mlc.c`
|
||||
|
||||
# Include THREADLIBS here to ensure that the correct versions of
|
||||
# linuxthread semaphore functions get linked:
|
||||
|
@ -39,9 +37,10 @@ libgcjgc_la_LIBADD = @addobjs@ $(THREADLIBS)
|
|||
libgcjgc_la_DEPENDENCIES = @addobjs@
|
||||
libgcjgc_la_LDFLAGS = -version-info 1:1:0 -rpath $(toolexeclibdir)
|
||||
|
||||
EXTRA_libgcjgc_la_SOURCES = alpha_mach_dep.s mips_sgi_mach_dep.s \
|
||||
mips_ultrix_mach_dep.s rs6000_mach_dep.s sparc_mach_dep.s \
|
||||
sparc_sunos4_mach_dep.s mach_dep.c ecos.cc
|
||||
EXTRA_libgcjgc_la_SOURCES = alpha_mach_dep.s hpux_test_and_clear.s \
|
||||
mips_sgi_mach_dep.s mips_ultrix_mach_dep.s powerpc_macosx_mach_dep.s \
|
||||
rs6000_mach_dep.s sparc_mach_dep.s sparc_netbsd_mach_dep.s \
|
||||
sparc_sunos4_mach_dep.s
|
||||
|
||||
AM_CXXFLAGS = @BOEHM_GC_CFLAGS@
|
||||
AM_CFLAGS = @BOEHM_GC_CFLAGS@
|
||||
|
@ -55,7 +54,8 @@ TESTS = gctest
|
|||
|
||||
## FIXME: relies on internal code generated by automake.
|
||||
all_objs = @addobjs@ $(libgcjgc_la_OBJECTS)
|
||||
$(all_objs) : gcconfig.h gc_priv.h gc_hdrs.h gc.h gc_mark.h
|
||||
$(all_objs) : include/private/gcconfig.h include/private/gc_priv.h \
|
||||
include/private/gc_hdrs.h include/gc.h include/gc_gcj.h include/gc_mark.h
|
||||
|
||||
## FIXME: we shouldn't have to do this, but automake forces us to.
|
||||
.s.lo:
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
# This is the original manually generated Makefile. It may stil be used
|
||||
# to build the collector.
|
||||
#
|
||||
# Primary targets:
|
||||
# gc.a - builds basic library
|
||||
# libgc.a - builds library for use with g++ "-fgc-keyword" extension
|
||||
# c++ - adds C++ interface to library
|
||||
# cords - adds cords (heavyweight strings) to library
|
||||
# test - prints porting information, then builds basic version of gc.a,
|
||||
|
@ -9,7 +11,6 @@
|
|||
# cord/de - builds dumb editor based on cords.
|
||||
ABI_FLAG=
|
||||
CC=cc $(ABI_FLAG)
|
||||
HOSTCC=$(CC)
|
||||
CXX=g++ $(ABI_FLAG)
|
||||
AS=as $(ABI_FLAG)
|
||||
# The above doesn't work with gas, which doesn't run cpp.
|
||||
|
@ -17,39 +18,60 @@ AS=as $(ABI_FLAG)
|
|||
# Under Irix 6, you will have to specify the ABI (-o32, -n32, or -64)
|
||||
# if you use something other than the default ABI on your machine.
|
||||
|
||||
CFLAGS= -O -DATOMIC_UNCOLLECTABLE -DNO_SIGNALS -DNO_EXECUTE_PERMISSION -DALL_INTERIOR_POINTERS -DSILENT
|
||||
# Redefining srcdir allows object code for the nonPCR version of the collector
|
||||
# to be generated in different directories.
|
||||
srcdir= .
|
||||
VPATH= $(srcdir)
|
||||
|
||||
CFLAGS= -O -I$(srcdir)/include -DATOMIC_UNCOLLECTABLE -DNO_SIGNALS -DNO_EXECUTE_PERMISSION -DSILENT -DALL_INTERIOR_POINTERS
|
||||
|
||||
# To build the parallel collector on Linux, add to the above:
|
||||
# -DGC_LINUX_THREADS -DPARALLEL_MARK -DTHREAD_LOCAL_ALLOC
|
||||
# To build the parallel collector n a static library on HP/UX, add to the above:
|
||||
# -DGC_HPUX_THREADS -DPARALLEL_MARK -DTHREAD_LOCAL_ALLOC -DUSE_HPUX_TLS -D_POSIX_C_SOURCE=199506L
|
||||
|
||||
# HOSTCC and HOSTCFLAGS are used to build executables that will be run as
|
||||
# part of the build process, i.e. on the build machine. These will usually
|
||||
# be the same as CC and CFLAGS, except in a cross-compilation environment.
|
||||
# Note that HOSTCFLAGS should include any -D flags that affect thread support.
|
||||
HOSTCC=$(CC)
|
||||
HOSTCFLAGS=$(CFLAGS)
|
||||
|
||||
# For dynamic library builds, it may be necessary to add flags to generate
|
||||
# PIC code, e.g. -fPIC on Linux.
|
||||
|
||||
# Setjmp_test may yield overly optimistic results when compiled
|
||||
# without optimization.
|
||||
|
||||
# These define arguments influence the collector configuration:
|
||||
# -DSILENT disables statistics printing, and improves performance.
|
||||
# -DFIND_LEAK causes GC_find_leak to be initially set.
|
||||
# This causes the collector to assume that all inaccessible
|
||||
# objects should have been explicitly deallocated, and reports exceptions.
|
||||
# Finalization and the test program are not usable in this mode.
|
||||
# -DSOLARIS_THREADS enables support for Solaris (thr_) threads.
|
||||
# (Clients should also define SOLARIS_THREADS and then include
|
||||
# -DGC_SOLARIS_THREADS enables support for Solaris (thr_) threads.
|
||||
# (Clients should also define GC_SOLARIS_THREADS and then include
|
||||
# gc.h before performing thr_ or dl* or GC_ operations.)
|
||||
# Must also define -D_REENTRANT.
|
||||
# -D_SOLARIS_PTHREADS enables support for Solaris pthreads.
|
||||
# -DGC_SOLARIS_PTHREADS enables support for Solaris pthreads.
|
||||
# Define SOLARIS_THREADS as well.
|
||||
# -DIRIX_THREADS enables support for Irix pthreads. See README.irix.
|
||||
# -DHPUX_THREADS enables support for HP/UX 11 pthreads.
|
||||
# Also requires -D_REENTRANT. See README.hp.
|
||||
# -DLINUX_THREADS enables support for Xavier Leroy's Linux threads.
|
||||
# -DGC_IRIX_THREADS enables support for Irix pthreads. See README.irix.
|
||||
# -DGC_HPUX_THREADS enables support for HP/UX 11 pthreads.
|
||||
# Also requires -D_REENTRANT or -D_POSIX_C_SOURCE=199506L. See README.hp.
|
||||
# -DGC_LINUX_THREADS enables support for Xavier Leroy's Linux threads.
|
||||
# see README.linux. -D_REENTRANT may also be required.
|
||||
# -DALL_INTERIOR_POINTERS allows all pointers to the interior
|
||||
# of objects to be recognized. (See gc_priv.h for consequences.)
|
||||
# Alternatively, GC_all_interior_pointers can be set at process
|
||||
# initialization time.
|
||||
# -DSMALL_CONFIG tries to tune the collector for small heap sizes,
|
||||
# usually causing it to use less space in such situations.
|
||||
# Incremental collection no longer works in this case.
|
||||
# -DLARGE_CONFIG tunes the collector for unusually large heaps.
|
||||
# Necessary for heaps larger than about 500 MB on most machines.
|
||||
# Recommended for heaps larger than about 64 MB.
|
||||
# -DDONT_ADD_BYTE_AT_END is meaningful only with
|
||||
# -DALL_INTERIOR_POINTERS. Normally -DALL_INTERIOR_POINTERS
|
||||
# -DDONT_ADD_BYTE_AT_END is meaningful only with -DALL_INTERIOR_POINTERS or
|
||||
# GC_all_interior_pointers = 1. Normally -DALL_INTERIOR_POINTERS
|
||||
# causes all objects to be padded so that pointers just past the end of
|
||||
# an object can be recognized. This can be expensive. (The padding
|
||||
# is normally more than one byte due to alignment constraints.)
|
||||
|
@ -73,12 +95,19 @@ CFLAGS= -O -DATOMIC_UNCOLLECTABLE -DNO_SIGNALS -DNO_EXECUTE_PERMISSION -DALL_INT
|
|||
# -DREDIRECT_MALLOC=X causes malloc, realloc, and free to be defined
|
||||
# as aliases for X, GC_realloc, and GC_free, respectively.
|
||||
# Calloc is redefined in terms of the new malloc. X should
|
||||
# be either GC_malloc or GC_malloc_uncollectable.
|
||||
# be either GC_malloc or GC_malloc_uncollectable, or
|
||||
# GC_debug_malloc_replacement. (The latter invokes GC_debug_malloc
|
||||
# with dummy source location information, but still results in
|
||||
# properly remembered call stacks on Linux/X86 and Solaris/SPARC.)
|
||||
# The former is occasionally useful for working around leaks in code
|
||||
# you don't want to (or can't) look at. It may not work for
|
||||
# existing code, but it often does. Neither works on all platforms,
|
||||
# since some ports use malloc or calloc to obtain system memory.
|
||||
# (Probably works for UNIX, and win32.)
|
||||
# -DREDIRECT_REALLOC=X causes GC_realloc to be redirected to X.
|
||||
# The canonical use is -DREDIRECT_REALLOC=GC_debug_realloc_replacement,
|
||||
# together with -DREDIRECT_MALLOC=GC_debug_malloc_replacement to
|
||||
# generate leak reports with call stacks for both malloc and realloc.
|
||||
# -DIGNORE_FREE turns calls to free into a noop. Only useful with
|
||||
# -DREDIRECT_MALLOC.
|
||||
# -DNO_DEBUGGING removes GC_dump and the debugging routines it calls.
|
||||
|
@ -119,13 +148,32 @@ CFLAGS= -O -DATOMIC_UNCOLLECTABLE -DNO_SIGNALS -DNO_EXECUTE_PERMISSION -DALL_INT
|
|||
# for objects allocated with the debugging allocator. If all objects
|
||||
# through GC_MALLOC with GC_DEBUG defined, this allows the client
|
||||
# to determine how particular or randomly chosen objects are reachable
|
||||
# for debugging/profiling purposes. The backptr.h interface is
|
||||
# for debugging/profiling purposes. The gc_backptr.h interface is
|
||||
# implemented only if this is defined.
|
||||
# -DGC_ASSERTIONS Enable some internal GC assertion checking. Currently
|
||||
# this facility is only used in a few places. It is intended primarily
|
||||
# for debugging of the garbage collector itself, but could also
|
||||
# -DDBG_HDRS_ALL Make sure that all objects have debug headers. Increases
|
||||
# the reliability (from 99.9999% to 100%) of some of the debugging
|
||||
# code (especially KEEP_BACK_PTRS). Makes -DSHORT_DBG_HDRS possible.
|
||||
# Assumes that all client allocation is done through debugging
|
||||
# allocators.
|
||||
# -DSHORT_DBG_HDRS Assume that all objects have debug headers. Shorten
|
||||
# the headers to minimize object size, at the expense of checking for
|
||||
# writes past the end of an object. This is intended for environments
|
||||
# in which most client code is written in a "safe" language, such as
|
||||
# Scheme or Java. Assumes that all client allocation is done using
|
||||
# the GC_debug_ functions, or through the macros that expand to these,
|
||||
# or by redirecting malloc to GC_debug_malloc_replacement.
|
||||
# (Also eliminates the field for the requested object size.)
|
||||
# occasionally be useful for debugging of client code. Slows down the
|
||||
# collector somewhat, but not drastically.
|
||||
# -DSAVE_CALL_COUNT=<n> Set the number of call frames saved with objects
|
||||
# allocated through the debugging interface. Affects the amount of
|
||||
# information generated in leak reports. Only matters on platforms
|
||||
# on which we can quickly generate call stacks, currently Linux/(X86 & SPARC)
|
||||
# and Solaris/SPARC. Turns on call chain saving on X86. On X86, client
|
||||
# code should NOT be compiled with -fomit-frame-pointer.
|
||||
# -DCHECKSUMS reports on erroneously clear dirty bits, and unexpectedly
|
||||
# altered stubborn objects, at substantial performance cost.
|
||||
# Use only for debugging of the incremental collector.
|
||||
|
@ -143,66 +191,80 @@ CFLAGS= -O -DATOMIC_UNCOLLECTABLE -DNO_SIGNALS -DNO_EXECUTE_PERMISSION -DALL_INT
|
|||
# -DUSE_3DNOW_PREFETCH causes the collector to issue AMD 3DNow style
|
||||
# prefetch instructions. Same restrictions as USE_I686_PREFETCH.
|
||||
# UNTESTED!!
|
||||
# -DUSE_LD_WRAP in combination with the gld flags listed in README.linux
|
||||
# -DGC_USE_LD_WRAP in combination with the gld flags listed in README.linux
|
||||
# causes the collector some system and pthread calls in a more transparent
|
||||
# fashion than the usual macro-based approach. Requires GNU ld, and
|
||||
# currently probably works only with Linux.
|
||||
# -DTHREAD_LOCAL_ALLOC defines GC_local_malloc(), GC_local_malloc_atomic()
|
||||
# and GC_local_gcj_malloc(). Needed for gc_gcj.h interface. These allocate
|
||||
# in a way that usually does not involve acquisition of a global lock.
|
||||
# Currently requires -DGC_LINUX_THREADS, but should be easy to port to
|
||||
# other pthreads environments. Recommended for multiprocessors.
|
||||
# -DPARALLEL_MARK allows the marker to run in multiple threads. Recommended
|
||||
# for multiprocessors. Currently requires Linux on X86 or IA64, though
|
||||
# support for other Posix platforms should be fairly easy to add,
|
||||
# if the thread implementation is otherwise supported.
|
||||
# -DNO_GETENV prevents the collector from looking at environment variables.
|
||||
# These may otherwise alter its configuration, or turn off GC altogether.
|
||||
# I don't know of a reason to disable this, except possibly if the
|
||||
# resulting process runs as a privileged user?
|
||||
# -DSTUBBORN_ALLOC allows allocation of "hard to change" objects, and thus
|
||||
# makes incremental collection easier. Was enabled by default until 6.0.
|
||||
# Rarely used, to my knowledge.
|
||||
#
|
||||
|
||||
|
||||
LIBGC_CFLAGS= -O -DNO_SIGNALS -DSILENT \
|
||||
-DREDIRECT_MALLOC=GC_malloc_uncollectable \
|
||||
-DDONT_ADD_BYTE_AT_END -DALL_INTERIOR_POINTERS
|
||||
# Flags for building libgc.a -- the last two are required.
|
||||
|
||||
CXXFLAGS= $(CFLAGS)
|
||||
AR= ar
|
||||
RANLIB= ranlib
|
||||
|
||||
|
||||
# Redefining srcdir allows object code for the nonPCR version of the collector
|
||||
# to be generated in different directories. In this case, the destination directory
|
||||
# should contain a copy of the original include directory.
|
||||
srcdir = .
|
||||
VPATH = $(srcdir)
|
||||
OBJS= alloc.o reclaim.o allchblk.o misc.o mach_dep.o os_dep.o mark_rts.o headers.o mark.o obj_map.o blacklst.o finalize.o new_hblk.o dbg_mlc.o malloc.o stubborn.o checksums.o solaris_threads.o irix_threads.o linux_threads.o typd_mlc.o ptr_chck.o mallocx.o solaris_pthreads.o gcj_mlc.o specific.o gc_dlopen.o
|
||||
|
||||
OBJS= alloc.o reclaim.o allchblk.o misc.o mach_dep.o os_dep.o mark_rts.o headers.o mark.o obj_map.o blacklst.o finalize.o new_hblk.o dbg_mlc.o malloc.o stubborn.o checksums.o solaris_threads.o hpux_irix_threads.o linux_threads.o typd_mlc.o ptr_chck.o mallocx.o solaris_pthreads.o gcj_mlc.o
|
||||
CSRCS= reclaim.c allchblk.c misc.c alloc.c mach_dep.c os_dep.c mark_rts.c headers.c mark.c obj_map.c pcr_interface.c blacklst.c finalize.c new_hblk.c real_malloc.c dyn_load.c dbg_mlc.c malloc.c stubborn.c checksums.c solaris_threads.c irix_threads.c linux_threads.c typd_mlc.c ptr_chck.c mallocx.c solaris_pthreads.c gcj_mlc.c specific.c gc_dlopen.c
|
||||
|
||||
CSRCS= reclaim.c allchblk.c misc.c alloc.c mach_dep.c os_dep.c mark_rts.c headers.c mark.c obj_map.c pcr_interface.c blacklst.c finalize.c new_hblk.c real_malloc.c dyn_load.c dbg_mlc.c malloc.c stubborn.c checksums.c solaris_threads.c hpux_irix_threads.c linux_threads.c typd_mlc.c ptr_chck.c mallocx.c solaris_pthreads.c gcj_mlc.c
|
||||
|
||||
CORD_SRCS= cord/cordbscs.c cord/cordxtra.c cord/cordprnt.c cord/de.c cord/cordtest.c cord/cord.h cord/ec.h cord/private/cord_pos.h cord/de_win.c cord/de_win.h cord/de_cmds.h cord/de_win.ICO cord/de_win.RC cord/SCOPTIONS.amiga cord/SMakefile.amiga
|
||||
CORD_SRCS= cord/cordbscs.c cord/cordxtra.c cord/cordprnt.c cord/de.c cord/cordtest.c include/cord.h include/ec.h include/private/cord_pos.h cord/de_win.c cord/de_win.h cord/de_cmds.h cord/de_win.ICO cord/de_win.RC
|
||||
|
||||
CORD_OBJS= cord/cordbscs.o cord/cordxtra.o cord/cordprnt.o
|
||||
|
||||
SRCS= $(CSRCS) mips_sgi_mach_dep.s rs6000_mach_dep.s alpha_mach_dep.s \
|
||||
sparc_mach_dep.s gc.h gc_typed.h gc_hdrs.h gc_priv.h gc_private.h \
|
||||
gcconfig.h gc_mark.h include/gc_inl.h include/gc_inline.h gc.man \
|
||||
threadlibs.c if_mach.c if_not_there.c gc_cpp.cc gc_cpp.h weakpointer.h \
|
||||
gcc_support.c mips_ultrix_mach_dep.s include/gc_alloc.h gc_alloc.h \
|
||||
sparc_mach_dep.s include/gc.h include/gc_typed.h \
|
||||
include/private/gc_hdrs.h include/private/gc_priv.h \
|
||||
include/private/gcconfig.h include/private/gc_pmark.h \
|
||||
include/gc_inl.h include/gc_inline.h include/gc_mark.h \
|
||||
threadlibs.c if_mach.c if_not_there.c gc_cpp.cc include/gc_cpp.h \
|
||||
include/weakpointer.h include/private/gc_locks.h \
|
||||
gcc_support.c mips_ultrix_mach_dep.s include/gc_alloc.h \
|
||||
include/new_gc_alloc.h include/javaxfc.h sparc_sunos4_mach_dep.s \
|
||||
solaris_threads.h backptr.h hpux_test_and_clear.s include/gc_gcj.h \
|
||||
dbg_mlc.h $(CORD_SRCS)
|
||||
sparc_netbsd_mach_dep.s \
|
||||
include/private/solaris_threads.h include/gc_backptr.h \
|
||||
hpux_test_and_clear.s include/gc_gcj.h \
|
||||
include/gc_local_alloc.h include/private/dbg_mlc.h \
|
||||
include/private/specific.h powerpc_macosx_mach_dep.s \
|
||||
include/leak_detector.h include/gc_amiga_redirects.h \
|
||||
include/gc_pthread_redirects.h $(CORD_SRCS)
|
||||
|
||||
DOC_FILES= README.QUICK doc/README.Mac doc/README.MacOSX doc/README.OS2 \
|
||||
doc/README.amiga doc/README.cords doc/README.debugging \
|
||||
doc/README.dj doc/README.hp doc/README.linux doc/README.rs6000 \
|
||||
doc/README.sgi doc/README.solaris2 doc/README.uts \
|
||||
doc/README.win32 doc/barrett_diagram doc/README \
|
||||
doc/README.contributors doc/README.changes doc/gc.man \
|
||||
doc/README.environment
|
||||
|
||||
TESTS= tests/test.c tests/test_cpp.cc tests/trace_test.c \
|
||||
tests/leak_test.c tests/thread_leak_test.c
|
||||
OTHER_FILES= Makefile PCR-Makefile OS2_MAKEFILE NT_MAKEFILE BCC_MAKEFILE \
|
||||
README test.c test_cpp.cc setjmp_t.c SMakefile.amiga \
|
||||
SCoptions.amiga README.amiga README.win32 cord/README \
|
||||
cord/gc.h include/gc.h include/gc_typed.h include/cord.h \
|
||||
include/ec.h include/private/cord_pos.h include/private/gcconfig.h \
|
||||
include/private/gc_hdrs.h include/private/gc_priv.h \
|
||||
include/gc_cpp.h README.rs6000 include/backptr.h \
|
||||
include/weakpointer.h README.QUICK callprocs pc_excludes \
|
||||
barrett_diagram README.OS2 README.Mac MacProjects.sit.hqx \
|
||||
MacOS.c EMX_MAKEFILE makefile.depend README.debugging \
|
||||
include/gc_cpp.h Mac_files/datastart.c Mac_files/dataend.c \
|
||||
setjmp_t.c SMakefile.amiga configure.in Makefile.am \
|
||||
callprocs pc_excludes \
|
||||
MacProjects.sit.hqx MacOS.c EMX_MAKEFILE \
|
||||
Mac_files/datastart.c Mac_files/dataend.c \
|
||||
Mac_files/MacOS_config.h Mac_files/MacOS_Test_config.h \
|
||||
add_gc_prefix.c README.solaris2 README.sgi README.hp README.uts \
|
||||
win32_threads.c NT_THREADS_MAKEFILE gc.mak README.dj Makefile.dj \
|
||||
README.alpha README.linux version.h Makefile.DLLs \
|
||||
WCC_MAKEFILE nursery.c include/gc_nursery.h include/gc_copy_descr.h \
|
||||
include/leak_detector.h
|
||||
add_gc_prefix.c gc_cpp.cpp \
|
||||
win32_threads.c NT_THREADS_MAKEFILE gc.mak Makefile.dj \
|
||||
version.h Makefile.DLLs WCC_MAKEFILE AmigaOS.c $(TESTS)
|
||||
|
||||
CORD_INCLUDE_FILES= $(srcdir)/gc.h $(srcdir)/cord/cord.h $(srcdir)/cord/ec.h \
|
||||
$(srcdir)/cord/private/cord_pos.h
|
||||
CORD_INCLUDE_FILES= $(srcdir)/include/gc.h $(srcdir)/include/cord.h \
|
||||
$(srcdir)/include/ec.h $(srcdir)/include/private/cord_pos.h
|
||||
|
||||
UTILS= if_mach if_not_there threadlibs
|
||||
|
||||
|
@ -214,7 +276,7 @@ CURSES= -lcurses -ltermlib
|
|||
# the SHELL environment variable.
|
||||
SHELL= /bin/sh
|
||||
|
||||
SPECIALCFLAGS =
|
||||
SPECIALCFLAGS = -I$(srcdir)/include
|
||||
# Alternative flags to the C compiler for mach_dep.c.
|
||||
# Mach_dep.c often doesn't like optimization, and it's
|
||||
# not time-critical anyway.
|
||||
|
@ -222,17 +284,47 @@ SPECIALCFLAGS =
|
|||
|
||||
all: gc.a gctest
|
||||
|
||||
pcr: PCR-Makefile gc_private.h gc_hdrs.h gc.h gcconfig.h mach_dep.o $(SRCS)
|
||||
make -f PCR-Makefile depend
|
||||
make -f PCR-Makefile
|
||||
BSD-pkg-all: bsd-libgc.a
|
||||
|
||||
$(OBJS) test.o dyn_load.o dyn_load_sunos53.o: $(srcdir)/gc_priv.h $(srcdir)/gc_hdrs.h $(srcdir)/gc.h \
|
||||
$(srcdir)/gcconfig.h $(srcdir)/gc_typed.h Makefile
|
||||
bsd-libgc.a:
|
||||
$(MAKE) CFLAGS="$(CFLAGS)" clean c++-t
|
||||
mv gc.a bsd-libgc.a
|
||||
|
||||
BSD-pkg-install: BSD-pkg-all
|
||||
${CP} bsd-libgc.a libgc.a
|
||||
${INSTALL_DATA} libgc.a ${PREFIX}/lib
|
||||
${INSTALL_DATA} gc.h gc_cpp.h ${PREFIX}/include
|
||||
|
||||
pcr: PCR-Makefile include/private/gc_private.h include/private/gc_hdrs.h \
|
||||
include/private/gc_locks.h include/gc.h include/private/gcconfig.h \
|
||||
mach_dep.o $(SRCS)
|
||||
$(MAKE) -f PCR-Makefile depend
|
||||
$(MAKE) -f PCR-Makefile
|
||||
|
||||
$(OBJS) tests/test.o dyn_load.o dyn_load_sunos53.o: \
|
||||
$(srcdir)/include/private/gc_priv.h \
|
||||
$(srcdir)/include/private/gc_hdrs.h $(srcdir)/include/private/gc_locks.h \
|
||||
$(srcdir)/include/gc.h \
|
||||
$(srcdir)/include/private/gcconfig.h $(srcdir)/include/gc_typed.h \
|
||||
Makefile
|
||||
# The dependency on Makefile is needed. Changing
|
||||
# options such as -DSILENT affects the size of GC_arrays,
|
||||
# invalidating all .o files that rely on gc_priv.h
|
||||
|
||||
mark.o typd_mlc.o finalize.o: $(srcdir)/gc_mark.h
|
||||
mark.o typd_mlc.o finalize.o ptr_chck.o: $(srcdir)/include/gc_mark.h $(srcdir)/include/private/gc_pmark.h
|
||||
|
||||
specific.o linux_threads.o: $(srcdir)/include/private/specific.h
|
||||
|
||||
solaris_threads.o solaris_pthreads.o: $(srcdir)/include/private/solaris_threads.h
|
||||
|
||||
dbg_mlc.o gcj_mlc.o: $(srcdir)/include/private/dbg_mlc.h
|
||||
|
||||
tests/test.o: tests $(srcdir)/tests/test.c
|
||||
$(CC) $(CFLAGS) -c $(srcdir)/tests/test.c
|
||||
mv test.o tests/test.o
|
||||
|
||||
tests:
|
||||
mkdir tests
|
||||
|
||||
base_lib gc.a: $(OBJS) dyn_load.o $(UTILS)
|
||||
echo > base_lib
|
||||
|
@ -254,16 +346,22 @@ cords: $(CORD_OBJS) cord/cordtest $(UTILS)
|
|||
./if_not_there dont_ar_3 $(AR) ru gc.a $(CORD_OBJS)
|
||||
./if_not_there dont_ar_3 $(RANLIB) gc.a || cat /dev/null
|
||||
|
||||
gc_cpp.o: $(srcdir)/gc_cpp.cc $(srcdir)/gc_cpp.h $(srcdir)/gc.h Makefile
|
||||
gc_cpp.o: $(srcdir)/gc_cpp.cc $(srcdir)/include/gc_cpp.h $(srcdir)/include/gc.h Makefile
|
||||
$(CXX) -c $(CXXFLAGS) $(srcdir)/gc_cpp.cc
|
||||
|
||||
test_cpp: $(srcdir)/test_cpp.cc $(srcdir)/gc_cpp.h gc_cpp.o $(srcdir)/gc.h \
|
||||
test_cpp: $(srcdir)/tests/test_cpp.cc $(srcdir)/include/gc_cpp.h gc_cpp.o $(srcdir)/include/gc.h \
|
||||
base_lib $(UTILS)
|
||||
rm -f test_cpp
|
||||
./if_mach HP_PA HPUX $(CXX) $(CXXFLAGS) -o test_cpp $(srcdir)/test_cpp.cc gc_cpp.o gc.a -ldld `./threadlibs`
|
||||
./if_not_there test_cpp $(CXX) $(CXXFLAGS) -o test_cpp $(srcdir)/test_cpp.cc gc_cpp.o gc.a `./threadlibs`
|
||||
./if_mach HP_PA HPUX $(CXX) $(CXXFLAGS) -o test_cpp $(srcdir)/tests/test_cpp.cc gc_cpp.o gc.a -ldld `./threadlibs`
|
||||
./if_not_there test_cpp $(CXX) $(CXXFLAGS) -o test_cpp $(srcdir)/tests/test_cpp.cc gc_cpp.o gc.a `./threadlibs`
|
||||
|
||||
c++: gc_cpp.o $(srcdir)/gc_cpp.h test_cpp
|
||||
c++-t: c++
|
||||
./test_cpp 1
|
||||
|
||||
c++-nt: c++
|
||||
@echo "Use ./test_cpp 1 to test the leak library"
|
||||
|
||||
c++: gc_cpp.o $(srcdir)/include/gc_cpp.h test_cpp
|
||||
rm -f dont_ar_4
|
||||
./if_mach SPARC SUNOS5 touch dont_ar_4
|
||||
./if_mach SPARC SUNOS5 $(AR) rus gc.a gc_cpp.o
|
||||
|
@ -294,7 +392,7 @@ libirixgc.so: $(OBJS) dyn_load.o
|
|||
|
||||
# Linux shared library version of the collector
|
||||
liblinuxgc.so: $(OBJS) dyn_load.o
|
||||
gcc -shared -o liblinuxgc.so $(OBJS) dyn_load.o -lo
|
||||
gcc -shared -o liblinuxgc.so $(OBJS) dyn_load.o
|
||||
ln liblinuxgc.so libgc.so
|
||||
|
||||
# Alternative Linux rule. This is preferable, but is likely to break the
|
||||
|
@ -310,21 +408,21 @@ liblinuxgc.so: $(OBJS) dyn_load.o
|
|||
# gcc -shared -Wl,-soname=libgc.so.0 -o libgc.so.0 $(LIBOBJS) dyn_load.lo
|
||||
# touch liblinuxgc.so
|
||||
|
||||
mach_dep.o: $(srcdir)/mach_dep.c $(srcdir)/mips_sgi_mach_dep.s $(srcdir)/mips_ultrix_mach_dep.s $(srcdir)/rs6000_mach_dep.s $(UTILS)
|
||||
mach_dep.o: $(srcdir)/mach_dep.c $(srcdir)/mips_sgi_mach_dep.s $(srcdir)/mips_ultrix_mach_dep.s \
|
||||
$(srcdir)/rs6000_mach_dep.s $(srcdir)/powerpc_macosx_mach_dep.s $(UTILS)
|
||||
rm -f mach_dep.o
|
||||
./if_mach MIPS IRIX5 $(AS) -o mach_dep.o $(srcdir)/mips_sgi_mach_dep.s
|
||||
./if_mach MIPS RISCOS $(AS) -o mach_dep.o $(srcdir)/mips_ultrix_mach_dep.s
|
||||
./if_mach MIPS ULTRIX $(AS) -o mach_dep.o $(srcdir)/mips_ultrix_mach_dep.s
|
||||
./if_mach RS6000 "" $(AS) -o mach_dep.o $(srcdir)/rs6000_mach_dep.s
|
||||
./if_mach POWERPC MACOSX $(AS) -o mach_dep.o $(srcdir)/powerpc_macosx_mach_dep.s
|
||||
# ./if_mach ALPHA "" $(AS) -o mach_dep.o $(srcdir)/alpha_mach_dep.s
|
||||
# alpha_mach_dep.s assumes that pointers are not saved in fp registers.
|
||||
# Gcc on a 21264 can spill pointers to fp registers. Oops.
|
||||
./if_mach SPARC SUNOS5 $(AS) -o mach_dep.o $(srcdir)/sparc_mach_dep.s
|
||||
./if_mach SPARC SUNOS4 $(AS) -o mach_dep.o $(srcdir)/sparc_sunos4_mach_dep.s
|
||||
./if_mach SPARC OPENBSD $(AS) -o mach_dep.o $(srcdir)/sparc_sunos4_mach_dep.s
|
||||
./if_mach HP_PA HPUX $(AS) -o hpux_test_and_clear.o $(srcdir)/hpux_test_and_clear.s
|
||||
./if_mach HP_PA HPUX $(CC) -c -o md_tmp.o $(SPECIALCFLAGS) $(srcdir)/mach_dep.c
|
||||
./if_mach HP_PA HPUX ld -r -o mach_dep.o md_tmp.o hpux_test_and_clear.o
|
||||
./if_mach SPARC NETBSD $(AS) -o mach_dep.o $(srcdir)/sparc_netbsd_mach_dep.s
|
||||
./if_not_there mach_dep.o $(CC) -c $(SPECIALCFLAGS) $(srcdir)/mach_dep.c
|
||||
|
||||
mark_rts.o: $(srcdir)/mark_rts.c $(UTILS)
|
||||
|
@ -336,16 +434,19 @@ mark_rts.o: $(srcdir)/mark_rts.c $(UTILS)
|
|||
|
||||
alloc.o: version.h
|
||||
|
||||
cord/cordbscs.o: $(srcdir)/cord/cordbscs.c $(CORD_INCLUDE_FILES)
|
||||
cord:
|
||||
mkdir cord
|
||||
|
||||
cord/cordbscs.o: cord $(srcdir)/cord/cordbscs.c $(CORD_INCLUDE_FILES)
|
||||
$(CC) $(CFLAGS) -c -I$(srcdir) $(srcdir)/cord/cordbscs.c
|
||||
mv cordbscs.o cord/cordbscs.o
|
||||
# not all compilers understand -o filename
|
||||
|
||||
cord/cordxtra.o: $(srcdir)/cord/cordxtra.c $(CORD_INCLUDE_FILES)
|
||||
cord/cordxtra.o: cord $(srcdir)/cord/cordxtra.c $(CORD_INCLUDE_FILES)
|
||||
$(CC) $(CFLAGS) -c -I$(srcdir) $(srcdir)/cord/cordxtra.c
|
||||
mv cordxtra.o cord/cordxtra.o
|
||||
|
||||
cord/cordprnt.o: $(srcdir)/cord/cordprnt.c $(CORD_INCLUDE_FILES)
|
||||
cord/cordprnt.o: cord $(srcdir)/cord/cordprnt.c $(CORD_INCLUDE_FILES)
|
||||
$(CC) $(CFLAGS) -c -I$(srcdir) $(srcdir)/cord/cordprnt.c
|
||||
mv cordprnt.o cord/cordprnt.o
|
||||
|
||||
|
@ -353,6 +454,7 @@ cord/cordtest: $(srcdir)/cord/cordtest.c $(CORD_OBJS) gc.a $(UTILS)
|
|||
rm -f cord/cordtest
|
||||
./if_mach SPARC DRSNX $(CC) $(CFLAGS) -o cord/cordtest $(srcdir)/cord/cordtest.c $(CORD_OBJS) gc.a -lucb
|
||||
./if_mach HP_PA HPUX $(CC) $(CFLAGS) -o cord/cordtest $(srcdir)/cord/cordtest.c $(CORD_OBJS) gc.a -ldld `./threadlibs`
|
||||
./if_mach M68K AMIGA $(CC) $(CFLAGS) -UGC_AMIGA_MAKINGLIB -o cord/cordtest $(srcdir)/cord/cordtest.c $(CORD_OBJS) gc.a `./threadlibs`
|
||||
./if_not_there cord/cordtest $(CC) $(CFLAGS) -o cord/cordtest $(srcdir)/cord/cordtest.c $(CORD_OBJS) gc.a `./threadlibs`
|
||||
|
||||
cord/de: $(srcdir)/cord/de.c cord/cordbscs.o cord/cordxtra.o gc.a $(UTILS)
|
||||
|
@ -360,37 +462,39 @@ cord/de: $(srcdir)/cord/de.c cord/cordbscs.o cord/cordxtra.o gc.a $(UTILS)
|
|||
./if_mach SPARC DRSNX $(CC) $(CFLAGS) -o cord/de $(srcdir)/cord/de.c cord/cordbscs.o cord/cordxtra.o gc.a $(CURSES) -lucb `./threadlibs`
|
||||
./if_mach HP_PA HPUX $(CC) $(CFLAGS) -o cord/de $(srcdir)/cord/de.c cord/cordbscs.o cord/cordxtra.o gc.a $(CURSES) -ldld `./threadlibs`
|
||||
./if_mach RS6000 "" $(CC) $(CFLAGS) -o cord/de $(srcdir)/cord/de.c cord/cordbscs.o cord/cordxtra.o gc.a -lcurses
|
||||
./if_mach POWERPC MACOSX $(CC) $(CFLAGS) -o cord/de $(srcdir)/cord/de.c cord/cordbscs.o cord/cordxtra.o gc.a
|
||||
./if_mach I386 LINUX $(CC) $(CFLAGS) -o cord/de $(srcdir)/cord/de.c cord/cordbscs.o cord/cordxtra.o gc.a -lcurses `./threadlibs`
|
||||
./if_mach ALPHA LINUX $(CC) $(CFLAGS) -o cord/de $(srcdir)/cord/de.c cord/cordbscs.o cord/cordxtra.o gc.a -lcurses `./threadlibs`
|
||||
./if_mach IA64 LINUX $(CC) $(CFLAGS) -o cord/de $(srcdir)/cord/de.c cord/cordbscs.o cord/cordxtra.o gc.a -lcurses `./threadlibs`
|
||||
./if_mach M68K AMIGA $(CC) $(CFLAGS) -o cord/de $(srcdir)/cord/de.c cord/cordbscs.o cord/cordxtra.o gc.a -lcurses
|
||||
./if_mach M68K AMIGA $(CC) $(CFLAGS) -UGC_AMIGA_MAKINGLIB -o cord/de $(srcdir)/cord/de.c cord/cordbscs.o cord/cordxtra.o gc.a -lcurses
|
||||
./if_not_there cord/de $(CC) $(CFLAGS) -o cord/de $(srcdir)/cord/de.c cord/cordbscs.o cord/cordxtra.o gc.a $(CURSES) `./threadlibs`
|
||||
|
||||
if_mach: $(srcdir)/if_mach.c $(srcdir)/gcconfig.h
|
||||
$(HOSTCC) $(CFLAGS) -o if_mach $(srcdir)/if_mach.c
|
||||
if_mach: $(srcdir)/if_mach.c $(srcdir)/include/private/gcconfig.h
|
||||
$(HOSTCC) $(HOSTCFLAGS) -o if_mach $(srcdir)/if_mach.c
|
||||
|
||||
threadlibs: $(srcdir)/threadlibs.c $(srcdir)/gcconfig.h Makefile
|
||||
$(HOSTCC) $(CFLAGS) -o threadlibs $(srcdir)/threadlibs.c
|
||||
threadlibs: $(srcdir)/threadlibs.c $(srcdir)/include/private/gcconfig.h Makefile
|
||||
$(HOSTCC) $(HOSTCFLAGS) -o threadlibs $(srcdir)/threadlibs.c
|
||||
|
||||
if_not_there: $(srcdir)/if_not_there.c
|
||||
$(HOSTCC) $(CFLAGS) -o if_not_there $(srcdir)/if_not_there.c
|
||||
$(HOSTCC) $(HOSTCFLAGS) -o if_not_there $(srcdir)/if_not_there.c
|
||||
|
||||
clean:
|
||||
rm -f gc.a *.o gctest gctest_dyn_link test_cpp \
|
||||
rm -f gc.a *.o *.exe tests/*.o gctest gctest_dyn_link test_cpp \
|
||||
setjmp_test mon.out gmon.out a.out core if_not_there if_mach \
|
||||
threadlibs $(CORD_OBJS) cord/cordtest cord/de
|
||||
-rm -f *~
|
||||
|
||||
gctest: test.o gc.a $(UTILS)
|
||||
gctest: tests/test.o gc.a $(UTILS)
|
||||
rm -f gctest
|
||||
./if_mach SPARC DRSNX $(CC) $(CFLAGS) -o gctest test.o gc.a -lucb
|
||||
./if_mach HP_PA HPUX $(CC) $(CFLAGS) -o gctest test.o gc.a -ldld `./threadlibs`
|
||||
./if_not_there gctest $(CC) $(CFLAGS) -o gctest test.o gc.a `./threadlibs`
|
||||
./if_mach SPARC DRSNX $(CC) $(CFLAGS) -o gctest tests/test.o gc.a -lucb
|
||||
./if_mach HP_PA HPUX $(CC) $(CFLAGS) -o gctest tests/test.o gc.a -ldld `./threadlibs`
|
||||
./if_mach M68K AMIGA $(CC) $(CFLAGS) -UGC_AMIGA_MAKINGLIB -o gctest tests/test.o gc.a `./threadlibs`
|
||||
./if_not_there gctest $(CC) $(CFLAGS) -o gctest tests/test.o gc.a `./threadlibs`
|
||||
|
||||
# If an optimized setjmp_test generates a segmentation fault,
|
||||
# odds are your compiler is broken. Gctest may still work.
|
||||
# Try compiling setjmp_t.c unoptimized.
|
||||
setjmp_test: $(srcdir)/setjmp_t.c $(srcdir)/gc.h $(UTILS)
|
||||
setjmp_test: $(srcdir)/setjmp_t.c $(srcdir)/include/gc.h $(UTILS)
|
||||
$(CC) $(CFLAGS) -o setjmp_test $(srcdir)/setjmp_t.c
|
||||
|
||||
test: KandRtest cord/cordtest
|
||||
|
@ -404,8 +508,8 @@ KandRtest: setjmp_test gctest
|
|||
add_gc_prefix: add_gc_prefix.c
|
||||
$(CC) -o add_gc_prefix $(srcdir)/add_gc_prefix.c
|
||||
|
||||
gc.tar: $(SRCS) $(OTHER_FILES) add_gc_prefix
|
||||
./add_gc_prefix $(SRCS) $(OTHER_FILES) > /tmp/gc.tar-files
|
||||
gc.tar: $(SRCS) $(DOC_FILES) $(OTHER_FILES) add_gc_prefix
|
||||
./add_gc_prefix $(SRCS) $(DOC_FILES) $(OTHER_FILES) > /tmp/gc.tar-files
|
||||
tar cvfh gc.tar `cat /tmp/gc.tar-files`
|
||||
|
||||
pc_gc.tar: $(SRCS) $(OTHER_FILES)
|
||||
|
@ -432,21 +536,23 @@ gc.tar.Z: gc.tar
|
|||
gc.tar.gz: gc.tar
|
||||
gzip gc.tar
|
||||
|
||||
lint: $(CSRCS) test.c
|
||||
lint -DLINT $(CSRCS) test.c | egrep -v "possible pointer alignment problem|abort|exit|sbrk|mprotect|syscall|change in ANSI|improper alignment"
|
||||
lint: $(CSRCS) tests/test.c
|
||||
lint -DLINT $(CSRCS) tests/test.c | egrep -v "possible pointer alignment problem|abort|exit|sbrk|mprotect|syscall|change in ANSI|improper alignment"
|
||||
|
||||
# BTL: added to test shared library version of collector.
|
||||
# Currently works only under SunOS5. Requires GC_INIT call from statically
|
||||
# loaded client code.
|
||||
ABSDIR = `pwd`
|
||||
gctest_dyn_link: test.o libgc.so
|
||||
$(CC) -L$(ABSDIR) -R$(ABSDIR) -o gctest_dyn_link test.o -lgc -ldl -lthread
|
||||
gctest_dyn_link: tests/test.o libgc.so
|
||||
$(CC) -L$(ABSDIR) -R$(ABSDIR) -o gctest_dyn_link tests/test.o -lgc -ldl -lthread
|
||||
|
||||
gctest_irix_dyn_link: test.o libirixgc.so
|
||||
$(CC) -L$(ABSDIR) -o gctest_irix_dyn_link test.o -lirixgc
|
||||
gctest_irix_dyn_link: tests/test.o libirixgc.so
|
||||
$(CC) -L$(ABSDIR) -o gctest_irix_dyn_link tests/test.o -lirixgc
|
||||
|
||||
test_dll.o: test.c libgc_globals.h
|
||||
$(CC) $(CFLAGS) -DGC_USE_DLL -c test.c -o test_dll.o
|
||||
# The following appear to be dead, especially since libgc_globals.h
|
||||
# is apparently lost.
|
||||
test_dll.o: tests/test.c libgc_globals.h
|
||||
$(CC) $(CFLAGS) -DGC_USE_DLL -c tests/test.c -o test_dll.o
|
||||
|
||||
test_dll: test_dll.o libgc_dll.a libgc.dll
|
||||
$(CC) test_dll.o -L$(ABSDIR) -lgc_dll -o test_dll
|
||||
|
@ -457,13 +563,13 @@ SYM_PREFIX-libgc=GC
|
|||
# include Makefile.DLLs
|
||||
|
||||
reserved_namespace: $(SRCS)
|
||||
for file in $(SRCS) test.c test_cpp.cc; do \
|
||||
for file in $(SRCS) tests/test.c tests/test_cpp.cc; do \
|
||||
sed s/GC_/_GC_/g < $$file > tmp; \
|
||||
cp tmp $$file; \
|
||||
done
|
||||
|
||||
user_namespace: $(SRCS)
|
||||
for file in $(SRCS) test.c test_cpp.cc; do \
|
||||
for file in $(SRCS) tests/test.c tests/test_cpp.cc; do \
|
||||
sed s/_GC_/GC_/g < $$file > tmp; \
|
||||
cp tmp $$file; \
|
||||
done
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
# This Makefile is intended only for DJGPP use.
|
||||
# It is mainly a copy of the main Makefile, but tends to get out of sync
|
||||
# with it. A merge would probably be appropriate.
|
||||
|
||||
# Primary targets:
|
||||
# gc.a - builds basic library
|
||||
# libgc.a - builds library for use with g++ "-fgc-keyword" extension
|
||||
|
@ -20,29 +24,18 @@ AS=gcc -c -x assembler-with-cpp $(ABI_FLAG)
|
|||
CXXLD=gxx $(ABI_FLAG)
|
||||
EXE_SUFFIX=.exe
|
||||
|
||||
CFLAGS= -O -DATOMIC_UNCOLLECTABLE -DNO_SIGNALS -DALL_INTERIOR_POINTERS -DNO_EXECUTE_PERMISSION -DSILENT
|
||||
srcdir= .
|
||||
VPATH= $(srcdir)
|
||||
|
||||
# For dynamic library builds, it may be necessary to add flags to generate
|
||||
# PIC code, e.g. -fPIC on Linux.
|
||||
CFLAGS= -O -I$(srcdir)/include -DATOMIC_UNCOLLECTABLE -DNO_SIGNALS -DALL_INTERIOR_POINTERS -DNO_EXECUTE_PERMISSION -DSILENT
|
||||
|
||||
# Setjmp_test may yield overly optimistic results when compiled
|
||||
# without optimization.
|
||||
# -DSILENT disables statistics printing, and improves performance.
|
||||
# -DCHECKSUMS reports on erroneously clear dirty bits, and unexpectedly
|
||||
# altered stubborn objects, at substantial performance cost.
|
||||
# Use only for incremental collector debugging.
|
||||
# -DFIND_LEAK causes the collector to assume that all inaccessible
|
||||
# -DFIND_LEAK causes GC_find_leak to be initially set.
|
||||
# This causes the collector to assume that all inaccessible
|
||||
# objects should have been explicitly deallocated, and reports exceptions.
|
||||
# Finalization and the test program are not usable in this mode.
|
||||
# -DSOLARIS_THREADS enables support for Solaris (thr_) threads.
|
||||
# (Clients should also define SOLARIS_THREADS and then include
|
||||
# gc.h before performing thr_ or dl* or GC_ operations.)
|
||||
# Must also define -D_REENTRANT.
|
||||
# -D_SOLARIS_PTHREADS enables support for Solaris pthreads.
|
||||
# Define SOLARIS_THREADS as well.
|
||||
# -DIRIX_THREADS enables support for Irix pthreads. See README.irix.
|
||||
# -DLINUX_THREADS enables support for Xavier Leroy's Linux threads.
|
||||
# see README.linux. -D_REENTRANT may also be required.
|
||||
# -DALL_INTERIOR_POINTERS allows all pointers to the interior
|
||||
# of objects to be recognized. (See gc_priv.h for consequences.)
|
||||
# -DSMALL_CONFIG tries to tune the collector for small heap sizes,
|
||||
|
@ -62,6 +55,8 @@ CFLAGS= -O -DATOMIC_UNCOLLECTABLE -DNO_SIGNALS -DALL_INTERIOR_POINTERS -DNO_EXEC
|
|||
# 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.
|
||||
# This is on by default. Turning it off has not been extensively tested with
|
||||
# compilers that reorder stores. It should have been.
|
||||
# -DNO_EXECUTE_PERMISSION may cause some or all of the heap to not
|
||||
# have execute permission, i.e. it may be impossible to execute
|
||||
# code from the heap. Currently this only affects the incremental
|
||||
|
@ -89,9 +84,12 @@ CFLAGS= -O -DATOMIC_UNCOLLECTABLE -DNO_SIGNALS -DALL_INTERIOR_POINTERS -DNO_EXEC
|
|||
# finalize.c). Objects reachable from finalizable objects will be marked
|
||||
# in a sepearte postpass, and hence their memory won't be reclaimed.
|
||||
# Not recommended unless you are implementing a language that specifies
|
||||
# these semantics.
|
||||
# these semantics. Since 5.0, determines only only the initial value
|
||||
# of GC_java_finalization variable.
|
||||
# -DFINALIZE_ON_DEMAND causes finalizers to be run only in response
|
||||
# to explicit GC_invoke_finalizers() calls.
|
||||
# In 5.0 this became runtime adjustable, and this only determines the
|
||||
# initial value of GC_finalize_on_demand.
|
||||
# -DATOMIC_UNCOLLECTABLE includes code for GC_malloc_atomic_uncollectable.
|
||||
# This is useful if either the vendor malloc implementation is poor,
|
||||
# or if REDIRECT_MALLOC is used.
|
||||
|
@ -100,76 +98,100 @@ CFLAGS= -O -DATOMIC_UNCOLLECTABLE -DNO_SIGNALS -DALL_INTERIOR_POINTERS -DNO_EXEC
|
|||
# kind of object. For the incremental collector it makes sense to match
|
||||
# the most likely page size. Otherwise large values result in more
|
||||
# fragmentation, but generally better performance for large heaps.
|
||||
# -DUSE_MMAP use MMAP instead of sbrk to get new memory.
|
||||
# Works for Solaris and Irix.
|
||||
# -DMMAP_STACKS (for Solaris threads) Use mmap from /dev/zero rather than
|
||||
# GC_scratch_alloc() to get stack memory.
|
||||
# -DPRINT_BLACK_LIST Whenever a black list entry is added, i.e. whenever
|
||||
# the garbage collector detects a value that looks almost, but not quite,
|
||||
# like a pointer, print both the address containing the value, and the
|
||||
# value of the near-bogus-pointer. Can be used to identifiy regions of
|
||||
# memory that are likely to contribute misidentified pointers.
|
||||
# -DOLD_BLOCK_ALLOC Use the old, possibly faster, large block
|
||||
# allocation strategy. The new strategy tries harder to minimize
|
||||
# fragmentation, sometimes at the expense of spending more time in the
|
||||
# large block allocator and/or collecting more frequently.
|
||||
# If you expect the allocator to promtly use an explicitly expanded
|
||||
# heap, this is highly recommended.
|
||||
#
|
||||
# -DKEEP_BACK_PTRS Add code to save back pointers in debugging headers
|
||||
# for objects allocated with the debugging allocator. If all objects
|
||||
# through GC_MALLOC with GC_DEBUG defined, this allows the client
|
||||
# to determine how particular or randomly chosen objects are reachable
|
||||
# for debugging/profiling purposes. The gc_backptr.h interface is
|
||||
# implemented only if this is defined.
|
||||
# -DGC_ASSERTIONS Enable some internal GC assertion checking. Currently
|
||||
# this facility is only used in a few places. It is intended primarily
|
||||
# for debugging of the garbage collector itself, but could also
|
||||
# -DDBG_HDRS_ALL Make sure that all objects have debug headers. Increases
|
||||
# the reliability (from 99.9999% to 100%) of some of the debugging
|
||||
# code (especially KEEP_BACK_PTRS). Makes -DSHORT_DBG_HDRS possible.
|
||||
# Assumes that all client allocation is done through debugging
|
||||
# allocators.
|
||||
# -DSHORT_DBG_HDRS Assume that all objects have debug headers. Shorten
|
||||
# the headers to minimize object size, at the expense of checking for
|
||||
# writes past the end of an object. This is intended for environments
|
||||
# in which most client code is written in a "safe" language, such as
|
||||
# Scheme or Java. Assumes that all client allocation is done using
|
||||
# the GC_debug_ functions (or through the macros that expand to these.
|
||||
# (Also eliminates the field for the requested object size.)
|
||||
# occasionally be useful for debugging of client code. Slows down the
|
||||
# collector somewhat, but not drastically.
|
||||
# -DCHECKSUMS reports on erroneously clear dirty bits, and unexpectedly
|
||||
# altered stubborn objects, at substantial performance cost.
|
||||
# Use only for debugging of the incremental collector.
|
||||
# -DGC_GCJ_SUPPORT includes support for gcj (and possibly other systems
|
||||
# that include a pointer to a type descriptor in each allocated object).
|
||||
# Building this way requires an ANSI C compiler.
|
||||
# -DUSE_I686_PREFETCH causes the collector to issue Pentium III style
|
||||
# prefetch instructions. No effect except on X86 Linux platforms.
|
||||
# Assumes a very recent gcc-compatible compiler and assembler.
|
||||
# (Gas prefetcht0 support was added around May 1999.)
|
||||
# Empirically the code appears to still run correctly on Pentium II
|
||||
# processors, though with no performance benefit. May not run on other
|
||||
# X86 processors? In some cases this improves performance by
|
||||
# 15% or so.
|
||||
# -DUSE_3DNOW_PREFETCH causes the collector to issue AMD 3DNow style
|
||||
# prefetch instructions. Same restrictions as USE_I686_PREFETCH.
|
||||
# UNTESTED!!
|
||||
# -DGC_USE_LD_WRAP in combination with the gld flags listed in README.linux
|
||||
# causes the collector some system and pthread calls in a more transparent
|
||||
# fashion than the usual macro-based approach. Requires GNU ld, and
|
||||
# currently probably works only with Linux.
|
||||
|
||||
|
||||
|
||||
LIBGC_CFLAGS= -O -DNO_SIGNALS -DSILENT \
|
||||
-DREDIRECT_MALLOC=GC_malloc_uncollectable \
|
||||
-DDONT_ADD_BYTE_AT_END -DALL_INTERIOR_POINTERS
|
||||
# Flags for building libgc.a -- the last two are required.
|
||||
|
||||
CXXFLAGS= $(CFLAGS) -DOPERATOR_NEW_ARRAY
|
||||
AR= ar
|
||||
RANLIB= ranlib
|
||||
|
||||
|
||||
# Redefining srcdir allows object code for the nonPCR version of the collector
|
||||
# to be generated in different directories. In this case, the destination directory
|
||||
# should contain a copy of the original include directory.
|
||||
srcdir = .
|
||||
VPATH = $(srcdir)
|
||||
OBJS= alloc.o reclaim.o allchblk.o misc.o mach_dep.o os_dep.o mark_rts.o headers.o mark.o obj_map.o blacklst.o finalize.o new_hblk.o dbg_mlc.o malloc.o stubborn.o checksums.o solaris_threads.o hpux_irix_threads.o linux_threads.o typd_mlc.o ptr_chck.o mallocx.o solaris_pthreads.o gcj_mlc.o specific.o
|
||||
|
||||
OBJS= alloc.o reclaim.o allchblk.o misc.o mach_dep.o os_dep.o mark_rts.o headers.o mark.o obj_map.o blacklst.o finalize.o new_hblk.o dbg_mlc.o malloc.o stubborn.o checksums.o solaris_threads.o irix_threads.o linux_threads.o typd_mlc.o ptr_chck.o mallocx.o solaris_pthreads.o
|
||||
CSRCS= reclaim.c allchblk.c misc.c alloc.c mach_dep.c os_dep.c mark_rts.c headers.c mark.c obj_map.c pcr_interface.c blacklst.c finalize.c new_hblk.c real_malloc.c dyn_load.c dbg_mlc.c malloc.c stubborn.c checksums.c solaris_threads.c hpux_irix_threads.c linux_threads.c typd_mlc.c ptr_chck.c mallocx.c solaris_pthreads.c gcj_mlc.c specific.c
|
||||
|
||||
CSRCS= reclaim.c allchblk.c misc.c alloc.c mach_dep.c os_dep.c mark_rts.c headers.c mark.c obj_map.c pcr_interface.c blacklst.c finalize.c new_hblk.c real_malloc.c dyn_load.c dbg_mlc.c malloc.c stubborn.c checksums.c solaris_threads.c irix_threads.c linux_threads.c typd_mlc.c ptr_chck.c mallocx.c solaris_pthreads.c
|
||||
|
||||
CORD_SRCS= cord/cordbscs.c cord/cordxtra.c cord/cordprnt.c cord/de.c cord/cordtest.c cord/cord.h cord/ec.h cord/private/cord_pos.h cord/de_win.c cord/de_win.h cord/de_cmds.h cord/de_win.ICO cord/de_win.RC cord/SCOPTIONS.amiga cord/SMakefile.amiga
|
||||
CORD_SRCS= cord/cordbscs.c cord/cordxtra.c cord/cordprnt.c cord/de.c cord/cordtest.c include/cord.h include/ec.h include/private/cord_pos.h cord/de_win.c cord/de_win.h cord/de_cmds.h cord/de_win.ICO cord/de_win.RC cord/SCOPTIONS.amiga cord/SMakefile.amiga
|
||||
|
||||
CORD_OBJS= cord/cordbscs.o cord/cordxtra.o cord/cordprnt.o
|
||||
|
||||
SRCS= $(CSRCS) mips_sgi_mach_dep.s rs6000_mach_dep.s alpha_mach_dep.s \
|
||||
sparc_mach_dep.s gc.h gc_typed.h gc_hdrs.h gc_priv.h gc_private.h \
|
||||
gcconfig.h gc_mark.h include/gc_inl.h include/gc_inline.h gc.man \
|
||||
threadlibs.c if_mach.c if_not_there.c gc_cpp.cc gc_cpp.h weakpointer.h \
|
||||
gcc_support.c mips_ultrix_mach_dep.s include/gc_alloc.h gc_alloc.h \
|
||||
sparc_mach_dep.s include/gc.h include/gc_typed.h \
|
||||
include/private/gc_hdrs.h include/private/gc_priv.h \
|
||||
include/private/gcconfig.h include/private/gc_mark.h \
|
||||
include/gc_inl.h include/gc_inline.h gc.man \
|
||||
threadlibs.c if_mach.c if_not_there.c gc_cpp.cc include/gc_cpp.h \
|
||||
include/weakpointer.h include/private/gc_locks.h \
|
||||
gcc_support.c mips_ultrix_mach_dep.s include/gc_alloc.h \
|
||||
include/new_gc_alloc.h include/javaxfc.h sparc_sunos4_mach_dep.s \
|
||||
solaris_threads.h $(CORD_SRCS)
|
||||
include/private/solaris_threads.h include/gc_backptr.h \
|
||||
hpux_test_and_clear.s include/gc_gcj.h \
|
||||
include/gc_local_alloc.h include/private/dbg_mlc.h \
|
||||
include/private/specific.h powerpc_macosx_mach_dep.s \
|
||||
include/leak_detector.h $(CORD_SRCS)
|
||||
|
||||
OTHER_FILES= Makefile PCR-Makefile OS2_MAKEFILE NT_MAKEFILE BCC_MAKEFILE \
|
||||
README test.c test_cpp.cc setjmp_t.c SMakefile.amiga \
|
||||
SCoptions.amiga README.amiga README.win32 cord/README \
|
||||
cord/gc.h include/gc.h include/gc_typed.h include/cord.h \
|
||||
include/ec.h include/private/cord_pos.h include/private/gcconfig.h \
|
||||
include/private/gc_hdrs.h include/private/gc_priv.h \
|
||||
include/gc_cpp.h README.rs6000 \
|
||||
include/weakpointer.h README.QUICK callprocs pc_excludes \
|
||||
README.rs6000 README.QUICK callprocs pc_excludes \
|
||||
barrett_diagram README.OS2 README.Mac MacProjects.sit.hqx \
|
||||
MacOS.c EMX_MAKEFILE makefile.depend README.debugging \
|
||||
include/gc_cpp.h Mac_files/datastart.c Mac_files/dataend.c \
|
||||
MacOS.c EMX_MAKEFILE README.debugging \
|
||||
Mac_files/datastart.c Mac_files/dataend.c \
|
||||
Mac_files/MacOS_config.h Mac_files/MacOS_Test_config.h \
|
||||
add_gc_prefix.c README.solaris2 README.sgi README.hp README.uts \
|
||||
win32_threads.c NT_THREADS_MAKEFILE gc.mak README.dj Makefile.dj \
|
||||
README.alpha README.linux version.h Makefile.DLLs \
|
||||
WCC_MAKEFILE
|
||||
README.alpha README.linux README.MacOSX version.h Makefile.DLLs \
|
||||
WCC_MAKEFILE nursery.c include/gc_nursery.h include/gc_copy_descr.h
|
||||
|
||||
CORD_INCLUDE_FILES= $(srcdir)/gc.h $(srcdir)/cord/cord.h $(srcdir)/cord/ec.h \
|
||||
$(srcdir)/cord/private/cord_pos.h
|
||||
CORD_INCLUDE_FILES= $(srcdir)/include/gc.h $(srcdir)/include/cord.h \
|
||||
$(srcdir)/include/ec.h $(srcdir)/include/private/cord_pos.h
|
||||
|
||||
UTILS= if_mach$(EXE_SUFFIX) if_not_there$(EXE_SUFFIX)
|
||||
|
||||
|
@ -189,12 +211,12 @@ SPECIALCFLAGS =
|
|||
|
||||
all: gc.a gctest$(EXE_SUFFIX)
|
||||
|
||||
pcr: PCR-Makefile gc_private.h gc_hdrs.h gc.h gcconfig.h mach_dep.o $(SRCS)
|
||||
make -f PCR-Makefile depend
|
||||
make -f PCR-Makefile
|
||||
|
||||
$(OBJS) test.o dyn_load.o dyn_load_sunos53.o: $(srcdir)/gc_priv.h $(srcdir)/gc_hdrs.h $(srcdir)/gc.h \
|
||||
$(srcdir)/gcconfig.h $(srcdir)/gc_typed.h Makefile
|
||||
$(OBJS) test.o dyn_load.o dyn_load_sunos53.o: \
|
||||
$(srcdir)/include/private/gc_priv.h \
|
||||
$(srcdir)/include/private/gc_hdrs.h $(srcdir)/include/private/gc_locks.h \
|
||||
$(srcdir)/include/gc.h \
|
||||
$(srcdir)/include/private/gcconfig.h $(srcdir)/include/gc_typed.h \
|
||||
Makefile
|
||||
# The dependency on Makefile is needed. Changing
|
||||
# options such as -DSILENT affects the size of GC_arrays,
|
||||
# invalidating all .o files that rely on gc_priv.h
|
||||
|
@ -217,17 +239,17 @@ cords: $(CORD_OBJS) cord/cordtest$(EXE_SUFFIX) $(UTILS)
|
|||
./if_not_there on_sparc_sunos5_3 $(AR) ru gc.a $(CORD_OBJS)
|
||||
-./if_not_there on_sparc_sunos5_3 $(RANLIB) gc.a
|
||||
|
||||
gc_cpp.o: $(srcdir)/gc_cpp.cc $(srcdir)/gc_cpp.h $(srcdir)/gc.h Makefile
|
||||
gc_cpp.o: $(srcdir)/gc_cpp.cc $(srcdir)/include/gc_cpp.h $(srcdir)/include/gc.h Makefile
|
||||
$(CXX) -c $(CXXFLAGS) $(srcdir)/gc_cpp.cc
|
||||
|
||||
test_cpp$(EXE_SUFFIX): $(srcdir)/test_cpp.cc $(srcdir)/gc_cpp.h gc_cpp.o $(srcdir)/gc.h \
|
||||
test_cpp$(EXE_SUFFIX): $(srcdir)/test_cpp.cc $(srcdir)/include/gc_cpp.h gc_cpp.o $(srcdir)/include/gc.h \
|
||||
base_lib $(UTILS)
|
||||
rm -f test_cpp test_cpp$(EXE_SUFFIX)
|
||||
./if_mach HP_PA "" $(CXX) $(CXXFLAGS) -o test_cpp $(srcdir)/test_cpp.cc gc_cpp.o gc.a -ldld
|
||||
./if_not_there test_cpp$(EXE_SUFFIX) $(CXXLD) $(CXXFLAGS) -o test_cpp$(EXE_SUFFIX) $(srcdir)/test_cpp.cc gc_cpp.o gc.a
|
||||
rm -f test_cpp
|
||||
|
||||
c++: gc_cpp.o $(srcdir)/gc_cpp.h test_cpp$(EXE_SUFFIX)
|
||||
c++: gc_cpp.o $(srcdir)/include/gc_cpp.h test_cpp$(EXE_SUFFIX)
|
||||
rm -f on_sparc_sunos5_4
|
||||
./if_mach SPARC SUNOS5 touch on_sparc_sunos5_4
|
||||
./if_mach SPARC SUNOS5 $(AR) rus gc.a gc_cpp.o
|
||||
|
@ -259,12 +281,14 @@ liblinuxgc.so: $(OBJS) dyn_load.o
|
|||
gcc -shared -o liblinuxgc.so $(OBJS) dyn_load.o -lo
|
||||
ln liblinuxgc.so libgc.so
|
||||
|
||||
mach_dep.o: $(srcdir)/mach_dep.c $(srcdir)/mips_sgi_mach_dep.s $(srcdir)/mips_ultrix_mach_dep.s $(srcdir)/rs6000_mach_dep.s $(UTILS)
|
||||
mach_dep.o: $(srcdir)/mach_dep.c $(srcdir)/mips_sgi_mach_dep.s $(srcdir)/mips_ultrix_mach_dep.s \
|
||||
$(srcdir)/rs6000_mach_dep.s $(srcdir)/powerpc_macosx_mach_dep.s $(UTILS)
|
||||
rm -f mach_dep.o
|
||||
./if_mach MIPS IRIX5 $(AS) -o mach_dep.o $(srcdir)/mips_sgi_mach_dep.s
|
||||
./if_mach MIPS RISCOS $(AS) -o mach_dep.o $(srcdir)/mips_ultrix_mach_dep.s
|
||||
./if_mach MIPS ULTRIX $(AS) -o mach_dep.o $(srcdir)/mips_ultrix_mach_dep.s
|
||||
./if_mach RS6000 "" $(AS) -o mach_dep.o $(srcdir)/rs6000_mach_dep.s
|
||||
./if_mach POWERPC MACOSX $(AS) -o mach_dep.o $(srcdir)/powerpc_macosx_mach_dep.s
|
||||
./if_mach ALPHA "" $(AS) -o mach_dep.o $(srcdir)/alpha_mach_dep.s
|
||||
./if_mach SPARC SUNOS5 $(AS) -o mach_dep.o $(srcdir)/sparc_mach_dep.s
|
||||
./if_mach SPARC SUNOS4 $(AS) -o mach_dep.o $(srcdir)/sparc_sunos4_mach_dep.s
|
||||
|
@ -312,20 +336,17 @@ cord/de$(EXE_SUFFIX): $(srcdir)/cord/de.c cord/cordbscs.o cord/cordxtra.o gc.a $
|
|||
./if_mach ALPHA LINUX $(CC) $(CFLAGS) -o cord/de $(srcdir)/cord/de.c cord/cordbscs.o cord/cordxtra.o gc.a -lcurses
|
||||
./if_not_there cord/de$(EXE_SUFFIX) $(CC) $(CFLAGS) -o cord/de$(EXE_SUFFIX) $(srcdir)/cord/de.c cord/cordbscs.o cord/cordxtra.o gc.a $(CURSES)
|
||||
|
||||
if_mach$(EXE_SUFFIX): $(srcdir)/if_mach.c $(srcdir)/gcconfig.h
|
||||
if_mach$(EXE_SUFFIX): $(srcdir)/if_mach.c $(srcdir)/include/private/gcconfig.h
|
||||
rm -f if_mach if_mach$(EXE_SUFFIX)
|
||||
$(CC) $(CFLAGS) -o if_mach $(srcdir)/if_mach.c
|
||||
rm -f if_mach
|
||||
|
||||
threadlibs$(EXE_SUFFIX): $(srcdir)/threadlibs.c $(srcdir)/gcconfig.h Makefile
|
||||
threadlibs$(EXE_SUFFIX): $(srcdir)/threadlibs.c $(srcdir)include/private/gcconfig.h Makefile
|
||||
rm -f threadlibs threadlibs$(EXE_SUFFIX)
|
||||
$(CC) $(CFLAGS) -o threadlibs $(srcdir)/threadlibs.c
|
||||
rm -f threadlibs
|
||||
|
||||
if_not_there$(EXE_SUFFIX): $(srcdir)/if_not_there.c
|
||||
rm -f if_not_there if_not_there$(EXE_SUFFIX)
|
||||
$(CC) $(CFLAGS) -o if_not_there $(srcdir)/if_not_there.c
|
||||
rm -f if_not_there
|
||||
|
||||
# Clean removes *.o several times,
|
||||
# because as the first one doesn't seem to get them all!
|
||||
|
@ -352,7 +373,7 @@ gctest$(EXE_SUFFIX): test.o gc.a if_mach$(EXE_SUFFIX) if_not_there$(EXE_SUFFIX)
|
|||
# If an optimized setjmp_test generates a segmentation fault,
|
||||
# odds are your compiler is broken. Gctest may still work.
|
||||
# Try compiling setjmp_t.c unoptimized.
|
||||
setjmp_test$(EXE_SUFFIX): $(srcdir)/setjmp_t.c $(srcdir)/gc.h \
|
||||
setjmp_test$(EXE_SUFFIX): $(srcdir)/setjmp_t.c $(srcdir)/include/gc.h \
|
||||
if_mach$(EXE_SUFFIX) if_not_there$(EXE_SUFFIX)
|
||||
rm -f setjmp_test$(EXE_SUFFIX)
|
||||
$(CC) $(CFLAGS) -o setjmp_test $(srcdir)/setjmp_t.c
|
||||
|
@ -377,21 +398,6 @@ gc.tar: $(SRCS) $(OTHER_FILES) add_gc_prefix
|
|||
pc_gc.tar: $(SRCS) $(OTHER_FILES)
|
||||
tar cvfX pc_gc.tar pc_excludes $(SRCS) $(OTHER_FILES)
|
||||
|
||||
floppy: pc_gc.tar
|
||||
-mmd a:/cord
|
||||
-mmd a:/cord/private
|
||||
-mmd a:/include
|
||||
-mmd a:/include/private
|
||||
mkdir /tmp/pc_gc
|
||||
cat pc_gc.tar | (cd /tmp/pc_gc; tar xvf -)
|
||||
-mcopy -tmn /tmp/pc_gc/* a:
|
||||
-mcopy -tmn /tmp/pc_gc/cord/* a:/cord
|
||||
-mcopy -mn /tmp/pc_gc/cord/de_win.ICO a:/cord
|
||||
-mcopy -tmn /tmp/pc_gc/cord/private/* a:/cord/private
|
||||
-mcopy -tmn /tmp/pc_gc/include/* a:/include
|
||||
-mcopy -tmn /tmp/pc_gc/include/private/* a:/include/private
|
||||
rm -r /tmp/pc_gc
|
||||
|
||||
gc.tar.Z: gc.tar
|
||||
compress gc.tar
|
||||
|
||||
|
@ -408,9 +414,6 @@ ABSDIR = `pwd`
|
|||
gctest_dyn_link: test.o libgc.so
|
||||
$(CC) -L$(ABSDIR) -R$(ABSDIR) -o gctest_dyn_link test.o -lgc -ldl -lthread
|
||||
|
||||
gctest_irix_dyn_link: test.o libirixgc.so
|
||||
$(CC) -L$(ABSDIR) -o gctest_irix_dyn_link test.o -lirixgc
|
||||
|
||||
test_dll.o: test.c libgc_globals.h
|
||||
$(CC) $(CFLAGS) -DGC_USE_DLL -c test.c -o test_dll.o
|
||||
|
||||
|
@ -422,15 +425,3 @@ SYM_PREFIX-libgc=GC
|
|||
# Uncomment the following line to build a GNU win32 DLL
|
||||
# include Makefile.DLLs
|
||||
|
||||
reserved_namespace: $(SRCS)
|
||||
for file in $(SRCS) test.c test_cpp.cc; do \
|
||||
sed s/GC_/_GC_/g < $$file > tmp; \
|
||||
cp tmp $$file; \
|
||||
done
|
||||
|
||||
user_namespace: $(SRCS)
|
||||
for file in $(SRCS) test.c test_cpp.cc; do \
|
||||
sed s/_GC_/GC_/g < $$file > tmp; \
|
||||
cp tmp $$file; \
|
||||
done
|
||||
|
||||
|
|
|
@ -102,22 +102,17 @@ MULTIDIRS =
|
|||
MULTISUBDIR =
|
||||
MULTIDO = true
|
||||
MULTICLEAN = true
|
||||
@USE_LIBDIR_TRUE@toolexeclibdir = \
|
||||
@USE_LIBDIR_TRUE@$(libdir)$(MULTISUBDIR)
|
||||
@USE_LIBDIR_FALSE@toolexeclibdir = \
|
||||
@USE_LIBDIR_FALSE@$(toolexecdir)/lib$(MULTISUBDIR)
|
||||
@USE_LIBDIR_FALSE@toolexecdir = \
|
||||
@USE_LIBDIR_FALSE@$(exec_prefix)/$(target_alias)
|
||||
@USE_LIBDIR_TRUE@toolexeclibdir = @USE_LIBDIR_TRUE@$(libdir)$(MULTISUBDIR)
|
||||
@USE_LIBDIR_FALSE@toolexeclibdir = @USE_LIBDIR_FALSE@$(toolexecdir)/lib$(MULTISUBDIR)
|
||||
@USE_LIBDIR_FALSE@toolexecdir = @USE_LIBDIR_FALSE@$(exec_prefix)/$(target_alias)
|
||||
|
||||
toolexeclib_LTLIBRARIES = $(target_all)
|
||||
EXTRA_LTLIBRARIES = libgcjgc.la
|
||||
libgcjgc_la_SOURCES = allchblk.c alloc.c blacklst.c checksums.c \
|
||||
gcconfig.h dbg_mlc.c dyn_load.c finalize.c gc.h gc_alloc.h gc_cpp.h \
|
||||
gc_hdrs.h gc_mark.h gc_priv.h gc_private.h gc_typed.h gcj_mlc.c headers.c \
|
||||
hpux_irix_threads.c linux_threads.c malloc.c mallocx.c mark.c mark_rts.c \
|
||||
misc.c new_hblk.c obj_map.c os_dep.c pcr_interface.c ptr_chck.c \
|
||||
real_malloc.c reclaim.c solaris_pthreads.c solaris_threads.c \
|
||||
solaris_threads.h stubborn.c typd_mlc.c version.h weakpointer.h
|
||||
libgcjgc_la_SOURCES = allchblk.c alloc.c blacklst.c checksums.c dbg_mlc.c \
|
||||
dyn_load.c finalize.c gc_dlopen.c gcj_mlc.c headers.c irix_threads.c \
|
||||
linux_threads.c malloc.c mallocx.c mark.c mark_rts.c misc.c new_hblk.c \
|
||||
obj_map.c os_dep.c pcr_interface.c ptr_chck.c real_malloc.c reclaim.c \
|
||||
solaris_pthreads.c solaris_threads.c specific.c stubborn.c typd_mlc.c`
|
||||
|
||||
|
||||
# Include THREADLIBS here to ensure that the correct versions of
|
||||
|
@ -126,9 +121,10 @@ libgcjgc_la_LIBADD = @addobjs@ $(THREADLIBS)
|
|||
libgcjgc_la_DEPENDENCIES = @addobjs@
|
||||
libgcjgc_la_LDFLAGS = -version-info 1:1:0 -rpath $(toolexeclibdir)
|
||||
|
||||
EXTRA_libgcjgc_la_SOURCES = alpha_mach_dep.s mips_sgi_mach_dep.s \
|
||||
mips_ultrix_mach_dep.s rs6000_mach_dep.s sparc_mach_dep.s \
|
||||
sparc_sunos4_mach_dep.s mach_dep.c ecos.cc
|
||||
EXTRA_libgcjgc_la_SOURCES = alpha_mach_dep.s hpux_test_and_clear.s \
|
||||
mips_sgi_mach_dep.s mips_ultrix_mach_dep.s powerpc_macosx_mach_dep.s \
|
||||
rs6000_mach_dep.s sparc_mach_dep.s sparc_netbsd_mach_dep.s \
|
||||
sparc_sunos4_mach_dep.s
|
||||
|
||||
|
||||
AM_CXXFLAGS = @BOEHM_GC_CFLAGS@
|
||||
|
@ -206,19 +202,14 @@ CPPFLAGS = @CPPFLAGS@
|
|||
LDFLAGS = @LDFLAGS@
|
||||
LIBS = @LIBS@
|
||||
libgcjgc_la_OBJECTS = allchblk.lo alloc.lo blacklst.lo checksums.lo \
|
||||
dbg_mlc.lo dyn_load.lo finalize.lo gcj_mlc.lo headers.lo \
|
||||
hpux_irix_threads.lo linux_threads.lo malloc.lo mallocx.lo mark.lo \
|
||||
dbg_mlc.lo dyn_load.lo finalize.lo gc_dlopen.lo gcj_mlc.lo headers.lo \
|
||||
irix_threads.lo linux_threads.lo malloc.lo mallocx.lo mark.lo \
|
||||
mark_rts.lo misc.lo new_hblk.lo obj_map.lo os_dep.lo pcr_interface.lo \
|
||||
ptr_chck.lo real_malloc.lo reclaim.lo solaris_pthreads.lo \
|
||||
solaris_threads.lo stubborn.lo typd_mlc.lo
|
||||
solaris_threads.lo specific.lo stubborn.lo
|
||||
check_PROGRAMS = gctest$(EXEEXT)
|
||||
gctest_OBJECTS = test.$(OBJEXT)
|
||||
gctest_DEPENDENCIES = ./libgcjgc.la
|
||||
CXXFLAGS = @CXXFLAGS@
|
||||
CXXCOMPILE = $(CXX) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
|
||||
LTCXXCOMPILE = $(LIBTOOL) --mode=compile $(CXX) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
|
||||
CXXLD = $(CXX)
|
||||
CXXLINK = $(LIBTOOL) --mode=link $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(LDFLAGS) -o $@
|
||||
CFLAGS = @CFLAGS@
|
||||
COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
|
||||
CCLD = $(CC)
|
||||
|
@ -228,14 +219,14 @@ aclocal.m4 configure configure.in
|
|||
|
||||
DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST)
|
||||
|
||||
TAR = tar
|
||||
TAR = gtar
|
||||
GZIP_ENV = --best
|
||||
SOURCES = $(libgcjgc_la_SOURCES) $(EXTRA_libgcjgc_la_SOURCES) $(gctest_SOURCES)
|
||||
OBJECTS = $(libgcjgc_la_OBJECTS) $(gctest_OBJECTS)
|
||||
|
||||
all: all-redirect
|
||||
.SUFFIXES:
|
||||
.SUFFIXES: .S .c .cc .lo .o .obj .s
|
||||
.SUFFIXES: .S .c .lo .o .obj .s
|
||||
$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4)
|
||||
cd $(top_srcdir) && $(AUTOMAKE) --cygnus Makefile
|
||||
|
||||
|
@ -332,12 +323,6 @@ maintainer-clean-checkPROGRAMS:
|
|||
gctest$(EXEEXT): $(gctest_OBJECTS) $(gctest_DEPENDENCIES)
|
||||
@rm -f gctest$(EXEEXT)
|
||||
$(LINK) $(gctest_LDFLAGS) $(gctest_OBJECTS) $(gctest_LDADD) $(LIBS)
|
||||
.cc.o:
|
||||
$(CXXCOMPILE) -c $<
|
||||
.cc.obj:
|
||||
$(CXXCOMPILE) -c `cygpath -w $<`
|
||||
.cc.lo:
|
||||
$(LTCXXCOMPILE) -c $<
|
||||
|
||||
tags: TAGS
|
||||
|
||||
|
@ -409,7 +394,7 @@ distdir: $(DISTFILES)
|
|||
@for file in $(DISTFILES); do \
|
||||
if test -f $$file; then d=.; else d=$(srcdir); fi; \
|
||||
if test -d $$d/$$file; then \
|
||||
cp -pr $$/$$file $(distdir)/$$file; \
|
||||
cp -pr $$d/$$file $(distdir)/$$file; \
|
||||
else \
|
||||
test -f $(distdir)/$$file \
|
||||
|| ln $$d/$$file $(distdir)/$$file 2> /dev/null \
|
||||
|
@ -526,7 +511,8 @@ install-am install uninstall-am uninstall all-redirect all-am all \
|
|||
installdirs mostlyclean-generic distclean-generic clean-generic \
|
||||
maintainer-clean-generic clean mostlyclean distclean maintainer-clean
|
||||
|
||||
$(all_objs) : gcconfig.h gc_priv.h gc_hdrs.h gc.h gc_mark.h
|
||||
$(all_objs) : include/private/gcconfig.h include/private/gc_priv.h \
|
||||
include/private/gc_hdrs.h include/gc.h include/gc_gcj.h include/gc_mark.h
|
||||
|
||||
.s.lo:
|
||||
$(LTCOMPILE) -Wp,-P -x assembler-with-cpp -c $<
|
||||
|
|
|
@ -10,29 +10,29 @@ OBJS= alloc.obj reclaim.obj allchblk.obj misc.obj mach_dep.obj os_dep.obj mark_r
|
|||
all: gctest.exe cord\de.exe test_cpp.exe
|
||||
|
||||
.c.obj:
|
||||
$(cc) $(cdebug) $(cflags) $(cvars) -DSILENT -DALL_INTERIOR_POINTERS -D__STDC__ $*.c /Fo$*.obj
|
||||
$(cc) $(cdebug) $(cflags) $(cvars) -Iinclude -DSILENT -DALL_INTERIOR_POINTERS -D__STDC__ -DGC_NOT_DLL $*.c /Fo$*.obj
|
||||
|
||||
.cpp.obj:
|
||||
$(cc) $(cdebug) $(cflags) $(cvars) -DSILENT -DALL_INTERIOR_POINTERS $*.CPP /Fo$*.obj
|
||||
$(cc) $(cdebug) $(cflags) $(cvars) -Iinclude -DSILENT -DALL_INTERIOR_POINTERS -DGC_NOT_DLL $*.CPP /Fo$*.obj
|
||||
|
||||
$(OBJS) test.obj: gc_priv.h gc_hdrs.h gc.h
|
||||
$(OBJS) tests\test.obj: include\private\gc_priv.h include\private\gc_hdrs.h include\gc.h include\private\gcconfig.h include\private\gc_locks.h include\private\gc_pmark.h include\gc_mark.h
|
||||
|
||||
gc.lib: $(OBJS)
|
||||
lib /MACHINE:i386 /out:gc.lib $(OBJS)
|
||||
# The original NT SDK used lib32 instead of lib
|
||||
|
||||
gctest.exe: test.obj gc.lib
|
||||
gctest.exe: tests\test.obj gc.lib
|
||||
# The following works for win32 debugging. For win32s debugging use debugtype:coff
|
||||
# and add mapsympe line.
|
||||
# This produces a "GUI" applications that opens no windows and writes to the log file
|
||||
# "gc.log". This is done to make the result runnable under win32s.
|
||||
$(link) -debug:full -debugtype:cv $(guiflags) -stack:131072 -out:$*.exe test.obj $(guilibs) gc.lib
|
||||
$(link) -debug:full -debugtype:cv $(guiflags) -stack:131072 -out:$*.exe tests\test.obj $(guilibs) gc.lib
|
||||
# mapsympe -n -o gctest.sym gctest.exe
|
||||
|
||||
cord\de_win.rbj: cord\de_win.res
|
||||
cvtres -$(CPU) cord\de_win.res -o cord\de_win.rbj
|
||||
|
||||
cord\de.obj cord\de_win.obj: cord\cord.h cord\private\cord_pos.h cord\de_win.h cord\de_cmds.h
|
||||
cord\de.obj cord\de_win.obj: include\cord.h include\private\cord_pos.h cord\de_win.h cord\de_cmds.h
|
||||
|
||||
cord\de_win.res: cord\de_win.rc cord\de_win.h cord\de_cmds.h
|
||||
$(rc) $(rcvars) -r -fo cord\de_win.res $(cvars) cord\de_win.rc
|
||||
|
@ -41,18 +41,18 @@ cord\de_win.res: cord\de_win.rc cord\de_win.h cord\de_cmds.h
|
|||
cord\de.exe: cord\cordbscs.obj cord\cordxtra.obj cord\de.obj cord\de_win.obj cord\de_win.rbj gc.lib
|
||||
$(link) -debug:full -debugtype:cv $(guiflags) -stack:16384 -out:cord\de.exe cord\cordbscs.obj cord\cordxtra.obj cord\de.obj cord\de_win.obj cord\de_win.rbj gc.lib $(guilibs)
|
||||
|
||||
gc_cpp.obj: gc_cpp.h gc.h
|
||||
gc_cpp.obj: include\gc_cpp.h include\gc.h
|
||||
|
||||
gc_cpp.cpp: gc_cpp.cc
|
||||
copy gc_cpp.cc gc_cpp.cpp
|
||||
|
||||
test_cpp.cpp: test_cpp.cc
|
||||
copy test_cpp.cc test_cpp.cpp
|
||||
test_cpp.cpp: tests\test_cpp.cc
|
||||
copy tests\test_cpp.cc test_cpp.cpp
|
||||
|
||||
# This generates the C++ test executable. The executable expects
|
||||
# a single numeric argument, which is the number of iterations.
|
||||
# The output appears in the file "gc.log".
|
||||
test_cpp.exe: test_cpp.obj gc_cpp.h gc.h gc.lib
|
||||
test_cpp.exe: test_cpp.obj include\gc_cpp.h include\gc.h gc.lib
|
||||
$(link) -debug:full -debugtype:cv $(guiflags) -stack:16384 -out:test_cpp.exe test_cpp.obj gc.lib $(guilibs)
|
||||
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ CFLAGS= /O /Q /DSILENT /DSMALL_CONFIG /DALL_INTERIOR_POINTERS
|
|||
|
||||
all: $(OBJS) gctest.exe cord\cordtest.exe
|
||||
|
||||
$(OBJS) test.obj: gc_priv.h gc_hdrs.h gc.h
|
||||
$(OBJS) test.obj: include\private\gc_priv.h include\private\gc_hdrs.h include\gc.h include\private\gcconfig.h
|
||||
|
||||
## ERASE THE LIB FIRST - if it is already there then this command will fail
|
||||
## (make sure its there or erase will fail!)
|
||||
|
@ -32,14 +32,14 @@ mach_dep.obj: mach_dep.c
|
|||
gctest.exe: test.obj gc.lib
|
||||
$(CC) $(CFLAGS) /B"/STACK:524288" /Fegctest test.obj gc.lib
|
||||
|
||||
cord\cordbscs.obj: cord\cordbscs.c cord\cord.h cord\private\cord_pos.h
|
||||
cord\cordbscs.obj: cord\cordbscs.c include\cord.h include\private\cord_pos.h
|
||||
$(CC) $(CFLAGS) /C /Focord\cordbscs cord\cordbscs.c
|
||||
|
||||
cord\cordxtra.obj: cord\cordxtra.c cord\cord.h cord\private\cord_pos.h cord\ec.h
|
||||
cord\cordxtra.obj: cord\cordxtra.c include\cord.h include\private\cord_pos.h include\ec.h
|
||||
$(CC) $(CFLAGS) /C /Focord\cordxtra cord\cordxtra.c
|
||||
|
||||
cord\cordprnt.obj: cord\cordprnt.c cord\cord.h cord\private\cord_pos.h cord\ec.h
|
||||
cord\cordprnt.obj: cord\cordprnt.c include\cord.h include\private\cord_pos.h include\ec.h
|
||||
$(CC) $(CFLAGS) /C /Focord\cordprnt cord\cordprnt.c
|
||||
|
||||
cord\cordtest.exe: cord\cordtest.c cord\cord.h cord\private\cord_pos.h cord\ec.h $(CORDOBJS) gc.lib
|
||||
cord\cordtest.exe: cord\cordtest.c include\cord.h include\private\cord_pos.h include\ec.h $(CORDOBJS) gc.lib
|
||||
$(CC) $(CFLAGS) /B"/STACK:65536" /Fecord\cordtest cord\cordtest.c gc.lib $(CORDOBJS)
|
||||
|
|
1646
boehm-gc/README
1646
boehm-gc/README
File diff suppressed because it is too large
Load diff
|
@ -1,385 +0,0 @@
|
|||
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 <ansi_prefix.mac.h>
|
||||
#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 <ansi_prefix.mac.h>
|
||||
#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 <gc.h> 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
|
|
@ -1,6 +0,0 @@
|
|||
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.
|
|
@ -1,43 +0,0 @@
|
|||
Copyright 1988, 1989 Hans-J. Boehm, Alan J. Demers
|
||||
Copyright (c) 1991-1995 by Xerox Corporation. All rights reserved.
|
||||
Copyright (c) 1996-1999 by Silicon Graphics. All rights reserved.
|
||||
Copyright (c) 1999 by Hewlett-Packard. 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.
|
||||
|
||||
|
||||
For more details and the names of other contributors, see the
|
||||
README file and gc.h. This file describes typical use of
|
||||
the collector on a machine that is already supported.
|
||||
|
||||
INSTALLATION:
|
||||
Under UN*X, type "make test". Under OS/2 or Windows NT, copy the
|
||||
appropriate makefile to MAKEFILE, read it, and type "nmake test".
|
||||
Read the machine specific README if one exists. The only way to
|
||||
develop code with the collector for Windows 3.1 is to develop under
|
||||
Windows NT, and then to use win32S.
|
||||
|
||||
If you wish to use the cord (structured string) library type
|
||||
"make cords". (This requires an ANSI C compiler. You may need
|
||||
to redefine CC in the Makefile.)
|
||||
|
||||
If you wish to use the collector from C++, type
|
||||
"make c++". These add further files to gc.a and to the include
|
||||
subdirectory. See cord/cord.h and gc_c++.h.
|
||||
|
||||
TYPICAL USE:
|
||||
Include "gc.h" from this directory. Link against the appropriate library
|
||||
("gc.a" under UN*X). Replace calls to malloc by calls to GC_MALLOC,
|
||||
and calls to realloc by calls to GC_REALLOC. If the object is known
|
||||
to never contain pointers, use GC_MALLOC_ATOMIC instead of
|
||||
GC_MALLOC.
|
||||
|
||||
Define GC_DEBUG before including gc.h for additional checking.
|
||||
|
|
@ -1,22 +0,0 @@
|
|||
Should work under OSF/1 and Linux. Currently no VMS or NT support, though
|
||||
the latter shouldn't be hard.
|
||||
|
||||
Incremental gc not yet supported under Linux because signal handler
|
||||
for SIGSEGV can't get a hold of fault address. Dynamic library support
|
||||
is also missing from Linux/alpha, probably for no good reason.
|
||||
|
||||
Currently there is no thread support in the standard distribution. There
|
||||
exists a separate port to DEC Unix pthreads. It should be possible to
|
||||
port the X86 Linux threads support to Alpha without much trouble.
|
||||
|
||||
If you get asssembler errors, be sure to read the first few lines of the
|
||||
Makefile.
|
||||
|
||||
From Philippe Queinnec:
|
||||
|
||||
System: DEC/Alpha OSF1 v3.2, vendor cc
|
||||
Problem: can't link if libgc has been compiled with "cc -std1".
|
||||
It works if the library has been compiled with either gcc or "cc"
|
||||
alone. The problem is because the variable "end" is not defined if
|
||||
compiling in std1 mode (see man ld).
|
||||
Proposed fix: none. Don't use cc -std1 !
|
|
@ -1,180 +0,0 @@
|
|||
===========================================================================
|
||||
Martin Tauchmann's notes (1-Apr-99)
|
||||
===========================================================================
|
||||
|
||||
Works now, also with the GNU-C compiler V2.7.2.1. <ftp://ftp.unina.it/pub/amiga/geekgadgets/amiga/m68k/snapshots/971125/amiga-bin/>
|
||||
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) <http://cognac.informatik.uni-kl.de/download/index.html>
|
||||
|
||||
|
||||
TESTED WITH HARDWARE
|
||||
|
||||
MC68030
|
||||
|
||||
|
||||
CONTACT
|
||||
|
||||
Please, contact me at <martintauchmann@bigfoot.com>, when you change the
|
||||
Amiga port. <http://martintauchmann.home.pages.de>
|
||||
|
||||
===========================================================================
|
||||
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<one>, 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.
|
||||
|
|
@ -1,68 +0,0 @@
|
|||
Debugging suggestions:
|
||||
|
||||
****If you get a segmentation fault or bus error while debugging with a debugger:
|
||||
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 preferable to tell the debugger to ignore SIGBUS and SIGSEGV ("handle" in gdb, "ignore" 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. I 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 you get warning messages informing you that the collector needed to allocate blacklisted blocks:
|
||||
|
||||
0) 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.)
|
||||
|
||||
1) 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.
|
||||
|
||||
2) If the large blocks are allocated with realloc, I 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);
|
||||
}
|
||||
|
||||
3) 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 pointerfree regions of bitmaps, etc. Sometimes the problem can be solved with trivial changes of encoding in certain values. It is possible, though not pleasant, to identify the source of the bogus pointers by setting a breakpoint in GC_add_to_black_list_stack, and looking at the value of current_p in the GC_mark_from_mark_stack frame. Current_p contains the address of the bogus pointer.
|
||||
|
||||
4) 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).
|
||||
|
||||
|
||||
****If the collector dies in GC_malloc while trying to remove a free list element:
|
||||
|
||||
1) With > 99% probability, you wrote past the end of an allocated object. Try setting GC_DEBUG and using the debugging facilities in gc.h.
|
||||
|
||||
|
||||
****If the heap grows too much:
|
||||
|
||||
1) Consider using GC_malloc_atomic for objects containing nonpointers. This is especially important for large arrays containg compressed data, pseudo-random numbers, and the like. (This isn't all that likely to solve your problem, but it's a useful and easy optimization anyway, and this is a good time to try it.) If you allocate large objects containg only one or two pointers at the beginning, either try the typed allocation primitives is gc.h, or separate out the pointerfree component.
|
||||
2) If you are using the collector in its default mode, with interior pointer recognition enabled, consider using GC_malloc_ignore_off_page to allocate large objects. (See gc.h and above for details. Large means > 100K in most environments.)
|
||||
3) GC_print_block_list() will print a list of all currently allocated heap blocks and what size objects they contain. GC_print_hblkfreelist() will print a list of free heap blocks, and whether they are blacklisted. GC_dump calls both of these, and also prints information about heap sections, and root segments.
|
||||
4) Build the collector with -DKEEP_BACK_PTRS, and use the backptr.h
|
||||
interface to determine why objects are being retained.
|
||||
|
||||
|
||||
****If the collector appears to be losing objects:
|
||||
|
||||
1) Replace all calls to GC_malloc_atomic and typed allocation by GC_malloc calls. If this fixes the problem, gradually reinsert your optimizations.
|
||||
2) You may also want to try the safe(r) pointer manipulation primitives in gc.h. But those are hard to use until the preprocessor becomes available.
|
||||
3) Try using the GC_DEBUG facilities. This is less likely to be successful here than if the collector crashes.
|
||||
[The rest of these are primarily for wizards. You shouldn't need them unless you're doing something really strange, or debugging a collector port.]
|
||||
4) Don't turn on incremental collection. If that fixes the problem, suspect a bug in the dirty bit implementation. Try compiling with -DCHECKSUMS to check for modified, but supposedly clean, pages.
|
||||
5) On a SPARC, in a single-threaded environment, GC_print_callers(GC_arrays._last_stack) prints a cryptic stack trace as of the time of the last collection. (You will need a debugger to decipher the result.) The question to ask then is "why should this object have been accessible at the time of the last collection? Where was a pointer to it stored?". This facility should be easy to add for some other collector ports (namely if it's easy to traverse stack frames), but will be hard for others.
|
||||
6) "print *GC_find_header(p)" in dbx or gdb will print the garbage collector block header information associated with the object p (e.g. object size, etc.)
|
||||
7) GC_is_marked(p) determines whether p is the base address of a marked object. Note that objects allocated since the last collection should not be marked, and that unmarked objects are reclaimed incrementally. It's usually most interesting to set a breakpoint in GC_finish_collection and then to determine how much of the damaged data structure is marked at that point.
|
||||
8) Look at the tracing facility in mark.c. (Ignore this suggestion unless you are very familiar with collector internals.)
|
||||
9) [From Melissa O'Neill:]
|
||||
If you're using multiple threads, double check that all thread
|
||||
creation goes through the GC_ wrapper functions rather than
|
||||
calling the thread-creation functions themselves (e.g.,
|
||||
GC_pthread_create rather than pthread_create). The gc.h header
|
||||
file includes suitable preprocessor definitions to accomplish
|
||||
this mapping transparently -- the question is: are you including
|
||||
it in all the modules that create threads?
|
||||
|
||||
|
||||
|
|
@ -1,12 +0,0 @@
|
|||
[Original version supplied by Xiaokun Zhu <xiaokun@aero.gla.ac.uk>]
|
||||
[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.
|
||||
|
|
@ -1,16 +0,0 @@
|
|||
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.
|
||||
|
||||
Thread support for HP/UX 11 Pthreads was also recently added. It is still
|
||||
flakey in this release. (It has only been tested on a uniprocessor. Even
|
||||
there some fraction of thread creation calls fail with a not-yet-understood
|
||||
error return from sem_wait.)
|
|
@ -1,68 +0,0 @@
|
|||
See README.alpha for Linux on DEC AXP info.
|
||||
|
||||
This file applies mostly to Linux/Intel IA32. Ports to Linux on an M68K
|
||||
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.
|
||||
|
||||
Incremental GC is supported on Intel IA32 and M68K.
|
||||
|
||||
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 with Linux threads. We have seen
|
||||
intermittent hangs in sem_wait. So far we have been unable to reproduce
|
||||
these unless the process was being debugged or traced. Thus it's
|
||||
possible that the only real issue is that the debugger loses
|
||||
signals on rare occasions.
|
||||
|
||||
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 (which are included in libc6).
|
||||
|
||||
The collector relies on some implementation details of the LinuxThreads
|
||||
package. It is unlikely that this code will work on other
|
||||
pthread implementations (in particular it will *not* work with
|
||||
MIT pthreads).
|
||||
|
||||
2) You must compile the collector with -DLINUX_THREADS and -D_REENTRANT
|
||||
specified in the Makefile.
|
||||
|
||||
3a) Every file that makes thread calls should define 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 with
|
||||
-DUSE_LD_WRAP, and to link the final program with
|
||||
|
||||
(for ld) --wrap read --wrap dlopen --wrap pthread_create \
|
||||
--wrap pthread_join --wrap pthread_sigmask
|
||||
|
||||
(for gcc) -Wl,--wrap -Wl,read -Wl,--wrap -Wl,dlopen -Wl,--wrap \
|
||||
-Wl,pthread_create -Wl,--wrap -Wl,pthread_join -Wl,--wrap \
|
||||
-Wl,pthread_sigmask
|
||||
|
||||
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 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.)
|
|
@ -1,9 +0,0 @@
|
|||
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 ...)
|
|
@ -1,41 +0,0 @@
|
|||
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 -DIRIX_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.
|
||||
|
|
@ -1,62 +0,0 @@
|
|||
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 -DSOLARIS_THREADS 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
|
||||
SOLARIS_THREADS 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.
|
||||
|
||||
If you are using the Pthreads interface, also define _SOLARIS_PTHREADS.
|
||||
|
||||
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, it is necessary to call GC_thr_init explicitly before forking the
|
||||
first thread. (This avoids a deadlock arising from calling GC_thr_init
|
||||
with the allocation lock held.)
|
||||
|
||||
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.)
|
|
@ -1,2 +0,0 @@
|
|||
Alistair Crooks supplied the port. He used Lexa C version 2.1.3 with
|
||||
-Xa to compile.
|
|
@ -1,149 +0,0 @@
|
|||
The collector has only been compiled under Windows NT, with the
|
||||
original Microsoft SDK, with Visual C++ 2.0 and later, with
|
||||
the GNU win32 environment, with Borland 4.5, and recently with
|
||||
Watcom C.
|
||||
|
||||
It 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.)
|
||||
|
||||
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 will 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 <cr> 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.)
|
||||
|
||||
For Microsoft development tools, rename NT_MAKEFILE as
|
||||
MAKEFILE. (Make sure that the CPU environment variable is defined
|
||||
to be i386.)
|
||||
|
||||
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. The GNU-win32 port is
|
||||
believed to work only for b18, not b19, probably dues to linker changes
|
||||
in b19. This is probably fixable with a different definition of
|
||||
DATASTART and DATAEND in gcconfig.h.
|
||||
|
||||
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 support was recently added. This is
|
||||
currently pretty simpleminded. 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,
|
||||
which is the default for win32. If you need incremental collection,
|
||||
undefine SMALL_CONFIG.
|
||||
|
||||
Incremental collection is not supported under win32s, and it may not
|
||||
be possible to do so. However, win32 applications that attempt to use
|
||||
incremental collection should continue to run, since the
|
||||
collector detects if it's running under win32s and turns calls to
|
||||
GC_enable_incremental() into noops.
|
||||
|
||||
James Clark has contributed the necessary code to support win32 threads.
|
||||
This code is known to exhibit some problems with incremental collection
|
||||
enabled. 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.
|
||||
Version 4.13 attempts to fix some of the earlier problems, but there
|
||||
may be other issues. If you need solid support for win32 threads, you
|
||||
might check with Geodesic Systems. Their collector must be licensed,
|
||||
but they have invested far more time in win32-specific issues.
|
||||
|
||||
Hans
|
||||
|
||||
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 gc 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)
|
||||
|
||||
|
|
@ -1,16 +0,0 @@
|
|||
CPU=68030
|
||||
NOSTACKCHECK
|
||||
OPTIMIZE
|
||||
VERBOSE
|
||||
MAPHUNK
|
||||
NOVERSION
|
||||
NOICONS
|
||||
OPTIMIZERTIME
|
||||
DEFINE SILENT
|
||||
DEFINE AMIGA_SKIP_SEG
|
||||
IGNORE=85
|
||||
IGNORE=154
|
||||
IGNORE=161
|
||||
IGNORE=100
|
||||
OPTIMIZERCOMPLEXITY=4
|
||||
OPTIMIZERDEPTH=3
|
|
@ -1,48 +1,178 @@
|
|||
OBJS= alloc.o reclaim.o allchblk.o misc.o mach_dep.o os_dep.o mark_rts.o headers.o mark.o obj_map.o blacklst.o finalize.o new_hblk.o real_malloc.o dyn_load.o dbg_mlc.o malloc.o stubborn.o checksums.o typd_mlc.o ptr_chck.o
|
||||
|
||||
# Rewritten smakefile for amiga / sas/c. -Kjetil M.
|
||||
# Dont use the cord-package if you define parm=both or parm=reg.
|
||||
|
||||
|
||||
#----------------TOOLS--------------------------------
|
||||
CC=sc
|
||||
LINKER=slink
|
||||
LIBER=oml
|
||||
|
||||
#----------------CPU OPTIONS--------------------------
|
||||
|
||||
CPU=68060
|
||||
|
||||
#----------------FPU OPTIONS--------------------------
|
||||
|
||||
MATH=8
|
||||
MATHLIB=LIB:scm881.lib
|
||||
|
||||
#----------------COMPILER OPTIONS---------------------
|
||||
|
||||
IGNORE= IGNORE=85 IGNORE=154 IGNORE=161 IGNORE=100
|
||||
|
||||
OPTIMIZE=optimize optimizetime optglobal optimizerdepth=100 optimizerpeephole optloop OPTSCHED optimizerinlocal optimizerrecurdepth=100
|
||||
# optimizerinline optimizercomplexity=100
|
||||
|
||||
OPT= $(OPTIMIZE) CPU=$(CPU) math=$(MATH) NOSTACKCHECK VERBOSE \
|
||||
MAPHUNK NOVERSION NOICONS nodebug \
|
||||
DEFINE SILENT \
|
||||
parm=reg \
|
||||
DEFINE __USE_SYSBASE
|
||||
|
||||
|
||||
SOPT= $(OPT) $(IGNORE) \
|
||||
DEFINE AMIGA_SKIP_SEG \
|
||||
DEFINE ATOMIC_UNCOLLECTABLE \
|
||||
DEFINE GC_AMIGA_FASTALLOC \
|
||||
DEFINE GC_AMIGA_RETRY \
|
||||
DEFINE GC_AMIGA_PRINTSTATS \
|
||||
DEFINE GC_AMIGA_GC
|
||||
|
||||
|
||||
#DEFINE ALL_INTERIOR_POINTERS \
|
||||
|
||||
|
||||
SCOPT= $(SOPT) define GC_AMIGA_MAKINGLIB
|
||||
|
||||
CSCOPT= $(OPT) DEFINE AMIGA IGNORE=100 IGNORE=161
|
||||
|
||||
#------------------LINKING----------------------------
|
||||
|
||||
|
||||
all: gctest setjmp_t cord/cordtest
|
||||
|
||||
clean:
|
||||
delete *.lib gctest setjmp_t *.o *.lnk cord/*.o cord/*.lib cord/*.lnk cord/cordtest
|
||||
smake
|
||||
|
||||
test: setjmp_t gctest cord/cordtest
|
||||
setjmp_t
|
||||
gctest
|
||||
cord/cordtest
|
||||
|
||||
gctest: gc$(CPU).lib GCAmigaOS$(CPU).lib test.o
|
||||
$(LINKER) LIB:c.o test.o TO gctest LIB gc$(CPU).lib LIB:sc.lib $(MATHLIB)
|
||||
|
||||
setjmp_t: setjmp_t.o gc.h
|
||||
$(LINKER) LIB:c.o setjmp_t.o to setjmp_t lib LIB:sc.lib
|
||||
|
||||
cord/cordtest: cord/cordtest.o cord/cord$(CPU).lib gc$(CPU).lib
|
||||
slink LIB:c.o cord/cordtest.o LIB $(MATHLIB) gc$(CPU).lib cord/cord$(CPU).lib LIB:sc.lib TO cord/cordtest
|
||||
|
||||
|
||||
#------------------LIBBING----------------------------
|
||||
|
||||
OBJS= alloc.o reclaim.o allchblk.o misc.o mach_dep.o os_dep.o mark_rts.o headers.o mark.o obj_map.o blacklst.o finalize.o new_hblk.o real_malloc.o dyn_load.o dbg_mlc.o malloc.o stubborn.o checksums.o typd_mlc.o ptr_chck.o mallocx.o
|
||||
|
||||
gc$(CPU).lib: $(OBJS)
|
||||
$(LIBER) gc$(CPU).lib r $(OBJS)
|
||||
|
||||
|
||||
COBJS = cord/cordbscs.o cord/cordprnt.o cord/cordxtra.o
|
||||
|
||||
cord/cord$(CPU).lib: $(COBJS)
|
||||
oml cord/cord$(CPU).lib r $(COBJS)
|
||||
|
||||
#------------------COMPILING--------------------------
|
||||
|
||||
INC= gc_private.h gc_hdrs.h gc.h gcconfig.h
|
||||
|
||||
all: gctest setjmp_t
|
||||
|
||||
alloc.o : alloc.c $(INC)
|
||||
$(CC) alloc.c $(SCOPT) ignore=7
|
||||
|
||||
reclaim.o : reclaim.c $(INC)
|
||||
$(CC) reclaim.c $(SCOPT)
|
||||
|
||||
allchblk.o : allchblk.c $(INC)
|
||||
$(CC) allchblk.c $(SCOPT)
|
||||
|
||||
misc.o : misc.c $(INC)
|
||||
os_dep.o : os_dep.c $(INC)
|
||||
$(CC) misc.c $(SCOPT)
|
||||
|
||||
os_dep.o : os_dep.c $(INC) AmigaOS.c
|
||||
$(CC) os_dep.c $(SCOPT)
|
||||
|
||||
mark_rts.o : mark_rts.c $(INC)
|
||||
$(CC) mark_rts.c $(SCOPT)
|
||||
|
||||
headers.o : headers.c $(INC)
|
||||
$(CC) headers.c $(SCOPT)
|
||||
|
||||
mark.o : mark.c $(INC)
|
||||
$(CC) mark.c $(SCOPT)
|
||||
|
||||
obj_map.o : obj_map.c $(INC)
|
||||
$(CC) obj_map.c $(SCOPT)
|
||||
|
||||
blacklst.o : blacklst.c $(INC)
|
||||
$(CC) blacklst.c $(SCOPT)
|
||||
|
||||
finalize.o : finalize.c $(INC)
|
||||
sc noopt finalize.c # There seems to be a bug in the optimizer (V6.51).
|
||||
# gctest won't work if you remove this...
|
||||
$(CC) finalize.c $(SCOPT) noopt #Could sas/c still have problems with this one? Gctest sometimes fails to finalize all.
|
||||
|
||||
new_hblk.o : new_hblk.c $(INC)
|
||||
$(CC) new_hblk.c $(SCOPT)
|
||||
|
||||
real_malloc.o : real_malloc.c $(INC)
|
||||
$(CC) real_malloc.c $(SCOPT)
|
||||
|
||||
dyn_load.o : dyn_load.c $(INC)
|
||||
$(CC) dyn_load.c $(SCOPT)
|
||||
|
||||
dbg_mlc.o : dbg_mlc.c $(INC)
|
||||
$(CC) dbg_mlc.c $(SCOPT)
|
||||
|
||||
malloc.o : malloc.c $(INC)
|
||||
mallocx.o : malloc.c $(INC)
|
||||
$(CC) malloc.c $(SCOPT)
|
||||
|
||||
mallocx.o : mallocx.c $(INC)
|
||||
$(CC) mallocx.c $(SCOPT)
|
||||
|
||||
stubborn.o : stubborn.c $(INC)
|
||||
$(CC) stubborn.c $(SCOPT)
|
||||
|
||||
checksums.o : checksums.c $(INC)
|
||||
$(CC) checksums.c $(SCOPT)
|
||||
|
||||
typd_mlc.o: typd_mlc.c $(INC)
|
||||
$(CC) typd_mlc.c $(SCOPT)
|
||||
|
||||
mach_dep.o : mach_dep.c $(INC)
|
||||
$(CC) mach_dep.c $(SCOPT)
|
||||
|
||||
ptr_chck.o: ptr_chck.c $(INC)
|
||||
$(CC) ptr_chck.c $(SCOPT)
|
||||
|
||||
test.o : test.c $(INC)
|
||||
|
||||
gc.lib: $(OBJS)
|
||||
oml gc.lib r $(OBJS)
|
||||
|
||||
clean:
|
||||
delete gc.lib gctest setjmp_t \#?.o
|
||||
|
||||
gctest: gc.lib test.o
|
||||
slink LIB:c.o test.o to $@ lib gc.lib LIB:sc.lib LIB:scm.lib
|
||||
$(CC) test.c $(SOPT)
|
||||
|
||||
setjmp_t: setjmp_t.c gc.h
|
||||
sc setjmp_t.c
|
||||
slink LIB:c.o $@.o to $@ lib LIB:sc.lib
|
||||
$(CC) setjmp_t.c $(SOPT)
|
||||
|
||||
|
||||
# cords:
|
||||
|
||||
cord/cordbscs.o: cord/cordbscs.c
|
||||
sc cord/cordbscs.c $(CSCOPT)
|
||||
|
||||
cord/cordprnt.o: cord/cordprnt.c
|
||||
sc cord/cordprnt.c $(CSCOPT)
|
||||
|
||||
cord/cordxtra.o: cord/cordxtra.c
|
||||
sc cord/cordxtra.c $(CSCOPT)
|
||||
|
||||
cord/cordtest.o: cord/cordtest.c
|
||||
sc cord/cordtest.c $(CSCOPT)
|
||||
|
||||
|
||||
test: setjmp_t gctest
|
||||
setjmp_t
|
||||
gctest
|
||||
|
|
|
@ -169,9 +169,9 @@ test_cpp.exe: test_cpp.obj gc.lib
|
|||
|
||||
gc_cpp.obj: gc_cpp.cc .AUTODEPEND
|
||||
$(CXX) $(TEST_CXXFLAGS) -iinclude $*.cc
|
||||
test.obj: test.c .AUTODEPEND
|
||||
test.obj: tests\test.c .AUTODEPEND
|
||||
$(CC) $(TEST_CFLAGS) $*.c
|
||||
test_cpp.obj: test_cpp.cc .AUTODEPEND
|
||||
test_cpp.obj: tests\test_cpp.cc .AUTODEPEND
|
||||
$(CXX) $(TEST_CXXFLAGS) -iinclude $*.cc
|
||||
|
||||
|
||||
|
|
2
boehm-gc/aclocal.m4
vendored
2
boehm-gc/aclocal.m4
vendored
|
@ -43,7 +43,7 @@ AC_SUBST(boehm_gc_basedir)
|
|||
|
||||
AC_CANONICAL_HOST
|
||||
|
||||
AM_INIT_AUTOMAKE(boehm-gc, 5.1, no-define)
|
||||
AM_INIT_AUTOMAKE(boehm-gc, 6.0a7, no-define)
|
||||
|
||||
# FIXME: We temporarily define our own version of AC_PROG_CC. This is
|
||||
# copied from autoconf 2.12, but does not call AC_PROG_CC_WORKS. We
|
||||
|
|
|
@ -14,10 +14,9 @@
|
|||
* modified is included with the above copyright notice.
|
||||
*/
|
||||
|
||||
#define DEBUG
|
||||
#undef DEBUG
|
||||
/* #define DEBUG */
|
||||
#include <stdio.h>
|
||||
#include "gc_priv.h"
|
||||
#include "private/gc_priv.h"
|
||||
|
||||
GC_bool GC_use_entire_heap = 0;
|
||||
|
||||
|
@ -47,6 +46,35 @@ GC_bool GC_use_entire_heap = 0;
|
|||
|
||||
struct hblk * GC_hblkfreelist[N_HBLK_FLS+1] = { 0 };
|
||||
|
||||
#ifndef USE_MUNMAP
|
||||
word GC_free_bytes[N_HBLK_FLS+1] = { 0 };
|
||||
/* Number of free bytes on each list. */
|
||||
|
||||
/* Is bytes + the number of free bytes on lists n .. N_HBLK_FLS */
|
||||
/* > GC_max_large_allocd_bytes? */
|
||||
GC_bool GC_enough_large_bytes_left(bytes,n)
|
||||
word bytes;
|
||||
int n;
|
||||
{
|
||||
int i;
|
||||
for (i = N_HBLK_FLS; i >= n; --i) {
|
||||
bytes += GC_free_bytes[i];
|
||||
if (bytes > GC_max_large_allocd_bytes) return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
# define INCR_FREE_BYTES(n, b) GC_free_bytes[n] += (b);
|
||||
|
||||
# define FREE_ASSERT(e) GC_ASSERT(e)
|
||||
|
||||
#else /* USE_MUNMAP */
|
||||
|
||||
# define INCR_FREE_BYTES(n, b)
|
||||
# define FREE_ASSERT(e)
|
||||
|
||||
#endif /* USE_MUNMAP */
|
||||
|
||||
/* Map a number of blocks to the appropriate large block free list index. */
|
||||
int GC_hblk_fl_from_blocks(blocks_needed)
|
||||
word blocks_needed;
|
||||
|
@ -79,7 +107,14 @@ void GC_print_hblkfreelist()
|
|||
|
||||
for (i = 0; i <= N_HBLK_FLS; ++i) {
|
||||
h = GC_hblkfreelist[i];
|
||||
if (0 != h) GC_printf1("Free list %ld:\n", (unsigned long)i);
|
||||
# ifdef USE_MUNMAP
|
||||
if (0 != h) GC_printf1("Free list %ld (Total size %ld):\n",
|
||||
(unsigned long)i);
|
||||
# else
|
||||
if (0 != h) GC_printf2("Free list %ld (Total size %ld):\n",
|
||||
(unsigned long)i,
|
||||
(unsigned long)GC_free_bytes[i]);
|
||||
# endif
|
||||
while (h != 0) {
|
||||
hhdr = HDR(h);
|
||||
sz = hhdr -> hb_sz;
|
||||
|
@ -219,14 +254,25 @@ void GC_remove_from_fl(hhdr, n)
|
|||
hdr * hhdr;
|
||||
int n;
|
||||
{
|
||||
int index;
|
||||
|
||||
GC_ASSERT(((hhdr -> hb_sz) & (HBLKSIZE-1)) == 0);
|
||||
# ifndef USE_MUNMAP
|
||||
/* We always need index to mainatin free counts. */
|
||||
if (FL_UNKNOWN == n) {
|
||||
index = GC_hblk_fl_from_blocks(divHBLKSZ(hhdr -> hb_sz));
|
||||
} else {
|
||||
index = n;
|
||||
}
|
||||
# endif
|
||||
if (hhdr -> hb_prev == 0) {
|
||||
int index;
|
||||
if (FL_UNKNOWN == n) {
|
||||
# ifdef USE_MUNMAP
|
||||
if (FL_UNKNOWN == n) {
|
||||
index = GC_hblk_fl_from_blocks(divHBLKSZ(hhdr -> hb_sz));
|
||||
} else {
|
||||
} else {
|
||||
index = n;
|
||||
}
|
||||
}
|
||||
# endif
|
||||
GC_ASSERT(HDR(GC_hblkfreelist[index]) == hhdr);
|
||||
GC_hblkfreelist[index] = hhdr -> hb_next;
|
||||
} else {
|
||||
|
@ -234,6 +280,8 @@ int n;
|
|||
GET_HDR(hhdr -> hb_prev, phdr);
|
||||
phdr -> hb_next = hhdr -> hb_next;
|
||||
}
|
||||
INCR_FREE_BYTES(index, - (signed_word)(hhdr -> hb_sz));
|
||||
FREE_ASSERT(GC_free_bytes[index] >= 0);
|
||||
if (0 != hhdr -> hb_next) {
|
||||
hdr * nhdr;
|
||||
GC_ASSERT(!IS_FORWARDING_ADDR_OR_NIL(NHDR(hhdr)));
|
||||
|
@ -294,6 +342,8 @@ hdr * hhdr;
|
|||
# endif
|
||||
GC_ASSERT(((hhdr -> hb_sz) & (HBLKSIZE-1)) == 0);
|
||||
GC_hblkfreelist[index] = h;
|
||||
INCR_FREE_BYTES(index, hhdr -> hb_sz);
|
||||
FREE_ASSERT(GC_free_bytes[index] <= GC_large_free_bytes)
|
||||
hhdr -> hb_next = second;
|
||||
hhdr -> hb_prev = 0;
|
||||
if (0 != second) {
|
||||
|
@ -419,7 +469,7 @@ int index;
|
|||
rest_hdr -> hb_sz = total_size - bytes;
|
||||
rest_hdr -> hb_flags = 0;
|
||||
# ifdef GC_ASSERTIONS
|
||||
// Mark h not free, to avoid assertion about adjacent free blocks.
|
||||
/* Mark h not free, to avoid assertion about adjacent free blocks. */
|
||||
hhdr -> hb_map = 0;
|
||||
# endif
|
||||
GC_add_to_fl(rest, rest_hdr);
|
||||
|
@ -463,6 +513,8 @@ int index; /* Index of free list */
|
|||
if (0 != next) {
|
||||
HDR(next) -> hb_prev = n;
|
||||
}
|
||||
INCR_FREE_BYTES(index, -(signed_word)h_size);
|
||||
FREE_ASSERT(GC_free_bytes[index] > 0);
|
||||
# ifdef GC_ASSERTIONS
|
||||
nhdr -> hb_map = 0; /* Don't fail test for consecutive */
|
||||
/* free blocks in GC_add_to_fl. */
|
||||
|
@ -484,20 +536,23 @@ struct hblk * GC_allochblk_nth();
|
|||
* NOTE: We set obj_map field in header correctly.
|
||||
* Caller is responsible for building an object freelist in block.
|
||||
*
|
||||
* We clear the block if it is destined for large objects, and if
|
||||
* kind requires that newly allocated objects be cleared.
|
||||
* Unlike older versions of the collectors, the client is responsible
|
||||
* for clearing the block, if necessary.
|
||||
*/
|
||||
struct hblk *
|
||||
GC_allochblk(sz, kind, flags)
|
||||
word sz;
|
||||
int kind;
|
||||
unsigned char flags; /* IGNORE_OFF_PAGE or 0 */
|
||||
unsigned flags; /* IGNORE_OFF_PAGE or 0 */
|
||||
{
|
||||
int start_list = GC_hblk_fl_from_blocks(OBJ_SZ_TO_BLOCKS(sz));
|
||||
word blocks = OBJ_SZ_TO_BLOCKS(sz);
|
||||
int start_list = GC_hblk_fl_from_blocks(blocks);
|
||||
int i;
|
||||
for (i = start_list; i <= N_HBLK_FLS; ++i) {
|
||||
struct hblk * result = GC_allochblk_nth(sz, kind, flags, i);
|
||||
if (0 != result) return result;
|
||||
if (0 != result) {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -526,12 +581,22 @@ int n;
|
|||
GET_HDR(hbp, hhdr);
|
||||
size_avail = hhdr->hb_sz;
|
||||
if (size_avail < size_needed) continue;
|
||||
if (!GC_use_entire_heap) {
|
||||
if (size_avail != size_needed
|
||||
&& USED_HEAP_SIZE >= GC_requested_heapsize
|
||||
&& !GC_incremental && GC_should_collect()) {
|
||||
if (!GC_use_entire_heap
|
||||
&& size_avail != size_needed
|
||||
&& USED_HEAP_SIZE >= GC_requested_heapsize
|
||||
&& !GC_incremental && GC_should_collect()) {
|
||||
# ifdef USE_MUNMAP
|
||||
continue;
|
||||
}
|
||||
# else
|
||||
/* If we enough large blocks left to cover any */
|
||||
/* previous request for large blocks, we go ahead */
|
||||
/* and split. Assuming a steady state, that should */
|
||||
/* be safe. It means that we can use the full */
|
||||
/* heap if we allocate only small objects. */
|
||||
if (!GC_enough_large_bytes_left(GC_large_allocd_bytes, n)) {
|
||||
continue;
|
||||
}
|
||||
# endif /* !USE_MUNMAP */
|
||||
}
|
||||
/* If the next heap block is obviously better, go on. */
|
||||
/* This prevents us from disassembling a single large block */
|
||||
|
@ -573,7 +638,7 @@ int n;
|
|||
/* Make sure it's mapped before we mangle it. */
|
||||
# ifdef USE_MUNMAP
|
||||
if (!IS_MAPPED(hhdr)) {
|
||||
GC_remap((ptr_t)hbp, size_avail);
|
||||
GC_remap((ptr_t)hbp, hhdr -> hb_sz);
|
||||
hhdr -> hb_flags &= ~WAS_UNMAPPED;
|
||||
}
|
||||
# endif
|
||||
|
@ -589,8 +654,10 @@ int n;
|
|||
&& orig_avail - size_needed
|
||||
> (signed_word)BL_LIMIT) {
|
||||
/* Punt, since anything else risks unreasonable heap growth. */
|
||||
WARN("Needed to allocate blacklisted block at 0x%lx\n",
|
||||
(word)hbp);
|
||||
if (0 != GETENV("GC_NO_BLACKLIST_WARNING")) {
|
||||
WARN("Needed to allocate blacklisted block at 0x%lx\n",
|
||||
(word)hbp);
|
||||
}
|
||||
size_avail = orig_avail;
|
||||
} else if (size_avail == 0 && size_needed == HBLKSIZE
|
||||
&& IS_MAPPED(hhdr)) {
|
||||
|
@ -618,10 +685,10 @@ int n;
|
|||
if (h == hbp || 0 != (hhdr = GC_install_header(h))) {
|
||||
(void) setup_header(
|
||||
hhdr,
|
||||
BYTES_TO_WORDS(HBLKSIZE - HDR_BYTES),
|
||||
BYTES_TO_WORDS(HBLKSIZE),
|
||||
PTRFREE, 0); /* Cant fail */
|
||||
if (GC_debugging_started) {
|
||||
BZERO(h + HDR_BYTES, HBLKSIZE - HDR_BYTES);
|
||||
BZERO(h, HBLKSIZE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -638,7 +705,7 @@ int n;
|
|||
if( size_avail >= size_needed ) {
|
||||
# ifdef USE_MUNMAP
|
||||
if (!IS_MAPPED(hhdr)) {
|
||||
GC_remap((ptr_t)hbp, size_avail);
|
||||
GC_remap((ptr_t)hbp, hhdr -> hb_sz);
|
||||
hhdr -> hb_flags &= ~WAS_UNMAPPED;
|
||||
}
|
||||
# endif
|
||||
|
@ -664,12 +731,6 @@ int n;
|
|||
return(0); /* ditto */
|
||||
}
|
||||
|
||||
/* Clear block if necessary */
|
||||
if (GC_debugging_started
|
||||
|| sz > MAXOBJSZ && GC_obj_kinds[kind].ok_init) {
|
||||
BZERO(hbp + HDR_BYTES, size_needed - HDR_BYTES);
|
||||
}
|
||||
|
||||
/* We just successfully allocated a block. Restart count of */
|
||||
/* consecutive failures. */
|
||||
{
|
||||
|
|
120
boehm-gc/alloc.c
120
boehm-gc/alloc.c
|
@ -16,10 +16,10 @@
|
|||
*/
|
||||
|
||||
|
||||
# include "gc_priv.h"
|
||||
# include "private/gc_priv.h"
|
||||
|
||||
# include <stdio.h>
|
||||
# ifndef MACOS
|
||||
# if !defined(MACOS) && !defined(MSWINCE)
|
||||
# include <signal.h>
|
||||
# include <sys/types.h>
|
||||
# endif
|
||||
|
@ -60,9 +60,11 @@ word GC_non_gc_bytes = 0; /* Number of bytes not intended to be collected */
|
|||
word GC_gc_no = 0;
|
||||
|
||||
#ifndef SMALL_CONFIG
|
||||
int GC_incremental = 0; /* By default, stop the world. */
|
||||
int GC_incremental = 0; /* By default, stop the world. */
|
||||
#endif
|
||||
|
||||
int GC_parallel = FALSE; /* By default, parallel GC is off. */
|
||||
|
||||
int GC_full_freq = 19; /* Every 20th collection is a full */
|
||||
/* collection, whether we need it */
|
||||
/* or not. */
|
||||
|
@ -76,6 +78,7 @@ char * GC_copyright[] =
|
|||
{"Copyright 1988,1989 Hans-J. Boehm and Alan J. Demers ",
|
||||
"Copyright (c) 1991-1995 by Xerox Corporation. All rights reserved. ",
|
||||
"Copyright (c) 1996-1998 by Silicon Graphics. All rights reserved. ",
|
||||
"Copyright (c) 1999-2000 by Hewlett-Packard Company. All rights reserved. ",
|
||||
"THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY",
|
||||
" EXPRESSED OR IMPLIED. ANY USE IS AT YOUR OWN RISK.",
|
||||
"See source code for details." };
|
||||
|
@ -116,10 +119,12 @@ int GC_n_attempts = 0; /* Number of attempts at finishing */
|
|||
GET_TIME(current_time);
|
||||
time_diff = MS_TIME_DIFF(current_time,GC_start_time);
|
||||
if (time_diff >= TIME_LIMIT) {
|
||||
# ifdef PRINTSTATS
|
||||
# ifdef CONDPRINT
|
||||
if (GC_print_stats) {
|
||||
GC_printf0("Abandoning stopped marking after ");
|
||||
GC_printf1("%lu msecs", (unsigned long)time_diff);
|
||||
GC_printf1("(attempt %d)\n", (unsigned long) GC_n_attempts);
|
||||
}
|
||||
# endif
|
||||
return(1);
|
||||
}
|
||||
|
@ -222,7 +227,7 @@ GC_bool GC_should_collect()
|
|||
|
||||
void GC_notify_full_gc()
|
||||
{
|
||||
if (GC_start_call_back != (void (*)())0) {
|
||||
if (GC_start_call_back != (void (*) GC_PROTO((void)))0) {
|
||||
(*GC_start_call_back)();
|
||||
}
|
||||
}
|
||||
|
@ -246,13 +251,18 @@ void GC_maybe_gc()
|
|||
n_partial_gcs = 0;
|
||||
return;
|
||||
} else if (GC_need_full_gc || n_partial_gcs >= GC_full_freq) {
|
||||
# ifdef PRINTSTATS
|
||||
GC_printf2(
|
||||
"***>Full mark for collection %lu after %ld allocd bytes\n",
|
||||
(unsigned long) GC_gc_no+1,
|
||||
(long)WORDS_TO_BYTES(GC_words_allocd));
|
||||
# ifdef CONDPRINT
|
||||
if (GC_print_stats) {
|
||||
GC_printf2(
|
||||
"***>Full mark for collection %lu after %ld allocd bytes\n",
|
||||
(unsigned long) GC_gc_no+1,
|
||||
(long)WORDS_TO_BYTES(GC_words_allocd));
|
||||
}
|
||||
# endif
|
||||
GC_promote_black_lists();
|
||||
# ifdef PARALLEL_MARK
|
||||
GC_wait_for_reclaim();
|
||||
# endif
|
||||
(void)GC_reclaim_all((GC_stop_func)0, TRUE);
|
||||
GC_clear_marks();
|
||||
n_partial_gcs = 0;
|
||||
|
@ -290,27 +300,36 @@ GC_bool GC_try_to_collect_inner(stop_func)
|
|||
GC_stop_func stop_func;
|
||||
{
|
||||
if (GC_incremental && GC_collection_in_progress()) {
|
||||
# ifdef PRINTSTATS
|
||||
# ifdef CONDPRINT
|
||||
if (GC_print_stats) {
|
||||
GC_printf0(
|
||||
"GC_try_to_collect_inner: finishing collection in progress\n");
|
||||
# endif /* PRINTSTATS */
|
||||
}
|
||||
# endif /* CONDPRINT */
|
||||
/* Just finish collection already in progress. */
|
||||
while(GC_collection_in_progress()) {
|
||||
if (stop_func()) return(FALSE);
|
||||
GC_collect_a_little_inner(1);
|
||||
}
|
||||
}
|
||||
# ifdef PRINTSTATS
|
||||
# ifdef CONDPRINT
|
||||
if (GC_print_stats) {
|
||||
GC_printf2(
|
||||
"Initiating full world-stop collection %lu after %ld allocd bytes\n",
|
||||
(unsigned long) GC_gc_no+1,
|
||||
(long)WORDS_TO_BYTES(GC_words_allocd));
|
||||
}
|
||||
# endif
|
||||
GC_promote_black_lists();
|
||||
/* Make sure all blocks have been reclaimed, so sweep routines */
|
||||
/* don't see cleared mark bits. */
|
||||
/* If we're guaranteed to finish, then this is unnecessary. */
|
||||
if (stop_func != GC_never_stop_func
|
||||
/* In the find_leak case, we have to finish to guarantee that */
|
||||
/* previously unmarked objects are not reported as leaks. */
|
||||
# ifdef PARALLEL_MARK
|
||||
GC_wait_for_reclaim();
|
||||
# endif
|
||||
if ((GC_find_leak || stop_func != GC_never_stop_func)
|
||||
&& !GC_reclaim_all(stop_func, FALSE)) {
|
||||
/* Aborted. So far everything is still consistent. */
|
||||
return(FALSE);
|
||||
|
@ -412,18 +431,22 @@ GC_stop_func stop_func;
|
|||
{
|
||||
register int i;
|
||||
int dummy;
|
||||
# ifdef PRINTSTATS
|
||||
# ifdef PRINTTIMES
|
||||
CLOCK_TYPE start_time, current_time;
|
||||
# endif
|
||||
|
||||
STOP_WORLD();
|
||||
# ifdef PRINTSTATS
|
||||
# ifdef PRINTTIMES
|
||||
GET_TIME(start_time);
|
||||
# endif
|
||||
# ifdef CONDPRINT
|
||||
if (GC_print_stats) {
|
||||
GC_printf1("--> Marking for collection %lu ",
|
||||
(unsigned long) GC_gc_no + 1);
|
||||
GC_printf2("after %lu allocd bytes + %lu wasted bytes\n",
|
||||
(unsigned long) WORDS_TO_BYTES(GC_words_allocd),
|
||||
(unsigned long) WORDS_TO_BYTES(GC_words_wasted));
|
||||
}
|
||||
# endif
|
||||
|
||||
/* Mark from all roots. */
|
||||
|
@ -433,10 +456,12 @@ GC_stop_func stop_func;
|
|||
GC_initiate_gc();
|
||||
for(i = 0;;i++) {
|
||||
if ((*stop_func)()) {
|
||||
# ifdef PRINTSTATS
|
||||
# ifdef CONDPRINT
|
||||
if (GC_print_stats) {
|
||||
GC_printf0("Abandoned stopped marking after ");
|
||||
GC_printf1("%lu iterations\n",
|
||||
(unsigned long)i);
|
||||
}
|
||||
# endif
|
||||
GC_deficit = i; /* Give the mutator a chance. */
|
||||
START_WORLD();
|
||||
|
@ -450,12 +475,22 @@ GC_stop_func stop_func;
|
|||
GC_printf2("Collection %lu reclaimed %ld bytes",
|
||||
(unsigned long) GC_gc_no - 1,
|
||||
(long)WORDS_TO_BYTES(GC_mem_found));
|
||||
GC_printf1(" ---> heapsize = %lu bytes\n",
|
||||
(unsigned long) GC_heapsize);
|
||||
/* Printf arguments may be pushed in funny places. Clear the */
|
||||
/* space. */
|
||||
GC_printf0("");
|
||||
# endif
|
||||
# else
|
||||
# ifdef CONDPRINT
|
||||
if (GC_print_stats) {
|
||||
GC_printf1("Collection %lu finished", (unsigned long) GC_gc_no - 1);
|
||||
}
|
||||
# endif
|
||||
# endif /* !PRINTSTATS */
|
||||
# ifdef CONDPRINT
|
||||
if (GC_print_stats) {
|
||||
GC_printf1(" ---> heapsize = %lu bytes\n",
|
||||
(unsigned long) GC_heapsize);
|
||||
/* Printf arguments may be pushed in funny places. Clear the */
|
||||
/* space. */
|
||||
GC_printf0("");
|
||||
}
|
||||
# endif /* CONDPRINT */
|
||||
|
||||
/* Check all debugged objects for consistency */
|
||||
if (GC_debugging_started) {
|
||||
|
@ -487,6 +522,11 @@ void GC_finish_collection()
|
|||
|
||||
# ifdef GATHERSTATS
|
||||
GC_mem_found = 0;
|
||||
# endif
|
||||
# if defined(LINUX) && defined(__ELF__) && !defined(SMALL_CONFIG)
|
||||
if (getenv("GC_PRINT_ADDRESS_MAP") != 0) {
|
||||
GC_print_address_map();
|
||||
}
|
||||
# endif
|
||||
if (GC_find_leak) {
|
||||
/* Mark all objects on the free list. All objects should be */
|
||||
|
@ -663,22 +703,22 @@ word bytes;
|
|||
GC_heap_sects[GC_n_heap_sects].hs_start = (ptr_t)p;
|
||||
GC_heap_sects[GC_n_heap_sects].hs_bytes = bytes;
|
||||
GC_n_heap_sects++;
|
||||
words = BYTES_TO_WORDS(bytes - HDR_BYTES);
|
||||
words = BYTES_TO_WORDS(bytes);
|
||||
phdr -> hb_sz = words;
|
||||
phdr -> hb_map = (char *)1; /* A value != GC_invalid_map */
|
||||
phdr -> hb_map = (unsigned char *)1; /* A value != GC_invalid_map */
|
||||
phdr -> hb_flags = 0;
|
||||
GC_freehblk(p);
|
||||
GC_heapsize += bytes;
|
||||
if ((ptr_t)p <= GC_least_plausible_heap_addr
|
||||
if ((ptr_t)p <= (ptr_t)GC_least_plausible_heap_addr
|
||||
|| GC_least_plausible_heap_addr == 0) {
|
||||
GC_least_plausible_heap_addr = (ptr_t)p - sizeof(word);
|
||||
GC_least_plausible_heap_addr = (GC_PTR)((ptr_t)p - sizeof(word));
|
||||
/* Making it a little smaller than necessary prevents */
|
||||
/* us from getting a false hit from the variable */
|
||||
/* itself. There's some unintentional reflection */
|
||||
/* here. */
|
||||
}
|
||||
if ((ptr_t)p + bytes >= GC_greatest_plausible_heap_addr) {
|
||||
GC_greatest_plausible_heap_addr = (ptr_t)p + bytes;
|
||||
if ((ptr_t)p + bytes >= (ptr_t)GC_greatest_plausible_heap_addr) {
|
||||
GC_greatest_plausible_heap_addr = (GC_PTR)((ptr_t)p + bytes);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -705,8 +745,8 @@ void GC_print_heap_sects()
|
|||
}
|
||||
# endif
|
||||
|
||||
ptr_t GC_least_plausible_heap_addr = (ptr_t)ONES;
|
||||
ptr_t GC_greatest_plausible_heap_addr = 0;
|
||||
GC_PTR GC_least_plausible_heap_addr = (GC_PTR)ONES;
|
||||
GC_PTR GC_greatest_plausible_heap_addr = 0;
|
||||
|
||||
ptr_t GC_max(x,y)
|
||||
ptr_t x, y;
|
||||
|
@ -762,9 +802,16 @@ word n;
|
|||
}
|
||||
space = GET_MEM(bytes);
|
||||
if( space == 0 ) {
|
||||
# ifdef CONDPRINT
|
||||
if (GC_print_stats) {
|
||||
GC_printf1("Failed to expand heap by %ld bytes\n",
|
||||
(unsigned long)bytes);
|
||||
}
|
||||
# endif
|
||||
return(FALSE);
|
||||
}
|
||||
# ifdef PRINTSTATS
|
||||
# ifdef CONDPRINT
|
||||
if (GC_print_stats) {
|
||||
GC_printf2("Increasing heap size by %lu after %lu allocated bytes\n",
|
||||
(unsigned long)bytes,
|
||||
(unsigned long)WORDS_TO_BYTES(GC_words_allocd));
|
||||
|
@ -773,6 +820,7 @@ word n;
|
|||
GC_print_block_list(); GC_print_hblkfreelist();
|
||||
GC_printf0("\n");
|
||||
# endif
|
||||
}
|
||||
# endif
|
||||
expansion_slop = 8 * WORDS_TO_BYTES(min_words_allocd());
|
||||
if (5 * HBLKSIZE * MAXHINCR > expansion_slop) {
|
||||
|
@ -856,12 +904,14 @@ GC_bool ignore_off_page;
|
|||
GC_notify_full_gc();
|
||||
GC_gcollect_inner();
|
||||
} else {
|
||||
WARN("Out of Memory! Returning NIL!\n", 0);
|
||||
# if !defined(AMIGA) || !defined(GC_AMIGA_FASTALLOC)
|
||||
WARN("Out of Memory! Returning NIL!\n", 0);
|
||||
# endif
|
||||
return(FALSE);
|
||||
}
|
||||
} else {
|
||||
# ifdef PRINTSTATS
|
||||
if (GC_fail_count) {
|
||||
# ifdef CONDPRINT
|
||||
if (GC_fail_count && GC_print_stats) {
|
||||
GC_printf0("Memory available again ...\n");
|
||||
}
|
||||
# endif
|
||||
|
|
|
@ -1,63 +0,0 @@
|
|||
/*
|
||||
* This is a simple API to implement pointer back tracing, i.e.
|
||||
* to answer questions such as "who is pointing to this" or
|
||||
* "why is this object being retained by the collector"
|
||||
*
|
||||
* This API assumes that we have an ANSI C compiler.
|
||||
*
|
||||
* Most of these calls yield useful information on only after
|
||||
* a garbage collection. Usually the client will first force
|
||||
* a full collection and then gather information, preferably
|
||||
* before much intervening allocation.
|
||||
*
|
||||
* The implementation of the interface is only about 99.9999%
|
||||
* correct. It is intended to be good enough for profiling,
|
||||
* but is not intended to be used with production code.
|
||||
*
|
||||
* Results are likely to be much more useful if all allocation is
|
||||
* accomplished through the debugging allocators.
|
||||
*
|
||||
* The implementation idea is due to A. Demers.
|
||||
*/
|
||||
|
||||
/* Store information about the object referencing dest in *base_p */
|
||||
/* and *offset_p. */
|
||||
/* If multiple objects or roots point to dest, the one reported */
|
||||
/* will be the last on used by the garbage collector to trace the */
|
||||
/* object. */
|
||||
/* source is root ==> *base_p = address, *offset_p = 0 */
|
||||
/* source is heap object ==> *base_p != 0, *offset_p = offset */
|
||||
/* Returns 1 on success, 0 if source couldn't be determined. */
|
||||
/* Dest can be any address within a heap object. */
|
||||
typedef enum { GC_UNREFERENCED, /* No reference info available. */
|
||||
GC_NO_SPACE, /* Dest not allocated with debug alloc */
|
||||
GC_REFD_FROM_ROOT, /* Referenced directly by root *base_p */
|
||||
GC_REFD_FROM_REG, /* Referenced from a register, i.e. */
|
||||
/* a root without an address. */
|
||||
GC_REFD_FROM_HEAP, /* Referenced from another heap obj. */
|
||||
GC_FINALIZER_REFD /* Finalizable and hence accessible. */
|
||||
} GC_ref_kind;
|
||||
|
||||
GC_ref_kind GC_get_back_ptr_info(void *dest, void **base_p, size_t *offset_p);
|
||||
|
||||
/* Generate a random heap address. */
|
||||
/* The resulting address is in the heap, but */
|
||||
/* not necessarily inside a valid object. */
|
||||
void * GC_generate_random_heap_address(void);
|
||||
|
||||
/* Generate a random address inside a valid marked heap object. */
|
||||
void * GC_generate_random_valid_address(void);
|
||||
|
||||
/* Force a garbage collection and generate a backtrace from a */
|
||||
/* random heap address. */
|
||||
/* This uses the GC logging mechanism (GC_printf) to produce */
|
||||
/* output. It can often be called from a debugger. The */
|
||||
/* source in dbg_mlc.c also serves as a sample client. */
|
||||
void GC_generate_random_backtrace(void);
|
||||
|
||||
/* Print a backtrace from a specific address. Used by the */
|
||||
/* above. The client should call GC_gcollect() immediately */
|
||||
/* before invocation. */
|
||||
void GC_print_backtrace(void *);
|
||||
|
||||
|
|
@ -1,106 +0,0 @@
|
|||
This is an ASCII diagram of the data structure used to check pointer
|
||||
validity. It was provided by Dave Barrett <barrett@asgard.cs.colorado.edu>,
|
||||
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.
|
|
@ -12,7 +12,7 @@
|
|||
* modified is included with the above copyright notice.
|
||||
*/
|
||||
/* Boehm, August 9, 1995 6:09 pm PDT */
|
||||
# include "gc_priv.h"
|
||||
# include "private/gc_priv.h"
|
||||
|
||||
/*
|
||||
* We maintain several hash tables of hblks that have had false hits.
|
||||
|
@ -52,15 +52,19 @@ word GC_black_list_spacing = MINHINCR*HBLKSIZE; /* Initial rough guess */
|
|||
|
||||
void GC_clear_bl();
|
||||
|
||||
void GC_default_print_heap_obj_proc(p)
|
||||
ptr_t p;
|
||||
# if defined(__STDC__) || defined(__cplusplus)
|
||||
void GC_default_print_heap_obj_proc(ptr_t p)
|
||||
# else
|
||||
void GC_default_print_heap_obj_proc(p)
|
||||
ptr_t p;
|
||||
# endif
|
||||
{
|
||||
ptr_t base = GC_base(p);
|
||||
|
||||
GC_err_printf2("start: 0x%lx, appr. length: %ld", base, GC_size(base));
|
||||
}
|
||||
|
||||
void (*GC_print_heap_obj)(/* char * s, ptr_t p */) =
|
||||
void (*GC_print_heap_obj) GC_PROTO((ptr_t p)) =
|
||||
GC_default_print_heap_obj_proc;
|
||||
|
||||
void GC_print_source_ptr(p)
|
||||
|
@ -81,18 +85,18 @@ ptr_t p;
|
|||
|
||||
void GC_bl_init()
|
||||
{
|
||||
# ifndef ALL_INTERIOR_POINTERS
|
||||
GC_old_normal_bl = (word *)
|
||||
if (!GC_all_interior_pointers) {
|
||||
GC_old_normal_bl = (word *)
|
||||
GC_scratch_alloc((word)(sizeof (page_hash_table)));
|
||||
GC_incomplete_normal_bl = (word *)GC_scratch_alloc
|
||||
GC_incomplete_normal_bl = (word *)GC_scratch_alloc
|
||||
((word)(sizeof(page_hash_table)));
|
||||
if (GC_old_normal_bl == 0 || GC_incomplete_normal_bl == 0) {
|
||||
if (GC_old_normal_bl == 0 || GC_incomplete_normal_bl == 0) {
|
||||
GC_err_printf0("Insufficient memory for black list\n");
|
||||
EXIT();
|
||||
}
|
||||
GC_clear_bl(GC_old_normal_bl);
|
||||
GC_clear_bl(GC_incomplete_normal_bl);
|
||||
}
|
||||
GC_clear_bl(GC_old_normal_bl);
|
||||
GC_clear_bl(GC_incomplete_normal_bl);
|
||||
# endif
|
||||
GC_old_stack_bl = (word *)GC_scratch_alloc((word)(sizeof(page_hash_table)));
|
||||
GC_incomplete_stack_bl = (word *)GC_scratch_alloc
|
||||
((word)(sizeof(page_hash_table)));
|
||||
|
@ -127,9 +131,9 @@ void GC_promote_black_lists()
|
|||
|
||||
GC_old_normal_bl = GC_incomplete_normal_bl;
|
||||
GC_old_stack_bl = GC_incomplete_stack_bl;
|
||||
# ifndef ALL_INTERIOR_POINTERS
|
||||
if (!GC_all_interior_pointers) {
|
||||
GC_clear_bl(very_old_normal_bl);
|
||||
# endif
|
||||
}
|
||||
GC_clear_bl(very_old_stack_bl);
|
||||
GC_incomplete_normal_bl = very_old_normal_bl;
|
||||
GC_incomplete_stack_bl = very_old_stack_bl;
|
||||
|
@ -156,13 +160,12 @@ void GC_promote_black_lists()
|
|||
|
||||
void GC_unpromote_black_lists()
|
||||
{
|
||||
# ifndef ALL_INTERIOR_POINTERS
|
||||
if (!GC_all_interior_pointers) {
|
||||
GC_copy_bl(GC_old_normal_bl, GC_incomplete_normal_bl);
|
||||
# endif
|
||||
}
|
||||
GC_copy_bl(GC_old_stack_bl, GC_incomplete_stack_bl);
|
||||
}
|
||||
|
||||
# ifndef ALL_INTERIOR_POINTERS
|
||||
/* P is not a valid pointer reference, but it falls inside */
|
||||
/* the plausible heap bounds. */
|
||||
/* Add it to the normal incomplete black list if appropriate. */
|
||||
|
@ -193,7 +196,6 @@ word p;
|
|||
/* object, and isn't worth black listing. */
|
||||
}
|
||||
}
|
||||
# endif
|
||||
|
||||
/* And the same for false pointers from the stack. */
|
||||
#ifdef PRINT_BLACK_LIST
|
||||
|
@ -236,12 +238,12 @@ word len;
|
|||
register word i;
|
||||
word nblocks = divHBLKSZ(len);
|
||||
|
||||
# ifndef ALL_INTERIOR_POINTERS
|
||||
if (!GC_all_interior_pointers) {
|
||||
if (get_pht_entry_from_index(GC_old_normal_bl, index)
|
||||
|| get_pht_entry_from_index(GC_incomplete_normal_bl, index)) {
|
||||
return(h+1);
|
||||
}
|
||||
# endif
|
||||
}
|
||||
|
||||
for (i = 0; ; ) {
|
||||
if (GC_old_stack_bl[divWORDSZ(index)] == 0
|
||||
|
|
|
@ -80,7 +80,7 @@ int index;
|
|||
if (pe -> block != 0 && pe -> block != h + OFFSET) ABORT("goofed");
|
||||
pe -> old_sum = pe -> new_sum;
|
||||
pe -> new_sum = GC_checksum(h);
|
||||
# ifndef MSWIN32
|
||||
# if !defined(MSWIN32) && !defined(MSWINCE)
|
||||
if (pe -> new_sum != 0 && !GC_page_was_ever_dirty(h)) {
|
||||
GC_printf1("GC_page_was_ever_dirty(0x%lx) is wrong\n",
|
||||
(unsigned long)h);
|
||||
|
|
165
boehm-gc/configure
vendored
165
boehm-gc/configure
vendored
|
@ -57,7 +57,6 @@ program_suffix=NONE
|
|||
program_transform_name=s,x,x,
|
||||
silent=
|
||||
site=
|
||||
sitefile=
|
||||
srcdir=
|
||||
target=NONE
|
||||
verbose=
|
||||
|
@ -172,7 +171,6 @@ Configuration:
|
|||
--help print this message
|
||||
--no-create do not create output files
|
||||
--quiet, --silent do not print \`checking...' messages
|
||||
--site-file=FILE use FILE as the site file
|
||||
--version print the version of autoconf that created configure
|
||||
Directory and file names:
|
||||
--prefix=PREFIX install architecture-independent files in PREFIX
|
||||
|
@ -343,11 +341,6 @@ EOF
|
|||
-site=* | --site=* | --sit=*)
|
||||
site="$ac_optarg" ;;
|
||||
|
||||
-site-file | --site-file | --site-fil | --site-fi | --site-f)
|
||||
ac_prev=sitefile ;;
|
||||
-site-file=* | --site-file=* | --site-fil=* | --site-fi=* | --site-f=*)
|
||||
sitefile="$ac_optarg" ;;
|
||||
|
||||
-srcdir | --srcdir | --srcdi | --srcd | --src | --sr)
|
||||
ac_prev=srcdir ;;
|
||||
-srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*)
|
||||
|
@ -487,7 +480,7 @@ echo > confdefs.h
|
|||
|
||||
# A filename unique to this package, relative to the directory that
|
||||
# configure is in, which we can look for to find out if srcdir is correct.
|
||||
ac_unique_file=gc_mark.h
|
||||
ac_unique_file=gcj_mlc.c
|
||||
|
||||
# Find the source files, if location was not specified.
|
||||
if test -z "$srcdir"; then
|
||||
|
@ -513,16 +506,12 @@ fi
|
|||
srcdir=`echo "${srcdir}" | sed 's%\([^/]\)/*$%\1%'`
|
||||
|
||||
# Prefer explicitly selected file to automatically selected ones.
|
||||
if test -z "$sitefile"; then
|
||||
if test -z "$CONFIG_SITE"; then
|
||||
if test "x$prefix" != xNONE; then
|
||||
CONFIG_SITE="$prefix/share/config.site $prefix/etc/config.site"
|
||||
else
|
||||
CONFIG_SITE="$ac_default_prefix/share/config.site $ac_default_prefix/etc/config.site"
|
||||
fi
|
||||
if test -z "$CONFIG_SITE"; then
|
||||
if test "x$prefix" != xNONE; then
|
||||
CONFIG_SITE="$prefix/share/config.site $prefix/etc/config.site"
|
||||
else
|
||||
CONFIG_SITE="$ac_default_prefix/share/config.site $ac_default_prefix/etc/config.site"
|
||||
fi
|
||||
else
|
||||
CONFIG_SITE="$sitefile"
|
||||
fi
|
||||
for ac_site_file in $CONFIG_SITE; do
|
||||
if test -r "$ac_site_file"; then
|
||||
|
@ -610,7 +599,7 @@ else { echo "configure: error: can not run $ac_config_sub" 1>&2; exit 1; }
|
|||
fi
|
||||
|
||||
echo $ac_n "checking host system type""... $ac_c" 1>&6
|
||||
echo "configure:614: checking host system type" >&5
|
||||
echo "configure:603: checking host system type" >&5
|
||||
|
||||
host_alias=$host
|
||||
case "$host_alias" in
|
||||
|
@ -631,7 +620,7 @@ host_os=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'`
|
|||
echo "$ac_t""$host" 1>&6
|
||||
|
||||
echo $ac_n "checking target system type""... $ac_c" 1>&6
|
||||
echo "configure:635: checking target system type" >&5
|
||||
echo "configure:624: checking target system type" >&5
|
||||
|
||||
target_alias=$target
|
||||
case "$target_alias" in
|
||||
|
@ -649,7 +638,7 @@ target_os=`echo $target | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'`
|
|||
echo "$ac_t""$target" 1>&6
|
||||
|
||||
echo $ac_n "checking build system type""... $ac_c" 1>&6
|
||||
echo "configure:653: checking build system type" >&5
|
||||
echo "configure:642: checking build system type" >&5
|
||||
|
||||
build_alias=$build
|
||||
case "$build_alias" in
|
||||
|
@ -684,7 +673,7 @@ test "$host_alias" != "$target_alias" &&
|
|||
# SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff"
|
||||
# ./install, which can be erroneously created by make from ./install.sh.
|
||||
echo $ac_n "checking for a BSD compatible install""... $ac_c" 1>&6
|
||||
echo "configure:688: checking for a BSD compatible install" >&5
|
||||
echo "configure:677: checking for a BSD compatible install" >&5
|
||||
if test -z "$INSTALL"; then
|
||||
if eval "test \"`echo '$''{'ac_cv_path_install'+set}'`\" = set"; then
|
||||
echo $ac_n "(cached) $ac_c" 1>&6
|
||||
|
@ -737,7 +726,7 @@ test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL_PROGRAM}'
|
|||
test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644'
|
||||
|
||||
echo $ac_n "checking whether build environment is sane""... $ac_c" 1>&6
|
||||
echo "configure:741: checking whether build environment is sane" >&5
|
||||
echo "configure:730: checking whether build environment is sane" >&5
|
||||
# Just in case
|
||||
sleep 1
|
||||
echo timestamp > conftestfile
|
||||
|
@ -794,7 +783,7 @@ test "$program_suffix" != NONE &&
|
|||
test "$program_transform_name" = "" && program_transform_name="s,x,x,"
|
||||
|
||||
echo $ac_n "checking whether ${MAKE-make} sets \${MAKE}""... $ac_c" 1>&6
|
||||
echo "configure:798: checking whether ${MAKE-make} sets \${MAKE}" >&5
|
||||
echo "configure:787: checking whether ${MAKE-make} sets \${MAKE}" >&5
|
||||
set dummy ${MAKE-make}; ac_make=`echo "$2" | sed 'y%./+-%__p_%'`
|
||||
if eval "test \"`echo '$''{'ac_cv_prog_make_${ac_make}_set'+set}'`\" = set"; then
|
||||
echo $ac_n "(cached) $ac_c" 1>&6
|
||||
|
@ -827,12 +816,12 @@ else
|
|||
fi
|
||||
|
||||
echo $ac_n "checking for Cygwin environment""... $ac_c" 1>&6
|
||||
echo "configure:831: checking for Cygwin environment" >&5
|
||||
echo "configure:820: checking for Cygwin environment" >&5
|
||||
if eval "test \"`echo '$''{'ac_cv_cygwin'+set}'`\" = set"; then
|
||||
echo $ac_n "(cached) $ac_c" 1>&6
|
||||
else
|
||||
cat > conftest.$ac_ext <<EOF
|
||||
#line 836 "configure"
|
||||
#line 825 "configure"
|
||||
#include "confdefs.h"
|
||||
|
||||
int main() {
|
||||
|
@ -843,7 +832,7 @@ int main() {
|
|||
return __CYGWIN__;
|
||||
; return 0; }
|
||||
EOF
|
||||
if { (eval echo configure:847: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
|
||||
if { (eval echo configure:836: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
|
||||
rm -rf conftest*
|
||||
ac_cv_cygwin=yes
|
||||
else
|
||||
|
@ -860,19 +849,19 @@ echo "$ac_t""$ac_cv_cygwin" 1>&6
|
|||
CYGWIN=
|
||||
test "$ac_cv_cygwin" = yes && CYGWIN=yes
|
||||
echo $ac_n "checking for mingw32 environment""... $ac_c" 1>&6
|
||||
echo "configure:864: checking for mingw32 environment" >&5
|
||||
echo "configure:853: checking for mingw32 environment" >&5
|
||||
if eval "test \"`echo '$''{'ac_cv_mingw32'+set}'`\" = set"; then
|
||||
echo $ac_n "(cached) $ac_c" 1>&6
|
||||
else
|
||||
cat > conftest.$ac_ext <<EOF
|
||||
#line 869 "configure"
|
||||
#line 858 "configure"
|
||||
#include "confdefs.h"
|
||||
|
||||
int main() {
|
||||
return __MINGW32__;
|
||||
; return 0; }
|
||||
EOF
|
||||
if { (eval echo configure:876: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
|
||||
if { (eval echo configure:865: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
|
||||
rm -rf conftest*
|
||||
ac_cv_mingw32=yes
|
||||
else
|
||||
|
@ -920,7 +909,7 @@ else { echo "configure: error: can not run $ac_config_sub" 1>&2; exit 1; }
|
|||
fi
|
||||
|
||||
echo $ac_n "checking host system type""... $ac_c" 1>&6
|
||||
echo "configure:924: checking host system type" >&5
|
||||
echo "configure:913: checking host system type" >&5
|
||||
|
||||
host_alias=$host
|
||||
case "$host_alias" in
|
||||
|
@ -954,7 +943,7 @@ fi
|
|||
|
||||
missing_dir=`cd $ac_aux_dir && pwd`
|
||||
echo $ac_n "checking for working aclocal""... $ac_c" 1>&6
|
||||
echo "configure:958: checking for working aclocal" >&5
|
||||
echo "configure:947: checking for working aclocal" >&5
|
||||
# Run test in a subshell; some versions of sh will print an error if
|
||||
# an executable is not found, even if stderr is redirected.
|
||||
# Redirect stdin to placate older versions of autoconf. Sigh.
|
||||
|
@ -967,7 +956,7 @@ else
|
|||
fi
|
||||
|
||||
echo $ac_n "checking for working autoconf""... $ac_c" 1>&6
|
||||
echo "configure:971: checking for working autoconf" >&5
|
||||
echo "configure:960: checking for working autoconf" >&5
|
||||
# Run test in a subshell; some versions of sh will print an error if
|
||||
# an executable is not found, even if stderr is redirected.
|
||||
# Redirect stdin to placate older versions of autoconf. Sigh.
|
||||
|
@ -980,7 +969,7 @@ else
|
|||
fi
|
||||
|
||||
echo $ac_n "checking for working automake""... $ac_c" 1>&6
|
||||
echo "configure:984: checking for working automake" >&5
|
||||
echo "configure:973: checking for working automake" >&5
|
||||
# Run test in a subshell; some versions of sh will print an error if
|
||||
# an executable is not found, even if stderr is redirected.
|
||||
# Redirect stdin to placate older versions of autoconf. Sigh.
|
||||
|
@ -993,7 +982,7 @@ else
|
|||
fi
|
||||
|
||||
echo $ac_n "checking for working autoheader""... $ac_c" 1>&6
|
||||
echo "configure:997: checking for working autoheader" >&5
|
||||
echo "configure:986: checking for working autoheader" >&5
|
||||
# Run test in a subshell; some versions of sh will print an error if
|
||||
# an executable is not found, even if stderr is redirected.
|
||||
# Redirect stdin to placate older versions of autoconf. Sigh.
|
||||
|
@ -1006,7 +995,7 @@ else
|
|||
fi
|
||||
|
||||
echo $ac_n "checking for working makeinfo""... $ac_c" 1>&6
|
||||
echo "configure:1010: checking for working makeinfo" >&5
|
||||
echo "configure:999: checking for working makeinfo" >&5
|
||||
# Run test in a subshell; some versions of sh will print an error if
|
||||
# an executable is not found, even if stderr is redirected.
|
||||
# Redirect stdin to placate older versions of autoconf. Sigh.
|
||||
|
@ -1032,7 +1021,7 @@ fi
|
|||
# Extract the first word of "gcc", so it can be a program name with args.
|
||||
set dummy gcc; ac_word=$2
|
||||
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
|
||||
echo "configure:1036: checking for $ac_word" >&5
|
||||
echo "configure:1025: checking for $ac_word" >&5
|
||||
if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
|
||||
echo $ac_n "(cached) $ac_c" 1>&6
|
||||
else
|
||||
|
@ -1062,7 +1051,7 @@ if test -z "$CC"; then
|
|||
# Extract the first word of "cc", so it can be a program name with args.
|
||||
set dummy cc; ac_word=$2
|
||||
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
|
||||
echo "configure:1066: checking for $ac_word" >&5
|
||||
echo "configure:1055: checking for $ac_word" >&5
|
||||
if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
|
||||
echo $ac_n "(cached) $ac_c" 1>&6
|
||||
else
|
||||
|
@ -1111,7 +1100,7 @@ fi
|
|||
fi
|
||||
|
||||
echo $ac_n "checking whether we are using GNU C""... $ac_c" 1>&6
|
||||
echo "configure:1115: checking whether we are using GNU C" >&5
|
||||
echo "configure:1104: checking whether we are using GNU C" >&5
|
||||
if eval "test \"`echo '$''{'ac_cv_prog_gcc'+set}'`\" = set"; then
|
||||
echo $ac_n "(cached) $ac_c" 1>&6
|
||||
else
|
||||
|
@ -1120,7 +1109,7 @@ else
|
|||
yes;
|
||||
#endif
|
||||
EOF
|
||||
if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:1124: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then
|
||||
if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:1113: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then
|
||||
ac_cv_prog_gcc=yes
|
||||
else
|
||||
ac_cv_prog_gcc=no
|
||||
|
@ -1135,7 +1124,7 @@ if test $ac_cv_prog_gcc = yes; then
|
|||
ac_save_CFLAGS="$CFLAGS"
|
||||
CFLAGS=
|
||||
echo $ac_n "checking whether ${CC-cc} accepts -g""... $ac_c" 1>&6
|
||||
echo "configure:1139: checking whether ${CC-cc} accepts -g" >&5
|
||||
echo "configure:1128: checking whether ${CC-cc} accepts -g" >&5
|
||||
if eval "test \"`echo '$''{'ac_cv_prog_cc_g'+set}'`\" = set"; then
|
||||
echo $ac_n "(cached) $ac_c" 1>&6
|
||||
else
|
||||
|
@ -1172,7 +1161,7 @@ do
|
|||
# Extract the first word of "$ac_prog", so it can be a program name with args.
|
||||
set dummy $ac_prog; ac_word=$2
|
||||
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
|
||||
echo "configure:1176: checking for $ac_word" >&5
|
||||
echo "configure:1165: checking for $ac_word" >&5
|
||||
if eval "test \"`echo '$''{'ac_cv_prog_CXX'+set}'`\" = set"; then
|
||||
echo $ac_n "(cached) $ac_c" 1>&6
|
||||
else
|
||||
|
@ -1205,7 +1194,7 @@ test -n "$CXX" || CXX="gcc"
|
|||
test -z "$CXX" && { echo "configure: error: no acceptable c++ found in \$PATH" 1>&2; exit 1; }
|
||||
|
||||
echo $ac_n "checking whether we are using GNU C++""... $ac_c" 1>&6
|
||||
echo "configure:1209: checking whether we are using GNU C++" >&5
|
||||
echo "configure:1198: checking whether we are using GNU C++" >&5
|
||||
if eval "test \"`echo '$''{'ac_cv_prog_gxx'+set}'`\" = set"; then
|
||||
echo $ac_n "(cached) $ac_c" 1>&6
|
||||
else
|
||||
|
@ -1214,7 +1203,7 @@ else
|
|||
yes;
|
||||
#endif
|
||||
EOF
|
||||
if { ac_try='${CXX-g++} -E conftest.C'; { (eval echo configure:1218: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then
|
||||
if { ac_try='${CXX-g++} -E conftest.C'; { (eval echo configure:1207: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then
|
||||
ac_cv_prog_gxx=yes
|
||||
else
|
||||
ac_cv_prog_gxx=no
|
||||
|
@ -1229,7 +1218,7 @@ if test $ac_cv_prog_gxx = yes; then
|
|||
ac_save_CXXFLAGS="$CXXFLAGS"
|
||||
CXXFLAGS=
|
||||
echo $ac_n "checking whether ${CXX-g++} accepts -g""... $ac_c" 1>&6
|
||||
echo "configure:1233: checking whether ${CXX-g++} accepts -g" >&5
|
||||
echo "configure:1222: checking whether ${CXX-g++} accepts -g" >&5
|
||||
if eval "test \"`echo '$''{'ac_cv_prog_cxx_g'+set}'`\" = set"; then
|
||||
echo $ac_n "(cached) $ac_c" 1>&6
|
||||
else
|
||||
|
@ -1262,7 +1251,7 @@ fi
|
|||
# NEWLIB_CONFIGURE, which doesn't work because that means that it will
|
||||
# be run before AC_CANONICAL_HOST.
|
||||
echo $ac_n "checking build system type""... $ac_c" 1>&6
|
||||
echo "configure:1266: checking build system type" >&5
|
||||
echo "configure:1255: checking build system type" >&5
|
||||
|
||||
build_alias=$build
|
||||
case "$build_alias" in
|
||||
|
@ -1283,7 +1272,7 @@ echo "$ac_t""$build" 1>&6
|
|||
# Extract the first word of "${ac_tool_prefix}as", so it can be a program name with args.
|
||||
set dummy ${ac_tool_prefix}as; ac_word=$2
|
||||
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
|
||||
echo "configure:1287: checking for $ac_word" >&5
|
||||
echo "configure:1276: checking for $ac_word" >&5
|
||||
if eval "test \"`echo '$''{'ac_cv_prog_AS'+set}'`\" = set"; then
|
||||
echo $ac_n "(cached) $ac_c" 1>&6
|
||||
else
|
||||
|
@ -1315,7 +1304,7 @@ fi
|
|||
# Extract the first word of "${ac_tool_prefix}ar", so it can be a program name with args.
|
||||
set dummy ${ac_tool_prefix}ar; ac_word=$2
|
||||
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
|
||||
echo "configure:1319: checking for $ac_word" >&5
|
||||
echo "configure:1308: checking for $ac_word" >&5
|
||||
if eval "test \"`echo '$''{'ac_cv_prog_AR'+set}'`\" = set"; then
|
||||
echo $ac_n "(cached) $ac_c" 1>&6
|
||||
else
|
||||
|
@ -1347,7 +1336,7 @@ fi
|
|||
# Extract the first word of "${ac_tool_prefix}ranlib", so it can be a program name with args.
|
||||
set dummy ${ac_tool_prefix}ranlib; ac_word=$2
|
||||
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
|
||||
echo "configure:1351: checking for $ac_word" >&5
|
||||
echo "configure:1340: checking for $ac_word" >&5
|
||||
if eval "test \"`echo '$''{'ac_cv_prog_RANLIB'+set}'`\" = set"; then
|
||||
echo $ac_n "(cached) $ac_c" 1>&6
|
||||
else
|
||||
|
@ -1379,7 +1368,7 @@ if test -n "$ac_tool_prefix"; then
|
|||
# Extract the first word of "ranlib", so it can be a program name with args.
|
||||
set dummy ranlib; ac_word=$2
|
||||
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
|
||||
echo "configure:1383: checking for $ac_word" >&5
|
||||
echo "configure:1372: checking for $ac_word" >&5
|
||||
if eval "test \"`echo '$''{'ac_cv_prog_RANLIB'+set}'`\" = set"; then
|
||||
echo $ac_n "(cached) $ac_c" 1>&6
|
||||
else
|
||||
|
@ -1424,7 +1413,7 @@ fi
|
|||
# SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff"
|
||||
# ./install, which can be erroneously created by make from ./install.sh.
|
||||
echo $ac_n "checking for a BSD compatible install""... $ac_c" 1>&6
|
||||
echo "configure:1428: checking for a BSD compatible install" >&5
|
||||
echo "configure:1417: checking for a BSD compatible install" >&5
|
||||
if test -z "$INSTALL"; then
|
||||
if eval "test \"`echo '$''{'ac_cv_path_install'+set}'`\" = set"; then
|
||||
echo $ac_n "(cached) $ac_c" 1>&6
|
||||
|
@ -1478,7 +1467,7 @@ test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644'
|
|||
|
||||
|
||||
echo $ac_n "checking whether to enable maintainer-specific portions of Makefiles""... $ac_c" 1>&6
|
||||
echo "configure:1482: checking whether to enable maintainer-specific portions of Makefiles" >&5
|
||||
echo "configure:1471: checking whether to enable maintainer-specific portions of Makefiles" >&5
|
||||
# Check whether --enable-maintainer-mode or --disable-maintainer-mode was given.
|
||||
if test "${enable_maintainer_mode+set}" = set; then
|
||||
enableval="$enable_maintainer_mode"
|
||||
|
@ -1512,7 +1501,7 @@ if false; then
|
|||
|
||||
|
||||
echo $ac_n "checking for executable suffix""... $ac_c" 1>&6
|
||||
echo "configure:1516: checking for executable suffix" >&5
|
||||
echo "configure:1505: checking for executable suffix" >&5
|
||||
if eval "test \"`echo '$''{'ac_cv_exeext'+set}'`\" = set"; then
|
||||
echo $ac_n "(cached) $ac_c" 1>&6
|
||||
else
|
||||
|
@ -1522,10 +1511,10 @@ else
|
|||
rm -f conftest*
|
||||
echo 'int main () { return 0; }' > conftest.$ac_ext
|
||||
ac_cv_exeext=
|
||||
if { (eval echo configure:1526: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; }; then
|
||||
if { (eval echo configure:1515: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; }; then
|
||||
for file in conftest.*; do
|
||||
case $file in
|
||||
*.c | *.o | *.obj | *.ilk | *.pdb) ;;
|
||||
*.c | *.o | *.obj) ;;
|
||||
*) ac_cv_exeext=`echo $file | sed -e s/conftest//` ;;
|
||||
esac
|
||||
done
|
||||
|
@ -1645,7 +1634,7 @@ ac_prog=ld
|
|||
if test "$GCC" = yes; then
|
||||
# Check if gcc -print-prog-name=ld gives a path.
|
||||
echo $ac_n "checking for ld used by GCC""... $ac_c" 1>&6
|
||||
echo "configure:1649: checking for ld used by GCC" >&5
|
||||
echo "configure:1638: checking for ld used by GCC" >&5
|
||||
case $host in
|
||||
*-*-mingw*)
|
||||
# gcc leaves a trailing carriage return which upsets mingw
|
||||
|
@ -1675,10 +1664,10 @@ echo "configure:1649: checking for ld used by GCC" >&5
|
|||
esac
|
||||
elif test "$with_gnu_ld" = yes; then
|
||||
echo $ac_n "checking for GNU ld""... $ac_c" 1>&6
|
||||
echo "configure:1679: checking for GNU ld" >&5
|
||||
echo "configure:1668: checking for GNU ld" >&5
|
||||
else
|
||||
echo $ac_n "checking for non-GNU ld""... $ac_c" 1>&6
|
||||
echo "configure:1682: checking for non-GNU ld" >&5
|
||||
echo "configure:1671: checking for non-GNU ld" >&5
|
||||
fi
|
||||
if eval "test \"`echo '$''{'lt_cv_path_LD'+set}'`\" = set"; then
|
||||
echo $ac_n "(cached) $ac_c" 1>&6
|
||||
|
@ -1713,7 +1702,7 @@ else
|
|||
fi
|
||||
test -z "$LD" && { echo "configure: error: no acceptable ld found in \$PATH" 1>&2; exit 1; }
|
||||
echo $ac_n "checking if the linker ($LD) is GNU ld""... $ac_c" 1>&6
|
||||
echo "configure:1717: checking if the linker ($LD) is GNU ld" >&5
|
||||
echo "configure:1706: checking if the linker ($LD) is GNU ld" >&5
|
||||
if eval "test \"`echo '$''{'lt_cv_prog_gnu_ld'+set}'`\" = set"; then
|
||||
echo $ac_n "(cached) $ac_c" 1>&6
|
||||
else
|
||||
|
@ -1730,7 +1719,7 @@ with_gnu_ld=$lt_cv_prog_gnu_ld
|
|||
|
||||
|
||||
echo $ac_n "checking for $LD option to reload object files""... $ac_c" 1>&6
|
||||
echo "configure:1734: checking for $LD option to reload object files" >&5
|
||||
echo "configure:1723: checking for $LD option to reload object files" >&5
|
||||
if eval "test \"`echo '$''{'lt_cv_ld_reload_flag'+set}'`\" = set"; then
|
||||
echo $ac_n "(cached) $ac_c" 1>&6
|
||||
else
|
||||
|
@ -1742,7 +1731,7 @@ reload_flag=$lt_cv_ld_reload_flag
|
|||
test -n "$reload_flag" && reload_flag=" $reload_flag"
|
||||
|
||||
echo $ac_n "checking for BSD-compatible nm""... $ac_c" 1>&6
|
||||
echo "configure:1746: checking for BSD-compatible nm" >&5
|
||||
echo "configure:1735: checking for BSD-compatible nm" >&5
|
||||
if eval "test \"`echo '$''{'lt_cv_path_NM'+set}'`\" = set"; then
|
||||
echo $ac_n "(cached) $ac_c" 1>&6
|
||||
else
|
||||
|
@ -1780,7 +1769,7 @@ NM="$lt_cv_path_NM"
|
|||
echo "$ac_t""$NM" 1>&6
|
||||
|
||||
echo $ac_n "checking whether ln -s works""... $ac_c" 1>&6
|
||||
echo "configure:1784: checking whether ln -s works" >&5
|
||||
echo "configure:1773: checking whether ln -s works" >&5
|
||||
if eval "test \"`echo '$''{'ac_cv_prog_LN_S'+set}'`\" = set"; then
|
||||
echo $ac_n "(cached) $ac_c" 1>&6
|
||||
else
|
||||
|
@ -1801,7 +1790,7 @@ else
|
|||
fi
|
||||
|
||||
echo $ac_n "checking how to recognise dependant libraries""... $ac_c" 1>&6
|
||||
echo "configure:1805: checking how to recognise dependant libraries" >&5
|
||||
echo "configure:1794: checking how to recognise dependant libraries" >&5
|
||||
if eval "test \"`echo '$''{'lt_cv_deplibs_check_method'+set}'`\" = set"; then
|
||||
echo $ac_n "(cached) $ac_c" 1>&6
|
||||
else
|
||||
|
@ -1965,13 +1954,13 @@ file_magic_cmd=$lt_cv_file_magic_cmd
|
|||
deplibs_check_method=$lt_cv_deplibs_check_method
|
||||
|
||||
echo $ac_n "checking for object suffix""... $ac_c" 1>&6
|
||||
echo "configure:1969: checking for object suffix" >&5
|
||||
echo "configure:1958: checking for object suffix" >&5
|
||||
if eval "test \"`echo '$''{'ac_cv_objext'+set}'`\" = set"; then
|
||||
echo $ac_n "(cached) $ac_c" 1>&6
|
||||
else
|
||||
rm -f conftest*
|
||||
echo 'int i = 1;' > conftest.$ac_ext
|
||||
if { (eval echo configure:1975: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
|
||||
if { (eval echo configure:1964: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
|
||||
for ac_file in conftest.*; do
|
||||
case $ac_file in
|
||||
*.c) ;;
|
||||
|
@ -1995,7 +1984,7 @@ case $deplibs_check_method in
|
|||
file_magic*)
|
||||
if test "$file_magic_cmd" = '$MAGIC_CMD'; then
|
||||
echo $ac_n "checking for ${ac_tool_prefix}file""... $ac_c" 1>&6
|
||||
echo "configure:1999: checking for ${ac_tool_prefix}file" >&5
|
||||
echo "configure:1988: checking for ${ac_tool_prefix}file" >&5
|
||||
if eval "test \"`echo '$''{'lt_cv_path_MAGIC_CMD'+set}'`\" = set"; then
|
||||
echo $ac_n "(cached) $ac_c" 1>&6
|
||||
else
|
||||
|
@ -2057,7 +2046,7 @@ fi
|
|||
if test -z "$lt_cv_path_MAGIC_CMD"; then
|
||||
if test -n "$ac_tool_prefix"; then
|
||||
echo $ac_n "checking for file""... $ac_c" 1>&6
|
||||
echo "configure:2061: checking for file" >&5
|
||||
echo "configure:2050: checking for file" >&5
|
||||
if eval "test \"`echo '$''{'lt_cv_path_MAGIC_CMD'+set}'`\" = set"; then
|
||||
echo $ac_n "(cached) $ac_c" 1>&6
|
||||
else
|
||||
|
@ -2128,7 +2117,7 @@ esac
|
|||
# Extract the first word of "${ac_tool_prefix}ranlib", so it can be a program name with args.
|
||||
set dummy ${ac_tool_prefix}ranlib; ac_word=$2
|
||||
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
|
||||
echo "configure:2132: checking for $ac_word" >&5
|
||||
echo "configure:2121: checking for $ac_word" >&5
|
||||
if eval "test \"`echo '$''{'ac_cv_prog_RANLIB'+set}'`\" = set"; then
|
||||
echo $ac_n "(cached) $ac_c" 1>&6
|
||||
else
|
||||
|
@ -2160,7 +2149,7 @@ if test -n "$ac_tool_prefix"; then
|
|||
# Extract the first word of "ranlib", so it can be a program name with args.
|
||||
set dummy ranlib; ac_word=$2
|
||||
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
|
||||
echo "configure:2164: checking for $ac_word" >&5
|
||||
echo "configure:2153: checking for $ac_word" >&5
|
||||
if eval "test \"`echo '$''{'ac_cv_prog_RANLIB'+set}'`\" = set"; then
|
||||
echo $ac_n "(cached) $ac_c" 1>&6
|
||||
else
|
||||
|
@ -2195,7 +2184,7 @@ fi
|
|||
# Extract the first word of "${ac_tool_prefix}strip", so it can be a program name with args.
|
||||
set dummy ${ac_tool_prefix}strip; ac_word=$2
|
||||
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
|
||||
echo "configure:2199: checking for $ac_word" >&5
|
||||
echo "configure:2188: checking for $ac_word" >&5
|
||||
if eval "test \"`echo '$''{'ac_cv_prog_STRIP'+set}'`\" = set"; then
|
||||
echo $ac_n "(cached) $ac_c" 1>&6
|
||||
else
|
||||
|
@ -2227,7 +2216,7 @@ if test -n "$ac_tool_prefix"; then
|
|||
# Extract the first word of "strip", so it can be a program name with args.
|
||||
set dummy strip; ac_word=$2
|
||||
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
|
||||
echo "configure:2231: checking for $ac_word" >&5
|
||||
echo "configure:2220: checking for $ac_word" >&5
|
||||
if eval "test \"`echo '$''{'ac_cv_prog_STRIP'+set}'`\" = set"; then
|
||||
echo $ac_n "(cached) $ac_c" 1>&6
|
||||
else
|
||||
|
@ -2294,8 +2283,8 @@ test x"$pic_mode" = xno && libtool_flags="$libtool_flags --prefer-non-pic"
|
|||
case $host in
|
||||
*-*-irix6*)
|
||||
# Find out which ABI we are using.
|
||||
echo '#line 2298 "configure"' > conftest.$ac_ext
|
||||
if { (eval echo configure:2299: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
|
||||
echo '#line 2287 "configure"' > conftest.$ac_ext
|
||||
if { (eval echo configure:2288: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
|
||||
case `/usr/bin/file conftest.$ac_objext` in
|
||||
*32-bit*)
|
||||
LD="${LD-ld} -32"
|
||||
|
@ -2316,7 +2305,7 @@ case $host in
|
|||
SAVE_CFLAGS="$CFLAGS"
|
||||
CFLAGS="$CFLAGS -belf"
|
||||
echo $ac_n "checking whether the C compiler needs -belf""... $ac_c" 1>&6
|
||||
echo "configure:2320: checking whether the C compiler needs -belf" >&5
|
||||
echo "configure:2309: checking whether the C compiler needs -belf" >&5
|
||||
if eval "test \"`echo '$''{'lt_cv_cc_needs_belf'+set}'`\" = set"; then
|
||||
echo $ac_n "(cached) $ac_c" 1>&6
|
||||
else
|
||||
|
@ -2329,14 +2318,14 @@ ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$a
|
|||
cross_compiling=$ac_cv_prog_cc_cross
|
||||
|
||||
cat > conftest.$ac_ext <<EOF
|
||||
#line 2333 "configure"
|
||||
#line 2322 "configure"
|
||||
#include "confdefs.h"
|
||||
|
||||
int main() {
|
||||
|
||||
; return 0; }
|
||||
EOF
|
||||
if { (eval echo configure:2340: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
|
||||
if { (eval echo configure:2329: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
|
||||
rm -rf conftest*
|
||||
lt_cv_cc_needs_belf=yes
|
||||
else
|
||||
|
@ -2366,7 +2355,7 @@ echo "$ac_t""$lt_cv_cc_needs_belf" 1>&6
|
|||
esac
|
||||
|
||||
echo $ac_n "checking how to run the C++ preprocessor""... $ac_c" 1>&6
|
||||
echo "configure:2370: checking how to run the C++ preprocessor" >&5
|
||||
echo "configure:2359: checking how to run the C++ preprocessor" >&5
|
||||
if test -z "$CXXCPP"; then
|
||||
if eval "test \"`echo '$''{'ac_cv_prog_CXXCPP'+set}'`\" = set"; then
|
||||
echo $ac_n "(cached) $ac_c" 1>&6
|
||||
|
@ -2379,12 +2368,12 @@ ac_link='${CXX-g++} -o conftest${ac_exeext} $CXXFLAGS $CPPFLAGS $LDFLAGS conftes
|
|||
cross_compiling=$ac_cv_prog_cxx_cross
|
||||
CXXCPP="${CXX-g++} -E"
|
||||
cat > conftest.$ac_ext <<EOF
|
||||
#line 2383 "configure"
|
||||
#line 2372 "configure"
|
||||
#include "confdefs.h"
|
||||
#include <stdlib.h>
|
||||
EOF
|
||||
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
|
||||
{ (eval echo configure:2388: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
|
||||
{ (eval echo configure:2377: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
|
||||
ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
|
||||
if test -z "$ac_err"; then
|
||||
:
|
||||
|
@ -2531,7 +2520,7 @@ fi
|
|||
|
||||
|
||||
echo $ac_n "checking whether to enable maintainer-specific portions of Makefiles""... $ac_c" 1>&6
|
||||
echo "configure:2535: checking whether to enable maintainer-specific portions of Makefiles" >&5
|
||||
echo "configure:2524: checking whether to enable maintainer-specific portions of Makefiles" >&5
|
||||
# Check whether --enable-maintainer-mode or --disable-maintainer-mode was given.
|
||||
if test "${enable_maintainer_mode+set}" = set; then
|
||||
enableval="$enable_maintainer_mode"
|
||||
|
@ -2560,7 +2549,7 @@ if test "x" = "y"; then
|
|||
|
||||
|
||||
echo $ac_n "checking for executable suffix""... $ac_c" 1>&6
|
||||
echo "configure:2564: checking for executable suffix" >&5
|
||||
echo "configure:2553: checking for executable suffix" >&5
|
||||
if eval "test \"`echo '$''{'ac_cv_exeext'+set}'`\" = set"; then
|
||||
echo $ac_n "(cached) $ac_c" 1>&6
|
||||
else
|
||||
|
@ -2570,10 +2559,10 @@ else
|
|||
rm -f conftest*
|
||||
echo 'int main () { return 0; }' > conftest.$ac_ext
|
||||
ac_cv_exeext=
|
||||
if { (eval echo configure:2574: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; }; then
|
||||
if { (eval echo configure:2563: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; }; then
|
||||
for file in conftest.*; do
|
||||
case $file in
|
||||
*.c | *.o | *.obj | *.ilk | *.pdb) ;;
|
||||
*.c | *.o | *.obj) ;;
|
||||
*) ac_cv_exeext=`echo $file | sed -e s/conftest//` ;;
|
||||
esac
|
||||
done
|
||||
|
@ -2593,11 +2582,11 @@ ac_exeext=$EXEEXT
|
|||
fi
|
||||
|
||||
echo $ac_n "checking for thread model used by GCC""... $ac_c" 1>&6
|
||||
echo "configure:2597: checking for thread model used by GCC" >&5
|
||||
echo "configure:2586: checking for thread model used by GCC" >&5
|
||||
THREADS=`$CC -v 2>&1 | sed -n 's/^Thread model: //p'`
|
||||
echo "$ac_t""$THREADS" 1>&6
|
||||
|
||||
INCLUDES=
|
||||
INCLUDES=-I${srcdir}/include
|
||||
THREADLIBS=
|
||||
case "$THREADS" in
|
||||
no | none | single)
|
||||
|
@ -2623,7 +2612,7 @@ EOF
|
|||
#define FREEBSD_THREADS 1
|
||||
EOF
|
||||
|
||||
INCLUDES=-pthread
|
||||
INCLUDES="$INCLUDES -pthread"
|
||||
THREADLIBS=-pthread
|
||||
;;
|
||||
*-*-solaris*)
|
||||
|
@ -2654,7 +2643,7 @@ esac
|
|||
|
||||
|
||||
echo $ac_n "checking for dlopen in -ldl""... $ac_c" 1>&6
|
||||
echo "configure:2658: checking for dlopen in -ldl" >&5
|
||||
echo "configure:2647: checking for dlopen in -ldl" >&5
|
||||
ac_lib_var=`echo dl'_'dlopen | sed 'y%./+-%__p_%'`
|
||||
if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
|
||||
echo $ac_n "(cached) $ac_c" 1>&6
|
||||
|
@ -2662,7 +2651,7 @@ else
|
|||
ac_save_LIBS="$LIBS"
|
||||
LIBS="-ldl $LIBS"
|
||||
cat > conftest.$ac_ext <<EOF
|
||||
#line 2666 "configure"
|
||||
#line 2655 "configure"
|
||||
#include "confdefs.h"
|
||||
/* Override any gcc2 internal prototype to avoid an error. */
|
||||
/* We use char because int might match the return type of a gcc2
|
||||
|
@ -2673,7 +2662,7 @@ int main() {
|
|||
dlopen()
|
||||
; return 0; }
|
||||
EOF
|
||||
if { (eval echo configure:2677: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
|
||||
if { (eval echo configure:2666: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
|
||||
rm -rf conftest*
|
||||
eval "ac_cv_lib_$ac_lib_var=yes"
|
||||
else
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
dnl Process this file with autoconf to produce configure.
|
||||
|
||||
AC_INIT(gc_mark.h)
|
||||
AC_INIT(gcj_mlc.c)
|
||||
|
||||
dnl Can't be done in BOEHM_CONFIGURE because that confuses automake.
|
||||
AC_CONFIG_AUX_DIR(..)
|
||||
|
@ -30,7 +30,7 @@ AC_MSG_CHECKING([for thread model used by GCC])
|
|||
THREADS=`$CC -v 2>&1 | sed -n 's/^Thread model: //p'`
|
||||
AC_MSG_RESULT([$THREADS])
|
||||
|
||||
INCLUDES=
|
||||
INCLUDES=-I${srcdir}/include
|
||||
THREADLIBS=
|
||||
case "$THREADS" in
|
||||
no | none | single)
|
||||
|
@ -47,7 +47,7 @@ case "$THREADS" in
|
|||
*-*-freebsd*)
|
||||
AC_MSG_WARN("FreeBSD does not yet fully support threads with Boehm GC.")
|
||||
AC_DEFINE(FREEBSD_THREADS)
|
||||
INCLUDES=-pthread
|
||||
INCLUDES="$INCLUDES -pthread"
|
||||
THREADLIBS=-pthread
|
||||
;;
|
||||
*-*-solaris*)
|
||||
|
|
|
@ -1,31 +0,0 @@
|
|||
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 (boehm@sgi.com).
|
||||
|
||||
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.
|
||||
|
||||
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.
|
|
@ -1,14 +0,0 @@
|
|||
MATH=STANDARD
|
||||
CPU=68030
|
||||
NOSTACKCHECK
|
||||
OPTIMIZE
|
||||
VERBOSE
|
||||
NOVERSION
|
||||
NOICONS
|
||||
OPTIMIZERTIME
|
||||
INCLUDEDIR=/
|
||||
DEFINE AMIGA
|
||||
LIBRARY=cord.lib
|
||||
LIBRARY=/gc.lib
|
||||
IGNORE=100
|
||||
IGNORE=161
|
|
@ -1,20 +0,0 @@
|
|||
# Makefile for cord.lib
|
||||
# Michel Schinz 1994/07/20
|
||||
|
||||
OBJS = cordbscs.o cordprnt.o cordxtra.o
|
||||
|
||||
all: cord.lib cordtest
|
||||
|
||||
cordbscs.o: cordbscs.c
|
||||
cordprnt.o: cordprnt.c
|
||||
cordxtra.o: cordxtra.c
|
||||
cordtest.o: cordtest.c
|
||||
|
||||
cord.lib: $(OBJS)
|
||||
oml cord.lib r $(OBJS)
|
||||
|
||||
cordtest: cordtest.o cord.lib
|
||||
sc cordtest.o link
|
||||
|
||||
clean:
|
||||
delete cord.lib cordtest \#?.o \#?.lnk
|
|
@ -1,327 +0,0 @@
|
|||
/*
|
||||
* 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.
|
||||
*
|
||||
* Author: Hans-J. Boehm (boehm@parc.xerox.com)
|
||||
*/
|
||||
/* Boehm, October 5, 1995 4:20 pm PDT */
|
||||
|
||||
/*
|
||||
* Cords are immutable character strings. A number of operations
|
||||
* on long cords are much more efficient than their strings.h counterpart.
|
||||
* In particular, concatenation takes constant time independent of the length
|
||||
* of the arguments. (Cords are represented as trees, with internal
|
||||
* nodes representing concatenation and leaves consisting of either C
|
||||
* strings or a functional description of the string.)
|
||||
*
|
||||
* The following are reasonable applications of cords. They would perform
|
||||
* unacceptably if C strings were used:
|
||||
* - A compiler that produces assembly language output by repeatedly
|
||||
* concatenating instructions onto a cord representing the output file.
|
||||
* - A text editor that converts the input file to a cord, and then
|
||||
* performs editing operations by producing a new cord representing
|
||||
* the file after echa character change (and keeping the old ones in an
|
||||
* edit history)
|
||||
*
|
||||
* For optimal performance, cords should be built by
|
||||
* concatenating short sections.
|
||||
* This interface is designed for maximum compatibility with C strings.
|
||||
* ASCII NUL characters may be embedded in cords using CORD_from_fn.
|
||||
* This is handled correctly, but CORD_to_char_star will produce a string
|
||||
* with embedded NULs when given such a cord.
|
||||
*
|
||||
* This interface is fairly big, largely for performance reasons.
|
||||
* The most basic constants and functions:
|
||||
*
|
||||
* CORD - the type of a cord;
|
||||
* CORD_EMPTY - empty cord;
|
||||
* CORD_len(cord) - length of a cord;
|
||||
* CORD_cat(cord1,cord2) - concatenation of two cords;
|
||||
* CORD_substr(cord, start, len) - substring (or subcord);
|
||||
* CORD_pos i; CORD_FOR(i, cord) { ... CORD_pos_fetch(i) ... } -
|
||||
* examine each character in a cord. CORD_pos_fetch(i) is the char.
|
||||
* CORD_fetch(int i) - Retrieve i'th character (slowly).
|
||||
* CORD_cmp(cord1, cord2) - compare two cords.
|
||||
* CORD_from_file(FILE * f) - turn a read-only file into a cord.
|
||||
* CORD_to_char_star(cord) - convert to C string.
|
||||
* (Non-NULL C constant strings are cords.)
|
||||
* CORD_printf (etc.) - cord version of printf. Use %r for cords.
|
||||
*/
|
||||
# ifndef CORD_H
|
||||
|
||||
# define CORD_H
|
||||
# include <stddef.h>
|
||||
# include <stdio.h>
|
||||
/* Cords have type const char *. This is cheating quite a bit, and not */
|
||||
/* 100% portable. But it means that nonempty character string */
|
||||
/* constants may be used as cords directly, provided the string is */
|
||||
/* never modified in place. The empty cord is represented by, and */
|
||||
/* can be written as, 0. */
|
||||
|
||||
typedef const char * CORD;
|
||||
|
||||
/* An empty cord is always represented as nil */
|
||||
# define CORD_EMPTY 0
|
||||
|
||||
/* Is a nonempty cord represented as a C string? */
|
||||
#define CORD_IS_STRING(s) (*(s) != '\0')
|
||||
|
||||
/* Concatenate two cords. If the arguments are C strings, they may */
|
||||
/* not be subsequently altered. */
|
||||
CORD CORD_cat(CORD x, CORD y);
|
||||
|
||||
/* Concatenate a cord and a C string with known length. Except for the */
|
||||
/* empty string case, this is a special case of CORD_cat. Since the */
|
||||
/* length is known, it can be faster. */
|
||||
/* The string y is shared with the resulting CORD. Hence it should */
|
||||
/* not be altered by the caller. */
|
||||
CORD CORD_cat_char_star(CORD x, const char * y, size_t leny);
|
||||
|
||||
/* Compute the length of a cord */
|
||||
size_t CORD_len(CORD x);
|
||||
|
||||
/* Cords may be represented by functions defining the ith character */
|
||||
typedef char (* CORD_fn)(size_t i, void * client_data);
|
||||
|
||||
/* Turn a functional description into a cord. */
|
||||
CORD CORD_from_fn(CORD_fn fn, void * client_data, size_t len);
|
||||
|
||||
/* Return the substring (subcord really) of x with length at most n, */
|
||||
/* starting at position i. (The initial character has position 0.) */
|
||||
CORD CORD_substr(CORD x, size_t i, size_t n);
|
||||
|
||||
/* Return the argument, but rebalanced to allow more efficient */
|
||||
/* character retrieval, substring operations, and comparisons. */
|
||||
/* This is useful only for cords that were built using repeated */
|
||||
/* concatenation. Guarantees log time access to the result, unless */
|
||||
/* x was obtained through a large number of repeated substring ops */
|
||||
/* or the embedded functional descriptions take longer to evaluate. */
|
||||
/* May reallocate significant parts of the cord. The argument is not */
|
||||
/* modified; only the result is balanced. */
|
||||
CORD CORD_balance(CORD x);
|
||||
|
||||
/* The following traverse a cord by applying a function to each */
|
||||
/* character. This is occasionally appropriate, especially where */
|
||||
/* speed is crucial. But, since C doesn't have nested functions, */
|
||||
/* clients of this sort of traversal are clumsy to write. Consider */
|
||||
/* the functions that operate on cord positions instead. */
|
||||
|
||||
/* Function to iteratively apply to individual characters in cord. */
|
||||
typedef int (* CORD_iter_fn)(char c, void * client_data);
|
||||
|
||||
/* Function to apply to substrings of a cord. Each substring is a */
|
||||
/* a C character string, not a general cord. */
|
||||
typedef int (* CORD_batched_iter_fn)(const char * s, void * client_data);
|
||||
# define CORD_NO_FN ((CORD_batched_iter_fn)0)
|
||||
|
||||
/* Apply f1 to each character in the cord, in ascending order, */
|
||||
/* starting at position i. If */
|
||||
/* f2 is not CORD_NO_FN, then multiple calls to f1 may be replaced by */
|
||||
/* a single call to f2. The parameter f2 is provided only to allow */
|
||||
/* some optimization by the client. This terminates when the right */
|
||||
/* end of this string is reached, or when f1 or f2 return != 0. In the */
|
||||
/* latter case CORD_iter returns != 0. Otherwise it returns 0. */
|
||||
/* The specified value of i must be < CORD_len(x). */
|
||||
int CORD_iter5(CORD x, size_t i, CORD_iter_fn f1,
|
||||
CORD_batched_iter_fn f2, void * client_data);
|
||||
|
||||
/* A simpler version that starts at 0, and without f2: */
|
||||
int CORD_iter(CORD x, CORD_iter_fn f1, void * client_data);
|
||||
# define CORD_iter(x, f1, cd) CORD_iter5(x, 0, f1, CORD_NO_FN, cd)
|
||||
|
||||
/* Similar to CORD_iter5, but end-to-beginning. No provisions for */
|
||||
/* CORD_batched_iter_fn. */
|
||||
int CORD_riter4(CORD x, size_t i, CORD_iter_fn f1, void * client_data);
|
||||
|
||||
/* A simpler version that starts at the end: */
|
||||
int CORD_riter(CORD x, CORD_iter_fn f1, void * client_data);
|
||||
|
||||
/* Functions that operate on cord positions. The easy way to traverse */
|
||||
/* cords. A cord position is logically a pair consisting of a cord */
|
||||
/* and an index into that cord. But it is much faster to retrieve a */
|
||||
/* charcter based on a position than on an index. Unfortunately, */
|
||||
/* positions are big (order of a few 100 bytes), so allocate them with */
|
||||
/* caution. */
|
||||
/* Things in cord_pos.h should be treated as opaque, except as */
|
||||
/* described below. Also note that */
|
||||
/* CORD_pos_fetch, CORD_next and CORD_prev have both macro and function */
|
||||
/* definitions. The former may evaluate their argument more than once. */
|
||||
# include "private/cord_pos.h"
|
||||
|
||||
/*
|
||||
Visible definitions from above:
|
||||
|
||||
typedef <OPAQUE but fairly big> CORD_pos[1];
|
||||
|
||||
* Extract the cord from a position:
|
||||
CORD CORD_pos_to_cord(CORD_pos p);
|
||||
|
||||
* Extract the current index from a position:
|
||||
size_t CORD_pos_to_index(CORD_pos p);
|
||||
|
||||
* Fetch the character located at the given position:
|
||||
char CORD_pos_fetch(CORD_pos p);
|
||||
|
||||
* Initialize the position to refer to the given cord and index.
|
||||
* Note that this is the most expensive function on positions:
|
||||
void CORD_set_pos(CORD_pos p, CORD x, size_t i);
|
||||
|
||||
* Advance the position to the next character.
|
||||
* P must be initialized and valid.
|
||||
* Invalidates p if past end:
|
||||
void CORD_next(CORD_pos p);
|
||||
|
||||
* Move the position to the preceding character.
|
||||
* P must be initialized and valid.
|
||||
* Invalidates p if past beginning:
|
||||
void CORD_prev(CORD_pos p);
|
||||
|
||||
* Is the position valid, i.e. inside the cord?
|
||||
int CORD_pos_valid(CORD_pos p);
|
||||
*/
|
||||
# define CORD_FOR(pos, cord) \
|
||||
for (CORD_set_pos(pos, cord, 0); CORD_pos_valid(pos); CORD_next(pos))
|
||||
|
||||
|
||||
/* An out of memory handler to call. May be supplied by client. */
|
||||
/* Must not return. */
|
||||
extern void (* CORD_oom_fn)(void);
|
||||
|
||||
/* Dump the representation of x to stdout in an implementation defined */
|
||||
/* manner. Intended for debugging only. */
|
||||
void CORD_dump(CORD x);
|
||||
|
||||
/* The following could easily be implemented by the client. They are */
|
||||
/* provided in cordxtra.c for convenience. */
|
||||
|
||||
/* Concatenate a character to the end of a cord. */
|
||||
CORD CORD_cat_char(CORD x, char c);
|
||||
|
||||
/* Concatenate n cords. */
|
||||
CORD CORD_catn(int n, /* CORD */ ...);
|
||||
|
||||
/* Return the character in CORD_substr(x, i, 1) */
|
||||
char CORD_fetch(CORD x, size_t i);
|
||||
|
||||
/* Return < 0, 0, or > 0, depending on whether x < y, x = y, x > y */
|
||||
int CORD_cmp(CORD x, CORD y);
|
||||
|
||||
/* A generalization that takes both starting positions for the */
|
||||
/* comparison, and a limit on the number of characters to be compared. */
|
||||
int CORD_ncmp(CORD x, size_t x_start, CORD y, size_t y_start, size_t len);
|
||||
|
||||
/* Find the first occurrence of s in x at position start or later. */
|
||||
/* Return the position of the first character of s in x, or */
|
||||
/* CORD_NOT_FOUND if there is none. */
|
||||
size_t CORD_str(CORD x, size_t start, CORD s);
|
||||
|
||||
/* Return a cord consisting of i copies of (possibly NUL) c. Dangerous */
|
||||
/* in conjunction with CORD_to_char_star. */
|
||||
/* The resulting representation takes constant space, independent of i. */
|
||||
CORD CORD_chars(char c, size_t i);
|
||||
# define CORD_nul(i) CORD_chars('\0', (i))
|
||||
|
||||
/* Turn a file into cord. The file must be seekable. Its contents */
|
||||
/* must remain constant. The file may be accessed as an immediate */
|
||||
/* result of this call and/or as a result of subsequent accesses to */
|
||||
/* the cord. Short files are likely to be immediately read, but */
|
||||
/* long files are likely to be read on demand, possibly relying on */
|
||||
/* stdio for buffering. */
|
||||
/* We must have exclusive access to the descriptor f, i.e. we may */
|
||||
/* read it at any time, and expect the file pointer to be */
|
||||
/* where we left it. Normally this should be invoked as */
|
||||
/* CORD_from_file(fopen(...)) */
|
||||
/* CORD_from_file arranges to close the file descriptor when it is no */
|
||||
/* longer needed (e.g. when the result becomes inaccessible). */
|
||||
/* The file f must be such that ftell reflects the actual character */
|
||||
/* position in the file, i.e. the number of characters that can be */
|
||||
/* or were read with fread. On UNIX systems this is always true. On */
|
||||
/* MS Windows systems, f must be opened in binary mode. */
|
||||
CORD CORD_from_file(FILE * f);
|
||||
|
||||
/* Equivalent to the above, except that the entire file will be read */
|
||||
/* and the file pointer will be closed immediately. */
|
||||
/* The binary mode restriction from above does not apply. */
|
||||
CORD CORD_from_file_eager(FILE * f);
|
||||
|
||||
/* Equivalent to the above, except that the file will be read on demand.*/
|
||||
/* The binary mode restriction applies. */
|
||||
CORD CORD_from_file_lazy(FILE * f);
|
||||
|
||||
/* Turn a cord into a C string. The result shares no structure with */
|
||||
/* x, and is thus modifiable. */
|
||||
char * CORD_to_char_star(CORD x);
|
||||
|
||||
/* Turn a C string into a CORD. The C string is copied, and so may */
|
||||
/* subsequently be modified. */
|
||||
CORD CORD_from_char_star(const char *s);
|
||||
|
||||
/* Identical to the above, but the result may share structure with */
|
||||
/* the argument and is thus not modifiable. */
|
||||
const char * CORD_to_const_char_star(CORD x);
|
||||
|
||||
/* Write a cord to a file, starting at the current position. No */
|
||||
/* trailing NULs are newlines are added. */
|
||||
/* Returns EOF if a write error occurs, 1 otherwise. */
|
||||
int CORD_put(CORD x, FILE * f);
|
||||
|
||||
/* "Not found" result for the following two functions. */
|
||||
# define CORD_NOT_FOUND ((size_t)(-1))
|
||||
|
||||
/* A vague analog of strchr. Returns the position (an integer, not */
|
||||
/* a pointer) of the first occurrence of (char) c inside x at position */
|
||||
/* i or later. The value i must be < CORD_len(x). */
|
||||
size_t CORD_chr(CORD x, size_t i, int c);
|
||||
|
||||
/* A vague analog of strrchr. Returns index of the last occurrence */
|
||||
/* of (char) c inside x at position i or earlier. The value i */
|
||||
/* must be < CORD_len(x). */
|
||||
size_t CORD_rchr(CORD x, size_t i, int c);
|
||||
|
||||
|
||||
/* The following are also not primitive, but are implemented in */
|
||||
/* cordprnt.c. They provide functionality similar to the ANSI C */
|
||||
/* functions with corresponding names, but with the following */
|
||||
/* additions and changes: */
|
||||
/* 1. A %r conversion specification specifies a CORD argument. Field */
|
||||
/* width, precision, etc. have the same semantics as for %s. */
|
||||
/* (Note that %c,%C, and %S were already taken.) */
|
||||
/* 2. The format string is represented as a CORD. */
|
||||
/* 3. CORD_sprintf and CORD_vsprintf assign the result through the 1st */ /* argument. Unlike their ANSI C versions, there is no need to guess */
|
||||
/* the correct buffer size. */
|
||||
/* 4. Most of the conversions are implement through the native */
|
||||
/* vsprintf. Hence they are usually no faster, and */
|
||||
/* idiosyncracies of the native printf are preserved. However, */
|
||||
/* CORD arguments to CORD_sprintf and CORD_vsprintf are NOT copied; */
|
||||
/* the result shares the original structure. This may make them */
|
||||
/* very efficient in some unusual applications. */
|
||||
/* The format string is copied. */
|
||||
/* All functions return the number of characters generated or -1 on */
|
||||
/* error. This complies with the ANSI standard, but is inconsistent */
|
||||
/* with some older implementations of sprintf. */
|
||||
|
||||
/* The implementation of these is probably less portable than the rest */
|
||||
/* of this package. */
|
||||
|
||||
#ifndef CORD_NO_IO
|
||||
|
||||
#include <stdarg.h>
|
||||
|
||||
int CORD_sprintf(CORD * out, CORD format, ...);
|
||||
int CORD_vsprintf(CORD * out, CORD format, va_list args);
|
||||
int CORD_fprintf(FILE * f, CORD format, ...);
|
||||
int CORD_vfprintf(FILE * f, CORD format, va_list args);
|
||||
int CORD_printf(CORD format, ...);
|
||||
int CORD_vprintf(CORD format, va_list args);
|
||||
|
||||
#endif /* CORD_NO_IO */
|
||||
|
||||
# endif /* CORD_H */
|
|
@ -1,70 +0,0 @@
|
|||
# ifndef EC_H
|
||||
# define EC_H
|
||||
|
||||
# ifndef CORD_H
|
||||
# include "cord.h"
|
||||
# endif
|
||||
|
||||
/* Extensible cords are strings that may be destructively appended to. */
|
||||
/* They allow fast construction of cords from characters that are */
|
||||
/* being read from a stream. */
|
||||
/*
|
||||
* A client might look like:
|
||||
*
|
||||
* {
|
||||
* CORD_ec x;
|
||||
* CORD result;
|
||||
* char c;
|
||||
* FILE *f;
|
||||
*
|
||||
* ...
|
||||
* CORD_ec_init(x);
|
||||
* while(...) {
|
||||
* c = getc(f);
|
||||
* ...
|
||||
* CORD_ec_append(x, c);
|
||||
* }
|
||||
* result = CORD_balance(CORD_ec_to_cord(x));
|
||||
*
|
||||
* If a C string is desired as the final result, the call to CORD_balance
|
||||
* may be replaced by a call to CORD_to_char_star.
|
||||
*/
|
||||
|
||||
# ifndef CORD_BUFSZ
|
||||
# define CORD_BUFSZ 128
|
||||
# endif
|
||||
|
||||
typedef struct CORD_ec_struct {
|
||||
CORD ec_cord;
|
||||
char * ec_bufptr;
|
||||
char ec_buf[CORD_BUFSZ+1];
|
||||
} CORD_ec[1];
|
||||
|
||||
/* This structure represents the concatenation of ec_cord with */
|
||||
/* ec_buf[0 ... (ec_bufptr-ec_buf-1)] */
|
||||
|
||||
/* Flush the buffer part of the extended chord into ec_cord. */
|
||||
/* 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)
|
||||
|
||||
/* Initialize an extensible cord. */
|
||||
# define CORD_ec_init(x) ((x)[0].ec_cord = 0, (x)[0].ec_bufptr = (x)[0].ec_buf)
|
||||
|
||||
/* Append a character to an extensible cord. */
|
||||
# define CORD_ec_append(x, c) \
|
||||
{ \
|
||||
if ((x)[0].ec_bufptr == (x)[0].ec_buf + CORD_BUFSZ) { \
|
||||
CORD_ec_flush_buf(x); \
|
||||
} \
|
||||
*((x)[0].ec_bufptr)++ = (c); \
|
||||
}
|
||||
|
||||
/* Append a cord to an extensible cord. Structure remains shared with */
|
||||
/* original. */
|
||||
void CORD_ec_append_cord(CORD_ec x, CORD s);
|
||||
|
||||
# endif /* EC_H */
|
|
@ -1,804 +0,0 @@
|
|||
/*
|
||||
* Copyright 1988, 1989 Hans-J. Boehm, Alan J. Demers
|
||||
* Copyright (c) 1991-1995 by Xerox Corporation. All rights reserved.
|
||||
* Copyright 1996-1999 by Silicon Graphics. All rights reserved.
|
||||
* Copyright 1999 by Hewlett-Packard Company. 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Note that this defines a large number of tuning hooks, which can
|
||||
* safely be ignored in nearly all cases. For normal use it suffices
|
||||
* to call only GC_MALLOC and perhaps GC_REALLOC.
|
||||
* For better performance, also look at GC_MALLOC_ATOMIC, and
|
||||
* GC_enable_incremental. If you need an action to be performed
|
||||
* immediately before an object is collected, look at GC_register_finalizer.
|
||||
* If you are using Solaris threads, look at the end of this file.
|
||||
* Everything else is best ignored unless you encounter performance
|
||||
* problems.
|
||||
*/
|
||||
|
||||
#ifndef _GC_H
|
||||
|
||||
# define _GC_H
|
||||
# define __GC
|
||||
# include <stddef.h>
|
||||
|
||||
#if defined(__CYGWIN32__) && defined(GC_USE_DLL)
|
||||
#include "libgc_globals.h"
|
||||
#endif
|
||||
|
||||
#if defined(__MINGW32__) && defined(WIN32_THREADS)
|
||||
# ifdef GC_BUILD
|
||||
# define GC_API __declspec(dllexport)
|
||||
# else
|
||||
# define GC_API __declspec(dllimport)
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if defined(_MSC_VER) && defined(_DLL)
|
||||
# ifdef GC_BUILD
|
||||
# define GC_API __declspec(dllexport)
|
||||
# else
|
||||
# define GC_API __declspec(dllimport)
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if defined(__WATCOMC__) && defined(GC_DLL)
|
||||
# ifdef GC_BUILD
|
||||
# define GC_API extern __declspec(dllexport)
|
||||
# else
|
||||
# define GC_API extern __declspec(dllimport)
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef GC_API
|
||||
#define GC_API extern
|
||||
#endif
|
||||
|
||||
# if defined(__STDC__) || defined(__cplusplus)
|
||||
# define GC_PROTO(args) args
|
||||
typedef void * GC_PTR;
|
||||
# define GC_CONST const
|
||||
# else
|
||||
# define GC_PROTO(args) ()
|
||||
typedef char * GC_PTR;
|
||||
# define GC_CONST
|
||||
# endif
|
||||
|
||||
# ifdef __cplusplus
|
||||
extern "C" {
|
||||
# endif
|
||||
|
||||
|
||||
/* Define word and signed_word to be unsigned and signed types of the */
|
||||
/* size as char * or void *. There seems to be no way to do this */
|
||||
/* even semi-portably. The following is probably no better/worse */
|
||||
/* than almost anything else. */
|
||||
/* The ANSI standard suggests that size_t and ptr_diff_t might be */
|
||||
/* better choices. But those appear to have incorrect definitions */
|
||||
/* on may systems. Notably "typedef int size_t" seems to be both */
|
||||
/* frequent and WRONG. */
|
||||
typedef unsigned long GC_word;
|
||||
typedef long GC_signed_word;
|
||||
|
||||
/* Public read-only variables */
|
||||
|
||||
GC_API GC_word GC_gc_no;/* Counter incremented per collection. */
|
||||
/* Includes empty GCs at startup. */
|
||||
|
||||
|
||||
/* Public R/W variables */
|
||||
|
||||
GC_API GC_PTR (*GC_oom_fn) GC_PROTO((size_t bytes_requested));
|
||||
/* When there is insufficient memory to satisfy */
|
||||
/* an allocation request, we return */
|
||||
/* (*GC_oom_fn)(). By default this just */
|
||||
/* returns 0. */
|
||||
/* If it returns, it must return 0 or a valid */
|
||||
/* pointer to a previously allocated heap */
|
||||
/* object. */
|
||||
|
||||
GC_API int GC_find_leak;
|
||||
/* Do not actually garbage collect, but simply */
|
||||
/* report inaccessible memory that was not */
|
||||
/* deallocated with GC_free. Initial value */
|
||||
/* is determined by FIND_LEAK macro. */
|
||||
|
||||
GC_API int GC_quiet; /* Disable statistics output. Only matters if */
|
||||
/* collector has been compiled with statistics */
|
||||
/* enabled. This involves a performance cost, */
|
||||
/* and is thus not the default. */
|
||||
|
||||
GC_API int GC_finalize_on_demand;
|
||||
/* If nonzero, finalizers will only be run in */
|
||||
/* response to an eplit GC_invoke_finalizers */
|
||||
/* call. The default is determined by whether */
|
||||
/* the FINALIZE_ON_DEMAND macro is defined */
|
||||
/* when the collector is built. */
|
||||
|
||||
GC_API int GC_java_finalization;
|
||||
/* Mark objects reachable from finalizable */
|
||||
/* objects in a separate postpass. This makes */
|
||||
/* it a bit safer to use non-topologically- */
|
||||
/* ordered finalization. Default value is */
|
||||
/* determined by JAVA_FINALIZATION macro. */
|
||||
|
||||
GC_API int GC_dont_gc; /* Dont collect unless explicitly requested, e.g. */
|
||||
/* because it's not safe. */
|
||||
|
||||
GC_API int GC_dont_expand;
|
||||
/* Dont expand heap unless explicitly requested */
|
||||
/* or forced to. */
|
||||
|
||||
GC_API int GC_use_entire_heap;
|
||||
/* Causes the nonincremental collector to use the */
|
||||
/* entire heap before collecting. This was the only */
|
||||
/* option for GC versions < 5.0. This sometimes */
|
||||
/* results in more large block fragmentation, since */
|
||||
/* very larg blocks will tend to get broken up */
|
||||
/* during each GC cycle. It is likely to result in a */
|
||||
/* larger working set, but lower collection */
|
||||
/* frequencies, and hence fewer instructions executed */
|
||||
/* in the collector. */
|
||||
|
||||
GC_API int GC_full_freq; /* Number of partial collections between */
|
||||
/* full collections. Matters only if */
|
||||
/* GC_incremental is set. */
|
||||
/* Full collections are also triggered if */
|
||||
/* the collector detects a substantial */
|
||||
/* increase in the number of in-use heap */
|
||||
/* blocks. Values in the tens are now */
|
||||
/* perfectly reasonable, unlike for */
|
||||
/* earlier GC versions. */
|
||||
|
||||
GC_API GC_word GC_non_gc_bytes;
|
||||
/* Bytes not considered candidates for collection. */
|
||||
/* Used only to control scheduling of collections. */
|
||||
|
||||
GC_API GC_word GC_free_space_divisor;
|
||||
/* We try to make sure that we allocate at */
|
||||
/* least N/GC_free_space_divisor bytes between */
|
||||
/* collections, where N is the heap size plus */
|
||||
/* a rough estimate of the root set size. */
|
||||
/* Initially, GC_free_space_divisor = 4. */
|
||||
/* Increasing its value will use less space */
|
||||
/* but more collection time. Decreasing it */
|
||||
/* will appreciably decrease collection time */
|
||||
/* at the expense of space. */
|
||||
/* GC_free_space_divisor = 1 will effectively */
|
||||
/* disable collections. */
|
||||
|
||||
GC_API GC_word GC_max_retries;
|
||||
/* The maximum number of GCs attempted before */
|
||||
/* reporting out of memory after heap */
|
||||
/* expansion fails. Initially 0. */
|
||||
|
||||
|
||||
GC_API char *GC_stackbottom; /* Cool end of user stack. */
|
||||
/* May be set in the client prior to */
|
||||
/* calling any GC_ routines. This */
|
||||
/* avoids some overhead, and */
|
||||
/* potentially some signals that can */
|
||||
/* confuse debuggers. Otherwise the */
|
||||
/* collector attempts to set it */
|
||||
/* automatically. */
|
||||
/* For multithreaded code, this is the */
|
||||
/* cold end of the stack for the */
|
||||
/* primordial thread. */
|
||||
|
||||
/* Public procedures */
|
||||
/*
|
||||
* general purpose allocation routines, with roughly malloc calling conv.
|
||||
* The atomic versions promise that no relevant pointers are contained
|
||||
* in the object. The nonatomic versions guarantee that the new object
|
||||
* is cleared. GC_malloc_stubborn promises that no changes to the object
|
||||
* will occur after GC_end_stubborn_change has been called on the
|
||||
* result of GC_malloc_stubborn. GC_malloc_uncollectable allocates an object
|
||||
* that is scanned for pointers to collectable objects, but is not itself
|
||||
* collectable. GC_malloc_uncollectable and GC_free called on the resulting
|
||||
* object implicitly update GC_non_gc_bytes appropriately.
|
||||
*/
|
||||
GC_API GC_PTR GC_malloc GC_PROTO((size_t size_in_bytes));
|
||||
GC_API GC_PTR GC_malloc_atomic GC_PROTO((size_t size_in_bytes));
|
||||
GC_API GC_PTR GC_malloc_uncollectable GC_PROTO((size_t size_in_bytes));
|
||||
GC_API GC_PTR GC_malloc_stubborn GC_PROTO((size_t size_in_bytes));
|
||||
|
||||
/* The following is only defined if the library has been suitably */
|
||||
/* compiled: */
|
||||
GC_API GC_PTR GC_malloc_atomic_uncollectable GC_PROTO((size_t size_in_bytes));
|
||||
|
||||
/* Explicitly deallocate an object. Dangerous if used incorrectly. */
|
||||
/* Requires a pointer to the base of an object. */
|
||||
/* If the argument is stubborn, it should not be changeable when freed. */
|
||||
/* An object should not be enable for finalization when it is */
|
||||
/* explicitly deallocated. */
|
||||
/* GC_free(0) is a no-op, as required by ANSI C for free. */
|
||||
GC_API void GC_free GC_PROTO((GC_PTR object_addr));
|
||||
|
||||
/*
|
||||
* Stubborn objects may be changed only if the collector is explicitly informed.
|
||||
* The collector is implicitly informed of coming change when such
|
||||
* an object is first allocated. The following routines inform the
|
||||
* collector that an object will no longer be changed, or that it will
|
||||
* once again be changed. Only nonNIL pointer stores into the object
|
||||
* are considered to be changes. The argument to GC_end_stubborn_change
|
||||
* must be exacly the value returned by GC_malloc_stubborn or passed to
|
||||
* GC_change_stubborn. (In the second case it may be an interior pointer
|
||||
* within 512 bytes of the beginning of the objects.)
|
||||
* There is a performance penalty for allowing more than
|
||||
* one stubborn object to be changed at once, but it is acceptable to
|
||||
* do so. The same applies to dropping stubborn objects that are still
|
||||
* changeable.
|
||||
*/
|
||||
GC_API void GC_change_stubborn GC_PROTO((GC_PTR));
|
||||
GC_API void GC_end_stubborn_change GC_PROTO((GC_PTR));
|
||||
|
||||
/* Return a pointer to the base (lowest address) of an object given */
|
||||
/* a pointer to a location within the object. */
|
||||
/* Return 0 if displaced_pointer doesn't point to within a valid */
|
||||
/* object. */
|
||||
GC_API GC_PTR GC_base GC_PROTO((GC_PTR displaced_pointer));
|
||||
|
||||
/* Given a pointer to the base of an object, return its size in bytes. */
|
||||
/* The returned size may be slightly larger than what was originally */
|
||||
/* requested. */
|
||||
GC_API size_t GC_size GC_PROTO((GC_PTR object_addr));
|
||||
|
||||
/* For compatibility with C library. This is occasionally faster than */
|
||||
/* a malloc followed by a bcopy. But if you rely on that, either here */
|
||||
/* or with the standard C library, your code is broken. In my */
|
||||
/* opinion, it shouldn't have been invented, but now we're stuck. -HB */
|
||||
/* The resulting object has the same kind as the original. */
|
||||
/* If the argument is stubborn, the result will have changes enabled. */
|
||||
/* It is an error to have changes enabled for the original object. */
|
||||
/* Follows ANSI comventions for NULL old_object. */
|
||||
GC_API GC_PTR GC_realloc
|
||||
GC_PROTO((GC_PTR old_object, size_t new_size_in_bytes));
|
||||
|
||||
/* Explicitly increase the heap size. */
|
||||
/* Returns 0 on failure, 1 on success. */
|
||||
GC_API int GC_expand_hp GC_PROTO((size_t number_of_bytes));
|
||||
|
||||
/* Limit the heap size to n bytes. Useful when you're debugging, */
|
||||
/* especially on systems that don't handle running out of memory well. */
|
||||
/* n == 0 ==> unbounded. This is the default. */
|
||||
GC_API void GC_set_max_heap_size GC_PROTO((GC_word n));
|
||||
|
||||
/* Inform the collector that a certain section of statically allocated */
|
||||
/* memory contains no pointers to garbage collected memory. Thus it */
|
||||
/* need not be scanned. This is sometimes important if the application */
|
||||
/* maps large read/write files into the address space, which could be */
|
||||
/* mistaken for dynamic library data segments on some systems. */
|
||||
GC_API void GC_exclude_static_roots GC_PROTO((GC_PTR start, GC_PTR finish));
|
||||
|
||||
/* Clear the set of root segments. Wizards only. */
|
||||
GC_API void GC_clear_roots GC_PROTO((void));
|
||||
|
||||
/* Add a root segment. Wizards only. */
|
||||
GC_API void GC_add_roots GC_PROTO((char * low_address,
|
||||
char * high_address_plus_1));
|
||||
|
||||
/* Add a displacement to the set of those considered valid by the */
|
||||
/* collector. GC_register_displacement(n) means that if p was returned */
|
||||
/* by GC_malloc, then (char *)p + n will be considered to be a valid */
|
||||
/* pointer to n. N must be small and less than the size of p. */
|
||||
/* (All pointers to the interior of objects from the stack are */
|
||||
/* considered valid in any case. This applies to heap objects and */
|
||||
/* static data.) */
|
||||
/* Preferably, this should be called before any other GC procedures. */
|
||||
/* Calling it later adds to the probability of excess memory */
|
||||
/* retention. */
|
||||
/* This is a no-op if the collector was compiled with recognition of */
|
||||
/* arbitrary interior pointers enabled, which is now the default. */
|
||||
GC_API void GC_register_displacement GC_PROTO((GC_word n));
|
||||
|
||||
/* The following version should be used if any debugging allocation is */
|
||||
/* being done. */
|
||||
GC_API void GC_debug_register_displacement GC_PROTO((GC_word n));
|
||||
|
||||
/* Explicitly trigger a full, world-stop collection. */
|
||||
GC_API void GC_gcollect GC_PROTO((void));
|
||||
|
||||
/* Trigger a full world-stopped collection. Abort the collection if */
|
||||
/* and when stop_func returns a nonzero value. Stop_func will be */
|
||||
/* called frequently, and should be reasonably fast. This works even */
|
||||
/* if virtual dirty bits, and hence incremental collection is not */
|
||||
/* available for this architecture. Collections can be aborted faster */
|
||||
/* than normal pause times for incremental collection. However, */
|
||||
/* aborted collections do no useful work; the next collection needs */
|
||||
/* to start from the beginning. */
|
||||
/* Return 0 if the collection was aborted, 1 if it succeeded. */
|
||||
typedef int (* GC_stop_func) GC_PROTO((void));
|
||||
GC_API int GC_try_to_collect GC_PROTO((GC_stop_func stop_func));
|
||||
|
||||
/* Return the number of bytes in the heap. Excludes collector private */
|
||||
/* data structures. Includes empty blocks and fragmentation loss. */
|
||||
/* Includes some pages that were allocated but never written. */
|
||||
GC_API size_t GC_get_heap_size GC_PROTO((void));
|
||||
|
||||
/* Return a lower bound on the number of free bytes in the heap. */
|
||||
GC_API size_t GC_get_free_bytes GC_PROTO((void));
|
||||
|
||||
/* Return the number of bytes allocated since the last collection. */
|
||||
GC_API size_t GC_get_bytes_since_gc GC_PROTO((void));
|
||||
|
||||
/* Enable incremental/generational collection. */
|
||||
/* Not advisable unless dirty bits are */
|
||||
/* available or most heap objects are */
|
||||
/* pointerfree(atomic) or immutable. */
|
||||
/* Don't use in leak finding mode. */
|
||||
/* Ignored if GC_dont_gc is true. */
|
||||
GC_API void GC_enable_incremental GC_PROTO((void));
|
||||
|
||||
/* Perform some garbage collection work, if appropriate. */
|
||||
/* Return 0 if there is no more work to be done. */
|
||||
/* Typically performs an amount of work corresponding roughly */
|
||||
/* to marking from one page. May do more work if further */
|
||||
/* progress requires it, e.g. if incremental collection is */
|
||||
/* disabled. It is reasonable to call this in a wait loop */
|
||||
/* until it returns 0. */
|
||||
GC_API int GC_collect_a_little GC_PROTO((void));
|
||||
|
||||
/* Allocate an object of size lb bytes. The client guarantees that */
|
||||
/* as long as the object is live, it will be referenced by a pointer */
|
||||
/* that points to somewhere within the first 256 bytes of the object. */
|
||||
/* (This should normally be declared volatile to prevent the compiler */
|
||||
/* from invalidating this assertion.) This routine is only useful */
|
||||
/* if a large array is being allocated. It reduces the chance of */
|
||||
/* accidentally retaining such an array as a result of scanning an */
|
||||
/* integer that happens to be an address inside the array. (Actually, */
|
||||
/* it reduces the chance of the allocator not finding space for such */
|
||||
/* an array, since it will try hard to avoid introducing such a false */
|
||||
/* reference.) On a SunOS 4.X or MS Windows system this is recommended */
|
||||
/* for arrays likely to be larger than 100K or so. For other systems, */
|
||||
/* or if the collector is not configured to recognize all interior */
|
||||
/* pointers, the threshold is normally much higher. */
|
||||
GC_API GC_PTR GC_malloc_ignore_off_page GC_PROTO((size_t lb));
|
||||
GC_API GC_PTR GC_malloc_atomic_ignore_off_page GC_PROTO((size_t lb));
|
||||
|
||||
#if defined(__sgi) && !defined(__GNUC__) && _COMPILER_VERSION >= 720
|
||||
# define GC_ADD_CALLER
|
||||
# define GC_RETURN_ADDR (GC_word)__return_address
|
||||
#endif
|
||||
|
||||
#ifdef GC_ADD_CALLER
|
||||
# define GC_EXTRAS GC_RETURN_ADDR, __FILE__, __LINE__
|
||||
# define GC_EXTRA_PARAMS GC_word ra, GC_CONST char * s, int i
|
||||
#else
|
||||
# define GC_EXTRAS __FILE__, __LINE__
|
||||
# define GC_EXTRA_PARAMS GC_CONST char * s, int i
|
||||
#endif
|
||||
|
||||
/* Debugging (annotated) allocation. GC_gcollect will check */
|
||||
/* objects allocated in this way for overwrites, etc. */
|
||||
GC_API GC_PTR GC_debug_malloc
|
||||
GC_PROTO((size_t size_in_bytes, GC_EXTRA_PARAMS));
|
||||
GC_API GC_PTR GC_debug_malloc_atomic
|
||||
GC_PROTO((size_t size_in_bytes, GC_EXTRA_PARAMS));
|
||||
GC_API GC_PTR GC_debug_malloc_uncollectable
|
||||
GC_PROTO((size_t size_in_bytes, GC_EXTRA_PARAMS));
|
||||
GC_API GC_PTR GC_debug_malloc_stubborn
|
||||
GC_PROTO((size_t size_in_bytes, GC_EXTRA_PARAMS));
|
||||
GC_API void GC_debug_free GC_PROTO((GC_PTR object_addr));
|
||||
GC_API GC_PTR GC_debug_realloc
|
||||
GC_PROTO((GC_PTR old_object, size_t new_size_in_bytes,
|
||||
GC_EXTRA_PARAMS));
|
||||
|
||||
GC_API void GC_debug_change_stubborn GC_PROTO((GC_PTR));
|
||||
GC_API void GC_debug_end_stubborn_change GC_PROTO((GC_PTR));
|
||||
# ifdef GC_DEBUG
|
||||
# define GC_MALLOC(sz) GC_debug_malloc(sz, GC_EXTRAS)
|
||||
# define GC_MALLOC_ATOMIC(sz) GC_debug_malloc_atomic(sz, GC_EXTRAS)
|
||||
# define GC_MALLOC_UNCOLLECTABLE(sz) GC_debug_malloc_uncollectable(sz, \
|
||||
GC_EXTRAS)
|
||||
# define GC_REALLOC(old, sz) GC_debug_realloc(old, sz, GC_EXTRAS)
|
||||
# define GC_FREE(p) GC_debug_free(p)
|
||||
# define GC_REGISTER_FINALIZER(p, f, d, of, od) \
|
||||
GC_debug_register_finalizer(p, f, d, of, od)
|
||||
# define GC_REGISTER_FINALIZER_IGNORE_SELF(p, f, d, of, od) \
|
||||
GC_debug_register_finalizer_ignore_self(p, f, d, of, od)
|
||||
# define GC_REGISTER_FINALIZER_NO_ORDER(p, f, d, of, od) \
|
||||
GC_debug_register_finalizer_no_order(p, f, d, of, od)
|
||||
# define GC_MALLOC_STUBBORN(sz) GC_debug_malloc_stubborn(sz, GC_EXTRAS);
|
||||
# define GC_CHANGE_STUBBORN(p) GC_debug_change_stubborn(p)
|
||||
# define GC_END_STUBBORN_CHANGE(p) GC_debug_end_stubborn_change(p)
|
||||
# define GC_GENERAL_REGISTER_DISAPPEARING_LINK(link, obj) \
|
||||
GC_general_register_disappearing_link(link, GC_base(obj))
|
||||
# define GC_REGISTER_DISPLACEMENT(n) GC_debug_register_displacement(n)
|
||||
# else
|
||||
# define GC_MALLOC(sz) GC_malloc(sz)
|
||||
# define GC_MALLOC_ATOMIC(sz) GC_malloc_atomic(sz)
|
||||
# define GC_MALLOC_UNCOLLECTABLE(sz) GC_malloc_uncollectable(sz)
|
||||
# define GC_REALLOC(old, sz) GC_realloc(old, sz)
|
||||
# define GC_FREE(p) GC_free(p)
|
||||
# define GC_REGISTER_FINALIZER(p, f, d, of, od) \
|
||||
GC_register_finalizer(p, f, d, of, od)
|
||||
# define GC_REGISTER_FINALIZER_IGNORE_SELF(p, f, d, of, od) \
|
||||
GC_register_finalizer_ignore_self(p, f, d, of, od)
|
||||
# define GC_REGISTER_FINALIZER_NO_ORDER(p, f, d, of, od) \
|
||||
GC_register_finalizer_no_order(p, f, d, of, od)
|
||||
# define GC_MALLOC_STUBBORN(sz) GC_malloc_stubborn(sz)
|
||||
# define GC_CHANGE_STUBBORN(p) GC_change_stubborn(p)
|
||||
# define GC_END_STUBBORN_CHANGE(p) GC_end_stubborn_change(p)
|
||||
# define GC_GENERAL_REGISTER_DISAPPEARING_LINK(link, obj) \
|
||||
GC_general_register_disappearing_link(link, obj)
|
||||
# define GC_REGISTER_DISPLACEMENT(n) GC_register_displacement(n)
|
||||
# endif
|
||||
/* The following are included because they are often convenient, and */
|
||||
/* reduce the chance for a misspecifed size argument. But calls may */
|
||||
/* expand to something syntactically incorrect if t is a complicated */
|
||||
/* type expression. */
|
||||
# define GC_NEW(t) (t *)GC_MALLOC(sizeof (t))
|
||||
# define GC_NEW_ATOMIC(t) (t *)GC_MALLOC_ATOMIC(sizeof (t))
|
||||
# define GC_NEW_STUBBORN(t) (t *)GC_MALLOC_STUBBORN(sizeof (t))
|
||||
# define GC_NEW_UNCOLLECTABLE(t) (t *)GC_MALLOC_UNCOLLECTABLE(sizeof (t))
|
||||
|
||||
/* Finalization. Some of these primitives are grossly unsafe. */
|
||||
/* The idea is to make them both cheap, and sufficient to build */
|
||||
/* a safer layer, closer to PCedar finalization. */
|
||||
/* The interface represents my conclusions from a long discussion */
|
||||
/* with Alan Demers, Dan Greene, Carl Hauser, Barry Hayes, */
|
||||
/* Christian Jacobi, and Russ Atkinson. It's not perfect, and */
|
||||
/* probably nobody else agrees with it. Hans-J. Boehm 3/13/92 */
|
||||
typedef void (*GC_finalization_proc)
|
||||
GC_PROTO((GC_PTR obj, GC_PTR client_data));
|
||||
|
||||
GC_API void GC_register_finalizer
|
||||
GC_PROTO((GC_PTR obj, GC_finalization_proc fn, GC_PTR cd,
|
||||
GC_finalization_proc *ofn, GC_PTR *ocd));
|
||||
GC_API void GC_debug_register_finalizer
|
||||
GC_PROTO((GC_PTR obj, GC_finalization_proc fn, GC_PTR cd,
|
||||
GC_finalization_proc *ofn, GC_PTR *ocd));
|
||||
/* When obj is no longer accessible, invoke */
|
||||
/* (*fn)(obj, cd). If a and b are inaccessible, and */
|
||||
/* a points to b (after disappearing links have been */
|
||||
/* made to disappear), then only a will be */
|
||||
/* finalized. (If this does not create any new */
|
||||
/* pointers to b, then b will be finalized after the */
|
||||
/* next collection.) Any finalizable object that */
|
||||
/* is reachable from itself by following one or more */
|
||||
/* pointers will not be finalized (or collected). */
|
||||
/* Thus cycles involving finalizable objects should */
|
||||
/* be avoided, or broken by disappearing links. */
|
||||
/* All but the last finalizer registered for an object */
|
||||
/* is ignored. */
|
||||
/* Finalization may be removed by passing 0 as fn. */
|
||||
/* Finalizers are implicitly unregistered just before */
|
||||
/* they are invoked. */
|
||||
/* The old finalizer and client data are stored in */
|
||||
/* *ofn and *ocd. */
|
||||
/* Fn is never invoked on an accessible object, */
|
||||
/* provided hidden pointers are converted to real */
|
||||
/* pointers only if the allocation lock is held, and */
|
||||
/* such conversions are not performed by finalization */
|
||||
/* routines. */
|
||||
/* If GC_register_finalizer is aborted as a result of */
|
||||
/* a signal, the object may be left with no */
|
||||
/* finalization, even if neither the old nor new */
|
||||
/* finalizer were NULL. */
|
||||
/* Obj should be the nonNULL starting address of an */
|
||||
/* object allocated by GC_malloc or friends. */
|
||||
/* Note that any garbage collectable object referenced */
|
||||
/* by cd will be considered accessible until the */
|
||||
/* finalizer is invoked. */
|
||||
|
||||
/* Another versions of the above follow. It ignores */
|
||||
/* self-cycles, i.e. pointers from a finalizable object to */
|
||||
/* itself. There is a stylistic argument that this is wrong, */
|
||||
/* but it's unavoidable for C++, since the compiler may */
|
||||
/* silently introduce these. It's also benign in that specific */
|
||||
/* case. */
|
||||
GC_API void GC_register_finalizer_ignore_self
|
||||
GC_PROTO((GC_PTR obj, GC_finalization_proc fn, GC_PTR cd,
|
||||
GC_finalization_proc *ofn, GC_PTR *ocd));
|
||||
GC_API void GC_debug_register_finalizer_ignore_self
|
||||
GC_PROTO((GC_PTR obj, GC_finalization_proc fn, GC_PTR cd,
|
||||
GC_finalization_proc *ofn, GC_PTR *ocd));
|
||||
|
||||
/* Another version of the above. It ignores all cycles. */
|
||||
/* It should probably only be used by Java implementations. */
|
||||
GC_API void GC_register_finalizer_no_order
|
||||
GC_PROTO((GC_PTR obj, GC_finalization_proc fn, GC_PTR cd,
|
||||
GC_finalization_proc *ofn, GC_PTR *ocd));
|
||||
GC_API void GC_debug_register_finalizer_no_order
|
||||
GC_PROTO((GC_PTR obj, GC_finalization_proc fn, GC_PTR cd,
|
||||
GC_finalization_proc *ofn, GC_PTR *ocd));
|
||||
|
||||
|
||||
/* The following routine may be used to break cycles between */
|
||||
/* finalizable objects, thus causing cyclic finalizable */
|
||||
/* objects to be finalized in the correct order. Standard */
|
||||
/* use involves calling GC_register_disappearing_link(&p), */
|
||||
/* where p is a pointer that is not followed by finalization */
|
||||
/* code, and should not be considered in determining */
|
||||
/* finalization order. */
|
||||
GC_API int GC_register_disappearing_link GC_PROTO((GC_PTR * /* link */));
|
||||
/* Link should point to a field of a heap allocated */
|
||||
/* object obj. *link will be cleared when obj is */
|
||||
/* found to be inaccessible. This happens BEFORE any */
|
||||
/* finalization code is invoked, and BEFORE any */
|
||||
/* decisions about finalization order are made. */
|
||||
/* This is useful in telling the finalizer that */
|
||||
/* some pointers are not essential for proper */
|
||||
/* finalization. This may avoid finalization cycles. */
|
||||
/* Note that obj may be resurrected by another */
|
||||
/* finalizer, and thus the clearing of *link may */
|
||||
/* be visible to non-finalization code. */
|
||||
/* There's an argument that an arbitrary action should */
|
||||
/* be allowed here, instead of just clearing a pointer. */
|
||||
/* But this causes problems if that action alters, or */
|
||||
/* examines connectivity. */
|
||||
/* Returns 1 if link was already registered, 0 */
|
||||
/* otherwise. */
|
||||
/* Only exists for backward compatibility. See below: */
|
||||
|
||||
GC_API int GC_general_register_disappearing_link
|
||||
GC_PROTO((GC_PTR * /* link */, GC_PTR obj));
|
||||
/* A slight generalization of the above. *link is */
|
||||
/* cleared when obj first becomes inaccessible. This */
|
||||
/* can be used to implement weak pointers easily and */
|
||||
/* safely. Typically link will point to a location */
|
||||
/* holding a disguised pointer to obj. (A pointer */
|
||||
/* inside an "atomic" object is effectively */
|
||||
/* disguised.) In this way soft */
|
||||
/* pointers are broken before any object */
|
||||
/* reachable from them are finalized. Each link */
|
||||
/* May be registered only once, i.e. with one obj */
|
||||
/* value. This was added after a long email discussion */
|
||||
/* with John Ellis. */
|
||||
/* Obj must be a pointer to the first word of an object */
|
||||
/* we allocated. It is unsafe to explicitly deallocate */
|
||||
/* the object containing link. Explicitly deallocating */
|
||||
/* obj may or may not cause link to eventually be */
|
||||
/* cleared. */
|
||||
GC_API int GC_unregister_disappearing_link GC_PROTO((GC_PTR * /* link */));
|
||||
/* Returns 0 if link was not actually registered. */
|
||||
/* Undoes a registration by either of the above two */
|
||||
/* routines. */
|
||||
|
||||
/* Auxiliary fns to make finalization work correctly with displaced */
|
||||
/* pointers introduced by the debugging allocators. */
|
||||
GC_API GC_PTR GC_make_closure GC_PROTO((GC_finalization_proc fn, GC_PTR data));
|
||||
GC_API void GC_debug_invoke_finalizer GC_PROTO((GC_PTR obj, GC_PTR data));
|
||||
|
||||
/* Returns !=0 if GC_invoke_finalizers has something to do. */
|
||||
GC_API int GC_should_invoke_finalizers GC_PROTO((void));
|
||||
|
||||
GC_API int GC_invoke_finalizers GC_PROTO((void));
|
||||
/* Run finalizers for all objects that are ready to */
|
||||
/* be finalized. Return the number of finalizers */
|
||||
/* that were run. Normally this is also called */
|
||||
/* implicitly during some allocations. If */
|
||||
/* GC-finalize_on_demand is nonzero, it must be called */
|
||||
/* explicitly. */
|
||||
|
||||
/* GC_set_warn_proc can be used to redirect or filter warning messages. */
|
||||
/* p may not be a NULL pointer. */
|
||||
typedef void (*GC_warn_proc) GC_PROTO((char *msg, GC_word arg));
|
||||
GC_API GC_warn_proc GC_set_warn_proc GC_PROTO((GC_warn_proc p));
|
||||
/* Returns old warning procedure. */
|
||||
|
||||
/* The following is intended to be used by a higher level */
|
||||
/* (e.g. cedar-like) finalization facility. It is expected */
|
||||
/* that finalization code will arrange for hidden pointers to */
|
||||
/* disappear. Otherwise objects can be accessed after they */
|
||||
/* have been collected. */
|
||||
/* Note that putting pointers in atomic objects or in */
|
||||
/* nonpointer slots of "typed" objects is equivalent to */
|
||||
/* disguising them in this way, and may have other advantages. */
|
||||
# if defined(I_HIDE_POINTERS) || defined(GC_I_HIDE_POINTERS)
|
||||
typedef GC_word GC_hidden_pointer;
|
||||
# define HIDE_POINTER(p) (~(GC_hidden_pointer)(p))
|
||||
# define REVEAL_POINTER(p) ((GC_PTR)(HIDE_POINTER(p)))
|
||||
/* Converting a hidden pointer to a real pointer requires verifying */
|
||||
/* that the object still exists. This involves acquiring the */
|
||||
/* allocator lock to avoid a race with the collector. */
|
||||
# endif /* I_HIDE_POINTERS */
|
||||
|
||||
typedef GC_PTR (*GC_fn_type) GC_PROTO((GC_PTR client_data));
|
||||
GC_API GC_PTR GC_call_with_alloc_lock
|
||||
GC_PROTO((GC_fn_type fn, GC_PTR client_data));
|
||||
|
||||
/* Check that p and q point to the same object. */
|
||||
/* Fail conspicuously if they don't. */
|
||||
/* Returns the first argument. */
|
||||
/* Succeeds if neither p nor q points to the heap. */
|
||||
/* May succeed if both p and q point to between heap objects. */
|
||||
GC_API GC_PTR GC_same_obj GC_PROTO((GC_PTR p, GC_PTR q));
|
||||
|
||||
/* Checked pointer pre- and post- increment operations. Note that */
|
||||
/* the second argument is in units of bytes, not multiples of the */
|
||||
/* object size. This should either be invoked from a macro, or the */
|
||||
/* call should be automatically generated. */
|
||||
GC_API GC_PTR GC_pre_incr GC_PROTO((GC_PTR *p, size_t how_much));
|
||||
GC_API GC_PTR GC_post_incr GC_PROTO((GC_PTR *p, size_t how_much));
|
||||
|
||||
/* Check that p is visible */
|
||||
/* to the collector as a possibly pointer containing location. */
|
||||
/* If it isn't fail conspicuously. */
|
||||
/* Returns the argument in all cases. May erroneously succeed */
|
||||
/* in hard cases. (This is intended for debugging use with */
|
||||
/* untyped allocations. The idea is that it should be possible, though */
|
||||
/* slow, to add such a call to all indirect pointer stores.) */
|
||||
/* Currently useless for multithreaded worlds. */
|
||||
GC_API GC_PTR GC_is_visible GC_PROTO((GC_PTR p));
|
||||
|
||||
/* Check that if p is a pointer to a heap page, then it points to */
|
||||
/* a valid displacement within a heap object. */
|
||||
/* Fail conspicuously if this property does not hold. */
|
||||
/* Uninteresting with ALL_INTERIOR_POINTERS. */
|
||||
/* Always returns its argument. */
|
||||
GC_API GC_PTR GC_is_valid_displacement GC_PROTO((GC_PTR p));
|
||||
|
||||
/* Safer, but slow, pointer addition. Probably useful mainly with */
|
||||
/* a preprocessor. Useful only for heap pointers. */
|
||||
#ifdef GC_DEBUG
|
||||
# define GC_PTR_ADD3(x, n, type_of_result) \
|
||||
((type_of_result)GC_same_obj((x)+(n), (x)))
|
||||
# define GC_PRE_INCR3(x, n, type_of_result) \
|
||||
((type_of_result)GC_pre_incr(&(x), (n)*sizeof(*x))
|
||||
# define GC_POST_INCR2(x, type_of_result) \
|
||||
((type_of_result)GC_post_incr(&(x), sizeof(*x))
|
||||
# ifdef __GNUC__
|
||||
# define GC_PTR_ADD(x, n) \
|
||||
GC_PTR_ADD3(x, n, typeof(x))
|
||||
# define GC_PRE_INCR(x, n) \
|
||||
GC_PRE_INCR3(x, n, typeof(x))
|
||||
# define GC_POST_INCR(x, n) \
|
||||
GC_POST_INCR3(x, typeof(x))
|
||||
# else
|
||||
/* We can't do this right without typeof, which ANSI */
|
||||
/* decided was not sufficiently useful. Repeatedly */
|
||||
/* mentioning the arguments seems too dangerous to be */
|
||||
/* useful. So does not casting the result. */
|
||||
# define GC_PTR_ADD(x, n) ((x)+(n))
|
||||
# endif
|
||||
#else /* !GC_DEBUG */
|
||||
# define GC_PTR_ADD3(x, n, type_of_result) ((x)+(n))
|
||||
# define GC_PTR_ADD(x, n) ((x)+(n))
|
||||
# define GC_PRE_INCR3(x, n, type_of_result) ((x) += (n))
|
||||
# define GC_PRE_INCR(x, n) ((x) += (n))
|
||||
# define GC_POST_INCR2(x, n, type_of_result) ((x)++)
|
||||
# define GC_POST_INCR(x, n) ((x)++)
|
||||
#endif
|
||||
|
||||
/* Safer assignment of a pointer to a nonstack location. */
|
||||
#ifdef GC_DEBUG
|
||||
# ifdef __STDC__
|
||||
# define GC_PTR_STORE(p, q) \
|
||||
(*(void **)GC_is_visible(p) = GC_is_valid_displacement(q))
|
||||
# else
|
||||
# define GC_PTR_STORE(p, q) \
|
||||
(*(char **)GC_is_visible(p) = GC_is_valid_displacement(q))
|
||||
# endif
|
||||
#else /* !GC_DEBUG */
|
||||
# define GC_PTR_STORE(p, q) *((p) = (q))
|
||||
#endif
|
||||
|
||||
/* Fynctions called to report pointer checking errors */
|
||||
GC_API void (*GC_same_obj_print_proc) GC_PROTO((GC_PTR p, GC_PTR q));
|
||||
|
||||
GC_API void (*GC_is_valid_displacement_print_proc)
|
||||
GC_PROTO((GC_PTR p));
|
||||
|
||||
GC_API void (*GC_is_visible_print_proc)
|
||||
GC_PROTO((GC_PTR p));
|
||||
|
||||
#if defined(_SOLARIS_PTHREADS) && !defined(SOLARIS_THREADS)
|
||||
# define SOLARIS_THREADS
|
||||
#endif
|
||||
|
||||
#ifdef SOLARIS_THREADS
|
||||
/* We need to intercept calls to many of the threads primitives, so */
|
||||
/* that we can locate thread stacks and stop the world. */
|
||||
/* Note also that the collector cannot see thread specific data. */
|
||||
/* Thread specific data should generally consist of pointers to */
|
||||
/* uncollectable objects, which are deallocated using the destructor */
|
||||
/* facility in thr_keycreate. */
|
||||
# include <thread.h>
|
||||
# include <signal.h>
|
||||
int GC_thr_create(void *stack_base, size_t stack_size,
|
||||
void *(*start_routine)(void *), void *arg, long flags,
|
||||
thread_t *new_thread);
|
||||
int GC_thr_join(thread_t wait_for, thread_t *departed, void **status);
|
||||
int GC_thr_suspend(thread_t target_thread);
|
||||
int GC_thr_continue(thread_t target_thread);
|
||||
void * GC_dlopen(const char *path, int mode);
|
||||
|
||||
# ifdef _SOLARIS_PTHREADS
|
||||
# include <pthread.h>
|
||||
extern int GC_pthread_create(pthread_t *new_thread,
|
||||
const pthread_attr_t *attr,
|
||||
void * (*thread_execp)(void *), void *arg);
|
||||
extern int GC_pthread_join(pthread_t wait_for, void **status);
|
||||
|
||||
# undef thread_t
|
||||
|
||||
# define pthread_join GC_pthread_join
|
||||
# define pthread_create GC_pthread_create
|
||||
#endif
|
||||
|
||||
# define thr_create GC_thr_create
|
||||
# define thr_join GC_thr_join
|
||||
# define thr_suspend GC_thr_suspend
|
||||
# define thr_continue GC_thr_continue
|
||||
# define dlopen GC_dlopen
|
||||
|
||||
# endif /* SOLARIS_THREADS */
|
||||
|
||||
|
||||
#if !defined(USE_LD_WRAP) && \
|
||||
(defined(IRIX_THREADS) || defined(LINUX_THREADS) || defined(HPUX_THREADS))
|
||||
/* We treat these similarly. */
|
||||
# include <pthread.h>
|
||||
# include <signal.h>
|
||||
|
||||
int GC_pthread_create(pthread_t *new_thread,
|
||||
const pthread_attr_t *attr,
|
||||
void *(*start_routine)(void *), void *arg);
|
||||
int GC_pthread_sigmask(int how, const sigset_t *set, sigset_t *oset);
|
||||
int GC_pthread_join(pthread_t thread, void **retval);
|
||||
|
||||
# define pthread_create GC_pthread_create
|
||||
# define pthread_sigmask GC_pthread_sigmask
|
||||
# define pthread_join GC_pthread_join
|
||||
# define dlopen GC_dlopen
|
||||
|
||||
#endif /* xxxxx_THREADS */
|
||||
|
||||
# if defined(PCR) || defined(SOLARIS_THREADS) || defined(WIN32_THREADS) || \
|
||||
defined(IRIX_THREADS) || defined(LINUX_THREADS) || \
|
||||
defined(IRIX_JDK_THREADS) || defined(HPUX_THREADS)
|
||||
/* Any flavor of threads except SRC_M3. */
|
||||
/* This returns a list of objects, linked through their first */
|
||||
/* word. Its use can greatly reduce lock contention problems, since */
|
||||
/* the allocation lock can be acquired and released many fewer times. */
|
||||
/* lb must be large enough to hold the pointer field. */
|
||||
GC_PTR GC_malloc_many(size_t lb);
|
||||
#define GC_NEXT(p) (*(GC_PTR *)(p)) /* Retrieve the next element */
|
||||
/* in returned list. */
|
||||
extern void GC_thr_init(); /* Needed for Solaris/X86 */
|
||||
|
||||
#endif /* THREADS && !SRC_M3 */
|
||||
|
||||
/*
|
||||
* If you are planning on putting
|
||||
* the collector in a SunOS 5 dynamic library, you need to call GC_INIT()
|
||||
* from the statically loaded program section.
|
||||
* This circumvents a Solaris 2.X (X<=4) linker bug.
|
||||
*/
|
||||
#if defined(sparc) || defined(__sparc)
|
||||
# define GC_INIT() { extern end, etext; \
|
||||
GC_noop(&end, &etext); }
|
||||
#else
|
||||
# if defined(__CYGWIN32__) && defined(GC_USE_DLL)
|
||||
/*
|
||||
* Similarly gnu-win32 DLLs need explicit initialization
|
||||
*/
|
||||
# define GC_INIT() { GC_add_roots(DATASTART, DATAEND); }
|
||||
# else
|
||||
# define GC_INIT()
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if (defined(_MSDOS) || defined(_MSC_VER)) && (_M_IX86 >= 300) \
|
||||
|| defined(_WIN32)
|
||||
/* win32S may not free all resources on process exit. */
|
||||
/* This explicitly deallocates the heap. */
|
||||
GC_API void GC_win32_free_heap ();
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* end of extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /* _GC_H */
|
|
@ -1,118 +0,0 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
/* Boehm, May 19, 1994 2:23 pm PDT */
|
||||
# ifndef CORD_POSITION_H
|
||||
|
||||
/* The representation of CORD_position. This is private to the */
|
||||
/* implementation, but the size is known to clients. Also */
|
||||
/* the implementation of some exported macros relies on it. */
|
||||
/* Don't use anything defined here and not in cord.h. */
|
||||
|
||||
# define MAX_DEPTH 48
|
||||
/* The maximum depth of a balanced cord + 1. */
|
||||
/* We don't let cords get deeper than MAX_DEPTH. */
|
||||
|
||||
struct CORD_pe {
|
||||
CORD pe_cord;
|
||||
size_t pe_start_pos;
|
||||
};
|
||||
|
||||
/* A structure describing an entry on the path from the root */
|
||||
/* to current position. */
|
||||
typedef struct CORD_Pos {
|
||||
size_t cur_pos;
|
||||
int path_len;
|
||||
# define CORD_POS_INVALID (0x55555555)
|
||||
/* path_len == INVALID <==> position invalid */
|
||||
const char *cur_leaf; /* Current leaf, if it is a string. */
|
||||
/* If the current leaf is a function, */
|
||||
/* then this may point to function_buf */
|
||||
/* containing the next few characters. */
|
||||
/* Always points to a valid string */
|
||||
/* containing the current character */
|
||||
/* unless cur_end is 0. */
|
||||
size_t cur_start; /* Start position of cur_leaf */
|
||||
size_t cur_end; /* Ending position of cur_leaf */
|
||||
/* 0 if cur_leaf is invalid. */
|
||||
struct CORD_pe path[MAX_DEPTH + 1];
|
||||
/* path[path_len] is the leaf corresponding to cur_pos */
|
||||
/* path[0].pe_cord is the cord we point to. */
|
||||
# define FUNCTION_BUF_SZ 8
|
||||
char function_buf[FUNCTION_BUF_SZ]; /* Space for next few chars */
|
||||
/* from function node. */
|
||||
} CORD_pos[1];
|
||||
|
||||
/* Extract the cord from a position: */
|
||||
CORD CORD_pos_to_cord(CORD_pos p);
|
||||
|
||||
/* Extract the current index from a position: */
|
||||
size_t CORD_pos_to_index(CORD_pos p);
|
||||
|
||||
/* Fetch the character located at the given position: */
|
||||
char CORD_pos_fetch(CORD_pos p);
|
||||
|
||||
/* Initialize the position to refer to the give cord and index. */
|
||||
/* Note that this is the most expensive function on positions: */
|
||||
void CORD_set_pos(CORD_pos p, CORD x, size_t i);
|
||||
|
||||
/* Advance the position to the next character. */
|
||||
/* P must be initialized and valid. */
|
||||
/* Invalidates p if past end: */
|
||||
void CORD_next(CORD_pos p);
|
||||
|
||||
/* Move the position to the preceding character. */
|
||||
/* P must be initialized and valid. */
|
||||
/* Invalidates p if past beginning: */
|
||||
void CORD_prev(CORD_pos p);
|
||||
|
||||
/* Is the position valid, i.e. inside the cord? */
|
||||
int CORD_pos_valid(CORD_pos p);
|
||||
|
||||
char CORD__pos_fetch(CORD_pos);
|
||||
void CORD__next(CORD_pos);
|
||||
void CORD__prev(CORD_pos);
|
||||
|
||||
#define CORD_pos_fetch(p) \
|
||||
(((p)[0].cur_end != 0)? \
|
||||
(p)[0].cur_leaf[(p)[0].cur_pos - (p)[0].cur_start] \
|
||||
: CORD__pos_fetch(p))
|
||||
|
||||
#define CORD_next(p) \
|
||||
(((p)[0].cur_pos + 1 < (p)[0].cur_end)? \
|
||||
(p)[0].cur_pos++ \
|
||||
: (CORD__next(p), 0))
|
||||
|
||||
#define CORD_prev(p) \
|
||||
(((p)[0].cur_end != 0 && (p)[0].cur_pos > (p)[0].cur_start)? \
|
||||
(p)[0].cur_pos-- \
|
||||
: (CORD__prev(p), 0))
|
||||
|
||||
#define CORD_pos_to_index(p) ((p)[0].cur_pos)
|
||||
|
||||
#define CORD_pos_to_cord(p) ((p)[0].path[0].pe_cord)
|
||||
|
||||
#define CORD_pos_valid(p) ((p)[0].path_len != CORD_POS_INVALID)
|
||||
|
||||
/* Some grubby stuff for performance-critical friends: */
|
||||
#define CORD_pos_chars_left(p) ((long)((p)[0].cur_end) - (long)((p)[0].cur_pos))
|
||||
/* Number of characters in cache. <= 0 ==> none */
|
||||
|
||||
#define CORD_pos_advance(p,n) ((p)[0].cur_pos += (n) - 1, CORD_next(p))
|
||||
/* Advance position by n characters */
|
||||
/* 0 < n < CORD_pos_chars_left(p) */
|
||||
|
||||
#define CORD_pos_cur_char_addr(p) \
|
||||
(p)[0].cur_leaf + ((p)[0].cur_pos - (p)[0].cur_start)
|
||||
/* address of current character in cache. */
|
||||
|
||||
#endif
|
|
@ -2,7 +2,7 @@
|
|||
* Copyright 1988, 1989 Hans-J. Boehm, Alan J. Demers
|
||||
* Copyright (c) 1991-1995 by Xerox Corporation. All rights reserved.
|
||||
* Copyright (c) 1997 by Silicon Graphics. All rights reserved.
|
||||
* Copyright (c) 1999 by Hewlett-Packard Company. All rights reserved.
|
||||
* Copyright (c) 1999-2000 by Hewlett-Packard Company. All rights reserved.
|
||||
*
|
||||
* THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED
|
||||
* OR IMPLIED. ANY USE IS AT YOUR OWN RISK.
|
||||
|
@ -14,7 +14,7 @@
|
|||
* modified is included with the above copyright notice.
|
||||
*/
|
||||
|
||||
#include "dbg_mlc.h"
|
||||
#include "private/dbg_mlc.h"
|
||||
|
||||
void GC_default_print_heap_obj_proc();
|
||||
GC_API void GC_register_finalizer_no_order
|
||||
|
@ -22,10 +22,17 @@ GC_API void GC_register_finalizer_no_order
|
|||
GC_finalization_proc *ofn, GC_PTR *ocd));
|
||||
|
||||
|
||||
#ifndef SHORT_DBG_HDRS
|
||||
/* Check whether object with base pointer p has debugging info */
|
||||
/* p is assumed to point to a legitimate object in our part */
|
||||
/* of the heap. */
|
||||
GC_bool GC_has_debug_info(p)
|
||||
/* This excludes the check as to whether tha back pointer is */
|
||||
/* odd, which is added by the GC_HAS_DEBUG_INFO macro. */
|
||||
/* Note that if DBG_HDRS_ALL is set, uncollectable objects */
|
||||
/* on free lists may not have debug information set. Thus it's */
|
||||
/* not always safe to return TRUE, even if the client does */
|
||||
/* its part. */
|
||||
GC_bool GC_has_other_debug_info(p)
|
||||
ptr_t p;
|
||||
{
|
||||
register oh * ohdr = (oh *)p;
|
||||
|
@ -46,8 +53,19 @@ ptr_t p;
|
|||
}
|
||||
return(FALSE);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef KEEP_BACK_PTRS
|
||||
|
||||
# include <stdlib.h>
|
||||
|
||||
# if defined(LINUX) || defined(SUNOS4) || defined(SUNOS5) \
|
||||
|| defined(HPUX) || defined(IRIX) || defined(OSF1)
|
||||
# define RANDOM() random()
|
||||
# else
|
||||
# define RANDOM() (long)rand()
|
||||
# endif
|
||||
|
||||
/* Store back pointer to source in dest, if that appears to be possible. */
|
||||
/* This is not completely safe, since we may mistakenly conclude that */
|
||||
/* dest has a debugging wrapper. But the error probability is very */
|
||||
|
@ -56,8 +74,8 @@ ptr_t p;
|
|||
/* be a pointer to the interior of an object. */
|
||||
void GC_store_back_pointer(ptr_t source, ptr_t dest)
|
||||
{
|
||||
if (GC_has_debug_info(dest)) {
|
||||
((oh *)dest) -> oh_back_ptr = (ptr_t)HIDE_POINTER(source);
|
||||
if (GC_HAS_DEBUG_INFO(dest)) {
|
||||
((oh *)dest) -> oh_back_ptr = HIDE_BACK_PTR(source);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -76,19 +94,34 @@ ptr_t p;
|
|||
oh * hdr = (oh *)GC_base(dest);
|
||||
ptr_t bp;
|
||||
ptr_t bp_base;
|
||||
if (!GC_has_debug_info((ptr_t) hdr)) return GC_NO_SPACE;
|
||||
bp = hdr -> oh_back_ptr;
|
||||
if (!GC_HAS_DEBUG_INFO((ptr_t) hdr)) return GC_NO_SPACE;
|
||||
bp = REVEAL_POINTER(hdr -> oh_back_ptr);
|
||||
if (MARKED_FOR_FINALIZATION == bp) return GC_FINALIZER_REFD;
|
||||
if (MARKED_FROM_REGISTER == bp) return GC_REFD_FROM_REG;
|
||||
if (0 == bp) return GC_UNREFERENCED;
|
||||
bp = REVEAL_POINTER(bp);
|
||||
if (NOT_MARKED == bp) return GC_UNREFERENCED;
|
||||
# if ALIGNMENT == 1
|
||||
/* Heuristically try to fix off by 1 errors we introduced by */
|
||||
/* insisting on even addresses. */
|
||||
{
|
||||
ptr_t alternate_ptr = bp + 1;
|
||||
ptr_t target = *(ptr_t *)bp;
|
||||
ptr_t alternate_target = *(ptr_t *)alternate_ptr;
|
||||
|
||||
if (alternate_target >= GC_least_plausible_heap_addr
|
||||
&& alternate_target <= GC_greatest_plausible_heap_addr
|
||||
&& (target < GC_least_plausible_heap_addr
|
||||
|| target > GC_greatest_plausible_heap_addr)) {
|
||||
bp = alternate_ptr;
|
||||
}
|
||||
}
|
||||
# endif
|
||||
bp_base = GC_base(bp);
|
||||
if (0 == bp_base) {
|
||||
*base_p = bp;
|
||||
*offset_p = 0;
|
||||
return GC_REFD_FROM_ROOT;
|
||||
} else {
|
||||
if (GC_has_debug_info(bp_base)) bp_base += sizeof(oh);
|
||||
if (GC_HAS_DEBUG_INFO(bp_base)) bp_base += sizeof(oh);
|
||||
*base_p = bp_base;
|
||||
*offset_p = bp - bp_base;
|
||||
return GC_REFD_FROM_HEAP;
|
||||
|
@ -101,7 +134,15 @@ ptr_t p;
|
|||
void *GC_generate_random_heap_address(void)
|
||||
{
|
||||
int i;
|
||||
int heap_offset = random() % GC_heapsize;
|
||||
long heap_offset = RANDOM();
|
||||
if (GC_heapsize > RAND_MAX) {
|
||||
heap_offset *= RAND_MAX;
|
||||
heap_offset += RANDOM();
|
||||
}
|
||||
heap_offset %= GC_heapsize;
|
||||
/* This doesn't yield a uniform distribution, especially if */
|
||||
/* e.g. RAND_MAX = 1.5* GC_heapsize. But for typical cases, */
|
||||
/* it's not too bad. */
|
||||
for (i = 0; i < GC_n_heap_sects; ++ i) {
|
||||
int size = GC_heap_sects[i].hs_bytes;
|
||||
if (heap_offset < size) {
|
||||
|
@ -203,18 +244,50 @@ word integer;
|
|||
/* inconsistent while we're in the handler. */
|
||||
LOCK();
|
||||
# ifdef KEEP_BACK_PTRS
|
||||
((oh *)p) -> oh_back_ptr = 0;
|
||||
((oh *)p) -> oh_back_ptr = HIDE_BACK_PTR(NOT_MARKED);
|
||||
# endif
|
||||
((oh *)p) -> oh_string = string;
|
||||
((oh *)p) -> oh_int = integer;
|
||||
((oh *)p) -> oh_sz = sz;
|
||||
((oh *)p) -> oh_sf = START_FLAG ^ (word)result;
|
||||
((word *)p)[BYTES_TO_WORDS(GC_size(p))-1] =
|
||||
# ifndef SHORT_DBG_HDRS
|
||||
((oh *)p) -> oh_sz = sz;
|
||||
((oh *)p) -> oh_sf = START_FLAG ^ (word)result;
|
||||
((word *)p)[BYTES_TO_WORDS(GC_size(p))-1] =
|
||||
result[ROUNDED_UP_WORDS(sz)] = END_FLAG ^ (word)result;
|
||||
# endif
|
||||
UNLOCK();
|
||||
return((ptr_t)result);
|
||||
}
|
||||
|
||||
#ifdef DBG_HDRS_ALL
|
||||
/* Store debugging info into p. Return displaced pointer. */
|
||||
/* This version assumes we do hold the allocation lock. */
|
||||
ptr_t GC_store_debug_info_inner(p, sz, string, integer)
|
||||
register ptr_t p; /* base pointer */
|
||||
word sz; /* bytes */
|
||||
char * string;
|
||||
word integer;
|
||||
{
|
||||
register word * result = (word *)((oh *)p + 1);
|
||||
|
||||
/* There is some argument that we should disable signals here. */
|
||||
/* But that's expensive. And this way things should only appear */
|
||||
/* inconsistent while we're in the handler. */
|
||||
# ifdef KEEP_BACK_PTRS
|
||||
((oh *)p) -> oh_back_ptr = 0;
|
||||
# endif
|
||||
((oh *)p) -> oh_string = string;
|
||||
((oh *)p) -> oh_int = integer;
|
||||
# ifndef SHORT_DBG_HDRS
|
||||
((oh *)p) -> oh_sz = sz;
|
||||
((oh *)p) -> oh_sf = START_FLAG ^ (word)result;
|
||||
((word *)p)[BYTES_TO_WORDS(GC_size(p))-1] =
|
||||
result[ROUNDED_UP_WORDS(sz)] = END_FLAG ^ (word)result;
|
||||
# endif
|
||||
return((ptr_t)result);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef SHORT_DBG_HDRS
|
||||
/* Check the object with debugging info at ohdr */
|
||||
/* return NIL if it's OK. Else return clobbered */
|
||||
/* address. */
|
||||
|
@ -238,6 +311,7 @@ register oh * ohdr;
|
|||
}
|
||||
return(0);
|
||||
}
|
||||
#endif /* !SHORT_DBG_HDRS */
|
||||
|
||||
void GC_print_obj(p)
|
||||
ptr_t p;
|
||||
|
@ -246,21 +320,30 @@ ptr_t p;
|
|||
|
||||
GC_err_printf1("0x%lx (", ((unsigned long)ohdr + sizeof(oh)));
|
||||
GC_err_puts(ohdr -> oh_string);
|
||||
GC_err_printf2(":%ld, sz=%ld)\n", (unsigned long)(ohdr -> oh_int),
|
||||
(unsigned long)(ohdr -> oh_sz));
|
||||
# ifdef SHORT_DBG_HDRS
|
||||
GC_err_printf1(":%ld, sz=%ld)\n", (unsigned long)(ohdr -> oh_int));
|
||||
# else
|
||||
GC_err_printf2(":%ld, sz=%ld)\n", (unsigned long)(ohdr -> oh_int),
|
||||
(unsigned long)(ohdr -> oh_sz));
|
||||
# endif
|
||||
PRINT_CALL_CHAIN(ohdr);
|
||||
}
|
||||
|
||||
void GC_debug_print_heap_obj_proc(p)
|
||||
ptr_t p;
|
||||
# if defined(__STDC__) || defined(__cplusplus)
|
||||
void GC_debug_print_heap_obj_proc(ptr_t p)
|
||||
# else
|
||||
void GC_debug_print_heap_obj_proc(p)
|
||||
ptr_t p;
|
||||
# endif
|
||||
{
|
||||
if (GC_has_debug_info(p)) {
|
||||
if (GC_HAS_DEBUG_INFO(p)) {
|
||||
GC_print_obj(p);
|
||||
} else {
|
||||
GC_default_print_heap_obj_proc(p);
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef SHORT_DBG_HDRS
|
||||
void GC_print_smashed_obj(p, clobbered_addr)
|
||||
ptr_t p, clobbered_addr;
|
||||
{
|
||||
|
@ -283,12 +366,19 @@ ptr_t p, clobbered_addr;
|
|||
PRINT_CALL_CHAIN(ohdr);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
void GC_check_heap_proc();
|
||||
void GC_check_heap_proc GC_PROTO((void));
|
||||
|
||||
void GC_do_nothing() {}
|
||||
|
||||
void GC_start_debugging()
|
||||
{
|
||||
GC_check_heap = GC_check_heap_proc;
|
||||
# ifndef SHORT_DBG_HDRS
|
||||
GC_check_heap = GC_check_heap_proc;
|
||||
# else
|
||||
GC_check_heap = GC_do_nothing;
|
||||
# endif
|
||||
GC_print_heap_obj = GC_debug_print_heap_obj_proc;
|
||||
GC_debugging_started = TRUE;
|
||||
GC_register_displacement((word)sizeof(oh));
|
||||
|
@ -362,6 +452,43 @@ void GC_start_debugging()
|
|||
return (GC_store_debug_info(result, (word)lb, s, (word)i));
|
||||
}
|
||||
|
||||
# ifdef DBG_HDRS_ALL
|
||||
/*
|
||||
* An allocation function for internal use.
|
||||
* Normally internally allocated objects do not have debug information.
|
||||
* But in this case, we need to make sure that all objects have debug
|
||||
* headers.
|
||||
* We assume debugging was started in collector initialization,
|
||||
* and we already hold the GC lock.
|
||||
*/
|
||||
GC_PTR GC_debug_generic_malloc_inner(size_t lb, int k)
|
||||
{
|
||||
GC_PTR result = GC_generic_malloc_inner(lb + DEBUG_BYTES, k);
|
||||
|
||||
if (result == 0) {
|
||||
GC_err_printf1("GC internal allocation (%ld bytes) returning NIL\n",
|
||||
(unsigned long) lb);
|
||||
return(0);
|
||||
}
|
||||
ADD_CALL_CHAIN(result, ra);
|
||||
return (GC_store_debug_info_inner(result, (word)lb, "INTERNAL", (word)0));
|
||||
}
|
||||
|
||||
GC_PTR GC_debug_generic_malloc_inner_ignore_off_page(size_t lb, int k)
|
||||
{
|
||||
GC_PTR result = GC_generic_malloc_inner_ignore_off_page(
|
||||
lb + DEBUG_BYTES, k);
|
||||
|
||||
if (result == 0) {
|
||||
GC_err_printf1("GC internal allocation (%ld bytes) returning NIL\n",
|
||||
(unsigned long) lb);
|
||||
return(0);
|
||||
}
|
||||
ADD_CALL_CHAIN(result, ra);
|
||||
return (GC_store_debug_info_inner(result, (word)lb, "INTERNAL", (word)0));
|
||||
}
|
||||
# endif
|
||||
|
||||
#ifdef STUBBORN_ALLOC
|
||||
# ifdef __STDC__
|
||||
GC_PTR GC_debug_malloc_stubborn(size_t lb, GC_EXTRA_PARAMS)
|
||||
|
@ -554,18 +681,20 @@ GC_PTR p;
|
|||
"GC_debug_free called on pointer %lx wo debugging info\n",
|
||||
(unsigned long)p);
|
||||
} else {
|
||||
clobbered = GC_check_annotated_obj((oh *)base);
|
||||
if (clobbered != 0) {
|
||||
if (((oh *)base) -> oh_sz == GC_size(base)) {
|
||||
# ifndef SHORT_DBG_HDRS
|
||||
clobbered = GC_check_annotated_obj((oh *)base);
|
||||
if (clobbered != 0) {
|
||||
if (((oh *)base) -> oh_sz == GC_size(base)) {
|
||||
GC_err_printf0(
|
||||
"GC_debug_free: found previously deallocated (?) object at ");
|
||||
} else {
|
||||
} else {
|
||||
GC_err_printf0("GC_debug_free: found smashed location at ");
|
||||
}
|
||||
GC_print_smashed_obj(p, clobbered);
|
||||
}
|
||||
GC_print_smashed_obj(p, clobbered);
|
||||
}
|
||||
/* Invalidate size */
|
||||
((oh *)base) -> oh_sz = GC_size(base);
|
||||
/* Invalidate size */
|
||||
((oh *)base) -> oh_sz = GC_size(base);
|
||||
# endif /* SHORT_DBG_HDRS */
|
||||
}
|
||||
if (GC_find_leak) {
|
||||
GC_free(base);
|
||||
|
@ -585,6 +714,17 @@ GC_PTR p;
|
|||
} /* !GC_find_leak */
|
||||
}
|
||||
|
||||
#ifdef THREADS
|
||||
|
||||
extern void GC_free_inner(GC_PTR p);
|
||||
|
||||
/* Used internally; we assume it's called correctly. */
|
||||
void GC_debug_free_inner(GC_PTR p)
|
||||
{
|
||||
GC_free_inner(GC_base(p));
|
||||
}
|
||||
#endif
|
||||
|
||||
# ifdef __STDC__
|
||||
GC_PTR GC_debug_realloc(GC_PTR p, size_t lb, GC_EXTRA_PARAMS)
|
||||
# else
|
||||
|
@ -639,12 +779,16 @@ GC_PTR p;
|
|||
GC_err_printf0("GC_debug_realloc: encountered bad kind\n");
|
||||
ABORT("bad kind");
|
||||
}
|
||||
clobbered = GC_check_annotated_obj((oh *)base);
|
||||
if (clobbered != 0) {
|
||||
# ifdef SHORT_DBG_HDRS
|
||||
old_sz = GC_size(base) - sizeof(oh);
|
||||
# else
|
||||
clobbered = GC_check_annotated_obj((oh *)base);
|
||||
if (clobbered != 0) {
|
||||
GC_err_printf0("GC_debug_realloc: found smashed location at ");
|
||||
GC_print_smashed_obj(p, clobbered);
|
||||
}
|
||||
old_sz = ((oh *)base) -> oh_sz;
|
||||
}
|
||||
old_sz = ((oh *)base) -> oh_sz;
|
||||
# endif
|
||||
if (old_sz < copy_sz) copy_sz = old_sz;
|
||||
if (result == 0) return(0);
|
||||
BCOPY(p, result, copy_sz);
|
||||
|
@ -652,11 +796,16 @@ GC_PTR p;
|
|||
return(result);
|
||||
}
|
||||
|
||||
#ifndef SHORT_DBG_HDRS
|
||||
/* Check all marked objects in the given block for validity */
|
||||
/*ARGSUSED*/
|
||||
void GC_check_heap_block(hbp, dummy)
|
||||
register struct hblk *hbp; /* ptr to current heap block */
|
||||
word dummy;
|
||||
# if defined(__STDC__) || defined(__cplusplus)
|
||||
void GC_check_heap_block(register struct hblk *hbp, word dummy)
|
||||
# else
|
||||
void GC_check_heap_block(hbp, dummy)
|
||||
register struct hblk *hbp; /* ptr to current heap block */
|
||||
word dummy;
|
||||
# endif
|
||||
{
|
||||
register struct hblkhdr * hhdr = HDR(hbp);
|
||||
register word sz = hhdr -> hb_sz;
|
||||
|
@ -664,7 +813,7 @@ word dummy;
|
|||
register word *p, *plim;
|
||||
|
||||
p = (word *)(hbp->hb_body);
|
||||
word_no = HDR_WORDS;
|
||||
word_no = 0;
|
||||
if (sz > MAXOBJSZ) {
|
||||
plim = p;
|
||||
} else {
|
||||
|
@ -673,7 +822,7 @@ word dummy;
|
|||
/* go through all words in block */
|
||||
while( p <= plim ) {
|
||||
if( mark_bit_from_hdr(hhdr, word_no)
|
||||
&& GC_has_debug_info((ptr_t)p)) {
|
||||
&& GC_HAS_DEBUG_INFO((ptr_t)p)) {
|
||||
ptr_t clobbered = GC_check_annotated_obj((oh *)p);
|
||||
|
||||
if (clobbered != 0) {
|
||||
|
@ -700,6 +849,8 @@ void GC_check_heap_proc()
|
|||
GC_apply_to_all_blocks(GC_check_heap_block, (word)0);
|
||||
}
|
||||
|
||||
#endif /* !SHORT_DBG_HDRS */
|
||||
|
||||
struct closure {
|
||||
GC_finalization_proc cl_fn;
|
||||
GC_PTR cl_data;
|
||||
|
@ -714,7 +865,12 @@ struct closure {
|
|||
# endif
|
||||
{
|
||||
struct closure * result =
|
||||
(struct closure *) GC_malloc(sizeof (struct closure));
|
||||
# ifdef DBG_HDRS_ALL
|
||||
(struct closure *) GC_debug_malloc(sizeof (struct closure),
|
||||
GC_EXTRAS);
|
||||
# else
|
||||
(struct closure *) GC_malloc(sizeof (struct closure));
|
||||
# endif
|
||||
|
||||
result -> cl_fn = fn;
|
||||
result -> cl_data = data;
|
||||
|
@ -807,3 +963,16 @@ struct closure {
|
|||
GC_register_finalizer_ignore_self(base, GC_debug_invoke_finalizer,
|
||||
GC_make_closure(fn,cd), ofn, ocd);
|
||||
}
|
||||
|
||||
GC_PTR GC_debug_malloc_replacement(lb)
|
||||
size_t lb;
|
||||
{
|
||||
return GC_debug_malloc(lb, "unknown", 0);
|
||||
}
|
||||
|
||||
GC_PTR GC_debug_realloc_replacement(p, lb)
|
||||
GC_PTR p;
|
||||
size_t lb;
|
||||
{
|
||||
return GC_debug_realloc(p, lb, "unknown", 0);
|
||||
}
|
||||
|
|
|
@ -1,102 +0,0 @@
|
|||
/*
|
||||
* Copyright 1988, 1989 Hans-J. Boehm, Alan J. Demers
|
||||
* Copyright (c) 1991-1995 by Xerox Corporation. All rights reserved.
|
||||
* Copyright (c) 1997 by Silicon Graphics. All rights reserved.
|
||||
* Copyright (c) 1999 by Hewlett-Packard Company. 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* This is mostly an internal header file. Typical clients should
|
||||
* not use it. Clients that define their own object kinds with
|
||||
* debugging allocators will probably want to include this, however.
|
||||
* No attempt is made to keep the namespace clean. This should not be
|
||||
* included from header filrd that are frequently included by clients.
|
||||
*/
|
||||
|
||||
#ifndef _DBG_MLC_H
|
||||
|
||||
#define _DBG_MLC_H
|
||||
|
||||
# define I_HIDE_POINTERS
|
||||
# include "gc_priv.h"
|
||||
# ifdef KEEP_BACK_PTRS
|
||||
# include "backptr.h"
|
||||
# endif
|
||||
|
||||
# define START_FLAG ((word)0xfedcedcb)
|
||||
# define END_FLAG ((word)0xbcdecdef)
|
||||
/* Stored both one past the end of user object, and one before */
|
||||
/* the end of the object as seen by the allocator. */
|
||||
|
||||
|
||||
/* Object header */
|
||||
typedef struct {
|
||||
# ifdef KEEP_BACK_PTRS
|
||||
ptr_t oh_back_ptr;
|
||||
# define MARKED_FOR_FINALIZATION (ptr_t)(-1)
|
||||
/* Object was marked because it is finalizable. */
|
||||
# define MARKED_FROM_REGISTER (ptr_t)(-2)
|
||||
/* Object was marked from a rgister. Hence the */
|
||||
/* source of the reference doesn't have an address. */
|
||||
# ifdef ALIGN_DOUBLE
|
||||
word oh_dummy;
|
||||
# endif
|
||||
# endif
|
||||
char * oh_string; /* object descriptor string */
|
||||
word oh_int; /* object descriptor integers */
|
||||
# ifdef NEED_CALLINFO
|
||||
struct callinfo oh_ci[NFRAMES];
|
||||
# endif
|
||||
word oh_sz; /* Original malloc arg. */
|
||||
word oh_sf; /* start flag */
|
||||
} oh;
|
||||
/* The size of the above structure is assumed not to dealign things, */
|
||||
/* and to be a multiple of the word length. */
|
||||
|
||||
#define DEBUG_BYTES (sizeof (oh) + sizeof (word))
|
||||
#define USR_PTR_FROM_BASE(p) ((ptr_t)(p) + sizeof(oh))
|
||||
|
||||
/* There is no reason to ever add a byte at the end explicitly, since we */
|
||||
/* already add a guard word. */
|
||||
#undef ROUNDED_UP_WORDS
|
||||
#define ROUNDED_UP_WORDS(n) BYTES_TO_WORDS((n) + WORDS_TO_BYTES(1) - 1)
|
||||
|
||||
#ifdef SAVE_CALL_CHAIN
|
||||
# define ADD_CALL_CHAIN(base, ra) GC_save_callers(((oh *)(base)) -> oh_ci)
|
||||
# define PRINT_CALL_CHAIN(base) GC_print_callers(((oh *)(base)) -> oh_ci)
|
||||
#else
|
||||
# ifdef GC_ADD_CALLER
|
||||
# define ADD_CALL_CHAIN(base, ra) ((oh *)(base)) -> oh_ci[0].ci_pc = (ra)
|
||||
# define PRINT_CALL_CHAIN(base) GC_print_callers(((oh *)(base)) -> oh_ci)
|
||||
# else
|
||||
# define ADD_CALL_CHAIN(base, ra)
|
||||
# define PRINT_CALL_CHAIN(base)
|
||||
# endif
|
||||
#endif
|
||||
|
||||
# ifdef GC_ADD_CALLER
|
||||
# define OPT_RA ra,
|
||||
# else
|
||||
# define OPT_RA
|
||||
# endif
|
||||
|
||||
|
||||
/* Check whether object with base pointer p has debugging info */
|
||||
/* p is assumed to point to a legitimate object in our part */
|
||||
/* of the heap. */
|
||||
GC_bool GC_has_debug_info(/* p */);
|
||||
|
||||
/* Store debugging info into p. Return displaced pointer. */
|
||||
/* Assumes we don't hold allocation lock. */
|
||||
ptr_t GC_store_debug_info(/* p, sz, string, integer */);
|
||||
|
||||
#endif /* _DBG_MLC_H */
|
|
@ -26,15 +26,15 @@
|
|||
* None of this is safe with dlclose and incremental collection.
|
||||
* But then not much of anything is safe in the presence of dlclose.
|
||||
*/
|
||||
#ifndef MACOS
|
||||
#if !defined(MACOS) && !defined(_WIN32_WCE)
|
||||
# include <sys/types.h>
|
||||
#endif
|
||||
#include "gc_priv.h"
|
||||
#include "private/gc_priv.h"
|
||||
|
||||
/* BTL: avoid circular redefinition of dlopen if SOLARIS_THREADS defined */
|
||||
# if (defined(LINUX_THREADS) || defined(SOLARIS_THREADS) \
|
||||
|| defined(HPUX_THREADS) || defined(IRIX_THREADS)) && defined(dlopen) \
|
||||
&& !defined(USE_LD_WRAP)
|
||||
&& !defined(GC_USE_LD_WRAP)
|
||||
/* To support threads in Solaris, gc.h interposes on dlopen by */
|
||||
/* defining "dlopen" to be "GC_dlopen", which is implemented below. */
|
||||
/* However, both GC_FirstDLOpenedLinkMap() and GC_dlopen() use the */
|
||||
|
@ -46,11 +46,14 @@
|
|||
# undef GC_must_restore_redefined_dlopen
|
||||
# endif
|
||||
|
||||
#if (defined(DYNAMIC_LOADING) || defined(MSWIN32)) && !defined(PCR)
|
||||
#if (defined(DYNAMIC_LOADING) || defined(MSWIN32) || defined(MSWINCE)) \
|
||||
&& !defined(PCR)
|
||||
#if !defined(SUNOS4) && !defined(SUNOS5DL) && !defined(IRIX5) && \
|
||||
!defined(MSWIN32) && !(defined(ALPHA) && defined(OSF1)) && \
|
||||
!defined(MSWIN32) && !defined(MSWINCE) && \
|
||||
!(defined(ALPHA) && defined(OSF1)) && \
|
||||
!defined(HPUX) && !(defined(LINUX) && defined(__ELF__)) && \
|
||||
!defined(RS6000) && !defined(SCO_ELF)
|
||||
!defined(RS6000) && !defined(SCO_ELF) && \
|
||||
!(defined(NETBSD) && defined(__ELF__))
|
||||
--> We only know how to find data segments of dynamic libraries for the
|
||||
--> above. Additional SVR4 variants might not be too
|
||||
--> hard to add.
|
||||
|
@ -121,6 +124,11 @@ GC_FirstDLOpenedLinkMap()
|
|||
|
||||
#endif /* SUNOS5DL ... */
|
||||
|
||||
/* BTL: added to fix circular dlopen definition if SOLARIS_THREADS defined */
|
||||
# if defined(GC_must_restore_redefined_dlopen)
|
||||
# define dlopen GC_dlopen
|
||||
# endif
|
||||
|
||||
#if defined(SUNOS4) && !defined(USE_PROC_FOR_LIBRARIES)
|
||||
|
||||
#ifdef LINT
|
||||
|
@ -161,69 +169,6 @@ static ptr_t GC_first_common()
|
|||
|
||||
#endif /* SUNOS4 ... */
|
||||
|
||||
# if defined(LINUX_THREADS) || defined(SOLARIS_THREADS) \
|
||||
|| defined(HPUX_THREADS) || defined(IRIX_THREADS)
|
||||
/* Make sure we're not in the middle of a collection, and make */
|
||||
/* sure we don't start any. Returns previous value of GC_dont_gc. */
|
||||
/* This is invoked prior to a dlopen call to avoid synchronization */
|
||||
/* issues. We can't just acquire the allocation lock, since startup */
|
||||
/* code in dlopen may try to allocate. */
|
||||
/* This solution risks heap growth in the presence of many dlopen */
|
||||
/* calls in either a multithreaded environment, or if the library */
|
||||
/* initialization code allocates substantial amounts of GC'ed memory. */
|
||||
/* But I don't know of a better solution. */
|
||||
/* This can still deadlock if the client explicitly starts a GC */
|
||||
/* during the dlopen. He shouldn't do that. */
|
||||
static GC_bool disable_gc_for_dlopen()
|
||||
{
|
||||
GC_bool result;
|
||||
LOCK();
|
||||
result = GC_dont_gc;
|
||||
while (GC_incremental && GC_collection_in_progress()) {
|
||||
GC_collect_a_little_inner(1000);
|
||||
}
|
||||
GC_dont_gc = TRUE;
|
||||
UNLOCK();
|
||||
return(result);
|
||||
}
|
||||
|
||||
/* Redefine dlopen to guarantee mutual exclusion with */
|
||||
/* GC_register_dynamic_libraries. */
|
||||
/* Should probably happen for other operating systems, too. */
|
||||
|
||||
#include <dlfcn.h>
|
||||
|
||||
#ifdef USE_LD_WRAP
|
||||
void * __wrap_dlopen(const char *path, int mode)
|
||||
#else
|
||||
void * GC_dlopen(path, mode)
|
||||
GC_CONST char * path;
|
||||
int mode;
|
||||
#endif
|
||||
{
|
||||
void * result;
|
||||
GC_bool dont_gc_save;
|
||||
|
||||
# ifndef USE_PROC_FOR_LIBRARIES
|
||||
dont_gc_save = disable_gc_for_dlopen();
|
||||
# endif
|
||||
# ifdef USE_LD_WRAP
|
||||
result = __real_dlopen(path, mode);
|
||||
# else
|
||||
result = dlopen(path, mode);
|
||||
# endif
|
||||
# ifndef USE_PROC_FOR_LIBRARIES
|
||||
GC_dont_gc = dont_gc_save;
|
||||
# endif
|
||||
return(result);
|
||||
}
|
||||
# endif /* SOLARIS_THREADS */
|
||||
|
||||
/* BTL: added to fix circular dlopen definition if SOLARIS_THREADS defined */
|
||||
# if defined(GC_must_restore_redefined_dlopen)
|
||||
# define dlopen GC_dlopen
|
||||
# endif
|
||||
|
||||
# if defined(SUNOS4) || defined(SUNOS5DL)
|
||||
/* Add dynamic library data sections to the root set. */
|
||||
# if !defined(PCR) && !defined(SOLARIS_THREADS) && defined(THREADS)
|
||||
|
@ -297,14 +242,193 @@ void GC_register_dynamic_libraries()
|
|||
# endif /* !USE_PROC ... */
|
||||
# endif /* SUNOS */
|
||||
|
||||
#if defined(LINUX) && defined(__ELF__) || defined(SCO_ELF)
|
||||
#if defined(LINUX) && defined(__ELF__) || defined(SCO_ELF) || \
|
||||
(defined(NETBSD) && defined(__ELF__))
|
||||
|
||||
|
||||
#ifdef USE_PROC_FOR_LIBRARIES
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#define MAPS_BUF_SIZE (32*1024)
|
||||
|
||||
extern ssize_t GC_repeat_read(int fd, char *buf, size_t count);
|
||||
/* Repeatedly read until buffer is filled, or EOF is encountered */
|
||||
/* Defined in os_dep.c. */
|
||||
|
||||
static char *parse_map_entry(char *buf_ptr, word *start, word *end,
|
||||
char *prot_buf, unsigned int *maj_dev);
|
||||
|
||||
void GC_register_dynamic_libraries()
|
||||
{
|
||||
int f;
|
||||
int result;
|
||||
char prot_buf[5];
|
||||
int maps_size;
|
||||
char maps_temp[32768];
|
||||
char *maps_buf;
|
||||
char *buf_ptr;
|
||||
int count;
|
||||
word start, end;
|
||||
unsigned int maj_dev, min_dev;
|
||||
word least_ha, greatest_ha;
|
||||
unsigned i;
|
||||
word datastart = (word)(DATASTART);
|
||||
|
||||
/* Read /proc/self/maps */
|
||||
/* Note that we may not allocate, and thus can't use stdio. */
|
||||
f = open("/proc/self/maps", O_RDONLY);
|
||||
if (-1 == f) ABORT("Couldn't open /proc/self/maps");
|
||||
/* stat() doesn't work for /proc/self/maps, so we have to
|
||||
read it to find out how large it is... */
|
||||
maps_size = 0;
|
||||
do {
|
||||
result = GC_repeat_read(f, maps_temp, sizeof(maps_temp));
|
||||
if (result <= 0) ABORT("Couldn't read /proc/self/maps");
|
||||
maps_size += result;
|
||||
} while (result == sizeof(maps_temp));
|
||||
|
||||
if (maps_size > sizeof(maps_temp)) {
|
||||
/* If larger than our buffer, close and re-read it. */
|
||||
close(f);
|
||||
f = open("/proc/self/maps", O_RDONLY);
|
||||
if (-1 == f) ABORT("Couldn't open /proc/self/maps");
|
||||
maps_buf = alloca(maps_size);
|
||||
if (NULL == maps_buf) ABORT("/proc/self/maps alloca failed");
|
||||
result = GC_repeat_read(f, maps_buf, maps_size);
|
||||
if (result <= 0) ABORT("Couldn't read /proc/self/maps");
|
||||
} else {
|
||||
/* Otherwise use the fixed size buffer */
|
||||
maps_buf = maps_temp;
|
||||
}
|
||||
|
||||
close(f);
|
||||
maps_buf[result] = '\0';
|
||||
buf_ptr = maps_buf;
|
||||
/* Compute heap bounds. Should be done by add_to_heap? */
|
||||
least_ha = (word)(-1);
|
||||
greatest_ha = 0;
|
||||
for (i = 0; i < GC_n_heap_sects; ++i) {
|
||||
word sect_start = (word)GC_heap_sects[i].hs_start;
|
||||
word sect_end = sect_start + GC_heap_sects[i].hs_bytes;
|
||||
if (sect_start < least_ha) least_ha = sect_start;
|
||||
if (sect_end > greatest_ha) greatest_ha = sect_end;
|
||||
}
|
||||
if (greatest_ha < (word)GC_scratch_last_end_ptr)
|
||||
greatest_ha = (word)GC_scratch_last_end_ptr;
|
||||
for (;;) {
|
||||
|
||||
buf_ptr = parse_map_entry(buf_ptr, &start, &end, prot_buf, &maj_dev);
|
||||
if (buf_ptr == NULL) return;
|
||||
|
||||
if (prot_buf[1] == 'w') {
|
||||
/* This is a writable mapping. Add it to */
|
||||
/* the root set unless it is already otherwise */
|
||||
/* accounted for. */
|
||||
if (start <= (word)GC_stackbottom && end >= (word)GC_stackbottom) {
|
||||
/* Stack mapping; discard */
|
||||
continue;
|
||||
}
|
||||
if (start <= datastart && end > datastart && maj_dev != 0) {
|
||||
/* Main data segment; discard */
|
||||
continue;
|
||||
}
|
||||
# ifdef THREADS
|
||||
if (GC_segment_is_thread_stack(start, end)) continue;
|
||||
# endif
|
||||
/* The rest of this assumes that there is no mapping */
|
||||
/* spanning the beginning of the data segment, or extending */
|
||||
/* beyond the entire heap at both ends. */
|
||||
/* Empirically these assumptions hold. */
|
||||
|
||||
if (start < (word)DATAEND && end > (word)DATAEND) {
|
||||
/* Rld may use space at the end of the main data */
|
||||
/* segment. Thus we add that in. */
|
||||
start = (word)DATAEND;
|
||||
}
|
||||
if (start < least_ha && end > least_ha) {
|
||||
end = least_ha;
|
||||
}
|
||||
if (start < greatest_ha && end > greatest_ha) {
|
||||
start = greatest_ha;
|
||||
}
|
||||
if (start >= least_ha && end <= greatest_ha) continue;
|
||||
GC_add_roots_inner((char *)start, (char *)end, TRUE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// parse_map_entry parses an entry from /proc/self/maps so we can
|
||||
// locate all writable data segments that belong to shared libraries.
|
||||
// The format of one of these entries and the fields we care about
|
||||
// is as follows:
|
||||
// XXXXXXXX-XXXXXXXX r-xp 00000000 30:05 260537 name of mapping...\n
|
||||
// ^^^^^^^^ ^^^^^^^^ ^^^^ ^^
|
||||
// start end prot maj_dev
|
||||
// 0 9 18 32
|
||||
//
|
||||
// The parser is called with a pointer to the entry and the return value
|
||||
// is either NULL or is advanced to the next entry(the byte after the
|
||||
// trailing '\n'.)
|
||||
//
|
||||
#define OFFSET_MAP_START 0
|
||||
#define OFFSET_MAP_END 9
|
||||
#define OFFSET_MAP_PROT 18
|
||||
#define OFFSET_MAP_MAJDEV 32
|
||||
|
||||
static char *parse_map_entry(char *buf_ptr, word *start, word *end,
|
||||
char *prot_buf, unsigned int *maj_dev)
|
||||
{
|
||||
int i;
|
||||
unsigned int val;
|
||||
char *tok;
|
||||
|
||||
if (buf_ptr == NULL || *buf_ptr == '\0') {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
memcpy(prot_buf, buf_ptr+OFFSET_MAP_PROT, 4); // do the protections first
|
||||
prot_buf[4] = '\0';
|
||||
|
||||
if (prot_buf[1] == 'w') { // we can skip all of this if it's not writable
|
||||
|
||||
tok = buf_ptr;
|
||||
buf_ptr[OFFSET_MAP_START+8] = '\0';
|
||||
*start = strtoul(tok, NULL, 16);
|
||||
|
||||
tok = buf_ptr+OFFSET_MAP_END;
|
||||
buf_ptr[OFFSET_MAP_END+8] = '\0';
|
||||
*end = strtoul(tok, NULL, 16);
|
||||
|
||||
buf_ptr += OFFSET_MAP_MAJDEV;
|
||||
tok = buf_ptr;
|
||||
while (*buf_ptr != ':') buf_ptr++;
|
||||
*buf_ptr++ = '\0';
|
||||
*maj_dev = strtoul(tok, NULL, 16);
|
||||
}
|
||||
|
||||
while (*buf_ptr && *buf_ptr++ != '\n');
|
||||
|
||||
return buf_ptr;
|
||||
}
|
||||
|
||||
#else /* !USE_PROC_FOR_LIBRARIES */
|
||||
|
||||
/* Dynamic loading code for Linux running ELF. Somewhat tested on
|
||||
* Linux/x86, untested but hopefully should work on Linux/Alpha.
|
||||
* This code was derived from the Solaris/ELF support. Thanks to
|
||||
* whatever kind soul wrote that. - Patrick Bridges */
|
||||
|
||||
#include <elf.h>
|
||||
#if defined(NETBSD)
|
||||
# include <sys/exec_elf.h>
|
||||
#else
|
||||
# include <elf.h>
|
||||
#endif
|
||||
#include <link.h>
|
||||
|
||||
/* Newer versions of Linux/Alpha and Linux/x86 define this macro. We
|
||||
|
@ -379,9 +503,11 @@ void GC_register_dynamic_libraries()
|
|||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif /* !USE_PROC_FOR_LIBRARIES */
|
||||
|
||||
#if defined(IRIX5) || defined(USE_PROC_FOR_LIBRARIES)
|
||||
#endif /* LINUX */
|
||||
|
||||
#if defined(IRIX5) || (defined(USE_PROC_FOR_LIBRARIES) && !defined(LINUX))
|
||||
|
||||
#include <sys/procfs.h>
|
||||
#include <sys/stat.h>
|
||||
|
@ -393,10 +519,6 @@ extern void * GC_roots_present();
|
|||
/* The type is a lie, since the real type doesn't make sense here, */
|
||||
/* and we only test for NULL. */
|
||||
|
||||
#ifndef GC_scratch_last_end_ptr
|
||||
extern ptr_t GC_scratch_last_end_ptr; /* End of GC_scratch_alloc arena */
|
||||
#endif
|
||||
|
||||
/* We use /proc to track down all parts of the address space that are */
|
||||
/* mapped by the process, and throw out regions we know we shouldn't */
|
||||
/* worry about. This may also work under other SVR4 variants. */
|
||||
|
@ -504,7 +626,7 @@ void GC_register_dynamic_libraries()
|
|||
|
||||
# endif /* USE_PROC || IRIX5 */
|
||||
|
||||
# ifdef MSWIN32
|
||||
# if defined(MSWIN32) || defined(MSWINCE)
|
||||
|
||||
# define WIN32_LEAN_AND_MEAN
|
||||
# define NOSERVICE
|
||||
|
@ -513,86 +635,97 @@ void GC_register_dynamic_libraries()
|
|||
|
||||
/* We traverse the entire address space and register all segments */
|
||||
/* that could possibly have been written to. */
|
||||
DWORD GC_allocation_granularity;
|
||||
|
||||
extern GC_bool GC_is_heap_base (ptr_t p);
|
||||
|
||||
# ifdef WIN32_THREADS
|
||||
extern void GC_get_next_stack(char *start, char **lo, char **hi);
|
||||
# endif
|
||||
|
||||
void GC_cond_add_roots(char *base, char * limit)
|
||||
{
|
||||
char dummy;
|
||||
char * stack_top
|
||||
= (char *) ((word)(&dummy) & ~(GC_allocation_granularity-1));
|
||||
if (base == limit) return;
|
||||
# ifdef WIN32_THREADS
|
||||
void GC_cond_add_roots(char *base, char * limit)
|
||||
{
|
||||
char * curr_base = base;
|
||||
char * next_stack_lo;
|
||||
char * next_stack_hi;
|
||||
|
||||
for(;;) {
|
||||
GC_get_next_stack(curr_base, &next_stack_lo, &next_stack_hi);
|
||||
if (next_stack_lo >= limit) break;
|
||||
GC_add_roots_inner(curr_base, next_stack_lo, TRUE);
|
||||
curr_base = next_stack_hi;
|
||||
}
|
||||
if (curr_base < limit) GC_add_roots_inner(curr_base, limit, TRUE);
|
||||
char * curr_base = base;
|
||||
char * next_stack_lo;
|
||||
char * next_stack_hi;
|
||||
|
||||
if (base == limit) return;
|
||||
for(;;) {
|
||||
GC_get_next_stack(curr_base, &next_stack_lo, &next_stack_hi);
|
||||
if (next_stack_lo >= limit) break;
|
||||
GC_add_roots_inner(curr_base, next_stack_lo, TRUE);
|
||||
curr_base = next_stack_hi;
|
||||
}
|
||||
if (curr_base < limit) GC_add_roots_inner(curr_base, limit, TRUE);
|
||||
}
|
||||
# else
|
||||
if (limit > stack_top && base < GC_stackbottom) {
|
||||
/* Part of the stack; ignore it. */
|
||||
return;
|
||||
}
|
||||
GC_add_roots_inner(base, limit, TRUE);
|
||||
# endif
|
||||
}
|
||||
|
||||
# else
|
||||
void GC_cond_add_roots(char *base, char * limit)
|
||||
{
|
||||
char dummy;
|
||||
char * stack_top
|
||||
= (char *) ((word)(&dummy) & ~(GC_sysinfo.dwAllocationGranularity-1));
|
||||
if (base == limit) return;
|
||||
if (limit > stack_top && base < GC_stackbottom) {
|
||||
/* Part of the stack; ignore it. */
|
||||
return;
|
||||
}
|
||||
GC_add_roots_inner(base, limit, TRUE);
|
||||
}
|
||||
# endif
|
||||
|
||||
# ifndef MSWINCE
|
||||
extern GC_bool GC_win32s;
|
||||
# endif
|
||||
|
||||
void GC_register_dynamic_libraries()
|
||||
{
|
||||
MEMORY_BASIC_INFORMATION buf;
|
||||
SYSTEM_INFO sysinfo;
|
||||
DWORD result;
|
||||
DWORD protect;
|
||||
LPVOID p;
|
||||
char * base;
|
||||
char * limit, * new_limit;
|
||||
|
||||
if (GC_win32s) return;
|
||||
GetSystemInfo(&sysinfo);
|
||||
base = limit = p = sysinfo.lpMinimumApplicationAddress;
|
||||
GC_allocation_granularity = sysinfo.dwAllocationGranularity;
|
||||
while (p < sysinfo.lpMaximumApplicationAddress) {
|
||||
|
||||
# ifdef MSWIN32
|
||||
if (GC_win32s) return;
|
||||
# endif
|
||||
base = limit = p = GC_sysinfo.lpMinimumApplicationAddress;
|
||||
# if defined(MSWINCE) && !defined(_WIN32_WCE_EMULATION)
|
||||
/* Only the first 32 MB of address space belongs to the current process */
|
||||
while (p < (LPVOID)0x02000000) {
|
||||
result = VirtualQuery(p, &buf, sizeof(buf));
|
||||
if (result != sizeof(buf)) {
|
||||
ABORT("Weird VirtualQuery result");
|
||||
}
|
||||
new_limit = (char *)p + buf.RegionSize;
|
||||
protect = buf.Protect;
|
||||
if (buf.State == MEM_COMMIT
|
||||
&& (protect == PAGE_EXECUTE_READWRITE
|
||||
|| protect == PAGE_READWRITE)
|
||||
&& !GC_is_heap_base(buf.AllocationBase)) {
|
||||
if ((char *)p == limit) {
|
||||
limit = new_limit;
|
||||
} else {
|
||||
GC_cond_add_roots(base, limit);
|
||||
base = p;
|
||||
limit = new_limit;
|
||||
}
|
||||
}
|
||||
if (result == 0) {
|
||||
/* Page is free; advance to the next possible allocation base */
|
||||
new_limit = (char *)
|
||||
(((DWORD) p + GC_sysinfo.dwAllocationGranularity)
|
||||
& ~(GC_sysinfo.dwAllocationGranularity-1));
|
||||
} else
|
||||
# else
|
||||
while (p < GC_sysinfo.lpMaximumApplicationAddress) {
|
||||
result = VirtualQuery(p, &buf, sizeof(buf));
|
||||
# endif
|
||||
{
|
||||
if (result != sizeof(buf)) {
|
||||
ABORT("Weird VirtualQuery result");
|
||||
}
|
||||
new_limit = (char *)p + buf.RegionSize;
|
||||
protect = buf.Protect;
|
||||
if (buf.State == MEM_COMMIT
|
||||
&& (protect == PAGE_EXECUTE_READWRITE
|
||||
|| protect == PAGE_READWRITE)
|
||||
&& !GC_is_heap_base(buf.AllocationBase)) {
|
||||
if ((char *)p != limit) {
|
||||
GC_cond_add_roots(base, limit);
|
||||
base = p;
|
||||
}
|
||||
limit = new_limit;
|
||||
}
|
||||
}
|
||||
if (p > (LPVOID)new_limit /* overflow */) break;
|
||||
p = (LPVOID)new_limit;
|
||||
}
|
||||
GC_cond_add_roots(base, limit);
|
||||
}
|
||||
|
||||
#endif /* MSWIN32 */
|
||||
|
||||
#endif /* MSWIN32 || MSWINCE */
|
||||
|
||||
#if defined(ALPHA) && defined(OSF1)
|
||||
|
||||
#include <loader.h>
|
||||
|
|
|
@ -14,8 +14,7 @@
|
|||
*/
|
||||
/* Boehm, February 1, 1996 1:19 pm PST */
|
||||
# define I_HIDE_POINTERS
|
||||
# include "gc_priv.h"
|
||||
# include "gc_mark.h"
|
||||
# include "private/gc_pmark.h"
|
||||
|
||||
# ifdef FINALIZE_ON_DEMAND
|
||||
int GC_finalize_on_demand = 1;
|
||||
|
@ -86,13 +85,13 @@ static signed_word log_fo_table_size = -1;
|
|||
|
||||
word GC_fo_entries = 0;
|
||||
|
||||
# ifdef SRC_M3
|
||||
void GC_push_finalizer_structures()
|
||||
void GC_push_finalizer_structures GC_PROTO((void))
|
||||
{
|
||||
GC_push_all((ptr_t)(&dl_head), (ptr_t)(&dl_head) + sizeof(word));
|
||||
GC_push_all((ptr_t)(&fo_head), (ptr_t)(&fo_head) + sizeof(word));
|
||||
GC_push_all((ptr_t)(&GC_finalize_now),
|
||||
(ptr_t)(&GC_finalize_now) + sizeof(word));
|
||||
}
|
||||
# endif
|
||||
|
||||
/* Double the size of a hash table. *size_ptr is the log of its current */
|
||||
/* size. May be a noop. */
|
||||
|
@ -110,7 +109,7 @@ signed_word * log_size_ptr;
|
|||
word old_size = ((log_old_size == -1)? 0: (1 << log_old_size));
|
||||
register word new_size = 1 << log_new_size;
|
||||
struct hash_chain_entry **new_table = (struct hash_chain_entry **)
|
||||
GC_generic_malloc_inner_ignore_off_page(
|
||||
GC_INTERNAL_MALLOC_IGNORE_OFF_PAGE(
|
||||
(size_t)new_size * sizeof(struct hash_chain_entry *), NORMAL);
|
||||
|
||||
if (new_table == 0) {
|
||||
|
@ -179,9 +178,11 @@ signed_word * log_size_ptr;
|
|||
# endif
|
||||
GC_grow_table((struct hash_chain_entry ***)(&dl_head),
|
||||
&log_dl_table_size);
|
||||
# ifdef PRINTSTATS
|
||||
# ifdef CONDPRINT
|
||||
if (GC_print_stats) {
|
||||
GC_printf1("Grew dl table to %lu entries\n",
|
||||
(unsigned long)(1 << log_dl_table_size));
|
||||
}
|
||||
# endif
|
||||
# ifndef THREADS
|
||||
ENABLE_SIGNALS();
|
||||
|
@ -199,13 +200,8 @@ signed_word * log_size_ptr;
|
|||
return(1);
|
||||
}
|
||||
}
|
||||
# ifdef THREADS
|
||||
new_dl = (struct disappearing_link *)
|
||||
GC_generic_malloc_inner(sizeof(struct disappearing_link),NORMAL);
|
||||
# else
|
||||
new_dl = (struct disappearing_link *)
|
||||
GC_malloc(sizeof(struct disappearing_link));
|
||||
# endif
|
||||
new_dl = (struct disappearing_link *)
|
||||
GC_INTERNAL_MALLOC(sizeof(struct disappearing_link),NORMAL);
|
||||
if (new_dl != 0) {
|
||||
new_dl -> dl_hidden_obj = HIDE_POINTER(obj);
|
||||
new_dl -> dl_hidden_link = HIDE_POINTER(link);
|
||||
|
@ -248,7 +244,11 @@ signed_word * log_size_ptr;
|
|||
GC_dl_entries--;
|
||||
UNLOCK();
|
||||
ENABLE_SIGNALS();
|
||||
GC_free((GC_PTR)curr_dl);
|
||||
# ifdef DBG_HDRS_ALL
|
||||
dl_next(curr_dl) = 0;
|
||||
# else
|
||||
GC_free((GC_PTR)curr_dl);
|
||||
# endif
|
||||
return(1);
|
||||
}
|
||||
prev_dl = curr_dl;
|
||||
|
@ -283,7 +283,7 @@ ptr_t p;
|
|||
ptr_t scan_limit;
|
||||
ptr_t target_limit = p + WORDS_TO_BYTES(hhdr -> hb_sz) - 1;
|
||||
|
||||
if ((descr & DS_TAGS) == DS_LENGTH) {
|
||||
if ((descr & GC_DS_TAGS) == GC_DS_LENGTH) {
|
||||
scan_limit = p + descr - sizeof(word);
|
||||
} else {
|
||||
scan_limit = target_limit + 1 - sizeof(word);
|
||||
|
@ -338,9 +338,11 @@ finalization_mark_proc * mp;
|
|||
# endif
|
||||
GC_grow_table((struct hash_chain_entry ***)(&fo_head),
|
||||
&log_fo_table_size);
|
||||
# ifdef PRINTSTATS
|
||||
# ifdef CONDPRINT
|
||||
if (GC_print_stats) {
|
||||
GC_printf1("Grew fo table to %lu entries\n",
|
||||
(unsigned long)(1 << log_fo_table_size));
|
||||
}
|
||||
# endif
|
||||
# ifndef THREADS
|
||||
ENABLE_SIGNALS();
|
||||
|
@ -370,7 +372,7 @@ finalization_mark_proc * mp;
|
|||
/* May not happen if we get a signal. But a high */
|
||||
/* estimate will only make the table larger than */
|
||||
/* necessary. */
|
||||
# ifndef THREADS
|
||||
# if !defined(THREADS) && !defined(DBG_HDRS_ALL)
|
||||
GC_free((GC_PTR)curr_fo);
|
||||
# endif
|
||||
} else {
|
||||
|
@ -406,23 +408,14 @@ finalization_mark_proc * mp;
|
|||
GET_HDR(base, hhdr);
|
||||
if (0 == hhdr) {
|
||||
/* We won't collect it, hence finalizer wouldn't be run. */
|
||||
/* This is changed for gcj, but it will be in version 6.0 of the */
|
||||
/* standard collector distribution. It costs virtually nothing */
|
||||
/* here, but it's expensive to check in the hash synchronization */
|
||||
/* code, where it matters. -HB */
|
||||
# ifdef THREADS
|
||||
UNLOCK();
|
||||
ENABLE_SIGNALS();
|
||||
# endif
|
||||
return;
|
||||
}
|
||||
# ifdef THREADS
|
||||
new_fo = (struct finalizable_object *)
|
||||
GC_generic_malloc_inner(sizeof(struct finalizable_object),NORMAL);
|
||||
# else
|
||||
new_fo = (struct finalizable_object *)
|
||||
GC_malloc(sizeof(struct finalizable_object));
|
||||
# endif
|
||||
new_fo = (struct finalizable_object *)
|
||||
GC_INTERNAL_MALLOC(sizeof(struct finalizable_object),NORMAL);
|
||||
if (new_fo != 0) {
|
||||
new_fo -> fo_hidden_base = (word)HIDE_POINTER(base);
|
||||
new_fo -> fo_fn = fn;
|
||||
|
@ -492,6 +485,34 @@ finalization_mark_proc * mp;
|
|||
ocd, GC_null_finalize_mark_proc);
|
||||
}
|
||||
|
||||
#ifndef NO_DEBUGGING
|
||||
void GC_dump_finalization()
|
||||
{
|
||||
struct disappearing_link * curr_dl;
|
||||
struct finalizable_object * curr_fo;
|
||||
ptr_t real_ptr, real_link;
|
||||
int dl_size = (log_dl_table_size == -1 ) ? 0 : (1 << log_dl_table_size);
|
||||
int fo_size = (log_fo_table_size == -1 ) ? 0 : (1 << log_fo_table_size);
|
||||
int i;
|
||||
|
||||
GC_printf0("Disappearing links:\n");
|
||||
for (i = 0; i < dl_size; i++) {
|
||||
for (curr_dl = dl_head[i]; curr_dl != 0; curr_dl = dl_next(curr_dl)) {
|
||||
real_ptr = (ptr_t)REVEAL_POINTER(curr_dl -> dl_hidden_obj);
|
||||
real_link = (ptr_t)REVEAL_POINTER(curr_dl -> dl_hidden_link);
|
||||
GC_printf2("Object: 0x%lx, Link:0x%lx\n", real_ptr, real_link);
|
||||
}
|
||||
}
|
||||
GC_printf0("Finalizers:\n");
|
||||
for (i = 0; i < fo_size; i++) {
|
||||
for (curr_fo = fo_head[i]; curr_fo != 0; curr_fo = fo_next(curr_fo)) {
|
||||
real_ptr = (ptr_t)REVEAL_POINTER(curr_fo -> fo_hidden_base);
|
||||
GC_printf1("Finalizable object: 0x%lx\n", real_ptr);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Called with world stopped. Cause disappearing links to disappear, */
|
||||
/* and invoke finalizers. */
|
||||
void GC_finalize()
|
||||
|
@ -529,9 +550,7 @@ void GC_finalize()
|
|||
}
|
||||
/* Mark all objects reachable via chains of 1 or more pointers */
|
||||
/* from finalizable objects. */
|
||||
# ifdef PRINTSTATS
|
||||
if (GC_mark_state != MS_NONE) ABORT("Bad mark state");
|
||||
# endif
|
||||
GC_ASSERT(GC_mark_state == MS_NONE);
|
||||
for (i = 0; i < fo_size; i++) {
|
||||
for (curr_fo = fo_head[i]; curr_fo != 0; curr_fo = fo_next(curr_fo)) {
|
||||
real_ptr = (ptr_t)REVEAL_POINTER(curr_fo -> fo_hidden_base);
|
||||
|
@ -574,11 +593,7 @@ void GC_finalize()
|
|||
GC_words_finalized +=
|
||||
ALIGNED_WORDS(curr_fo -> fo_object_size)
|
||||
+ ALIGNED_WORDS(sizeof(struct finalizable_object));
|
||||
# ifdef PRINTSTATS
|
||||
if (!GC_is_marked((ptr_t)curr_fo)) {
|
||||
ABORT("GC_finalize: found accessible unmarked object\n");
|
||||
}
|
||||
# endif
|
||||
GC_ASSERT(GC_is_marked((ptr_t)curr_fo));
|
||||
curr_fo = next_fo;
|
||||
} else {
|
||||
prev_fo = curr_fo;
|
||||
|
@ -753,6 +768,25 @@ int GC_invoke_finalizers()
|
|||
return count;
|
||||
}
|
||||
|
||||
void (* GC_finalizer_notifier)() = (void (*) GC_PROTO((void)))0;
|
||||
|
||||
static GC_word last_finalizer_notification = 0;
|
||||
|
||||
void GC_notify_or_invoke_finalizers GC_PROTO((void))
|
||||
{
|
||||
if (GC_finalize_now == 0) return;
|
||||
if (!GC_finalize_on_demand) {
|
||||
(void) GC_invoke_finalizers();
|
||||
GC_ASSERT(GC_finalize_now == 0);
|
||||
return;
|
||||
}
|
||||
if (GC_finalizer_notifier != (void (*) GC_PROTO((void)))0
|
||||
&& last_finalizer_notification != GC_gc_no) {
|
||||
last_finalizer_notification = GC_gc_no;
|
||||
GC_finalizer_notifier();
|
||||
}
|
||||
}
|
||||
|
||||
# ifdef __STDC__
|
||||
GC_PTR GC_call_with_alloc_lock(GC_fn_type fn,
|
||||
GC_PTR client_data)
|
||||
|
@ -772,7 +806,9 @@ int GC_invoke_finalizers()
|
|||
# endif
|
||||
result = (*fn)(client_data);
|
||||
# ifdef THREADS
|
||||
UNSET_LOCK_HOLDER();
|
||||
# ifndef GC_ASSERTIONS
|
||||
UNSET_LOCK_HOLDER();
|
||||
# endif /* o.w. UNLOCK() does it implicitly */
|
||||
UNLOCK();
|
||||
ENABLE_SIGNALS();
|
||||
# endif
|
||||
|
|
804
boehm-gc/gc.h
804
boehm-gc/gc.h
|
@ -1,804 +0,0 @@
|
|||
/*
|
||||
* Copyright 1988, 1989 Hans-J. Boehm, Alan J. Demers
|
||||
* Copyright (c) 1991-1995 by Xerox Corporation. All rights reserved.
|
||||
* Copyright 1996-1999 by Silicon Graphics. All rights reserved.
|
||||
* Copyright 1999 by Hewlett-Packard Company. 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Note that this defines a large number of tuning hooks, which can
|
||||
* safely be ignored in nearly all cases. For normal use it suffices
|
||||
* to call only GC_MALLOC and perhaps GC_REALLOC.
|
||||
* For better performance, also look at GC_MALLOC_ATOMIC, and
|
||||
* GC_enable_incremental. If you need an action to be performed
|
||||
* immediately before an object is collected, look at GC_register_finalizer.
|
||||
* If you are using Solaris threads, look at the end of this file.
|
||||
* Everything else is best ignored unless you encounter performance
|
||||
* problems.
|
||||
*/
|
||||
|
||||
#ifndef _GC_H
|
||||
|
||||
# define _GC_H
|
||||
# define __GC
|
||||
# include <stddef.h>
|
||||
|
||||
#if defined(__CYGWIN32__) && defined(GC_USE_DLL)
|
||||
#include "libgc_globals.h"
|
||||
#endif
|
||||
|
||||
#if defined(__MINGW32__) && defined(WIN32_THREADS)
|
||||
# ifdef GC_BUILD
|
||||
# define GC_API __declspec(dllexport)
|
||||
# else
|
||||
# define GC_API __declspec(dllimport)
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if defined(_MSC_VER) && defined(_DLL)
|
||||
# ifdef GC_BUILD
|
||||
# define GC_API __declspec(dllexport)
|
||||
# else
|
||||
# define GC_API __declspec(dllimport)
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if defined(__WATCOMC__) && defined(GC_DLL)
|
||||
# ifdef GC_BUILD
|
||||
# define GC_API extern __declspec(dllexport)
|
||||
# else
|
||||
# define GC_API extern __declspec(dllimport)
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef GC_API
|
||||
#define GC_API extern
|
||||
#endif
|
||||
|
||||
# if defined(__STDC__) || defined(__cplusplus)
|
||||
# define GC_PROTO(args) args
|
||||
typedef void * GC_PTR;
|
||||
# define GC_CONST const
|
||||
# else
|
||||
# define GC_PROTO(args) ()
|
||||
typedef char * GC_PTR;
|
||||
# define GC_CONST
|
||||
# endif
|
||||
|
||||
# ifdef __cplusplus
|
||||
extern "C" {
|
||||
# endif
|
||||
|
||||
|
||||
/* Define word and signed_word to be unsigned and signed types of the */
|
||||
/* size as char * or void *. There seems to be no way to do this */
|
||||
/* even semi-portably. The following is probably no better/worse */
|
||||
/* than almost anything else. */
|
||||
/* The ANSI standard suggests that size_t and ptr_diff_t might be */
|
||||
/* better choices. But those appear to have incorrect definitions */
|
||||
/* on may systems. Notably "typedef int size_t" seems to be both */
|
||||
/* frequent and WRONG. */
|
||||
typedef unsigned long GC_word;
|
||||
typedef long GC_signed_word;
|
||||
|
||||
/* Public read-only variables */
|
||||
|
||||
GC_API GC_word GC_gc_no;/* Counter incremented per collection. */
|
||||
/* Includes empty GCs at startup. */
|
||||
|
||||
|
||||
/* Public R/W variables */
|
||||
|
||||
GC_API GC_PTR (*GC_oom_fn) GC_PROTO((size_t bytes_requested));
|
||||
/* When there is insufficient memory to satisfy */
|
||||
/* an allocation request, we return */
|
||||
/* (*GC_oom_fn)(). By default this just */
|
||||
/* returns 0. */
|
||||
/* If it returns, it must return 0 or a valid */
|
||||
/* pointer to a previously allocated heap */
|
||||
/* object. */
|
||||
|
||||
GC_API int GC_find_leak;
|
||||
/* Do not actually garbage collect, but simply */
|
||||
/* report inaccessible memory that was not */
|
||||
/* deallocated with GC_free. Initial value */
|
||||
/* is determined by FIND_LEAK macro. */
|
||||
|
||||
GC_API int GC_quiet; /* Disable statistics output. Only matters if */
|
||||
/* collector has been compiled with statistics */
|
||||
/* enabled. This involves a performance cost, */
|
||||
/* and is thus not the default. */
|
||||
|
||||
GC_API int GC_finalize_on_demand;
|
||||
/* If nonzero, finalizers will only be run in */
|
||||
/* response to an eplit GC_invoke_finalizers */
|
||||
/* call. The default is determined by whether */
|
||||
/* the FINALIZE_ON_DEMAND macro is defined */
|
||||
/* when the collector is built. */
|
||||
|
||||
GC_API int GC_java_finalization;
|
||||
/* Mark objects reachable from finalizable */
|
||||
/* objects in a separate postpass. This makes */
|
||||
/* it a bit safer to use non-topologically- */
|
||||
/* ordered finalization. Default value is */
|
||||
/* determined by JAVA_FINALIZATION macro. */
|
||||
|
||||
GC_API int GC_dont_gc; /* Dont collect unless explicitly requested, e.g. */
|
||||
/* because it's not safe. */
|
||||
|
||||
GC_API int GC_dont_expand;
|
||||
/* Dont expand heap unless explicitly requested */
|
||||
/* or forced to. */
|
||||
|
||||
GC_API int GC_use_entire_heap;
|
||||
/* Causes the nonincremental collector to use the */
|
||||
/* entire heap before collecting. This was the only */
|
||||
/* option for GC versions < 5.0. This sometimes */
|
||||
/* results in more large block fragmentation, since */
|
||||
/* very larg blocks will tend to get broken up */
|
||||
/* during each GC cycle. It is likely to result in a */
|
||||
/* larger working set, but lower collection */
|
||||
/* frequencies, and hence fewer instructions executed */
|
||||
/* in the collector. */
|
||||
|
||||
GC_API int GC_full_freq; /* Number of partial collections between */
|
||||
/* full collections. Matters only if */
|
||||
/* GC_incremental is set. */
|
||||
/* Full collections are also triggered if */
|
||||
/* the collector detects a substantial */
|
||||
/* increase in the number of in-use heap */
|
||||
/* blocks. Values in the tens are now */
|
||||
/* perfectly reasonable, unlike for */
|
||||
/* earlier GC versions. */
|
||||
|
||||
GC_API GC_word GC_non_gc_bytes;
|
||||
/* Bytes not considered candidates for collection. */
|
||||
/* Used only to control scheduling of collections. */
|
||||
|
||||
GC_API GC_word GC_free_space_divisor;
|
||||
/* We try to make sure that we allocate at */
|
||||
/* least N/GC_free_space_divisor bytes between */
|
||||
/* collections, where N is the heap size plus */
|
||||
/* a rough estimate of the root set size. */
|
||||
/* Initially, GC_free_space_divisor = 4. */
|
||||
/* Increasing its value will use less space */
|
||||
/* but more collection time. Decreasing it */
|
||||
/* will appreciably decrease collection time */
|
||||
/* at the expense of space. */
|
||||
/* GC_free_space_divisor = 1 will effectively */
|
||||
/* disable collections. */
|
||||
|
||||
GC_API GC_word GC_max_retries;
|
||||
/* The maximum number of GCs attempted before */
|
||||
/* reporting out of memory after heap */
|
||||
/* expansion fails. Initially 0. */
|
||||
|
||||
|
||||
GC_API char *GC_stackbottom; /* Cool end of user stack. */
|
||||
/* May be set in the client prior to */
|
||||
/* calling any GC_ routines. This */
|
||||
/* avoids some overhead, and */
|
||||
/* potentially some signals that can */
|
||||
/* confuse debuggers. Otherwise the */
|
||||
/* collector attempts to set it */
|
||||
/* automatically. */
|
||||
/* For multithreaded code, this is the */
|
||||
/* cold end of the stack for the */
|
||||
/* primordial thread. */
|
||||
|
||||
/* Public procedures */
|
||||
/*
|
||||
* general purpose allocation routines, with roughly malloc calling conv.
|
||||
* The atomic versions promise that no relevant pointers are contained
|
||||
* in the object. The nonatomic versions guarantee that the new object
|
||||
* is cleared. GC_malloc_stubborn promises that no changes to the object
|
||||
* will occur after GC_end_stubborn_change has been called on the
|
||||
* result of GC_malloc_stubborn. GC_malloc_uncollectable allocates an object
|
||||
* that is scanned for pointers to collectable objects, but is not itself
|
||||
* collectable. GC_malloc_uncollectable and GC_free called on the resulting
|
||||
* object implicitly update GC_non_gc_bytes appropriately.
|
||||
*/
|
||||
GC_API GC_PTR GC_malloc GC_PROTO((size_t size_in_bytes));
|
||||
GC_API GC_PTR GC_malloc_atomic GC_PROTO((size_t size_in_bytes));
|
||||
GC_API GC_PTR GC_malloc_uncollectable GC_PROTO((size_t size_in_bytes));
|
||||
GC_API GC_PTR GC_malloc_stubborn GC_PROTO((size_t size_in_bytes));
|
||||
|
||||
/* The following is only defined if the library has been suitably */
|
||||
/* compiled: */
|
||||
GC_API GC_PTR GC_malloc_atomic_uncollectable GC_PROTO((size_t size_in_bytes));
|
||||
|
||||
/* Explicitly deallocate an object. Dangerous if used incorrectly. */
|
||||
/* Requires a pointer to the base of an object. */
|
||||
/* If the argument is stubborn, it should not be changeable when freed. */
|
||||
/* An object should not be enable for finalization when it is */
|
||||
/* explicitly deallocated. */
|
||||
/* GC_free(0) is a no-op, as required by ANSI C for free. */
|
||||
GC_API void GC_free GC_PROTO((GC_PTR object_addr));
|
||||
|
||||
/*
|
||||
* Stubborn objects may be changed only if the collector is explicitly informed.
|
||||
* The collector is implicitly informed of coming change when such
|
||||
* an object is first allocated. The following routines inform the
|
||||
* collector that an object will no longer be changed, or that it will
|
||||
* once again be changed. Only nonNIL pointer stores into the object
|
||||
* are considered to be changes. The argument to GC_end_stubborn_change
|
||||
* must be exacly the value returned by GC_malloc_stubborn or passed to
|
||||
* GC_change_stubborn. (In the second case it may be an interior pointer
|
||||
* within 512 bytes of the beginning of the objects.)
|
||||
* There is a performance penalty for allowing more than
|
||||
* one stubborn object to be changed at once, but it is acceptable to
|
||||
* do so. The same applies to dropping stubborn objects that are still
|
||||
* changeable.
|
||||
*/
|
||||
GC_API void GC_change_stubborn GC_PROTO((GC_PTR));
|
||||
GC_API void GC_end_stubborn_change GC_PROTO((GC_PTR));
|
||||
|
||||
/* Return a pointer to the base (lowest address) of an object given */
|
||||
/* a pointer to a location within the object. */
|
||||
/* Return 0 if displaced_pointer doesn't point to within a valid */
|
||||
/* object. */
|
||||
GC_API GC_PTR GC_base GC_PROTO((GC_PTR displaced_pointer));
|
||||
|
||||
/* Given a pointer to the base of an object, return its size in bytes. */
|
||||
/* The returned size may be slightly larger than what was originally */
|
||||
/* requested. */
|
||||
GC_API size_t GC_size GC_PROTO((GC_PTR object_addr));
|
||||
|
||||
/* For compatibility with C library. This is occasionally faster than */
|
||||
/* a malloc followed by a bcopy. But if you rely on that, either here */
|
||||
/* or with the standard C library, your code is broken. In my */
|
||||
/* opinion, it shouldn't have been invented, but now we're stuck. -HB */
|
||||
/* The resulting object has the same kind as the original. */
|
||||
/* If the argument is stubborn, the result will have changes enabled. */
|
||||
/* It is an error to have changes enabled for the original object. */
|
||||
/* Follows ANSI comventions for NULL old_object. */
|
||||
GC_API GC_PTR GC_realloc
|
||||
GC_PROTO((GC_PTR old_object, size_t new_size_in_bytes));
|
||||
|
||||
/* Explicitly increase the heap size. */
|
||||
/* Returns 0 on failure, 1 on success. */
|
||||
GC_API int GC_expand_hp GC_PROTO((size_t number_of_bytes));
|
||||
|
||||
/* Limit the heap size to n bytes. Useful when you're debugging, */
|
||||
/* especially on systems that don't handle running out of memory well. */
|
||||
/* n == 0 ==> unbounded. This is the default. */
|
||||
GC_API void GC_set_max_heap_size GC_PROTO((GC_word n));
|
||||
|
||||
/* Inform the collector that a certain section of statically allocated */
|
||||
/* memory contains no pointers to garbage collected memory. Thus it */
|
||||
/* need not be scanned. This is sometimes important if the application */
|
||||
/* maps large read/write files into the address space, which could be */
|
||||
/* mistaken for dynamic library data segments on some systems. */
|
||||
GC_API void GC_exclude_static_roots GC_PROTO((GC_PTR start, GC_PTR finish));
|
||||
|
||||
/* Clear the set of root segments. Wizards only. */
|
||||
GC_API void GC_clear_roots GC_PROTO((void));
|
||||
|
||||
/* Add a root segment. Wizards only. */
|
||||
GC_API void GC_add_roots GC_PROTO((char * low_address,
|
||||
char * high_address_plus_1));
|
||||
|
||||
/* Add a displacement to the set of those considered valid by the */
|
||||
/* collector. GC_register_displacement(n) means that if p was returned */
|
||||
/* by GC_malloc, then (char *)p + n will be considered to be a valid */
|
||||
/* pointer to n. N must be small and less than the size of p. */
|
||||
/* (All pointers to the interior of objects from the stack are */
|
||||
/* considered valid in any case. This applies to heap objects and */
|
||||
/* static data.) */
|
||||
/* Preferably, this should be called before any other GC procedures. */
|
||||
/* Calling it later adds to the probability of excess memory */
|
||||
/* retention. */
|
||||
/* This is a no-op if the collector was compiled with recognition of */
|
||||
/* arbitrary interior pointers enabled, which is now the default. */
|
||||
GC_API void GC_register_displacement GC_PROTO((GC_word n));
|
||||
|
||||
/* The following version should be used if any debugging allocation is */
|
||||
/* being done. */
|
||||
GC_API void GC_debug_register_displacement GC_PROTO((GC_word n));
|
||||
|
||||
/* Explicitly trigger a full, world-stop collection. */
|
||||
GC_API void GC_gcollect GC_PROTO((void));
|
||||
|
||||
/* Trigger a full world-stopped collection. Abort the collection if */
|
||||
/* and when stop_func returns a nonzero value. Stop_func will be */
|
||||
/* called frequently, and should be reasonably fast. This works even */
|
||||
/* if virtual dirty bits, and hence incremental collection is not */
|
||||
/* available for this architecture. Collections can be aborted faster */
|
||||
/* than normal pause times for incremental collection. However, */
|
||||
/* aborted collections do no useful work; the next collection needs */
|
||||
/* to start from the beginning. */
|
||||
/* Return 0 if the collection was aborted, 1 if it succeeded. */
|
||||
typedef int (* GC_stop_func) GC_PROTO((void));
|
||||
GC_API int GC_try_to_collect GC_PROTO((GC_stop_func stop_func));
|
||||
|
||||
/* Return the number of bytes in the heap. Excludes collector private */
|
||||
/* data structures. Includes empty blocks and fragmentation loss. */
|
||||
/* Includes some pages that were allocated but never written. */
|
||||
GC_API size_t GC_get_heap_size GC_PROTO((void));
|
||||
|
||||
/* Return a lower bound on the number of free bytes in the heap. */
|
||||
GC_API size_t GC_get_free_bytes GC_PROTO((void));
|
||||
|
||||
/* Return the number of bytes allocated since the last collection. */
|
||||
GC_API size_t GC_get_bytes_since_gc GC_PROTO((void));
|
||||
|
||||
/* Enable incremental/generational collection. */
|
||||
/* Not advisable unless dirty bits are */
|
||||
/* available or most heap objects are */
|
||||
/* pointerfree(atomic) or immutable. */
|
||||
/* Don't use in leak finding mode. */
|
||||
/* Ignored if GC_dont_gc is true. */
|
||||
GC_API void GC_enable_incremental GC_PROTO((void));
|
||||
|
||||
/* Perform some garbage collection work, if appropriate. */
|
||||
/* Return 0 if there is no more work to be done. */
|
||||
/* Typically performs an amount of work corresponding roughly */
|
||||
/* to marking from one page. May do more work if further */
|
||||
/* progress requires it, e.g. if incremental collection is */
|
||||
/* disabled. It is reasonable to call this in a wait loop */
|
||||
/* until it returns 0. */
|
||||
GC_API int GC_collect_a_little GC_PROTO((void));
|
||||
|
||||
/* Allocate an object of size lb bytes. The client guarantees that */
|
||||
/* as long as the object is live, it will be referenced by a pointer */
|
||||
/* that points to somewhere within the first 256 bytes of the object. */
|
||||
/* (This should normally be declared volatile to prevent the compiler */
|
||||
/* from invalidating this assertion.) This routine is only useful */
|
||||
/* if a large array is being allocated. It reduces the chance of */
|
||||
/* accidentally retaining such an array as a result of scanning an */
|
||||
/* integer that happens to be an address inside the array. (Actually, */
|
||||
/* it reduces the chance of the allocator not finding space for such */
|
||||
/* an array, since it will try hard to avoid introducing such a false */
|
||||
/* reference.) On a SunOS 4.X or MS Windows system this is recommended */
|
||||
/* for arrays likely to be larger than 100K or so. For other systems, */
|
||||
/* or if the collector is not configured to recognize all interior */
|
||||
/* pointers, the threshold is normally much higher. */
|
||||
GC_API GC_PTR GC_malloc_ignore_off_page GC_PROTO((size_t lb));
|
||||
GC_API GC_PTR GC_malloc_atomic_ignore_off_page GC_PROTO((size_t lb));
|
||||
|
||||
#if defined(__sgi) && !defined(__GNUC__) && _COMPILER_VERSION >= 720
|
||||
# define GC_ADD_CALLER
|
||||
# define GC_RETURN_ADDR (GC_word)__return_address
|
||||
#endif
|
||||
|
||||
#ifdef GC_ADD_CALLER
|
||||
# define GC_EXTRAS GC_RETURN_ADDR, __FILE__, __LINE__
|
||||
# define GC_EXTRA_PARAMS GC_word ra, GC_CONST char * s, int i
|
||||
#else
|
||||
# define GC_EXTRAS __FILE__, __LINE__
|
||||
# define GC_EXTRA_PARAMS GC_CONST char * s, int i
|
||||
#endif
|
||||
|
||||
/* Debugging (annotated) allocation. GC_gcollect will check */
|
||||
/* objects allocated in this way for overwrites, etc. */
|
||||
GC_API GC_PTR GC_debug_malloc
|
||||
GC_PROTO((size_t size_in_bytes, GC_EXTRA_PARAMS));
|
||||
GC_API GC_PTR GC_debug_malloc_atomic
|
||||
GC_PROTO((size_t size_in_bytes, GC_EXTRA_PARAMS));
|
||||
GC_API GC_PTR GC_debug_malloc_uncollectable
|
||||
GC_PROTO((size_t size_in_bytes, GC_EXTRA_PARAMS));
|
||||
GC_API GC_PTR GC_debug_malloc_stubborn
|
||||
GC_PROTO((size_t size_in_bytes, GC_EXTRA_PARAMS));
|
||||
GC_API void GC_debug_free GC_PROTO((GC_PTR object_addr));
|
||||
GC_API GC_PTR GC_debug_realloc
|
||||
GC_PROTO((GC_PTR old_object, size_t new_size_in_bytes,
|
||||
GC_EXTRA_PARAMS));
|
||||
|
||||
GC_API void GC_debug_change_stubborn GC_PROTO((GC_PTR));
|
||||
GC_API void GC_debug_end_stubborn_change GC_PROTO((GC_PTR));
|
||||
# ifdef GC_DEBUG
|
||||
# define GC_MALLOC(sz) GC_debug_malloc(sz, GC_EXTRAS)
|
||||
# define GC_MALLOC_ATOMIC(sz) GC_debug_malloc_atomic(sz, GC_EXTRAS)
|
||||
# define GC_MALLOC_UNCOLLECTABLE(sz) GC_debug_malloc_uncollectable(sz, \
|
||||
GC_EXTRAS)
|
||||
# define GC_REALLOC(old, sz) GC_debug_realloc(old, sz, GC_EXTRAS)
|
||||
# define GC_FREE(p) GC_debug_free(p)
|
||||
# define GC_REGISTER_FINALIZER(p, f, d, of, od) \
|
||||
GC_debug_register_finalizer(p, f, d, of, od)
|
||||
# define GC_REGISTER_FINALIZER_IGNORE_SELF(p, f, d, of, od) \
|
||||
GC_debug_register_finalizer_ignore_self(p, f, d, of, od)
|
||||
# define GC_REGISTER_FINALIZER_NO_ORDER(p, f, d, of, od) \
|
||||
GC_debug_register_finalizer_no_order(p, f, d, of, od)
|
||||
# define GC_MALLOC_STUBBORN(sz) GC_debug_malloc_stubborn(sz, GC_EXTRAS);
|
||||
# define GC_CHANGE_STUBBORN(p) GC_debug_change_stubborn(p)
|
||||
# define GC_END_STUBBORN_CHANGE(p) GC_debug_end_stubborn_change(p)
|
||||
# define GC_GENERAL_REGISTER_DISAPPEARING_LINK(link, obj) \
|
||||
GC_general_register_disappearing_link(link, GC_base(obj))
|
||||
# define GC_REGISTER_DISPLACEMENT(n) GC_debug_register_displacement(n)
|
||||
# else
|
||||
# define GC_MALLOC(sz) GC_malloc(sz)
|
||||
# define GC_MALLOC_ATOMIC(sz) GC_malloc_atomic(sz)
|
||||
# define GC_MALLOC_UNCOLLECTABLE(sz) GC_malloc_uncollectable(sz)
|
||||
# define GC_REALLOC(old, sz) GC_realloc(old, sz)
|
||||
# define GC_FREE(p) GC_free(p)
|
||||
# define GC_REGISTER_FINALIZER(p, f, d, of, od) \
|
||||
GC_register_finalizer(p, f, d, of, od)
|
||||
# define GC_REGISTER_FINALIZER_IGNORE_SELF(p, f, d, of, od) \
|
||||
GC_register_finalizer_ignore_self(p, f, d, of, od)
|
||||
# define GC_REGISTER_FINALIZER_NO_ORDER(p, f, d, of, od) \
|
||||
GC_register_finalizer_no_order(p, f, d, of, od)
|
||||
# define GC_MALLOC_STUBBORN(sz) GC_malloc_stubborn(sz)
|
||||
# define GC_CHANGE_STUBBORN(p) GC_change_stubborn(p)
|
||||
# define GC_END_STUBBORN_CHANGE(p) GC_end_stubborn_change(p)
|
||||
# define GC_GENERAL_REGISTER_DISAPPEARING_LINK(link, obj) \
|
||||
GC_general_register_disappearing_link(link, obj)
|
||||
# define GC_REGISTER_DISPLACEMENT(n) GC_register_displacement(n)
|
||||
# endif
|
||||
/* The following are included because they are often convenient, and */
|
||||
/* reduce the chance for a misspecifed size argument. But calls may */
|
||||
/* expand to something syntactically incorrect if t is a complicated */
|
||||
/* type expression. */
|
||||
# define GC_NEW(t) (t *)GC_MALLOC(sizeof (t))
|
||||
# define GC_NEW_ATOMIC(t) (t *)GC_MALLOC_ATOMIC(sizeof (t))
|
||||
# define GC_NEW_STUBBORN(t) (t *)GC_MALLOC_STUBBORN(sizeof (t))
|
||||
# define GC_NEW_UNCOLLECTABLE(t) (t *)GC_MALLOC_UNCOLLECTABLE(sizeof (t))
|
||||
|
||||
/* Finalization. Some of these primitives are grossly unsafe. */
|
||||
/* The idea is to make them both cheap, and sufficient to build */
|
||||
/* a safer layer, closer to PCedar finalization. */
|
||||
/* The interface represents my conclusions from a long discussion */
|
||||
/* with Alan Demers, Dan Greene, Carl Hauser, Barry Hayes, */
|
||||
/* Christian Jacobi, and Russ Atkinson. It's not perfect, and */
|
||||
/* probably nobody else agrees with it. Hans-J. Boehm 3/13/92 */
|
||||
typedef void (*GC_finalization_proc)
|
||||
GC_PROTO((GC_PTR obj, GC_PTR client_data));
|
||||
|
||||
GC_API void GC_register_finalizer
|
||||
GC_PROTO((GC_PTR obj, GC_finalization_proc fn, GC_PTR cd,
|
||||
GC_finalization_proc *ofn, GC_PTR *ocd));
|
||||
GC_API void GC_debug_register_finalizer
|
||||
GC_PROTO((GC_PTR obj, GC_finalization_proc fn, GC_PTR cd,
|
||||
GC_finalization_proc *ofn, GC_PTR *ocd));
|
||||
/* When obj is no longer accessible, invoke */
|
||||
/* (*fn)(obj, cd). If a and b are inaccessible, and */
|
||||
/* a points to b (after disappearing links have been */
|
||||
/* made to disappear), then only a will be */
|
||||
/* finalized. (If this does not create any new */
|
||||
/* pointers to b, then b will be finalized after the */
|
||||
/* next collection.) Any finalizable object that */
|
||||
/* is reachable from itself by following one or more */
|
||||
/* pointers will not be finalized (or collected). */
|
||||
/* Thus cycles involving finalizable objects should */
|
||||
/* be avoided, or broken by disappearing links. */
|
||||
/* All but the last finalizer registered for an object */
|
||||
/* is ignored. */
|
||||
/* Finalization may be removed by passing 0 as fn. */
|
||||
/* Finalizers are implicitly unregistered just before */
|
||||
/* they are invoked. */
|
||||
/* The old finalizer and client data are stored in */
|
||||
/* *ofn and *ocd. */
|
||||
/* Fn is never invoked on an accessible object, */
|
||||
/* provided hidden pointers are converted to real */
|
||||
/* pointers only if the allocation lock is held, and */
|
||||
/* such conversions are not performed by finalization */
|
||||
/* routines. */
|
||||
/* If GC_register_finalizer is aborted as a result of */
|
||||
/* a signal, the object may be left with no */
|
||||
/* finalization, even if neither the old nor new */
|
||||
/* finalizer were NULL. */
|
||||
/* Obj should be the nonNULL starting address of an */
|
||||
/* object allocated by GC_malloc or friends. */
|
||||
/* Note that any garbage collectable object referenced */
|
||||
/* by cd will be considered accessible until the */
|
||||
/* finalizer is invoked. */
|
||||
|
||||
/* Another versions of the above follow. It ignores */
|
||||
/* self-cycles, i.e. pointers from a finalizable object to */
|
||||
/* itself. There is a stylistic argument that this is wrong, */
|
||||
/* but it's unavoidable for C++, since the compiler may */
|
||||
/* silently introduce these. It's also benign in that specific */
|
||||
/* case. */
|
||||
GC_API void GC_register_finalizer_ignore_self
|
||||
GC_PROTO((GC_PTR obj, GC_finalization_proc fn, GC_PTR cd,
|
||||
GC_finalization_proc *ofn, GC_PTR *ocd));
|
||||
GC_API void GC_debug_register_finalizer_ignore_self
|
||||
GC_PROTO((GC_PTR obj, GC_finalization_proc fn, GC_PTR cd,
|
||||
GC_finalization_proc *ofn, GC_PTR *ocd));
|
||||
|
||||
/* Another version of the above. It ignores all cycles. */
|
||||
/* It should probably only be used by Java implementations. */
|
||||
GC_API void GC_register_finalizer_no_order
|
||||
GC_PROTO((GC_PTR obj, GC_finalization_proc fn, GC_PTR cd,
|
||||
GC_finalization_proc *ofn, GC_PTR *ocd));
|
||||
GC_API void GC_debug_register_finalizer_no_order
|
||||
GC_PROTO((GC_PTR obj, GC_finalization_proc fn, GC_PTR cd,
|
||||
GC_finalization_proc *ofn, GC_PTR *ocd));
|
||||
|
||||
|
||||
/* The following routine may be used to break cycles between */
|
||||
/* finalizable objects, thus causing cyclic finalizable */
|
||||
/* objects to be finalized in the correct order. Standard */
|
||||
/* use involves calling GC_register_disappearing_link(&p), */
|
||||
/* where p is a pointer that is not followed by finalization */
|
||||
/* code, and should not be considered in determining */
|
||||
/* finalization order. */
|
||||
GC_API int GC_register_disappearing_link GC_PROTO((GC_PTR * /* link */));
|
||||
/* Link should point to a field of a heap allocated */
|
||||
/* object obj. *link will be cleared when obj is */
|
||||
/* found to be inaccessible. This happens BEFORE any */
|
||||
/* finalization code is invoked, and BEFORE any */
|
||||
/* decisions about finalization order are made. */
|
||||
/* This is useful in telling the finalizer that */
|
||||
/* some pointers are not essential for proper */
|
||||
/* finalization. This may avoid finalization cycles. */
|
||||
/* Note that obj may be resurrected by another */
|
||||
/* finalizer, and thus the clearing of *link may */
|
||||
/* be visible to non-finalization code. */
|
||||
/* There's an argument that an arbitrary action should */
|
||||
/* be allowed here, instead of just clearing a pointer. */
|
||||
/* But this causes problems if that action alters, or */
|
||||
/* examines connectivity. */
|
||||
/* Returns 1 if link was already registered, 0 */
|
||||
/* otherwise. */
|
||||
/* Only exists for backward compatibility. See below: */
|
||||
|
||||
GC_API int GC_general_register_disappearing_link
|
||||
GC_PROTO((GC_PTR * /* link */, GC_PTR obj));
|
||||
/* A slight generalization of the above. *link is */
|
||||
/* cleared when obj first becomes inaccessible. This */
|
||||
/* can be used to implement weak pointers easily and */
|
||||
/* safely. Typically link will point to a location */
|
||||
/* holding a disguised pointer to obj. (A pointer */
|
||||
/* inside an "atomic" object is effectively */
|
||||
/* disguised.) In this way soft */
|
||||
/* pointers are broken before any object */
|
||||
/* reachable from them are finalized. Each link */
|
||||
/* May be registered only once, i.e. with one obj */
|
||||
/* value. This was added after a long email discussion */
|
||||
/* with John Ellis. */
|
||||
/* Obj must be a pointer to the first word of an object */
|
||||
/* we allocated. It is unsafe to explicitly deallocate */
|
||||
/* the object containing link. Explicitly deallocating */
|
||||
/* obj may or may not cause link to eventually be */
|
||||
/* cleared. */
|
||||
GC_API int GC_unregister_disappearing_link GC_PROTO((GC_PTR * /* link */));
|
||||
/* Returns 0 if link was not actually registered. */
|
||||
/* Undoes a registration by either of the above two */
|
||||
/* routines. */
|
||||
|
||||
/* Auxiliary fns to make finalization work correctly with displaced */
|
||||
/* pointers introduced by the debugging allocators. */
|
||||
GC_API GC_PTR GC_make_closure GC_PROTO((GC_finalization_proc fn, GC_PTR data));
|
||||
GC_API void GC_debug_invoke_finalizer GC_PROTO((GC_PTR obj, GC_PTR data));
|
||||
|
||||
/* Returns !=0 if GC_invoke_finalizers has something to do. */
|
||||
GC_API int GC_should_invoke_finalizers GC_PROTO((void));
|
||||
|
||||
GC_API int GC_invoke_finalizers GC_PROTO((void));
|
||||
/* Run finalizers for all objects that are ready to */
|
||||
/* be finalized. Return the number of finalizers */
|
||||
/* that were run. Normally this is also called */
|
||||
/* implicitly during some allocations. If */
|
||||
/* GC-finalize_on_demand is nonzero, it must be called */
|
||||
/* explicitly. */
|
||||
|
||||
/* GC_set_warn_proc can be used to redirect or filter warning messages. */
|
||||
/* p may not be a NULL pointer. */
|
||||
typedef void (*GC_warn_proc) GC_PROTO((char *msg, GC_word arg));
|
||||
GC_API GC_warn_proc GC_set_warn_proc GC_PROTO((GC_warn_proc p));
|
||||
/* Returns old warning procedure. */
|
||||
|
||||
/* The following is intended to be used by a higher level */
|
||||
/* (e.g. cedar-like) finalization facility. It is expected */
|
||||
/* that finalization code will arrange for hidden pointers to */
|
||||
/* disappear. Otherwise objects can be accessed after they */
|
||||
/* have been collected. */
|
||||
/* Note that putting pointers in atomic objects or in */
|
||||
/* nonpointer slots of "typed" objects is equivalent to */
|
||||
/* disguising them in this way, and may have other advantages. */
|
||||
# if defined(I_HIDE_POINTERS) || defined(GC_I_HIDE_POINTERS)
|
||||
typedef GC_word GC_hidden_pointer;
|
||||
# define HIDE_POINTER(p) (~(GC_hidden_pointer)(p))
|
||||
# define REVEAL_POINTER(p) ((GC_PTR)(HIDE_POINTER(p)))
|
||||
/* Converting a hidden pointer to a real pointer requires verifying */
|
||||
/* that the object still exists. This involves acquiring the */
|
||||
/* allocator lock to avoid a race with the collector. */
|
||||
# endif /* I_HIDE_POINTERS */
|
||||
|
||||
typedef GC_PTR (*GC_fn_type) GC_PROTO((GC_PTR client_data));
|
||||
GC_API GC_PTR GC_call_with_alloc_lock
|
||||
GC_PROTO((GC_fn_type fn, GC_PTR client_data));
|
||||
|
||||
/* Check that p and q point to the same object. */
|
||||
/* Fail conspicuously if they don't. */
|
||||
/* Returns the first argument. */
|
||||
/* Succeeds if neither p nor q points to the heap. */
|
||||
/* May succeed if both p and q point to between heap objects. */
|
||||
GC_API GC_PTR GC_same_obj GC_PROTO((GC_PTR p, GC_PTR q));
|
||||
|
||||
/* Checked pointer pre- and post- increment operations. Note that */
|
||||
/* the second argument is in units of bytes, not multiples of the */
|
||||
/* object size. This should either be invoked from a macro, or the */
|
||||
/* call should be automatically generated. */
|
||||
GC_API GC_PTR GC_pre_incr GC_PROTO((GC_PTR *p, size_t how_much));
|
||||
GC_API GC_PTR GC_post_incr GC_PROTO((GC_PTR *p, size_t how_much));
|
||||
|
||||
/* Check that p is visible */
|
||||
/* to the collector as a possibly pointer containing location. */
|
||||
/* If it isn't fail conspicuously. */
|
||||
/* Returns the argument in all cases. May erroneously succeed */
|
||||
/* in hard cases. (This is intended for debugging use with */
|
||||
/* untyped allocations. The idea is that it should be possible, though */
|
||||
/* slow, to add such a call to all indirect pointer stores.) */
|
||||
/* Currently useless for multithreaded worlds. */
|
||||
GC_API GC_PTR GC_is_visible GC_PROTO((GC_PTR p));
|
||||
|
||||
/* Check that if p is a pointer to a heap page, then it points to */
|
||||
/* a valid displacement within a heap object. */
|
||||
/* Fail conspicuously if this property does not hold. */
|
||||
/* Uninteresting with ALL_INTERIOR_POINTERS. */
|
||||
/* Always returns its argument. */
|
||||
GC_API GC_PTR GC_is_valid_displacement GC_PROTO((GC_PTR p));
|
||||
|
||||
/* Safer, but slow, pointer addition. Probably useful mainly with */
|
||||
/* a preprocessor. Useful only for heap pointers. */
|
||||
#ifdef GC_DEBUG
|
||||
# define GC_PTR_ADD3(x, n, type_of_result) \
|
||||
((type_of_result)GC_same_obj((x)+(n), (x)))
|
||||
# define GC_PRE_INCR3(x, n, type_of_result) \
|
||||
((type_of_result)GC_pre_incr(&(x), (n)*sizeof(*x))
|
||||
# define GC_POST_INCR2(x, type_of_result) \
|
||||
((type_of_result)GC_post_incr(&(x), sizeof(*x))
|
||||
# ifdef __GNUC__
|
||||
# define GC_PTR_ADD(x, n) \
|
||||
GC_PTR_ADD3(x, n, typeof(x))
|
||||
# define GC_PRE_INCR(x, n) \
|
||||
GC_PRE_INCR3(x, n, typeof(x))
|
||||
# define GC_POST_INCR(x, n) \
|
||||
GC_POST_INCR3(x, typeof(x))
|
||||
# else
|
||||
/* We can't do this right without typeof, which ANSI */
|
||||
/* decided was not sufficiently useful. Repeatedly */
|
||||
/* mentioning the arguments seems too dangerous to be */
|
||||
/* useful. So does not casting the result. */
|
||||
# define GC_PTR_ADD(x, n) ((x)+(n))
|
||||
# endif
|
||||
#else /* !GC_DEBUG */
|
||||
# define GC_PTR_ADD3(x, n, type_of_result) ((x)+(n))
|
||||
# define GC_PTR_ADD(x, n) ((x)+(n))
|
||||
# define GC_PRE_INCR3(x, n, type_of_result) ((x) += (n))
|
||||
# define GC_PRE_INCR(x, n) ((x) += (n))
|
||||
# define GC_POST_INCR2(x, n, type_of_result) ((x)++)
|
||||
# define GC_POST_INCR(x, n) ((x)++)
|
||||
#endif
|
||||
|
||||
/* Safer assignment of a pointer to a nonstack location. */
|
||||
#ifdef GC_DEBUG
|
||||
# ifdef __STDC__
|
||||
# define GC_PTR_STORE(p, q) \
|
||||
(*(void **)GC_is_visible(p) = GC_is_valid_displacement(q))
|
||||
# else
|
||||
# define GC_PTR_STORE(p, q) \
|
||||
(*(char **)GC_is_visible(p) = GC_is_valid_displacement(q))
|
||||
# endif
|
||||
#else /* !GC_DEBUG */
|
||||
# define GC_PTR_STORE(p, q) *((p) = (q))
|
||||
#endif
|
||||
|
||||
/* Fynctions called to report pointer checking errors */
|
||||
GC_API void (*GC_same_obj_print_proc) GC_PROTO((GC_PTR p, GC_PTR q));
|
||||
|
||||
GC_API void (*GC_is_valid_displacement_print_proc)
|
||||
GC_PROTO((GC_PTR p));
|
||||
|
||||
GC_API void (*GC_is_visible_print_proc)
|
||||
GC_PROTO((GC_PTR p));
|
||||
|
||||
#if defined(_SOLARIS_PTHREADS) && !defined(SOLARIS_THREADS)
|
||||
# define SOLARIS_THREADS
|
||||
#endif
|
||||
|
||||
#ifdef SOLARIS_THREADS
|
||||
/* We need to intercept calls to many of the threads primitives, so */
|
||||
/* that we can locate thread stacks and stop the world. */
|
||||
/* Note also that the collector cannot see thread specific data. */
|
||||
/* Thread specific data should generally consist of pointers to */
|
||||
/* uncollectable objects, which are deallocated using the destructor */
|
||||
/* facility in thr_keycreate. */
|
||||
# include <thread.h>
|
||||
# include <signal.h>
|
||||
int GC_thr_create(void *stack_base, size_t stack_size,
|
||||
void *(*start_routine)(void *), void *arg, long flags,
|
||||
thread_t *new_thread);
|
||||
int GC_thr_join(thread_t wait_for, thread_t *departed, void **status);
|
||||
int GC_thr_suspend(thread_t target_thread);
|
||||
int GC_thr_continue(thread_t target_thread);
|
||||
void * GC_dlopen(const char *path, int mode);
|
||||
|
||||
# ifdef _SOLARIS_PTHREADS
|
||||
# include <pthread.h>
|
||||
extern int GC_pthread_create(pthread_t *new_thread,
|
||||
const pthread_attr_t *attr,
|
||||
void * (*thread_execp)(void *), void *arg);
|
||||
extern int GC_pthread_join(pthread_t wait_for, void **status);
|
||||
|
||||
# undef thread_t
|
||||
|
||||
# define pthread_join GC_pthread_join
|
||||
# define pthread_create GC_pthread_create
|
||||
#endif
|
||||
|
||||
# define thr_create GC_thr_create
|
||||
# define thr_join GC_thr_join
|
||||
# define thr_suspend GC_thr_suspend
|
||||
# define thr_continue GC_thr_continue
|
||||
# define dlopen GC_dlopen
|
||||
|
||||
# endif /* SOLARIS_THREADS */
|
||||
|
||||
|
||||
#if !defined(USE_LD_WRAP) && \
|
||||
(defined(IRIX_THREADS) || defined(LINUX_THREADS) || defined(HPUX_THREADS))
|
||||
/* We treat these similarly. */
|
||||
# include <pthread.h>
|
||||
# include <signal.h>
|
||||
|
||||
int GC_pthread_create(pthread_t *new_thread,
|
||||
const pthread_attr_t *attr,
|
||||
void *(*start_routine)(void *), void *arg);
|
||||
int GC_pthread_sigmask(int how, const sigset_t *set, sigset_t *oset);
|
||||
int GC_pthread_join(pthread_t thread, void **retval);
|
||||
|
||||
# define pthread_create GC_pthread_create
|
||||
# define pthread_sigmask GC_pthread_sigmask
|
||||
# define pthread_join GC_pthread_join
|
||||
# define dlopen GC_dlopen
|
||||
|
||||
#endif /* xxxxx_THREADS */
|
||||
|
||||
# if defined(PCR) || defined(SOLARIS_THREADS) || defined(WIN32_THREADS) || \
|
||||
defined(IRIX_THREADS) || defined(LINUX_THREADS) || \
|
||||
defined(IRIX_JDK_THREADS) || defined(HPUX_THREADS)
|
||||
/* Any flavor of threads except SRC_M3. */
|
||||
/* This returns a list of objects, linked through their first */
|
||||
/* word. Its use can greatly reduce lock contention problems, since */
|
||||
/* the allocation lock can be acquired and released many fewer times. */
|
||||
/* lb must be large enough to hold the pointer field. */
|
||||
GC_PTR GC_malloc_many(size_t lb);
|
||||
#define GC_NEXT(p) (*(GC_PTR *)(p)) /* Retrieve the next element */
|
||||
/* in returned list. */
|
||||
extern void GC_thr_init(); /* Needed for Solaris/X86 */
|
||||
|
||||
#endif /* THREADS && !SRC_M3 */
|
||||
|
||||
/*
|
||||
* If you are planning on putting
|
||||
* the collector in a SunOS 5 dynamic library, you need to call GC_INIT()
|
||||
* from the statically loaded program section.
|
||||
* This circumvents a Solaris 2.X (X<=4) linker bug.
|
||||
*/
|
||||
#if defined(sparc) || defined(__sparc)
|
||||
# define GC_INIT() { extern end, etext; \
|
||||
GC_noop(&end, &etext); }
|
||||
#else
|
||||
# if defined(__CYGWIN32__) && defined(GC_USE_DLL)
|
||||
/*
|
||||
* Similarly gnu-win32 DLLs need explicit initialization
|
||||
*/
|
||||
# define GC_INIT() { GC_add_roots(DATASTART, DATAEND); }
|
||||
# else
|
||||
# define GC_INIT()
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if (defined(_MSDOS) || defined(_MSC_VER)) && (_M_IX86 >= 300) \
|
||||
|| defined(_WIN32)
|
||||
/* win32S may not free all resources on process exit. */
|
||||
/* This explicitly deallocates the heap. */
|
||||
GC_API void GC_win32_free_heap ();
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* end of extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /* _GC_H */
|
501
boehm-gc/gc.mak
501
boehm-gc/gc.mak
|
@ -1,5 +1,6 @@
|
|||
# Microsoft Developer Studio Generated NMAKE File, Format Version 4.10
|
||||
# ** DO NOT EDIT **
|
||||
# This has been hand-edited way too many times.
|
||||
# A clean, manually generated makefile would be an improvement.
|
||||
|
||||
# TARGTYPE "Win32 (x86) Application" 0x0101
|
||||
# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
|
||||
|
@ -72,6 +73,8 @@ CLEAN :
|
|||
-@erase ".\Release\finalize.obj"
|
||||
-@erase ".\Release\finalize.sbr"
|
||||
-@erase ".\Release\gc.bsc"
|
||||
-@erase ".\Release\gc_cpp.obj"
|
||||
-@erase ".\Release\gc_cpp.sbr"
|
||||
-@erase ".\Release\gc.dll"
|
||||
-@erase ".\Release\gc.exp"
|
||||
-@erase ".\Release\gc.lib"
|
||||
|
@ -111,8 +114,8 @@ CLEAN :
|
|||
|
||||
CPP=cl.exe
|
||||
# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /c
|
||||
# ADD CPP /nologo /MD /W3 /GX /O2 /D "NDEBUG" /D "SILENT" /D "GC_BUILD" /D "WIN32" /D "_WINDOWS" /D "ALL_INTERIOR_POINTERS" /D "__STDC__" /D "WIN32_THREADS" /FR /YX /c
|
||||
CPP_PROJ=/nologo /MD /W3 /GX /O2 /D "NDEBUG" /D "SILENT" /D "GC_BUILD" /D\
|
||||
# ADD CPP /nologo /MD /W3 /GX /O2 /I include /D "NDEBUG" /D "SILENT" /D "GC_BUILD" /D "WIN32" /D "_WINDOWS" /D "ALL_INTERIOR_POINTERS" /D "__STDC__" /D "WIN32_THREADS" /FR /YX /c
|
||||
CPP_PROJ=/nologo /MD /W3 /GX /O2 /I include /D "NDEBUG" /D "SILENT" /D "GC_BUILD" /D\
|
||||
"WIN32" /D "_WINDOWS" /D "ALL_INTERIOR_POINTERS" /D "__STDC__" /D\
|
||||
"WIN32_THREADS" /FR"$(INTDIR)/" /Fp"$(INTDIR)/gc.pch" /YX /Fo"$(INTDIR)/" /c
|
||||
CPP_OBJS=.\Release/
|
||||
|
@ -155,6 +158,7 @@ BSC32_SBRS= \
|
|||
".\Release\dbg_mlc.sbr" \
|
||||
".\Release\dyn_load.sbr" \
|
||||
".\Release\finalize.sbr" \
|
||||
".\Release\gc_cpp.sbr" \
|
||||
".\Release\headers.sbr" \
|
||||
".\Release\mach_dep.sbr" \
|
||||
".\Release\malloc.sbr" \
|
||||
|
@ -192,6 +196,7 @@ LINK32_OBJS= \
|
|||
".\Release\dbg_mlc.obj" \
|
||||
".\Release\dyn_load.obj" \
|
||||
".\Release\finalize.obj" \
|
||||
".\Release\gc_cpp.obj" \
|
||||
".\Release\headers.obj" \
|
||||
".\Release\mach_dep.obj" \
|
||||
".\Release\malloc.obj" \
|
||||
|
@ -245,6 +250,8 @@ CLEAN :
|
|||
-@erase ".\Debug\dyn_load.sbr"
|
||||
-@erase ".\Debug\finalize.obj"
|
||||
-@erase ".\Debug\finalize.sbr"
|
||||
-@erase ".\Debug\gc_cpp.obj"
|
||||
-@erase ".\Debug\gc_cpp.sbr"
|
||||
-@erase ".\Debug\gc.bsc"
|
||||
-@erase ".\Debug\gc.dll"
|
||||
-@erase ".\Debug\gc.exp"
|
||||
|
@ -289,8 +296,8 @@ CLEAN :
|
|||
|
||||
CPP=cl.exe
|
||||
# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /c
|
||||
# ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /D "_DEBUG" /D "SILENT" /D "GC_BUILD" /D "WIN32" /D "_WINDOWS" /D "ALL_INTERIOR_POINTERS" /D "__STDC__" /D "WIN32_THREADS" /FR /YX /c
|
||||
CPP_PROJ=/nologo /MDd /W3 /Gm /GX /Zi /Od /D "_DEBUG" /D "SILENT" /D "GC_BUILD"\
|
||||
# ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /I include /D "_DEBUG" /D "SILENT" /D "GC_BUILD" /D "WIN32" /D "_WINDOWS" /D "ALL_INTERIOR_POINTERS" /D "__STDC__" /D "WIN32_THREADS" /FR /YX /c
|
||||
CPP_PROJ=/nologo /MDd /W3 /Gm /GX /Zi /Od /I include /D "_DEBUG" /D "SILENT" /D "GC_BUILD"\
|
||||
/D "WIN32" /D "_WINDOWS" /D "ALL_INTERIOR_POINTERS" /D "__STDC__" /D\
|
||||
"WIN32_THREADS" /FR"$(INTDIR)/" /Fp"$(INTDIR)/gc.pch" /YX /Fo"$(INTDIR)/"\
|
||||
/Fd"$(INTDIR)/" /c
|
||||
|
@ -334,6 +341,7 @@ BSC32_SBRS= \
|
|||
".\Debug\dbg_mlc.sbr" \
|
||||
".\Debug\dyn_load.sbr" \
|
||||
".\Debug\finalize.sbr" \
|
||||
".\Debug\gc_cpp.sbr" \
|
||||
".\Debug\headers.sbr" \
|
||||
".\Debug\mach_dep.sbr" \
|
||||
".\Debug\malloc.sbr" \
|
||||
|
@ -371,6 +379,7 @@ LINK32_OBJS= \
|
|||
".\Debug\dbg_mlc.obj" \
|
||||
".\Debug\dyn_load.obj" \
|
||||
".\Debug\finalize.obj" \
|
||||
".\Debug\gc_cpp.obj" \
|
||||
".\Debug\headers.obj" \
|
||||
".\Debug\mach_dep.obj" \
|
||||
".\Debug\malloc.obj" \
|
||||
|
@ -416,10 +425,13 @@ CLEAN :
|
|||
"$(OUTDIR)" :
|
||||
if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
|
||||
|
||||
test.c : tests\test.c
|
||||
copy tests\test.c test.c
|
||||
|
||||
CPP=cl.exe
|
||||
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /c
|
||||
# ADD CPP /nologo /MD /W3 /GX /O2 /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "ALL_INTERIOR_POINTERS" /D "__STDC__" /D "WIN32_THREADS" /YX /c
|
||||
CPP_PROJ=/nologo /MD /W3 /GX /O2 /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D\
|
||||
# ADD CPP /nologo /MD /W3 /GX /O2 /I include /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "ALL_INTERIOR_POINTERS" /D "__STDC__" /D "WIN32_THREADS" /YX /c
|
||||
CPP_PROJ=/nologo /MD /W3 /GX /O2 /I include /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D\
|
||||
"ALL_INTERIOR_POINTERS" /D "__STDC__" /D "WIN32_THREADS"\
|
||||
/Fp"$(INTDIR)/gctest.pch" /YX /Fo"$(INTDIR)/" /c
|
||||
CPP_OBJS=.\gctest\Release/
|
||||
|
@ -505,7 +517,7 @@ CLEAN :
|
|||
CPP=cl.exe
|
||||
# ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /c
|
||||
# ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "ALL_INTERIOR_POINTERS" /D "__STDC__" /D "WIN32_THREADS" /FR /YX /c
|
||||
CPP_PROJ=/nologo /MDd /W3 /Gm /GX /Zi /Od /D "_DEBUG" /D "WIN32" /D "_WINDOWS"\
|
||||
CPP_PROJ=/nologo /MDd /W3 /Gm /GX /Zi /Od /I include /D "_DEBUG" /D "WIN32" /D "_WINDOWS"\
|
||||
/D "ALL_INTERIOR_POINTERS" /D "__STDC__" /D "WIN32_THREADS" /FR"$(INTDIR)/"\
|
||||
/Fp"$(INTDIR)/gctest.pch" /YX /Fo"$(INTDIR)/" /Fd"$(INTDIR)/" /c
|
||||
CPP_OBJS=.\gctest\Debug/
|
||||
|
@ -596,7 +608,7 @@ CLEAN :
|
|||
CPP=cl.exe
|
||||
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /c
|
||||
# ADD CPP /nologo /MD /W3 /GX /O2 /I "." /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "ALL_INTERIOR_POINTERS" /YX /c
|
||||
CPP_PROJ=/nologo /MD /W3 /GX /O2 /I "." /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D\
|
||||
CPP_PROJ=/nologo /MD /W3 /GX /O2 /I "." /I include /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D\
|
||||
"ALL_INTERIOR_POINTERS" /Fp"$(INTDIR)/cord.pch" /YX /Fo"$(INTDIR)/" /c
|
||||
CPP_OBJS=.\cord\Release/
|
||||
CPP_SBRS=.\.
|
||||
|
@ -688,7 +700,7 @@ CLEAN :
|
|||
CPP=cl.exe
|
||||
# ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /c
|
||||
# ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /I "." /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "ALL_INTERIOR_POINTERS" /YX /c
|
||||
CPP_PROJ=/nologo /MDd /W3 /Gm /GX /Zi /Od /I "." /D "_DEBUG" /D "WIN32" /D\
|
||||
CPP_PROJ=/nologo /MDd /W3 /Gm /GX /Zi /Od /I "." /I include /D "_DEBUG" /D "WIN32" /D\
|
||||
"_WINDOWS" /D "ALL_INTERIOR_POINTERS" /Fp"$(INTDIR)/cord.pch" /YX\
|
||||
/Fo"$(INTDIR)/" /Fd"$(INTDIR)/" /c
|
||||
CPP_OBJS=.\cord\Debug/
|
||||
|
@ -763,15 +775,65 @@ LINK32_OBJS= \
|
|||
################################################################################
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\gc_cpp.cpp
|
||||
|
||||
!IF "$(CFG)" == "gc - Win32 Release"
|
||||
|
||||
DEP_CPP_RECLA=\
|
||||
".\include\private\gcconfig.h"\
|
||||
".\include\gc.h"\
|
||||
".\include\private\gc_hdrs.h"\
|
||||
".\include\private\gc_priv.h"\
|
||||
".\include\gc_cpp.h"\
|
||||
{$(INCLUDE)}"\sys\TYPES.H"\
|
||||
|
||||
NODEP_CPP_RECLA=\
|
||||
".\th\PCR_Th.h"\
|
||||
".\th\PCR_ThCrSec.h"\
|
||||
".\th\PCR_ThCtl.h"\
|
||||
|
||||
|
||||
".\Release\gc_cpp.obj" : $(SOURCE) $(DEP_CPP_RECLA) "$(INTDIR)"
|
||||
|
||||
".\Release\gc_cpp.sbr" : $(SOURCE) $(DEP_CPP_RECLA) "$(INTDIR)"
|
||||
|
||||
|
||||
!ELSEIF "$(CFG)" == "gc - Win32 Debug"
|
||||
|
||||
DEP_CPP_RECLA=\
|
||||
".\include\private\gcconfig.h"\
|
||||
".\include\gc.h"\
|
||||
".\include\private\gc_hdrs.h"\
|
||||
".\include\private\gc_priv.h"\
|
||||
".\include\gc_cpp.h"\
|
||||
{$(INCLUDE)}"\sys\TYPES.H"\
|
||||
|
||||
NODEP_CPP_RECLA=\
|
||||
".\th\PCR_Th.h"\
|
||||
".\th\PCR_ThCrSec.h"\
|
||||
".\th\PCR_ThCtl.h"\
|
||||
|
||||
|
||||
".\Debug\gc_cpp.obj" : $(SOURCE) $(DEP_CPP_RECLA) "$(INTDIR)"
|
||||
|
||||
".\Debug\gc_cpp.sbr" : $(SOURCE) $(DEP_CPP_RECLA) "$(INTDIR)"
|
||||
|
||||
|
||||
!ENDIF
|
||||
|
||||
# End Source File
|
||||
################################################################################
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\reclaim.c
|
||||
|
||||
!IF "$(CFG)" == "gc - Win32 Release"
|
||||
|
||||
DEP_CPP_RECLA=\
|
||||
".\gcconfig.h"\
|
||||
".\gc.h"\
|
||||
".\gc_hdrs.h"\
|
||||
".\gc_priv.h"\
|
||||
".\include\private\gcconfig.h"\
|
||||
".\include\gc.h"\
|
||||
".\include\private\gc_hdrs.h"\
|
||||
".\include\private\gc_priv.h"\
|
||||
{$(INCLUDE)}"\sys\TYPES.H"\
|
||||
|
||||
NODEP_CPP_RECLA=\
|
||||
|
@ -788,10 +850,10 @@ NODEP_CPP_RECLA=\
|
|||
!ELSEIF "$(CFG)" == "gc - Win32 Debug"
|
||||
|
||||
DEP_CPP_RECLA=\
|
||||
".\gcconfig.h"\
|
||||
".\gc.h"\
|
||||
".\gc_hdrs.h"\
|
||||
".\gc_priv.h"\
|
||||
".\include\private\gcconfig.h"\
|
||||
".\include\gc.h"\
|
||||
".\include\private\gc_hdrs.h"\
|
||||
".\include\private\gc_priv.h"\
|
||||
{$(INCLUDE)}"\sys\TYPES.H"\
|
||||
|
||||
NODEP_CPP_RECLA=\
|
||||
|
@ -808,6 +870,7 @@ NODEP_CPP_RECLA=\
|
|||
!ENDIF
|
||||
|
||||
# End Source File
|
||||
|
||||
################################################################################
|
||||
# Begin Source File
|
||||
|
||||
|
@ -816,10 +879,10 @@ SOURCE=.\os_dep.c
|
|||
!IF "$(CFG)" == "gc - Win32 Release"
|
||||
|
||||
DEP_CPP_OS_DE=\
|
||||
".\gcconfig.h"\
|
||||
".\gc.h"\
|
||||
".\gc_hdrs.h"\
|
||||
".\gc_priv.h"\
|
||||
".\include\private\gcconfig.h"\
|
||||
".\include\gc.h"\
|
||||
".\include\private\gc_hdrs.h"\
|
||||
".\include\private\gc_priv.h"\
|
||||
{$(INCLUDE)}"\sys\STAT.H"\
|
||||
{$(INCLUDE)}"\sys\TYPES.H"\
|
||||
|
||||
|
@ -840,10 +903,10 @@ NODEP_CPP_OS_DE=\
|
|||
!ELSEIF "$(CFG)" == "gc - Win32 Debug"
|
||||
|
||||
DEP_CPP_OS_DE=\
|
||||
".\gcconfig.h"\
|
||||
".\gc.h"\
|
||||
".\gc_hdrs.h"\
|
||||
".\gc_priv.h"\
|
||||
".\include\private\gcconfig.h"\
|
||||
".\include\gc.h"\
|
||||
".\include\private\gc_hdrs.h"\
|
||||
".\include\private\gc_priv.h"\
|
||||
{$(INCLUDE)}"\sys\STAT.H"\
|
||||
{$(INCLUDE)}"\sys\TYPES.H"\
|
||||
|
||||
|
@ -872,10 +935,10 @@ SOURCE=.\misc.c
|
|||
!IF "$(CFG)" == "gc - Win32 Release"
|
||||
|
||||
DEP_CPP_MISC_=\
|
||||
".\gcconfig.h"\
|
||||
".\gc.h"\
|
||||
".\gc_hdrs.h"\
|
||||
".\gc_priv.h"\
|
||||
".\include\private\gcconfig.h"\
|
||||
".\include\gc.h"\
|
||||
".\include\private\gc_hdrs.h"\
|
||||
".\include\private\gc_priv.h"\
|
||||
{$(INCLUDE)}"\sys\TYPES.H"\
|
||||
|
||||
NODEP_CPP_MISC_=\
|
||||
|
@ -893,10 +956,10 @@ NODEP_CPP_MISC_=\
|
|||
!ELSEIF "$(CFG)" == "gc - Win32 Debug"
|
||||
|
||||
DEP_CPP_MISC_=\
|
||||
".\gcconfig.h"\
|
||||
".\gc.h"\
|
||||
".\gc_hdrs.h"\
|
||||
".\gc_priv.h"\
|
||||
".\include\private\gcconfig.h"\
|
||||
".\include\gc.h"\
|
||||
".\include\private\gc_hdrs.h"\
|
||||
".\include\private\gc_priv.h"\
|
||||
{$(INCLUDE)}"\sys\TYPES.H"\
|
||||
|
||||
NODEP_CPP_MISC_=\
|
||||
|
@ -922,10 +985,10 @@ SOURCE=.\mark_rts.c
|
|||
!IF "$(CFG)" == "gc - Win32 Release"
|
||||
|
||||
DEP_CPP_MARK_=\
|
||||
".\gcconfig.h"\
|
||||
".\gc.h"\
|
||||
".\gc_hdrs.h"\
|
||||
".\gc_priv.h"\
|
||||
".\include\private\gcconfig.h"\
|
||||
".\include\gc.h"\
|
||||
".\include\private\gc_hdrs.h"\
|
||||
".\include\private\gc_priv.h"\
|
||||
{$(INCLUDE)}"\sys\TYPES.H"\
|
||||
|
||||
NODEP_CPP_MARK_=\
|
||||
|
@ -942,10 +1005,10 @@ NODEP_CPP_MARK_=\
|
|||
!ELSEIF "$(CFG)" == "gc - Win32 Debug"
|
||||
|
||||
DEP_CPP_MARK_=\
|
||||
".\gcconfig.h"\
|
||||
".\gc.h"\
|
||||
".\gc_hdrs.h"\
|
||||
".\gc_priv.h"\
|
||||
".\include\private\gcconfig.h"\
|
||||
".\include\gc.h"\
|
||||
".\include\private\gc_hdrs.h"\
|
||||
".\include\private\gc_priv.h"\
|
||||
{$(INCLUDE)}"\sys\TYPES.H"\
|
||||
|
||||
NODEP_CPP_MARK_=\
|
||||
|
@ -970,10 +1033,10 @@ SOURCE=.\mach_dep.c
|
|||
!IF "$(CFG)" == "gc - Win32 Release"
|
||||
|
||||
DEP_CPP_MACH_=\
|
||||
".\gcconfig.h"\
|
||||
".\gc.h"\
|
||||
".\gc_hdrs.h"\
|
||||
".\gc_priv.h"\
|
||||
".\include\private\gcconfig.h"\
|
||||
".\include\gc.h"\
|
||||
".\include\private\gc_hdrs.h"\
|
||||
".\include\private\gc_priv.h"\
|
||||
{$(INCLUDE)}"\sys\TYPES.H"\
|
||||
|
||||
NODEP_CPP_MACH_=\
|
||||
|
@ -990,10 +1053,10 @@ NODEP_CPP_MACH_=\
|
|||
!ELSEIF "$(CFG)" == "gc - Win32 Debug"
|
||||
|
||||
DEP_CPP_MACH_=\
|
||||
".\gcconfig.h"\
|
||||
".\gc.h"\
|
||||
".\gc_hdrs.h"\
|
||||
".\gc_priv.h"\
|
||||
".\include\private\gcconfig.h"\
|
||||
".\include\gc.h"\
|
||||
".\include\private\gc_hdrs.h"\
|
||||
".\include\private\gc_priv.h"\
|
||||
{$(INCLUDE)}"\sys\TYPES.H"\
|
||||
|
||||
NODEP_CPP_MACH_=\
|
||||
|
@ -1018,10 +1081,10 @@ SOURCE=.\headers.c
|
|||
!IF "$(CFG)" == "gc - Win32 Release"
|
||||
|
||||
DEP_CPP_HEADE=\
|
||||
".\gcconfig.h"\
|
||||
".\gc.h"\
|
||||
".\gc_hdrs.h"\
|
||||
".\gc_priv.h"\
|
||||
".\include\private\gcconfig.h"\
|
||||
".\include\gc.h"\
|
||||
".\include\private\gc_hdrs.h"\
|
||||
".\include\private\gc_priv.h"\
|
||||
{$(INCLUDE)}"\sys\TYPES.H"\
|
||||
|
||||
NODEP_CPP_HEADE=\
|
||||
|
@ -1038,10 +1101,10 @@ NODEP_CPP_HEADE=\
|
|||
!ELSEIF "$(CFG)" == "gc - Win32 Debug"
|
||||
|
||||
DEP_CPP_HEADE=\
|
||||
".\gcconfig.h"\
|
||||
".\gc.h"\
|
||||
".\gc_hdrs.h"\
|
||||
".\gc_priv.h"\
|
||||
".\include\private\gcconfig.h"\
|
||||
".\include\gc.h"\
|
||||
".\include\private\gc_hdrs.h"\
|
||||
".\include\private\gc_priv.h"\
|
||||
{$(INCLUDE)}"\sys\TYPES.H"\
|
||||
|
||||
NODEP_CPP_HEADE=\
|
||||
|
@ -1066,10 +1129,10 @@ SOURCE=.\alloc.c
|
|||
!IF "$(CFG)" == "gc - Win32 Release"
|
||||
|
||||
DEP_CPP_ALLOC=\
|
||||
".\gcconfig.h"\
|
||||
".\gc.h"\
|
||||
".\gc_hdrs.h"\
|
||||
".\gc_priv.h"\
|
||||
".\include\private\gcconfig.h"\
|
||||
".\include\gc.h"\
|
||||
".\include\private\gc_hdrs.h"\
|
||||
".\include\private\gc_priv.h"\
|
||||
{$(INCLUDE)}"\sys\TYPES.H"\
|
||||
|
||||
NODEP_CPP_ALLOC=\
|
||||
|
@ -1086,10 +1149,10 @@ NODEP_CPP_ALLOC=\
|
|||
!ELSEIF "$(CFG)" == "gc - Win32 Debug"
|
||||
|
||||
DEP_CPP_ALLOC=\
|
||||
".\gcconfig.h"\
|
||||
".\gc.h"\
|
||||
".\gc_hdrs.h"\
|
||||
".\gc_priv.h"\
|
||||
".\include\private\gcconfig.h"\
|
||||
".\include\gc.h"\
|
||||
".\include\private\gc_hdrs.h"\
|
||||
".\include\private\gc_priv.h"\
|
||||
{$(INCLUDE)}"\sys\TYPES.H"\
|
||||
|
||||
NODEP_CPP_ALLOC=\
|
||||
|
@ -1114,10 +1177,10 @@ SOURCE=.\allchblk.c
|
|||
!IF "$(CFG)" == "gc - Win32 Release"
|
||||
|
||||
DEP_CPP_ALLCH=\
|
||||
".\gcconfig.h"\
|
||||
".\gc.h"\
|
||||
".\gc_hdrs.h"\
|
||||
".\gc_priv.h"\
|
||||
".\include\private\gcconfig.h"\
|
||||
".\include\gc.h"\
|
||||
".\include\private\gc_hdrs.h"\
|
||||
".\include\private\gc_priv.h"\
|
||||
{$(INCLUDE)}"\sys\TYPES.H"\
|
||||
|
||||
NODEP_CPP_ALLCH=\
|
||||
|
@ -1134,10 +1197,10 @@ NODEP_CPP_ALLCH=\
|
|||
!ELSEIF "$(CFG)" == "gc - Win32 Debug"
|
||||
|
||||
DEP_CPP_ALLCH=\
|
||||
".\gcconfig.h"\
|
||||
".\gc.h"\
|
||||
".\gc_hdrs.h"\
|
||||
".\gc_priv.h"\
|
||||
".\include\private\gcconfig.h"\
|
||||
".\include\gc.h"\
|
||||
".\include\private\gc_hdrs.h"\
|
||||
".\include\private\gc_priv.h"\
|
||||
{$(INCLUDE)}"\sys\TYPES.H"\
|
||||
|
||||
NODEP_CPP_ALLCH=\
|
||||
|
@ -1162,10 +1225,10 @@ SOURCE=.\stubborn.c
|
|||
!IF "$(CFG)" == "gc - Win32 Release"
|
||||
|
||||
DEP_CPP_STUBB=\
|
||||
".\gcconfig.h"\
|
||||
".\gc.h"\
|
||||
".\gc_hdrs.h"\
|
||||
".\gc_priv.h"\
|
||||
".\include\private\gcconfig.h"\
|
||||
".\include\gc.h"\
|
||||
".\include\private\gc_hdrs.h"\
|
||||
".\include\private\gc_priv.h"\
|
||||
{$(INCLUDE)}"\sys\TYPES.H"\
|
||||
|
||||
NODEP_CPP_STUBB=\
|
||||
|
@ -1182,10 +1245,10 @@ NODEP_CPP_STUBB=\
|
|||
!ELSEIF "$(CFG)" == "gc - Win32 Debug"
|
||||
|
||||
DEP_CPP_STUBB=\
|
||||
".\gcconfig.h"\
|
||||
".\gc.h"\
|
||||
".\gc_hdrs.h"\
|
||||
".\gc_priv.h"\
|
||||
".\include\private\gcconfig.h"\
|
||||
".\include\gc.h"\
|
||||
".\include\private\gc_hdrs.h"\
|
||||
".\include\private\gc_priv.h"\
|
||||
{$(INCLUDE)}"\sys\TYPES.H"\
|
||||
|
||||
NODEP_CPP_STUBB=\
|
||||
|
@ -1210,10 +1273,10 @@ SOURCE=.\obj_map.c
|
|||
!IF "$(CFG)" == "gc - Win32 Release"
|
||||
|
||||
DEP_CPP_OBJ_M=\
|
||||
".\gcconfig.h"\
|
||||
".\gc.h"\
|
||||
".\gc_hdrs.h"\
|
||||
".\gc_priv.h"\
|
||||
".\include\private\gcconfig.h"\
|
||||
".\include\gc.h"\
|
||||
".\include\private\gc_hdrs.h"\
|
||||
".\include\private\gc_priv.h"\
|
||||
{$(INCLUDE)}"\sys\TYPES.H"\
|
||||
|
||||
NODEP_CPP_OBJ_M=\
|
||||
|
@ -1230,10 +1293,10 @@ NODEP_CPP_OBJ_M=\
|
|||
!ELSEIF "$(CFG)" == "gc - Win32 Debug"
|
||||
|
||||
DEP_CPP_OBJ_M=\
|
||||
".\gcconfig.h"\
|
||||
".\gc.h"\
|
||||
".\gc_hdrs.h"\
|
||||
".\gc_priv.h"\
|
||||
".\include\private\gcconfig.h"\
|
||||
".\include\gc.h"\
|
||||
".\include\private\gc_hdrs.h"\
|
||||
".\include\private\gc_priv.h"\
|
||||
{$(INCLUDE)}"\sys\TYPES.H"\
|
||||
|
||||
NODEP_CPP_OBJ_M=\
|
||||
|
@ -1258,10 +1321,10 @@ SOURCE=.\new_hblk.c
|
|||
!IF "$(CFG)" == "gc - Win32 Release"
|
||||
|
||||
DEP_CPP_NEW_H=\
|
||||
".\gcconfig.h"\
|
||||
".\gc.h"\
|
||||
".\gc_hdrs.h"\
|
||||
".\gc_priv.h"\
|
||||
".\include\private\gcconfig.h"\
|
||||
".\include\gc.h"\
|
||||
".\include\private\gc_hdrs.h"\
|
||||
".\include\private\gc_priv.h"\
|
||||
{$(INCLUDE)}"\sys\TYPES.H"\
|
||||
|
||||
NODEP_CPP_NEW_H=\
|
||||
|
@ -1278,10 +1341,10 @@ NODEP_CPP_NEW_H=\
|
|||
!ELSEIF "$(CFG)" == "gc - Win32 Debug"
|
||||
|
||||
DEP_CPP_NEW_H=\
|
||||
".\gcconfig.h"\
|
||||
".\gc.h"\
|
||||
".\gc_hdrs.h"\
|
||||
".\gc_priv.h"\
|
||||
".\include\private\gcconfig.h"\
|
||||
".\include\gc.h"\
|
||||
".\include\private\gc_hdrs.h"\
|
||||
".\include\private\gc_priv.h"\
|
||||
{$(INCLUDE)}"\sys\TYPES.H"\
|
||||
|
||||
NODEP_CPP_NEW_H=\
|
||||
|
@ -1306,11 +1369,12 @@ SOURCE=.\mark.c
|
|||
!IF "$(CFG)" == "gc - Win32 Release"
|
||||
|
||||
DEP_CPP_MARK_C=\
|
||||
".\gcconfig.h"\
|
||||
".\gc.h"\
|
||||
".\gc_hdrs.h"\
|
||||
".\gc_mark.h"\
|
||||
".\gc_priv.h"\
|
||||
".\include\private\gcconfig.h"\
|
||||
".\include\gc.h"\
|
||||
".\include\private\gc_hdrs.h"\
|
||||
".\include\private\gc_pmark.h"\
|
||||
".\include\gc_mark.h"\
|
||||
".\include\private\gc_priv.h"\
|
||||
{$(INCLUDE)}"\sys\TYPES.H"\
|
||||
|
||||
NODEP_CPP_MARK_C=\
|
||||
|
@ -1327,11 +1391,12 @@ NODEP_CPP_MARK_C=\
|
|||
!ELSEIF "$(CFG)" == "gc - Win32 Debug"
|
||||
|
||||
DEP_CPP_MARK_C=\
|
||||
".\gcconfig.h"\
|
||||
".\gc.h"\
|
||||
".\gc_hdrs.h"\
|
||||
".\gc_mark.h"\
|
||||
".\gc_priv.h"\
|
||||
".\include\private\gcconfig.h"\
|
||||
".\include\gc.h"\
|
||||
".\include\private\gc_hdrs.h"\
|
||||
".\include\private\gc_pmark.h"\
|
||||
".\include\gc_mark.h"\
|
||||
".\include\private\gc_priv.h"\
|
||||
{$(INCLUDE)}"\sys\TYPES.H"\
|
||||
|
||||
NODEP_CPP_MARK_C=\
|
||||
|
@ -1356,10 +1421,10 @@ SOURCE=.\malloc.c
|
|||
!IF "$(CFG)" == "gc - Win32 Release"
|
||||
|
||||
DEP_CPP_MALLO=\
|
||||
".\gcconfig.h"\
|
||||
".\gc.h"\
|
||||
".\gc_hdrs.h"\
|
||||
".\gc_priv.h"\
|
||||
".\include\private\gcconfig.h"\
|
||||
".\include\gc.h"\
|
||||
".\include\private\gc_hdrs.h"\
|
||||
".\include\private\gc_priv.h"\
|
||||
{$(INCLUDE)}"\sys\TYPES.H"\
|
||||
|
||||
NODEP_CPP_MALLO=\
|
||||
|
@ -1376,10 +1441,10 @@ NODEP_CPP_MALLO=\
|
|||
!ELSEIF "$(CFG)" == "gc - Win32 Debug"
|
||||
|
||||
DEP_CPP_MALLO=\
|
||||
".\gcconfig.h"\
|
||||
".\gc.h"\
|
||||
".\gc_hdrs.h"\
|
||||
".\gc_priv.h"\
|
||||
".\include\private\gcconfig.h"\
|
||||
".\include\gc.h"\
|
||||
".\include\private\gc_hdrs.h"\
|
||||
".\include\private\gc_priv.h"\
|
||||
{$(INCLUDE)}"\sys\TYPES.H"\
|
||||
|
||||
NODEP_CPP_MALLO=\
|
||||
|
@ -1404,10 +1469,10 @@ SOURCE=.\mallocx.c
|
|||
!IF "$(CFG)" == "gc - Win32 Release"
|
||||
|
||||
DEP_CPP_MALLX=\
|
||||
".\gcconfig.h"\
|
||||
".\gc.h"\
|
||||
".\gc_hdrs.h"\
|
||||
".\gc_priv.h"\
|
||||
".\include\private\gcconfig.h"\
|
||||
".\include\gc.h"\
|
||||
".\include\private\gc_hdrs.h"\
|
||||
".\include\private\gc_priv.h"\
|
||||
{$(INCLUDE)}"\sys\TYPES.H"\
|
||||
|
||||
NODEP_CPP_MALLX=\
|
||||
|
@ -1424,10 +1489,10 @@ NODEP_CPP_MALLX=\
|
|||
!ELSEIF "$(CFG)" == "gc - Win32 Debug"
|
||||
|
||||
DEP_CPP_MALLX=\
|
||||
".\gcconfig.h"\
|
||||
".\gc.h"\
|
||||
".\gc_hdrs.h"\
|
||||
".\gc_priv.h"\
|
||||
".\include\private\gcconfig.h"\
|
||||
".\include\gc.h"\
|
||||
".\include\private\gc_hdrs.h"\
|
||||
".\include\private\gc_priv.h"\
|
||||
{$(INCLUDE)}"\sys\TYPES.H"\
|
||||
|
||||
NODEP_CPP_MALLX=\
|
||||
|
@ -1452,11 +1517,12 @@ SOURCE=.\finalize.c
|
|||
!IF "$(CFG)" == "gc - Win32 Release"
|
||||
|
||||
DEP_CPP_FINAL=\
|
||||
".\gcconfig.h"\
|
||||
".\gc.h"\
|
||||
".\gc_hdrs.h"\
|
||||
".\gc_mark.h"\
|
||||
".\gc_priv.h"\
|
||||
".\include\private\gcconfig.h"\
|
||||
".\include\gc.h"\
|
||||
".\include\private\gc_hdrs.h"\
|
||||
".\include\private\gc_pmark.h"\
|
||||
".\include\gc_mark.h"\
|
||||
".\include\private\gc_priv.h"\
|
||||
{$(INCLUDE)}"\sys\TYPES.H"\
|
||||
|
||||
NODEP_CPP_FINAL=\
|
||||
|
@ -1473,11 +1539,12 @@ NODEP_CPP_FINAL=\
|
|||
!ELSEIF "$(CFG)" == "gc - Win32 Debug"
|
||||
|
||||
DEP_CPP_FINAL=\
|
||||
".\gcconfig.h"\
|
||||
".\gc.h"\
|
||||
".\gc_hdrs.h"\
|
||||
".\gc_mark.h"\
|
||||
".\gc_priv.h"\
|
||||
".\include\private\gcconfig.h"\
|
||||
".\include\gc.h"\
|
||||
".\include\private\gc_hdrs.h"\
|
||||
".\include\private\gc_pmark.h"\
|
||||
".\include\gc_mark.h"\
|
||||
".\include\private\gc_priv.h"\
|
||||
{$(INCLUDE)}"\sys\TYPES.H"\
|
||||
|
||||
NODEP_CPP_FINAL=\
|
||||
|
@ -1502,10 +1569,10 @@ SOURCE=.\dbg_mlc.c
|
|||
!IF "$(CFG)" == "gc - Win32 Release"
|
||||
|
||||
DEP_CPP_DBG_M=\
|
||||
".\gcconfig.h"\
|
||||
".\gc.h"\
|
||||
".\gc_hdrs.h"\
|
||||
".\gc_priv.h"\
|
||||
".\include\private\gcconfig.h"\
|
||||
".\include\gc.h"\
|
||||
".\include\private\gc_hdrs.h"\
|
||||
".\include\private\gc_priv.h"\
|
||||
{$(INCLUDE)}"\sys\TYPES.H"\
|
||||
|
||||
NODEP_CPP_DBG_M=\
|
||||
|
@ -1522,10 +1589,10 @@ NODEP_CPP_DBG_M=\
|
|||
!ELSEIF "$(CFG)" == "gc - Win32 Debug"
|
||||
|
||||
DEP_CPP_DBG_M=\
|
||||
".\gcconfig.h"\
|
||||
".\gc.h"\
|
||||
".\gc_hdrs.h"\
|
||||
".\gc_priv.h"\
|
||||
".\include\private\gcconfig.h"\
|
||||
".\include\gc.h"\
|
||||
".\include\private\gc_hdrs.h"\
|
||||
".\include\private\gc_priv.h"\
|
||||
{$(INCLUDE)}"\sys\TYPES.H"\
|
||||
|
||||
NODEP_CPP_DBG_M=\
|
||||
|
@ -1550,10 +1617,10 @@ SOURCE=.\blacklst.c
|
|||
!IF "$(CFG)" == "gc - Win32 Release"
|
||||
|
||||
DEP_CPP_BLACK=\
|
||||
".\gcconfig.h"\
|
||||
".\gc.h"\
|
||||
".\gc_hdrs.h"\
|
||||
".\gc_priv.h"\
|
||||
".\include\private\gcconfig.h"\
|
||||
".\include\gc.h"\
|
||||
".\include\private\gc_hdrs.h"\
|
||||
".\include\private\gc_priv.h"\
|
||||
{$(INCLUDE)}"\sys\TYPES.H"\
|
||||
|
||||
NODEP_CPP_BLACK=\
|
||||
|
@ -1570,10 +1637,10 @@ NODEP_CPP_BLACK=\
|
|||
!ELSEIF "$(CFG)" == "gc - Win32 Debug"
|
||||
|
||||
DEP_CPP_BLACK=\
|
||||
".\gcconfig.h"\
|
||||
".\gc.h"\
|
||||
".\gc_hdrs.h"\
|
||||
".\gc_priv.h"\
|
||||
".\include\private\gcconfig.h"\
|
||||
".\include\gc.h"\
|
||||
".\include\private\gc_hdrs.h"\
|
||||
".\include\private\gc_priv.h"\
|
||||
{$(INCLUDE)}"\sys\TYPES.H"\
|
||||
|
||||
NODEP_CPP_BLACK=\
|
||||
|
@ -1598,12 +1665,13 @@ SOURCE=.\typd_mlc.c
|
|||
!IF "$(CFG)" == "gc - Win32 Release"
|
||||
|
||||
DEP_CPP_TYPD_=\
|
||||
".\gcconfig.h"\
|
||||
".\gc.h"\
|
||||
".\gc_hdrs.h"\
|
||||
".\gc_mark.h"\
|
||||
".\gc_priv.h"\
|
||||
".\gc_typed.h"\
|
||||
".\include\private\gcconfig.h"\
|
||||
".\include\gc.h"\
|
||||
".\include\private\gc_hdrs.h"\
|
||||
".\include\private\gc_pmark.h"\
|
||||
".\include\gc_mark.h"\
|
||||
".\include\private\gc_priv.h"\
|
||||
".\include\gc_typed.h"\
|
||||
{$(INCLUDE)}"\sys\TYPES.H"\
|
||||
|
||||
NODEP_CPP_TYPD_=\
|
||||
|
@ -1620,12 +1688,13 @@ NODEP_CPP_TYPD_=\
|
|||
!ELSEIF "$(CFG)" == "gc - Win32 Debug"
|
||||
|
||||
DEP_CPP_TYPD_=\
|
||||
".\gcconfig.h"\
|
||||
".\gc.h"\
|
||||
".\gc_hdrs.h"\
|
||||
".\gc_mark.h"\
|
||||
".\gc_priv.h"\
|
||||
".\gc_typed.h"\
|
||||
".\include\private\gcconfig.h"\
|
||||
".\include\gc.h"\
|
||||
".\include\private\gc_hdrs.h"\
|
||||
".\include\private\gc_pmark.h"\
|
||||
".\include\gc_mark.h"\
|
||||
".\include\private\gc_priv.h"\
|
||||
".\include\gc_typed.h"\
|
||||
{$(INCLUDE)}"\sys\TYPES.H"\
|
||||
|
||||
NODEP_CPP_TYPD_=\
|
||||
|
@ -1650,11 +1719,12 @@ SOURCE=.\ptr_chck.c
|
|||
!IF "$(CFG)" == "gc - Win32 Release"
|
||||
|
||||
DEP_CPP_PTR_C=\
|
||||
".\gcconfig.h"\
|
||||
".\gc.h"\
|
||||
".\gc_hdrs.h"\
|
||||
".\gc_mark.h"\
|
||||
".\gc_priv.h"\
|
||||
".\include\private\gcconfig.h"\
|
||||
".\include\gc.h"\
|
||||
".\include\private\gc_hdrs.h"\
|
||||
".\include\private\gc_pmark.h"\
|
||||
".\include\gc_mark.h"\
|
||||
".\include\private\gc_priv.h"\
|
||||
{$(INCLUDE)}"\sys\TYPES.H"\
|
||||
|
||||
NODEP_CPP_PTR_C=\
|
||||
|
@ -1671,11 +1741,12 @@ NODEP_CPP_PTR_C=\
|
|||
!ELSEIF "$(CFG)" == "gc - Win32 Debug"
|
||||
|
||||
DEP_CPP_PTR_C=\
|
||||
".\gcconfig.h"\
|
||||
".\gc.h"\
|
||||
".\gc_hdrs.h"\
|
||||
".\gc_mark.h"\
|
||||
".\gc_priv.h"\
|
||||
".\include\private\gcconfig.h"\
|
||||
".\include\gc.h"\
|
||||
".\include\private\gc_hdrs.h"\
|
||||
".\include\private\gc_pmark.h"\
|
||||
".\include\gc_mark.h"\
|
||||
".\include\private\gc_priv.h"\
|
||||
{$(INCLUDE)}"\sys\TYPES.H"\
|
||||
|
||||
NODEP_CPP_PTR_C=\
|
||||
|
@ -1700,10 +1771,10 @@ SOURCE=.\dyn_load.c
|
|||
!IF "$(CFG)" == "gc - Win32 Release"
|
||||
|
||||
DEP_CPP_DYN_L=\
|
||||
".\gcconfig.h"\
|
||||
".\gc.h"\
|
||||
".\gc_hdrs.h"\
|
||||
".\gc_priv.h"\
|
||||
".\include\private\gcconfig.h"\
|
||||
".\include\gc.h"\
|
||||
".\include\private\gc_hdrs.h"\
|
||||
".\include\private\gc_priv.h"\
|
||||
{$(INCLUDE)}"\sys\STAT.H"\
|
||||
{$(INCLUDE)}"\sys\TYPES.H"\
|
||||
|
||||
|
@ -1723,10 +1794,10 @@ NODEP_CPP_DYN_L=\
|
|||
!ELSEIF "$(CFG)" == "gc - Win32 Debug"
|
||||
|
||||
DEP_CPP_DYN_L=\
|
||||
".\gcconfig.h"\
|
||||
".\gc.h"\
|
||||
".\gc_hdrs.h"\
|
||||
".\gc_priv.h"\
|
||||
".\include\private\gcconfig.h"\
|
||||
".\include\gc.h"\
|
||||
".\include\private\gc_hdrs.h"\
|
||||
".\include\private\gc_priv.h"\
|
||||
{$(INCLUDE)}"\sys\STAT.H"\
|
||||
{$(INCLUDE)}"\sys\TYPES.H"\
|
||||
|
||||
|
@ -1754,10 +1825,10 @@ SOURCE=.\win32_threads.c
|
|||
!IF "$(CFG)" == "gc - Win32 Release"
|
||||
|
||||
DEP_CPP_WIN32=\
|
||||
".\gcconfig.h"\
|
||||
".\gc.h"\
|
||||
".\gc_hdrs.h"\
|
||||
".\gc_priv.h"\
|
||||
".\include\private\gcconfig.h"\
|
||||
".\include\gc.h"\
|
||||
".\include\private\gc_hdrs.h"\
|
||||
".\include\private\gc_priv.h"\
|
||||
{$(INCLUDE)}"\sys\TYPES.H"\
|
||||
|
||||
NODEP_CPP_WIN32=\
|
||||
|
@ -1774,10 +1845,10 @@ NODEP_CPP_WIN32=\
|
|||
!ELSEIF "$(CFG)" == "gc - Win32 Debug"
|
||||
|
||||
DEP_CPP_WIN32=\
|
||||
".\gcconfig.h"\
|
||||
".\gc.h"\
|
||||
".\gc_hdrs.h"\
|
||||
".\gc_priv.h"\
|
||||
".\include\private\gcconfig.h"\
|
||||
".\include\gc.h"\
|
||||
".\include\private\gc_hdrs.h"\
|
||||
".\include\private\gc_priv.h"\
|
||||
{$(INCLUDE)}"\sys\TYPES.H"\
|
||||
|
||||
NODEP_CPP_WIN32=\
|
||||
|
@ -1802,10 +1873,10 @@ SOURCE=.\checksums.c
|
|||
!IF "$(CFG)" == "gc - Win32 Release"
|
||||
|
||||
DEP_CPP_CHECK=\
|
||||
".\gcconfig.h"\
|
||||
".\gc.h"\
|
||||
".\gc_hdrs.h"\
|
||||
".\gc_priv.h"\
|
||||
".\include\private\gcconfig.h"\
|
||||
".\include\gc.h"\
|
||||
".\include\private\gc_hdrs.h"\
|
||||
".\include\private\gc_priv.h"\
|
||||
{$(INCLUDE)}"\sys\TYPES.H"\
|
||||
|
||||
NODEP_CPP_CHECK=\
|
||||
|
@ -1822,10 +1893,10 @@ NODEP_CPP_CHECK=\
|
|||
!ELSEIF "$(CFG)" == "gc - Win32 Debug"
|
||||
|
||||
DEP_CPP_CHECK=\
|
||||
".\gcconfig.h"\
|
||||
".\gc.h"\
|
||||
".\gc_hdrs.h"\
|
||||
".\gc_priv.h"\
|
||||
".\include\private\gcconfig.h"\
|
||||
".\include\gc.h"\
|
||||
".\include\private\gc_hdrs.h"\
|
||||
".\include\private\gc_priv.h"\
|
||||
{$(INCLUDE)}"\sys\TYPES.H"\
|
||||
|
||||
NODEP_CPP_CHECK=\
|
||||
|
@ -1876,13 +1947,13 @@ NODEP_CPP_CHECK=\
|
|||
################################################################################
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\test.c
|
||||
SOURCE=.\tests\test.c
|
||||
DEP_CPP_TEST_=\
|
||||
".\gcconfig.h"\
|
||||
".\gc.h"\
|
||||
".\gc_hdrs.h"\
|
||||
".\gc_priv.h"\
|
||||
".\gc_typed.h"\
|
||||
".\include\private\gcconfig.h"\
|
||||
".\include\gc.h"\
|
||||
".\include\private\gc_hdrs.h"\
|
||||
".\include\private\gc_priv.h"\
|
||||
".\include\gc_typed.h"\
|
||||
{$(INCLUDE)}"\sys\TYPES.H"\
|
||||
|
||||
NODEP_CPP_TEST_=\
|
||||
|
@ -1944,13 +2015,13 @@ NODEP_CPP_TEST_=\
|
|||
|
||||
SOURCE=.\cord\de_win.c
|
||||
DEP_CPP_DE_WI=\
|
||||
".\cord\cord.h"\
|
||||
".\include\cord.h"\
|
||||
".\cord\de_cmds.h"\
|
||||
".\cord\de_win.h"\
|
||||
".\cord\private\cord_pos.h"\
|
||||
".\include\private\cord_pos.h"\
|
||||
|
||||
NODEP_CPP_DE_WI=\
|
||||
".\cord\gc.h"\
|
||||
".\include\gc.h"\
|
||||
|
||||
|
||||
!IF "$(CFG)" == "cord - Win32 Release"
|
||||
|
@ -1975,13 +2046,13 @@ NODEP_CPP_DE_WI=\
|
|||
|
||||
SOURCE=.\cord\de.c
|
||||
DEP_CPP_DE_C2e=\
|
||||
".\cord\cord.h"\
|
||||
".\include\cord.h"\
|
||||
".\cord\de_cmds.h"\
|
||||
".\cord\de_win.h"\
|
||||
".\cord\private\cord_pos.h"\
|
||||
".\include\private\cord_pos.h"\
|
||||
|
||||
NODEP_CPP_DE_C2e=\
|
||||
".\cord\gc.h"\
|
||||
".\include\gc.h"\
|
||||
|
||||
|
||||
!IF "$(CFG)" == "cord - Win32 Release"
|
||||
|
@ -2006,12 +2077,12 @@ NODEP_CPP_DE_C2e=\
|
|||
|
||||
SOURCE=.\cord\cordxtra.c
|
||||
DEP_CPP_CORDX=\
|
||||
".\cord\cord.h"\
|
||||
".\cord\ec.h"\
|
||||
".\cord\private\cord_pos.h"\
|
||||
".\include\cord.h"\
|
||||
".\include\ec.h"\
|
||||
".\include\private\cord_pos.h"\
|
||||
|
||||
NODEP_CPP_CORDX=\
|
||||
".\cord\gc.h"\
|
||||
".\include\gc.h"\
|
||||
|
||||
|
||||
!IF "$(CFG)" == "cord - Win32 Release"
|
||||
|
@ -2036,11 +2107,11 @@ NODEP_CPP_CORDX=\
|
|||
|
||||
SOURCE=.\cord\cordbscs.c
|
||||
DEP_CPP_CORDB=\
|
||||
".\cord\cord.h"\
|
||||
".\cord\private\cord_pos.h"\
|
||||
".\include\cord.h"\
|
||||
".\include\private\cord_pos.h"\
|
||||
|
||||
NODEP_CPP_CORDB=\
|
||||
".\cord\gc.h"\
|
||||
".\include\gc.h"\
|
||||
|
||||
|
||||
!IF "$(CFG)" == "cord - Win32 Release"
|
||||
|
|
|
@ -1,80 +0,0 @@
|
|||
.TH GC_MALLOC 1L "12 February 1996"
|
||||
.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
|
||||
# define malloc(n) GC_malloc(n)
|
||||
.br
|
||||
... malloc(...) ...
|
||||
.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
|
||||
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
|
||||
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
|
||||
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 (boehm@parc.xerox.com). Some of the code was written by others, most notably Alan Demers.
|
|
@ -1,380 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 1996-1998 by Silicon Graphics. All rights reserved.
|
||||
*
|
||||
* THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED
|
||||
* OR IMPLIED. ANY USE IS AT YOUR OWN RISK.
|
||||
*
|
||||
* Permission is hereby granted to use or copy this program
|
||||
* for any purpose, provided the above notices are retained on all copies.
|
||||
* Permission to modify the code and to distribute modified code is granted,
|
||||
* provided the above notices are retained, and a notice that the code was
|
||||
* modified is included with the above copyright notice.
|
||||
*/
|
||||
|
||||
//
|
||||
// This is a C++ header file that is intended to replace the SGI STL
|
||||
// alloc.h. This assumes SGI STL version < 3.0.
|
||||
//
|
||||
// This assumes the collector has been compiled with -DATOMIC_UNCOLLECTABLE
|
||||
// and -DALL_INTERIOR_POINTERS. We also recommend
|
||||
// -DREDIRECT_MALLOC=GC_uncollectable_malloc.
|
||||
//
|
||||
// Some of this could be faster in the explicit deallocation case. In particular,
|
||||
// we spend too much time clearing objects on the free lists. That could be avoided.
|
||||
//
|
||||
// This uses template classes with static members, and hence does not work
|
||||
// with g++ 2.7.2 and earlier.
|
||||
//
|
||||
|
||||
#include "gc.h"
|
||||
|
||||
#ifndef GC_ALLOC_H
|
||||
|
||||
#define GC_ALLOC_H
|
||||
#define __ALLOC_H // Prevent inclusion of the default version. Ugly.
|
||||
#define __SGI_STL_ALLOC_H
|
||||
#define __SGI_STL_INTERNAL_ALLOC_H
|
||||
|
||||
#ifndef __ALLOC
|
||||
# define __ALLOC alloc
|
||||
#endif
|
||||
|
||||
#include <stddef.h>
|
||||
#include <string.h>
|
||||
|
||||
// The following is just replicated from the conventional SGI alloc.h:
|
||||
|
||||
template<class T, class alloc>
|
||||
class simple_alloc {
|
||||
|
||||
public:
|
||||
static T *allocate(size_t n)
|
||||
{ return 0 == n? 0 : (T*) alloc::allocate(n * sizeof (T)); }
|
||||
static T *allocate(void)
|
||||
{ return (T*) alloc::allocate(sizeof (T)); }
|
||||
static void deallocate(T *p, size_t n)
|
||||
{ if (0 != n) alloc::deallocate(p, n * sizeof (T)); }
|
||||
static void deallocate(T *p)
|
||||
{ alloc::deallocate(p, sizeof (T)); }
|
||||
};
|
||||
|
||||
#include "gc.h"
|
||||
|
||||
// The following need to match collector data structures.
|
||||
// We can't include gc_priv.h, since that pulls in way too much stuff.
|
||||
// This should eventually be factored out into another include file.
|
||||
|
||||
extern "C" {
|
||||
extern void ** const GC_objfreelist_ptr;
|
||||
extern void ** const GC_aobjfreelist_ptr;
|
||||
extern void ** const GC_uobjfreelist_ptr;
|
||||
extern void ** const GC_auobjfreelist_ptr;
|
||||
|
||||
extern void GC_incr_words_allocd(size_t words);
|
||||
extern void GC_incr_mem_freed(size_t words);
|
||||
|
||||
extern char * GC_generic_malloc_words_small(size_t word, int kind);
|
||||
}
|
||||
|
||||
// Object kinds; must match PTRFREE, NORMAL, UNCOLLECTABLE, and
|
||||
// AUNCOLLECTABLE in gc_priv.h.
|
||||
|
||||
enum { GC_PTRFREE = 0, GC_NORMAL = 1, GC_UNCOLLECTABLE = 2,
|
||||
GC_AUNCOLLECTABLE = 3 };
|
||||
|
||||
enum { GC_max_fast_bytes = 255 };
|
||||
|
||||
enum { GC_bytes_per_word = sizeof(char *) };
|
||||
|
||||
enum { GC_byte_alignment = 8 };
|
||||
|
||||
enum { GC_word_alignment = GC_byte_alignment/GC_bytes_per_word };
|
||||
|
||||
inline void * &GC_obj_link(void * p)
|
||||
{ return *(void **)p; }
|
||||
|
||||
// Compute a number of words >= n+1 bytes.
|
||||
// The +1 allows for pointers one past the end.
|
||||
inline size_t GC_round_up(size_t n)
|
||||
{
|
||||
return ((n + GC_byte_alignment)/GC_byte_alignment)*GC_word_alignment;
|
||||
}
|
||||
|
||||
// The same but don't allow for extra byte.
|
||||
inline size_t GC_round_up_uncollectable(size_t n)
|
||||
{
|
||||
return ((n + GC_byte_alignment - 1)/GC_byte_alignment)*GC_word_alignment;
|
||||
}
|
||||
|
||||
template <int dummy>
|
||||
class GC_aux_template {
|
||||
public:
|
||||
// File local count of allocated words. Occasionally this is
|
||||
// added into the global count. A separate count is necessary since the
|
||||
// real one must be updated with a procedure call.
|
||||
static size_t GC_words_recently_allocd;
|
||||
|
||||
// Same for uncollectable mmory. Not yet reflected in either
|
||||
// GC_words_recently_allocd or GC_non_gc_bytes.
|
||||
static size_t GC_uncollectable_words_recently_allocd;
|
||||
|
||||
// Similar counter for explicitly deallocated memory.
|
||||
static size_t GC_mem_recently_freed;
|
||||
|
||||
// Again for uncollectable memory.
|
||||
static size_t GC_uncollectable_mem_recently_freed;
|
||||
|
||||
static void * GC_out_of_line_malloc(size_t nwords, int kind);
|
||||
};
|
||||
|
||||
template <int dummy>
|
||||
size_t GC_aux_template<dummy>::GC_words_recently_allocd = 0;
|
||||
|
||||
template <int dummy>
|
||||
size_t GC_aux_template<dummy>::GC_uncollectable_words_recently_allocd = 0;
|
||||
|
||||
template <int dummy>
|
||||
size_t GC_aux_template<dummy>::GC_mem_recently_freed = 0;
|
||||
|
||||
template <int dummy>
|
||||
size_t GC_aux_template<dummy>::GC_uncollectable_mem_recently_freed = 0;
|
||||
|
||||
template <int dummy>
|
||||
void * GC_aux_template<dummy>::GC_out_of_line_malloc(size_t nwords, int kind)
|
||||
{
|
||||
GC_words_recently_allocd += GC_uncollectable_words_recently_allocd;
|
||||
GC_non_gc_bytes +=
|
||||
GC_bytes_per_word * GC_uncollectable_words_recently_allocd;
|
||||
GC_uncollectable_words_recently_allocd = 0;
|
||||
|
||||
GC_mem_recently_freed += GC_uncollectable_mem_recently_freed;
|
||||
GC_non_gc_bytes -=
|
||||
GC_bytes_per_word * GC_uncollectable_mem_recently_freed;
|
||||
GC_uncollectable_mem_recently_freed = 0;
|
||||
|
||||
GC_incr_words_allocd(GC_words_recently_allocd);
|
||||
GC_words_recently_allocd = 0;
|
||||
|
||||
GC_incr_mem_freed(GC_mem_recently_freed);
|
||||
GC_mem_recently_freed = 0;
|
||||
|
||||
return GC_generic_malloc_words_small(nwords, kind);
|
||||
}
|
||||
|
||||
typedef GC_aux_template<0> GC_aux;
|
||||
|
||||
// A fast, single-threaded, garbage-collected allocator
|
||||
// We assume the first word will be immediately overwritten.
|
||||
// In this version, deallocation is not a noop, and explicit
|
||||
// deallocation is likely to help performance.
|
||||
template <int dummy>
|
||||
class single_client_gc_alloc_template {
|
||||
public:
|
||||
static void * allocate(size_t n)
|
||||
{
|
||||
size_t nwords = GC_round_up(n);
|
||||
void ** flh;
|
||||
void * op;
|
||||
|
||||
if (n > GC_max_fast_bytes) return GC_malloc(n);
|
||||
flh = GC_objfreelist_ptr + nwords;
|
||||
if (0 == (op = *flh)) {
|
||||
return GC_aux::GC_out_of_line_malloc(nwords, GC_NORMAL);
|
||||
}
|
||||
*flh = GC_obj_link(op);
|
||||
GC_aux::GC_words_recently_allocd += nwords;
|
||||
return op;
|
||||
}
|
||||
static void * ptr_free_allocate(size_t n)
|
||||
{
|
||||
size_t nwords = GC_round_up(n);
|
||||
void ** flh;
|
||||
void * op;
|
||||
|
||||
if (n > GC_max_fast_bytes) return GC_malloc_atomic(n);
|
||||
flh = GC_aobjfreelist_ptr + nwords;
|
||||
if (0 == (op = *flh)) {
|
||||
return GC_aux::GC_out_of_line_malloc(nwords, GC_PTRFREE);
|
||||
}
|
||||
*flh = GC_obj_link(op);
|
||||
GC_aux::GC_words_recently_allocd += nwords;
|
||||
return op;
|
||||
}
|
||||
static void deallocate(void *p, size_t n)
|
||||
{
|
||||
size_t nwords = GC_round_up(n);
|
||||
void ** flh;
|
||||
|
||||
if (n > GC_max_fast_bytes) {
|
||||
GC_free(p);
|
||||
} else {
|
||||
flh = GC_objfreelist_ptr + nwords;
|
||||
GC_obj_link(p) = *flh;
|
||||
memset((char *)p + GC_bytes_per_word, 0,
|
||||
GC_bytes_per_word * (nwords - 1));
|
||||
*flh = p;
|
||||
GC_aux::GC_mem_recently_freed += nwords;
|
||||
}
|
||||
}
|
||||
static void ptr_free_deallocate(void *p, size_t n)
|
||||
{
|
||||
size_t nwords = GC_round_up(n);
|
||||
void ** flh;
|
||||
|
||||
if (n > GC_max_fast_bytes) {
|
||||
GC_free(p);
|
||||
} else {
|
||||
flh = GC_aobjfreelist_ptr + nwords;
|
||||
GC_obj_link(p) = *flh;
|
||||
*flh = p;
|
||||
GC_aux::GC_mem_recently_freed += nwords;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
typedef single_client_gc_alloc_template<0> single_client_gc_alloc;
|
||||
|
||||
// Once more, for uncollectable objects.
|
||||
template <int dummy>
|
||||
class single_client_alloc_template {
|
||||
public:
|
||||
static void * allocate(size_t n)
|
||||
{
|
||||
size_t nwords = GC_round_up_uncollectable(n);
|
||||
void ** flh;
|
||||
void * op;
|
||||
|
||||
if (n > GC_max_fast_bytes) return GC_malloc_uncollectable(n);
|
||||
flh = GC_uobjfreelist_ptr + nwords;
|
||||
if (0 == (op = *flh)) {
|
||||
return GC_aux::GC_out_of_line_malloc(nwords, GC_UNCOLLECTABLE);
|
||||
}
|
||||
*flh = GC_obj_link(op);
|
||||
GC_aux::GC_uncollectable_words_recently_allocd += nwords;
|
||||
return op;
|
||||
}
|
||||
static void * ptr_free_allocate(size_t n)
|
||||
{
|
||||
size_t nwords = GC_round_up_uncollectable(n);
|
||||
void ** flh;
|
||||
void * op;
|
||||
|
||||
if (n > GC_max_fast_bytes) return GC_malloc_atomic_uncollectable(n);
|
||||
flh = GC_auobjfreelist_ptr + nwords;
|
||||
if (0 == (op = *flh)) {
|
||||
return GC_aux::GC_out_of_line_malloc(nwords, GC_AUNCOLLECTABLE);
|
||||
}
|
||||
*flh = GC_obj_link(op);
|
||||
GC_aux::GC_uncollectable_words_recently_allocd += nwords;
|
||||
return op;
|
||||
}
|
||||
static void deallocate(void *p, size_t n)
|
||||
{
|
||||
size_t nwords = GC_round_up_uncollectable(n);
|
||||
void ** flh;
|
||||
|
||||
if (n > GC_max_fast_bytes) {
|
||||
GC_free(p);
|
||||
} else {
|
||||
flh = GC_uobjfreelist_ptr + nwords;
|
||||
GC_obj_link(p) = *flh;
|
||||
*flh = p;
|
||||
GC_aux::GC_uncollectable_mem_recently_freed += nwords;
|
||||
}
|
||||
}
|
||||
static void ptr_free_deallocate(void *p, size_t n)
|
||||
{
|
||||
size_t nwords = GC_round_up_uncollectable(n);
|
||||
void ** flh;
|
||||
|
||||
if (n > GC_max_fast_bytes) {
|
||||
GC_free(p);
|
||||
} else {
|
||||
flh = GC_auobjfreelist_ptr + nwords;
|
||||
GC_obj_link(p) = *flh;
|
||||
*flh = p;
|
||||
GC_aux::GC_uncollectable_mem_recently_freed += nwords;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
typedef single_client_alloc_template<0> single_client_alloc;
|
||||
|
||||
template < int dummy >
|
||||
class gc_alloc_template {
|
||||
public:
|
||||
static void * allocate(size_t n) { return GC_malloc(n); }
|
||||
static void * ptr_free_allocate(size_t n)
|
||||
{ return GC_malloc_atomic(n); }
|
||||
static void deallocate(void *, size_t) { }
|
||||
static void ptr_free_deallocate(void *, size_t) { }
|
||||
};
|
||||
|
||||
typedef gc_alloc_template < 0 > gc_alloc;
|
||||
|
||||
template < int dummy >
|
||||
class alloc_template {
|
||||
public:
|
||||
static void * allocate(size_t n) { return GC_malloc_uncollectable(n); }
|
||||
static void * ptr_free_allocate(size_t n)
|
||||
{ return GC_malloc_atomic_uncollectable(n); }
|
||||
static void deallocate(void *p, size_t) { GC_free(p); }
|
||||
static void ptr_free_deallocate(void *p, size_t) { GC_free(p); }
|
||||
};
|
||||
|
||||
typedef alloc_template < 0 > alloc;
|
||||
|
||||
#ifdef _SGI_SOURCE
|
||||
|
||||
// We want to specialize simple_alloc so that it does the right thing
|
||||
// for all pointerfree types. At the moment there is no portable way to
|
||||
// even approximate that. The following approximation should work for
|
||||
// SGI compilers, and perhaps some others.
|
||||
|
||||
# define __GC_SPECIALIZE(T,alloc) \
|
||||
class simple_alloc<T, alloc> { \
|
||||
public: \
|
||||
static T *allocate(size_t n) \
|
||||
{ return 0 == n? 0 : \
|
||||
(T*) alloc::ptr_free_allocate(n * sizeof (T)); } \
|
||||
static T *allocate(void) \
|
||||
{ return (T*) alloc::ptr_free_allocate(sizeof (T)); } \
|
||||
static void deallocate(T *p, size_t n) \
|
||||
{ if (0 != n) alloc::ptr_free_deallocate(p, n * sizeof (T)); } \
|
||||
static void deallocate(T *p) \
|
||||
{ alloc::ptr_free_deallocate(p, sizeof (T)); } \
|
||||
};
|
||||
|
||||
__GC_SPECIALIZE(char, gc_alloc)
|
||||
__GC_SPECIALIZE(int, gc_alloc)
|
||||
__GC_SPECIALIZE(unsigned, gc_alloc)
|
||||
__GC_SPECIALIZE(float, gc_alloc)
|
||||
__GC_SPECIALIZE(double, gc_alloc)
|
||||
|
||||
__GC_SPECIALIZE(char, alloc)
|
||||
__GC_SPECIALIZE(int, alloc)
|
||||
__GC_SPECIALIZE(unsigned, alloc)
|
||||
__GC_SPECIALIZE(float, alloc)
|
||||
__GC_SPECIALIZE(double, alloc)
|
||||
|
||||
__GC_SPECIALIZE(char, single_client_gc_alloc)
|
||||
__GC_SPECIALIZE(int, single_client_gc_alloc)
|
||||
__GC_SPECIALIZE(unsigned, single_client_gc_alloc)
|
||||
__GC_SPECIALIZE(float, single_client_gc_alloc)
|
||||
__GC_SPECIALIZE(double, single_client_gc_alloc)
|
||||
|
||||
__GC_SPECIALIZE(char, single_client_alloc)
|
||||
__GC_SPECIALIZE(int, single_client_alloc)
|
||||
__GC_SPECIALIZE(unsigned, single_client_alloc)
|
||||
__GC_SPECIALIZE(float, single_client_alloc)
|
||||
__GC_SPECIALIZE(double, single_client_alloc)
|
||||
|
||||
#ifdef __STL_USE_STD_ALLOCATORS
|
||||
|
||||
???copy stuff from stl_alloc.h or remove it to a different file ???
|
||||
|
||||
#endif /* __STL_USE_STD_ALLOCATORS */
|
||||
|
||||
#endif /* _SGI_SOURCE */
|
||||
|
||||
#endif /* GC_ALLOC_H */
|
|
@ -26,27 +26,14 @@ Authors: John R. Ellis and Jesse Hull
|
|||
|
||||
#include "gc_cpp.h"
|
||||
|
||||
#ifndef _MSC_VER
|
||||
/* In the Visual C++ case, we moved this into the header. */
|
||||
void* operator new( size_t size ) {
|
||||
return GC_MALLOC_UNCOLLECTABLE( size );}
|
||||
|
||||
void operator delete( void* obj ) {
|
||||
GC_FREE( obj );}
|
||||
|
||||
#ifdef _MSC_VER
|
||||
// This new operator is used by VC++ in case of Debug builds !
|
||||
void* operator new( size_t size,
|
||||
int ,//nBlockUse,
|
||||
const char * szFileName,
|
||||
int nLine
|
||||
) {
|
||||
# ifndef GC_DEBUG
|
||||
return GC_malloc_uncollectable( size );
|
||||
# else
|
||||
return GC_debug_malloc_uncollectable(size, szFileName, nLine);
|
||||
# endif
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef OPERATOR_NEW_ARRAY
|
||||
|
||||
void* operator new[]( size_t size ) {
|
||||
|
@ -57,4 +44,6 @@ void operator delete[]( void* obj ) {
|
|||
|
||||
#endif /* OPERATOR_NEW_ARRAY */
|
||||
|
||||
#endif /* _MSC_VER */
|
||||
|
||||
|
||||
|
|
|
@ -1,299 +0,0 @@
|
|||
#ifndef GC_CPP_H
|
||||
#define GC_CPP_H
|
||||
/****************************************************************************
|
||||
Copyright (c) 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.
|
||||
****************************************************************************
|
||||
|
||||
C++ Interface to the Boehm Collector
|
||||
|
||||
John R. Ellis and Jesse Hull
|
||||
|
||||
This interface provides access to the Boehm collector. It provides
|
||||
basic facilities similar to those described in "Safe, Efficient
|
||||
Garbage Collection for C++", by John R. Elis and David L. Detlefs
|
||||
(ftp://ftp.parc.xerox.com/pub/ellis/gc).
|
||||
|
||||
All heap-allocated objects are either "collectable" or
|
||||
"uncollectable". Programs must explicitly delete uncollectable
|
||||
objects, whereas the garbage collector will automatically delete
|
||||
collectable objects when it discovers them to be inaccessible.
|
||||
Collectable objects may freely point at uncollectable objects and vice
|
||||
versa.
|
||||
|
||||
Objects allocated with the built-in "::operator new" are uncollectable.
|
||||
|
||||
Objects derived from class "gc" are collectable. For example:
|
||||
|
||||
class A: public gc {...};
|
||||
A* a = new A; // a is collectable.
|
||||
|
||||
Collectable instances of non-class types can be allocated using the GC
|
||||
(or UseGC) placement:
|
||||
|
||||
typedef int A[ 10 ];
|
||||
A* a = new (GC) A;
|
||||
|
||||
Uncollectable instances of classes derived from "gc" can be allocated
|
||||
using the NoGC placement:
|
||||
|
||||
class A: public gc {...};
|
||||
A* a = new (NoGC) A; // a is uncollectable.
|
||||
|
||||
Both uncollectable and collectable objects can be explicitly deleted
|
||||
with "delete", which invokes an object's destructors and frees its
|
||||
storage immediately.
|
||||
|
||||
A collectable object may have a clean-up function, which will be
|
||||
invoked when the collector discovers the object to be inaccessible.
|
||||
An object derived from "gc_cleanup" or containing a member derived
|
||||
from "gc_cleanup" has a default clean-up function that invokes the
|
||||
object's destructors. Explicit clean-up functions may be specified as
|
||||
an additional placement argument:
|
||||
|
||||
A* a = ::new (GC, MyCleanup) A;
|
||||
|
||||
An object is considered "accessible" by the collector if it can be
|
||||
reached by a path of pointers from static variables, automatic
|
||||
variables of active functions, or from some object with clean-up
|
||||
enabled; pointers from an object to itself are ignored.
|
||||
|
||||
Thus, if objects A and B both have clean-up functions, and A points at
|
||||
B, B is considered accessible. After A's clean-up is invoked and its
|
||||
storage released, B will then become inaccessible and will have its
|
||||
clean-up invoked. If A points at B and B points to A, forming a
|
||||
cycle, then that's considered a storage leak, and neither will be
|
||||
collectable. See the interface gc.h for low-level facilities for
|
||||
handling such cycles of objects with clean-up.
|
||||
|
||||
The collector cannot guarrantee that it will find all inaccessible
|
||||
objects. In practice, it finds almost all of them.
|
||||
|
||||
|
||||
Cautions:
|
||||
|
||||
1. Be sure the collector has been augmented with "make c++".
|
||||
|
||||
2. If your compiler supports the new "operator new[]" syntax, then
|
||||
add -DOPERATOR_NEW_ARRAY to the Makefile.
|
||||
|
||||
If your compiler doesn't support "operator new[]", beware that an
|
||||
array of type T, where T is derived from "gc", may or may not be
|
||||
allocated as a collectable object (it depends on the compiler). Use
|
||||
the explicit GC placement to make the array collectable. For example:
|
||||
|
||||
class A: public gc {...};
|
||||
A* a1 = new A[ 10 ]; // collectable or uncollectable?
|
||||
A* a2 = new (GC) A[ 10 ]; // collectable
|
||||
|
||||
3. The destructors of collectable arrays of objects derived from
|
||||
"gc_cleanup" will not be invoked properly. For example:
|
||||
|
||||
class A: public gc_cleanup {...};
|
||||
A* a = new (GC) A[ 10 ]; // destructors not invoked correctly
|
||||
|
||||
Typically, only the destructor for the first element of the array will
|
||||
be invoked when the array is garbage-collected. To get all the
|
||||
destructors of any array executed, you must supply an explicit
|
||||
clean-up function:
|
||||
|
||||
A* a = new (GC, MyCleanUp) A[ 10 ];
|
||||
|
||||
(Implementing clean-up of arrays correctly, portably, and in a way
|
||||
that preserves the correct exception semantics requires a language
|
||||
extension, e.g. the "gc" keyword.)
|
||||
|
||||
4. Compiler bugs:
|
||||
|
||||
* Solaris 2's CC (SC3.0) doesn't implement t->~T() correctly, so the
|
||||
destructors of classes derived from gc_cleanup won't be invoked.
|
||||
You'll have to explicitly register a clean-up function with
|
||||
new-placement syntax.
|
||||
|
||||
* Evidently cfront 3.0 does not allow destructors to be explicitly
|
||||
invoked using the ANSI-conforming syntax t->~T(). If you're using
|
||||
cfront 3.0, you'll have to comment out the class gc_cleanup, which
|
||||
uses explicit invocation.
|
||||
|
||||
5. GC name conflicts:
|
||||
|
||||
Many other systems seem to use the identifier "GC" as an abbreviation
|
||||
for "Graphics Context". Since version 5.0, GC placement has been replaced
|
||||
by UseGC. GC is an alias for UseGC, unless GC_NAME_CONFLICT is defined.
|
||||
|
||||
****************************************************************************/
|
||||
|
||||
#include "gc.h"
|
||||
|
||||
#ifndef THINK_CPLUS
|
||||
#define _cdecl
|
||||
#endif
|
||||
|
||||
#if ! defined( OPERATOR_NEW_ARRAY ) \
|
||||
&& (__BORLANDC__ >= 0x450 || (__GNUC__ >= 2 && __GNUC_MINOR__ >= 6) \
|
||||
|| __WATCOMC__ >= 1050)
|
||||
# define OPERATOR_NEW_ARRAY
|
||||
#endif
|
||||
|
||||
enum GCPlacement {UseGC,
|
||||
#ifndef GC_NAME_CONFLICT
|
||||
GC=UseGC,
|
||||
#endif
|
||||
NoGC, PointerFreeGC};
|
||||
|
||||
class gc {public:
|
||||
inline void* operator new( size_t size );
|
||||
inline void* operator new( size_t size, GCPlacement gcp );
|
||||
inline void operator delete( void* obj );
|
||||
|
||||
#ifdef OPERATOR_NEW_ARRAY
|
||||
inline void* operator new[]( size_t size );
|
||||
inline void* operator new[]( size_t size, GCPlacement gcp );
|
||||
inline void operator delete[]( void* obj );
|
||||
#endif /* OPERATOR_NEW_ARRAY */
|
||||
};
|
||||
/*
|
||||
Instances of classes derived from "gc" will be allocated in the
|
||||
collected heap by default, unless an explicit NoGC placement is
|
||||
specified. */
|
||||
|
||||
class gc_cleanup: virtual public gc {public:
|
||||
inline gc_cleanup();
|
||||
inline virtual ~gc_cleanup();
|
||||
private:
|
||||
inline static void _cdecl cleanup( void* obj, void* clientData );};
|
||||
/*
|
||||
Instances of classes derived from "gc_cleanup" will be allocated
|
||||
in the collected heap by default. When the collector discovers an
|
||||
inaccessible object derived from "gc_cleanup" or containing a
|
||||
member derived from "gc_cleanup", its destructors will be
|
||||
invoked. */
|
||||
|
||||
extern "C" {typedef void (*GCCleanUpFunc)( void* obj, void* clientData );}
|
||||
|
||||
inline void* operator new(
|
||||
size_t size,
|
||||
GCPlacement gcp,
|
||||
GCCleanUpFunc cleanup = 0,
|
||||
void* clientData = 0 );
|
||||
/*
|
||||
Allocates a collectable or uncollected object, according to the
|
||||
value of "gcp".
|
||||
|
||||
For collectable objects, if "cleanup" is non-null, then when the
|
||||
allocated object "obj" becomes inaccessible, the collector will
|
||||
invoke the function "cleanup( obj, clientData )" but will not
|
||||
invoke the object's destructors. It is an error to explicitly
|
||||
delete an object allocated with a non-null "cleanup".
|
||||
|
||||
It is an error to specify a non-null "cleanup" with NoGC or for
|
||||
classes derived from "gc_cleanup" or containing members derived
|
||||
from "gc_cleanup". */
|
||||
|
||||
#ifdef OPERATOR_NEW_ARRAY
|
||||
|
||||
inline void* operator new[](
|
||||
size_t size,
|
||||
GCPlacement gcp,
|
||||
GCCleanUpFunc cleanup = 0,
|
||||
void* clientData = 0 );
|
||||
/*
|
||||
The operator new for arrays, identical to the above. */
|
||||
|
||||
#endif /* OPERATOR_NEW_ARRAY */
|
||||
|
||||
/****************************************************************************
|
||||
|
||||
Inline implementation
|
||||
|
||||
****************************************************************************/
|
||||
|
||||
inline void* gc::operator new( size_t size ) {
|
||||
return GC_MALLOC( size );}
|
||||
|
||||
inline void* gc::operator new( size_t size, GCPlacement gcp ) {
|
||||
if (gcp == UseGC)
|
||||
return GC_MALLOC( size );
|
||||
else if (gcp == PointerFreeGC)
|
||||
return GC_MALLOC_ATOMIC( size );
|
||||
else
|
||||
return GC_MALLOC_UNCOLLECTABLE( size );}
|
||||
|
||||
inline void gc::operator delete( void* obj ) {
|
||||
GC_FREE( obj );}
|
||||
|
||||
|
||||
#ifdef OPERATOR_NEW_ARRAY
|
||||
|
||||
inline void* gc::operator new[]( size_t size ) {
|
||||
return gc::operator new( size );}
|
||||
|
||||
inline void* gc::operator new[]( size_t size, GCPlacement gcp ) {
|
||||
return gc::operator new( size, gcp );}
|
||||
|
||||
inline void gc::operator delete[]( void* obj ) {
|
||||
gc::operator delete( obj );}
|
||||
|
||||
#endif /* OPERATOR_NEW_ARRAY */
|
||||
|
||||
|
||||
inline gc_cleanup::~gc_cleanup() {
|
||||
GC_REGISTER_FINALIZER_IGNORE_SELF( GC_base(this), 0, 0, 0, 0 );}
|
||||
|
||||
inline void gc_cleanup::cleanup( void* obj, void* displ ) {
|
||||
((gc_cleanup*) ((char*) obj + (ptrdiff_t) displ))->~gc_cleanup();}
|
||||
|
||||
inline gc_cleanup::gc_cleanup() {
|
||||
GC_finalization_proc oldProc;
|
||||
void* oldData;
|
||||
void* base = GC_base( (void *) this );
|
||||
if (0 != base) {
|
||||
GC_REGISTER_FINALIZER_IGNORE_SELF(
|
||||
base, (GC_finalization_proc)cleanup, (void*) ((char*) this - (char*) base),
|
||||
&oldProc, &oldData );
|
||||
if (0 != oldProc) {
|
||||
GC_REGISTER_FINALIZER_IGNORE_SELF( base, oldProc, oldData, 0, 0 );}}}
|
||||
|
||||
inline void* operator new(
|
||||
size_t size,
|
||||
GCPlacement gcp,
|
||||
GCCleanUpFunc cleanup,
|
||||
void* clientData )
|
||||
{
|
||||
void* obj;
|
||||
|
||||
if (gcp == UseGC) {
|
||||
obj = GC_MALLOC( size );
|
||||
if (cleanup != 0)
|
||||
GC_REGISTER_FINALIZER_IGNORE_SELF(
|
||||
obj, cleanup, clientData, 0, 0 );}
|
||||
else if (gcp == PointerFreeGC) {
|
||||
obj = GC_MALLOC_ATOMIC( size );}
|
||||
else {
|
||||
obj = GC_MALLOC_UNCOLLECTABLE( size );};
|
||||
return obj;}
|
||||
|
||||
|
||||
#ifdef OPERATOR_NEW_ARRAY
|
||||
|
||||
inline void* operator new[](
|
||||
size_t size,
|
||||
GCPlacement gcp,
|
||||
GCCleanUpFunc cleanup,
|
||||
void* clientData )
|
||||
{
|
||||
return ::operator new( size, gcp, cleanup, clientData );}
|
||||
|
||||
#endif /* OPERATOR_NEW_ARRAY */
|
||||
|
||||
|
||||
#endif /* GC_CPP_H */
|
||||
|
|
@ -1,303 +0,0 @@
|
|||
/*
|
||||
* Copyright 1988, 1989 Hans-J. Boehm, Alan J. Demers
|
||||
* Copyright (c) 1991-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.
|
||||
*/
|
||||
/* Boehm, July 11, 1995 11:54 am PDT */
|
||||
# ifndef GC_HEADERS_H
|
||||
# define GC_HEADERS_H
|
||||
typedef struct hblkhdr hdr;
|
||||
|
||||
# if CPP_WORDSZ != 32 && CPP_WORDSZ < 36
|
||||
--> Get a real machine.
|
||||
# endif
|
||||
|
||||
/*
|
||||
* The 2 level tree data structure that is used to find block headers.
|
||||
* If there are more than 32 bits in a pointer, the top level is a hash
|
||||
* table.
|
||||
*
|
||||
* This defines HDR, GET_HDR, and SET_HDR, the main macros used to
|
||||
* retrieve and set object headers. We also define some variants to
|
||||
* retrieve 2 unrelated headers in interleaved fashion. This
|
||||
* slightly improves scheduling.
|
||||
*
|
||||
* Since 5.0 alpha 5, we can also take advantage of a header lookup
|
||||
* cache. This is a locally declared direct mapped cache, used inside
|
||||
* the marker. The HC_GET_HDR and HC_GET_HDR2 macros use and maintain this
|
||||
* cache. Assuming we get reasonable hit rates, this shaves a few
|
||||
* memory references from each pointer validation.
|
||||
*/
|
||||
|
||||
# if CPP_WORDSZ > 32
|
||||
# define HASH_TL
|
||||
# endif
|
||||
|
||||
/* Define appropriate out-degrees for each of the two tree levels */
|
||||
# ifdef SMALL_CONFIG
|
||||
# define LOG_BOTTOM_SZ 11
|
||||
/* Keep top index size reasonable with smaller blocks. */
|
||||
# else
|
||||
# define LOG_BOTTOM_SZ 10
|
||||
# endif
|
||||
# ifndef HASH_TL
|
||||
# define LOG_TOP_SZ (WORDSZ - LOG_BOTTOM_SZ - LOG_HBLKSIZE)
|
||||
# else
|
||||
# define LOG_TOP_SZ 11
|
||||
# endif
|
||||
# define TOP_SZ (1 << LOG_TOP_SZ)
|
||||
# define BOTTOM_SZ (1 << LOG_BOTTOM_SZ)
|
||||
|
||||
#ifndef SMALL_CONFIG
|
||||
# define USE_HDR_CACHE
|
||||
#endif
|
||||
|
||||
/* #define COUNT_HDR_CACHE_HITS */
|
||||
|
||||
extern hdr * GC_invalid_header; /* header for an imaginary block */
|
||||
/* containing no objects. */
|
||||
|
||||
|
||||
/* Check whether p and corresponding hhdr point to long or invalid */
|
||||
/* object. If so, advance them to */
|
||||
/* beginning of block, or set hhdr to GC_invalid_header. */
|
||||
#define ADVANCE(p, hhdr, source) \
|
||||
if (IS_FORWARDING_ADDR_OR_NIL(hhdr)) { \
|
||||
p = GC_FIND_START(p, hhdr, (word)source); \
|
||||
if (p == 0) { \
|
||||
hhdr = GC_invalid_header; \
|
||||
} else { \
|
||||
hhdr = GC_find_header(p); \
|
||||
} \
|
||||
}
|
||||
|
||||
#ifdef USE_HDR_CACHE
|
||||
|
||||
# ifdef COUNT_HDR_CACHE_HITS
|
||||
extern word GC_hdr_cache_hits;
|
||||
extern word GC_hdr_cache_misses;
|
||||
# define HC_HIT() ++GC_hdr_cache_hits
|
||||
# define HC_MISS() ++GC_hdr_cache_misses
|
||||
# else
|
||||
# define HC_HIT()
|
||||
# define HC_MISS()
|
||||
# endif
|
||||
|
||||
typedef struct hce {
|
||||
word block_addr; /* right shifted by LOG_HBLKSIZE */
|
||||
hdr * hce_hdr;
|
||||
} hdr_cache_entry;
|
||||
|
||||
# define HDR_CACHE_SIZE 8 /* power of 2 */
|
||||
|
||||
# define DECLARE_HDR_CACHE \
|
||||
hdr_cache_entry hdr_cache[HDR_CACHE_SIZE]
|
||||
|
||||
# define INIT_HDR_CACHE BZERO(hdr_cache, sizeof(hdr_cache));
|
||||
|
||||
# define HCE(h) hdr_cache + (((word)(h) >> LOG_HBLKSIZE) & (HDR_CACHE_SIZE-1))
|
||||
|
||||
# define HCE_VALID_FOR(hce,h) ((hce) -> block_addr == \
|
||||
((word)(h) >> LOG_HBLKSIZE))
|
||||
|
||||
# define HCE_HDR(h) ((hce) -> hce_hdr)
|
||||
|
||||
|
||||
/* Analogous to GET_HDR, except that in the case of large objects, it */
|
||||
/* Returns the header for the object beginning, and updates p. */
|
||||
/* Returns &GC_bad_header instead of 0. All of this saves a branch */
|
||||
/* in the fast path. */
|
||||
# define HC_GET_HDR(p, hhdr, source) \
|
||||
{ \
|
||||
hdr_cache_entry * hce = HCE(p); \
|
||||
if (HCE_VALID_FOR(hce, p)) { \
|
||||
HC_HIT(); \
|
||||
hhdr = hce -> hce_hdr; \
|
||||
} else { \
|
||||
HC_MISS(); \
|
||||
GET_HDR(p, hhdr); \
|
||||
ADVANCE(p, hhdr, source); \
|
||||
hce -> block_addr = (word)(p) >> LOG_HBLKSIZE; \
|
||||
hce -> hce_hdr = hhdr; \
|
||||
} \
|
||||
}
|
||||
|
||||
# define HC_GET_HDR2(p1, hhdr1, source1, p2, hhdr2, source2) \
|
||||
{ \
|
||||
hdr_cache_entry * hce1 = HCE(p1); \
|
||||
hdr_cache_entry * hce2 = HCE(p2); \
|
||||
if (HCE_VALID_FOR(hce1, p1)) { \
|
||||
HC_HIT(); \
|
||||
hhdr1 = hce1 -> hce_hdr; \
|
||||
} else { \
|
||||
HC_MISS(); \
|
||||
GET_HDR(p1, hhdr1); \
|
||||
ADVANCE(p1, hhdr1, source1); \
|
||||
hce1 -> block_addr = (word)(p1) >> LOG_HBLKSIZE; \
|
||||
hce1 -> hce_hdr = hhdr1; \
|
||||
} \
|
||||
if (HCE_VALID_FOR(hce2, p2)) { \
|
||||
HC_HIT(); \
|
||||
hhdr2 = hce2 -> hce_hdr; \
|
||||
} else { \
|
||||
HC_MISS(); \
|
||||
GET_HDR(p2, hhdr2); \
|
||||
ADVANCE(p2, hhdr2, source2); \
|
||||
hce2 -> block_addr = (word)(p2) >> LOG_HBLKSIZE; \
|
||||
hce2 -> hce_hdr = hhdr2; \
|
||||
} \
|
||||
}
|
||||
|
||||
#else /* !USE_HDR_CACHE */
|
||||
|
||||
# define DECLARE_HDR_CACHE
|
||||
|
||||
# define INIT_HDR_CACHE
|
||||
|
||||
# define HC_GET_HDR(p, hhdr, source) \
|
||||
{ \
|
||||
GET_HDR(p, hhdr); \
|
||||
ADVANCE(p, hhdr, source); \
|
||||
}
|
||||
|
||||
# define HC_GET_HDR2(p1, hhdr1, source1, p2, hhdr2, source2) \
|
||||
{ \
|
||||
GET_HDR2(p1, hhdr1, p2, hhdr2); \
|
||||
ADVANCE(p1, hhdr1, source1); \
|
||||
ADVANCE(p2, hhdr2, source2); \
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
typedef struct bi {
|
||||
hdr * index[BOTTOM_SZ];
|
||||
/*
|
||||
* The bottom level index contains one of three kinds of values:
|
||||
* 0 means we're not responsible for this block,
|
||||
* or this is a block other than the first one in a free block.
|
||||
* 1 < (long)X <= MAX_JUMP means the block starts at least
|
||||
* X * HBLKSIZE bytes before the current address.
|
||||
* A valid pointer points to a hdr structure. (The above can't be
|
||||
* valid pointers due to the GET_MEM return convention.)
|
||||
*/
|
||||
struct bi * asc_link; /* All indices are linked in */
|
||||
/* ascending order... */
|
||||
struct bi * desc_link; /* ... and in descending order. */
|
||||
word key; /* high order address bits. */
|
||||
# ifdef HASH_TL
|
||||
struct bi * hash_link; /* Hash chain link. */
|
||||
# endif
|
||||
} bottom_index;
|
||||
|
||||
/* extern bottom_index GC_all_nils; - really part of GC_arrays */
|
||||
|
||||
/* extern bottom_index * GC_top_index []; - really part of GC_arrays */
|
||||
/* Each entry points to a bottom_index. */
|
||||
/* On a 32 bit machine, it points to */
|
||||
/* the index for a set of high order */
|
||||
/* bits equal to the index. For longer */
|
||||
/* addresses, we hash the high order */
|
||||
/* bits to compute the index in */
|
||||
/* GC_top_index, and each entry points */
|
||||
/* to a hash chain. */
|
||||
/* The last entry in each chain is */
|
||||
/* GC_all_nils. */
|
||||
|
||||
|
||||
# define MAX_JUMP (HBLKSIZE - 1)
|
||||
|
||||
# define HDR_FROM_BI(bi, p) \
|
||||
((bi)->index[((word)(p) >> LOG_HBLKSIZE) & (BOTTOM_SZ - 1)])
|
||||
# ifndef HASH_TL
|
||||
# define BI(p) (GC_top_index \
|
||||
[(word)(p) >> (LOG_BOTTOM_SZ + LOG_HBLKSIZE)])
|
||||
# define HDR_INNER(p) HDR_FROM_BI(BI(p),p)
|
||||
# ifdef SMALL_CONFIG
|
||||
# define HDR(p) GC_find_header((ptr_t)(p))
|
||||
# else
|
||||
# define HDR(p) HDR_INNER(p)
|
||||
# endif
|
||||
# define GET_BI(p, bottom_indx) (bottom_indx) = BI(p)
|
||||
# define GET_HDR(p, hhdr) (hhdr) = HDR(p)
|
||||
# define SET_HDR(p, hhdr) HDR_INNER(p) = (hhdr)
|
||||
# define GET_HDR_ADDR(p, ha) (ha) = &(HDR_INNER(p))
|
||||
# define GET_HDR2(p1, hhdr1, p2, hhdr2) \
|
||||
{ GET_HDR(p1, hhdr1); GET_HDR(p2, hhdr2); }
|
||||
# else /* hash */
|
||||
/* Hash function for tree top level */
|
||||
# define TL_HASH(hi) ((hi) & (TOP_SZ - 1))
|
||||
/* Set bottom_indx to point to the bottom index for address p */
|
||||
# define GET_BI(p, bottom_indx) \
|
||||
{ \
|
||||
register word hi = \
|
||||
(word)(p) >> (LOG_BOTTOM_SZ + LOG_HBLKSIZE); \
|
||||
register bottom_index * _bi = GC_top_index[TL_HASH(hi)]; \
|
||||
\
|
||||
while (_bi -> key != hi && _bi != GC_all_nils) \
|
||||
_bi = _bi -> hash_link; \
|
||||
(bottom_indx) = _bi; \
|
||||
}
|
||||
# define GET_HDR_ADDR(p, ha) \
|
||||
{ \
|
||||
register bottom_index * bi; \
|
||||
\
|
||||
GET_BI(p, bi); \
|
||||
(ha) = &(HDR_FROM_BI(bi, p)); \
|
||||
}
|
||||
# define GET_HDR(p, hhdr) { register hdr ** _ha; GET_HDR_ADDR(p, _ha); \
|
||||
(hhdr) = *_ha; }
|
||||
# define SET_HDR(p, hhdr) { register hdr ** _ha; GET_HDR_ADDR(p, _ha); \
|
||||
*_ha = (hhdr); }
|
||||
# define HDR(p) GC_find_header((ptr_t)(p))
|
||||
/* And some interleaved versions for two pointers at once. */
|
||||
/* This hopefully helps scheduling on processors like IA64. */
|
||||
# define GET_BI2(p1, bottom_indx1, p2, bottom_indx2) \
|
||||
{ \
|
||||
register word hi1 = \
|
||||
(word)(p1) >> (LOG_BOTTOM_SZ + LOG_HBLKSIZE); \
|
||||
register word hi2 = \
|
||||
(word)(p2) >> (LOG_BOTTOM_SZ + LOG_HBLKSIZE); \
|
||||
register bottom_index * _bi1 = GC_top_index[TL_HASH(hi1)]; \
|
||||
register bottom_index * _bi2 = GC_top_index[TL_HASH(hi2)]; \
|
||||
\
|
||||
while (_bi1 -> key != hi1 && _bi1 != GC_all_nils) \
|
||||
_bi1 = _bi1 -> hash_link; \
|
||||
while (_bi2 -> key != hi2 && _bi2 != GC_all_nils) \
|
||||
_bi2 = _bi2 -> hash_link; \
|
||||
(bottom_indx1) = _bi1; \
|
||||
(bottom_indx2) = _bi2; \
|
||||
}
|
||||
# define GET_HDR_ADDR2(p1, ha1, p2, ha2) \
|
||||
{ \
|
||||
register bottom_index * bi1; \
|
||||
register bottom_index * bi2; \
|
||||
\
|
||||
GET_BI2(p1, bi1, p2, bi2); \
|
||||
(ha1) = &(HDR_FROM_BI(bi1, p1)); \
|
||||
(ha2) = &(HDR_FROM_BI(bi2, p2)); \
|
||||
}
|
||||
# define GET_HDR2(p1, hhdr1, p2, hhdr2) \
|
||||
{ register hdr ** _ha1; \
|
||||
register hdr ** _ha2; \
|
||||
GET_HDR_ADDR2(p1, _ha1, p2, _ha2); \
|
||||
(hhdr1) = *_ha1; \
|
||||
(hhdr2) = *_ha2; \
|
||||
}
|
||||
# endif
|
||||
|
||||
/* Is the result a forwarding address to someplace closer to the */
|
||||
/* beginning of the block or NIL? */
|
||||
# define IS_FORWARDING_ADDR_OR_NIL(hhdr) ((unsigned long) (hhdr) <= MAX_JUMP)
|
||||
|
||||
/* Get an HBLKSIZE aligned address closer to the beginning of the block */
|
||||
/* h. Assumes hhdr == HDR(h) and IS_FORWARDING_ADDR(hhdr). */
|
||||
# define FORWARDED_ADDR(h, hhdr) ((struct hblk *)(h) - (unsigned long)(hhdr))
|
||||
# endif /* GC_HEADERS_H */
|
|
@ -1,346 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 1991-1994, 2000 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.
|
||||
*
|
||||
*/
|
||||
/* Boehm, November 7, 1994 4:56 pm PST */
|
||||
|
||||
/*
|
||||
* Declarations of mark stack. Needed by marker and client supplied mark
|
||||
* routines. To be included after gc_priv.h.
|
||||
*/
|
||||
#ifndef GC_MARK_H
|
||||
# define GC_MARK_H
|
||||
|
||||
# ifdef KEEP_BACK_PTRS
|
||||
# include "dbg_mlc.h"
|
||||
# endif
|
||||
|
||||
/* A client supplied mark procedure. Returns new mark stack pointer. */
|
||||
/* Primary effect should be to push new entries on the mark stack. */
|
||||
/* Mark stack pointer values are passed and returned explicitly. */
|
||||
/* Global variables decribing mark stack are not necessarily valid. */
|
||||
/* (This usually saves a few cycles by keeping things in registers.) */
|
||||
/* Assumed to scan about PROC_BYTES on average. If it needs to do */
|
||||
/* much more work than that, it should do it in smaller pieces by */
|
||||
/* pushing itself back on the mark stack. */
|
||||
/* Note that it should always do some work (defined as marking some */
|
||||
/* objects) before pushing more than one entry on the mark stack. */
|
||||
/* This is required to ensure termination in the event of mark stack */
|
||||
/* overflows. */
|
||||
/* This procedure is always called with at least one empty entry on the */
|
||||
/* mark stack. */
|
||||
/* Currently we require that mark procedures look for pointers in a */
|
||||
/* subset of the places the conservative marker would. It must be safe */
|
||||
/* to invoke the normal mark procedure instead. */
|
||||
# define PROC_BYTES 100
|
||||
/* The real declarations of the following are in gc_priv.h, so that */
|
||||
/* we can avoid scanning the following table. */
|
||||
/*
|
||||
typedef struct ms_entry * (*mark_proc)( word * addr,
|
||||
struct ms_entry *mark_stack_ptr,
|
||||
struct ms_entry *mark_stack_limit,
|
||||
word env );
|
||||
|
||||
# define LOG_MAX_MARK_PROCS 6
|
||||
# define MAX_MARK_PROCS (1 << LOG_MAX_MARK_PROCS)
|
||||
extern mark_proc GC_mark_procs[MAX_MARK_PROCS];
|
||||
*/
|
||||
|
||||
extern word GC_n_mark_procs;
|
||||
|
||||
/* In a few cases it's necessary to assign statically known indices to */
|
||||
/* certain mark procs. Thus we reserve a few for well known clients. */
|
||||
/* (This is necessary if mark descriptors are compiler generated.) */
|
||||
#define GC_RESERVED_MARK_PROCS 8
|
||||
# define GCJ_RESERVED_MARK_PROC_INDEX 0
|
||||
|
||||
/* Object descriptors on mark stack or in objects. Low order two */
|
||||
/* bits are tags distinguishing among the following 4 possibilities */
|
||||
/* for the high order 30 bits. */
|
||||
#define DS_TAG_BITS 2
|
||||
#define DS_TAGS ((1 << DS_TAG_BITS) - 1)
|
||||
#define DS_LENGTH 0 /* The entire word is a length in bytes that */
|
||||
/* must be a multiple of 4. */
|
||||
#define DS_BITMAP 1 /* 30 bits are a bitmap describing pointer */
|
||||
/* fields. The msb is 1 iff the first word */
|
||||
/* is a pointer. */
|
||||
/* (This unconventional ordering sometimes */
|
||||
/* makes the marker slightly faster.) */
|
||||
/* Zeroes indicate definite nonpointers. Ones */
|
||||
/* indicate possible pointers. */
|
||||
/* Only usable if pointers are word aligned. */
|
||||
# define BITMAP_BITS (WORDSZ - DS_TAG_BITS)
|
||||
#define DS_PROC 2
|
||||
/* The objects referenced by this object can be */
|
||||
/* pushed on the mark stack by invoking */
|
||||
/* PROC(descr). ENV(descr) is passed as the */
|
||||
/* last argument. */
|
||||
# define PROC(descr) \
|
||||
(GC_mark_procs[((descr) >> DS_TAG_BITS) & (MAX_MARK_PROCS-1)])
|
||||
# define ENV(descr) \
|
||||
((descr) >> (DS_TAG_BITS + LOG_MAX_MARK_PROCS))
|
||||
# define MAX_ENV \
|
||||
(((word)1 << (WORDSZ - DS_TAG_BITS - LOG_MAX_MARK_PROCS)) - 1)
|
||||
# define MAKE_PROC(proc_index, env) \
|
||||
(((((env) << LOG_MAX_MARK_PROCS) | (proc_index)) << DS_TAG_BITS) \
|
||||
| DS_PROC)
|
||||
#define DS_PER_OBJECT 3 /* The real descriptor is at the */
|
||||
/* byte displacement from the beginning of the */
|
||||
/* object given by descr & ~DS_TAGS */
|
||||
/* If the descriptor is negative, the real */
|
||||
/* descriptor is at (*<object_start>) - */
|
||||
/* (descr & ~DS_TAGS) - INDIR_PER_OBJ_BIAS */
|
||||
/* The latter alternative can be used if each */
|
||||
/* object contains a type descriptor in the */
|
||||
/* first word. */
|
||||
#define INDIR_PER_OBJ_BIAS 0x10
|
||||
|
||||
typedef struct ms_entry {
|
||||
word * mse_start; /* First word of object */
|
||||
word mse_descr; /* Descriptor; low order two bits are tags, */
|
||||
/* identifying the upper 30 bits as one of the */
|
||||
/* following: */
|
||||
} mse;
|
||||
|
||||
extern word GC_mark_stack_size;
|
||||
|
||||
extern mse * GC_mark_stack_top;
|
||||
|
||||
extern mse * GC_mark_stack;
|
||||
|
||||
#ifdef PRINT_BLACK_LIST
|
||||
ptr_t GC_find_start(ptr_t, hdr*, word);
|
||||
#else
|
||||
ptr_t GC_find_start(ptr_t, hdr*);
|
||||
#endif
|
||||
|
||||
mse * GC_signal_mark_stack_overflow(mse *);
|
||||
|
||||
# ifdef GATHERSTATS
|
||||
# define ADD_TO_ATOMIC(sz) GC_atomic_in_use += (sz)
|
||||
# define ADD_TO_COMPOSITE(sz) GC_composite_in_use += (sz)
|
||||
# else
|
||||
# define ADD_TO_ATOMIC(sz)
|
||||
# define ADD_TO_COMPOSITE(sz)
|
||||
# endif
|
||||
|
||||
/* Push the object obj with corresponding heap block header hhdr onto */
|
||||
/* the mark stack. */
|
||||
# define PUSH_OBJ(obj, hhdr, mark_stack_top, mark_stack_limit) \
|
||||
{ \
|
||||
register word _descr = (hhdr) -> hb_descr; \
|
||||
\
|
||||
if (_descr == 0) { \
|
||||
ADD_TO_ATOMIC((hhdr) -> hb_sz); \
|
||||
} else { \
|
||||
ADD_TO_COMPOSITE((hhdr) -> hb_sz); \
|
||||
mark_stack_top++; \
|
||||
if (mark_stack_top >= mark_stack_limit) { \
|
||||
mark_stack_top = GC_signal_mark_stack_overflow(mark_stack_top); \
|
||||
} \
|
||||
mark_stack_top -> mse_start = (obj); \
|
||||
mark_stack_top -> mse_descr = _descr; \
|
||||
} \
|
||||
}
|
||||
|
||||
#ifdef PRINT_BLACK_LIST
|
||||
# define GC_FIND_START(current, hhdr, source) \
|
||||
GC_find_start(current, hhdr, source)
|
||||
#else
|
||||
# define GC_FIND_START(current, hhdr, source) \
|
||||
GC_find_start(current, hhdr)
|
||||
#endif
|
||||
|
||||
/* Push the contents of current onto the mark stack if it is a valid */
|
||||
/* ptr to a currently unmarked object. Mark it. */
|
||||
/* If we assumed a standard-conforming compiler, we could probably */
|
||||
/* generate the exit_label transparently. */
|
||||
# define PUSH_CONTENTS(current, mark_stack_top, mark_stack_limit, \
|
||||
source, exit_label) \
|
||||
{ \
|
||||
hdr * my_hhdr; \
|
||||
ptr_t my_current = current; \
|
||||
\
|
||||
GET_HDR(my_current, my_hhdr); \
|
||||
if (IS_FORWARDING_ADDR_OR_NIL(my_hhdr)) { \
|
||||
my_current = GC_FIND_START(my_current, my_hhdr, (word)source); \
|
||||
if (my_current == 0) goto exit_label; \
|
||||
my_hhdr = GC_find_header(my_current); \
|
||||
} \
|
||||
PUSH_CONTENTS_HDR(my_current, mark_stack_top, mark_stack_limit, \
|
||||
source, exit_label, my_hhdr); \
|
||||
exit_label: ; \
|
||||
}
|
||||
|
||||
/* As above, but use header cache for header lookup. */
|
||||
# define HC_PUSH_CONTENTS(current, mark_stack_top, mark_stack_limit, \
|
||||
source, exit_label) \
|
||||
{ \
|
||||
hdr * my_hhdr; \
|
||||
ptr_t my_current = current; \
|
||||
\
|
||||
HC_GET_HDR(my_current, my_hhdr, source); \
|
||||
PUSH_CONTENTS_HDR(my_current, mark_stack_top, mark_stack_limit, \
|
||||
source, exit_label, my_hhdr); \
|
||||
exit_label: ; \
|
||||
}
|
||||
|
||||
/* As above, but deal with two pointers in interleaved fashion. */
|
||||
# define HC_PUSH_CONTENTS2(current1, current2, mark_stack_top, \
|
||||
mark_stack_limit, \
|
||||
source1, source2, exit_label1, exit_label2) \
|
||||
{ \
|
||||
hdr * hhdr1; \
|
||||
ptr_t my_current1 = current1; \
|
||||
hdr * hhdr2; \
|
||||
ptr_t my_current2 = current2; \
|
||||
\
|
||||
HC_GET_HDR2(my_current1, hhdr1, source1, my_current2, hhdr2, source2); \
|
||||
PUSH_CONTENTS_HDR(my_current1, mark_stack_top, mark_stack_limit, \
|
||||
source1, exit_label1, hhdr1); \
|
||||
exit_label1: ; \
|
||||
if (0 != hhdr2) { \
|
||||
PUSH_CONTENTS_HDR(my_current2, mark_stack_top, mark_stack_limit, \
|
||||
source2, exit_label2, hhdr2); \
|
||||
} \
|
||||
exit_label2: ; \
|
||||
}
|
||||
|
||||
# define PUSH_CONTENTS_HDR(current, mark_stack_top, mark_stack_limit, \
|
||||
source, exit_label, hhdr) \
|
||||
{ \
|
||||
int displ; /* Displacement in block; first bytes, then words */ \
|
||||
map_entry_type map_entry; \
|
||||
\
|
||||
displ = HBLKDISPL(current); \
|
||||
map_entry = MAP_ENTRY((hhdr -> hb_map), displ); \
|
||||
if (map_entry == OBJ_INVALID) { \
|
||||
GC_ADD_TO_BLACK_LIST_NORMAL(current, source); goto exit_label; \
|
||||
} \
|
||||
displ = BYTES_TO_WORDS(displ); \
|
||||
displ -= map_entry; \
|
||||
\
|
||||
{ \
|
||||
register word * mark_word_addr = hhdr -> hb_marks + divWORDSZ(displ); \
|
||||
register word mark_word = *mark_word_addr; \
|
||||
register word mark_bit = (word)1 << modWORDSZ(displ); \
|
||||
\
|
||||
if (mark_word & mark_bit) { \
|
||||
/* Mark bit is already set */ \
|
||||
goto exit_label; \
|
||||
} \
|
||||
GC_STORE_BACK_PTR((ptr_t)source, (ptr_t)HBLKPTR(current) \
|
||||
+ WORDS_TO_BYTES(displ)); \
|
||||
*mark_word_addr = mark_word | mark_bit; \
|
||||
} \
|
||||
PUSH_OBJ(((word *)(HBLKPTR(current)) + displ), hhdr, \
|
||||
mark_stack_top, mark_stack_limit) \
|
||||
}
|
||||
|
||||
#if defined(PRINT_BLACK_LIST) || defined(KEEP_BACK_PTRS)
|
||||
# define PUSH_ONE_CHECKED(p, ip, source) \
|
||||
GC_push_one_checked(p, ip, (ptr_t)(source))
|
||||
#else
|
||||
# define PUSH_ONE_CHECKED(p, ip, source) \
|
||||
GC_push_one_checked(p, ip)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Push a single value onto mark stack. Mark from the object pointed to by p.
|
||||
* P is considered valid even if it is an interior pointer.
|
||||
* Previously marked objects are not pushed. Hence we make progress even
|
||||
* if the mark stack overflows.
|
||||
*/
|
||||
# define GC_PUSH_ONE_STACK(p, source) \
|
||||
if ((ptr_t)(p) >= GC_least_plausible_heap_addr \
|
||||
&& (ptr_t)(p) < GC_greatest_plausible_heap_addr) { \
|
||||
PUSH_ONE_CHECKED(p, TRUE, source); \
|
||||
}
|
||||
|
||||
/*
|
||||
* As above, but interior pointer recognition as for
|
||||
* normal for heap pointers.
|
||||
*/
|
||||
# ifdef ALL_INTERIOR_POINTERS
|
||||
# define AIP TRUE
|
||||
# else
|
||||
# define AIP FALSE
|
||||
# endif
|
||||
# define GC_PUSH_ONE_HEAP(p,source) \
|
||||
if ((ptr_t)(p) >= GC_least_plausible_heap_addr \
|
||||
&& (ptr_t)(p) < GC_greatest_plausible_heap_addr) { \
|
||||
PUSH_ONE_CHECKED(p,AIP,source); \
|
||||
}
|
||||
|
||||
/*
|
||||
* Mark from one finalizable object using the specified
|
||||
* mark proc. May not mark the object pointed to by
|
||||
* real_ptr. That is the job of the caller, if appropriate
|
||||
*/
|
||||
# define GC_MARK_FO(real_ptr, mark_proc) \
|
||||
{ \
|
||||
(*(mark_proc))(real_ptr); \
|
||||
while (!GC_mark_stack_empty()) GC_mark_from_mark_stack(); \
|
||||
if (GC_mark_state != MS_NONE) { \
|
||||
GC_set_mark_bit(real_ptr); \
|
||||
while (!GC_mark_some((ptr_t)0)); \
|
||||
} \
|
||||
}
|
||||
|
||||
extern GC_bool GC_mark_stack_too_small;
|
||||
/* We need a larger mark stack. May be */
|
||||
/* set by client supplied mark routines.*/
|
||||
|
||||
typedef int mark_state_t; /* Current state of marking, as follows:*/
|
||||
/* Used to remember where we are during */
|
||||
/* concurrent marking. */
|
||||
|
||||
/* We say something is dirty if it was */
|
||||
/* written since the last time we */
|
||||
/* retrieved dirty bits. We say it's */
|
||||
/* grungy if it was marked dirty in the */
|
||||
/* last set of bits we retrieved. */
|
||||
|
||||
/* Invariant I: all roots and marked */
|
||||
/* objects p are either dirty, or point */
|
||||
/* to objects q that are either marked */
|
||||
/* or a pointer to q appears in a range */
|
||||
/* on the mark stack. */
|
||||
|
||||
# define MS_NONE 0 /* No marking in progress. I holds. */
|
||||
/* Mark stack is empty. */
|
||||
|
||||
# define MS_PUSH_RESCUERS 1 /* Rescuing objects are currently */
|
||||
/* being pushed. I holds, except */
|
||||
/* that grungy roots may point to */
|
||||
/* unmarked objects, as may marked */
|
||||
/* grungy objects above scan_ptr. */
|
||||
|
||||
# define MS_PUSH_UNCOLLECTABLE 2
|
||||
/* I holds, except that marked */
|
||||
/* uncollectable objects above scan_ptr */
|
||||
/* may point to unmarked objects. */
|
||||
/* Roots may point to unmarked objects */
|
||||
|
||||
# define MS_ROOTS_PUSHED 3 /* I holds, mark stack may be nonempty */
|
||||
|
||||
# define MS_PARTIALLY_INVALID 4 /* I may not hold, e.g. because of M.S. */
|
||||
/* overflow. However marked heap */
|
||||
/* objects below scan_ptr point to */
|
||||
/* marked or stacked objects. */
|
||||
|
||||
# define MS_INVALID 5 /* I may not hold. */
|
||||
|
||||
extern mark_state_t GC_mark_state;
|
||||
|
||||
#endif /* GC_MARK_H */
|
||||
|
1906
boehm-gc/gc_priv.h
1906
boehm-gc/gc_priv.h
File diff suppressed because it is too large
Load diff
|
@ -1 +0,0 @@
|
|||
# include "gc_priv.h"
|
|
@ -1,93 +0,0 @@
|
|||
/*
|
||||
* Copyright 1988, 1989 Hans-J. Boehm, Alan J. Demers
|
||||
* Copyright (c) 1991-1994 by Xerox Corporation. All rights reserved.
|
||||
* Copyright 1996 Silicon Graphics. All rights reserved.
|
||||
*
|
||||
* THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED
|
||||
* OR IMPLIED. ANY USE IS AT YOUR OWN RISK.
|
||||
*
|
||||
* Permission is hereby granted to use or copy this program
|
||||
* for any purpose, provided the above notices are retained on all copies.
|
||||
* Permission to modify the code and to distribute modified code is granted,
|
||||
* provided the above notices are retained, and a notice that the code was
|
||||
* modified is included with the above copyright notice.
|
||||
*/
|
||||
/*
|
||||
* Some simple primitives for allocation with explicit type information.
|
||||
* Facilities for dynamic type inference may be added later.
|
||||
* Should be used only for extremely performance critical applications,
|
||||
* or if conservative collector leakage is otherwise a problem (unlikely).
|
||||
* Note that this is implemented completely separately from the rest
|
||||
* of the collector, and is not linked in unless referenced.
|
||||
* This does not currently support GC_DEBUG in any interesting way.
|
||||
*/
|
||||
/* Boehm, May 19, 1994 2:13 pm PDT */
|
||||
|
||||
#ifndef _GC_TYPED_H
|
||||
# define _GC_TYPED_H
|
||||
# ifndef _GC_H
|
||||
# include "gc.h"
|
||||
# endif
|
||||
|
||||
typedef GC_word * GC_bitmap;
|
||||
/* The least significant bit of the first word is one if */
|
||||
/* the first word in the object may be a pointer. */
|
||||
|
||||
# define GC_get_bit(bm, index) \
|
||||
(((bm)[divWORDSZ(index)] >> modWORDSZ(index)) & 1)
|
||||
# define GC_set_bit(bm, index) \
|
||||
(bm)[divWORDSZ(index)] |= (word)1 << modWORDSZ(index)
|
||||
|
||||
typedef GC_word GC_descr;
|
||||
|
||||
GC_API GC_descr GC_make_descriptor GC_PROTO((GC_bitmap bm, size_t len));
|
||||
/* Return a type descriptor for the object whose layout */
|
||||
/* is described by the argument. */
|
||||
/* The least significant bit of the first word is one */
|
||||
/* if the first word in the object may be a pointer. */
|
||||
/* The second argument specifies the number of */
|
||||
/* meaningful bits in the bitmap. The actual object */
|
||||
/* may be larger (but not smaller). Any additional */
|
||||
/* words in the object are assumed not to contain */
|
||||
/* pointers. */
|
||||
/* Returns a conservative approximation in the */
|
||||
/* (unlikely) case of insufficient memory to build */
|
||||
/* the descriptor. Calls to GC_make_descriptor */
|
||||
/* may consume some amount of a finite resource. This */
|
||||
/* is intended to be called once per type, not once */
|
||||
/* per allocation. */
|
||||
|
||||
GC_API GC_PTR GC_malloc_explicitly_typed
|
||||
GC_PROTO((size_t size_in_bytes, GC_descr d));
|
||||
/* Allocate an object whose layout is described by d. */
|
||||
/* The resulting object MAY NOT BE PASSED TO REALLOC. */
|
||||
/* The returned object is cleared. */
|
||||
|
||||
GC_API GC_PTR GC_malloc_explicitly_typed_ignore_off_page
|
||||
GC_PROTO((size_t size_in_bytes, GC_descr d));
|
||||
|
||||
GC_API GC_PTR GC_calloc_explicitly_typed
|
||||
GC_PROTO((size_t nelements,
|
||||
size_t element_size_in_bytes,
|
||||
GC_descr d));
|
||||
/* Allocate an array of nelements elements, each of the */
|
||||
/* given size, and with the given descriptor. */
|
||||
/* The elemnt size must be a multiple of the byte */
|
||||
/* alignment required for pointers. E.g. on a 32-bit */
|
||||
/* machine with 16-bit aligned pointers, size_in_bytes */
|
||||
/* must be a multiple of 2. */
|
||||
/* Returned object is cleared. */
|
||||
|
||||
#ifdef GC_DEBUG
|
||||
# define GC_MALLOC_EXPLICTLY_TYPED(bytes, d) GC_MALLOC(bytes)
|
||||
# define GC_CALLOC_EXPLICTLY_TYPED(n, bytes, d) GC_MALLOC(n*bytes)
|
||||
#else
|
||||
# define GC_MALLOC_EXPLICTLY_TYPED(bytes, d) \
|
||||
GC_malloc_explicitly_typed(bytes, d)
|
||||
# define GC_CALLOC_EXPLICTLY_TYPED(n, bytes, d) \
|
||||
GC_calloc_explicitly_typed(n, bytes, d)
|
||||
#endif /* !GC_DEBUG */
|
||||
|
||||
|
||||
#endif /* _GC_TYPED_H */
|
||||
|
1383
boehm-gc/gcconfig.h
1383
boehm-gc/gcconfig.h
File diff suppressed because it is too large
Load diff
|
@ -17,13 +17,13 @@
|
|||
#ifdef GC_GCJ_SUPPORT
|
||||
|
||||
/*
|
||||
* This is an allocator interface tuned for gcj (the GNU/Cygnus static
|
||||
* This is an allocator interface tuned for gcj (the GNU static
|
||||
* java compiler).
|
||||
*
|
||||
* Each allocated object has a pointer in its first word to a vtable,
|
||||
* which for our purposes is simply a structure describing the type of
|
||||
* the object.
|
||||
* This descriptor structur contains a GC marking descriptor at offset
|
||||
* This descriptor structure contains a GC marking descriptor at offset
|
||||
* MARK_DESCR_OFFSET.
|
||||
*
|
||||
* It is hoped that this interface may also be useful for other systems,
|
||||
|
@ -36,10 +36,10 @@
|
|||
* 3) FASTLOCK is not a significant win.
|
||||
*/
|
||||
|
||||
#include "gc_priv.h"
|
||||
#include "gc_mark.h"
|
||||
#include "include/gc_gcj.h"
|
||||
#include "dbg_mlc.h"
|
||||
#include "private/gc_priv.h"
|
||||
#include "private/gc_pmark.h"
|
||||
#include "gc_gcj.h"
|
||||
#include "private/dbg_mlc.h"
|
||||
|
||||
GC_bool GC_gcj_malloc_initialized = FALSE;
|
||||
|
||||
|
@ -51,12 +51,8 @@ int GC_gcj_debug_kind; /* The kind of objects that is always marked */
|
|||
ptr_t * GC_gcjobjfreelist;
|
||||
ptr_t * GC_gcjdebugobjfreelist;
|
||||
|
||||
void * GC_default_oom_action(void) { return 0; }
|
||||
|
||||
void * (*GC_oom_action)(void) = GC_default_oom_action;
|
||||
|
||||
/* Caller does not hold allocation lock. */
|
||||
void GC_init_gcj_malloc(int mp_index, void * /* really mark_proc */mp)
|
||||
void GC_init_gcj_malloc(int mp_index, void * /* really GC_mark_proc */mp)
|
||||
{
|
||||
register int i;
|
||||
DCL_LOCK_STATE;
|
||||
|
@ -70,23 +66,23 @@ void GC_init_gcj_malloc(int mp_index, void * /* really mark_proc */mp)
|
|||
return;
|
||||
}
|
||||
GC_gcj_malloc_initialized = TRUE;
|
||||
GC_mark_procs[mp_index] = (mark_proc)mp;
|
||||
GC_mark_procs[mp_index] = (GC_mark_proc)mp;
|
||||
if (mp_index >= GC_n_mark_procs) ABORT("GC_init_gcj_malloc: bad index");
|
||||
/* Set up object kind gcj-style indirect descriptor. */
|
||||
GC_gcjobjfreelist = (ptr_t *)
|
||||
GC_generic_malloc_inner((MAXOBJSZ+1)*sizeof(ptr_t), PTRFREE);
|
||||
GC_INTERNAL_MALLOC((MAXOBJSZ+1)*sizeof(ptr_t), PTRFREE);
|
||||
if (GC_gcjobjfreelist == 0) ABORT("Couldn't allocate GC_gcjobjfreelist");
|
||||
BZERO(GC_gcjobjfreelist, (MAXOBJSZ+1)*sizeof(ptr_t));
|
||||
GC_gcj_kind = GC_n_kinds++;
|
||||
GC_obj_kinds[GC_gcj_kind].ok_freelist = GC_gcjobjfreelist;
|
||||
GC_obj_kinds[GC_gcj_kind].ok_reclaim_list = 0;
|
||||
GC_obj_kinds[GC_gcj_kind].ok_descriptor =
|
||||
(((word)(-MARK_DESCR_OFFSET - INDIR_PER_OBJ_BIAS)) | DS_PER_OBJECT);
|
||||
(((word)(-MARK_DESCR_OFFSET - GC_INDIR_PER_OBJ_BIAS)) | GC_DS_PER_OBJECT);
|
||||
GC_obj_kinds[GC_gcj_kind].ok_relocate_descr = FALSE;
|
||||
GC_obj_kinds[GC_gcj_kind].ok_init = TRUE;
|
||||
/* Set up object kind for objects that require mark proc call. */
|
||||
GC_gcjdebugobjfreelist = (ptr_t *)
|
||||
GC_generic_malloc_inner((MAXOBJSZ+1)*sizeof(ptr_t), PTRFREE);
|
||||
GC_INTERNAL_MALLOC((MAXOBJSZ+1)*sizeof(ptr_t), PTRFREE);
|
||||
if (GC_gcjdebugobjfreelist == 0)
|
||||
ABORT("Couldn't allocate GC_gcjdebugobjfreelist");
|
||||
BZERO(GC_gcjdebugobjfreelist, (MAXOBJSZ+1)*sizeof(ptr_t));
|
||||
|
@ -94,7 +90,7 @@ void GC_init_gcj_malloc(int mp_index, void * /* really mark_proc */mp)
|
|||
GC_obj_kinds[GC_gcj_debug_kind].ok_freelist = GC_gcjdebugobjfreelist;
|
||||
GC_obj_kinds[GC_gcj_debug_kind].ok_reclaim_list = 0;
|
||||
GC_obj_kinds[GC_gcj_debug_kind].ok_descriptor =
|
||||
MAKE_PROC(mp_index, 1 /* allocated with debug info */);
|
||||
GC_MAKE_PROC(mp_index, 1 /* allocated with debug info */);
|
||||
GC_obj_kinds[GC_gcj_debug_kind].ok_relocate_descr = FALSE;
|
||||
GC_obj_kinds[GC_gcj_debug_kind].ok_init = TRUE;
|
||||
UNLOCK();
|
||||
|
@ -119,7 +115,7 @@ register ptr_t * opp;
|
|||
register word lw;
|
||||
DCL_LOCK_STATE;
|
||||
|
||||
if( SMALL_OBJ(lb) ) {
|
||||
if( EXPECT(SMALL_OBJ(lb), 1) ) {
|
||||
# ifdef MERGE_SIZES
|
||||
lw = GC_size_map[lb];
|
||||
# else
|
||||
|
@ -127,11 +123,12 @@ DCL_LOCK_STATE;
|
|||
# endif
|
||||
opp = &(GC_gcjobjfreelist[lw]);
|
||||
LOCK();
|
||||
if( (op = *opp) == 0 ) {
|
||||
op = *opp;
|
||||
if( EXPECT(op == 0, 0)) {
|
||||
op = (ptr_t)GENERAL_MALLOC((word)lb, GC_gcj_kind);
|
||||
if (0 == op) {
|
||||
UNLOCK();
|
||||
return(GC_oom_action());
|
||||
return(GC_oom_fn(lb));
|
||||
}
|
||||
# ifdef MERGE_SIZES
|
||||
lw = GC_size_map[lb]; /* May have been uninitialized. */
|
||||
|
@ -147,7 +144,7 @@ DCL_LOCK_STATE;
|
|||
op = (ptr_t)GENERAL_MALLOC((word)lb, GC_gcj_kind);
|
||||
if (0 == op) {
|
||||
UNLOCK();
|
||||
return(GC_oom_action());
|
||||
return(GC_oom_fn(lb));
|
||||
}
|
||||
*(void **)op = ptr_to_struct_containing_descr;
|
||||
UNLOCK();
|
||||
|
@ -174,7 +171,7 @@ GC_PTR GC_debug_gcj_malloc(size_t lb, void * ptr_to_struct_containing_descr,
|
|||
(unsigned long) ptr_to_struct_containing_descr);
|
||||
GC_err_puts(s);
|
||||
GC_err_printf1(":%ld)\n", (unsigned long)i);
|
||||
return(GC_oom_action());
|
||||
return(GC_oom_fn(lb));
|
||||
}
|
||||
*((void **)((ptr_t)result + sizeof(oh))) = ptr_to_struct_containing_descr;
|
||||
UNLOCK();
|
||||
|
@ -196,12 +193,13 @@ DCL_LOCK_STATE;
|
|||
|
||||
opp = &(GC_gcjobjfreelist[lw]);
|
||||
LOCK();
|
||||
if( (op = *opp) == 0 ) {
|
||||
op = *opp;
|
||||
if( EXPECT(op == 0, 0) ) {
|
||||
op = (ptr_t)GC_clear_stack(
|
||||
GC_generic_malloc_words_small_inner(lw, GC_gcj_kind));
|
||||
if (0 == op) {
|
||||
UNLOCK();
|
||||
return(GC_oom_action());
|
||||
return GC_oom_fn(WORDS_TO_BYTES(lw));
|
||||
}
|
||||
} else {
|
||||
*opp = obj_link(op);
|
||||
|
@ -232,7 +230,7 @@ void * GC_debug_gcj_fast_malloc(size_t lw,
|
|||
(unsigned long) ptr_to_struct_containing_descr);
|
||||
GC_err_puts(s);
|
||||
GC_err_printf1(":%ld)\n", (unsigned long)i);
|
||||
return(GC_oom_action());
|
||||
return GC_oom_fn(WORDS_TO_BYTES(lw));
|
||||
}
|
||||
*((void **)((ptr_t)result + sizeof(oh))) = ptr_to_struct_containing_descr;
|
||||
UNLOCK();
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
* level tree.
|
||||
*/
|
||||
|
||||
# include "gc_priv.h"
|
||||
# include "private/gc_priv.h"
|
||||
|
||||
bottom_index * GC_all_bottom_indices = 0;
|
||||
/* Pointer to first (lowest addr) */
|
||||
|
@ -260,7 +260,7 @@ register word sz; /* bytes */
|
|||
/* Apply fn to all allocated blocks */
|
||||
/*VARARGS1*/
|
||||
void GC_apply_to_all_blocks(fn, client_data)
|
||||
void (*fn)(/* struct hblk *h, word client_data */);
|
||||
void (*fn) GC_PROTO((struct hblk *h, word client_data));
|
||||
word client_data;
|
||||
{
|
||||
register int j;
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
/* Conditionally execute a command based on machine and OS from gcconfig.h */
|
||||
|
||||
# include "gcconfig.h"
|
||||
# include "private/gcconfig.h"
|
||||
# include <stdio.h>
|
||||
# include <string.h>
|
||||
# include <unistd.h>
|
||||
|
||||
int main(argc, argv, envp)
|
||||
int argc;
|
||||
|
@ -13,6 +15,7 @@ char ** envp;
|
|||
if (strcmp(OS_TYPE, "") != 0 && strcmp(argv[2], "") != 0
|
||||
&& strcmp(OS_TYPE, argv[2]) != 0) return(0);
|
||||
printf("^^^^Starting command^^^^\n");
|
||||
fflush(stdout);
|
||||
execvp(argv[3], argv+3);
|
||||
perror("Couldn't execute");
|
||||
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
/* Conditionally execute a command based if the file argv[1] doesn't exist */
|
||||
/* Except for execvp, we stick to ANSI C. */
|
||||
# include "gcconfig.h"
|
||||
# include "private/gcconfig.h"
|
||||
# include <stdio.h>
|
||||
# include <stdlib.h>
|
||||
# include <unistd.h>
|
||||
|
||||
int main(argc, argv, envp)
|
||||
int argc;
|
||||
|
@ -16,6 +18,7 @@ char ** envp;
|
|||
return(0);
|
||||
}
|
||||
printf("^^^^Starting command^^^^\n");
|
||||
fflush(stdout);
|
||||
execvp(argv[2], argv+2);
|
||||
exit(1);
|
||||
|
||||
|
|
|
@ -1,63 +0,0 @@
|
|||
/*
|
||||
* This is a simple API to implement pointer back tracing, i.e.
|
||||
* to answer questions such as "who is pointing to this" or
|
||||
* "why is this object being retained by the collector"
|
||||
*
|
||||
* This API assumes that we have an ANSI C compiler.
|
||||
*
|
||||
* Most of these calls yield useful information on only after
|
||||
* a garbage collection. Usually the client will first force
|
||||
* a full collection and then gather information, preferably
|
||||
* before much intervening allocation.
|
||||
*
|
||||
* The implementation of the interface is only about 99.9999%
|
||||
* correct. It is intended to be good enough for profiling,
|
||||
* but is not intended to be used with production code.
|
||||
*
|
||||
* Results are likely to be much more useful if all allocation is
|
||||
* accomplished through the debugging allocators.
|
||||
*
|
||||
* The implementation idea is due to A. Demers.
|
||||
*/
|
||||
|
||||
/* Store information about the object referencing dest in *base_p */
|
||||
/* and *offset_p. */
|
||||
/* If multiple objects or roots point to dest, the one reported */
|
||||
/* will be the last on used by the garbage collector to trace the */
|
||||
/* object. */
|
||||
/* source is root ==> *base_p = address, *offset_p = 0 */
|
||||
/* source is heap object ==> *base_p != 0, *offset_p = offset */
|
||||
/* Returns 1 on success, 0 if source couldn't be determined. */
|
||||
/* Dest can be any address within a heap object. */
|
||||
typedef enum { GC_UNREFERENCED, /* No reference info available. */
|
||||
GC_NO_SPACE, /* Dest not allocated with debug alloc */
|
||||
GC_REFD_FROM_ROOT, /* Referenced directly by root *base_p */
|
||||
GC_REFD_FROM_REG, /* Referenced from a register, i.e. */
|
||||
/* a root without an address. */
|
||||
GC_REFD_FROM_HEAP, /* Referenced from another heap obj. */
|
||||
GC_FINALIZER_REFD /* Finalizable and hence accessible. */
|
||||
} GC_ref_kind;
|
||||
|
||||
GC_ref_kind GC_get_back_ptr_info(void *dest, void **base_p, size_t *offset_p);
|
||||
|
||||
/* Generate a random heap address. */
|
||||
/* The resulting address is in the heap, but */
|
||||
/* not necessarily inside a valid object. */
|
||||
void * GC_generate_random_heap_address(void);
|
||||
|
||||
/* Generate a random address inside a valid marked heap object. */
|
||||
void * GC_generate_random_valid_address(void);
|
||||
|
||||
/* Force a garbage collection and generate a backtrace from a */
|
||||
/* random heap address. */
|
||||
/* This uses the GC logging mechanism (GC_printf) to produce */
|
||||
/* output. It can often be called from a debugger. The */
|
||||
/* source in dbg_mlc.c also serves as a sample client. */
|
||||
void GC_generate_random_backtrace(void);
|
||||
|
||||
/* Print a backtrace from a specific address. Used by the */
|
||||
/* above. The client should call GC_gcollect() immediately */
|
||||
/* before invocation. */
|
||||
void GC_print_backtrace(void *);
|
||||
|
||||
|
|
@ -1,26 +0,0 @@
|
|||
|
||||
/*
|
||||
* Copyright (c) 1999 by Silicon Graphics. All rights reserved.
|
||||
*
|
||||
* THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED
|
||||
* OR IMPLIED. ANY USE IS AT YOUR OWN RISK.
|
||||
*
|
||||
* Permission is hereby granted to use or copy this program
|
||||
* for any purpose, provided the above notices are retained on all copies.
|
||||
* Permission to modify the code and to distribute modified code is granted,
|
||||
* provided the above notices are retained, and a notice that the code was
|
||||
* modified is included with the above copyright notice.
|
||||
*/
|
||||
/* Descriptor for allocation request. May be redefined by client. */
|
||||
typedef struct {
|
||||
GC_word bitmap; /* Bitmap describing pointer locations. */
|
||||
/* High order bit correspond to 0th */
|
||||
/* word. 2 lsbs must be 0. */
|
||||
size_t length; /* In bytes, must be multiple of word */
|
||||
/* size. Must be >0, <= 512 */
|
||||
} * GC_copy_descriptor;
|
||||
|
||||
/* The collector accesses descriptors only through these two macros. */
|
||||
#define GC_SIZE_FROM_DESCRIPTOR(d) ((d) -> length)
|
||||
#define GC_BIT_MAP_FROM_DESCRIPTOR(d) ((d) -> bitmap)
|
||||
|
|
@ -1,90 +0,0 @@
|
|||
|
||||
/*
|
||||
* Copyright (c) 1999 by Silicon Graphics. All rights reserved.
|
||||
*
|
||||
* THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED
|
||||
* OR IMPLIED. ANY USE IS AT YOUR OWN RISK.
|
||||
*
|
||||
* Permission is hereby granted to use or copy this program
|
||||
* for any purpose, provided the above notices are retained on all copies.
|
||||
* Permission to modify the code and to distribute modified code is granted,
|
||||
* provided the above notices are retained, and a notice that the code was
|
||||
* modified is included with the above copyright notice.
|
||||
*/
|
||||
|
||||
/*
|
||||
* THIS IMPLEMENTATION FOR THIS INTERFACE IS INCOMPLETE.
|
||||
* NONE OF THIS HAS BEEN TESTED. DO NOT USE.
|
||||
*
|
||||
* Comments on the interface are appreciated, especially from
|
||||
* potential users of the interface.
|
||||
*
|
||||
* This is a Bartlett style copying collector for young objects.
|
||||
* We assume for now that all objects allocated through this
|
||||
* mechanism have pointers only in the first BITMAP_BITS words.
|
||||
* (On a 32-bit machine, BITMAP_BITS is 30.)
|
||||
* Objects allocated in this manner should be rarely referenced
|
||||
* by objects not allocated either through this interface, or through
|
||||
* the typed allocation interface.
|
||||
* If this interface is used, we assume that type information provided
|
||||
* through either this or the typed allocation interface is valid
|
||||
* in a stronger sense:
|
||||
*
|
||||
* 1) No pointers are stored in fields not marked as such.
|
||||
* (Otherwise it is only necessary that objects referenced by
|
||||
* fields marked as nonpointers are also reachable via another
|
||||
* path.)
|
||||
* 2) Values stored in pointer fields are either not addresses in
|
||||
* the heap, or they really are pointers. In the latter case, it
|
||||
* is acceptable to move the object they refer to, and to update
|
||||
* the pointer.
|
||||
*
|
||||
* GC_free may not be invoked on objects allocated with GC_copying_malloc.
|
||||
*
|
||||
* No extra space is added to the end of objects allocated through this
|
||||
* interface. If the client needs to maintain pointers past the
|
||||
* end, the size should be explicitly padded.
|
||||
*
|
||||
* We assume that calls to this will usually be compiler generated.
|
||||
* Hence the interface is allowed to be a bit ugly in return for speed.
|
||||
*/
|
||||
|
||||
#include "gc_copy_descr.h"
|
||||
|
||||
/* GC_copy_descr.h must define */
|
||||
/* GC_SIZE_FROM_DESCRIPTOR(descr) and */
|
||||
/* GC_BIT_MAP_FROM_DESCRIPTOR(descr). */
|
||||
/* It may either be the GC supplied version of the header file, or a */
|
||||
/* client specific one that derives the information from a client- */
|
||||
/* specific type descriptor. */
|
||||
|
||||
typedef GC_PTR GC_copy_alloc_state;
|
||||
/* Current allocator state. */
|
||||
/* Multiple allocation states */
|
||||
/* may be used for concurrent */
|
||||
/* allocation, or to enhance */
|
||||
/* locality. */
|
||||
/* Should be treated as opaque. */
|
||||
|
||||
/* Allocate a memory block of size given in the descriptor, and with */
|
||||
/* pointer layout given by the descriptor. The resulting block may not */
|
||||
/* be cleared, and should immediately be initialized by the client. */
|
||||
/* (A concurrent GC may see an uninitialized pointer field. If it */
|
||||
/* points outside the nursery, that's fine. If it points inside, it */
|
||||
/* may retain an object, and be relocated. But that's also fine, since */
|
||||
/* the new value will be immediately overwritten. */
|
||||
/* This variant acquires the allocation lock, and uses a default */
|
||||
/* global allocation state. */
|
||||
GC_PTR GC_copying_malloc(GC_copy_descriptor);
|
||||
|
||||
/* A variant of the above that does no locking on the fast path, */
|
||||
/* and passes an explicit pointer to an allocation state. */
|
||||
/* The allocation state is updated. */
|
||||
/* There will eventually need to be a macro or inline function version */
|
||||
/* of this. */
|
||||
GC_PTR GC_copying_malloc2(GC_copy_descriptor, GC_copy_alloc_state *);
|
||||
|
||||
/* Initialize an allocation state so that it can be used for */
|
||||
/* allocation. This implicitly reserves a small section of the */
|
||||
/* nursery for use with this allocator. */
|
||||
void GC_init_copy_alloc_state(GC_copy_alloc_state *);
|
|
@ -132,9 +132,14 @@ extern mse * GC_mark_stack;
|
|||
*/
|
||||
#endif /* PARALLEL_MARK */
|
||||
|
||||
ptr_t GC_find_start();
|
||||
# ifdef PRINT_BLACK_LIST
|
||||
ptr_t GC_find_start(ptr_t current, hdr *hhdr, word source);
|
||||
# else
|
||||
ptr_t GC_find_start(ptr_t current, hdr *hhdr);
|
||||
# define source 0
|
||||
# endif
|
||||
|
||||
mse * GC_signal_mark_stack_overflow();
|
||||
mse *GC_signal_mark_stack_overflow(mse *msp);
|
||||
|
||||
# ifdef GATHERSTATS
|
||||
# define ADD_TO_ATOMIC(sz) GC_atomic_in_use += (sz)
|
||||
|
@ -245,7 +250,6 @@ exit_label2: ; \
|
|||
# define SET_MARK_BIT_EXIT_IF_SET(hhdr,displ,exit_label) \
|
||||
{ \
|
||||
register word * mark_word_addr = hhdr -> hb_marks + divWORDSZ(displ); \
|
||||
register word mark_word = *mark_word_addr; \
|
||||
\
|
||||
OR_WORD_EXIT_IF_SET(mark_word_addr, (word)1 << modWORDSZ(displ), \
|
||||
exit_label); \
|
||||
|
|
|
@ -25,13 +25,9 @@
|
|||
* there too.
|
||||
*/
|
||||
|
||||
# if defined(IRIX_THREADS) || defined(HPUX_THREADS)
|
||||
# if defined(GC_IRIX_THREADS) || defined(IRIX_THREADS)
|
||||
|
||||
# if defined(HPUX_THREADS)
|
||||
# include <sys/semaphore.h>
|
||||
# endif
|
||||
|
||||
# include "gc_priv.h"
|
||||
# include "private/gc_priv.h"
|
||||
# include <pthread.h>
|
||||
# include <semaphore.h>
|
||||
# include <time.h>
|
||||
|
@ -43,6 +39,7 @@
|
|||
#undef pthread_create
|
||||
#undef pthread_sigmask
|
||||
#undef pthread_join
|
||||
#undef pthread_detach
|
||||
|
||||
void GC_thr_init();
|
||||
|
||||
|
@ -208,6 +205,11 @@ void GC_stack_free(ptr_t stack, size_t size)
|
|||
# define THREAD_TABLE_SZ 128 /* Must be power of 2 */
|
||||
volatile GC_thread GC_threads[THREAD_TABLE_SZ];
|
||||
|
||||
void GC_push_thread_structures GC_PROTO((void))
|
||||
{
|
||||
GC_push_all((ptr_t)(GC_threads), (ptr_t)(GC_threads)+sizeof(GC_threads));
|
||||
}
|
||||
|
||||
/* Add a thread to GC_threads. We assume it wasn't already there. */
|
||||
/* Caller holds allocation lock. */
|
||||
GC_thread GC_new_thread(pthread_t id)
|
||||
|
@ -223,7 +225,7 @@ GC_thread GC_new_thread(pthread_t id)
|
|||
/* Dont acquire allocation lock, since we may already hold it. */
|
||||
} else {
|
||||
result = (struct GC_Thread_Rep *)
|
||||
GC_generic_malloc_inner(sizeof(struct GC_Thread_Rep), NORMAL);
|
||||
GC_INTERNAL_MALLOC(sizeof(struct GC_Thread_Rep), NORMAL);
|
||||
}
|
||||
if (result == 0) return(0);
|
||||
result -> id = id;
|
||||
|
@ -503,10 +505,33 @@ int GC_pthread_join(pthread_t thread, void **retval)
|
|||
/* Some versions of the Irix pthreads library can erroneously */
|
||||
/* return EINTR when the call succeeds. */
|
||||
if (EINTR == result) result = 0;
|
||||
if (result == 0) {
|
||||
LOCK();
|
||||
/* Here the pthread thread id may have been recycled. */
|
||||
GC_delete_gc_thread(thread, thread_gc_id);
|
||||
UNLOCK();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
int GC_pthread_detach(pthread_t thread)
|
||||
{
|
||||
int result;
|
||||
GC_thread thread_gc_id;
|
||||
|
||||
LOCK();
|
||||
/* Here the pthread thread id may have been recycled. */
|
||||
GC_delete_gc_thread(thread, thread_gc_id);
|
||||
thread_gc_id = GC_lookup_thread(thread);
|
||||
UNLOCK();
|
||||
result = REAL_FUNC(pthread_detach)(thread);
|
||||
if (result == 0) {
|
||||
LOCK();
|
||||
thread_gc_id -> flags |= DETACHED;
|
||||
/* Here the pthread thread id may have been recycled. */
|
||||
if (thread_gc_id -> flags & FINISHED) {
|
||||
GC_delete_gc_thread(thread, thread_gc_id);
|
||||
}
|
||||
UNLOCK();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -552,39 +577,7 @@ void * GC_start_routine(void * arg)
|
|||
return(result);
|
||||
}
|
||||
|
||||
# ifdef HPUX_THREADS
|
||||
/* pthread_attr_t is not a structure, thus a simple structure copy */
|
||||
/* won't work. */
|
||||
static void copy_attr(pthread_attr_t * pa_ptr,
|
||||
const pthread_attr_t * source) {
|
||||
int tmp;
|
||||
size_t stmp;
|
||||
void * vtmp;
|
||||
struct sched_param sp_tmp;
|
||||
pthread_spu_t ps_tmp;
|
||||
(void) pthread_attr_init(pa_ptr);
|
||||
(void) pthread_attr_getdetachstate(source, &tmp);
|
||||
(void) pthread_attr_setdetachstate(pa_ptr, tmp);
|
||||
(void) pthread_attr_getinheritsched(source, &tmp);
|
||||
(void) pthread_attr_setinheritsched(pa_ptr, tmp);
|
||||
(void) pthread_attr_getschedpolicy(source, &tmp);
|
||||
(void) pthread_attr_setschedpolicy(pa_ptr, tmp);
|
||||
(void) pthread_attr_getstacksize(source, &stmp);
|
||||
(void) pthread_attr_setstacksize(pa_ptr, stmp);
|
||||
(void) pthread_attr_getguardsize(source, &stmp);
|
||||
(void) pthread_attr_setguardsize(pa_ptr, stmp);
|
||||
(void) pthread_attr_getstackaddr(source, &vtmp);
|
||||
(void) pthread_attr_setstackaddr(pa_ptr, vtmp);
|
||||
(void) pthread_attr_getscope(source, &tmp);
|
||||
(void) pthread_attr_setscope(pa_ptr, tmp);
|
||||
(void) pthread_attr_getschedparam(source, &sp_tmp);
|
||||
(void) pthread_attr_setschedparam(pa_ptr, &sp_tmp);
|
||||
(void) pthread_attr_getprocessor_np(source, &ps_tmp, &tmp);
|
||||
(void) pthread_attr_setprocessor_np(pa_ptr, ps_tmp, tmp);
|
||||
}
|
||||
# else
|
||||
# define copy_attr(pa_ptr, source) *(pa_ptr) = *(source)
|
||||
# endif
|
||||
# define copy_attr(pa_ptr, source) *(pa_ptr) = *(source)
|
||||
|
||||
int
|
||||
GC_pthread_create(pthread_t *new_thread,
|
||||
|
@ -650,14 +643,12 @@ GC_pthread_create(pthread_t *new_thread,
|
|||
}
|
||||
}
|
||||
sem_destroy(&(si -> registered));
|
||||
pthread_attr_destroy(&new_attr); /* Not a no-op under HPUX */
|
||||
pthread_attr_destroy(&new_attr); /* Probably unnecessary under Irix */
|
||||
return(result);
|
||||
}
|
||||
|
||||
#ifndef HPUX_THREADS
|
||||
/* For now we use the pthreads locking primitives on HP/UX */
|
||||
|
||||
GC_bool GC_collecting = 0; /* A hint that we're in the collector and */
|
||||
VOLATILE GC_bool GC_collecting = 0;
|
||||
/* A hint that we're in the collector and */
|
||||
/* holding the allocation lock for an */
|
||||
/* extended period. */
|
||||
|
||||
|
@ -666,15 +657,9 @@ GC_bool GC_collecting = 0; /* A hint that we're in the collector and */
|
|||
|
||||
#define SLEEP_THRESHOLD 3
|
||||
|
||||
#ifdef HPUX
|
||||
unsigned long GC_allocate_lock = 1;
|
||||
# define GC_TRY_LOCK() GC_test_and_clear(&GC_allocate_lock)
|
||||
# define GC_LOCK_TAKEN !GC_allocate_lock
|
||||
#else
|
||||
unsigned long GC_allocate_lock = 0;
|
||||
# define GC_TRY_LOCK() !GC_test_and_set(&GC_allocate_lock,1)
|
||||
# define GC_LOCK_TAKEN GC_allocate_lock
|
||||
#endif
|
||||
unsigned long GC_allocate_lock = 0;
|
||||
# define GC_TRY_LOCK() !GC_test_and_set(&GC_allocate_lock,1)
|
||||
# define GC_LOCK_TAKEN GC_allocate_lock
|
||||
|
||||
void GC_lock()
|
||||
{
|
||||
|
@ -734,8 +719,6 @@ yield:
|
|||
}
|
||||
}
|
||||
|
||||
#endif /* !HPUX_THREADS */
|
||||
|
||||
# else
|
||||
|
||||
#ifndef LINT
|
File diff suppressed because it is too large
Load diff
|
@ -12,7 +12,7 @@
|
|||
* modified is included with the above copyright notice.
|
||||
*/
|
||||
/* Boehm, November 17, 1995 12:13 pm PST */
|
||||
# include "gc_priv.h"
|
||||
# include "private/gc_priv.h"
|
||||
# include <stdio.h>
|
||||
# include <setjmp.h>
|
||||
# if defined(OS2) || defined(CX_UX)
|
||||
|
@ -21,7 +21,7 @@
|
|||
# endif
|
||||
# ifdef AMIGA
|
||||
# ifndef __GNUC__
|
||||
# include <dos/dos.h>
|
||||
# include <dos.h>
|
||||
# else
|
||||
# include <machine/reg.h>
|
||||
# endif
|
||||
|
@ -178,7 +178,10 @@ void GC_push_regs()
|
|||
# else /* !__GNUC__ */
|
||||
GC_push_one(getreg(REG_A2));
|
||||
GC_push_one(getreg(REG_A3));
|
||||
GC_push_one(getreg(REG_A4));
|
||||
# ifndef __SASC
|
||||
/* Can probably be changed to #if 0 -Kjetil M. (a4=globals)*/
|
||||
GC_push_one(getreg(REG_A4));
|
||||
# endif
|
||||
GC_push_one(getreg(REG_A5));
|
||||
GC_push_one(getreg(REG_A6));
|
||||
/* Skip stack pointer */
|
||||
|
@ -220,8 +223,11 @@ void GC_push_regs()
|
|||
# if defined(I386) &&!defined(OS2) &&!defined(SVR4) \
|
||||
&& (defined(__MINGW32__) || !defined(MSWIN32)) \
|
||||
&& !defined(SCO) && !defined(SCO_ELF) \
|
||||
&& !(defined(LINUX) && defined(__ELF__)) \
|
||||
&& !(defined(LINUX) && defined(__ELF__)) \
|
||||
&& !(defined(FREEBSD) && defined(__ELF__)) \
|
||||
&& !(defined(NETBSD) && defined(__ELF__)) \
|
||||
&& !(defined(OPENBSD) && defined(__ELF__)) \
|
||||
&& !(defined(BEOS) && defined(__ELF__)) \
|
||||
&& !defined(DOS4GW)
|
||||
/* I386 code, generic code does not appear to work */
|
||||
/* It does appear to work under OS2, and asms dont */
|
||||
|
@ -236,7 +242,9 @@ void GC_push_regs()
|
|||
# endif
|
||||
|
||||
# if ( defined(I386) && defined(LINUX) && defined(__ELF__) ) \
|
||||
|| ( defined(I386) && defined(FREEBSD) && defined(__ELF__) )
|
||||
|| ( defined(I386) && defined(FREEBSD) && defined(__ELF__) ) \
|
||||
|| ( defined(I386) && defined(NETBSD) && defined(__ELF__) ) \
|
||||
|| ( defined(I386) && defined(OPENBSD) && defined(__ELF__) )
|
||||
|
||||
/* This is modified for Linux with ELF (Note: _ELF_ only) */
|
||||
/* This section handles FreeBSD with ELF. */
|
||||
|
@ -253,6 +261,17 @@ void GC_push_regs()
|
|||
asm("pushl %ebx; call GC_push_one; addl $4,%esp");
|
||||
# endif
|
||||
|
||||
# if ( defined(I386) && defined(BEOS) && defined(__ELF__) )
|
||||
/* As far as I can understand from */
|
||||
/* http://www.beunited.org/articles/jbq/nasm.shtml, */
|
||||
/* only ebp, esi, edi and ebx are not scratch. How MMX */
|
||||
/* etc. registers should be treated, I have no idea. */
|
||||
asm("pushl %ebp; call GC_push_one; addl $4,%esp");
|
||||
asm("pushl %esi; call GC_push_one; addl $4,%esp");
|
||||
asm("pushl %edi; call GC_push_one; addl $4,%esp");
|
||||
asm("pushl %ebx; call GC_push_one; addl $4,%esp");
|
||||
# endif
|
||||
|
||||
# if defined(I386) && defined(MSWIN32) && !defined(__MINGW32__) \
|
||||
&& !defined(USE_GENERIC)
|
||||
/* I386 code, Microsoft variant */
|
||||
|
@ -402,7 +421,8 @@ ptr_t cold_gc_frame;
|
|||
for (; (char *)i < lim; i++) {
|
||||
*i = 0;
|
||||
}
|
||||
# if defined(POWERPC) || defined(MSWIN32) || defined(UTS4) || defined(LINUX)
|
||||
# if defined(POWERPC) || defined(MSWIN32) || defined(MSWINCE) \
|
||||
|| defined(UTS4) || defined(LINUX)
|
||||
(void) setjmp(regs);
|
||||
# else
|
||||
(void) _setjmp(regs);
|
||||
|
@ -438,15 +458,15 @@ ptr_t cold_gc_frame;
|
|||
asm("_GC_save_regs_in_stack:");
|
||||
# endif
|
||||
# if defined(__arch64__) || defined(__sparcv9)
|
||||
asm(" save %sp,-128,%sp");
|
||||
asm(" flushw");
|
||||
asm(" ret");
|
||||
asm(" restore %sp,2047+128,%o0");
|
||||
asm(" save %sp,-128,%sp");
|
||||
asm(" flushw");
|
||||
asm(" ret");
|
||||
asm(" restore %sp,2047+128,%o0");
|
||||
# else
|
||||
asm(" ta 0x3 ! ST_FLUSH_WINDOWS");
|
||||
asm(" retl");
|
||||
asm(" mov %sp,%o0");
|
||||
#endif
|
||||
asm(" ta 0x3 ! ST_FLUSH_WINDOWS");
|
||||
asm(" retl");
|
||||
asm(" mov %sp,%o0");
|
||||
# endif
|
||||
# ifdef SVR4
|
||||
asm(" .GC_save_regs_in_stack_end:");
|
||||
asm(" .size GC_save_regs_in_stack,.GC_save_regs_in_stack_end-GC_save_regs_in_stack");
|
||||
|
@ -460,6 +480,7 @@ ptr_t cold_gc_frame;
|
|||
/* up on the other side of the stack segment. */
|
||||
/* Returns the backing store pointer for the register stack. */
|
||||
# ifdef IA64
|
||||
# ifdef __GNUC__
|
||||
asm(" .text");
|
||||
asm(" .psr abi64");
|
||||
asm(" .psr lsb");
|
||||
|
@ -476,6 +497,14 @@ ptr_t cold_gc_frame;
|
|||
asm(" mov r8=ar.bsp");
|
||||
asm(" br.ret.sptk.few rp");
|
||||
asm(" .endp GC_save_regs_in_stack");
|
||||
# else
|
||||
void GC_save_regs_in_stack() {
|
||||
asm(" flushrs");
|
||||
asm(" ;;");
|
||||
asm(" mov r8=ar.bsp");
|
||||
asm(" br.ret.sptk.few rp");
|
||||
}
|
||||
# endif
|
||||
# endif
|
||||
|
||||
/* GC_clear_stack_inner(arg, limit) clears stack area up to limit and */
|
||||
|
@ -523,7 +552,7 @@ ptr_t cold_gc_frame;
|
|||
asm("add %o3,-8,%o3"); /* p -= 8 (delay slot) */
|
||||
asm("retl");
|
||||
asm("mov %o2,%sp"); /* Restore sp., delay slot */
|
||||
#endif
|
||||
#endif /* old SPARC */
|
||||
/* First argument = %o0 = return value */
|
||||
# ifdef SVR4
|
||||
asm(" .GC_clear_stack_inner_end:");
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
/*
|
||||
* Copyright 1988, 1989 Hans-J. Boehm, Alan J. Demers
|
||||
* Copyright (c) 1991-1994 by Xerox Corporation. All rights reserved.
|
||||
* Copyright (c) 2000 by Hewlett-Packard Company. All rights reserved.
|
||||
*
|
||||
* THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED
|
||||
* OR IMPLIED. ANY USE IS AT YOUR OWN RISK.
|
||||
|
@ -14,7 +15,7 @@
|
|||
/* Boehm, February 7, 1996 4:32 pm PST */
|
||||
|
||||
#include <stdio.h>
|
||||
#include "gc_priv.h"
|
||||
#include "private/gc_priv.h"
|
||||
|
||||
extern ptr_t GC_clear_stack(); /* in misc.c, behaves like identity */
|
||||
void GC_extend_size_map(); /* in misc.c. */
|
||||
|
@ -32,7 +33,66 @@ register struct obj_kind * kind;
|
|||
return(TRUE);
|
||||
}
|
||||
|
||||
/* allocate lb bytes for an object of kind. */
|
||||
/* Allocate a large block of size lw words. */
|
||||
/* The block is not cleared. */
|
||||
/* Flags is 0 or IGNORE_OFF_PAGE. */
|
||||
ptr_t GC_alloc_large(lw, k, flags)
|
||||
word lw;
|
||||
int k;
|
||||
unsigned flags;
|
||||
{
|
||||
struct hblk * h;
|
||||
word n_blocks = OBJ_SZ_TO_BLOCKS(lw);
|
||||
ptr_t result;
|
||||
|
||||
if (!GC_is_initialized) GC_init_inner();
|
||||
/* Do our share of marking work */
|
||||
if(GC_incremental && !GC_dont_gc)
|
||||
GC_collect_a_little_inner((int)n_blocks);
|
||||
h = GC_allochblk(lw, k, flags);
|
||||
# ifdef USE_MUNMAP
|
||||
if (0 == h) {
|
||||
GC_merge_unmapped();
|
||||
h = GC_allochblk(lw, k, flags);
|
||||
}
|
||||
# endif
|
||||
while (0 == h && GC_collect_or_expand(n_blocks, (flags != 0))) {
|
||||
h = GC_allochblk(lw, k, flags);
|
||||
}
|
||||
if (h == 0) {
|
||||
result = 0;
|
||||
} else {
|
||||
int total_bytes = BYTES_TO_WORDS(n_blocks * HBLKSIZE);
|
||||
if (n_blocks > 1) {
|
||||
GC_large_allocd_bytes += n_blocks * HBLKSIZE;
|
||||
if (GC_large_allocd_bytes > GC_max_large_allocd_bytes)
|
||||
GC_max_large_allocd_bytes = GC_large_allocd_bytes;
|
||||
}
|
||||
result = (ptr_t) (h -> hb_body);
|
||||
GC_words_wasted += total_bytes - lw;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/* Allocate a large block of size lb bytes. Clear if appropriate. */
|
||||
ptr_t GC_alloc_large_and_clear(lw, k, flags)
|
||||
word lw;
|
||||
int k;
|
||||
unsigned flags;
|
||||
{
|
||||
ptr_t result = GC_alloc_large(lw, k, flags);
|
||||
word n_blocks = OBJ_SZ_TO_BLOCKS(lw);
|
||||
|
||||
if (0 == result) return 0;
|
||||
if (GC_debugging_started || GC_obj_kinds[k].ok_init) {
|
||||
/* Clear the whole block, in case of GC_realloc call. */
|
||||
BZERO(result, n_blocks * HBLKSIZE);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/* allocate lb bytes for an object of kind k. */
|
||||
/* Should not be used to directly to allocate */
|
||||
/* objects such as STUBBORN objects that */
|
||||
/* require special handling on allocation. */
|
||||
|
@ -88,36 +148,31 @@ register ptr_t *opp;
|
|||
*opp = obj_link(op);
|
||||
obj_link(op) = 0;
|
||||
} else {
|
||||
register struct hblk * h;
|
||||
register word n_blocks = divHBLKSZ(ADD_SLOP(lb)
|
||||
+ HDR_BYTES + HBLKSIZE-1);
|
||||
|
||||
if (!GC_is_initialized) GC_init_inner();
|
||||
/* Do our share of marking work */
|
||||
if(GC_incremental && !GC_dont_gc)
|
||||
GC_collect_a_little_inner((int)n_blocks);
|
||||
lw = ROUNDED_UP_WORDS(lb);
|
||||
h = GC_allochblk(lw, k, 0);
|
||||
# ifdef USE_MUNMAP
|
||||
if (0 == h) {
|
||||
GC_merge_unmapped();
|
||||
h = GC_allochblk(lw, k, 0);
|
||||
}
|
||||
# endif
|
||||
while (0 == h && GC_collect_or_expand(n_blocks, FALSE)) {
|
||||
h = GC_allochblk(lw, k, 0);
|
||||
}
|
||||
if (h == 0) {
|
||||
op = 0;
|
||||
} else {
|
||||
op = (ptr_t) (h -> hb_body);
|
||||
GC_words_wasted += BYTES_TO_WORDS(n_blocks * HBLKSIZE) - lw;
|
||||
}
|
||||
op = (ptr_t)GC_alloc_large_and_clear(lw, k, 0);
|
||||
}
|
||||
GC_words_allocd += lw;
|
||||
|
||||
out:
|
||||
return((ptr_t)op);
|
||||
return op;
|
||||
}
|
||||
|
||||
/* Allocate a composite object of size n bytes. The caller guarantees */
|
||||
/* that pointers past the first page are not relevant. Caller holds */
|
||||
/* allocation lock. */
|
||||
ptr_t GC_generic_malloc_inner_ignore_off_page(lb, k)
|
||||
register size_t lb;
|
||||
register int k;
|
||||
{
|
||||
register word lw;
|
||||
ptr_t op;
|
||||
|
||||
if (lb <= HBLKSIZE)
|
||||
return(GC_generic_malloc_inner((word)lb, k));
|
||||
lw = ROUNDED_UP_WORDS(lb);
|
||||
op = (ptr_t)GC_alloc_large_and_clear(lw, k, IGNORE_OFF_PAGE);
|
||||
GC_words_allocd += lw;
|
||||
return op;
|
||||
}
|
||||
|
||||
ptr_t GC_generic_malloc(lb, k)
|
||||
|
@ -128,11 +183,43 @@ register int k;
|
|||
DCL_LOCK_STATE;
|
||||
|
||||
GC_INVOKE_FINALIZERS();
|
||||
DISABLE_SIGNALS();
|
||||
LOCK();
|
||||
result = GC_generic_malloc_inner(lb, k);
|
||||
UNLOCK();
|
||||
ENABLE_SIGNALS();
|
||||
if (SMALL_OBJ(lb)) {
|
||||
DISABLE_SIGNALS();
|
||||
LOCK();
|
||||
result = GC_generic_malloc_inner((word)lb, k);
|
||||
UNLOCK();
|
||||
ENABLE_SIGNALS();
|
||||
} else {
|
||||
word lw;
|
||||
word n_blocks;
|
||||
GC_bool init;
|
||||
lw = ROUNDED_UP_WORDS(lb);
|
||||
n_blocks = OBJ_SZ_TO_BLOCKS(lw);
|
||||
init = GC_obj_kinds[k].ok_init;
|
||||
DISABLE_SIGNALS();
|
||||
LOCK();
|
||||
result = (ptr_t)GC_alloc_large(lw, k, 0);
|
||||
if (0 != result) {
|
||||
if (GC_debugging_started) {
|
||||
BZERO(result, n_blocks * HBLKSIZE);
|
||||
} else {
|
||||
# ifdef THREADS
|
||||
/* Clear any memory that might be used for GC descriptors */
|
||||
/* before we release the lock. */
|
||||
((word *)result)[0] = 0;
|
||||
((word *)result)[1] = 0;
|
||||
((word *)result)[lw-1] = 0;
|
||||
((word *)result)[lw-2] = 0;
|
||||
# endif
|
||||
}
|
||||
}
|
||||
GC_words_allocd += lw;
|
||||
UNLOCK();
|
||||
ENABLE_SIGNALS();
|
||||
if (init & !GC_debugging_started && 0 != result) {
|
||||
BZERO(result, n_blocks * HBLKSIZE);
|
||||
}
|
||||
}
|
||||
if (0 == result) {
|
||||
return((*GC_oom_fn)(lb));
|
||||
} else {
|
||||
|
@ -159,7 +246,7 @@ register ptr_t * opp;
|
|||
register word lw;
|
||||
DCL_LOCK_STATE;
|
||||
|
||||
if( SMALL_OBJ(lb) ) {
|
||||
if( EXPECT(SMALL_OBJ(lb), 1) ) {
|
||||
# ifdef MERGE_SIZES
|
||||
lw = GC_size_map[lb];
|
||||
# else
|
||||
|
@ -167,7 +254,7 @@ DCL_LOCK_STATE;
|
|||
# endif
|
||||
opp = &(GC_aobjfreelist[lw]);
|
||||
FASTLOCK();
|
||||
if( !FASTLOCK_SUCCEEDED() || (op = *opp) == 0 ) {
|
||||
if( EXPECT(!FASTLOCK_SUCCEEDED() || (op = *opp) == 0, 0) ) {
|
||||
FASTUNLOCK();
|
||||
return(GENERAL_MALLOC((word)lb, PTRFREE));
|
||||
}
|
||||
|
@ -194,7 +281,7 @@ register ptr_t *opp;
|
|||
register word lw;
|
||||
DCL_LOCK_STATE;
|
||||
|
||||
if( SMALL_OBJ(lb) ) {
|
||||
if( EXPECT(SMALL_OBJ(lb), 1) ) {
|
||||
# ifdef MERGE_SIZES
|
||||
lw = GC_size_map[lb];
|
||||
# else
|
||||
|
@ -202,7 +289,7 @@ DCL_LOCK_STATE;
|
|||
# endif
|
||||
opp = &(GC_objfreelist[lw]);
|
||||
FASTLOCK();
|
||||
if( !FASTLOCK_SUCCEEDED() || (op = *opp) == 0 ) {
|
||||
if( EXPECT(!FASTLOCK_SUCCEEDED() || (op = *opp) == 0, 0) ) {
|
||||
FASTUNLOCK();
|
||||
return(GENERAL_MALLOC((word)lb, NORMAL));
|
||||
}
|
||||
|
@ -238,7 +325,7 @@ DCL_LOCK_STATE;
|
|||
*/
|
||||
if (!GC_is_initialized) return sbrk(lb);
|
||||
# endif /* I386 && SOLARIS_THREADS */
|
||||
return(REDIRECT_MALLOC(lb));
|
||||
return((GC_PTR)REDIRECT_MALLOC(lb));
|
||||
}
|
||||
|
||||
# ifdef __STDC__
|
||||
|
@ -248,125 +335,7 @@ DCL_LOCK_STATE;
|
|||
size_t n, lb;
|
||||
# endif
|
||||
{
|
||||
return(REDIRECT_MALLOC(n*lb));
|
||||
}
|
||||
# endif /* REDIRECT_MALLOC */
|
||||
|
||||
GC_PTR GC_generic_or_special_malloc(lb,knd)
|
||||
word lb;
|
||||
int knd;
|
||||
{
|
||||
switch(knd) {
|
||||
# ifdef STUBBORN_ALLOC
|
||||
case STUBBORN:
|
||||
return(GC_malloc_stubborn((size_t)lb));
|
||||
# endif
|
||||
case PTRFREE:
|
||||
return(GC_malloc_atomic((size_t)lb));
|
||||
case NORMAL:
|
||||
return(GC_malloc((size_t)lb));
|
||||
case UNCOLLECTABLE:
|
||||
return(GC_malloc_uncollectable((size_t)lb));
|
||||
# ifdef ATOMIC_UNCOLLECTABLE
|
||||
case AUNCOLLECTABLE:
|
||||
return(GC_malloc_atomic_uncollectable((size_t)lb));
|
||||
# endif /* ATOMIC_UNCOLLECTABLE */
|
||||
default:
|
||||
return(GC_generic_malloc(lb,knd));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Change the size of the block pointed to by p to contain at least */
|
||||
/* lb bytes. The object may be (and quite likely will be) moved. */
|
||||
/* The kind (e.g. atomic) is the same as that of the old. */
|
||||
/* Shrinking of large blocks is not implemented well. */
|
||||
# ifdef __STDC__
|
||||
GC_PTR GC_realloc(GC_PTR p, size_t lb)
|
||||
# else
|
||||
GC_PTR GC_realloc(p,lb)
|
||||
GC_PTR p;
|
||||
size_t lb;
|
||||
# endif
|
||||
{
|
||||
register struct hblk * h;
|
||||
register hdr * hhdr;
|
||||
register word sz; /* Current size in bytes */
|
||||
register word orig_sz; /* Original sz in bytes */
|
||||
int obj_kind;
|
||||
|
||||
if (p == 0) return(GC_malloc(lb)); /* Required by ANSI */
|
||||
h = HBLKPTR(p);
|
||||
hhdr = HDR(h);
|
||||
sz = hhdr -> hb_sz;
|
||||
obj_kind = hhdr -> hb_obj_kind;
|
||||
sz = WORDS_TO_BYTES(sz);
|
||||
orig_sz = sz;
|
||||
|
||||
if (sz > WORDS_TO_BYTES(MAXOBJSZ)) {
|
||||
/* Round it up to the next whole heap block */
|
||||
register word descr;
|
||||
|
||||
sz = (sz+HDR_BYTES+HBLKSIZE-1)
|
||||
& (~HBLKMASK);
|
||||
sz -= HDR_BYTES;
|
||||
hhdr -> hb_sz = BYTES_TO_WORDS(sz);
|
||||
descr = GC_obj_kinds[obj_kind].ok_descriptor;
|
||||
if (GC_obj_kinds[obj_kind].ok_relocate_descr) descr += sz;
|
||||
hhdr -> hb_descr = descr;
|
||||
if (IS_UNCOLLECTABLE(obj_kind)) GC_non_gc_bytes += (sz - orig_sz);
|
||||
/* Extra area is already cleared by allochblk. */
|
||||
}
|
||||
if (ADD_SLOP(lb) <= sz) {
|
||||
if (lb >= (sz >> 1)) {
|
||||
# ifdef STUBBORN_ALLOC
|
||||
if (obj_kind == STUBBORN) GC_change_stubborn(p);
|
||||
# endif
|
||||
if (orig_sz > lb) {
|
||||
/* Clear unneeded part of object to avoid bogus pointer */
|
||||
/* tracing. */
|
||||
/* Safe for stubborn objects. */
|
||||
BZERO(((ptr_t)p) + lb, orig_sz - lb);
|
||||
}
|
||||
return(p);
|
||||
} else {
|
||||
/* shrink */
|
||||
GC_PTR result =
|
||||
GC_generic_or_special_malloc((word)lb, obj_kind);
|
||||
|
||||
if (result == 0) return(0);
|
||||
/* Could also return original object. But this */
|
||||
/* gives the client warning of imminent disaster. */
|
||||
BCOPY(p, result, lb);
|
||||
# ifndef IGNORE_FREE
|
||||
GC_free(p);
|
||||
# endif
|
||||
return(result);
|
||||
}
|
||||
} else {
|
||||
/* grow */
|
||||
GC_PTR result =
|
||||
GC_generic_or_special_malloc((word)lb, obj_kind);
|
||||
|
||||
if (result == 0) return(0);
|
||||
BCOPY(p, result, sz);
|
||||
# ifndef IGNORE_FREE
|
||||
GC_free(p);
|
||||
# endif
|
||||
return(result);
|
||||
}
|
||||
}
|
||||
|
||||
# ifdef REDIRECT_MALLOC
|
||||
# ifdef __STDC__
|
||||
GC_PTR realloc(GC_PTR p, size_t lb)
|
||||
# else
|
||||
GC_PTR realloc(p,lb)
|
||||
GC_PTR p;
|
||||
size_t lb;
|
||||
# endif
|
||||
{
|
||||
return(GC_realloc(p, lb));
|
||||
return((GC_PTR)REDIRECT_MALLOC(n*lb));
|
||||
}
|
||||
# endif /* REDIRECT_MALLOC */
|
||||
|
||||
|
@ -391,15 +360,18 @@ int obj_kind;
|
|||
h = HBLKPTR(p);
|
||||
hhdr = HDR(h);
|
||||
# if defined(REDIRECT_MALLOC) && \
|
||||
(defined(SOLARIS_THREADS) || defined(LINUX_THREADS))
|
||||
/* We have to redirect malloc calls during initialization. */
|
||||
(defined(SOLARIS_THREADS) || defined(LINUX_THREADS) \
|
||||
|| defined(__MINGW32__)) /* Should this be MSWIN32 in general? */
|
||||
/* For Solaris, we have to redirect malloc calls during */
|
||||
/* initialization. For the others, this seems to happen */
|
||||
/* implicitly. */
|
||||
/* Don't try to deallocate that memory. */
|
||||
if (0 == hhdr) return;
|
||||
# endif
|
||||
knd = hhdr -> hb_obj_kind;
|
||||
sz = hhdr -> hb_sz;
|
||||
ok = &GC_obj_kinds[knd];
|
||||
if (sz <= MAXOBJSZ) {
|
||||
if (EXPECT((sz <= MAXOBJSZ), 1)) {
|
||||
# ifdef THREADS
|
||||
DISABLE_SIGNALS();
|
||||
LOCK();
|
||||
|
@ -432,6 +404,42 @@ int obj_kind;
|
|||
}
|
||||
}
|
||||
|
||||
/* Explicitly deallocate an object p when we already hold lock. */
|
||||
/* Only used for internally allocated objects, so we can take some */
|
||||
/* shortcuts. */
|
||||
#ifdef THREADS
|
||||
void GC_free_inner(GC_PTR p)
|
||||
{
|
||||
register struct hblk *h;
|
||||
register hdr *hhdr;
|
||||
register signed_word sz;
|
||||
register ptr_t * flh;
|
||||
register int knd;
|
||||
register struct obj_kind * ok;
|
||||
DCL_LOCK_STATE;
|
||||
|
||||
h = HBLKPTR(p);
|
||||
hhdr = HDR(h);
|
||||
knd = hhdr -> hb_obj_kind;
|
||||
sz = hhdr -> hb_sz;
|
||||
ok = &GC_obj_kinds[knd];
|
||||
if (sz <= MAXOBJSZ) {
|
||||
GC_mem_freed += sz;
|
||||
if (IS_UNCOLLECTABLE(knd)) GC_non_gc_bytes -= WORDS_TO_BYTES(sz);
|
||||
if (ok -> ok_init) {
|
||||
BZERO((word *)p + 1, WORDS_TO_BYTES(sz-1));
|
||||
}
|
||||
flh = &(ok -> ok_freelist[sz]);
|
||||
obj_link(p) = *flh;
|
||||
*flh = (ptr_t)p;
|
||||
} else {
|
||||
GC_mem_freed += sz;
|
||||
if (IS_UNCOLLECTABLE(knd)) GC_non_gc_bytes -= WORDS_TO_BYTES(sz);
|
||||
GC_freehblk(h);
|
||||
}
|
||||
}
|
||||
#endif /* THREADS */
|
||||
|
||||
# ifdef REDIRECT_MALLOC
|
||||
# ifdef __STDC__
|
||||
void free(GC_PTR p)
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
* Copyright 1988, 1989 Hans-J. Boehm, Alan J. Demers
|
||||
* Copyright (c) 1991-1994 by Xerox Corporation. All rights reserved.
|
||||
* Copyright (c) 1996 by Silicon Graphics. All rights reserved.
|
||||
* Copyright (c) 2000 by Hewlett-Packard Company. All rights reserved.
|
||||
*
|
||||
* THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED
|
||||
* OR IMPLIED. ANY USE IS AT YOUR OWN RISK.
|
||||
|
@ -21,7 +22,7 @@
|
|||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include "gc_priv.h"
|
||||
#include "private/gc_priv.h"
|
||||
|
||||
extern ptr_t GC_clear_stack(); /* in misc.c, behaves like identity */
|
||||
void GC_extend_size_map(); /* in misc.c. */
|
||||
|
@ -30,69 +31,179 @@ GC_bool GC_alloc_reclaim_list(); /* in malloc.c */
|
|||
/* Some externally visible but unadvertised variables to allow access to */
|
||||
/* free lists from inlined allocators without including gc_priv.h */
|
||||
/* or introducing dependencies on internal data structure layouts. */
|
||||
ptr_t * CONST GC_objfreelist_ptr = GC_objfreelist;
|
||||
ptr_t * CONST GC_aobjfreelist_ptr = GC_aobjfreelist;
|
||||
ptr_t * CONST GC_uobjfreelist_ptr = GC_uobjfreelist;
|
||||
ptr_t * GC_CONST GC_objfreelist_ptr = GC_objfreelist;
|
||||
ptr_t * GC_CONST GC_aobjfreelist_ptr = GC_aobjfreelist;
|
||||
ptr_t * GC_CONST GC_uobjfreelist_ptr = GC_uobjfreelist;
|
||||
# ifdef ATOMIC_UNCOLLECTABLE
|
||||
ptr_t * CONST GC_auobjfreelist_ptr = GC_auobjfreelist;
|
||||
ptr_t * GC_CONST GC_auobjfreelist_ptr = GC_auobjfreelist;
|
||||
# endif
|
||||
|
||||
/* Allocate a composite object of size n bytes. The caller guarantees */
|
||||
/* that pointers past the first page are not relevant. Caller holds */
|
||||
/* allocation lock. */
|
||||
ptr_t GC_generic_malloc_inner_ignore_off_page(lb, k)
|
||||
register size_t lb;
|
||||
register int k;
|
||||
{
|
||||
register struct hblk * h;
|
||||
register word n_blocks;
|
||||
register word lw;
|
||||
register ptr_t op;
|
||||
|
||||
if (lb <= HBLKSIZE)
|
||||
return(GC_generic_malloc_inner((word)lb, k));
|
||||
n_blocks = divHBLKSZ(ADD_SLOP(lb) + HDR_BYTES + HBLKSIZE-1);
|
||||
if (!GC_is_initialized) GC_init_inner();
|
||||
/* Do our share of marking work */
|
||||
if(GC_incremental && !GC_dont_gc)
|
||||
GC_collect_a_little_inner((int)n_blocks);
|
||||
lw = ROUNDED_UP_WORDS(lb);
|
||||
h = GC_allochblk(lw, k, IGNORE_OFF_PAGE);
|
||||
# ifdef USE_MUNMAP
|
||||
if (0 == h) {
|
||||
GC_merge_unmapped();
|
||||
h = GC_allochblk(lw, k, IGNORE_OFF_PAGE);
|
||||
}
|
||||
# endif
|
||||
while (0 == h && GC_collect_or_expand(n_blocks, TRUE)) {
|
||||
h = GC_allochblk(lw, k, IGNORE_OFF_PAGE);
|
||||
GC_PTR GC_generic_or_special_malloc(lb,knd)
|
||||
word lb;
|
||||
int knd;
|
||||
{
|
||||
switch(knd) {
|
||||
# ifdef STUBBORN_ALLOC
|
||||
case STUBBORN:
|
||||
return(GC_malloc_stubborn((size_t)lb));
|
||||
# endif
|
||||
case PTRFREE:
|
||||
return(GC_malloc_atomic((size_t)lb));
|
||||
case NORMAL:
|
||||
return(GC_malloc((size_t)lb));
|
||||
case UNCOLLECTABLE:
|
||||
return(GC_malloc_uncollectable((size_t)lb));
|
||||
# ifdef ATOMIC_UNCOLLECTABLE
|
||||
case AUNCOLLECTABLE:
|
||||
return(GC_malloc_atomic_uncollectable((size_t)lb));
|
||||
# endif /* ATOMIC_UNCOLLECTABLE */
|
||||
default:
|
||||
return(GC_generic_malloc(lb,knd));
|
||||
}
|
||||
if (h == 0) {
|
||||
op = 0;
|
||||
} else {
|
||||
op = (ptr_t) (h -> hb_body);
|
||||
GC_words_wasted += BYTES_TO_WORDS(n_blocks * HBLKSIZE) - lw;
|
||||
}
|
||||
GC_words_allocd += lw;
|
||||
return((ptr_t)op);
|
||||
}
|
||||
|
||||
|
||||
/* Change the size of the block pointed to by p to contain at least */
|
||||
/* lb bytes. The object may be (and quite likely will be) moved. */
|
||||
/* The kind (e.g. atomic) is the same as that of the old. */
|
||||
/* Shrinking of large blocks is not implemented well. */
|
||||
# ifdef __STDC__
|
||||
GC_PTR GC_realloc(GC_PTR p, size_t lb)
|
||||
# else
|
||||
GC_PTR GC_realloc(p,lb)
|
||||
GC_PTR p;
|
||||
size_t lb;
|
||||
# endif
|
||||
{
|
||||
register struct hblk * h;
|
||||
register hdr * hhdr;
|
||||
register word sz; /* Current size in bytes */
|
||||
register word orig_sz; /* Original sz in bytes */
|
||||
int obj_kind;
|
||||
|
||||
if (p == 0) return(GC_malloc(lb)); /* Required by ANSI */
|
||||
h = HBLKPTR(p);
|
||||
hhdr = HDR(h);
|
||||
sz = hhdr -> hb_sz;
|
||||
obj_kind = hhdr -> hb_obj_kind;
|
||||
sz = WORDS_TO_BYTES(sz);
|
||||
orig_sz = sz;
|
||||
|
||||
if (sz > MAXOBJBYTES) {
|
||||
/* Round it up to the next whole heap block */
|
||||
register word descr;
|
||||
|
||||
sz = (sz+HBLKSIZE-1) & (~HBLKMASK);
|
||||
hhdr -> hb_sz = BYTES_TO_WORDS(sz);
|
||||
descr = GC_obj_kinds[obj_kind].ok_descriptor;
|
||||
if (GC_obj_kinds[obj_kind].ok_relocate_descr) descr += sz;
|
||||
hhdr -> hb_descr = descr;
|
||||
if (IS_UNCOLLECTABLE(obj_kind)) GC_non_gc_bytes += (sz - orig_sz);
|
||||
/* Extra area is already cleared by GC_alloc_large_and_clear. */
|
||||
}
|
||||
if (ADD_SLOP(lb) <= sz) {
|
||||
if (lb >= (sz >> 1)) {
|
||||
# ifdef STUBBORN_ALLOC
|
||||
if (obj_kind == STUBBORN) GC_change_stubborn(p);
|
||||
# endif
|
||||
if (orig_sz > lb) {
|
||||
/* Clear unneeded part of object to avoid bogus pointer */
|
||||
/* tracing. */
|
||||
/* Safe for stubborn objects. */
|
||||
BZERO(((ptr_t)p) + lb, orig_sz - lb);
|
||||
}
|
||||
return(p);
|
||||
} else {
|
||||
/* shrink */
|
||||
GC_PTR result =
|
||||
GC_generic_or_special_malloc((word)lb, obj_kind);
|
||||
|
||||
if (result == 0) return(0);
|
||||
/* Could also return original object. But this */
|
||||
/* gives the client warning of imminent disaster. */
|
||||
BCOPY(p, result, lb);
|
||||
# ifndef IGNORE_FREE
|
||||
GC_free(p);
|
||||
# endif
|
||||
return(result);
|
||||
}
|
||||
} else {
|
||||
/* grow */
|
||||
GC_PTR result =
|
||||
GC_generic_or_special_malloc((word)lb, obj_kind);
|
||||
|
||||
if (result == 0) return(0);
|
||||
BCOPY(p, result, sz);
|
||||
# ifndef IGNORE_FREE
|
||||
GC_free(p);
|
||||
# endif
|
||||
return(result);
|
||||
}
|
||||
}
|
||||
|
||||
# if defined(REDIRECT_MALLOC) || defined(REDIRECT_REALLOC)
|
||||
# ifdef __STDC__
|
||||
GC_PTR realloc(GC_PTR p, size_t lb)
|
||||
# else
|
||||
GC_PTR realloc(p,lb)
|
||||
GC_PTR p;
|
||||
size_t lb;
|
||||
# endif
|
||||
{
|
||||
# ifdef REDIRECT_REALLOC
|
||||
return(REDIRECT_REALLOC(p, lb));
|
||||
# else
|
||||
return(GC_realloc(p, lb));
|
||||
# endif
|
||||
}
|
||||
# endif /* REDIRECT_MALLOC */
|
||||
|
||||
|
||||
/* The same thing, except caller does not hold allocation lock. */
|
||||
/* We avoid holding allocation lock while we clear memory. */
|
||||
ptr_t GC_generic_malloc_ignore_off_page(lb, k)
|
||||
register size_t lb;
|
||||
register int k;
|
||||
{
|
||||
register ptr_t result;
|
||||
word lw;
|
||||
word n_blocks;
|
||||
GC_bool init;
|
||||
DCL_LOCK_STATE;
|
||||
|
||||
if (SMALL_OBJ(lb))
|
||||
return(GC_generic_malloc((word)lb, k));
|
||||
lw = ROUNDED_UP_WORDS(lb);
|
||||
n_blocks = OBJ_SZ_TO_BLOCKS(lw);
|
||||
init = GC_obj_kinds[k].ok_init;
|
||||
GC_INVOKE_FINALIZERS();
|
||||
DISABLE_SIGNALS();
|
||||
LOCK();
|
||||
result = GC_generic_malloc_inner_ignore_off_page(lb,k);
|
||||
result = (ptr_t)GC_alloc_large(lw, k, IGNORE_OFF_PAGE);
|
||||
if (0 != result) {
|
||||
if (GC_debugging_started) {
|
||||
BZERO(result, n_blocks * HBLKSIZE);
|
||||
} else {
|
||||
# ifdef THREADS
|
||||
/* Clear any memory that might be used for GC descriptors */
|
||||
/* before we release the lock. */
|
||||
((word *)result)[0] = 0;
|
||||
((word *)result)[1] = 0;
|
||||
((word *)result)[lw-1] = 0;
|
||||
((word *)result)[lw-2] = 0;
|
||||
# endif
|
||||
}
|
||||
}
|
||||
GC_words_allocd += lw;
|
||||
UNLOCK();
|
||||
ENABLE_SIGNALS();
|
||||
if (0 == result) {
|
||||
return((*GC_oom_fn)(lb));
|
||||
} else {
|
||||
if (init & !GC_debugging_started) {
|
||||
BZERO(result, n_blocks * HBLKSIZE);
|
||||
}
|
||||
return(result);
|
||||
}
|
||||
}
|
||||
|
@ -185,6 +296,24 @@ DCL_LOCK_STATE;
|
|||
}
|
||||
|
||||
#if defined(THREADS) && !defined(SRC_M3)
|
||||
|
||||
extern signed_word GC_mem_found; /* Protected by GC lock. */
|
||||
|
||||
#ifdef PARALLEL_MARK
|
||||
volatile signed_word GC_words_allocd_tmp = 0;
|
||||
/* Number of words of memory allocated since */
|
||||
/* we released the GC lock. Instead of */
|
||||
/* reacquiring the GC lock just to add this in, */
|
||||
/* we add it in the next time we reacquire */
|
||||
/* the lock. (Atomically adding it doesn't */
|
||||
/* work, since we would have to atomically */
|
||||
/* update it in GC_malloc, which is too */
|
||||
/* expensive. */
|
||||
#endif /* PARALLEL_MARK */
|
||||
|
||||
/* See reclaim.c: */
|
||||
extern ptr_t GC_reclaim_generic();
|
||||
|
||||
/* Return a list of 1 or more objects of the indicated size, linked */
|
||||
/* through the first word in the object. This has the advantage that */
|
||||
/* it acquires the allocation lock only once, and may greatly reduce */
|
||||
|
@ -200,12 +329,19 @@ register word lb;
|
|||
register int k;
|
||||
{
|
||||
ptr_t op;
|
||||
register ptr_t p;
|
||||
ptr_t p;
|
||||
ptr_t *opp;
|
||||
word lw;
|
||||
register word my_words_allocd;
|
||||
word my_words_allocd = 0;
|
||||
struct obj_kind * ok = &(GC_obj_kinds[k]);
|
||||
DCL_LOCK_STATE;
|
||||
|
||||
# if defined(GATHERSTATS) || defined(PARALLEL_MARK)
|
||||
# define COUNT_ARG , &my_words_allocd
|
||||
# else
|
||||
# define COUNT_ARG
|
||||
# define NEED_TO_COUNT
|
||||
# endif
|
||||
if (!SMALL_OBJ(lb)) {
|
||||
op = GC_generic_malloc(lb, k);
|
||||
if(0 != op) obj_link(op) = 0;
|
||||
|
@ -215,40 +351,142 @@ DCL_LOCK_STATE;
|
|||
GC_INVOKE_FINALIZERS();
|
||||
DISABLE_SIGNALS();
|
||||
LOCK();
|
||||
opp = &(GC_obj_kinds[k].ok_freelist[lw]);
|
||||
if( (op = *opp) == 0 ) {
|
||||
if (!GC_is_initialized) {
|
||||
GC_init_inner();
|
||||
}
|
||||
op = GC_clear_stack(GC_allocobj(lw, k));
|
||||
if (op == 0) {
|
||||
UNLOCK();
|
||||
ENABLE_SIGNALS();
|
||||
op = (*GC_oom_fn)(lb);
|
||||
if(0 != op) obj_link(op) = 0;
|
||||
return(op);
|
||||
}
|
||||
if (!GC_is_initialized) GC_init_inner();
|
||||
/* First see if we can reclaim a page of objects waiting to be */
|
||||
/* reclaimed. */
|
||||
{
|
||||
struct hblk ** rlh = ok -> ok_reclaim_list;
|
||||
struct hblk * hbp;
|
||||
hdr * hhdr;
|
||||
|
||||
rlh += lw;
|
||||
while ((hbp = *rlh) != 0) {
|
||||
hhdr = HDR(hbp);
|
||||
*rlh = hhdr -> hb_next;
|
||||
# ifdef PARALLEL_MARK
|
||||
{
|
||||
signed_word my_words_allocd_tmp = GC_words_allocd_tmp;
|
||||
|
||||
GC_ASSERT(my_words_allocd_tmp >= 0);
|
||||
/* We only decrement it while holding the GC lock. */
|
||||
/* Thus we can't accidentally adjust it down in more */
|
||||
/* than one thread simultaneously. */
|
||||
if (my_words_allocd_tmp != 0) {
|
||||
(void)GC_atomic_add(
|
||||
(volatile GC_word *)(&GC_words_allocd_tmp),
|
||||
(GC_word)(-my_words_allocd_tmp));
|
||||
GC_words_allocd += my_words_allocd_tmp;
|
||||
}
|
||||
}
|
||||
GC_acquire_mark_lock();
|
||||
++ GC_fl_builder_count;
|
||||
UNLOCK();
|
||||
ENABLE_SIGNALS();
|
||||
GC_release_mark_lock();
|
||||
# endif
|
||||
op = GC_reclaim_generic(hbp, hhdr, lw,
|
||||
ok -> ok_init, 0 COUNT_ARG);
|
||||
if (op != 0) {
|
||||
# ifdef NEED_TO_COUNT
|
||||
/* We are neither gathering statistics, nor marking in */
|
||||
/* parallel. Thus GC_reclaim_generic doesn't count */
|
||||
/* for us. */
|
||||
for (p = op; p != 0; p = obj_link(p)) {
|
||||
my_words_allocd += lw;
|
||||
}
|
||||
# endif
|
||||
# if defined(GATHERSTATS)
|
||||
/* We also reclaimed memory, so we need to adjust */
|
||||
/* that count. */
|
||||
/* This should be atomic, so the results may be */
|
||||
/* inaccurate. */
|
||||
GC_mem_found += my_words_allocd;
|
||||
# endif
|
||||
# ifdef PARALLEL_MARK
|
||||
(void)GC_atomic_add(
|
||||
(volatile GC_word *)(&GC_words_allocd_tmp),
|
||||
(GC_word)(my_words_allocd));
|
||||
GC_acquire_mark_lock();
|
||||
-- GC_fl_builder_count;
|
||||
if (GC_fl_builder_count == 0) GC_notify_all_builder();
|
||||
GC_release_mark_lock();
|
||||
return GC_clear_stack(op);
|
||||
# else
|
||||
GC_words_allocd += my_words_allocd;
|
||||
goto out;
|
||||
# endif
|
||||
}
|
||||
# ifdef PARALLEL_MARK
|
||||
GC_acquire_mark_lock();
|
||||
-- GC_fl_builder_count;
|
||||
if (GC_fl_builder_count == 0) GC_notify_all_builder();
|
||||
GC_release_mark_lock();
|
||||
DISABLE_SIGNALS();
|
||||
LOCK();
|
||||
/* GC lock is needed for reclaim list access. We */
|
||||
/* must decrement fl_builder_count before reaquiring GC */
|
||||
/* lock. Hopefully this path is rare. */
|
||||
# endif
|
||||
}
|
||||
}
|
||||
*opp = 0;
|
||||
my_words_allocd = 0;
|
||||
for (p = op; p != 0; p = obj_link(p)) {
|
||||
my_words_allocd += lw;
|
||||
if (my_words_allocd >= BODY_SZ) {
|
||||
/* Next try to use prefix of global free list if there is one. */
|
||||
/* We don't refill it, but we need to use it up before allocating */
|
||||
/* a new block ourselves. */
|
||||
opp = &(GC_obj_kinds[k].ok_freelist[lw]);
|
||||
if ( (op = *opp) != 0 ) {
|
||||
*opp = 0;
|
||||
my_words_allocd = 0;
|
||||
for (p = op; p != 0; p = obj_link(p)) {
|
||||
my_words_allocd += lw;
|
||||
if (my_words_allocd >= BODY_SZ) {
|
||||
*opp = obj_link(p);
|
||||
obj_link(p) = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
GC_words_allocd += my_words_allocd;
|
||||
goto out;
|
||||
}
|
||||
/* Next try to allocate a new block worth of objects of this size. */
|
||||
{
|
||||
struct hblk *h = GC_allochblk(lw, k, 0);
|
||||
if (h != 0) {
|
||||
if (IS_UNCOLLECTABLE(k)) GC_set_hdr_marks(HDR(h));
|
||||
GC_words_allocd += BYTES_TO_WORDS(HBLKSIZE)
|
||||
- BYTES_TO_WORDS(HBLKSIZE) % lw;
|
||||
# ifdef PARALLEL_MARK
|
||||
GC_acquire_mark_lock();
|
||||
++ GC_fl_builder_count;
|
||||
UNLOCK();
|
||||
ENABLE_SIGNALS();
|
||||
GC_release_mark_lock();
|
||||
# endif
|
||||
|
||||
op = GC_build_fl(h, lw, ok -> ok_init, 0);
|
||||
# ifdef PARALLEL_MARK
|
||||
GC_acquire_mark_lock();
|
||||
-- GC_fl_builder_count;
|
||||
if (GC_fl_builder_count == 0) GC_notify_all_builder();
|
||||
GC_release_mark_lock();
|
||||
return GC_clear_stack(op);
|
||||
# else
|
||||
goto out;
|
||||
# endif
|
||||
}
|
||||
}
|
||||
GC_words_allocd += my_words_allocd;
|
||||
|
||||
out:
|
||||
/* As a last attempt, try allocating a single object. Note that */
|
||||
/* this may trigger a collection or expand the heap. */
|
||||
op = GC_generic_malloc_inner(lb, k);
|
||||
if (0 != op) obj_link(op) = 0;
|
||||
|
||||
out:
|
||||
UNLOCK();
|
||||
ENABLE_SIGNALS();
|
||||
return(op);
|
||||
|
||||
return(GC_clear_stack(op));
|
||||
}
|
||||
|
||||
void * GC_malloc_many(size_t lb)
|
||||
GC_PTR GC_malloc_many(size_t lb)
|
||||
{
|
||||
return(GC_generic_malloc_many(lb, NORMAL));
|
||||
}
|
||||
|
@ -272,11 +510,9 @@ DCL_LOCK_STATE;
|
|||
|
||||
if( SMALL_OBJ(lb) ) {
|
||||
# ifdef MERGE_SIZES
|
||||
# ifdef ADD_BYTE_AT_END
|
||||
if (lb != 0) lb--;
|
||||
if (EXTRA_BYTES != 0 && lb != 0) lb--;
|
||||
/* We don't need the extra byte, since this won't be */
|
||||
/* collected anyway. */
|
||||
# endif
|
||||
lw = GC_size_map[lb];
|
||||
# else
|
||||
lw = ALIGNED_WORDS(lb);
|
||||
|
@ -338,11 +574,9 @@ DCL_LOCK_STATE;
|
|||
|
||||
if( SMALL_OBJ(lb) ) {
|
||||
# ifdef MERGE_SIZES
|
||||
# ifdef ADD_BYTE_AT_END
|
||||
if (lb != 0) lb--;
|
||||
if (EXTRA_BYTES != 0 && lb != 0) lb--;
|
||||
/* We don't need the extra byte, since this won't be */
|
||||
/* collected anyway. */
|
||||
# endif
|
||||
lw = GC_size_map[lb];
|
||||
# else
|
||||
lw = ALIGNED_WORDS(lb);
|
||||
|
|
702
boehm-gc/mark.c
702
boehm-gc/mark.c
File diff suppressed because it is too large
Load diff
|
@ -11,9 +11,8 @@
|
|||
* provided the above notices are retained, and a notice that the code was
|
||||
* modified is included with the above copyright notice.
|
||||
*/
|
||||
/* Boehm, October 9, 1995 1:06 pm PDT */
|
||||
# include <stdio.h>
|
||||
# include "gc_priv.h"
|
||||
# include "private/gc_priv.h"
|
||||
|
||||
/* Data structure for list of root sets. */
|
||||
/* We keep a hash table, so that we can filter out duplicate additions. */
|
||||
|
@ -23,7 +22,7 @@
|
|||
struct roots {
|
||||
ptr_t r_start;
|
||||
ptr_t r_end;
|
||||
# ifndef MSWIN32
|
||||
# if !defined(MSWIN32) && !defined(MSWINCE)
|
||||
struct roots * r_next;
|
||||
# endif
|
||||
GC_bool r_tmp;
|
||||
|
@ -33,6 +32,8 @@ struct roots {
|
|||
struct roots GC_static_roots[MAX_ROOT_SETS];
|
||||
*/
|
||||
|
||||
int GC_no_dls = 0; /* Register dynamic library data segments. */
|
||||
|
||||
static int n_root_sets = 0;
|
||||
|
||||
/* GC_static_roots[0..n_root_sets) contains the valid root sets. */
|
||||
|
@ -69,11 +70,12 @@ void GC_print_static_roots()
|
|||
GC_bool GC_is_static_root(p)
|
||||
ptr_t p;
|
||||
{
|
||||
static int last_root_set = 0;
|
||||
static int last_root_set = MAX_ROOT_SETS;
|
||||
register int i;
|
||||
|
||||
|
||||
if (p >= GC_static_roots[last_root_set].r_start
|
||||
if (last_root_set < n_root_sets
|
||||
&& p >= GC_static_roots[last_root_set].r_start
|
||||
&& p < GC_static_roots[last_root_set].r_end) return(TRUE);
|
||||
for (i = 0; i < n_root_sets; i++) {
|
||||
if (p >= GC_static_roots[i].r_start
|
||||
|
@ -85,7 +87,7 @@ ptr_t p;
|
|||
return(FALSE);
|
||||
}
|
||||
|
||||
#ifndef MSWIN32
|
||||
#if !defined(MSWIN32) && !defined(MSWINCE)
|
||||
/*
|
||||
# define LOG_RT_SIZE 6
|
||||
# define RT_SIZE (1 << LOG_RT_SIZE) -- Power of 2, may be != MAX_ROOT_SETS
|
||||
|
@ -137,7 +139,7 @@ struct roots *p;
|
|||
GC_root_index[h] = p;
|
||||
}
|
||||
|
||||
# else /* MSWIN32 */
|
||||
# else /* MSWIN32 || MSWINCE */
|
||||
|
||||
# define add_roots_to_index(p)
|
||||
|
||||
|
@ -173,7 +175,7 @@ GC_bool tmp;
|
|||
{
|
||||
struct roots * old;
|
||||
|
||||
# ifdef MSWIN32
|
||||
# if defined(MSWIN32) || defined(MSWINCE)
|
||||
/* Spend the time to ensure that there are no overlapping */
|
||||
/* or adjacent intervals. */
|
||||
/* This could be done faster with e.g. a */
|
||||
|
@ -242,7 +244,7 @@ GC_bool tmp;
|
|||
GC_static_roots[n_root_sets].r_start = (ptr_t)b;
|
||||
GC_static_roots[n_root_sets].r_end = (ptr_t)e;
|
||||
GC_static_roots[n_root_sets].r_tmp = tmp;
|
||||
# ifndef MSWIN32
|
||||
# if !defined(MSWIN32) && !defined(MSWINCE)
|
||||
GC_static_roots[n_root_sets].r_next = 0;
|
||||
# endif
|
||||
add_roots_to_index(GC_static_roots + n_root_sets);
|
||||
|
@ -250,15 +252,18 @@ GC_bool tmp;
|
|||
n_root_sets++;
|
||||
}
|
||||
|
||||
static roots_were_cleared = FALSE;
|
||||
|
||||
void GC_clear_roots GC_PROTO((void))
|
||||
{
|
||||
DCL_LOCK_STATE;
|
||||
|
||||
DISABLE_SIGNALS();
|
||||
LOCK();
|
||||
roots_were_cleared = TRUE;
|
||||
n_root_sets = 0;
|
||||
GC_root_size = 0;
|
||||
# ifndef MSWIN32
|
||||
# if !defined(MSWIN32) && !defined(MSWINCE)
|
||||
{
|
||||
register int i;
|
||||
|
||||
|
@ -286,7 +291,7 @@ void GC_remove_tmp_roots()
|
|||
i++;
|
||||
}
|
||||
}
|
||||
# ifndef MSWIN32
|
||||
# if !defined(MSWIN32) && !defined(MSWINCE)
|
||||
{
|
||||
register int i;
|
||||
|
||||
|
@ -298,11 +303,41 @@ void GC_remove_tmp_roots()
|
|||
|
||||
}
|
||||
|
||||
#if defined(MSWIN32) || defined(_WIN32_WCE_EMULATION)
|
||||
/* Workaround for the OS mapping and unmapping behind our back: */
|
||||
/* Is the address p in one of the temporary static root sections? */
|
||||
GC_bool GC_is_tmp_root(p)
|
||||
ptr_t p;
|
||||
{
|
||||
static int last_root_set = MAX_ROOT_SETS;
|
||||
register int i;
|
||||
|
||||
if (last_root_set < n_root_sets
|
||||
&& p >= GC_static_roots[last_root_set].r_start
|
||||
&& p < GC_static_roots[last_root_set].r_end)
|
||||
return GC_static_roots[last_root_set].r_tmp;
|
||||
for (i = 0; i < n_root_sets; i++) {
|
||||
if (p >= GC_static_roots[i].r_start
|
||||
&& p < GC_static_roots[i].r_end) {
|
||||
last_root_set = i;
|
||||
return GC_static_roots[i].r_tmp;
|
||||
}
|
||||
}
|
||||
return(FALSE);
|
||||
}
|
||||
#endif /* MSWIN32 || _WIN32_WCE_EMULATION */
|
||||
|
||||
ptr_t GC_approx_sp()
|
||||
{
|
||||
word dummy;
|
||||
|
||||
|
||||
# ifdef _MSC_VER
|
||||
# pragma warning(disable:4172)
|
||||
# endif
|
||||
return((ptr_t)(&dummy));
|
||||
# ifdef _MSC_VER
|
||||
# pragma warning(default:4172)
|
||||
# endif
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -432,15 +467,15 @@ ptr_t cold_gc_frame;
|
|||
/* Previously set to backing store pointer. */
|
||||
ptr_t bsp = (ptr_t) GC_save_regs_ret_val;
|
||||
ptr_t cold_gc_bs_pointer;
|
||||
# ifdef ALL_INTERIOR_POINTERS
|
||||
if (GC_all_interior_pointers) {
|
||||
cold_gc_bs_pointer = bsp - 2048;
|
||||
if (cold_gc_bs_pointer < BACKING_STORE_BASE) {
|
||||
cold_gc_bs_pointer = BACKING_STORE_BASE;
|
||||
}
|
||||
GC_push_all(BACKING_STORE_BASE, cold_gc_bs_pointer);
|
||||
# else
|
||||
GC_push_all_stack(BACKING_STORE_BASE, cold_gc_bs_pointer);
|
||||
} else {
|
||||
cold_gc_bs_pointer = BACKING_STORE_BASE;
|
||||
# endif
|
||||
}
|
||||
GC_push_all_eager(cold_gc_bs_pointer, bsp);
|
||||
/* All values should be sufficiently aligned that we */
|
||||
/* dont have to worry about the boundary. */
|
||||
|
@ -453,6 +488,19 @@ ptr_t cold_gc_frame;
|
|||
# endif /* !THREADS */
|
||||
}
|
||||
|
||||
/*
|
||||
* Push GC internal roots. Only called if there is some reason to believe
|
||||
* these would not otherwise get registered.
|
||||
*/
|
||||
void GC_push_gc_structures GC_PROTO((void))
|
||||
{
|
||||
GC_push_finalizer_structures();
|
||||
GC_push_stubborn_structures();
|
||||
# if defined(THREADS)
|
||||
GC_push_thread_structures();
|
||||
# endif
|
||||
}
|
||||
|
||||
/*
|
||||
* Call the mark routines (GC_tl_push for a single pointer, GC_push_conditional
|
||||
* on groups of pointers) on every top level accessible pointer.
|
||||
|
@ -483,11 +531,14 @@ ptr_t cold_gc_frame;
|
|||
* not robust against mark stack overflow.
|
||||
*/
|
||||
/* Reregister dynamic libraries, in case one got added. */
|
||||
# if (defined(DYNAMIC_LOADING) || defined(MSWIN32) || defined(PCR)) \
|
||||
&& !defined(SRC_M3)
|
||||
# if (defined(DYNAMIC_LOADING) || defined(MSWIN32) || defined(MSWINCE) \
|
||||
|| defined(PCR)) && !defined(SRC_M3)
|
||||
GC_remove_tmp_roots();
|
||||
GC_register_dynamic_libraries();
|
||||
if (!GC_no_dls) GC_register_dynamic_libraries();
|
||||
# else
|
||||
GC_no_dls = TRUE;
|
||||
# endif
|
||||
|
||||
/* Mark everything in static data areas */
|
||||
for (i = 0; i < n_root_sets; i++) {
|
||||
GC_push_conditional_with_exclusions(
|
||||
|
@ -495,6 +546,12 @@ ptr_t cold_gc_frame;
|
|||
GC_static_roots[i].r_end, all);
|
||||
}
|
||||
|
||||
/* Mark from GC internal roots if those might otherwise have */
|
||||
/* been excluded. */
|
||||
if (GC_no_dls || roots_were_cleared) {
|
||||
GC_push_gc_structures();
|
||||
}
|
||||
|
||||
/*
|
||||
* Now traverse stacks.
|
||||
*/
|
||||
|
|
380
boehm-gc/misc.c
380
boehm-gc/misc.c
|
@ -15,16 +15,21 @@
|
|||
|
||||
|
||||
#include <stdio.h>
|
||||
#ifndef _WIN32_WCE
|
||||
#include <signal.h>
|
||||
#endif
|
||||
|
||||
#define I_HIDE_POINTERS /* To make GC_call_with_alloc_lock visible */
|
||||
#include "gc_priv.h"
|
||||
#include "private/gc_pmark.h"
|
||||
|
||||
#ifdef SOLARIS_THREADS
|
||||
# include <sys/syscall.h>
|
||||
#endif
|
||||
#ifdef MSWIN32
|
||||
#if defined(MSWIN32) || defined(MSWINCE)
|
||||
# define WIN32_LEAN_AND_MEAN
|
||||
# define NOSERVICE
|
||||
# include <windows.h>
|
||||
# include <tchar.h>
|
||||
#endif
|
||||
|
||||
# ifdef THREADS
|
||||
|
@ -40,15 +45,22 @@
|
|||
mutex_t GC_allocate_ml; /* Implicitly initialized. */
|
||||
# else
|
||||
# ifdef WIN32_THREADS
|
||||
GC_API CRITICAL_SECTION GC_allocate_ml;
|
||||
# if defined(_DLL) || defined(GC_DLL)
|
||||
__declspec(dllexport) CRITICAL_SECTION GC_allocate_ml;
|
||||
# else
|
||||
CRITICAL_SECTION GC_allocate_ml;
|
||||
# endif
|
||||
# else
|
||||
# if defined(IRIX_THREADS) || defined(IRIX_JDK_THREADS) \
|
||||
# if defined(IRIX_THREADS) \
|
||||
|| (defined(LINUX_THREADS) && defined(USE_SPIN_LOCK))
|
||||
pthread_t GC_lock_holder = NO_THREAD;
|
||||
# else
|
||||
# if defined(HPUX_THREADS) \
|
||||
|| defined(LINUX_THREADS) && !defined(USE_SPIN_LOCK)
|
||||
pthread_mutex_t GC_allocate_ml = PTHREAD_MUTEX_INITIALIZER;
|
||||
pthread_t GC_lock_holder = NO_THREAD;
|
||||
/* Used only for assertions, and to prevent */
|
||||
/* recursive reentry in the system call wrapper. */
|
||||
# else
|
||||
--> declare allocator lock here
|
||||
# endif
|
||||
|
@ -69,22 +81,36 @@ GC_FAR struct _GC_arrays GC_arrays /* = { 0 } */;
|
|||
GC_bool GC_debugging_started = FALSE;
|
||||
/* defined here so we don't have to load debug_malloc.o */
|
||||
|
||||
void (*GC_check_heap)() = (void (*)())0;
|
||||
void (*GC_check_heap) GC_PROTO((void)) = (void (*) GC_PROTO((void)))0;
|
||||
|
||||
void (*GC_start_call_back)() = (void (*)())0;
|
||||
void (*GC_start_call_back) GC_PROTO((void)) = (void (*) GC_PROTO((void)))0;
|
||||
|
||||
ptr_t GC_stackbottom = 0;
|
||||
|
||||
#ifdef IA64
|
||||
ptr_t GC_register_stackbottom = 0;
|
||||
#endif
|
||||
|
||||
GC_bool GC_dont_gc = 0;
|
||||
|
||||
GC_bool GC_dont_precollect = 0;
|
||||
|
||||
GC_bool GC_quiet = 0;
|
||||
|
||||
GC_bool GC_print_stats = 0;
|
||||
|
||||
#ifdef FIND_LEAK
|
||||
int GC_find_leak = 1;
|
||||
#else
|
||||
int GC_find_leak = 0;
|
||||
#endif
|
||||
|
||||
#ifdef ALL_INTERIOR_POINTERS
|
||||
int GC_all_interior_pointers = 1;
|
||||
#else
|
||||
int GC_all_interior_pointers = 0;
|
||||
#endif
|
||||
|
||||
/*ARGSUSED*/
|
||||
GC_PTR GC_default_oom_fn GC_PROTO((size_t bytes_requested))
|
||||
{
|
||||
|
@ -107,9 +133,10 @@ extern signed_word GC_mem_found;
|
|||
{
|
||||
register unsigned i;
|
||||
|
||||
/* Map size 0 to something bigger. */
|
||||
/* This avoids problems at lower levels. */
|
||||
/* One word objects don't have to be 2 word aligned. */
|
||||
/* Map size 0 to something bigger. */
|
||||
/* This avoids problems at lower levels. */
|
||||
/* One word objects don't have to be 2 word aligned, */
|
||||
/* unless we're using mark bytes. */
|
||||
for (i = 0; i < sizeof(word); i++) {
|
||||
GC_size_map[i] = MIN_WORDS;
|
||||
}
|
||||
|
@ -119,11 +146,7 @@ extern signed_word GC_mem_found;
|
|||
GC_size_map[sizeof(word)] = ROUNDED_UP_WORDS(sizeof(word));
|
||||
# endif
|
||||
for (i = sizeof(word) + 1; i <= 8 * sizeof(word); i++) {
|
||||
# ifdef ALIGN_DOUBLE
|
||||
GC_size_map[i] = (ROUNDED_UP_WORDS(i) + 1) & (~1);
|
||||
# else
|
||||
GC_size_map[i] = ROUNDED_UP_WORDS(i);
|
||||
# endif
|
||||
GC_size_map[i] = ALIGNED_WORDS(i);
|
||||
}
|
||||
for (i = 8*sizeof(word) + 1; i <= 16 * sizeof(word); i++) {
|
||||
GC_size_map[i] = (ROUNDED_UP_WORDS(i) + 1) & (~1);
|
||||
|
@ -186,10 +209,10 @@ extern signed_word GC_mem_found;
|
|||
# endif
|
||||
}
|
||||
byte_sz = WORDS_TO_BYTES(word_sz);
|
||||
# ifdef ADD_BYTE_AT_END
|
||||
if (GC_all_interior_pointers) {
|
||||
/* We need one extra byte; don't fill in GC_size_map[byte_sz] */
|
||||
byte_sz--;
|
||||
# endif
|
||||
}
|
||||
|
||||
for (j = low_limit; j <= byte_sz; j++) GC_size_map[j] = word_sz;
|
||||
}
|
||||
|
@ -206,39 +229,24 @@ extern signed_word GC_mem_found;
|
|||
*/
|
||||
word GC_stack_last_cleared = 0; /* GC_no when we last did this */
|
||||
# ifdef THREADS
|
||||
# define CLEAR_SIZE 512
|
||||
# else
|
||||
# define CLEAR_SIZE 213
|
||||
# define BIG_CLEAR_SIZE 2048 /* Clear this much now and then. */
|
||||
# define SMALL_CLEAR_SIZE 256 /* Clear this much every time. */
|
||||
# endif
|
||||
# define CLEAR_SIZE 213 /* Granularity for GC_clear_stack_inner */
|
||||
# define DEGRADE_RATE 50
|
||||
|
||||
word GC_min_sp; /* Coolest stack pointer value from which we've */
|
||||
/* already cleared the stack. */
|
||||
|
||||
# ifdef STACK_GROWS_DOWN
|
||||
# define COOLER_THAN >
|
||||
# define HOTTER_THAN <
|
||||
# define MAKE_COOLER(x,y) if ((word)(x)+(y) > (word)(x)) {(x) += (y);} \
|
||||
else {(x) = (word)ONES;}
|
||||
# define MAKE_HOTTER(x,y) (x) -= (y)
|
||||
# else
|
||||
# define COOLER_THAN <
|
||||
# define HOTTER_THAN >
|
||||
# define MAKE_COOLER(x,y) if ((word)(x)-(y) < (word)(x)) {(x) -= (y);} else {(x) = 0;}
|
||||
# define MAKE_HOTTER(x,y) (x) += (y)
|
||||
# endif
|
||||
|
||||
word GC_high_water;
|
||||
/* "hottest" stack pointer value we have seen */
|
||||
/* recently. Degrades over time. */
|
||||
|
||||
word GC_words_allocd_at_reset;
|
||||
|
||||
#if defined(ASM_CLEAR_CODE) && !defined(THREADS)
|
||||
#if defined(ASM_CLEAR_CODE)
|
||||
extern ptr_t GC_clear_stack_inner();
|
||||
#endif
|
||||
|
||||
#if !defined(ASM_CLEAR_CODE) && !defined(THREADS)
|
||||
#else
|
||||
/* Clear the stack up to about limit. Return arg. */
|
||||
/*ARGSUSED*/
|
||||
ptr_t GC_clear_stack_inner(arg, limit)
|
||||
|
@ -266,10 +274,13 @@ ptr_t arg;
|
|||
{
|
||||
register word sp = (word)GC_approx_sp(); /* Hotter than actual sp */
|
||||
# ifdef THREADS
|
||||
word dummy[CLEAR_SIZE];
|
||||
# else
|
||||
register word limit;
|
||||
word dummy[SMALL_CLEAR_SIZE];
|
||||
static unsigned random_no = 0;
|
||||
/* Should be more random than it is ... */
|
||||
/* Used to occasionally clear a bigger */
|
||||
/* chunk. */
|
||||
# endif
|
||||
register word limit;
|
||||
|
||||
# define SLOP 400
|
||||
/* Extra bytes we clear every time. This clears our own */
|
||||
|
@ -287,7 +298,14 @@ ptr_t arg;
|
|||
/* thus more junk remains accessible, thus the heap gets */
|
||||
/* larger ... */
|
||||
# ifdef THREADS
|
||||
BZERO(dummy, CLEAR_SIZE*sizeof(word));
|
||||
if (++random_no % 13 == 0) {
|
||||
limit = sp;
|
||||
MAKE_HOTTER(limit, BIG_CLEAR_SIZE*sizeof(word));
|
||||
return GC_clear_stack_inner(arg, limit);
|
||||
} else {
|
||||
BZERO(dummy, SMALL_CLEAR_SIZE*sizeof(word));
|
||||
return arg;
|
||||
}
|
||||
# else
|
||||
if (GC_gc_no > GC_stack_last_cleared) {
|
||||
/* Start things over, so we clear the entire stack again */
|
||||
|
@ -317,8 +335,8 @@ ptr_t arg;
|
|||
if (GC_min_sp HOTTER_THAN GC_high_water) GC_min_sp = GC_high_water;
|
||||
GC_words_allocd_at_reset = GC_words_allocd;
|
||||
}
|
||||
return(arg);
|
||||
# endif
|
||||
return(arg);
|
||||
}
|
||||
|
||||
|
||||
|
@ -347,37 +365,27 @@ ptr_t arg;
|
|||
/* to the beginning. */
|
||||
while (IS_FORWARDING_ADDR_OR_NIL(candidate_hdr)) {
|
||||
h = FORWARDED_ADDR(h,candidate_hdr);
|
||||
r = (word)h + HDR_BYTES;
|
||||
r = (word)h;
|
||||
candidate_hdr = HDR(h);
|
||||
}
|
||||
if (candidate_hdr -> hb_map == GC_invalid_map) return(0);
|
||||
/* Make sure r points to the beginning of the object */
|
||||
r &= ~(WORDS_TO_BYTES(1) - 1);
|
||||
{
|
||||
register int offset = (char *)r - (char *)(HBLKPTR(r));
|
||||
register int offset = HBLKDISPL(r);
|
||||
register signed_word sz = candidate_hdr -> hb_sz;
|
||||
|
||||
# ifdef ALL_INTERIOR_POINTERS
|
||||
register map_entry_type map_entry;
|
||||
register signed_word map_entry;
|
||||
|
||||
map_entry = MAP_ENTRY((candidate_hdr -> hb_map), offset);
|
||||
if (map_entry == OBJ_INVALID) {
|
||||
return(0);
|
||||
}
|
||||
r -= WORDS_TO_BYTES(map_entry);
|
||||
limit = r + WORDS_TO_BYTES(sz);
|
||||
# else
|
||||
register int correction;
|
||||
|
||||
offset = BYTES_TO_WORDS(offset - HDR_BYTES);
|
||||
correction = offset % sz;
|
||||
r -= (WORDS_TO_BYTES(correction));
|
||||
limit = r + WORDS_TO_BYTES(sz);
|
||||
if (limit > (word)(h + 1)
|
||||
&& sz <= BYTES_TO_WORDS(HBLKSIZE) - HDR_WORDS) {
|
||||
map_entry = MAP_ENTRY((candidate_hdr -> hb_map), offset);
|
||||
if (map_entry > CPP_MAX_OFFSET) {
|
||||
map_entry = (signed_word)(BYTES_TO_WORDS(offset)) % sz;
|
||||
}
|
||||
r -= WORDS_TO_BYTES(map_entry);
|
||||
limit = r + WORDS_TO_BYTES(sz);
|
||||
if (limit > (word)(h + 1)
|
||||
&& sz <= BYTES_TO_WORDS(HBLKSIZE)) {
|
||||
return(0);
|
||||
}
|
||||
# endif
|
||||
}
|
||||
if ((word)p >= limit) return(0);
|
||||
}
|
||||
return((GC_PTR)r);
|
||||
|
@ -398,11 +406,7 @@ ptr_t arg;
|
|||
register hdr * hhdr = HDR(p);
|
||||
|
||||
sz = WORDS_TO_BYTES(hhdr -> hb_sz);
|
||||
if (sz < 0) {
|
||||
return(-sz);
|
||||
} else {
|
||||
return(sz);
|
||||
}
|
||||
return(sz);
|
||||
}
|
||||
|
||||
size_t GC_get_heap_size GC_PROTO(())
|
||||
|
@ -420,6 +424,11 @@ size_t GC_get_bytes_since_gc GC_PROTO(())
|
|||
return ((size_t) WORDS_TO_BYTES(GC_words_allocd));
|
||||
}
|
||||
|
||||
size_t GC_get_total_bytes GC_PROTO(())
|
||||
{
|
||||
return ((size_t) WORDS_TO_BYTES(GC_words_allocd+GC_words_allocd_before_gc));
|
||||
}
|
||||
|
||||
GC_bool GC_is_initialized = FALSE;
|
||||
|
||||
void GC_init()
|
||||
|
@ -434,58 +443,100 @@ void GC_init()
|
|||
|
||||
}
|
||||
|
||||
#if defined(MSWIN32) || defined(MSWINCE)
|
||||
CRITICAL_SECTION GC_write_cs;
|
||||
#endif
|
||||
|
||||
#ifdef MSWIN32
|
||||
extern void GC_init_win32();
|
||||
extern void GC_init_win32 GC_PROTO((void));
|
||||
#endif
|
||||
|
||||
extern void GC_setpagesize();
|
||||
|
||||
#ifdef UNIX_LIKE
|
||||
|
||||
extern void GC_set_and_save_fault_handler GC_PROTO((void (*handler)(int)));
|
||||
|
||||
static void looping_handler(sig)
|
||||
int sig;
|
||||
{
|
||||
GC_err_printf1("Caught signal %d: looping in handler\n", sig);
|
||||
for(;;);
|
||||
}
|
||||
#endif
|
||||
|
||||
void GC_init_inner()
|
||||
{
|
||||
# ifndef THREADS
|
||||
# if !defined(THREADS) && defined(GC_ASSERTIONS)
|
||||
word dummy;
|
||||
# endif
|
||||
word initial_heap_sz = (word)MINHINCR;
|
||||
|
||||
if (GC_is_initialized) return;
|
||||
GC_setpagesize();
|
||||
GC_exclude_static_roots(beginGC_arrays, end_gc_area);
|
||||
# ifdef PRINTSTATS
|
||||
if ((ptr_t)endGC_arrays != (ptr_t)(&GC_obj_kinds)) {
|
||||
GC_printf0("Reordering linker, didn't exclude obj_kinds\n");
|
||||
}
|
||||
GC_print_stats = 1;
|
||||
# endif
|
||||
if (0 != GETENV("GC_PRINT_STATS")) {
|
||||
GC_print_stats = 1;
|
||||
}
|
||||
if (0 != GETENV("GC_FIND_LEAK")) {
|
||||
GC_find_leak = 1;
|
||||
}
|
||||
if (0 != GETENV("GC_ALL_INTERIOR_POINTERS")) {
|
||||
GC_all_interior_pointers = 1;
|
||||
}
|
||||
if (0 != GETENV("GC_DONT_GC")) {
|
||||
GC_dont_gc = 1;
|
||||
}
|
||||
# ifdef UNIX_LIKE
|
||||
if (0 != GETENV("GC_LOOP_ON_ABORT")) {
|
||||
GC_set_and_save_fault_handler(looping_handler);
|
||||
}
|
||||
# endif
|
||||
/* Adjust normal object descriptor for extra allocation. */
|
||||
if (ALIGNMENT > GC_DS_TAGS && EXTRA_BYTES != 0) {
|
||||
GC_obj_kinds[NORMAL].ok_descriptor = ((word)(-ALIGNMENT) | GC_DS_LENGTH);
|
||||
}
|
||||
# if defined(MSWIN32) || defined(MSWINCE)
|
||||
InitializeCriticalSection(&GC_write_cs);
|
||||
# endif
|
||||
GC_setpagesize();
|
||||
GC_exclude_static_roots(beginGC_arrays, endGC_arrays);
|
||||
GC_exclude_static_roots(beginGC_obj_kinds, endGC_obj_kinds);
|
||||
# ifdef SEPARATE_GLOBALS
|
||||
GC_exclude_static_roots(beginGC_objfreelist, endGC_objfreelist);
|
||||
GC_exclude_static_roots(beginGC_aobjfreelist, endGC_aobjfreelist);
|
||||
# endif
|
||||
# ifdef MSWIN32
|
||||
GC_init_win32();
|
||||
# endif
|
||||
# if defined(SEARCH_FOR_DATA_START)
|
||||
/* This doesn't really work if the collector is in a shared library. */
|
||||
GC_init_linux_data_start();
|
||||
# endif
|
||||
# ifdef SOLARIS_THREADS
|
||||
GC_thr_init();
|
||||
/* We need dirty bits in order to find live stack sections. */
|
||||
GC_dirty_init();
|
||||
# if defined(NETBSD) && defined(__ELF__)
|
||||
GC_init_netbsd_elf();
|
||||
# endif
|
||||
# if defined(IRIX_THREADS) || defined(LINUX_THREADS) \
|
||||
|| defined(IRIX_JDK_THREADS) || defined(HPUX_THREADS)
|
||||
|| defined(HPUX_THREADS) || defined(SOLARIS_THREADS)
|
||||
GC_thr_init();
|
||||
# endif
|
||||
# ifdef SOLARIS_THREADS
|
||||
/* We need dirty bits in order to find live stack sections. */
|
||||
GC_dirty_init();
|
||||
# endif
|
||||
# if !defined(THREADS) || defined(SOLARIS_THREADS) || defined(WIN32_THREADS) \
|
||||
|| defined(IRIX_THREADS) || defined(LINUX_THREADS) \
|
||||
|| defined(HPUX_THREADS)
|
||||
if (GC_stackbottom == 0) {
|
||||
GC_stackbottom = GC_get_stack_base();
|
||||
# if defined(LINUX) && defined(IA64)
|
||||
GC_register_stackbottom = GC_get_register_stack_base();
|
||||
# endif
|
||||
}
|
||||
# endif
|
||||
if (sizeof (ptr_t) != sizeof(word)) {
|
||||
ABORT("sizeof (ptr_t) != sizeof(word)\n");
|
||||
}
|
||||
if (sizeof (signed_word) != sizeof(word)) {
|
||||
ABORT("sizeof (signed_word) != sizeof(word)\n");
|
||||
}
|
||||
if (sizeof (struct hblk) != HBLKSIZE) {
|
||||
ABORT("sizeof (struct hblk) != HBLKSIZE\n");
|
||||
}
|
||||
GC_ASSERT(sizeof (ptr_t) == sizeof(word));
|
||||
GC_ASSERT(sizeof (signed_word) == sizeof(word));
|
||||
GC_ASSERT(sizeof (struct hblk) == HBLKSIZE);
|
||||
# ifndef THREADS
|
||||
# if defined(STACK_GROWS_UP) && defined(STACK_GROWS_DOWN)
|
||||
ABORT(
|
||||
|
@ -496,40 +547,16 @@ void GC_init_inner()
|
|||
"One of STACK_GROWS_UP and STACK_GROWS_DOWN should be defd\n");
|
||||
# endif
|
||||
# ifdef STACK_GROWS_DOWN
|
||||
if ((word)(&dummy) > (word)GC_stackbottom) {
|
||||
GC_err_printf0(
|
||||
"STACK_GROWS_DOWN is defd, but stack appears to grow up\n");
|
||||
# ifndef UTS4 /* Compiler bug workaround */
|
||||
GC_err_printf2("sp = 0x%lx, GC_stackbottom = 0x%lx\n",
|
||||
(unsigned long) (&dummy),
|
||||
(unsigned long) GC_stackbottom);
|
||||
# endif
|
||||
ABORT("stack direction 3\n");
|
||||
}
|
||||
GC_ASSERT((word)(&dummy) <= (word)GC_stackbottom);
|
||||
# else
|
||||
if ((word)(&dummy) < (word)GC_stackbottom) {
|
||||
GC_err_printf0(
|
||||
"STACK_GROWS_UP is defd, but stack appears to grow down\n");
|
||||
GC_err_printf2("sp = 0x%lx, GC_stackbottom = 0x%lx\n",
|
||||
(unsigned long) (&dummy),
|
||||
(unsigned long) GC_stackbottom);
|
||||
ABORT("stack direction 4");
|
||||
}
|
||||
GC_ASSERT((word)(&dummy) >= (word)GC_stackbottom);
|
||||
# endif
|
||||
# endif
|
||||
# if !defined(_AUX_SOURCE) || defined(__GNUC__)
|
||||
if ((word)(-1) < (word)0) {
|
||||
GC_err_printf0("The type word should be an unsigned integer type\n");
|
||||
GC_err_printf0("It appears to be signed\n");
|
||||
ABORT("word");
|
||||
}
|
||||
GC_ASSERT((word)(-1) > (word)0);
|
||||
/* word should be unsigned */
|
||||
# endif
|
||||
if ((signed_word)(-1) >= (signed_word)0) {
|
||||
GC_err_printf0(
|
||||
"The type signed_word should be a signed integer type\n");
|
||||
GC_err_printf0("It appears to be unsigned\n");
|
||||
ABORT("signed_word");
|
||||
}
|
||||
GC_ASSERT((signed_word)(-1) < (signed_word)0);
|
||||
|
||||
/* Add initial guess of root sets. Do this first, since sbrk(0) */
|
||||
/* might be used. */
|
||||
|
@ -537,7 +564,18 @@ void GC_init_inner()
|
|||
GC_init_headers();
|
||||
GC_bl_init();
|
||||
GC_mark_init();
|
||||
if (!GC_expand_hp_inner((word)MINHINCR)) {
|
||||
{
|
||||
char * sz_str = GETENV("GC_INITIAL_HEAP_SIZE");
|
||||
if (sz_str != NULL) {
|
||||
initial_heap_sz = atoi(sz_str);
|
||||
if (initial_heap_sz <= MINHINCR * HBLKSIZE) {
|
||||
WARN("Bad initial heap size %s - ignoring it.\n",
|
||||
sz_str);
|
||||
}
|
||||
initial_heap_sz = divHBLKSZ(initial_heap_sz);
|
||||
}
|
||||
}
|
||||
if (!GC_expand_hp_inner(initial_heap_sz)) {
|
||||
GC_err_printf0("Can't start up: not enough memory\n");
|
||||
EXIT();
|
||||
}
|
||||
|
@ -562,11 +600,11 @@ void GC_init_inner()
|
|||
GC_pcr_install();
|
||||
# endif
|
||||
/* Get black list set up */
|
||||
GC_gcollect_inner();
|
||||
if (!GC_dont_precollect) GC_gcollect_inner();
|
||||
GC_is_initialized = TRUE;
|
||||
# ifdef STUBBORN_ALLOC
|
||||
GC_stubborn_init();
|
||||
# endif
|
||||
GC_is_initialized = TRUE;
|
||||
/* Convince lint that some things are used */
|
||||
# ifdef LINT
|
||||
{
|
||||
|
@ -631,25 +669,41 @@ out:
|
|||
}
|
||||
|
||||
|
||||
#ifdef MSWIN32
|
||||
# define LOG_FILE "gc.log"
|
||||
#if defined(MSWIN32) || defined(MSWINCE)
|
||||
# define LOG_FILE _T("gc.log")
|
||||
|
||||
HANDLE GC_stdout = 0, GC_stderr;
|
||||
int GC_tmp;
|
||||
DWORD GC_junk;
|
||||
HANDLE GC_stdout = 0;
|
||||
|
||||
void GC_set_files()
|
||||
void GC_deinit()
|
||||
{
|
||||
if (!GC_stdout) {
|
||||
GC_stdout = CreateFile(LOG_FILE, GENERIC_WRITE,
|
||||
FILE_SHARE_READ | FILE_SHARE_WRITE,
|
||||
NULL, CREATE_ALWAYS, FILE_FLAG_WRITE_THROUGH,
|
||||
NULL);
|
||||
if (INVALID_HANDLE_VALUE == GC_stdout) ABORT("Open of log file failed");
|
||||
}
|
||||
if (GC_stderr == 0) {
|
||||
GC_stderr = GC_stdout;
|
||||
}
|
||||
if (GC_is_initialized) {
|
||||
DeleteCriticalSection(&GC_write_cs);
|
||||
}
|
||||
}
|
||||
|
||||
int GC_write(buf, len)
|
||||
char * buf;
|
||||
size_t len;
|
||||
{
|
||||
BOOL tmp;
|
||||
DWORD written;
|
||||
if (len == 0)
|
||||
return 0;
|
||||
EnterCriticalSection(&GC_write_cs);
|
||||
if (GC_stdout == INVALID_HANDLE_VALUE) {
|
||||
return -1;
|
||||
} else if (GC_stdout == 0) {
|
||||
GC_stdout = CreateFile(LOG_FILE, GENERIC_WRITE,
|
||||
FILE_SHARE_READ | FILE_SHARE_WRITE,
|
||||
NULL, CREATE_ALWAYS, FILE_FLAG_WRITE_THROUGH,
|
||||
NULL);
|
||||
if (GC_stdout == INVALID_HANDLE_VALUE) ABORT("Open of log file failed");
|
||||
}
|
||||
tmp = WriteFile(GC_stdout, buf, len, &written, NULL);
|
||||
if (!tmp)
|
||||
DebugBreak();
|
||||
LeaveCriticalSection(&GC_write_cs);
|
||||
return tmp ? (int)written : -1;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -670,7 +724,7 @@ int GC_tmp; /* Should really be local ... */
|
|||
}
|
||||
#endif
|
||||
|
||||
#if !defined(OS2) && !defined(MACOS) && !defined(MSWIN32)
|
||||
#if !defined(OS2) && !defined(MACOS) && !defined(MSWIN32) && !defined(MSWINCE)
|
||||
int GC_stdout = 1;
|
||||
int GC_stderr = 2;
|
||||
# if !defined(AMIGA)
|
||||
|
@ -678,7 +732,7 @@ int GC_tmp; /* Should really be local ... */
|
|||
# endif
|
||||
#endif
|
||||
|
||||
#if !defined(MSWIN32) && !defined(OS2) && !defined(MACOS) && !defined(ECOS)
|
||||
#if !defined(MSWIN32) && !defined(MSWINCE) && !defined(OS2) && !defined(MACOS)
|
||||
int GC_write(fd, buf, len)
|
||||
int fd;
|
||||
char *buf;
|
||||
|
@ -710,11 +764,8 @@ int GC_write(fd, buf, len)
|
|||
#endif
|
||||
|
||||
|
||||
#ifdef MSWIN32
|
||||
# define WRITE(f, buf, len) (GC_set_files(), \
|
||||
GC_tmp = WriteFile((f), (buf), \
|
||||
(len), &GC_junk, NULL),\
|
||||
(GC_tmp? 1 : -1))
|
||||
#if defined(MSWIN32) || defined(MSWINCE)
|
||||
# define WRITE(f, buf, len) GC_write(buf, len)
|
||||
#else
|
||||
# if defined(OS2) || defined(MACOS)
|
||||
# define WRITE(f, buf, len) (GC_set_files(), \
|
||||
|
@ -732,7 +783,7 @@ int GC_write(fd, buf, len)
|
|||
/* same size as long, and that the format conversions expect something */
|
||||
/* of that size. */
|
||||
void GC_printf(format, a, b, c, d, e, f)
|
||||
char * format;
|
||||
GC_CONST char * format;
|
||||
long a, b, c, d, e, f;
|
||||
{
|
||||
char buf[1025];
|
||||
|
@ -745,7 +796,7 @@ long a, b, c, d, e, f;
|
|||
}
|
||||
|
||||
void GC_err_printf(format, a, b, c, d, e, f)
|
||||
char * format;
|
||||
GC_CONST char * format;
|
||||
long a, b, c, d, e, f;
|
||||
{
|
||||
char buf[1025];
|
||||
|
@ -757,11 +808,20 @@ long a, b, c, d, e, f;
|
|||
}
|
||||
|
||||
void GC_err_puts(s)
|
||||
char *s;
|
||||
GC_CONST char *s;
|
||||
{
|
||||
if (WRITE(GC_stderr, s, strlen(s)) < 0) ABORT("write to stderr failed");
|
||||
}
|
||||
|
||||
#if defined(LINUX) && !defined(SMALL_CONFIG)
|
||||
void GC_err_write(buf, len)
|
||||
GC_CONST char *buf;
|
||||
size_t len;
|
||||
{
|
||||
if (WRITE(GC_stderr, buf, len) < 0) ABORT("write to stderr failed");
|
||||
}
|
||||
#endif
|
||||
|
||||
# if defined(__STDC__) || defined(__cplusplus)
|
||||
void GC_default_warn_proc(char *msg, GC_word arg)
|
||||
# else
|
||||
|
@ -794,10 +854,26 @@ GC_warn_proc GC_current_warn_proc = GC_default_warn_proc;
|
|||
|
||||
#ifndef PCR
|
||||
void GC_abort(msg)
|
||||
char * msg;
|
||||
GC_CONST char * msg;
|
||||
{
|
||||
GC_err_printf1("%s\n", msg);
|
||||
(void) abort();
|
||||
# if defined(MSWIN32)
|
||||
(void) MessageBoxA(NULL, msg, "Fatal error in gc", MB_ICONERROR|MB_OK);
|
||||
DebugBreak();
|
||||
# else
|
||||
GC_err_printf1("%s\n", msg);
|
||||
# endif
|
||||
if (GETENV("GC_LOOP_ON_ABORT") != NULL) {
|
||||
/* In many cases it's easier to debug a running process. */
|
||||
/* It's arguably nicer to sleep, but that makes it harder */
|
||||
/* to look at the thread if the debugger doesn't know much */
|
||||
/* about threads. */
|
||||
for(;;);
|
||||
}
|
||||
# ifdef MSWIN32
|
||||
DebugBreak();
|
||||
# else
|
||||
(void) abort();
|
||||
# endif
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -860,4 +936,4 @@ void GC_dump()
|
|||
GC_print_block_list();
|
||||
}
|
||||
|
||||
# endif /* NO_DEBUGGING */
|
||||
#endif /* NO_DEBUGGING */
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
/*
|
||||
* Copyright 1988, 1989 Hans-J. Boehm, Alan J. Demers
|
||||
* Copyright (c) 1991-1994 by Xerox Corporation. All rights reserved.
|
||||
* Copyright (c) 2000 by Hewlett-Packard Company. All rights reserved.
|
||||
*
|
||||
* THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED
|
||||
* OR IMPLIED. ANY USE IS AT YOUR OWN RISK.
|
||||
|
@ -19,7 +20,7 @@
|
|||
|
||||
|
||||
# include <stdio.h>
|
||||
# include "gc_priv.h"
|
||||
# include "private/gc_priv.h"
|
||||
|
||||
#ifndef SMALL_CONFIG
|
||||
/*
|
||||
|
@ -30,7 +31,7 @@ ptr_t GC_build_fl1(h, ofl)
|
|||
struct hblk *h;
|
||||
ptr_t ofl;
|
||||
{
|
||||
register word * p = (word *)h;
|
||||
register word * p = h -> hb_body;
|
||||
register word * lim = (word *)(h + 1);
|
||||
|
||||
p[0] = (word)ofl;
|
||||
|
@ -52,7 +53,7 @@ ptr_t GC_build_fl_clear2(h, ofl)
|
|||
struct hblk *h;
|
||||
ptr_t ofl;
|
||||
{
|
||||
register word * p = (word *)h;
|
||||
register word * p = h -> hb_body;
|
||||
register word * lim = (word *)(h + 1);
|
||||
|
||||
p[0] = (word)ofl;
|
||||
|
@ -74,7 +75,7 @@ ptr_t GC_build_fl_clear3(h, ofl)
|
|||
struct hblk *h;
|
||||
ptr_t ofl;
|
||||
{
|
||||
register word * p = (word *)h;
|
||||
register word * p = h -> hb_body;
|
||||
register word * lim = (word *)(h + 1) - 2;
|
||||
|
||||
p[0] = (word)ofl;
|
||||
|
@ -94,7 +95,7 @@ ptr_t GC_build_fl_clear4(h, ofl)
|
|||
struct hblk *h;
|
||||
ptr_t ofl;
|
||||
{
|
||||
register word * p = (word *)h;
|
||||
register word * p = h -> hb_body;
|
||||
register word * lim = (word *)(h + 1);
|
||||
|
||||
p[0] = (word)ofl;
|
||||
|
@ -116,7 +117,7 @@ ptr_t GC_build_fl2(h, ofl)
|
|||
struct hblk *h;
|
||||
ptr_t ofl;
|
||||
{
|
||||
register word * p = (word *)h;
|
||||
register word * p = h -> hb_body;
|
||||
register word * lim = (word *)(h + 1);
|
||||
|
||||
p[0] = (word)ofl;
|
||||
|
@ -134,7 +135,7 @@ ptr_t GC_build_fl4(h, ofl)
|
|||
struct hblk *h;
|
||||
ptr_t ofl;
|
||||
{
|
||||
register word * p = (word *)h;
|
||||
register word * p = h -> hb_body;
|
||||
register word * lim = (word *)(h + 1);
|
||||
|
||||
p[0] = (word)ofl;
|
||||
|
@ -150,71 +151,51 @@ ptr_t ofl;
|
|||
|
||||
#endif /* !SMALL_CONFIG */
|
||||
|
||||
/*
|
||||
* Allocate a new heapblock for small objects of size n.
|
||||
* Add all of the heapblock's objects to the free list for objects
|
||||
* of that size.
|
||||
* Set all mark bits if objects are uncollectable.
|
||||
* Will fail to do anything if we are out of memory.
|
||||
*/
|
||||
void GC_new_hblk(sz, kind)
|
||||
register word sz;
|
||||
int kind;
|
||||
|
||||
/* Build a free list for objects of size sz inside heap block h. */
|
||||
/* Clear objects inside h if clear is set. Add list to the end of */
|
||||
/* the free list we build. Return the new free list. */
|
||||
/* This could be called without the main GC lock, if we ensure that */
|
||||
/* there is no concurrent collection which might reclaim objects that */
|
||||
/* we have not yet allocated. */
|
||||
ptr_t GC_build_fl(h, sz, clear, list)
|
||||
struct hblk *h;
|
||||
word sz;
|
||||
GC_bool clear;
|
||||
ptr_t list;
|
||||
{
|
||||
register word *p,
|
||||
*prev;
|
||||
word *last_object; /* points to last object in new hblk */
|
||||
register struct hblk *h; /* the new heap block */
|
||||
register GC_bool clear = GC_obj_kinds[kind].ok_init;
|
||||
word *p, *prev;
|
||||
word *last_object; /* points to last object in new hblk */
|
||||
|
||||
# ifdef PRINTSTATS
|
||||
if ((sizeof (struct hblk)) > HBLKSIZE) {
|
||||
ABORT("HBLK SZ inconsistency");
|
||||
}
|
||||
# endif
|
||||
|
||||
/* Allocate a new heap block */
|
||||
h = GC_allochblk(sz, kind, 0);
|
||||
if (h == 0) return;
|
||||
|
||||
/* Mark all objects if appropriate. */
|
||||
if (IS_UNCOLLECTABLE(kind)) GC_set_hdr_marks(HDR(h));
|
||||
|
||||
PREFETCH_FOR_WRITE((char *)h);
|
||||
PREFETCH_FOR_WRITE((char *)h + 128);
|
||||
PREFETCH_FOR_WRITE((char *)h + 256);
|
||||
PREFETCH_FOR_WRITE((char *)h + 378);
|
||||
/* Do a few prefetches here, just because its cheap. */
|
||||
/* If we were more serious about it, these should go inside */
|
||||
/* the loops. But write prefetches usually don't seem to */
|
||||
/* matter much. */
|
||||
PREFETCH_FOR_WRITE((char *)h);
|
||||
PREFETCH_FOR_WRITE((char *)h + 128);
|
||||
PREFETCH_FOR_WRITE((char *)h + 256);
|
||||
PREFETCH_FOR_WRITE((char *)h + 378);
|
||||
/* Handle small objects sizes more efficiently. For larger objects */
|
||||
/* the difference is less significant. */
|
||||
# ifndef SMALL_CONFIG
|
||||
switch (sz) {
|
||||
case 1: GC_obj_kinds[kind].ok_freelist[1] =
|
||||
GC_build_fl1(h, GC_obj_kinds[kind].ok_freelist[1]);
|
||||
return;
|
||||
case 1: return GC_build_fl1(h, list);
|
||||
case 2: if (clear) {
|
||||
GC_obj_kinds[kind].ok_freelist[2] =
|
||||
GC_build_fl_clear2(h, GC_obj_kinds[kind].ok_freelist[2]);
|
||||
return GC_build_fl_clear2(h, list);
|
||||
} else {
|
||||
GC_obj_kinds[kind].ok_freelist[2] =
|
||||
GC_build_fl2(h, GC_obj_kinds[kind].ok_freelist[2]);
|
||||
return GC_build_fl2(h, list);
|
||||
}
|
||||
return;
|
||||
case 3: if (clear) {
|
||||
GC_obj_kinds[kind].ok_freelist[3] =
|
||||
GC_build_fl_clear3(h, GC_obj_kinds[kind].ok_freelist[3]);
|
||||
return;
|
||||
return GC_build_fl_clear3(h, list);
|
||||
} else {
|
||||
/* It's messy to do better than the default here. */
|
||||
break;
|
||||
}
|
||||
case 4: if (clear) {
|
||||
GC_obj_kinds[kind].ok_freelist[4] =
|
||||
GC_build_fl_clear4(h, GC_obj_kinds[kind].ok_freelist[4]);
|
||||
return GC_build_fl_clear4(h, list);
|
||||
} else {
|
||||
GC_obj_kinds[kind].ok_freelist[4] =
|
||||
GC_build_fl4(h, GC_obj_kinds[kind].ok_freelist[4]);
|
||||
return GC_build_fl4(h, list);
|
||||
}
|
||||
return;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -243,7 +224,39 @@ int kind;
|
|||
* put p (which is now head of list of objects in *h) as first
|
||||
* pointer in the appropriate free list for this size.
|
||||
*/
|
||||
obj_link(h -> hb_body) = GC_obj_kinds[kind].ok_freelist[sz];
|
||||
GC_obj_kinds[kind].ok_freelist[sz] = ((ptr_t)p);
|
||||
obj_link(h -> hb_body) = list;
|
||||
return ((ptr_t)p);
|
||||
}
|
||||
|
||||
/*
|
||||
* Allocate a new heapblock for small objects of size n.
|
||||
* Add all of the heapblock's objects to the free list for objects
|
||||
* of that size.
|
||||
* Set all mark bits if objects are uncollectable.
|
||||
* Will fail to do anything if we are out of memory.
|
||||
*/
|
||||
void GC_new_hblk(sz, kind)
|
||||
register word sz;
|
||||
int kind;
|
||||
{
|
||||
register struct hblk *h; /* the new heap block */
|
||||
register GC_bool clear = GC_obj_kinds[kind].ok_init;
|
||||
|
||||
# ifdef PRINTSTATS
|
||||
if ((sizeof (struct hblk)) > HBLKSIZE) {
|
||||
ABORT("HBLK SZ inconsistency");
|
||||
}
|
||||
# endif
|
||||
|
||||
/* Allocate a new heap block */
|
||||
h = GC_allochblk(sz, kind, 0);
|
||||
if (h == 0) return;
|
||||
|
||||
/* Mark all objects if appropriate. */
|
||||
if (IS_UNCOLLECTABLE(kind)) GC_set_hdr_marks(HDR(h));
|
||||
|
||||
/* Build the free list */
|
||||
GC_obj_kinds[kind].ok_freelist[sz] =
|
||||
GC_build_fl(h, sz, clear, GC_obj_kinds[kind].ok_freelist[sz]);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,312 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 1999 by Silicon Graphics. All rights reserved.
|
||||
*
|
||||
* THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED
|
||||
* OR IMPLIED. ANY USE IS AT YOUR OWN RISK.
|
||||
*
|
||||
* Permission is hereby granted to use or copy this program
|
||||
* for any purpose, provided the above notices are retained on all copies.
|
||||
* Permission to modify the code and to distribute modified code is granted,
|
||||
* provided the above notices are retained, and a notice that the code was
|
||||
* modified is included with the above copyright notice.
|
||||
*/
|
||||
|
||||
#ifdef NURSERY
|
||||
??? This implementation is incomplete. If you are trying to
|
||||
??? compile this you are doing something wrong.
|
||||
|
||||
#include "nursery.h"
|
||||
|
||||
#define SCAN_STATICS_FOR_NURSERY
|
||||
/* If this is not defined, the collector will not see */
|
||||
/* references from static data areas to the nursery. */
|
||||
|
||||
struct copy_obj {
|
||||
ptr_t forward; /* Forwarding link for copied objects. */
|
||||
GC_copy_descriptor descr; /* Object descriptor */
|
||||
word data[1];
|
||||
}
|
||||
|
||||
ptr_t GC_nursery_start; /* Start of nursery area. */
|
||||
/* Must be NURSERY_BLOCK_SIZE */
|
||||
/* aligned. */
|
||||
ptr_t GC_nursery_end; /* End of nursery area. */
|
||||
unsigned char * GC_nursery_map;
|
||||
/* GC_nursery_map[i] != 0 if an object */
|
||||
/* starts on the ith 64-bit "word" of */
|
||||
/* nursery. This simple structure has */
|
||||
/* the advantage that */
|
||||
/* allocation is cheap. Lookup is */
|
||||
/* cheap for pointers to the head of */
|
||||
/* an object, which should be the */
|
||||
/* usual case. */
|
||||
# define NURSERY_MAP_NOT_START 0 /* Not start of object. */
|
||||
# define NURSERY_MAP_START 1 /* Start of object. */
|
||||
# define NURSERY_MAP_PINNED 2 /* Start of pinned obj. */
|
||||
|
||||
# ifdef ALIGN_DOUBLE
|
||||
# define NURSERY_WORD_SIZE (2 * sizeof(word))
|
||||
# else
|
||||
# define NURSERY_WORD_SIZE sizeof(word)
|
||||
# endif
|
||||
|
||||
# define NURSERY_BLOCK_SIZE (HBLKSIZE/2)
|
||||
/* HBLKSIZE must be a multiple of NURSERY_BLOCK_SIZE */
|
||||
# define NURSERY_SIZE (1024 * NURSERY_BLOCK_SIZE)
|
||||
|
||||
size_t GC_nursery_size = NURSERY_SIZE;
|
||||
/* Must be multiple of NURSERY_BLOCK_SIZE */
|
||||
|
||||
size_t GC_nursery_blocks; /* Number of blocks in the nursery. */
|
||||
|
||||
unsigned GC_next_nursery_block; /* index of next block we will attempt */
|
||||
/* allocate from during this cycle. */
|
||||
/* If it is pinned, we won't actually */
|
||||
/* use it. */
|
||||
|
||||
unsigned short *GC_pinned; /* Number of pinned objects in ith */
|
||||
/* nursery block. */
|
||||
/* GC_pinned[i] != 0 if the ith nursery */
|
||||
/* block is pinned, and thus not used */
|
||||
/* for allocation. */
|
||||
|
||||
GC_copy_alloc_state global_alloc_state = (ptr_t)(-1); /* will overflow. */
|
||||
|
||||
/* Array of known rescuing pointers from the heap to the nursery. */
|
||||
ptr_t ** nursery_rescuers;
|
||||
/* Pointer to one past the last slot in rescuer table */
|
||||
ptr_t ** nursery_rescuers_end;
|
||||
/* Maximum number of known rescuing pointers. */
|
||||
# define MAX_NURSERY_RESCUERS 32*1024
|
||||
/* Add a rescuer to the list */
|
||||
# define ADD_NURSERY_RESCUER(p) \
|
||||
if (nursery_rescuers_end >= nursery_rescuers + MAX_NURSERY_RESCUERS) { \
|
||||
ABORT("Nursery recuers overflow"); /* Fix later !!! */ \
|
||||
} else { \
|
||||
*nursery_rescuers_end++ = p; \
|
||||
}
|
||||
/* Remove rescuer at the given position in the table */
|
||||
# define REMOVE_RESCUER(p) \
|
||||
*p = *--nursery_rescuers_end
|
||||
|
||||
/* Should be called with allocator lock held. */
|
||||
GC_nursery_init() {
|
||||
GC_nursery_start = GET_MEM(GC_nursery_size);
|
||||
GC_nursery_end = GC_nursery_start + GC_nursery_size;
|
||||
GC_next_nursery_block = 0;
|
||||
if (GC_nursery_start < GC_least_plausible_heap_addr) {
|
||||
GC_least_plausible_heap_addr = GC_nursery_start;
|
||||
}
|
||||
if (GC_nursery_end > GC_greatest_plausible_heap_addr) {
|
||||
GC_greatest_plausible_heap_addr = GC_nursery_end;
|
||||
}
|
||||
if (GC_nursery_start & (NURSERY_BLOCK_SIZE-1)) {
|
||||
GC_err_printf1("Nursery area is misaligned!!");
|
||||
/* This should be impossible, since GET_MEM returns HBLKSIZE */
|
||||
/* aligned chunks, and that should be a multiple of */
|
||||
/* NURSERY_BLOCK_SIZE */
|
||||
ABORT("misaligned nursery");
|
||||
}
|
||||
GC_nursery_map = GET_MEM(GC_nursery_size/NURSERY_WORD_SIZE);
|
||||
/* Map is cleared a block at a time when we allocate from the block. */
|
||||
/* BZERO(GC_nursery_map, GC_nursery_size/NURSERY_WORD_SIZE); */
|
||||
GC_nursery_blocks = GC_nursery_size/NURSERY_BLOCK_SIZE;
|
||||
GC_pinned = GC_scratch_alloc(GC_nursery_blocks * sizeof(unsigned short));
|
||||
BZERO(GC_pinned, GC_nursery_blocks);
|
||||
nursery_rescuers = GET_MEM(MAX_NURSERY_RESCUERS * sizeof(ptr_t *));
|
||||
nursery_rescuers_end = nursery_rescuers;
|
||||
if (0 == GC_nursery_start || 0 == GC_nursery_map || 0 == nursery_rescuers)
|
||||
ABORT("Insufficient memory for nursery");
|
||||
}
|
||||
|
||||
#define PIN_OBJ(p) \
|
||||
if (p >= GC_nursery_start && p < GC_nursery_end) { GC_pin_obj_checked(p); }
|
||||
|
||||
/* Pin the object at p, if it's in the nursery. */
|
||||
void GC_pin_obj(ptr_t p) {
|
||||
PIN_OBJ(p);
|
||||
}
|
||||
|
||||
void (*GC_push_proc)(ptr_t) = 0;
|
||||
|
||||
/* Pin the object at p, which is known to be in the nursery. */
|
||||
void GC_pin_obj_checked(ptr_t p) {
|
||||
unsigned offset = p - GC_nursery_start;
|
||||
unsigned word_offset = BYTES_TO_WORDS(offset);
|
||||
unsigned blockno = (current - GC_nursery_start)/NURSERY_BLOCK_SIZE;
|
||||
while (GC_nursery_map[word_offset] == NURSERY_MAP_NOT_START) {
|
||||
--word_offset;
|
||||
}
|
||||
if (GC_nursery_map[word_offset] != NURSERY_MAP_PINNED) {
|
||||
GC_nursery_map[word_offset] = NURSERY_MAP_PINNED;
|
||||
++GC_pinned[blockno];
|
||||
??Push object at GC_nursery_start + WORDS_TO_BYTES(word_offset)
|
||||
??onto mark stack.
|
||||
}
|
||||
}
|
||||
|
||||
void GC_scan_region_for_nursery(ptr_t low, ptr_t high) {
|
||||
# if CPP_WORDSZ/8 != ALIGNMENT
|
||||
--> fix this
|
||||
# endif
|
||||
word * l = (word *)((word)low + ALIGNMENT - 1 & ~(ALIGNMENT - 1));
|
||||
word * h = (word *)((word)high & ~(ALIGNMENT - 1));
|
||||
word * p;
|
||||
for (p = l; p < h; ++p) {
|
||||
PIN_OBJ(p);
|
||||
}
|
||||
}
|
||||
|
||||
/* Invoke GC_scan_region_for_nursery on ranges that are not excluded. */
|
||||
void GC_scan_region_for_nursery_with_exclusions(ptr_t bottom, ptr_t top)
|
||||
{
|
||||
struct exclusion * next;
|
||||
ptr_t excl_start;
|
||||
|
||||
while (bottom < top) {
|
||||
next = GC_next_exclusion(bottom);
|
||||
if (0 == next || (excl_start = next -> e_start) >= top) {
|
||||
GC_scan_region_for_nursery(bottom, top);
|
||||
return;
|
||||
}
|
||||
if (excl_start > bottom)
|
||||
GC_scan_region_for_nursery(bottom, excl_start);
|
||||
bottom = next -> e_end;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void GC_scan_stacks_for_nursery(void) {
|
||||
# ifdef THREADS
|
||||
--> fix this
|
||||
# endif
|
||||
# ifdef STACK_GROWS_DOWN
|
||||
ptr_t stack_low = GC_approx_sp();
|
||||
ptr_t stack_high = GC_stackbottom;
|
||||
# else
|
||||
ptr_t stack_low = GC_stackbottom;
|
||||
ptr_t stack_high = GC_approx_sp();
|
||||
# endif
|
||||
GC_scan_region_for_nursery(stack_low, stack_high);
|
||||
# ifdef IA64
|
||||
GC_scan_region_for_nursery(BACKING_STORE_BASE,
|
||||
(ptr_t) GC_save_regs_ret_val);
|
||||
# endif
|
||||
}
|
||||
|
||||
void GC_scan_roots_for_nursery(void) {
|
||||
/* Scan registers. */
|
||||
/* Direct GC_push_one to call GC_pin_obj instead of marking */
|
||||
/* and pushing objects. */
|
||||
/* This is a bit ugly, but we don't have to touch the */
|
||||
/* platform-dependent code. */
|
||||
|
||||
void (*old_push_proc)(ptr_t) = GC_push_proc;
|
||||
GC_push_proc = GC_pin_obj;
|
||||
GC_push_regs();
|
||||
GC_push_proc = old_push_proc;
|
||||
GC_scan_stacks_for_nursery();
|
||||
# ifdef SCAN_STATICS_FOR_NURSERY
|
||||
# if (defined(DYNAMIC_LOADING) || defined(MSWIN32) || defined(PCR)) \
|
||||
&& !defined(SRC_M3)
|
||||
GC_remove_tmp_roots();
|
||||
GC_register_dynamic_libraries();
|
||||
# endif
|
||||
/* Mark everything in static data areas */
|
||||
for (i = 0; i < n_root_sets; i++) {
|
||||
GC_scan_region_for_nursery_with_exclusions (
|
||||
GC_static_roots[i].r_start,
|
||||
GC_static_roots[i].r_end);
|
||||
}
|
||||
# endif
|
||||
}
|
||||
|
||||
/* Array of known rescuing pointers from the heap to the nursery. */
|
||||
ptr_t ** nursery_rescuers;
|
||||
|
||||
/* Caller holds allocation lock. */
|
||||
void GC_collect_nursery(void) {
|
||||
int i;
|
||||
ptr_t scan_ptr = 0;
|
||||
STOP_WORLD;
|
||||
for (i = 0; i < GC_nursery_blocks; ++i) GC_pinned[i] = 0;
|
||||
GC_scan_roots_for_nursery();
|
||||
/* All objects referenced by roots are now pinned. */
|
||||
/* Their contents are described by */
|
||||
/* mark stack entries. */
|
||||
|
||||
/* Pin blocks corresponding to valid allocation states. */
|
||||
/* that probably happens automagically if the allocation */
|
||||
/* states are kept where we can see them. */
|
||||
/* It will take work if static roots are not scanned. */
|
||||
/* We want to do this both for correctness and to avoid */
|
||||
/* promoting very young objects. */
|
||||
|
||||
/* Somehow capture dirty bits. Update rescuers array to */
|
||||
/* reflect newly valid and invalid references from dirty */
|
||||
/* pages. Other references should remain valid, since the */
|
||||
/* referents should have been pinned. */
|
||||
|
||||
/* Traverse the old object heap. Pin objects in the */
|
||||
/* nursery that are ambiguously referenced, copy those */
|
||||
/* that are unambiguously referenced. */
|
||||
|
||||
/* Traverse objects in mark stack. */
|
||||
/* If referenced object is in pinned block, add contents */
|
||||
/* to mark stack. If referenced object is forwarded, */
|
||||
/* update pointer. Otherwise reallocate the object in the */
|
||||
/* old heap, copy its contents, and then enqueue its */
|
||||
/* contents in the mark stack. */
|
||||
START_WORLD;
|
||||
}
|
||||
|
||||
/* Initialize an allocation state so that it can be used for */
|
||||
/* allocation. This implicitly reserves a small section of the */
|
||||
/* nursery for use with this allocator. */
|
||||
/* Also called to replenish an allocator that has been */
|
||||
/* exhausted. */
|
||||
void GC_init_copy_alloc_state(GC_copy_alloc_state *)
|
||||
unsigned next_block;
|
||||
ptr_t block_addr;
|
||||
LOCK();
|
||||
next_block = GC_next_nursery_block;
|
||||
while(is_pinned[next_block] && next_block < GC_nursery_blocks) {
|
||||
++next_block;
|
||||
}
|
||||
if (next_block < GC_nursery_blocks) {
|
||||
block_addr = GC_nursery_start + NURSERY_BLOCK_SIZE * next_block;
|
||||
GC_next_nursery_block = next_block + 1;
|
||||
BZERO(GC_nursery_map + next_block *
|
||||
(NURSERY_BLOCK_SIZE/NURSERY_WORD_SIZE),
|
||||
NURSERY_BLOCK_SIZE/NURSERY_WORD_SIZE);
|
||||
*GC_copy_alloc_state = block_addr;
|
||||
UNLOCK();
|
||||
} else {
|
||||
GC_collect_nursery();
|
||||
GC_next_nursery_block = 0;
|
||||
UNLOCK();
|
||||
get_new_block(s);
|
||||
}
|
||||
}
|
||||
|
||||
GC_PTR GC_copying_malloc2(GC_copy_descriptor *d, GC_copy_alloc_state *s) {
|
||||
size_t sz = GC_SIZE_FROM_DESCRIPTOR(d);
|
||||
ptrdiff_t offset;
|
||||
ptr_t result = *s;
|
||||
ptr_t new = result + sz;
|
||||
if (new & COPY_BLOCK_MASK <= result & COPY_BLOCK_MASK> {
|
||||
GC_init_copy_alloc_state(s);
|
||||
result = *s;
|
||||
new = result + sz;
|
||||
GC_ASSERT(new & COPY_BLOCK_MASK > result & COPY_BLOCK_MASK>
|
||||
}
|
||||
(struct copy_obj *)result -> descr = d;
|
||||
(struct copy_obj *)result -> forward = 0;
|
||||
offset = (result - GC_nursery_start)/NURSERY_WORD_SIZE;
|
||||
GC_nursery_map[offset] = NURSERY_MAP_NOT_START;
|
||||
}
|
||||
|
||||
GC_PTR GC_copying_malloc(GC_copy_descriptor *d) {
|
||||
}
|
||||
|
||||
#endif /* NURSERY */
|
|
@ -1,6 +1,7 @@
|
|||
/*
|
||||
* Copyright 1988, 1989 Hans-J. Boehm, Alan J. Demers
|
||||
* Copyright (c) 1991, 1992 by Xerox Corporation. All rights reserved.
|
||||
* Copyright (c) 1999-2001 by Hewlett-Packard Company. All rights reserved.
|
||||
*
|
||||
* THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED
|
||||
* OR IMPLIED. ANY USE IS AT YOUR OWN RISK.
|
||||
|
@ -11,7 +12,6 @@
|
|||
* provided the above notices are retained, and a notice that the code was
|
||||
* modified is included with the above copyright notice.
|
||||
*/
|
||||
/* Boehm, October 9, 1995 1:09 pm PDT */
|
||||
|
||||
/* Routines for maintaining maps describing heap block
|
||||
* layouts for various object sizes. Allows fast pointer validity checks
|
||||
|
@ -19,9 +19,9 @@
|
|||
* with slow division.
|
||||
*/
|
||||
|
||||
# include "gc_priv.h"
|
||||
# include "private/gc_priv.h"
|
||||
|
||||
char * GC_invalid_map = 0;
|
||||
map_entry_type * GC_invalid_map = 0;
|
||||
|
||||
/* Invalidate the object map associated with a block. Free blocks */
|
||||
/* are identified by invalid maps. */
|
||||
|
@ -31,7 +31,7 @@ hdr *hhdr;
|
|||
register int displ;
|
||||
|
||||
if (GC_invalid_map == 0) {
|
||||
GC_invalid_map = GC_scratch_alloc(MAP_SIZE);
|
||||
GC_invalid_map = (map_entry_type *)GC_scratch_alloc(MAP_SIZE);
|
||||
if (GC_invalid_map == 0) {
|
||||
GC_err_printf0(
|
||||
"Cant initialize GC_invalid_map: insufficient memory\n");
|
||||
|
@ -54,7 +54,6 @@ hdr *hhdr;
|
|||
GC_word offset;
|
||||
# endif
|
||||
{
|
||||
# ifndef ALL_INTERIOR_POINTERS
|
||||
DCL_LOCK_STATE;
|
||||
|
||||
DISABLE_SIGNALS();
|
||||
|
@ -62,39 +61,40 @@ hdr *hhdr;
|
|||
GC_register_displacement_inner(offset);
|
||||
UNLOCK();
|
||||
ENABLE_SIGNALS();
|
||||
# endif
|
||||
}
|
||||
|
||||
void GC_register_displacement_inner(offset)
|
||||
word offset;
|
||||
{
|
||||
# ifndef ALL_INTERIOR_POINTERS
|
||||
register unsigned i;
|
||||
word map_entry = BYTES_TO_WORDS(offset);
|
||||
|
||||
if (offset > MAX_OFFSET) {
|
||||
if (offset >= VALID_OFFSET_SZ) {
|
||||
ABORT("Bad argument to GC_register_displacement");
|
||||
}
|
||||
if (map_entry > MAX_OFFSET) map_entry = OFFSET_TOO_BIG;
|
||||
if (!GC_valid_offsets[offset]) {
|
||||
GC_valid_offsets[offset] = TRUE;
|
||||
GC_modws_valid_offsets[offset % sizeof(word)] = TRUE;
|
||||
for (i = 0; i <= MAXOBJSZ; i++) {
|
||||
if (!GC_all_interior_pointers) {
|
||||
for (i = 0; i <= MAXOBJSZ; i++) {
|
||||
if (GC_obj_map[i] != 0) {
|
||||
if (i == 0) {
|
||||
GC_obj_map[i][offset + HDR_BYTES] = (char)BYTES_TO_WORDS(offset);
|
||||
GC_obj_map[i][offset] = (map_entry_type)map_entry;
|
||||
} else {
|
||||
register unsigned j;
|
||||
register unsigned lb = WORDS_TO_BYTES(i);
|
||||
|
||||
if (offset < lb) {
|
||||
for (j = offset + HDR_BYTES; j < HBLKSIZE; j += lb) {
|
||||
GC_obj_map[i][j] = (char)BYTES_TO_WORDS(offset);
|
||||
for (j = offset; j < HBLKSIZE; j += lb) {
|
||||
GC_obj_map[i][j] = (map_entry_type)map_entry;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
# endif
|
||||
}
|
||||
|
||||
|
||||
|
@ -105,13 +105,14 @@ word sz;
|
|||
{
|
||||
register unsigned obj_start;
|
||||
register unsigned displ;
|
||||
register char * new_map;
|
||||
register map_entry_type * new_map;
|
||||
word map_entry;
|
||||
|
||||
if (sz > MAXOBJSZ) sz = 0;
|
||||
if (GC_obj_map[sz] != 0) {
|
||||
return(TRUE);
|
||||
}
|
||||
new_map = GC_scratch_alloc(MAP_SIZE);
|
||||
new_map = (map_entry_type *)GC_scratch_alloc(MAP_SIZE);
|
||||
if (new_map == 0) return(FALSE);
|
||||
# ifdef PRINTSTATS
|
||||
GC_printf1("Adding block map for size %lu\n", (unsigned long)sz);
|
||||
|
@ -120,19 +121,23 @@ word sz;
|
|||
MAP_ENTRY(new_map,displ) = OBJ_INVALID;
|
||||
}
|
||||
if (sz == 0) {
|
||||
for(displ = 0; displ <= MAX_OFFSET; displ++) {
|
||||
for(displ = 0; displ <= HBLKSIZE; displ++) {
|
||||
if (OFFSET_VALID(displ)) {
|
||||
MAP_ENTRY(new_map,displ+HDR_BYTES) = BYTES_TO_WORDS(displ);
|
||||
map_entry = BYTES_TO_WORDS(displ);
|
||||
if (map_entry > MAX_OFFSET) map_entry = OFFSET_TOO_BIG;
|
||||
MAP_ENTRY(new_map,displ) = (map_entry_type)map_entry;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (obj_start = HDR_BYTES;
|
||||
for (obj_start = 0;
|
||||
obj_start + WORDS_TO_BYTES(sz) <= HBLKSIZE;
|
||||
obj_start += WORDS_TO_BYTES(sz)) {
|
||||
for (displ = 0; displ < WORDS_TO_BYTES(sz); displ++) {
|
||||
if (OFFSET_VALID(displ)) {
|
||||
map_entry = BYTES_TO_WORDS(displ);
|
||||
if (map_entry > MAX_OFFSET) map_entry = OFFSET_TOO_BIG;
|
||||
MAP_ENTRY(new_map, obj_start + displ) =
|
||||
BYTES_TO_WORDS(displ);
|
||||
(map_entry_type)map_entry;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
1016
boehm-gc/os_dep.c
1016
boehm-gc/os_dep.c
File diff suppressed because it is too large
Load diff
|
@ -1,4 +1,6 @@
|
|||
solaris_threads.c
|
||||
solaris_pthreads.c
|
||||
irix_threads.c
|
||||
pcr_interface.c
|
||||
real_malloc.c
|
||||
mips_mach_dep.s
|
||||
|
@ -8,8 +10,12 @@ sparc_mach_dep.s
|
|||
PCR-Makefile
|
||||
setjmp_t.c
|
||||
callprocs
|
||||
gc.man
|
||||
doc/gc.man
|
||||
pc_excludes
|
||||
barrett_diagram
|
||||
include/gc_c++.h
|
||||
include/gc_inline.h
|
||||
include/gc_inline.h
|
||||
doc/README.hp
|
||||
doc/README.rs6000
|
||||
doc/README.sgi
|
||||
|
||||
|
|
|
@ -10,8 +10,7 @@
|
|||
* provided the above notices are retained, and a notice that the code was
|
||||
* modified is included with the above copyright notice.
|
||||
*/
|
||||
/* Boehm, February 7, 1996 11:09 am PST */
|
||||
# include "gc_priv.h"
|
||||
# include "private/gc_priv.h"
|
||||
|
||||
# ifdef PCR
|
||||
/*
|
||||
|
@ -170,4 +169,10 @@ PCR_GC_Run(void)
|
|||
return PCR_ERes_okay;
|
||||
}
|
||||
|
||||
void GC_push_thread_structures(void)
|
||||
{
|
||||
/* PCR doesn't work unless static roots are pushed. Can't get here. */
|
||||
ABORT("In GC_push_thread_structures()");
|
||||
}
|
||||
|
||||
# endif
|
||||
|
|
|
@ -10,10 +10,13 @@
|
|||
* provided the above notices are retained, and a notice that the code was
|
||||
* modified is included with the above copyright notice.
|
||||
*/
|
||||
/* Boehm, September 19, 1995 1:26 pm PDT */
|
||||
|
||||
#include "gc_priv.h"
|
||||
#include "gc_mark.h"
|
||||
/*
|
||||
* These are checking routines calls to which could be inserted by a
|
||||
* preprocessor to validate C pointer arithmetic.
|
||||
*/
|
||||
|
||||
#include "private/gc_pmark.h"
|
||||
|
||||
#ifdef __STDC__
|
||||
void GC_default_same_obj_print_proc(GC_PTR p, GC_PTR q)
|
||||
|
@ -69,7 +72,7 @@ void (*GC_same_obj_print_proc) GC_PROTO((GC_PTR, GC_PTR))
|
|||
h = FORWARDED_ADDR(h, hhdr);
|
||||
hhdr = HDR(h);
|
||||
}
|
||||
limit = (ptr_t)((word *)h + HDR_WORDS + hhdr -> hb_sz);
|
||||
limit = (ptr_t)((word *)h + hhdr -> hb_sz);
|
||||
if ((ptr_t)p >= limit || (ptr_t)q >= limit || (ptr_t)q < (ptr_t)h ) {
|
||||
goto fail;
|
||||
}
|
||||
|
@ -83,28 +86,19 @@ void (*GC_same_obj_print_proc) GC_PROTO((GC_PTR, GC_PTR))
|
|||
goto fail;
|
||||
}
|
||||
} else {
|
||||
# ifdef ALL_INTERIOR_POINTERS
|
||||
register map_entry_type map_entry;
|
||||
register int pdispl;
|
||||
|
||||
pdispl = HBLKDISPL(p);
|
||||
map_entry = MAP_ENTRY((hhdr -> hb_map), pdispl);
|
||||
if (map_entry == OBJ_INVALID) {
|
||||
goto fail;
|
||||
} else {
|
||||
base = (char *)((word)p & ~(WORDS_TO_BYTES(1) - 1));
|
||||
base -= WORDS_TO_BYTES(map_entry);
|
||||
}
|
||||
# else
|
||||
register int offset = HBLKDISPL(p) - HDR_BYTES;
|
||||
register word correction = offset % sz;
|
||||
|
||||
if (HBLKPTR(p) != HBLKPTR(q)) {
|
||||
/* The following computation otherwise fails in this case */
|
||||
goto fail;
|
||||
}
|
||||
base = (ptr_t)p - correction;
|
||||
# endif
|
||||
register int map_entry;
|
||||
register int pdispl = HBLKDISPL(p);
|
||||
|
||||
map_entry = MAP_ENTRY((hhdr -> hb_map), pdispl);
|
||||
if (map_entry > CPP_MAX_OFFSET) {
|
||||
map_entry = BYTES_TO_WORDS(pdispl) % BYTES_TO_WORDS(sz);
|
||||
if (HBLKPTR(p) != HBLKPTR(q)) goto fail;
|
||||
/* W/o this check, we might miss an error if */
|
||||
/* q points to the first object on a page, and */
|
||||
/* points just before the page. */
|
||||
}
|
||||
base = (char *)((word)p & ~(WORDS_TO_BYTES(1) - 1));
|
||||
base -= WORDS_TO_BYTES(map_entry);
|
||||
limit = base + sz;
|
||||
}
|
||||
/* [base, limit) delimits the object containing p, if any. */
|
||||
|
@ -137,7 +131,7 @@ void (*GC_is_valid_displacement_print_proc) GC_PROTO((GC_PTR)) =
|
|||
|
||||
/* Check that if p is a pointer to a heap page, then it points to */
|
||||
/* a valid displacement within a heap object. */
|
||||
/* Uninteresting with ALL_INTERIOR_POINTERS. */
|
||||
/* Uninteresting with GC_all_interior_pointers. */
|
||||
/* Always returns its argument. */
|
||||
/* Note that we don't lock, since nothing relevant about the header */
|
||||
/* should change while we have a valid object pointer to the block. */
|
||||
|
@ -158,12 +152,12 @@ void (*GC_is_valid_displacement_print_proc) GC_PROTO((GC_PTR)) =
|
|||
hhdr = HDR((word)p);
|
||||
if (hhdr == 0) return(p);
|
||||
h = HBLKPTR(p);
|
||||
# ifdef ALL_INTERIOR_POINTERS
|
||||
if (GC_all_interior_pointers) {
|
||||
while (IS_FORWARDING_ADDR_OR_NIL(hhdr)) {
|
||||
h = FORWARDED_ADDR(h, hhdr);
|
||||
hhdr = HDR(h);
|
||||
}
|
||||
# endif
|
||||
}
|
||||
if (IS_FORWARDING_ADDR_OR_NIL(hhdr)) {
|
||||
goto fail;
|
||||
}
|
||||
|
@ -252,7 +246,8 @@ ptr_t p;
|
|||
|
||||
if (GC_is_static_root(p)) return(p);
|
||||
/* Else do it again correctly: */
|
||||
# if (defined(DYNAMIC_LOADING) || defined(MSWIN32) || defined(PCR)) \
|
||||
# if (defined(DYNAMIC_LOADING) || defined(MSWIN32) || \
|
||||
defined(MSWINCE) || defined(PCR)) \
|
||||
&& !defined(SRC_M3)
|
||||
DISABLE_SIGNALS();
|
||||
GC_register_dynamic_libraries();
|
||||
|
@ -270,23 +265,30 @@ ptr_t p;
|
|||
if (HBLKPTR(base) != HBLKPTR(p)) hhdr = HDR((word)p);
|
||||
descr = hhdr -> hb_descr;
|
||||
retry:
|
||||
switch(descr & DS_TAGS) {
|
||||
case DS_LENGTH:
|
||||
switch(descr & GC_DS_TAGS) {
|
||||
case GC_DS_LENGTH:
|
||||
if ((word)((ptr_t)p - (ptr_t)base) > (word)descr) goto fail;
|
||||
break;
|
||||
case DS_BITMAP:
|
||||
case GC_DS_BITMAP:
|
||||
if ((ptr_t)p - (ptr_t)base
|
||||
>= WORDS_TO_BYTES(BITMAP_BITS)
|
||||
|| ((word)p & (sizeof(word) - 1))) goto fail;
|
||||
if (!((1 << (WORDSZ - ((ptr_t)p - (ptr_t)base) - 1))
|
||||
& descr)) goto fail;
|
||||
break;
|
||||
case DS_PROC:
|
||||
case GC_DS_PROC:
|
||||
/* We could try to decipher this partially. */
|
||||
/* For now we just punt. */
|
||||
break;
|
||||
case DS_PER_OBJECT:
|
||||
descr = *(word *)((ptr_t)base + (descr & ~DS_TAGS));
|
||||
case GC_DS_PER_OBJECT:
|
||||
if ((signed_word)descr >= 0) {
|
||||
descr = *(word *)((ptr_t)base + (descr & ~GC_DS_TAGS));
|
||||
} else {
|
||||
ptr_t type_descr = *(ptr_t *)base;
|
||||
descr = *(word *)(type_descr
|
||||
- (descr - (GC_DS_PER_OBJECT
|
||||
- GC_INDIR_PER_OBJ_BIAS)));
|
||||
}
|
||||
goto retry;
|
||||
}
|
||||
return(p);
|
||||
|
@ -305,9 +307,9 @@ size_t how_much;
|
|||
GC_PTR initial = *p;
|
||||
GC_PTR result = GC_same_obj((GC_PTR)((word)initial + how_much), initial);
|
||||
|
||||
# ifndef ALL_INTERIOR_POINTERS
|
||||
if (!GC_all_interior_pointers) {
|
||||
(void) GC_is_valid_displacement(result);
|
||||
# endif
|
||||
}
|
||||
return (*p = result);
|
||||
}
|
||||
|
||||
|
@ -318,9 +320,9 @@ size_t how_much;
|
|||
GC_PTR initial = *p;
|
||||
GC_PTR result = GC_same_obj((GC_PTR)((word)initial + how_much), initial);
|
||||
|
||||
# ifndef ALL_INTERIOR_POINTERS
|
||||
if (!GC_all_interior_pointers) {
|
||||
(void) GC_is_valid_displacement(result);
|
||||
# endif
|
||||
}
|
||||
*p = result;
|
||||
return(initial);
|
||||
}
|
||||
|
|
|
@ -15,11 +15,18 @@
|
|||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include "gc_priv.h"
|
||||
#include "private/gc_priv.h"
|
||||
|
||||
signed_word GC_mem_found = 0;
|
||||
/* Number of words of memory reclaimed */
|
||||
|
||||
#ifdef PARALLEL_MARK
|
||||
word GC_fl_builder_count = 0;
|
||||
/* Number of threads currently building free lists without */
|
||||
/* holding GC lock. It is not safe to collect if this is */
|
||||
/* nonzero. */
|
||||
#endif /* PARALLEL_MARK */
|
||||
|
||||
static void report_leak(p, sz)
|
||||
ptr_t p;
|
||||
word sz;
|
||||
|
@ -54,9 +61,12 @@ word sz;
|
|||
GC_bool GC_block_empty(hhdr)
|
||||
register hdr * hhdr;
|
||||
{
|
||||
/* We treat hb_marks as an array of words here, even if it is */
|
||||
/* actually an array of bytes. Since we only check for zero, there */
|
||||
/* are no endian-ness issues. */
|
||||
register word *p = (word *)(&(hhdr -> hb_marks[0]));
|
||||
register word * plim =
|
||||
(word *)(&(hhdr -> hb_marks[MARK_BITS_SZ]));
|
||||
(word *)(&(hhdr -> hb_marks[MARK_BITS_SZ]));
|
||||
while (p < plim) {
|
||||
if (*p++) return(FALSE);
|
||||
}
|
||||
|
@ -70,7 +80,45 @@ register hdr * hhdr;
|
|||
# define GC_block_nearly_full1(hhdr, pat1) DONT_KNOW
|
||||
# define GC_block_nearly_full3(hhdr, pat1, pat2) DONT_KNOW
|
||||
# define GC_block_nearly_full(hhdr) DONT_KNOW
|
||||
#else
|
||||
#endif
|
||||
|
||||
#if !defined(SMALL_CONFIG) && defined(USE_MARK_BYTES)
|
||||
|
||||
# define GC_block_nearly_full1(hhdr, pat1) GC_block_nearly_full(hhdr)
|
||||
# define GC_block_nearly_full3(hhdr, pat1, pat2) GC_block_nearly_full(hhdr)
|
||||
|
||||
|
||||
GC_bool GC_block_nearly_full(hhdr)
|
||||
register hdr * hhdr;
|
||||
{
|
||||
/* We again treat hb_marks as an array of words, even though it */
|
||||
/* isn't. We first sum up all the words, resulting in a word */
|
||||
/* containing 4 or 8 separate partial sums. */
|
||||
/* We then sum the bytes in the word of partial sums. */
|
||||
/* This is still endian independant. This fails if the partial */
|
||||
/* sums can overflow. */
|
||||
# if (BYTES_TO_WORDS(MARK_BITS_SZ)) >= 256
|
||||
--> potential overflow; fix the code
|
||||
# endif
|
||||
register word *p = (word *)(&(hhdr -> hb_marks[0]));
|
||||
register word * plim =
|
||||
(word *)(&(hhdr -> hb_marks[MARK_BITS_SZ]));
|
||||
word sum_vector = 0;
|
||||
unsigned sum;
|
||||
while (p < plim) {
|
||||
sum_vector += *p;
|
||||
++p;
|
||||
}
|
||||
sum = 0;
|
||||
while (sum_vector > 0) {
|
||||
sum += sum_vector & 0xff;
|
||||
sum_vector >>= 8;
|
||||
}
|
||||
return (sum > BYTES_TO_WORDS(7*HBLKSIZE/8)/(hhdr -> hb_sz));
|
||||
}
|
||||
#endif /* USE_MARK_BYTES */
|
||||
|
||||
#if !defined(SMALL_CONFIG) && !defined(USE_MARK_BYTES)
|
||||
|
||||
/*
|
||||
* Test whether nearly all of the mark words consist of the same
|
||||
|
@ -139,8 +187,6 @@ hdr *hhdr;
|
|||
# if CPP_WORDSZ != 32 && CPP_WORDSZ != 64
|
||||
return DONT_KNOW; /* Shouldn't be used in any standard config. */
|
||||
# endif
|
||||
if (0 != HDR_WORDS) return DONT_KNOW;
|
||||
/* Also shouldn't happen */
|
||||
# if CPP_WORDSZ == 32
|
||||
switch(sz) {
|
||||
case 1:
|
||||
|
@ -194,12 +240,28 @@ hdr *hhdr;
|
|||
}
|
||||
# endif
|
||||
}
|
||||
#endif /* !SMALL_CONFIG */
|
||||
#endif /* !SMALL_CONFIG && !USE_MARK_BYTES */
|
||||
|
||||
# ifdef GATHERSTATS
|
||||
/* We keep track of reclaimed memory if we are either asked to, or */
|
||||
/* we are using the parallel marker. In the latter case, we assume */
|
||||
/* that most allocation goes through GC_malloc_many for scalability. */
|
||||
/* GC_malloc_many needs the count anyway. */
|
||||
# if defined(GATHERSTATS) || defined(PARALLEL_MARK)
|
||||
# define INCR_WORDS(sz) n_words_found += (sz)
|
||||
# define COUNT_PARAM , count
|
||||
# define COUNT_ARG , count
|
||||
# define COUNT_DECL signed_word * count;
|
||||
# define NWORDS_DECL signed_word n_words_found = 0;
|
||||
# define COUNT_UPDATE *count += n_words_found;
|
||||
# define MEM_FOUND_ADDR , &GC_mem_found
|
||||
# else
|
||||
# define INCR_WORDS(sz)
|
||||
# define COUNT_PARAM
|
||||
# define COUNT_ARG
|
||||
# define COUNT_DECL
|
||||
# define NWORDS_DECL
|
||||
# define COUNT_UPDATE
|
||||
# define MEM_FOUND_ADDR
|
||||
# endif
|
||||
/*
|
||||
* Restore unmarked small objects in h of size sz to the object
|
||||
|
@ -207,20 +269,20 @@ hdr *hhdr;
|
|||
* Clears unmarked objects.
|
||||
*/
|
||||
/*ARGSUSED*/
|
||||
ptr_t GC_reclaim_clear(hbp, hhdr, sz, list)
|
||||
ptr_t GC_reclaim_clear(hbp, hhdr, sz, list COUNT_PARAM)
|
||||
register struct hblk *hbp; /* ptr to current heap block */
|
||||
register hdr * hhdr;
|
||||
register ptr_t list;
|
||||
register word sz;
|
||||
COUNT_DECL
|
||||
{
|
||||
register int word_no;
|
||||
register word *p, *q, *plim;
|
||||
# ifdef GATHERSTATS
|
||||
register int n_words_found = 0;
|
||||
# endif
|
||||
NWORDS_DECL
|
||||
|
||||
GC_ASSERT(hhdr == GC_find_header((ptr_t)hbp));
|
||||
p = (word *)(hbp->hb_body);
|
||||
word_no = HDR_WORDS;
|
||||
word_no = 0;
|
||||
plim = (word *)((((word)hbp) + HBLKSIZE)
|
||||
- WORDS_TO_BYTES(sz));
|
||||
|
||||
|
@ -235,37 +297,45 @@ register word sz;
|
|||
list = ((ptr_t)p);
|
||||
/* Clear object, advance p to next object in the process */
|
||||
q = p + sz;
|
||||
p++; /* Skip link field */
|
||||
while (p < q) {
|
||||
# ifdef USE_MARK_BYTES
|
||||
GC_ASSERT(!(sz & 1)
|
||||
&& !((word)p & (2 * sizeof(word) - 1)));
|
||||
p[1] = 0;
|
||||
p += 2;
|
||||
while (p < q) {
|
||||
CLEAR_DOUBLE(p);
|
||||
p += 2;
|
||||
}
|
||||
# else
|
||||
p++; /* Skip link field */
|
||||
while (p < q) {
|
||||
*p++ = 0;
|
||||
}
|
||||
}
|
||||
# endif
|
||||
}
|
||||
word_no += sz;
|
||||
}
|
||||
# ifdef GATHERSTATS
|
||||
GC_mem_found += n_words_found;
|
||||
# endif
|
||||
COUNT_UPDATE
|
||||
return(list);
|
||||
}
|
||||
|
||||
#ifndef SMALL_CONFIG
|
||||
#if !defined(SMALL_CONFIG) && !defined(USE_MARK_BYTES)
|
||||
|
||||
/*
|
||||
* A special case for 2 word composite objects (e.g. cons cells):
|
||||
*/
|
||||
/*ARGSUSED*/
|
||||
ptr_t GC_reclaim_clear2(hbp, hhdr, list)
|
||||
ptr_t GC_reclaim_clear2(hbp, hhdr, list COUNT_PARAM)
|
||||
register struct hblk *hbp; /* ptr to current heap block */
|
||||
hdr * hhdr;
|
||||
register ptr_t list;
|
||||
COUNT_DECL
|
||||
{
|
||||
register word * mark_word_addr = &(hhdr->hb_marks[divWORDSZ(HDR_WORDS)]);
|
||||
register word * mark_word_addr = &(hhdr->hb_marks[0]);
|
||||
register word *p, *plim;
|
||||
# ifdef GATHERSTATS
|
||||
register int n_words_found = 0;
|
||||
# endif
|
||||
register word mark_word;
|
||||
register int i;
|
||||
NWORDS_DECL
|
||||
# define DO_OBJ(start_displ) \
|
||||
if (!(mark_word & ((word)1 << start_displ))) { \
|
||||
p[start_displ] = (word)list; \
|
||||
|
@ -289,9 +359,7 @@ register ptr_t list;
|
|||
mark_word >>= 8;
|
||||
}
|
||||
}
|
||||
# ifdef GATHERSTATS
|
||||
GC_mem_found += n_words_found;
|
||||
# endif
|
||||
COUNT_UPDATE
|
||||
return(list);
|
||||
# undef DO_OBJ
|
||||
}
|
||||
|
@ -300,17 +368,16 @@ register ptr_t list;
|
|||
* Another special case for 4 word composite objects:
|
||||
*/
|
||||
/*ARGSUSED*/
|
||||
ptr_t GC_reclaim_clear4(hbp, hhdr, list)
|
||||
ptr_t GC_reclaim_clear4(hbp, hhdr, list COUNT_PARAM)
|
||||
register struct hblk *hbp; /* ptr to current heap block */
|
||||
hdr * hhdr;
|
||||
register ptr_t list;
|
||||
COUNT_DECL
|
||||
{
|
||||
register word * mark_word_addr = &(hhdr->hb_marks[divWORDSZ(HDR_WORDS)]);
|
||||
register word * mark_word_addr = &(hhdr->hb_marks[0]);
|
||||
register word *p, *plim;
|
||||
# ifdef GATHERSTATS
|
||||
register int n_words_found = 0;
|
||||
# endif
|
||||
register word mark_word;
|
||||
NWORDS_DECL
|
||||
# define DO_OBJ(start_displ) \
|
||||
if (!(mark_word & ((word)1 << start_displ))) { \
|
||||
p[start_displ] = (word)list; \
|
||||
|
@ -346,31 +413,27 @@ register ptr_t list;
|
|||
# endif
|
||||
p += WORDSZ;
|
||||
}
|
||||
# ifdef GATHERSTATS
|
||||
GC_mem_found += n_words_found;
|
||||
# endif
|
||||
COUNT_UPDATE
|
||||
return(list);
|
||||
# undef DO_OBJ
|
||||
}
|
||||
|
||||
#endif /* !SMALL_CONFIG */
|
||||
#endif /* !SMALL_CONFIG && !USE_MARK_BYTES */
|
||||
|
||||
/* The same thing, but don't clear objects: */
|
||||
/*ARGSUSED*/
|
||||
ptr_t GC_reclaim_uninit(hbp, hhdr, sz, list)
|
||||
ptr_t GC_reclaim_uninit(hbp, hhdr, sz, list COUNT_PARAM)
|
||||
register struct hblk *hbp; /* ptr to current heap block */
|
||||
register hdr * hhdr;
|
||||
register ptr_t list;
|
||||
register word sz;
|
||||
COUNT_DECL
|
||||
{
|
||||
register int word_no;
|
||||
register int word_no = 0;
|
||||
register word *p, *plim;
|
||||
# ifdef GATHERSTATS
|
||||
register int n_words_found = 0;
|
||||
# endif
|
||||
NWORDS_DECL
|
||||
|
||||
p = (word *)(hbp->hb_body);
|
||||
word_no = HDR_WORDS;
|
||||
plim = (word *)((((word)hbp) + HBLKSIZE)
|
||||
- WORDS_TO_BYTES(sz));
|
||||
|
||||
|
@ -385,9 +448,7 @@ register word sz;
|
|||
p += sz;
|
||||
word_no += sz;
|
||||
}
|
||||
# ifdef GATHERSTATS
|
||||
GC_mem_found += n_words_found;
|
||||
# endif
|
||||
COUNT_UPDATE
|
||||
return(list);
|
||||
}
|
||||
|
||||
|
@ -398,14 +459,13 @@ register struct hblk *hbp; /* ptr to current heap block */
|
|||
register hdr * hhdr;
|
||||
register word sz;
|
||||
{
|
||||
register int word_no;
|
||||
register int word_no = 0;
|
||||
register word *p, *plim;
|
||||
# ifdef GATHERSTATS
|
||||
register int n_words_found = 0;
|
||||
# endif
|
||||
|
||||
p = (word *)(hbp->hb_body);
|
||||
word_no = HDR_WORDS;
|
||||
plim = (word *)((((word)hbp) + HBLKSIZE)
|
||||
- WORDS_TO_BYTES(sz));
|
||||
|
||||
|
@ -419,23 +479,22 @@ register word sz;
|
|||
}
|
||||
}
|
||||
|
||||
#ifndef SMALL_CONFIG
|
||||
#if !defined(SMALL_CONFIG) && !defined(USE_MARK_BYTES)
|
||||
/*
|
||||
* Another special case for 2 word atomic objects:
|
||||
*/
|
||||
/*ARGSUSED*/
|
||||
ptr_t GC_reclaim_uninit2(hbp, hhdr, list)
|
||||
ptr_t GC_reclaim_uninit2(hbp, hhdr, list COUNT_PARAM)
|
||||
register struct hblk *hbp; /* ptr to current heap block */
|
||||
hdr * hhdr;
|
||||
register ptr_t list;
|
||||
COUNT_DECL
|
||||
{
|
||||
register word * mark_word_addr = &(hhdr->hb_marks[divWORDSZ(HDR_WORDS)]);
|
||||
register word * mark_word_addr = &(hhdr->hb_marks[0]);
|
||||
register word *p, *plim;
|
||||
# ifdef GATHERSTATS
|
||||
register int n_words_found = 0;
|
||||
# endif
|
||||
register word mark_word;
|
||||
register int i;
|
||||
NWORDS_DECL
|
||||
# define DO_OBJ(start_displ) \
|
||||
if (!(mark_word & ((word)1 << start_displ))) { \
|
||||
p[start_displ] = (word)list; \
|
||||
|
@ -458,9 +517,7 @@ register ptr_t list;
|
|||
mark_word >>= 8;
|
||||
}
|
||||
}
|
||||
# ifdef GATHERSTATS
|
||||
GC_mem_found += n_words_found;
|
||||
# endif
|
||||
COUNT_UPDATE
|
||||
return(list);
|
||||
# undef DO_OBJ
|
||||
}
|
||||
|
@ -469,17 +526,16 @@ register ptr_t list;
|
|||
* Another special case for 4 word atomic objects:
|
||||
*/
|
||||
/*ARGSUSED*/
|
||||
ptr_t GC_reclaim_uninit4(hbp, hhdr, list)
|
||||
ptr_t GC_reclaim_uninit4(hbp, hhdr, list COUNT_PARAM)
|
||||
register struct hblk *hbp; /* ptr to current heap block */
|
||||
hdr * hhdr;
|
||||
register ptr_t list;
|
||||
COUNT_DECL
|
||||
{
|
||||
register word * mark_word_addr = &(hhdr->hb_marks[divWORDSZ(HDR_WORDS)]);
|
||||
register word * mark_word_addr = &(hhdr->hb_marks[0]);
|
||||
register word *p, *plim;
|
||||
# ifdef GATHERSTATS
|
||||
register int n_words_found = 0;
|
||||
# endif
|
||||
register word mark_word;
|
||||
NWORDS_DECL
|
||||
# define DO_OBJ(start_displ) \
|
||||
if (!(mark_word & ((word)1 << start_displ))) { \
|
||||
p[start_displ] = (word)list; \
|
||||
|
@ -513,27 +569,24 @@ register ptr_t list;
|
|||
# endif
|
||||
p += WORDSZ;
|
||||
}
|
||||
# ifdef GATHERSTATS
|
||||
GC_mem_found += n_words_found;
|
||||
# endif
|
||||
COUNT_UPDATE
|
||||
return(list);
|
||||
# undef DO_OBJ
|
||||
}
|
||||
|
||||
/* Finally the one word case, which never requires any clearing: */
|
||||
/*ARGSUSED*/
|
||||
ptr_t GC_reclaim1(hbp, hhdr, list)
|
||||
ptr_t GC_reclaim1(hbp, hhdr, list COUNT_PARAM)
|
||||
register struct hblk *hbp; /* ptr to current heap block */
|
||||
hdr * hhdr;
|
||||
register ptr_t list;
|
||||
COUNT_DECL
|
||||
{
|
||||
register word * mark_word_addr = &(hhdr->hb_marks[divWORDSZ(HDR_WORDS)]);
|
||||
register word * mark_word_addr = &(hhdr->hb_marks[0]);
|
||||
register word *p, *plim;
|
||||
# ifdef GATHERSTATS
|
||||
register int n_words_found = 0;
|
||||
# endif
|
||||
register word mark_word;
|
||||
register int i;
|
||||
NWORDS_DECL
|
||||
# define DO_OBJ(start_displ) \
|
||||
if (!(mark_word & ((word)1 << start_displ))) { \
|
||||
p[start_displ] = (word)list; \
|
||||
|
@ -556,14 +609,76 @@ register ptr_t list;
|
|||
mark_word >>= 4;
|
||||
}
|
||||
}
|
||||
# ifdef GATHERSTATS
|
||||
GC_mem_found += n_words_found;
|
||||
# endif
|
||||
COUNT_UPDATE
|
||||
return(list);
|
||||
# undef DO_OBJ
|
||||
}
|
||||
|
||||
#endif /* !SMALL_CONFIG */
|
||||
#endif /* !SMALL_CONFIG && !USE_MARK_BYTES */
|
||||
|
||||
/*
|
||||
* Generic procedure to rebuild a free list in hbp.
|
||||
* Also called directly from GC_malloc_many.
|
||||
*/
|
||||
ptr_t GC_reclaim_generic(hbp, hhdr, sz, init, list COUNT_PARAM)
|
||||
struct hblk *hbp; /* ptr to current heap block */
|
||||
hdr * hhdr;
|
||||
GC_bool init;
|
||||
ptr_t list;
|
||||
word sz;
|
||||
COUNT_DECL
|
||||
{
|
||||
ptr_t result = list;
|
||||
|
||||
GC_ASSERT(GC_find_header((ptr_t)hbp) == hhdr);
|
||||
if (init) {
|
||||
switch(sz) {
|
||||
# if !defined(SMALL_CONFIG) && !defined(USE_MARK_BYTES)
|
||||
case 1:
|
||||
/* We now issue the hint even if GC_nearly_full returned */
|
||||
/* DONT_KNOW. */
|
||||
GC_write_hint(hbp);
|
||||
result = GC_reclaim1(hbp, hhdr, list COUNT_ARG);
|
||||
break;
|
||||
case 2:
|
||||
GC_write_hint(hbp);
|
||||
result = GC_reclaim_clear2(hbp, hhdr, list COUNT_ARG);
|
||||
break;
|
||||
case 4:
|
||||
GC_write_hint(hbp);
|
||||
result = GC_reclaim_clear4(hbp, hhdr, list COUNT_ARG);
|
||||
break;
|
||||
# endif /* !SMALL_CONFIG && !USE_MARK_BYTES */
|
||||
default:
|
||||
GC_write_hint(hbp);
|
||||
result = GC_reclaim_clear(hbp, hhdr, sz, list COUNT_ARG);
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
switch(sz) {
|
||||
# if !defined(SMALL_CONFIG) && !defined(USE_MARK_BYTES)
|
||||
case 1:
|
||||
GC_write_hint(hbp);
|
||||
result = GC_reclaim1(hbp, hhdr, list COUNT_ARG);
|
||||
break;
|
||||
case 2:
|
||||
GC_write_hint(hbp);
|
||||
result = GC_reclaim_uninit2(hbp, hhdr, list COUNT_ARG);
|
||||
break;
|
||||
case 4:
|
||||
GC_write_hint(hbp);
|
||||
result = GC_reclaim_uninit4(hbp, hhdr, list COUNT_ARG);
|
||||
break;
|
||||
# endif /* !SMALL_CONFIG && !USE_MARK_BYTES */
|
||||
default:
|
||||
GC_write_hint(hbp);
|
||||
result = GC_reclaim_uninit(hbp, hhdr, sz, list COUNT_ARG);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (IS_UNCOLLECTABLE(hhdr -> hb_obj_kind)) GC_set_hdr_marks(hhdr);
|
||||
return result;
|
||||
}
|
||||
|
||||
/*
|
||||
* Restore unmarked small objects in the block pointed to by hbp
|
||||
|
@ -571,112 +686,25 @@ register ptr_t list;
|
|||
* If entirely empty blocks are to be completely deallocated, then
|
||||
* caller should perform that check.
|
||||
*/
|
||||
void GC_reclaim_small_nonempty_block(hbp, report_if_found)
|
||||
void GC_reclaim_small_nonempty_block(hbp, report_if_found COUNT_PARAM)
|
||||
register struct hblk *hbp; /* ptr to current heap block */
|
||||
int report_if_found; /* Abort if a reclaimable object is found */
|
||||
COUNT_DECL
|
||||
{
|
||||
hdr * hhdr;
|
||||
word sz; /* size of objects in current block */
|
||||
struct obj_kind * ok;
|
||||
ptr_t * flh;
|
||||
int kind;
|
||||
GC_bool full;
|
||||
hdr *hhdr = HDR(hbp);
|
||||
word sz = hhdr -> hb_sz;
|
||||
int kind = hhdr -> hb_obj_kind;
|
||||
struct obj_kind * ok = &GC_obj_kinds[kind];
|
||||
ptr_t * flh = &(ok -> ok_freelist[sz]);
|
||||
|
||||
hhdr = HDR(hbp);
|
||||
sz = hhdr -> hb_sz;
|
||||
hhdr -> hb_last_reclaimed = (unsigned short) GC_gc_no;
|
||||
kind = hhdr -> hb_obj_kind;
|
||||
ok = &GC_obj_kinds[kind];
|
||||
flh = &(ok -> ok_freelist[sz]);
|
||||
|
||||
if (report_if_found) {
|
||||
GC_reclaim_check(hbp, hhdr, sz);
|
||||
} else if (ok -> ok_init) {
|
||||
switch(sz) {
|
||||
# ifndef SMALL_CONFIG
|
||||
case 1:
|
||||
# if CPP_WORDSZ == 64
|
||||
full = GC_block_nearly_full1(hhdr, 0xffffffffffffffffl);
|
||||
# else
|
||||
full = GC_block_nearly_full1(hhdr, 0xffffffffl);
|
||||
# endif
|
||||
if (TRUE == full) goto out;
|
||||
if (FALSE == full) GC_write_hint(hbp);
|
||||
/* In the DONT_KNOW case, we let reclaim fault. */
|
||||
*flh = GC_reclaim1(hbp, hhdr, *flh);
|
||||
break;
|
||||
case 2:
|
||||
# if CPP_WORDSZ == 64
|
||||
full = GC_block_nearly_full1(hhdr, 0x5555555555555555l);
|
||||
# else
|
||||
full = GC_block_nearly_full1(hhdr, 0x55555555l);
|
||||
# endif
|
||||
if (TRUE == full) goto out;
|
||||
if (FALSE == full) GC_write_hint(hbp);
|
||||
*flh = GC_reclaim_clear2(hbp, hhdr, *flh);
|
||||
break;
|
||||
case 4:
|
||||
# if CPP_WORDSZ == 64
|
||||
full = GC_block_nearly_full1(hhdr, 0x1111111111111111l);
|
||||
# else
|
||||
full = GC_block_nearly_full1(hhdr, 0x11111111l);
|
||||
# endif
|
||||
if (TRUE == full) goto out;
|
||||
if (FALSE == full) GC_write_hint(hbp);
|
||||
*flh = GC_reclaim_clear4(hbp, hhdr, *flh);
|
||||
break;
|
||||
# endif
|
||||
default:
|
||||
full = GC_block_nearly_full(hhdr);
|
||||
if (TRUE == full) goto out;
|
||||
if (FALSE == full) GC_write_hint(hbp);
|
||||
*flh = GC_reclaim_clear(hbp, hhdr, sz, *flh);
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
switch(sz) {
|
||||
# ifndef SMALL_CONFIG
|
||||
case 1:
|
||||
# if CPP_WORDSZ == 64
|
||||
full = GC_block_nearly_full1(hhdr, 0xffffffffffffffffl);
|
||||
# else
|
||||
full = GC_block_nearly_full1(hhdr, 0xffffffffl);
|
||||
# endif
|
||||
if (TRUE == full) goto out;
|
||||
if (FALSE == full) GC_write_hint(hbp);
|
||||
*flh = GC_reclaim1(hbp, hhdr, *flh);
|
||||
break;
|
||||
case 2:
|
||||
# if CPP_WORDSZ == 64
|
||||
full = GC_block_nearly_full1(hhdr, 0x5555555555555555l);
|
||||
# else
|
||||
full = GC_block_nearly_full1(hhdr, 0x55555555l);
|
||||
# endif
|
||||
if (TRUE == full) goto out;
|
||||
if (FALSE == full) GC_write_hint(hbp);
|
||||
*flh = GC_reclaim_uninit2(hbp, hhdr, *flh);
|
||||
break;
|
||||
case 4:
|
||||
# if CPP_WORDSZ == 64
|
||||
full = GC_block_nearly_full1(hhdr, 0x1111111111111111l);
|
||||
# else
|
||||
full = GC_block_nearly_full1(hhdr, 0x11111111l);
|
||||
# endif
|
||||
if (TRUE == full) goto out;
|
||||
if (FALSE == full) GC_write_hint(hbp);
|
||||
*flh = GC_reclaim_uninit4(hbp, hhdr, *flh);
|
||||
break;
|
||||
# endif
|
||||
default:
|
||||
full = GC_block_nearly_full(hhdr);
|
||||
if (TRUE == full) goto out;
|
||||
if (FALSE == full) GC_write_hint(hbp);
|
||||
*flh = GC_reclaim_uninit(hbp, hhdr, sz, *flh);
|
||||
break;
|
||||
}
|
||||
}
|
||||
out:
|
||||
if (IS_UNCOLLECTABLE(kind)) GC_set_hdr_marks(hhdr);
|
||||
*flh = GC_reclaim_generic(hbp, hhdr, sz, ok -> ok_init,
|
||||
*flh MEM_FOUND_ADDR);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -687,9 +715,13 @@ out:
|
|||
* If report_if_found is TRUE, then process any block immediately, and
|
||||
* simply report free objects; do not actually reclaim them.
|
||||
*/
|
||||
void GC_reclaim_block(hbp, report_if_found)
|
||||
register struct hblk *hbp; /* ptr to current heap block */
|
||||
word report_if_found; /* Abort if a reclaimable object is found */
|
||||
# if defined(__STDC__) || defined(__cplusplus)
|
||||
void GC_reclaim_block(register struct hblk *hbp, word report_if_found)
|
||||
# else
|
||||
void GC_reclaim_block(hbp, report_if_found)
|
||||
register struct hblk *hbp; /* ptr to current heap block */
|
||||
word report_if_found; /* Abort if a reclaimable object is found */
|
||||
# endif
|
||||
{
|
||||
register hdr * hhdr;
|
||||
register word sz; /* size of objects in current block */
|
||||
|
@ -701,10 +733,14 @@ word report_if_found; /* Abort if a reclaimable object is found */
|
|||
ok = &GC_obj_kinds[hhdr -> hb_obj_kind];
|
||||
|
||||
if( sz > MAXOBJSZ ) { /* 1 big object */
|
||||
if( !mark_bit_from_hdr(hhdr, HDR_WORDS) ) {
|
||||
if( !mark_bit_from_hdr(hhdr, 0) ) {
|
||||
if (report_if_found) {
|
||||
FOUND_FREE(hbp, HDR_WORDS);
|
||||
FOUND_FREE(hbp, 0);
|
||||
} else {
|
||||
word blocks = OBJ_SZ_TO_BLOCKS(sz);
|
||||
if (blocks > 1) {
|
||||
GC_large_allocd_bytes -= blocks * HBLKSIZE;
|
||||
}
|
||||
# ifdef GATHERSTATS
|
||||
GC_mem_found += sz;
|
||||
# endif
|
||||
|
@ -714,18 +750,23 @@ word report_if_found; /* Abort if a reclaimable object is found */
|
|||
} else {
|
||||
GC_bool empty = GC_block_empty(hhdr);
|
||||
if (report_if_found) {
|
||||
GC_reclaim_small_nonempty_block(hbp, (int)report_if_found);
|
||||
GC_reclaim_small_nonempty_block(hbp, (int)report_if_found
|
||||
MEM_FOUND_ADDR);
|
||||
} else if (empty) {
|
||||
# ifdef GATHERSTATS
|
||||
GC_mem_found += BYTES_TO_WORDS(HBLKSIZE);
|
||||
# endif
|
||||
GC_freehblk(hbp);
|
||||
} else {
|
||||
} else if (TRUE != GC_block_nearly_full(hhdr)){
|
||||
/* group of smaller objects, enqueue the real work */
|
||||
rlh = &(ok -> ok_reclaim_list[sz]);
|
||||
hhdr -> hb_next = *rlh;
|
||||
*rlh = hbp;
|
||||
}
|
||||
} /* else not worth salvaging. */
|
||||
/* We used to do the nearly_full check later, but we */
|
||||
/* already have the right cache context here. Also */
|
||||
/* doing it here avoids some silly lock contention in */
|
||||
/* GC_malloc_many. */
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -736,6 +777,23 @@ word report_if_found; /* Abort if a reclaimable object is found */
|
|||
static size_t number_of_blocks;
|
||||
static size_t total_bytes;
|
||||
|
||||
#ifdef USE_MARK_BYTES
|
||||
|
||||
/* Return the number of set mark bits in the given header */
|
||||
int GC_n_set_marks(hhdr)
|
||||
hdr * hhdr;
|
||||
{
|
||||
register int result = 0;
|
||||
register int i;
|
||||
|
||||
for (i = 0; i < MARK_BITS_SZ; i++) {
|
||||
result += hhdr -> hb_marks[i];
|
||||
}
|
||||
return(result);
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
/* Number of set bits in a word. Not performance critical. */
|
||||
static int set_bits(n)
|
||||
word n;
|
||||
|
@ -763,10 +821,16 @@ hdr * hhdr;
|
|||
return(result);
|
||||
}
|
||||
|
||||
#endif /* !USE_MARK_BYTES */
|
||||
|
||||
/*ARGSUSED*/
|
||||
void GC_print_block_descr(h, dummy)
|
||||
struct hblk *h;
|
||||
word dummy;
|
||||
# if defined(__STDC__) || defined(__cplusplus)
|
||||
void GC_print_block_descr(struct hblk *h, word dummy)
|
||||
# else
|
||||
void GC_print_block_descr(h, dummy)
|
||||
struct hblk *h;
|
||||
word dummy;
|
||||
# endif
|
||||
{
|
||||
register hdr * hhdr = HDR(h);
|
||||
register size_t bytes = WORDS_TO_BYTES(hhdr -> hb_sz);
|
||||
|
@ -774,7 +838,7 @@ word dummy;
|
|||
GC_printf3("(%lu:%lu,%lu)", (unsigned long)(hhdr -> hb_obj_kind),
|
||||
(unsigned long)bytes,
|
||||
(unsigned long)(GC_n_set_marks(hhdr)));
|
||||
bytes += HDR_BYTES + HBLKSIZE-1;
|
||||
bytes += HBLKSIZE-1;
|
||||
bytes &= ~(HBLKSIZE-1);
|
||||
total_bytes += bytes;
|
||||
number_of_blocks++;
|
||||
|
@ -861,7 +925,7 @@ int kind;
|
|||
while ((hbp = *rlh) != 0) {
|
||||
hhdr = HDR(hbp);
|
||||
*rlh = hhdr -> hb_next;
|
||||
GC_reclaim_small_nonempty_block(hbp, FALSE);
|
||||
GC_reclaim_small_nonempty_block(hbp, FALSE MEM_FOUND_ADDR);
|
||||
if (*flh != 0) break;
|
||||
}
|
||||
}
|
||||
|
@ -909,7 +973,7 @@ GC_bool ignore_old;
|
|||
/* It's likely we'll need it this time, too */
|
||||
/* It's been touched recently, so this */
|
||||
/* shouldn't trigger paging. */
|
||||
GC_reclaim_small_nonempty_block(hbp, FALSE);
|
||||
GC_reclaim_small_nonempty_block(hbp, FALSE MEM_FOUND_ADDR);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,7 +10,6 @@
|
|||
* provided the above notices are retained, and a notice that the code was
|
||||
* modified is included with the above copyright notice.
|
||||
*/
|
||||
/* Boehm, September 21, 1995 5:39 pm PDT */
|
||||
|
||||
/* Check whether setjmp actually saves registers in jmp_buf. */
|
||||
/* If it doesn't, the generic mark_regs code won't work. */
|
||||
|
@ -21,11 +20,11 @@
|
|||
/* recommended that this be run optimized. (If the machine */
|
||||
/* has no callee-save registers, then the generic code is */
|
||||
/* safe, but this will not be noticed by this piece of */
|
||||
/* code.) */
|
||||
/* code.) This test appears to be far from perfect. */
|
||||
#include <stdio.h>
|
||||
#include <setjmp.h>
|
||||
#include <string.h>
|
||||
#include "gcconfig.h"
|
||||
#include "private/gcconfig.h"
|
||||
|
||||
#ifdef OS2
|
||||
/* GETPAGESIZE() is set to getpagesize() by default, but that */
|
||||
|
|
|
@ -17,8 +17,8 @@
|
|||
*/
|
||||
/* Boehm, September 14, 1994 4:44 pm PDT */
|
||||
|
||||
# if defined(_SOLARIS_PTHREADS)
|
||||
# include "gc_priv.h"
|
||||
# if defined(GC_SOLARIS_PTHREADS) || defined(_SOLARIS_PTHREADS)
|
||||
# include "private/gc_priv.h"
|
||||
# include <pthread.h>
|
||||
# include <thread.h>
|
||||
# include <signal.h>
|
||||
|
@ -35,7 +35,7 @@
|
|||
# define _CLASSIC_XOPEN_TYPES
|
||||
# include <unistd.h>
|
||||
# include <errno.h>
|
||||
# include "solaris_threads.h"
|
||||
# include "private/solaris_threads.h"
|
||||
# include <stdio.h>
|
||||
|
||||
#undef pthread_join
|
||||
|
|
|
@ -16,10 +16,10 @@
|
|||
*/
|
||||
/* Boehm, September 14, 1994 4:44 pm PDT */
|
||||
|
||||
# if defined(SOLARIS_THREADS)
|
||||
# if defined(GC_SOLARIS_THREADS) || defined(SOLARIS_THREADS)
|
||||
|
||||
# include "gc_priv.h"
|
||||
# include "solaris_threads.h"
|
||||
# include "private/gc_priv.h"
|
||||
# include "private/solaris_threads.h"
|
||||
# include <thread.h>
|
||||
# include <synch.h>
|
||||
# include <signal.h>
|
||||
|
@ -558,6 +558,11 @@ void GC_old_stacks_are_fresh()
|
|||
# define THREAD_TABLE_SZ 128 /* Must be power of 2 */
|
||||
volatile GC_thread GC_threads[THREAD_TABLE_SZ];
|
||||
|
||||
void GC_push_thread_structures GC_PROTO((void))
|
||||
{
|
||||
GC_push_all((ptr_t)(GC_threads), (ptr_t)(GC_threads)+sizeof(GC_threads));
|
||||
}
|
||||
|
||||
/* Add a thread to GC_threads. We assume it wasn't already there. */
|
||||
/* Caller holds allocation lock. */
|
||||
GC_thread GC_new_thread(thread_t id)
|
||||
|
@ -573,7 +578,7 @@ GC_thread GC_new_thread(thread_t id)
|
|||
/* Dont acquire allocation lock, since we may already hold it. */
|
||||
} else {
|
||||
result = (struct GC_Thread_Rep *)
|
||||
GC_generic_malloc_inner(sizeof(struct GC_Thread_Rep), NORMAL);
|
||||
GC_INTERNAL_MALLOC(sizeof(struct GC_Thread_Rep), NORMAL);
|
||||
}
|
||||
if (result == 0) return(0);
|
||||
result -> id = id;
|
||||
|
@ -627,7 +632,7 @@ word GC_get_orig_stack_size() {
|
|||
result = (word)rl.rlim_cur & ~(HBLKSIZE-1);
|
||||
if (result > MAX_ORIG_STACK_SIZE) {
|
||||
if (!warned) {
|
||||
WARN("Large stack limit(%ld): only scanning 8 MB", result);
|
||||
WARN("Large stack limit(%ld): only scanning 8 MB\n", result);
|
||||
warned = 1;
|
||||
}
|
||||
result = MAX_ORIG_STACK_SIZE;
|
||||
|
@ -673,7 +678,7 @@ void GC_push_all_stacks()
|
|||
|
||||
# define PUSH(bottom,top) \
|
||||
if (GC_dirty_maintained) { \
|
||||
GC_push_dirty((bottom), (top), GC_page_was_ever_dirty, \
|
||||
GC_push_selected((bottom), (top), GC_page_was_ever_dirty, \
|
||||
GC_push_all_stack); \
|
||||
} else { \
|
||||
GC_push_all_stack((bottom), (top)); \
|
||||
|
@ -703,7 +708,6 @@ int GC_is_thread_stack(ptr_t addr)
|
|||
register int i;
|
||||
register GC_thread p;
|
||||
register ptr_t bottom, top;
|
||||
struct rlimit rl;
|
||||
|
||||
for (i = 0; i < THREAD_TABLE_SZ; i++) {
|
||||
for (p = GC_threads[i]; p != 0; p = p -> next) {
|
||||
|
@ -714,6 +718,7 @@ int GC_is_thread_stack(ptr_t addr)
|
|||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* The only thread that ever really performs a thr_join. */
|
||||
|
|
|
@ -1,34 +0,0 @@
|
|||
#ifdef SOLARIS_THREADS
|
||||
|
||||
/* The set of all known threads. We intercept thread creation and */
|
||||
/* joins. We never actually create detached threads. We allocate all */
|
||||
/* new thread stacks ourselves. These allow us to maintain this */
|
||||
/* data structure. */
|
||||
/* Protected by GC_thr_lock. */
|
||||
/* Some of this should be declared volatile, but that's incosnsistent */
|
||||
/* with some library routine declarations. In particular, the */
|
||||
/* definition of cond_t doesn't mention volatile! */
|
||||
typedef struct GC_Thread_Rep {
|
||||
struct GC_Thread_Rep * next;
|
||||
thread_t id;
|
||||
word flags;
|
||||
# define FINISHED 1 /* Thread has exited. */
|
||||
# define DETACHED 2 /* Thread is intended to be detached. */
|
||||
# define CLIENT_OWNS_STACK 4
|
||||
/* Stack was supplied by client. */
|
||||
# define SUSPENDED 8 /* Currently suspended. */
|
||||
ptr_t stack;
|
||||
size_t stack_size;
|
||||
cond_t join_cv;
|
||||
void * status;
|
||||
} * GC_thread;
|
||||
extern GC_thread GC_new_thread(thread_t id);
|
||||
|
||||
extern GC_bool GC_thr_initialized;
|
||||
extern volatile GC_thread GC_threads[];
|
||||
extern size_t GC_min_stack_sz;
|
||||
extern size_t GC_page_sz;
|
||||
extern void GC_thr_init(void);
|
||||
|
||||
# endif /* SOLARIS_THREADS */
|
||||
|
|
@ -14,7 +14,7 @@
|
|||
/* Boehm, July 31, 1995 5:02 pm PDT */
|
||||
|
||||
|
||||
#include "gc_priv.h"
|
||||
#include "private/gc_priv.h"
|
||||
|
||||
# ifdef STUBBORN_ALLOC
|
||||
/* Stubborn object (hard to change, nearly immutable) allocation. */
|
||||
|
@ -31,6 +31,12 @@ extern ptr_t GC_clear_stack(); /* in misc.c, behaves like identity */
|
|||
|
||||
GC_PTR * GC_changing_list_start;
|
||||
|
||||
void GC_push_stubborn_structures GC_PROTO((void))
|
||||
{
|
||||
GC_push_all((ptr_t)(&GC_changing_list_start),
|
||||
(ptr_t)(&GC_changing_list_start) + sizeof(GC_PTR *));
|
||||
}
|
||||
|
||||
# ifdef THREADS
|
||||
VOLATILE GC_PTR * VOLATILE GC_changing_list_current;
|
||||
# else
|
||||
|
@ -50,7 +56,7 @@ void GC_stubborn_init()
|
|||
# define INIT_SIZE 10
|
||||
|
||||
GC_changing_list_start = (GC_PTR *)
|
||||
GC_generic_malloc_inner(
|
||||
GC_INTERNAL_MALLOC(
|
||||
(word)(INIT_SIZE * sizeof(GC_PTR)),
|
||||
PTRFREE);
|
||||
BZERO(GC_changing_list_start,
|
||||
|
@ -88,7 +94,7 @@ GC_bool GC_compact_changing_list()
|
|||
}
|
||||
if (2 * count > old_size) new_size = 2 * count;
|
||||
new_list = (GC_PTR *)
|
||||
GC_generic_malloc_inner(
|
||||
GC_INTERNAL_MALLOC(
|
||||
new_size * sizeof(GC_PTR), PTRFREE);
|
||||
/* PTRFREE is a lie. But we don't want the collector to */
|
||||
/* consider these. We do want the list itself to be */
|
||||
|
@ -313,5 +319,8 @@ GC_PTR p;
|
|||
{
|
||||
}
|
||||
|
||||
void GC_push_stubborn_structures GC_PROTO((void))
|
||||
{
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
1390
boehm-gc/test.c
1390
boehm-gc/test.c
File diff suppressed because it is too large
Load diff
|
@ -1,271 +0,0 @@
|
|||
/****************************************************************************
|
||||
Copyright (c) 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.
|
||||
****************************************************************************
|
||||
Last modified on Mon Jul 10 21:06:03 PDT 1995 by ellis
|
||||
modified on December 20, 1994 7:27 pm PST by boehm
|
||||
|
||||
usage: test_cpp number-of-iterations
|
||||
|
||||
This program tries to test the specific C++ functionality provided by
|
||||
gc_c++.h that isn't tested by the more general test routines of the
|
||||
collector.
|
||||
|
||||
A recommended value for number-of-iterations is 10, which will take a
|
||||
few minutes to complete.
|
||||
|
||||
***************************************************************************/
|
||||
|
||||
#include "gc_cpp.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#ifndef __GNUC__
|
||||
# include "gc_alloc.h"
|
||||
#endif
|
||||
extern "C" {
|
||||
#include "gc_priv.h"
|
||||
}
|
||||
#ifdef MSWIN32
|
||||
# include <windows.h>
|
||||
#endif
|
||||
#ifdef GC_NAME_CONFLICT
|
||||
# define USE_GC UseGC
|
||||
struct foo * GC;
|
||||
#else
|
||||
# define USE_GC GC
|
||||
#endif
|
||||
|
||||
|
||||
#define my_assert( e ) \
|
||||
if (! (e)) { \
|
||||
GC_printf1( "Assertion failure in " __FILE__ ", line %d: " #e "\n", \
|
||||
__LINE__ ); \
|
||||
exit( 1 ); }
|
||||
|
||||
|
||||
class A {public:
|
||||
/* An uncollectable class. */
|
||||
|
||||
A( int iArg ): i( iArg ) {}
|
||||
void Test( int iArg ) {
|
||||
my_assert( i == iArg );}
|
||||
int i;};
|
||||
|
||||
|
||||
class B: public gc, public A {public:
|
||||
/* A collectable class. */
|
||||
|
||||
B( int j ): A( j ) {}
|
||||
~B() {
|
||||
my_assert( deleting );}
|
||||
static void Deleting( int on ) {
|
||||
deleting = on;}
|
||||
static int deleting;};
|
||||
|
||||
int B::deleting = 0;
|
||||
|
||||
|
||||
class C: public gc_cleanup, public A {public:
|
||||
/* A collectable class with cleanup and virtual multiple inheritance. */
|
||||
|
||||
C( int levelArg ): A( levelArg ), level( levelArg ) {
|
||||
nAllocated++;
|
||||
if (level > 0) {
|
||||
left = new C( level - 1 );
|
||||
right = new C( level - 1 );}
|
||||
else {
|
||||
left = right = 0;}}
|
||||
~C() {
|
||||
this->A::Test( level );
|
||||
nFreed++;
|
||||
my_assert( level == 0 ?
|
||||
left == 0 && right == 0 :
|
||||
level == left->level + 1 && level == right->level + 1 );
|
||||
left = right = 0;
|
||||
level = -123456;}
|
||||
static void Test() {
|
||||
my_assert( nFreed <= nAllocated && nFreed >= .8 * nAllocated );}
|
||||
|
||||
static int nFreed;
|
||||
static int nAllocated;
|
||||
int level;
|
||||
C* left;
|
||||
C* right;};
|
||||
|
||||
int C::nFreed = 0;
|
||||
int C::nAllocated = 0;
|
||||
|
||||
|
||||
class D: public gc {public:
|
||||
/* A collectable class with a static member function to be used as
|
||||
an explicit clean-up function supplied to ::new. */
|
||||
|
||||
D( int iArg ): i( iArg ) {
|
||||
nAllocated++;}
|
||||
static void CleanUp( void* obj, void* data ) {
|
||||
D* self = (D*) obj;
|
||||
nFreed++;
|
||||
my_assert( self->i == (int) (long) data );}
|
||||
static void Test() {
|
||||
my_assert( nFreed >= .8 * nAllocated );}
|
||||
|
||||
int i;
|
||||
static int nFreed;
|
||||
static int nAllocated;};
|
||||
|
||||
int D::nFreed = 0;
|
||||
int D::nAllocated = 0;
|
||||
|
||||
|
||||
class E: public gc_cleanup {public:
|
||||
/* A collectable class with clean-up for use by F. */
|
||||
|
||||
E() {
|
||||
nAllocated++;}
|
||||
~E() {
|
||||
nFreed++;}
|
||||
|
||||
static int nFreed;
|
||||
static int nAllocated;};
|
||||
|
||||
int E::nFreed = 0;
|
||||
int E::nAllocated = 0;
|
||||
|
||||
|
||||
class F: public E {public:
|
||||
/* A collectable class with clean-up, a base with clean-up, and a
|
||||
member with clean-up. */
|
||||
|
||||
F() {
|
||||
nAllocated++;}
|
||||
~F() {
|
||||
nFreed++;}
|
||||
static void Test() {
|
||||
my_assert( nFreed >= .8 * nAllocated );
|
||||
my_assert( 2 * nFreed == E::nFreed );}
|
||||
|
||||
E e;
|
||||
static int nFreed;
|
||||
static int nAllocated;};
|
||||
|
||||
int F::nFreed = 0;
|
||||
int F::nAllocated = 0;
|
||||
|
||||
|
||||
long Disguise( void* p ) {
|
||||
return ~ (long) p;}
|
||||
|
||||
void* Undisguise( long i ) {
|
||||
return (void*) ~ i;}
|
||||
|
||||
|
||||
#ifdef MSWIN32
|
||||
int APIENTRY WinMain(
|
||||
HINSTANCE instance, HINSTANCE prev, LPSTR cmd, int cmdShow )
|
||||
{
|
||||
int argc;
|
||||
char* argv[ 3 ];
|
||||
|
||||
for (argc = 1; argc < sizeof( argv ) / sizeof( argv[ 0 ] ); argc++) {
|
||||
argv[ argc ] = strtok( argc == 1 ? cmd : 0, " \t" );
|
||||
if (0 == argv[ argc ]) break;}
|
||||
|
||||
#else
|
||||
# ifdef MACOS
|
||||
int main() {
|
||||
# else
|
||||
int main( int argc, char* argv[] ) {
|
||||
# endif
|
||||
#endif
|
||||
|
||||
# if defined(MACOS) // MacOS
|
||||
char* argv_[] = {"test_cpp", "10"}; // doesn't
|
||||
argv = argv_; // have a
|
||||
argc = sizeof(argv_)/sizeof(argv_[0]); // commandline
|
||||
# endif
|
||||
int i, iters, n;
|
||||
# if !defined(__GNUC__) && !defined(MACOS)
|
||||
int *x = (int *)alloc::allocate(sizeof(int));
|
||||
|
||||
*x = 29;
|
||||
x -= 3;
|
||||
# endif
|
||||
if (argc != 2 || (0 >= (n = atoi( argv[ 1 ] )))) {
|
||||
GC_printf0( "usage: test_cpp number-of-iterations\n" );
|
||||
exit( 1 );}
|
||||
|
||||
for (iters = 1; iters <= n; iters++) {
|
||||
GC_printf1( "Starting iteration %d\n", iters );
|
||||
|
||||
/* Allocate some uncollectable As and disguise their pointers.
|
||||
Later we'll check to see if the objects are still there. We're
|
||||
checking to make sure these objects really are uncollectable. */
|
||||
long as[ 1000 ];
|
||||
long bs[ 1000 ];
|
||||
for (i = 0; i < 1000; i++) {
|
||||
as[ i ] = Disguise( new (NoGC) A( i ) );
|
||||
bs[ i ] = Disguise( new (NoGC) B( i ) );}
|
||||
|
||||
/* Allocate a fair number of finalizable Cs, Ds, and Fs.
|
||||
Later we'll check to make sure they've gone away. */
|
||||
for (i = 0; i < 1000; i++) {
|
||||
C* c = new C( 2 );
|
||||
C c1( 2 ); /* stack allocation should work too */
|
||||
D* d = ::new (USE_GC, D::CleanUp, (void*) i) D( i );
|
||||
F* f = new F;
|
||||
if (0 == i % 10) delete c;}
|
||||
|
||||
/* Allocate a very large number of collectable As and Bs and
|
||||
drop the references to them immediately, forcing many
|
||||
collections. */
|
||||
for (i = 0; i < 1000000; i++) {
|
||||
A* a = new (USE_GC) A( i );
|
||||
B* b = new B( i );
|
||||
b = new (USE_GC) B( i );
|
||||
if (0 == i % 10) {
|
||||
B::Deleting( 1 );
|
||||
delete b;
|
||||
B::Deleting( 0 );}
|
||||
# ifdef FINALIZE_ON_DEMAND
|
||||
GC_invoke_finalizers();
|
||||
# endif
|
||||
}
|
||||
|
||||
/* Make sure the uncollectable As and Bs are still there. */
|
||||
for (i = 0; i < 1000; i++) {
|
||||
A* a = (A*) Undisguise( as[ i ] );
|
||||
B* b = (B*) Undisguise( bs[ i ] );
|
||||
a->Test( i );
|
||||
delete a;
|
||||
b->Test( i );
|
||||
B::Deleting( 1 );
|
||||
delete b;
|
||||
B::Deleting( 0 );
|
||||
# ifdef FINALIZE_ON_DEMAND
|
||||
GC_invoke_finalizers();
|
||||
# endif
|
||||
|
||||
}
|
||||
|
||||
/* Make sure most of the finalizable Cs, Ds, and Fs have
|
||||
gone away. */
|
||||
C::Test();
|
||||
D::Test();
|
||||
F::Test();}
|
||||
|
||||
# if !defined(__GNUC__) && !defined(MACOS)
|
||||
my_assert (29 == x[3]);
|
||||
# endif
|
||||
GC_printf0( "The test appears to have succeeded.\n" );
|
||||
return( 0 );}
|
||||
|
||||
|
|
@ -1,16 +1,16 @@
|
|||
# include "gcconfig.h"
|
||||
# include "private/gcconfig.h"
|
||||
# include <stdio.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
# if defined(LINUX_THREADS)
|
||||
# ifdef USE_LD_WRAP
|
||||
# if defined(GC_USE_LD_WRAP)
|
||||
printf("-Wl,--wrap -Wl,read -Wl,--wrap -Wl,dlopen "
|
||||
"-Wl,--wrap -Wl,pthread_create -Wl,--wrap -Wl,pthread_join "
|
||||
"-Wl,--wrap -Wl,pthread_sigmask -lpthread -ldl\n");
|
||||
# else
|
||||
printf("-lpthread -ldl\n");
|
||||
# endif
|
||||
"-Wl,--wrap -Wl,pthread_detach "
|
||||
"-Wl,--wrap -Wl,pthread_sigmask -Wl,--wrap -Wl,sleep\n");
|
||||
# endif
|
||||
# if defined(LINUX_THREADS)
|
||||
printf("-lpthread\n");
|
||||
# endif
|
||||
# if defined(IRIX_THREADS)
|
||||
printf("-lpthread\n");
|
||||
|
@ -20,6 +20,9 @@ int main()
|
|||
# endif
|
||||
# ifdef SOLARIS_THREADS
|
||||
printf("-lthread -ldl\n");
|
||||
# endif
|
||||
# ifdef GC_OSF1_THREADS
|
||||
printf("-lpthread -lrt\n");
|
||||
# endif
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
/*
|
||||
* Copyright (c) 1991-1994 by Xerox Corporation. All rights reserved.
|
||||
* opyright (c) 1999-2000 by Hewlett-Packard Company. All rights reserved.
|
||||
*
|
||||
* THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED
|
||||
* OR IMPLIED. ANY USE IS AT YOUR OWN RISK.
|
||||
|
@ -11,7 +12,6 @@
|
|||
* modified is included with the above copyright notice.
|
||||
*
|
||||
*/
|
||||
/* Boehm, July 31, 1995 5:02 pm PDT */
|
||||
|
||||
|
||||
/*
|
||||
|
@ -36,15 +36,10 @@
|
|||
* since they are not accessible through the current interface.
|
||||
*/
|
||||
|
||||
#include "gc_priv.h"
|
||||
#include "gc_mark.h"
|
||||
#include "private/gc_pmark.h"
|
||||
#include "gc_typed.h"
|
||||
|
||||
# ifdef ADD_BYTE_AT_END
|
||||
# define EXTRA_BYTES (sizeof(word) - 1)
|
||||
# else
|
||||
# define EXTRA_BYTES (sizeof(word))
|
||||
# endif
|
||||
# define TYPD_EXTRA_BYTES (sizeof(word) - EXTRA_BYTES)
|
||||
|
||||
GC_bool GC_explicit_typing_initialized = FALSE;
|
||||
|
||||
|
@ -170,15 +165,15 @@ GC_descr GC_bm_table[WORDSZ/2];
|
|||
/* each of which is described by descriptor. */
|
||||
/* The result is known to be short enough to fit into a bitmap */
|
||||
/* descriptor. */
|
||||
/* Descriptor is a DS_LENGTH or DS_BITMAP descriptor. */
|
||||
/* Descriptor is a GC_DS_LENGTH or GC_DS_BITMAP descriptor. */
|
||||
GC_descr GC_double_descr(descriptor, nwords)
|
||||
register GC_descr descriptor;
|
||||
register word nwords;
|
||||
{
|
||||
if (descriptor & DS_TAGS == DS_LENGTH) {
|
||||
if ((descriptor & GC_DS_TAGS) == GC_DS_LENGTH) {
|
||||
descriptor = GC_bm_table[BYTES_TO_WORDS((word)descriptor)];
|
||||
};
|
||||
descriptor |= (descriptor & ~DS_TAGS) >> nwords;
|
||||
descriptor |= (descriptor & ~GC_DS_TAGS) >> nwords;
|
||||
return(descriptor);
|
||||
}
|
||||
|
||||
|
@ -196,7 +191,7 @@ complex_descriptor * GC_make_sequence_descriptor();
|
|||
/* is returned in *simple_d. */
|
||||
/* If the result is NO_MEM, then */
|
||||
/* we failed to allocate the descriptor. */
|
||||
/* The implementation knows that DS_LENGTH is 0. */
|
||||
/* The implementation knows that GC_DS_LENGTH is 0. */
|
||||
/* *leaf, *complex_d, and *simple_d may be used as temporaries */
|
||||
/* during the construction. */
|
||||
# define COMPLEX 2
|
||||
|
@ -216,7 +211,7 @@ struct LeafDescriptor * leaf;
|
|||
/* For larger arrays, we try to combine descriptors of adjacent */
|
||||
/* descriptors to speed up marking, and to reduce the amount */
|
||||
/* of space needed on the mark stack. */
|
||||
if ((descriptor & DS_TAGS) == DS_LENGTH) {
|
||||
if ((descriptor & GC_DS_TAGS) == GC_DS_LENGTH) {
|
||||
if ((word)descriptor == size) {
|
||||
*simple_d = nelements * descriptor;
|
||||
return(SIMPLE);
|
||||
|
@ -236,7 +231,7 @@ struct LeafDescriptor * leaf;
|
|||
}
|
||||
}
|
||||
} else if (size <= BITMAP_BITS/2
|
||||
&& (descriptor & DS_TAGS) != DS_PROC
|
||||
&& (descriptor & GC_DS_TAGS) != GC_DS_PROC
|
||||
&& (size & (sizeof(word)-1)) == 0) {
|
||||
int result =
|
||||
GC_make_array_descriptor(nelements/2, 2*size,
|
||||
|
@ -343,9 +338,15 @@ ptr_t * GC_eobjfreelist;
|
|||
|
||||
ptr_t * GC_arobjfreelist;
|
||||
|
||||
mse * GC_typed_mark_proc();
|
||||
mse * GC_typed_mark_proc GC_PROTO((register word * addr,
|
||||
register mse * mark_stack_ptr,
|
||||
mse * mark_stack_limit,
|
||||
word env));
|
||||
|
||||
mse * GC_array_mark_proc();
|
||||
mse * GC_array_mark_proc GC_PROTO((register word * addr,
|
||||
register mse * mark_stack_ptr,
|
||||
mse * mark_stack_limit,
|
||||
word env));
|
||||
|
||||
GC_descr GC_generic_array_descr;
|
||||
|
||||
|
@ -370,14 +371,14 @@ void GC_init_explicit_typing()
|
|||
GC_explicit_typing_initialized = TRUE;
|
||||
/* Set up object kind with simple indirect descriptor. */
|
||||
GC_eobjfreelist = (ptr_t *)
|
||||
GC_generic_malloc_inner((MAXOBJSZ+1)*sizeof(ptr_t), PTRFREE);
|
||||
GC_INTERNAL_MALLOC((MAXOBJSZ+1)*sizeof(ptr_t), PTRFREE);
|
||||
if (GC_eobjfreelist == 0) ABORT("Couldn't allocate GC_eobjfreelist");
|
||||
BZERO(GC_eobjfreelist, (MAXOBJSZ+1)*sizeof(ptr_t));
|
||||
GC_explicit_kind = GC_n_kinds++;
|
||||
GC_obj_kinds[GC_explicit_kind].ok_freelist = GC_eobjfreelist;
|
||||
GC_obj_kinds[GC_explicit_kind].ok_reclaim_list = 0;
|
||||
GC_obj_kinds[GC_explicit_kind].ok_descriptor =
|
||||
(((word)WORDS_TO_BYTES(-1)) | DS_PER_OBJECT);
|
||||
(((word)WORDS_TO_BYTES(-1)) | GC_DS_PER_OBJECT);
|
||||
GC_obj_kinds[GC_explicit_kind].ok_relocate_descr = TRUE;
|
||||
GC_obj_kinds[GC_explicit_kind].ok_init = TRUE;
|
||||
/* Descriptors are in the last word of the object. */
|
||||
|
@ -387,7 +388,7 @@ void GC_init_explicit_typing()
|
|||
/* Moving this up breaks DEC AXP compiler. */
|
||||
/* Set up object kind with array descriptor. */
|
||||
GC_arobjfreelist = (ptr_t *)
|
||||
GC_generic_malloc_inner((MAXOBJSZ+1)*sizeof(ptr_t), PTRFREE);
|
||||
GC_INTERNAL_MALLOC((MAXOBJSZ+1)*sizeof(ptr_t), PTRFREE);
|
||||
if (GC_arobjfreelist == 0) ABORT("Couldn't allocate GC_arobjfreelist");
|
||||
BZERO(GC_arobjfreelist, (MAXOBJSZ+1)*sizeof(ptr_t));
|
||||
if (GC_n_mark_procs >= MAX_MARK_PROCS)
|
||||
|
@ -399,26 +400,33 @@ void GC_init_explicit_typing()
|
|||
GC_obj_kinds[GC_array_kind].ok_freelist = GC_arobjfreelist;
|
||||
GC_obj_kinds[GC_array_kind].ok_reclaim_list = 0;
|
||||
GC_obj_kinds[GC_array_kind].ok_descriptor =
|
||||
MAKE_PROC(GC_array_mark_proc_index, 0);;
|
||||
GC_MAKE_PROC(GC_array_mark_proc_index, 0);;
|
||||
GC_obj_kinds[GC_array_kind].ok_relocate_descr = FALSE;
|
||||
GC_obj_kinds[GC_array_kind].ok_init = TRUE;
|
||||
/* Descriptors are in the last word of the object. */
|
||||
GC_mark_procs[GC_array_mark_proc_index] = GC_array_mark_proc;
|
||||
for (i = 0; i < WORDSZ/2; i++) {
|
||||
GC_descr d = (((word)(-1)) >> (WORDSZ - i)) << (WORDSZ - i);
|
||||
d |= DS_BITMAP;
|
||||
d |= GC_DS_BITMAP;
|
||||
GC_bm_table[i] = d;
|
||||
}
|
||||
GC_generic_array_descr = MAKE_PROC(GC_array_mark_proc_index, 0);
|
||||
GC_generic_array_descr = GC_MAKE_PROC(GC_array_mark_proc_index, 0);
|
||||
UNLOCK();
|
||||
ENABLE_SIGNALS();
|
||||
}
|
||||
|
||||
mse * GC_typed_mark_proc(addr, mark_stack_ptr, mark_stack_limit, env)
|
||||
register word * addr;
|
||||
register mse * mark_stack_ptr;
|
||||
mse * mark_stack_limit;
|
||||
word env;
|
||||
# if defined(__STDC__) || defined(__cplusplus)
|
||||
mse * GC_typed_mark_proc(register word * addr,
|
||||
register mse * mark_stack_ptr,
|
||||
mse * mark_stack_limit,
|
||||
word env)
|
||||
# else
|
||||
mse * GC_typed_mark_proc(addr, mark_stack_ptr, mark_stack_limit, env)
|
||||
register word * addr;
|
||||
register mse * mark_stack_ptr;
|
||||
mse * mark_stack_limit;
|
||||
word env;
|
||||
# endif
|
||||
{
|
||||
register word bm = GC_ext_descriptors[env].ed_bitmap;
|
||||
register word * current_p = addr;
|
||||
|
@ -446,7 +454,7 @@ word env;
|
|||
}
|
||||
mark_stack_ptr -> mse_start = addr + WORDSZ;
|
||||
mark_stack_ptr -> mse_descr =
|
||||
MAKE_PROC(GC_typed_mark_proc_index, env+1);
|
||||
GC_MAKE_PROC(GC_typed_mark_proc_index, env+1);
|
||||
}
|
||||
return(mark_stack_ptr);
|
||||
}
|
||||
|
@ -533,11 +541,18 @@ mse * msl;
|
|||
}
|
||||
|
||||
/*ARGSUSED*/
|
||||
mse * GC_array_mark_proc(addr, mark_stack_ptr, mark_stack_limit, env)
|
||||
register word * addr;
|
||||
register mse * mark_stack_ptr;
|
||||
mse * mark_stack_limit;
|
||||
word env;
|
||||
# if defined(__STDC__) || defined(__cplusplus)
|
||||
mse * GC_array_mark_proc(register word * addr,
|
||||
register mse * mark_stack_ptr,
|
||||
mse * mark_stack_limit,
|
||||
word env)
|
||||
# else
|
||||
mse * GC_array_mark_proc(addr, mark_stack_ptr, mark_stack_limit, env)
|
||||
register word * addr;
|
||||
register mse * mark_stack_ptr;
|
||||
mse * mark_stack_limit;
|
||||
word env;
|
||||
# endif
|
||||
{
|
||||
register hdr * hhdr = HDR(addr);
|
||||
register word sz = hhdr -> hb_sz;
|
||||
|
@ -563,12 +578,12 @@ word env;
|
|||
GC_mark_stack_too_small = TRUE;
|
||||
new_mark_stack_ptr = orig_mark_stack_ptr + 1;
|
||||
new_mark_stack_ptr -> mse_start = addr;
|
||||
new_mark_stack_ptr -> mse_descr = WORDS_TO_BYTES(sz) | DS_LENGTH;
|
||||
new_mark_stack_ptr -> mse_descr = WORDS_TO_BYTES(sz) | GC_DS_LENGTH;
|
||||
} else {
|
||||
/* Push descriptor itself */
|
||||
new_mark_stack_ptr++;
|
||||
new_mark_stack_ptr -> mse_start = addr + sz - 1;
|
||||
new_mark_stack_ptr -> mse_descr = sizeof(word) | DS_LENGTH;
|
||||
new_mark_stack_ptr -> mse_descr = sizeof(word) | GC_DS_LENGTH;
|
||||
}
|
||||
return(new_mark_stack_ptr);
|
||||
}
|
||||
|
@ -600,7 +615,7 @@ word env;
|
|||
}
|
||||
if (all_bits_set) {
|
||||
/* An initial section contains all pointers. Use length descriptor. */
|
||||
return(WORDS_TO_BYTES(last_set_bit+1) | DS_LENGTH);
|
||||
return(WORDS_TO_BYTES(last_set_bit+1) | GC_DS_LENGTH);
|
||||
}
|
||||
}
|
||||
# endif
|
||||
|
@ -612,16 +627,16 @@ word env;
|
|||
result >>= 1;
|
||||
if (GC_get_bit(bm, i)) result |= HIGH_BIT;
|
||||
}
|
||||
result |= DS_BITMAP;
|
||||
result |= GC_DS_BITMAP;
|
||||
return(result);
|
||||
} else {
|
||||
signed_word index;
|
||||
|
||||
index = GC_add_ext_descriptor(bm, (word)last_set_bit+1);
|
||||
if (index == -1) return(WORDS_TO_BYTES(last_set_bit+1) | DS_LENGTH);
|
||||
if (index == -1) return(WORDS_TO_BYTES(last_set_bit+1) | GC_DS_LENGTH);
|
||||
/* Out of memory: use conservative */
|
||||
/* approximation. */
|
||||
result = MAKE_PROC(GC_typed_mark_proc_index, (word)index);
|
||||
result = GC_MAKE_PROC(GC_typed_mark_proc_index, (word)index);
|
||||
return(result);
|
||||
}
|
||||
}
|
||||
|
@ -647,7 +662,7 @@ register ptr_t * opp;
|
|||
register word lw;
|
||||
DCL_LOCK_STATE;
|
||||
|
||||
lb += EXTRA_BYTES;
|
||||
lb += TYPD_EXTRA_BYTES;
|
||||
if( SMALL_OBJ(lb) ) {
|
||||
# ifdef MERGE_SIZES
|
||||
lw = GC_size_map[lb];
|
||||
|
@ -692,7 +707,7 @@ register ptr_t * opp;
|
|||
register word lw;
|
||||
DCL_LOCK_STATE;
|
||||
|
||||
lb += EXTRA_BYTES;
|
||||
lb += TYPD_EXTRA_BYTES;
|
||||
if( SMALL_OBJ(lb) ) {
|
||||
# ifdef MERGE_SIZES
|
||||
lw = GC_size_map[lb];
|
||||
|
@ -750,11 +765,11 @@ DCL_LOCK_STATE;
|
|||
case SIMPLE: return(GC_malloc_explicitly_typed(n*lb, simple_descr));
|
||||
case LEAF:
|
||||
lb *= n;
|
||||
lb += sizeof(struct LeafDescriptor) + EXTRA_BYTES;
|
||||
lb += sizeof(struct LeafDescriptor) + TYPD_EXTRA_BYTES;
|
||||
break;
|
||||
case COMPLEX:
|
||||
lb *= n;
|
||||
lb += EXTRA_BYTES;
|
||||
lb += TYPD_EXTRA_BYTES;
|
||||
break;
|
||||
}
|
||||
if( SMALL_OBJ(lb) ) {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#define GC_VERSION_MAJOR 5
|
||||
#define GC_VERSION_MINOR 1
|
||||
#define GC_ALPHA_VERSION GC_NOT_ALPHA
|
||||
#define GC_VERSION_MAJOR 6
|
||||
#define GC_VERSION_MINOR 0
|
||||
#define GC_ALPHA_VERSION 7
|
||||
|
||||
# define GC_NOT_ALPHA 0xff
|
||||
|
||||
|
|
|
@ -1,221 +0,0 @@
|
|||
#ifndef _weakpointer_h_
|
||||
#define _weakpointer_h_
|
||||
|
||||
/****************************************************************************
|
||||
|
||||
WeakPointer and CleanUp
|
||||
|
||||
Copyright (c) 1991 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 copy this code for any purpose,
|
||||
provided the above notices are retained on all copies.
|
||||
|
||||
Last modified on Mon Jul 17 18:16:01 PDT 1995 by ellis
|
||||
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
|
||||
WeakPointer
|
||||
|
||||
A weak pointer is a pointer to a heap-allocated object that doesn't
|
||||
prevent the object from being garbage collected. Weak pointers can be
|
||||
used to track which objects haven't yet been reclaimed by the
|
||||
collector. A weak pointer is deactivated when the collector discovers
|
||||
its referent object is unreachable by normal pointers (reachability
|
||||
and deactivation are defined more precisely below). A deactivated weak
|
||||
pointer remains deactivated forever.
|
||||
|
||||
****************************************************************************/
|
||||
|
||||
|
||||
template< class T > class WeakPointer {
|
||||
public:
|
||||
|
||||
WeakPointer( T* t = 0 )
|
||||
/* Constructs a weak pointer for *t. t may be null. It is an error
|
||||
if t is non-null and *t is not a collected object. */
|
||||
{impl = _WeakPointer_New( t );}
|
||||
|
||||
T* Pointer()
|
||||
/* wp.Pointer() returns a pointer to the referent object of wp or
|
||||
null if wp has been deactivated (because its referent object
|
||||
has been discovered unreachable by the collector). */
|
||||
{return (T*) _WeakPointer_Pointer( this->impl );}
|
||||
|
||||
int operator==( WeakPointer< T > wp2 )
|
||||
/* Given weak pointers wp1 and wp2, if wp1 == wp2, then wp1 and
|
||||
wp2 refer to the same object. If wp1 != wp2, then either wp1
|
||||
and wp2 don't refer to the same object, or if they do, one or
|
||||
both of them has been deactivated. (Note: If objects t1 and t2
|
||||
are never made reachable by their clean-up functions, then
|
||||
WeakPointer<T>(t1) == WeakPointer<T>(t2) if and only t1 == t2.) */
|
||||
{return _WeakPointer_Equal( this->impl, wp2.impl );}
|
||||
|
||||
int Hash()
|
||||
/* Returns a hash code suitable for use by multiplicative- and
|
||||
division-based hash tables. If wp1 == wp2, then wp1.Hash() ==
|
||||
wp2.Hash(). */
|
||||
{return _WeakPointer_Hash( this->impl );}
|
||||
|
||||
private:
|
||||
void* impl;
|
||||
};
|
||||
|
||||
/*****************************************************************************
|
||||
|
||||
CleanUp
|
||||
|
||||
A garbage-collected object can have an associated clean-up function
|
||||
that will be invoked some time after the collector discovers the
|
||||
object is unreachable via normal pointers. Clean-up functions can be
|
||||
used to release resources such as open-file handles or window handles
|
||||
when their containing objects become unreachable. If a C++ object has
|
||||
a non-empty explicit destructor (i.e. it contains programmer-written
|
||||
code), the destructor will be automatically registered as the object's
|
||||
initial clean-up function.
|
||||
|
||||
There is no guarantee that the collector will detect every unreachable
|
||||
object (though it will find almost all of them). Clients should not
|
||||
rely on clean-up to cause some action to occur immediately -- clean-up
|
||||
is only a mechanism for improving resource usage.
|
||||
|
||||
Every object with a clean-up function also has a clean-up queue. When
|
||||
the collector finds the object is unreachable, it enqueues it on its
|
||||
queue. The clean-up function is applied when the object is removed
|
||||
from the queue. By default, objects are enqueued on the garbage
|
||||
collector's queue, and the collector removes all objects from its
|
||||
queue after each collection. If a client supplies another queue for
|
||||
objects, it is his responsibility to remove objects (and cause their
|
||||
functions to be called) by polling it periodically.
|
||||
|
||||
Clean-up queues allow clean-up functions accessing global data to
|
||||
synchronize with the main program. Garbage collection can occur at any
|
||||
time, and clean-ups invoked by the collector might access data in an
|
||||
inconsistent state. A client can control this by defining an explicit
|
||||
queue for objects and polling it at safe points.
|
||||
|
||||
The following definitions are used by the specification below:
|
||||
|
||||
Given a pointer t to a collected object, the base object BO(t) is the
|
||||
value returned by new when it created the object. (Because of multiple
|
||||
inheritance, t and BO(t) may not be the same address.)
|
||||
|
||||
A weak pointer wp references an object *t if BO(wp.Pointer()) ==
|
||||
BO(t).
|
||||
|
||||
***************************************************************************/
|
||||
|
||||
template< class T, class Data > class CleanUp {
|
||||
public:
|
||||
|
||||
static void Set( T* t, void c( Data* d, T* t ), Data* d = 0 )
|
||||
/* Sets the clean-up function of object BO(t) to be <c, d>,
|
||||
replacing any previously defined clean-up function for BO(t); c
|
||||
and d can be null, but t cannot. Sets the clean-up queue for
|
||||
BO(t) to be the collector's queue. When t is removed from its
|
||||
clean-up queue, its clean-up will be applied by calling c(d,
|
||||
t). It is an error if *t is not a collected object. */
|
||||
{_CleanUp_Set( t, c, d );}
|
||||
|
||||
static void Call( T* t )
|
||||
/* Sets the new clean-up function for BO(t) to be null and, if the
|
||||
old one is non-null, calls it immediately, even if BO(t) is
|
||||
still reachable. Deactivates any weak pointers to BO(t). */
|
||||
{_CleanUp_Call( t );}
|
||||
|
||||
class Queue {public:
|
||||
Queue()
|
||||
/* Constructs a new queue. */
|
||||
{this->head = _CleanUp_Queue_NewHead();}
|
||||
|
||||
void Set( T* t )
|
||||
/* q.Set(t) sets the clean-up queue of BO(t) to be q. */
|
||||
{_CleanUp_Queue_Set( this->head, t );}
|
||||
|
||||
int Call()
|
||||
/* If q is non-empty, q.Call() removes the first object and
|
||||
calls its clean-up function; does nothing if q is
|
||||
empty. Returns true if there are more objects in the
|
||||
queue. */
|
||||
{return _CleanUp_Queue_Call( this->head );}
|
||||
|
||||
private:
|
||||
void* head;
|
||||
};
|
||||
};
|
||||
|
||||
/**********************************************************************
|
||||
|
||||
Reachability and Clean-up
|
||||
|
||||
An object O is reachable if it can be reached via a non-empty path of
|
||||
normal pointers from the registers, stacks, global variables, or an
|
||||
object with a non-null clean-up function (including O itself),
|
||||
ignoring pointers from an object to itself.
|
||||
|
||||
This definition of reachability ensures that if object B is accessible
|
||||
from object A (and not vice versa) and if both A and B have clean-up
|
||||
functions, then A will always be cleaned up before B. Note that as
|
||||
long as an object with a clean-up function is contained in a cycle of
|
||||
pointers, it will always be reachable and will never be cleaned up or
|
||||
collected.
|
||||
|
||||
When the collector finds an unreachable object with a null clean-up
|
||||
function, it atomically deactivates all weak pointers referencing the
|
||||
object and recycles its storage. If object B is accessible from object
|
||||
A via a path of normal pointers, A will be discovered unreachable no
|
||||
later than B, and a weak pointer to A will be deactivated no later
|
||||
than a weak pointer to B.
|
||||
|
||||
When the collector finds an unreachable object with a non-null
|
||||
clean-up function, the collector atomically deactivates all weak
|
||||
pointers referencing the object, redefines its clean-up function to be
|
||||
null, and enqueues it on its clean-up queue. The object then becomes
|
||||
reachable again and remains reachable at least until its clean-up
|
||||
function executes.
|
||||
|
||||
The clean-up function is assured that its argument is the only
|
||||
accessible pointer to the object. Nothing prevents the function from
|
||||
redefining the object's clean-up function or making the object
|
||||
reachable again (for example, by storing the pointer in a global
|
||||
variable).
|
||||
|
||||
If the clean-up function does not make its object reachable again and
|
||||
does not redefine its clean-up function, then the object will be
|
||||
collected by a subsequent collection (because the object remains
|
||||
unreachable and now has a null clean-up function). If the clean-up
|
||||
function does make its object reachable again and a clean-up function
|
||||
is subsequently redefined for the object, then the new clean-up
|
||||
function will be invoked the next time the collector finds the object
|
||||
unreachable.
|
||||
|
||||
Note that a destructor for a collected object cannot safely redefine a
|
||||
clean-up function for its object, since after the destructor executes,
|
||||
the object has been destroyed into "raw memory". (In most
|
||||
implementations, destroying an object mutates its vtbl.)
|
||||
|
||||
Finally, note that calling delete t on a collected object first
|
||||
deactivates any weak pointers to t and then invokes its clean-up
|
||||
function (destructor).
|
||||
|
||||
**********************************************************************/
|
||||
|
||||
extern "C" {
|
||||
void* _WeakPointer_New( void* t );
|
||||
void* _WeakPointer_Pointer( void* wp );
|
||||
int _WeakPointer_Equal( void* wp1, void* wp2 );
|
||||
int _WeakPointer_Hash( void* wp );
|
||||
void _CleanUp_Set( void* t, void (*c)( void* d, void* t ), void* d );
|
||||
void _CleanUp_Call( void* t );
|
||||
void* _CleanUp_Queue_NewHead ();
|
||||
void _CleanUp_Queue_Set( void* h, void* t );
|
||||
int _CleanUp_Queue_Call( void* h );
|
||||
}
|
||||
|
||||
#endif /* _weakpointer_h_ */
|
||||
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
#ifdef WIN32_THREADS
|
||||
#if defined(GC_WIN32_THREADS) || defined(WIN32_THREADS)
|
||||
|
||||
#include "gc_priv.h"
|
||||
#include "private/gc_priv.h"
|
||||
|
||||
#if 0
|
||||
#define STRICT
|
||||
|
@ -24,6 +24,13 @@ volatile GC_bool GC_please_stop = FALSE;
|
|||
|
||||
volatile struct thread_entry thread_table[MAX_THREADS];
|
||||
|
||||
void GC_push_thread_structures GC_PROTO((void))
|
||||
{
|
||||
/* Unlike the other threads implementations, the thread table here */
|
||||
/* contains no pointers to the collectable heap. Thus we have */
|
||||
/* no private structures we need to preserve. */
|
||||
}
|
||||
|
||||
void GC_stop_world()
|
||||
{
|
||||
DWORD thread_id = GetCurrentThreadId();
|
||||
|
@ -33,8 +40,28 @@ void GC_stop_world()
|
|||
for (i = 0; i < MAX_THREADS; i++)
|
||||
if (thread_table[i].stack != 0
|
||||
&& thread_table[i].id != thread_id) {
|
||||
if (SuspendThread(thread_table[i].handle) == (DWORD)-1)
|
||||
ABORT("SuspendThread failed");
|
||||
# ifdef MSWINCE
|
||||
/* SuspendThread will fail if thread is running kernel code */
|
||||
while (SuspendThread(thread_table[i].handle) == (DWORD)-1)
|
||||
Sleep(10);
|
||||
# else
|
||||
/* Apparently the Windows 95 GetOpenFileName call creates */
|
||||
/* a thread that does not properly get cleaned up, and */
|
||||
/* SuspendThread on its descriptor may provoke a crash. */
|
||||
/* This reduces the probability of that event, though it still */
|
||||
/* appears there's a race here. */
|
||||
DWORD exitCode;
|
||||
if (GetExitCodeThread(thread_table[i].handle,&exitCode) &&
|
||||
exitCode != STILL_ACTIVE) {
|
||||
thread_table[i].stack = 0;
|
||||
thread_table[i].in_use = FALSE;
|
||||
CloseHandle(thread_table[i].handle);
|
||||
BZERO((void *)(&thread_table[i].context), sizeof(CONTEXT));
|
||||
continue;
|
||||
}
|
||||
if (SuspendThread(thread_table[i].handle) == (DWORD)-1)
|
||||
ABORT("SuspendThread failed");
|
||||
# endif
|
||||
thread_table[i].suspended = TRUE;
|
||||
}
|
||||
}
|
||||
|
@ -53,6 +80,9 @@ void GC_start_world()
|
|||
GC_please_stop = FALSE;
|
||||
}
|
||||
|
||||
# ifdef _MSC_VER
|
||||
# pragma warning(disable:4715)
|
||||
# endif
|
||||
ptr_t GC_current_stackbottom()
|
||||
{
|
||||
DWORD thread_id = GetCurrentThreadId();
|
||||
|
@ -62,18 +92,30 @@ ptr_t GC_current_stackbottom()
|
|||
return thread_table[i].stack;
|
||||
ABORT("no thread table entry for current thread");
|
||||
}
|
||||
# ifdef _MSC_VER
|
||||
# pragma warning(default:4715)
|
||||
# endif
|
||||
|
||||
static ptr_t GC_get_lo_stack_addr(ptr_t s)
|
||||
{
|
||||
ptr_t bottom;
|
||||
MEMORY_BASIC_INFORMATION info;
|
||||
VirtualQuery(s, &info, sizeof(info));
|
||||
do {
|
||||
bottom = info.BaseAddress;
|
||||
VirtualQuery(bottom - 1, &info, sizeof(info));
|
||||
} while ((info.Protect & PAGE_READWRITE) && !(info.Protect & PAGE_GUARD));
|
||||
return(bottom);
|
||||
}
|
||||
# ifdef MSWINCE
|
||||
/* The VirtualQuery calls below won't work properly on WinCE, but */
|
||||
/* since each stack is restricted to an aligned 64K region of */
|
||||
/* virtual memory we can just take the next lowest multiple of 64K. */
|
||||
# define GC_get_lo_stack_addr(s) \
|
||||
((ptr_t)(((DWORD)(s) - 1) & 0xFFFF0000))
|
||||
# else
|
||||
static ptr_t GC_get_lo_stack_addr(ptr_t s)
|
||||
{
|
||||
ptr_t bottom;
|
||||
MEMORY_BASIC_INFORMATION info;
|
||||
VirtualQuery(s, &info, sizeof(info));
|
||||
do {
|
||||
bottom = info.BaseAddress;
|
||||
VirtualQuery(bottom - 1, &info, sizeof(info));
|
||||
} while ((info.Protect & PAGE_READWRITE)
|
||||
&& !(info.Protect & PAGE_GUARD));
|
||||
return(bottom);
|
||||
}
|
||||
# endif
|
||||
|
||||
void GC_push_all_stacks()
|
||||
{
|
||||
|
@ -83,23 +125,186 @@ void GC_push_all_stacks()
|
|||
if (thread_table[i].stack) {
|
||||
ptr_t bottom = GC_get_lo_stack_addr(thread_table[i].stack);
|
||||
if (thread_table[i].id == thread_id)
|
||||
GC_push_all_stack(&i, thread_table[i].stack);
|
||||
GC_push_all_stack((ptr_t)&i, thread_table[i].stack);
|
||||
else {
|
||||
thread_table[i].context.ContextFlags
|
||||
= (CONTEXT_INTEGER|CONTEXT_CONTROL);
|
||||
if (!GetThreadContext(thread_table[i].handle,
|
||||
&thread_table[i].context))
|
||||
/* cast away volatile qualifier */
|
||||
(LPCONTEXT)&thread_table[i].context))
|
||||
ABORT("GetThreadContext failed");
|
||||
if (thread_table[i].context.Esp >= (DWORD)thread_table[i].stack
|
||||
|| thread_table[i].context.Esp < (DWORD)bottom)
|
||||
ABORT("Thread stack pointer out of range");
|
||||
GC_push_one ((word) thread_table[i].context.Edi);
|
||||
GC_push_one ((word) thread_table[i].context.Esi);
|
||||
GC_push_one ((word) thread_table[i].context.Ebx);
|
||||
GC_push_one ((word) thread_table[i].context.Edx);
|
||||
GC_push_one ((word) thread_table[i].context.Ecx);
|
||||
GC_push_one ((word) thread_table[i].context.Eax);
|
||||
GC_push_all_stack(thread_table[i].context.Esp, thread_table[i].stack);
|
||||
# ifdef I386
|
||||
if (thread_table[i].context.Esp >= (DWORD)thread_table[i].stack
|
||||
|| thread_table[i].context.Esp < (DWORD)bottom)
|
||||
ABORT("Thread stack pointer out of range");
|
||||
GC_push_one ((word) thread_table[i].context.Edi);
|
||||
GC_push_one ((word) thread_table[i].context.Esi);
|
||||
GC_push_one ((word) thread_table[i].context.Ebp);
|
||||
GC_push_one ((word) thread_table[i].context.Ebx);
|
||||
GC_push_one ((word) thread_table[i].context.Edx);
|
||||
GC_push_one ((word) thread_table[i].context.Ecx);
|
||||
GC_push_one ((word) thread_table[i].context.Eax);
|
||||
GC_push_all_stack((char *) thread_table[i].context.Esp,
|
||||
thread_table[i].stack);
|
||||
# else
|
||||
# ifdef ARM32
|
||||
if (thread_table[i].context.Sp >= (DWORD)thread_table[i].stack
|
||||
|| thread_table[i].context.Sp < (DWORD)bottom)
|
||||
ABORT("Thread stack pointer out of range");
|
||||
GC_push_one ((word) thread_table[i].context.R0);
|
||||
GC_push_one ((word) thread_table[i].context.R1);
|
||||
GC_push_one ((word) thread_table[i].context.R2);
|
||||
GC_push_one ((word) thread_table[i].context.R3);
|
||||
GC_push_one ((word) thread_table[i].context.R4);
|
||||
GC_push_one ((word) thread_table[i].context.R5);
|
||||
GC_push_one ((word) thread_table[i].context.R6);
|
||||
GC_push_one ((word) thread_table[i].context.R7);
|
||||
GC_push_one ((word) thread_table[i].context.R8);
|
||||
GC_push_one ((word) thread_table[i].context.R9);
|
||||
GC_push_one ((word) thread_table[i].context.R10);
|
||||
GC_push_one ((word) thread_table[i].context.R11);
|
||||
GC_push_one ((word) thread_table[i].context.R12);
|
||||
GC_push_all_stack((char *) thread_table[i].context.Sp,
|
||||
thread_table[i].stack);
|
||||
# else
|
||||
# ifdef SHx
|
||||
if (thread_table[i].context.R15 >= (DWORD)thread_table[i].stack
|
||||
|| thread_table[i].context.R15 < (DWORD)bottom)
|
||||
ABORT("Thread stack pointer out of range");
|
||||
GC_push_one ((word) thread_table[i].context.R0);
|
||||
GC_push_one ((word) thread_table[i].context.R1);
|
||||
GC_push_one ((word) thread_table[i].context.R2);
|
||||
GC_push_one ((word) thread_table[i].context.R3);
|
||||
GC_push_one ((word) thread_table[i].context.R4);
|
||||
GC_push_one ((word) thread_table[i].context.R5);
|
||||
GC_push_one ((word) thread_table[i].context.R6);
|
||||
GC_push_one ((word) thread_table[i].context.R7);
|
||||
GC_push_one ((word) thread_table[i].context.R8);
|
||||
GC_push_one ((word) thread_table[i].context.R9);
|
||||
GC_push_one ((word) thread_table[i].context.R10);
|
||||
GC_push_one ((word) thread_table[i].context.R11);
|
||||
GC_push_one ((word) thread_table[i].context.R12);
|
||||
GC_push_one ((word) thread_table[i].context.R13);
|
||||
GC_push_one ((word) thread_table[i].context.R14);
|
||||
GC_push_all_stack((char *) thread_table[i].context.R15,
|
||||
thread_table[i].stack);
|
||||
# else
|
||||
# ifdef MIPS
|
||||
if (thread_table[i].context.IntSp >= (DWORD)thread_table[i].stack
|
||||
|| thread_table[i].context.IntSp < (DWORD)bottom)
|
||||
ABORT("Thread stack pointer out of range");
|
||||
GC_push_one ((word) thread_table[i].context.IntAt);
|
||||
GC_push_one ((word) thread_table[i].context.IntV0);
|
||||
GC_push_one ((word) thread_table[i].context.IntV1);
|
||||
GC_push_one ((word) thread_table[i].context.IntA0);
|
||||
GC_push_one ((word) thread_table[i].context.IntA1);
|
||||
GC_push_one ((word) thread_table[i].context.IntA2);
|
||||
GC_push_one ((word) thread_table[i].context.IntA3);
|
||||
GC_push_one ((word) thread_table[i].context.IntT0);
|
||||
GC_push_one ((word) thread_table[i].context.IntT1);
|
||||
GC_push_one ((word) thread_table[i].context.IntT2);
|
||||
GC_push_one ((word) thread_table[i].context.IntT3);
|
||||
GC_push_one ((word) thread_table[i].context.IntT4);
|
||||
GC_push_one ((word) thread_table[i].context.IntT5);
|
||||
GC_push_one ((word) thread_table[i].context.IntT6);
|
||||
GC_push_one ((word) thread_table[i].context.IntT7);
|
||||
GC_push_one ((word) thread_table[i].context.IntS0);
|
||||
GC_push_one ((word) thread_table[i].context.IntS1);
|
||||
GC_push_one ((word) thread_table[i].context.IntS2);
|
||||
GC_push_one ((word) thread_table[i].context.IntS3);
|
||||
GC_push_one ((word) thread_table[i].context.IntS4);
|
||||
GC_push_one ((word) thread_table[i].context.IntS5);
|
||||
GC_push_one ((word) thread_table[i].context.IntS6);
|
||||
GC_push_one ((word) thread_table[i].context.IntS7);
|
||||
GC_push_one ((word) thread_table[i].context.IntT8);
|
||||
GC_push_one ((word) thread_table[i].context.IntT9);
|
||||
GC_push_one ((word) thread_table[i].context.IntK0);
|
||||
GC_push_one ((word) thread_table[i].context.IntK1);
|
||||
GC_push_one ((word) thread_table[i].context.IntS8);
|
||||
GC_push_all_stack((char *) thread_table[i].context.IntSp,
|
||||
thread_table[i].stack);
|
||||
# else
|
||||
# ifdef PPC
|
||||
if (thread_table[i].context.Gpr1 >= (DWORD)thread_table[i].stack
|
||||
|| thread_table[i].context.Gpr1 < (DWORD)bottom)
|
||||
ABORT("Thread stack pointer out of range");
|
||||
GC_push_one ((word) thread_table[i].context.Gpr0);
|
||||
/* Gpr1 is stack pointer */
|
||||
/* Gpr2 is global pointer */
|
||||
GC_push_one ((word) thread_table[i].context.Gpr3);
|
||||
GC_push_one ((word) thread_table[i].context.Gpr4);
|
||||
GC_push_one ((word) thread_table[i].context.Gpr5);
|
||||
GC_push_one ((word) thread_table[i].context.Gpr6);
|
||||
GC_push_one ((word) thread_table[i].context.Gpr7);
|
||||
GC_push_one ((word) thread_table[i].context.Gpr8);
|
||||
GC_push_one ((word) thread_table[i].context.Gpr9);
|
||||
GC_push_one ((word) thread_table[i].context.Gpr10);
|
||||
GC_push_one ((word) thread_table[i].context.Gpr11);
|
||||
GC_push_one ((word) thread_table[i].context.Gpr12);
|
||||
/* Gpr13 is reserved for the kernel */
|
||||
GC_push_one ((word) thread_table[i].context.Gpr14);
|
||||
GC_push_one ((word) thread_table[i].context.Gpr15);
|
||||
GC_push_one ((word) thread_table[i].context.Gpr16);
|
||||
GC_push_one ((word) thread_table[i].context.Gpr17);
|
||||
GC_push_one ((word) thread_table[i].context.Gpr18);
|
||||
GC_push_one ((word) thread_table[i].context.Gpr19);
|
||||
GC_push_one ((word) thread_table[i].context.Gpr20);
|
||||
GC_push_one ((word) thread_table[i].context.Gpr21);
|
||||
GC_push_one ((word) thread_table[i].context.Gpr22);
|
||||
GC_push_one ((word) thread_table[i].context.Gpr23);
|
||||
GC_push_one ((word) thread_table[i].context.Gpr24);
|
||||
GC_push_one ((word) thread_table[i].context.Gpr25);
|
||||
GC_push_one ((word) thread_table[i].context.Gpr26);
|
||||
GC_push_one ((word) thread_table[i].context.Gpr27);
|
||||
GC_push_one ((word) thread_table[i].context.Gpr28);
|
||||
GC_push_one ((word) thread_table[i].context.Gpr29);
|
||||
GC_push_one ((word) thread_table[i].context.Gpr30);
|
||||
GC_push_one ((word) thread_table[i].context.Gpr31);
|
||||
GC_push_all_stack((char *) thread_table[i].context.Gpr1,
|
||||
thread_table[i].stack);
|
||||
# else
|
||||
# ifdef ALPHA
|
||||
if (thread_table[i].context.IntSp >= (DWORD)thread_table[i].stack
|
||||
|| thread_table[i].context.IntSp < (DWORD)bottom)
|
||||
ABORT("Thread stack pointer out of range");
|
||||
GC_push_one ((word) thread_table[i].context.IntV0);
|
||||
GC_push_one ((word) thread_table[i].context.IntT0);
|
||||
GC_push_one ((word) thread_table[i].context.IntT1);
|
||||
GC_push_one ((word) thread_table[i].context.IntT2);
|
||||
GC_push_one ((word) thread_table[i].context.IntT3);
|
||||
GC_push_one ((word) thread_table[i].context.IntT4);
|
||||
GC_push_one ((word) thread_table[i].context.IntT5);
|
||||
GC_push_one ((word) thread_table[i].context.IntT6);
|
||||
GC_push_one ((word) thread_table[i].context.IntT7);
|
||||
GC_push_one ((word) thread_table[i].context.IntS0);
|
||||
GC_push_one ((word) thread_table[i].context.IntS1);
|
||||
GC_push_one ((word) thread_table[i].context.IntS2);
|
||||
GC_push_one ((word) thread_table[i].context.IntS3);
|
||||
GC_push_one ((word) thread_table[i].context.IntS4);
|
||||
GC_push_one ((word) thread_table[i].context.IntS5);
|
||||
GC_push_one ((word) thread_table[i].context.IntFp);
|
||||
GC_push_one ((word) thread_table[i].context.IntA0);
|
||||
GC_push_one ((word) thread_table[i].context.IntA1);
|
||||
GC_push_one ((word) thread_table[i].context.IntA2);
|
||||
GC_push_one ((word) thread_table[i].context.IntA3);
|
||||
GC_push_one ((word) thread_table[i].context.IntA4);
|
||||
GC_push_one ((word) thread_table[i].context.IntA5);
|
||||
GC_push_one ((word) thread_table[i].context.IntT8);
|
||||
GC_push_one ((word) thread_table[i].context.IntT9);
|
||||
GC_push_one ((word) thread_table[i].context.IntT10);
|
||||
GC_push_one ((word) thread_table[i].context.IntT11);
|
||||
GC_push_one ((word) thread_table[i].context.IntT12);
|
||||
GC_push_one ((word) thread_table[i].context.IntAt);
|
||||
GC_push_all_stack((char *) thread_table[i].context.IntSp,
|
||||
thread_table[i].stack);
|
||||
# else
|
||||
--> architecture not supported
|
||||
# endif /* !ALPHA */
|
||||
# endif /* !PPC */
|
||||
# endif /* !MIPS */
|
||||
# endif /* !SHx */
|
||||
# endif /* !ARM32 */
|
||||
# endif /* !I386 */
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -126,6 +331,177 @@ void GC_get_next_stack(char *start, char **lo, char **hi)
|
|||
if (*lo < start) *lo = start;
|
||||
}
|
||||
|
||||
|
||||
# ifdef MSWINCE
|
||||
|
||||
typedef struct {
|
||||
HANDLE child_ready_h, parent_ready_h;
|
||||
volatile struct thread_entry * entry;
|
||||
LPTHREAD_START_ROUTINE start;
|
||||
LPVOID param;
|
||||
} thread_args;
|
||||
|
||||
DWORD WINAPI thread_start(LPVOID arg);
|
||||
|
||||
HANDLE WINAPI GC_CreateThread(
|
||||
LPSECURITY_ATTRIBUTES lpThreadAttributes,
|
||||
DWORD dwStackSize, LPTHREAD_START_ROUTINE lpStartAddress,
|
||||
LPVOID lpParameter, DWORD dwCreationFlags, LPDWORD lpThreadId )
|
||||
{
|
||||
HANDLE thread_h = NULL;
|
||||
HANDLE child_ready_h, parent_ready_h;
|
||||
|
||||
int i;
|
||||
thread_args args;
|
||||
|
||||
/* allocate thread slot */
|
||||
LOCK();
|
||||
for (i = 0; i != MAX_THREADS && thread_table[i].in_use; i++)
|
||||
;
|
||||
if (i != MAX_THREADS) {
|
||||
thread_table[i].in_use = TRUE;
|
||||
}
|
||||
UNLOCK();
|
||||
|
||||
if (i != MAX_THREADS) {
|
||||
|
||||
/* create unnamed unsignalled events */
|
||||
if (child_ready_h = CreateEvent(NULL, FALSE, FALSE, NULL)) {
|
||||
if (parent_ready_h = CreateEvent(NULL, FALSE, FALSE, NULL)) {
|
||||
|
||||
/* set up thread arguments */
|
||||
args.child_ready_h = child_ready_h;
|
||||
args.parent_ready_h = parent_ready_h;
|
||||
args.entry = &thread_table[i];
|
||||
args.start = lpStartAddress;
|
||||
args.param = lpParameter;
|
||||
|
||||
thread_h = CreateThread(lpThreadAttributes,
|
||||
dwStackSize, thread_start,
|
||||
&args,
|
||||
dwCreationFlags & ~CREATE_SUSPENDED,
|
||||
lpThreadId);
|
||||
|
||||
if (thread_h) {
|
||||
|
||||
/* fill in ID and handle; tell child this is done */
|
||||
thread_table[i].id = *lpThreadId;
|
||||
thread_table[i].handle = thread_h;
|
||||
SetEvent (parent_ready_h);
|
||||
|
||||
/* wait for child to fill in stack and copy args */
|
||||
WaitForSingleObject (child_ready_h, INFINITE);
|
||||
|
||||
/* suspend the child if requested */
|
||||
if (dwCreationFlags & CREATE_SUSPENDED)
|
||||
SuspendThread (thread_h);
|
||||
|
||||
/* let child call given function now (or when resumed) */
|
||||
SetEvent (parent_ready_h);
|
||||
|
||||
} else {
|
||||
CloseHandle (parent_ready_h);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
CloseHandle (child_ready_h);
|
||||
|
||||
if (thread_h == NULL)
|
||||
thread_table[i].in_use = FALSE;
|
||||
|
||||
} else { /* no thread slot found */
|
||||
SetLastError (ERROR_TOO_MANY_TCBS);
|
||||
}
|
||||
|
||||
return thread_h;
|
||||
}
|
||||
|
||||
static DWORD WINAPI thread_start(LPVOID arg)
|
||||
{
|
||||
DWORD ret = 0;
|
||||
thread_args args = *(thread_args *)arg;
|
||||
|
||||
/* wait for parent to fill in ID and handle */
|
||||
WaitForSingleObject (args.parent_ready_h, INFINITE);
|
||||
ResetEvent (args.parent_ready_h);
|
||||
|
||||
/* fill in stack; tell parent this is done */
|
||||
args.entry->stack = GC_get_stack_base();
|
||||
SetEvent (args.child_ready_h);
|
||||
|
||||
/* wait for parent to tell us to go (in case it needs to suspend us) */
|
||||
WaitForSingleObject (args.parent_ready_h, INFINITE);
|
||||
CloseHandle (args.parent_ready_h);
|
||||
|
||||
/* Clear the thread entry even if we exit with an exception. */
|
||||
/* This is probably pointless, since an uncaught exception is */
|
||||
/* supposed to result in the process being killed. */
|
||||
__try {
|
||||
ret = args.start (args.param);
|
||||
} __finally {
|
||||
LOCK();
|
||||
args.entry->stack = 0;
|
||||
args.entry->in_use = FALSE;
|
||||
/* cast away volatile qualifier */
|
||||
BZERO((void *) &args.entry->context, sizeof(CONTEXT));
|
||||
UNLOCK();
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
HINSTANCE hInstance;
|
||||
HINSTANCE hPrevInstance;
|
||||
LPWSTR lpCmdLine;
|
||||
int nShowCmd;
|
||||
} main_thread_args;
|
||||
|
||||
DWORD WINAPI main_thread_start(LPVOID arg);
|
||||
|
||||
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
|
||||
LPWSTR lpCmdLine, int nShowCmd)
|
||||
{
|
||||
DWORD exit_code = 1;
|
||||
|
||||
main_thread_args args = {
|
||||
hInstance, hPrevInstance, lpCmdLine, nShowCmd
|
||||
};
|
||||
HANDLE thread_h;
|
||||
DWORD thread_id;
|
||||
|
||||
/* initialize everything */
|
||||
InitializeCriticalSection(&GC_allocate_ml);
|
||||
GC_init();
|
||||
|
||||
/* start the main thread */
|
||||
thread_h = GC_CreateThread(
|
||||
NULL, 0, main_thread_start, &args, 0, &thread_id);
|
||||
|
||||
if (thread_h != NULL)
|
||||
{
|
||||
WaitForSingleObject (thread_h, INFINITE);
|
||||
GetExitCodeThread (thread_h, &exit_code);
|
||||
CloseHandle (thread_h);
|
||||
}
|
||||
|
||||
GC_deinit();
|
||||
DeleteCriticalSection(&GC_allocate_ml);
|
||||
|
||||
return (int) exit_code;
|
||||
}
|
||||
|
||||
DWORD WINAPI main_thread_start(LPVOID arg)
|
||||
{
|
||||
main_thread_args * args = (main_thread_args *) arg;
|
||||
|
||||
return (DWORD) GC_WinMain (args->hInstance, args->hPrevInstance,
|
||||
args->lpCmdLine, args->nShowCmd);
|
||||
}
|
||||
|
||||
# else /* !MSWINCE */
|
||||
|
||||
LONG WINAPI GC_write_fault_handler(struct _EXCEPTION_POINTERS *exc_info);
|
||||
|
||||
/*
|
||||
|
@ -153,11 +529,14 @@ BOOL WINAPI DllMain(HINSTANCE inst, ULONG reason, LPVOID reserved)
|
|||
/* The following should be a noop according to the win32 */
|
||||
/* documentation. There is empirical evidence that it */
|
||||
/* isn't. - HB */
|
||||
# ifndef SMALL_CONFIG
|
||||
# ifdef MPROTECT_VDB
|
||||
if (GC_incremental) SetUnhandledExceptionFilter(GC_write_fault_handler);
|
||||
# endif
|
||||
|
||||
for (i = 0; InterlockedExchange(&thread_table[i].in_use,1) != 0; i++) {
|
||||
for (i = 0;
|
||||
/* cast away volatile qualifier */
|
||||
InterlockedExchange((LPLONG) &thread_table[i].in_use, 1) != 0;
|
||||
i++) {
|
||||
/* Compare-and-swap would make this cleaner, but that's not */
|
||||
/* supported before Windows 98 and NT 4.0. In Windows 2000, */
|
||||
/* InterlockedExchange is supposed to be replaced by */
|
||||
|
@ -168,15 +547,16 @@ BOOL WINAPI DllMain(HINSTANCE inst, ULONG reason, LPVOID reserved)
|
|||
}
|
||||
thread_table[i].id = GetCurrentThreadId();
|
||||
if (!DuplicateHandle(GetCurrentProcess(),
|
||||
GetCurrentThread(),
|
||||
GetCurrentThread(),
|
||||
GetCurrentProcess(),
|
||||
&thread_table[i].handle,
|
||||
/* cast away volatile qualifier */
|
||||
(HANDLE *) &thread_table[i].handle,
|
||||
0,
|
||||
0,
|
||||
DUPLICATE_SAME_ACCESS)) {
|
||||
DWORD last_error = GetLastError();
|
||||
GC_printf1("Last error code: %lx\n", last_error);
|
||||
ABORT("DuplicateHandle failed");
|
||||
DWORD last_error = GetLastError();
|
||||
GC_printf1("Last error code: %lx\n", last_error);
|
||||
ABORT("DuplicateHandle failed");
|
||||
}
|
||||
thread_table[i].stack = GC_get_stack_base();
|
||||
/* If this thread is being created while we are trying to stop */
|
||||
|
@ -185,27 +565,53 @@ BOOL WINAPI DllMain(HINSTANCE inst, ULONG reason, LPVOID reserved)
|
|||
while (GC_please_stop) Sleep(20);
|
||||
}
|
||||
break;
|
||||
case DLL_PROCESS_DETACH:
|
||||
case DLL_THREAD_DETACH:
|
||||
{
|
||||
int i;
|
||||
DWORD thread_id = GetCurrentThreadId();
|
||||
LOCK();
|
||||
for (i = 0;
|
||||
thread_table[i].stack == 0 || thread_table[i].id != thread_id;
|
||||
i++) {
|
||||
if (i == MAX_THREADS - 1)
|
||||
ABORT("thread not found on detach");
|
||||
i < MAX_THREADS &&
|
||||
(thread_table[i].stack == 0 || thread_table[i].id != thread_id);
|
||||
i++) {}
|
||||
if (i >= MAX_THREADS) {
|
||||
WARN("thread %ld not found on detach", (GC_word)thread_id);
|
||||
} else {
|
||||
thread_table[i].stack = 0;
|
||||
thread_table[i].in_use = FALSE;
|
||||
CloseHandle(thread_table[i].handle);
|
||||
/* cast away volatile qualifier */
|
||||
BZERO((void *) &thread_table[i].context, sizeof(CONTEXT));
|
||||
}
|
||||
thread_table[i].stack = 0;
|
||||
thread_table[i].in_use = FALSE;
|
||||
CloseHandle(thread_table[i].handle);
|
||||
BZERO(&thread_table[i].context, sizeof(CONTEXT));
|
||||
UNLOCK();
|
||||
}
|
||||
break;
|
||||
case DLL_PROCESS_DETACH:
|
||||
{
|
||||
int i;
|
||||
|
||||
LOCK();
|
||||
for (i = 0; i < MAX_THREADS; ++i)
|
||||
{
|
||||
if (thread_table[i].in_use)
|
||||
{
|
||||
thread_table[i].stack = 0;
|
||||
thread_table[i].in_use = FALSE;
|
||||
CloseHandle(thread_table[i].handle);
|
||||
BZERO((void *) &thread_table[i].context, sizeof(CONTEXT));
|
||||
}
|
||||
}
|
||||
UNLOCK();
|
||||
|
||||
GC_deinit();
|
||||
DeleteCriticalSection(&GC_allocate_ml);
|
||||
}
|
||||
break;
|
||||
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
# endif /* !MSWINCE */
|
||||
|
||||
#endif /* WIN32_THREADS */
|
||||
|
|
Loading…
Add table
Reference in a new issue