1 /* src/mm/cacao-gc/gc.h - main garbage collector header
3 Copyright (C) 2006 R. Grafl, A. Krall, C. Kruegel,
4 C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring,
5 E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich,
6 J. Wenninger, Institut f. Computersprachen - TU Wien
8 This file is part of CACAO.
10 This program is free software; you can redistribute it and/or
11 modify it under the terms of the GNU General Public License as
12 published by the Free Software Foundation; either version 2, or (at
13 your option) any later version.
15 This program is distributed in the hope that it will be useful, but
16 WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 General Public License for more details.
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
25 Contact: cacao@cacaojvm.org
27 Authors: Michael Starzinger
35 # error Why is the BoehmGC header included???
46 #if defined(ENABLE_THREADS)
47 # include "threads/native/threads.h"
50 #include "vm/jit/replace.h"
53 /* Configuration Switches *****************************************************/
55 #define GCCONF_FINALIZER
56 /*#define GCCONF_HDRFLAG_REFERENCING*/
59 /* Debugging ******************************************************************/
62 /*#define GC_DEBUGGING2*/
64 #if !defined(NDEBUG) && defined(GC_DEBUGGING)
66 # include "vmcore/options.h"
67 # define GC_LOG(code) if (opt_verbosegc) { code; }
68 # define GC_ASSERT(assertion) assert(assertion)
71 # define GC_ASSERT(assertion)
74 #if !defined(NDEBUG) && defined(GC_DEBUGGING2)
75 # define GC_LOG2(code) GC_LOG(code)
77 # define GC_LOG2(code)
81 /* Development Break **********************************************************/
83 #if 0 && defined(ENABLE_THREADS)
84 # error "GC does not work with threads enabled!"
87 #if 1 && defined(ENABLE_INTRP)
88 # error "GC does not work with interpreter enabled!"
91 #if 1 && defined(ENABLE_JVMTI)
92 # error "GC does not work with JVMTI enabled!"
95 #if 1 && !defined(ENABLE_REPLACEMENT)
96 # error "GC does only work with replacement enabled!"
99 #if 1 && !defined(__I386__)
100 # error "GC was only ported to i386 so far!"
104 /* Helper Macros **************************************************************/
106 #define GC_SET_FLAGS(obj, flags) ((obj)->hdrflags |= (flags))
107 #define GC_CLEAR_FLAGS(obj, flags) ((obj)->hdrflags &= ~(flags))
108 #define GC_TEST_FLAGS(obj, flags) ((obj)->hdrflags & (flags))
110 #define POINTS_INTO(ptr, ptr_start, ptr_end) \
111 ((void *) (ptr) >= (ptr_start) && (void *) (ptr) < (ptr_end))
114 /* Global Variables ***********************************************************/
116 extern bool gc_pending;
117 extern bool gc_notify_finalizer;
120 /* No-Thread specific stuff ***************************************************/
122 #if defined(ENABLE_THREADS)
123 # define GC_EXECUTIONSTATE (thread->es)
124 # define GC_SOURCESTATE (thread->ss)
126 # define GC_EXECUTIONSTATE (_no_threads_executionstate)
127 # define GC_SOURCESTATE (_no_threads_sourcestate)
129 extern executionstate_t *_no_threads_executionstate;
130 extern sourcestate_t *_no_threads_sourcestate;
135 /* Prototypes *****************************************************************/
137 #if defined(ENABLE_THREADS)
138 bool gc_suspend(threadobject *thread, u1 *pc, u1 *sp);
142 /* Statistics *****************************************************************/
144 #if defined(ENABLE_STATISTICS)
146 #define GCSTAT_INIT(cnt) { (cnt) = 0; }
147 #define GCSTAT_COUNT(cnt) { (cnt)++; }
148 #define GCSTAT_DEC(cnt) { (cnt)--; GC_ASSERT((cnt) >= 0); }
149 #define GCSTAT_COUNT_MAX(cnt,max) { (cnt)++; if ((cnt) > (max)) (max) = (cnt); }
151 extern int gcstat_mark_depth;
152 extern int gcstat_mark_depth_max;
153 extern int gcstat_mark_count;
155 void gcstat_println();
157 #endif /* defined(ENABLE_STATISTICS) */
163 * These are local overrides for various environment variables in Emacs.
164 * Please do not remove this and leave it at the end of the file, where
165 * Emacs will automagically detect them.
166 * ---------------------------------------------------------------------
169 * indent-tabs-mode: t
173 * vim:noexpandtab:sw=4:ts=4: