* src/vm/jit/trace.cpp: Method tracer can now trace builtin functions as well.
[cacao.git] / src / mm / cacao-gc / heap.h
1 /* mm/cacao-gc/heap.h - GC header for heap 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 */
26
27
28 #ifndef _HEAP_H
29 #define _HEAP_H
30
31 #include "vm/types.h"
32
33 #include "gc.h"
34 #include "region.h"
35 #include "vm/array.hpp" /* needed for ARRAYTYPE_OBJECT */
36
37
38 #define GC_SIZE_DUMMY 0xff
39
40 #if SIZEOF_VOID_P == 8
41 # define GC_GET_SIZE(obj)       ((u4) (((obj)->hdrflags >> 56) & 0xff))
42 # define GC_SET_SIZE(obj, size) ((obj)->hdrflags |= ((u8) ((size) & 0xff)) << 56)
43 #else
44 # define GC_GET_SIZE(obj)       ((u4) (((obj)->hdrflags >> 24) & 0xff))
45 # define GC_SET_SIZE(obj, size) ((obj)->hdrflags |= ((u4) ((size) & 0xff)) << 24)
46 #endif
47
48
49 extern s4 heap_current_size;
50 extern s4 heap_maximal_size;
51 extern regioninfo_t *heap_region_sys;
52 extern regioninfo_t *heap_region_main;
53
54
55 s4 get_object_size(java_object_t *o);
56
57 #if !defined(NDEBUG)
58 void heap_println_usage();
59 void heap_print_object(java_object_t *o);
60 void heap_dump_region(regioninfo_t *region, bool marked_only);
61 #endif
62
63
64 /* walking macros */
65 #define IS_ARRAY(o) ((o)->vftbl->arraydesc != NULL)
66 #define FOREACH_ARRAY_REF(o,ref,refptr,code) \
67         { \
68                 java_objectarray_t *a = (java_objectarray_t *) o; \
69                 arraydescriptor    *desc = o->vftbl->arraydesc; \
70                 int i; \
71                 \
72                 GC_ASSERT(desc); \
73                 \
74                 if (desc->arraytype == ARRAYTYPE_OBJECT) { \
75                         for (i = 0; i < a->header.size; i++) { \
76                                 \
77                                 refptr = &( a->data[i] ); \
78                                 ref = (java_object_t *) (a->data[i]); \
79                                 \
80                                 code; \
81                         } \
82                 } \
83         }
84
85 #define FOREACH_OBJECT_REF(o,ref,refptr,code) \
86         { \
87                 classinfo *c = o->vftbl->class; \
88                 fieldinfo *f; \
89                 int i; \
90                 \
91                 GC_ASSERT(c); \
92                 \
93                 for (; c; c = c->super) { \
94                         for (i = 0; i < c->fieldscount; i++) { \
95                                 f = &(c->fields[i]); \
96                                 \
97                                 if (!IS_ADR_TYPE(f->type) || (f->flags & ACC_STATIC)) \
98                                         continue; \
99                                 \
100                                 refptr = (java_object_t **) ((s1 *) o + f->offset); \
101                                 ref = *( refptr ); \
102                                 \
103                                 code; \
104                         } \
105                 } \
106         }
107
108
109
110 #endif /* _HEAP_H */
111
112 /*
113  * These are local overrides for various environment variables in Emacs.
114  * Please do not remove this and leave it at the end of the file, where
115  * Emacs will automagically detect them.
116  * ---------------------------------------------------------------------
117  * Local variables:
118  * mode: c
119  * indent-tabs-mode: t
120  * c-basic-offset: 4
121  * tab-width: 4
122  * End:
123  * vim:noexpandtab:sw=4:ts=4:
124  */