2142ef8935b0a4ea9f80fc75f0b441b884536ea6
[cacao.git] / src / vm / linker.hpp
1 /* src/vm/linker.h - class linker header
2
3    Copyright (C) 1996-2005, 2006, 2007, 2008
4    CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
5
6    This file is part of CACAO.
7
8    This program is free software; you can redistribute it and/or
9    modify it under the terms of the GNU General Public License as
10    published by the Free Software Foundation; either version 2, or (at
11    your option) any later version.
12
13    This program is distributed in the hope that it will be useful, but
14    WITHOUT ANY WARRANTY; without even the implied warranty of
15    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16    General Public License for more details.
17
18    You should have received a copy of the GNU General Public License
19    along with this program; if not, write to the Free Software
20    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21    02110-1301, USA.
22
23 */
24
25
26 #ifndef _LINKER_H
27 #define _LINKER_H
28
29 /* forward typedefs ***********************************************************/
30
31 typedef struct arraydescriptor arraydescriptor;
32 typedef struct primitivetypeinfo primitivetypeinfo;
33
34
35 #include "config.h"
36 #include "vm/types.h"
37
38 #include "threads/mutex.hpp"
39
40 #include "vm/class.hpp"
41 #include "vm/references.h"
42 #include "vm/vftbl.hpp"
43
44
45 /* arraydescriptor *************************************************************
46
47    For every array class an arraydescriptor is allocated which
48    describes the array class. The arraydescriptor is referenced from
49    the vftbl of the array class.
50
51 *******************************************************************************/
52
53 struct arraydescriptor {
54         vftbl_t *componentvftbl; /* vftbl of the component type, NULL for primit. */
55         vftbl_t *elementvftbl;   /* vftbl of the element type, NULL for primitive */
56         s2       arraytype;      /* ARRAYTYPE_* constant                          */
57         s2       dimension;      /* dimension of the array (always >= 1)          */
58         s4       dataoffset;     /* offset of the array data from object pointer  */
59         s4       componentsize;  /* size of a component in bytes                  */
60         s2       elementtype;    /* ARRAYTYPE_* constant                          */
61 };
62
63
64 /* global variables ***********************************************************/
65
66 /* This lock must be taken while renumbering classes or while atomically      */
67 /* accessing classes.                                                         */
68
69 #if USES_NEW_SUBTYPE
70
71 #define LOCK_CLASSRENUMBER_LOCK   /* nothing */
72 #define UNLOCK_CLASSRENUMBER_LOCK /* nothing */
73
74 #else
75 extern Mutex *linker_classrenumber_lock;
76
77 #define LOCK_CLASSRENUMBER_LOCK   linker_classrenumber_lock->lock()
78 #define UNLOCK_CLASSRENUMBER_LOCK linker_classrenumber_lock->unlock()
79
80 #endif
81
82
83 /* function prototypes ********************************************************/
84
85 #ifdef __cplusplus
86 extern "C" {
87 #endif
88
89 void       linker_preinit(void);
90 void       linker_init(void);
91 classinfo *link_class(classinfo *c);
92
93 #ifdef __cplusplus
94 }
95 #endif
96
97 #endif /* _LINKER_H */
98
99
100 /*
101  * These are local overrides for various environment variables in Emacs.
102  * Please do not remove this and leave it at the end of the file, where
103  * Emacs will automagically detect them.
104  * ---------------------------------------------------------------------
105  * Local variables:
106  * mode: c
107  * indent-tabs-mode: t
108  * c-basic-offset: 4
109  * tab-width: 4
110  * End:
111  */