X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=src%2Fmm%2Fcacao-gc%2Fgc.h;h=31060381d73868057a9a8dcbfb33960a0ee6cf40;hb=8c81647e1c96715f45498a3ada7f795b5c9dfe81;hp=0246992b085299845ba6bfcd06c46acd6db800e9;hpb=d06e2e8ef11e00c27605970b1738ebec4f09ef1b;p=cacao.git diff --git a/src/mm/cacao-gc/gc.h b/src/mm/cacao-gc/gc.h index 0246992b0..31060381d 100644 --- a/src/mm/cacao-gc/gc.h +++ b/src/mm/cacao-gc/gc.h @@ -1,9 +1,7 @@ /* src/mm/cacao-gc/gc.h - main garbage collector header - Copyright (C) 2006 R. Grafl, A. Krall, C. Kruegel, - C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring, - E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, - J. Wenninger, Institut f. Computersprachen - TU Wien + Copyright (C) 2006, 2008 + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO This file is part of CACAO. @@ -22,12 +20,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - Contact: cacao@cacaojvm.org - - Authors: Michael Starzinger - - $Id$ - */ @@ -40,9 +32,19 @@ #define _GC_H +#include "config.h" +#include "vm/types.h" + +#include "threads/thread.h" + +#include "toolbox/list.h" +#include "vm/jit/replace.h" + + /* Configuration Switches *****************************************************/ -/*#define GCCONF_FINALIZER*/ +#define GCCONF_FINALIZER +/*#define GCCONF_HDRFLAG_REFERENCING*/ /* Debugging ******************************************************************/ @@ -85,8 +87,12 @@ # error "GC does only work with replacement enabled!" #endif -#if 1 && !defined(__I386__) -# error "GC was only ported to i386 so far!" +#if 1 && !defined(ENABLE_HANDLES) +# error "GC does only work with handles (indirection cells) enabled!" +#endif + +#if 1 && !defined(__ALPHA__) && !defined(__ARM__) && !defined(__I386__) && !defined(__POWERPC__) && !defined(__X86_64__) && !defined(__M68K__) && !defined(__SPARC_64__) +# error "GC was only ported to some architectures so far!" #endif @@ -99,11 +105,66 @@ #define POINTS_INTO(ptr, ptr_start, ptr_end) \ ((void *) (ptr) >= (ptr_start) && (void *) (ptr) < (ptr_end)) +#define GC_ALIGN_SIZE SIZEOF_VOID_P +#define GC_ALIGN(val,size) ((((val) + (size) - 1) / (size)) * (size)) + /* Global Variables ***********************************************************/ +extern bool gc_pending; extern bool gc_notify_finalizer; +extern list_t *gc_reflist_strong; +extern list_t *gc_reflist_weak; + + +/* Structures *****************************************************************/ + +typedef struct list_gcref_entry_t list_gcref_entry_t; + +struct list_gcref_entry_t { + listnode_t linkage; + java_object_t **ref; +#if !defined(NDEBUG) + s4 reftype; +#endif +}; + + +/* Global GC mutext stuff *****************************************************/ + +#if defined(ENABLE_THREADS) +# define GC_MUTEX_LOCK threads_mutex_gc_lock() +# define GC_MUTEX_UNLOCK threads_mutex_gc_unlock() +#else +# define GC_MUTEX_LOCK +# define GC_MUTEX_UNLOCK +#endif + + +/* No-Thread specific stuff ***************************************************/ + +#if defined(ENABLE_THREADS) +# define GC_EXECUTIONSTATE (thread->es) +# define GC_SOURCESTATE (thread->ss) +#else +# define GC_EXECUTIONSTATE (_no_threads_executionstate) +# define GC_SOURCESTATE (_no_threads_sourcestate) + +extern executionstate_t *_no_threads_executionstate; +extern sourcestate_t *_no_threads_sourcestate; + +#endif + + +/* Prototypes *****************************************************************/ + +void gc_collect(s4 level); + +#if defined(ENABLE_THREADS) +bool gc_suspend(threadobject *thread, u1 *pc, u1 *sp); +#endif + /* Statistics *****************************************************************/ @@ -114,12 +175,21 @@ extern bool gc_notify_finalizer; #define GCSTAT_DEC(cnt) { (cnt)--; GC_ASSERT((cnt) >= 0); } #define GCSTAT_COUNT_MAX(cnt,max) { (cnt)++; if ((cnt) > (max)) (max) = (cnt); } +extern int gcstat_collections; +extern int gcstat_collections_forced; extern int gcstat_mark_depth; extern int gcstat_mark_depth_max; extern int gcstat_mark_count; void gcstat_println(); +#else /* defined(ENABLE_STATISTICS) */ + +#define GCSTAT_INIT(cnt) +#define GCSTAT_COUNT(cnt) +#define GCSTAT_DEC(cnt) +#define GCSTAT_COUNT_MAX(cnt,max) + #endif /* defined(ENABLE_STATISTICS) */