* src/mm/cacao-gc/rootset.h (rootset_entry_t) Added. Rootsets can be resized.
[cacao.git] / src / mm / cacao-gc / rootset.h
1 /* mm/cacao-gc/rootset.h - GC header for root set management
2
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
7
8    This file is part of CACAO.
9
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.
14
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.
19
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
23    02110-1301, USA.
24
25    $Id$
26
27 */
28
29
30 #ifndef _ROOTSET_H
31 #define _ROOTSET_H
32
33 typedef struct rootset_t rootset_t;
34
35 #include "config.h"
36 #include "vm/types.h"
37
38 #if defined(ENABLE_THREADS)
39 # include "threads/native/threads.h"
40 #else
41 # include "threads/none/threads.h"
42 #endif
43
44 #include "vm/jit/replace.h"
45 #include "vmcore/method.h"
46
47
48 /* Structures *****************************************************************/
49
50 #define ROOTSET_DUMMY_THREAD ((threadobject *) (ptrint) -1)
51
52 #define ROOTSET_INITIAL_CAPACITY 16
53
54 #define REFTYPE_THREADOBJECT 1
55 #define REFTYPE_REGISTERED   1
56 #define REFTYPE_CLASSLOADER  2
57 #define REFTYPE_GLOBALREF    3
58 #define REFTYPE_FINALIZER    4
59 #define REFTYPE_LOCALREF     5
60 #define REFTYPE_STACK        6
61 #define REFTYPE_CLASSREF     7
62
63 /* rootset is passed as array of pointers, which point to the location of
64    the reference */
65
66 typedef struct rootset_entry_t {
67         java_objectheader **ref;            /* a pointer to the actual reference */
68         bool                marks;          /* indicates if a reference marks */
69 #if !defined(NDEBUG)
70         s4                  type;
71 #endif
72 } rootset_entry_t;
73
74
75 struct rootset_t {
76         rootset_t          *next;           /* link to the next chain element */
77         threadobject       *thread;         /* thread this rootset belongs to */
78         sourcestate_t      *ss;             /* sourcestate of the thread */
79         executionstate_t   *es;             /* executionstate of the thread */
80         s4                  capacity;       /* the current capacity of this rs */
81         s4                  refcount;       /* number of references */
82         rootset_entry_t     refs[ROOTSET_INITIAL_CAPACITY]; /* list of references */
83 };
84
85
86 /* Prototypes *****************************************************************/
87
88 /*
89 rootset_t *rootset_create(void);
90 void rootset_from_globals(rootset_t *rs);
91 void rootset_from_thread(threadobject *thread, rootset_t *rs);
92 */
93 rootset_t *rootset_readout();
94 void rootset_writeback(rootset_t *rs);
95
96 #if !defined(NDEBUG)
97 void rootset_print(rootset_t *rs);
98 #endif
99
100
101 #endif /* _ROOTSET_H */
102
103 /*
104  * These are local overrides for various environment variables in Emacs.
105  * Please do not remove this and leave it at the end of the file, where
106  * Emacs will automagically detect them.
107  * ---------------------------------------------------------------------
108  * Local variables:
109  * mode: c
110  * indent-tabs-mode: t
111  * c-basic-offset: 4
112  * tab-width: 4
113  * End:
114  * vim:noexpandtab:sw=4:ts=4:
115  */