Commit 56293c2b by Bryce McKinlay

This commit was generated by cvs2svn to compensate for changes in r33244,

which included commits to RCS files with non-trunk default branches.

From-SVN: r33245
parent 0eebf9e5
...@@ -29,9 +29,11 @@ ...@@ -29,9 +29,11 @@
/* source is heap object ==> *base_p != 0, *offset_p = offset */ /* source is heap object ==> *base_p != 0, *offset_p = offset */
/* Returns 1 on success, 0 if source couldn't be determined. */ /* Returns 1 on success, 0 if source couldn't be determined. */
/* Dest can be any address within a heap object. */ /* Dest can be any address within a heap object. */
typedef enum { GC_UNREFERENCED, /* No refence info available. */ typedef enum { GC_UNREFERENCED, /* No reference info available. */
GC_NO_SPACE, /* Dest not allocated with debug alloc */ GC_NO_SPACE, /* Dest not allocated with debug alloc */
GC_REFD_FROM_ROOT, /* Referenced directly by root *base_p */ 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_REFD_FROM_HEAP, /* Referenced from another heap obj. */
GC_FINALIZER_REFD /* Finalizable and hence accessible. */ GC_FINALIZER_REFD /* Finalizable and hence accessible. */
} GC_ref_kind; } GC_ref_kind;
...@@ -53,4 +55,9 @@ void * GC_generate_random_valid_address(void); ...@@ -53,4 +55,9 @@ void * GC_generate_random_valid_address(void);
/* source in dbg_mlc.c also serves as a sample client. */ /* source in dbg_mlc.c also serves as a sample client. */
void GC_generate_random_backtrace(void); 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 *);
...@@ -233,7 +233,7 @@ int CORD_vsprintf(CORD * out, CORD format, va_list args) ...@@ -233,7 +233,7 @@ int CORD_vsprintf(CORD * out, CORD format, va_list args)
if (width == NONE && prec == NONE) { if (width == NONE && prec == NONE) {
register char c; register char c;
c = va_arg(args, char); c = va_arg(args, int);
CORD_ec_append(result, c); CORD_ec_append(result, c);
goto done; goto done;
} }
......
/* /*
* Copyright 1988, 1989 Hans-J. Boehm, Alan J. Demers * Copyright 1988, 1989 Hans-J. Boehm, Alan J. Demers
* Copyright (c) 1991-1995 by Xerox Corporation. All rights reserved. * Copyright (c) 1991-1995 by Xerox Corporation. All rights reserved.
* Copyright 1996 by Silicon Graphics. 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 * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED
* OR IMPLIED. ANY USE IS AT YOUR OWN RISK. * OR IMPLIED. ANY USE IS AT YOUR OWN RISK.
...@@ -352,11 +353,11 @@ GC_API GC_PTR GC_malloc_atomic_ignore_off_page GC_PROTO((size_t lb)); ...@@ -352,11 +353,11 @@ GC_API GC_PTR GC_malloc_atomic_ignore_off_page GC_PROTO((size_t lb));
#ifdef GC_ADD_CALLER #ifdef GC_ADD_CALLER
# define GC_EXTRAS GC_RETURN_ADDR, __FILE__, __LINE__ # define GC_EXTRAS GC_RETURN_ADDR, __FILE__, __LINE__
# define GC_EXTRA_PARAMS GC_word ra, GC_CONST char * descr_string, # define GC_EXTRA_PARAMS GC_word ra, GC_CONST char * s,
int descr_int int i
#else #else
# define GC_EXTRAS __FILE__, __LINE__ # define GC_EXTRAS __FILE__, __LINE__
# define GC_EXTRA_PARAMS GC_CONST char * descr_string, int descr_int # define GC_EXTRA_PARAMS GC_CONST char * s, int i
#endif #endif
/* Debugging (annotated) allocation. GC_gcollect will check */ /* Debugging (annotated) allocation. GC_gcollect will check */
......
...@@ -387,7 +387,8 @@ int GC_is_thread_stack(ptr_t addr) ...@@ -387,7 +387,8 @@ int GC_is_thread_stack(ptr_t addr)
} }
# endif # endif
/* We hold allocation lock. We assume the world is stopped. */ /* We hold allocation lock. Should do exactly the right thing if the */
/* world is stopped. Should not fail if it isn't. */
void GC_push_all_stacks() void GC_push_all_stacks()
{ {
register int i; register int i;
......
...@@ -29,9 +29,11 @@ ...@@ -29,9 +29,11 @@
/* source is heap object ==> *base_p != 0, *offset_p = offset */ /* source is heap object ==> *base_p != 0, *offset_p = offset */
/* Returns 1 on success, 0 if source couldn't be determined. */ /* Returns 1 on success, 0 if source couldn't be determined. */
/* Dest can be any address within a heap object. */ /* Dest can be any address within a heap object. */
typedef enum { GC_UNREFERENCED, /* No refence info available. */ typedef enum { GC_UNREFERENCED, /* No reference info available. */
GC_NO_SPACE, /* Dest not allocated with debug alloc */ GC_NO_SPACE, /* Dest not allocated with debug alloc */
GC_REFD_FROM_ROOT, /* Referenced directly by root *base_p */ 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_REFD_FROM_HEAP, /* Referenced from another heap obj. */
GC_FINALIZER_REFD /* Finalizable and hence accessible. */ GC_FINALIZER_REFD /* Finalizable and hence accessible. */
} GC_ref_kind; } GC_ref_kind;
...@@ -53,4 +55,9 @@ void * GC_generate_random_valid_address(void); ...@@ -53,4 +55,9 @@ void * GC_generate_random_valid_address(void);
/* source in dbg_mlc.c also serves as a sample client. */ /* source in dbg_mlc.c also serves as a sample client. */
void GC_generate_random_backtrace(void); 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 *);
...@@ -41,7 +41,7 @@ ...@@ -41,7 +41,7 @@
* This interface is fairly big, largely for performance reasons. * This interface is fairly big, largely for performance reasons.
* The most basic constants and functions: * The most basic constants and functions:
* *
* CORD - the type fo a cord; * CORD - the type of a cord;
* CORD_EMPTY - empty cord; * CORD_EMPTY - empty cord;
* CORD_len(cord) - length of a cord; * CORD_len(cord) - length of a cord;
* CORD_cat(cord1,cord2) - concatenation of two cords; * CORD_cat(cord1,cord2) - concatenation of two cords;
......
/* /*
* Copyright 1988, 1989 Hans-J. Boehm, Alan J. Demers * Copyright 1988, 1989 Hans-J. Boehm, Alan J. Demers
* Copyright (c) 1991-1995 by Xerox Corporation. All rights reserved. * Copyright (c) 1991-1995 by Xerox Corporation. All rights reserved.
* Copyright 1996 by Silicon Graphics. 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 * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED
* OR IMPLIED. ANY USE IS AT YOUR OWN RISK. * OR IMPLIED. ANY USE IS AT YOUR OWN RISK.
...@@ -35,6 +36,14 @@ ...@@ -35,6 +36,14 @@
#include "libgc_globals.h" #include "libgc_globals.h"
#endif #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) #if defined(_MSC_VER) && defined(_DLL)
# ifdef GC_BUILD # ifdef GC_BUILD
# define GC_API __declspec(dllexport) # define GC_API __declspec(dllexport)
...@@ -130,6 +139,17 @@ GC_API int GC_dont_expand; ...@@ -130,6 +139,17 @@ GC_API int GC_dont_expand;
/* Dont expand heap unless explicitly requested */ /* Dont expand heap unless explicitly requested */
/* or forced to. */ /* 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 */ GC_API int GC_full_freq; /* Number of partial collections between */
/* full collections. Matters only if */ /* full collections. Matters only if */
/* GC_incremental is set. */ /* GC_incremental is set. */
...@@ -352,11 +372,11 @@ GC_API GC_PTR GC_malloc_atomic_ignore_off_page GC_PROTO((size_t lb)); ...@@ -352,11 +372,11 @@ GC_API GC_PTR GC_malloc_atomic_ignore_off_page GC_PROTO((size_t lb));
#ifdef GC_ADD_CALLER #ifdef GC_ADD_CALLER
# define GC_EXTRAS GC_RETURN_ADDR, __FILE__, __LINE__ # define GC_EXTRAS GC_RETURN_ADDR, __FILE__, __LINE__
# define GC_EXTRA_PARAMS GC_word ra, GC_CONST char * descr_string, # define GC_EXTRA_PARAMS GC_word ra, GC_CONST char * s,
int descr_int int i
#else #else
# define GC_EXTRAS __FILE__, __LINE__ # define GC_EXTRAS __FILE__, __LINE__
# define GC_EXTRA_PARAMS GC_CONST char * descr_string, int descr_int # define GC_EXTRA_PARAMS GC_CONST char * s, int i
#endif #endif
/* Debugging (annotated) allocation. GC_gcollect will check */ /* Debugging (annotated) allocation. GC_gcollect will check */
...@@ -387,6 +407,8 @@ GC_API void GC_debug_end_stubborn_change GC_PROTO((GC_PTR)); ...@@ -387,6 +407,8 @@ GC_API void GC_debug_end_stubborn_change GC_PROTO((GC_PTR));
GC_debug_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) \ # define GC_REGISTER_FINALIZER_IGNORE_SELF(p, f, d, of, od) \
GC_debug_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_MALLOC_STUBBORN(sz) GC_debug_malloc_stubborn(sz, GC_EXTRAS);
# define GC_CHANGE_STUBBORN(p) GC_debug_change_stubborn(p) # define GC_CHANGE_STUBBORN(p) GC_debug_change_stubborn(p)
# define GC_END_STUBBORN_CHANGE(p) GC_debug_end_stubborn_change(p) # define GC_END_STUBBORN_CHANGE(p) GC_debug_end_stubborn_change(p)
...@@ -403,6 +425,8 @@ GC_API void GC_debug_end_stubborn_change GC_PROTO((GC_PTR)); ...@@ -403,6 +425,8 @@ GC_API void GC_debug_end_stubborn_change GC_PROTO((GC_PTR));
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) \ # define GC_REGISTER_FINALIZER_IGNORE_SELF(p, f, d, of, od) \
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_MALLOC_STUBBORN(sz) GC_malloc_stubborn(sz)
# define GC_CHANGE_STUBBORN(p) GC_change_stubborn(p) # define GC_CHANGE_STUBBORN(p) GC_change_stubborn(p)
# define GC_END_STUBBORN_CHANGE(p) GC_end_stubborn_change(p) # define GC_END_STUBBORN_CHANGE(p) GC_end_stubborn_change(p)
...@@ -481,6 +505,16 @@ GC_API void GC_debug_register_finalizer_ignore_self ...@@ -481,6 +505,16 @@ GC_API void GC_debug_register_finalizer_ignore_self
GC_PROTO((GC_PTR obj, GC_finalization_proc fn, GC_PTR cd, GC_PROTO((GC_PTR obj, GC_finalization_proc fn, GC_PTR cd,
GC_finalization_proc *ofn, GC_PTR *ocd)); 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 */ /* The following routine may be used to break cycles between */
/* finalizable objects, thus causing cyclic finalizable */ /* finalizable objects, thus causing cyclic finalizable */
/* objects to be finalized in the correct order. Standard */ /* objects to be finalized in the correct order. Standard */
...@@ -537,6 +571,9 @@ GC_API int GC_unregister_disappearing_link GC_PROTO((GC_PTR * /* link */)); ...@@ -537,6 +571,9 @@ GC_API int GC_unregister_disappearing_link GC_PROTO((GC_PTR * /* link */));
GC_API GC_PTR GC_make_closure GC_PROTO((GC_finalization_proc fn, GC_PTR data)); 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)); 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)); GC_API int GC_invoke_finalizers GC_PROTO((void));
/* Run finalizers for all objects that are ready to */ /* Run finalizers for all objects that are ready to */
/* be finalized. Return the number of finalizers */ /* be finalized. Return the number of finalizers */
...@@ -700,7 +737,8 @@ GC_API void (*GC_is_visible_print_proc) ...@@ -700,7 +737,8 @@ GC_API void (*GC_is_visible_print_proc)
# endif /* SOLARIS_THREADS */ # endif /* SOLARIS_THREADS */
#if defined(IRIX_THREADS) || defined(LINUX_THREADS) || defined(HPUX_THREADS) #if !defined(USE_LD_WRAP) && \
(defined(IRIX_THREADS) || defined(LINUX_THREADS) || defined(HPUX_THREADS))
/* We treat these similarly. */ /* We treat these similarly. */
# include <pthread.h> # include <pthread.h>
# include <signal.h> # include <signal.h>
...@@ -714,8 +752,9 @@ GC_API void (*GC_is_visible_print_proc) ...@@ -714,8 +752,9 @@ GC_API void (*GC_is_visible_print_proc)
# define pthread_create GC_pthread_create # define pthread_create GC_pthread_create
# define pthread_sigmask GC_pthread_sigmask # define pthread_sigmask GC_pthread_sigmask
# define pthread_join GC_pthread_join # define pthread_join GC_pthread_join
# define dlopen GC_dlopen
#endif /* IRIX_THREADS || LINUX_THREADS */ #endif /* xxxxx_THREADS */
# if defined(PCR) || defined(SOLARIS_THREADS) || defined(WIN32_THREADS) || \ # if defined(PCR) || defined(SOLARIS_THREADS) || defined(WIN32_THREADS) || \
defined(IRIX_THREADS) || defined(LINUX_THREADS) || \ defined(IRIX_THREADS) || defined(LINUX_THREADS) || \
......
...@@ -16,12 +16,11 @@ the code was modified is included with the above copyright notice. ...@@ -16,12 +16,11 @@ the code was modified is included with the above copyright notice.
C++ Interface to the Boehm Collector C++ Interface to the Boehm Collector
John R. Ellis and Jesse Hull John R. Ellis and Jesse Hull
Last modified on Mon Jul 24 15:43:42 PDT 1995 by ellis
This interface provides access to the Boehm collector. It provides This interface provides access to the Boehm collector. It provides
basic facilities similar to those described in "Safe, Efficient basic facilities similar to those described in "Safe, Efficient
Garbage Collection for C++", by John R. Elis and David L. Detlefs Garbage Collection for C++", by John R. Elis and David L. Detlefs
(ftp.parc.xerox.com:/pub/ellis/gc). (ftp://ftp.parc.xerox.com/pub/ellis/gc).
All heap-allocated objects are either "collectable" or All heap-allocated objects are either "collectable" or
"uncollectable". Programs must explicitly delete uncollectable "uncollectable". Programs must explicitly delete uncollectable
...@@ -38,7 +37,7 @@ Objects derived from class "gc" are collectable. For example: ...@@ -38,7 +37,7 @@ Objects derived from class "gc" are collectable. For example:
A* a = new A; // a is collectable. A* a = new A; // a is collectable.
Collectable instances of non-class types can be allocated using the GC Collectable instances of non-class types can be allocated using the GC
placement: (or UseGC) placement:
typedef int A[ 10 ]; typedef int A[ 10 ];
A* a = new (GC) A; A* a = new (GC) A;
...@@ -124,6 +123,12 @@ invoked using the ANSI-conforming syntax t->~T(). If you're using ...@@ -124,6 +123,12 @@ 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 cfront 3.0, you'll have to comment out the class gc_cleanup, which
uses explicit invocation. 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" #include "gc.h"
...@@ -138,7 +143,11 @@ uses explicit invocation. ...@@ -138,7 +143,11 @@ uses explicit invocation.
# define OPERATOR_NEW_ARRAY # define OPERATOR_NEW_ARRAY
#endif #endif
enum GCPlacement {GC, NoGC, PointerFreeGC}; enum GCPlacement {UseGC,
#ifndef GC_NAME_CONFLICT
GC=UseGC,
#endif
NoGC, PointerFreeGC};
class gc {public: class gc {public:
inline void* operator new( size_t size ); inline void* operator new( size_t size );
...@@ -211,7 +220,7 @@ inline void* gc::operator new( size_t size ) { ...@@ -211,7 +220,7 @@ inline void* gc::operator new( size_t size ) {
return GC_MALLOC( size );} return GC_MALLOC( size );}
inline void* gc::operator new( size_t size, GCPlacement gcp ) { inline void* gc::operator new( size_t size, GCPlacement gcp ) {
if (gcp == GC) if (gcp == UseGC)
return GC_MALLOC( size ); return GC_MALLOC( size );
else if (gcp == PointerFreeGC) else if (gcp == PointerFreeGC)
return GC_MALLOC_ATOMIC( size ); return GC_MALLOC_ATOMIC( size );
...@@ -261,7 +270,7 @@ inline void* operator new( ...@@ -261,7 +270,7 @@ inline void* operator new(
{ {
void* obj; void* obj;
if (gcp == GC) { if (gcp == UseGC) {
obj = GC_MALLOC( size ); obj = GC_MALLOC( size );
if (cleanup != 0) if (cleanup != 0)
GC_REGISTER_FINALIZER_IGNORE_SELF( GC_REGISTER_FINALIZER_IGNORE_SELF(
......
...@@ -61,6 +61,7 @@ GC_API GC_PTR GC_malloc_explicitly_typed ...@@ -61,6 +61,7 @@ GC_API GC_PTR GC_malloc_explicitly_typed
GC_PROTO((size_t size_in_bytes, GC_descr d)); GC_PROTO((size_t size_in_bytes, GC_descr d));
/* Allocate an object whose layout is described by d. */ /* Allocate an object whose layout is described by d. */
/* The resulting object MAY NOT BE PASSED TO REALLOC. */ /* 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_API GC_PTR GC_malloc_explicitly_typed_ignore_off_page
GC_PROTO((size_t size_in_bytes, GC_descr d)); GC_PROTO((size_t size_in_bytes, GC_descr d));
...@@ -75,6 +76,7 @@ GC_API GC_PTR GC_calloc_explicitly_typed ...@@ -75,6 +76,7 @@ GC_API GC_PTR GC_calloc_explicitly_typed
/* alignment required for pointers. E.g. on a 32-bit */ /* alignment required for pointers. E.g. on a 32-bit */
/* machine with 16-bit aligned pointers, size_in_bytes */ /* machine with 16-bit aligned pointers, size_in_bytes */
/* must be a multiple of 2. */ /* must be a multiple of 2. */
/* Returned object is cleared. */
#ifdef GC_DEBUG #ifdef GC_DEBUG
# define GC_MALLOC_EXPLICTLY_TYPED(bytes, d) GC_MALLOC(bytes) # define GC_MALLOC_EXPLICTLY_TYPED(bytes, d) GC_MALLOC(bytes)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment