boehm-gc: revert all CACAO-specific modifications; this is now an exact copy of the...
[cacao.git] / src / vm / stackmap.h
1 /* src/vm/stackmap.h - class attribute StackMapTable
2
3    Copyright (C) 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 _STACKMAP_H
27 #define _STACKMAP_H
28
29 /* forward typedefs ***********************************************************/
30
31 typedef struct stack_map_t                       stack_map_t;
32 typedef union  stack_map_frame_t                 stack_map_frame_t;
33 typedef struct same_locals_1_stack_item_frame_t  same_locals_1_stack_item_frame_t;
34 typedef struct same_locals_1_stack_item_frame_extended_t same_locals_1_stack_item_frame_extended_t;
35 typedef struct chop_frame_t                      chop_frame_t;
36 typedef struct same_frame_extended_t             same_frame_extended_t;
37 typedef struct append_frame_t                    append_frame_t;
38 typedef struct full_frame_t                      full_frame_t;
39
40 typedef union  verification_type_info_t          verification_type_info_t;
41 typedef struct Top_variable_info_t                   Top_variable_info_t;
42 typedef struct Integer_variable_info_t           Integer_variable_info_t;
43 typedef struct Float_variable_info_t             Float_variable_info_t;
44 typedef struct Long_variable_info_t              Long_variable_info_t;
45 typedef struct Double_variable_info_t            Double_variable_info_t;
46 typedef struct Null_variable_info_t              Null_variable_info_t;
47 typedef struct UninitializedThis_variable_info_t UninitializedThis_variable_info_t;
48 typedef struct Object_variable_info_t            Object_variable_info_t;
49 typedef struct Uninitialized_variable_info_t     Uninitialized_variable_info_t;
50
51
52 #include "config.h"
53 #include "vm/types.h"
54
55 #include "vm/global.h"
56 #include "vm/loader.hpp"
57 #include "vm/method.hpp"
58
59
60 /* verification_type_info *****************************************************/
61
62 #define ITEM_Top                  0
63 #define ITEM_Integer              1
64 #define ITEM_Float                2
65 #define ITEM_Double               3
66 #define ITEM_Long                 4
67 #define ITEM_Null                 5
68 #define ITEM_UninitializedThis    6
69 #define ITEM_Object               7
70 #define ITEM_Uninitialized        8
71
72 struct Top_variable_info_t {
73         u1 tag;
74 };
75
76 struct Integer_variable_info_t {
77         u1 tag;
78 };
79
80 struct Float_variable_info_t {
81         u1 tag;
82 };
83
84 struct Long_variable_info_t {
85         u1 tag;
86 };
87
88 struct Double_variable_info_t {
89         u1 tag;
90 };
91
92 struct Null_variable_info_t {
93         u1 tag;
94 };
95
96 struct UninitializedThis_variable_info_t {
97         u1 tag;
98 };
99
100 struct Object_variable_info_t {
101         u1 tag;
102         u2 cpool_index;
103 };
104
105 struct Uninitialized_variable_info_t {
106         u1 tag;
107         u2 offset;
108 };
109
110 union verification_type_info_t {
111         u1 tag;
112         Top_variable_info_t                   Top_variable_info;
113         Integer_variable_info_t           Integer_variable_info;
114         Float_variable_info_t             Float_variable_info;
115         Long_variable_info_t              Long_variable_info;
116         Double_variable_info_t            Double_variable_info;
117         Null_variable_info_t              Null_variable_info;
118         UninitializedThis_variable_info_t UninitializedThis_variable_info;
119         Object_variable_info_t            Object_variable_info;
120         Uninitialized_variable_info_t     Uninitialized_variable_info;
121 };
122
123
124 /* stack_map_t ****************************************************************/
125
126 struct stack_map_t {
127         u2                 attribute_name_index;
128         u4                 attribute_length;
129         u2                 number_of_entries;
130         stack_map_frame_t *entries;
131 };
132
133
134 /* same_locals_1_stack_item_frame_t *******************************************/
135
136 struct same_locals_1_stack_item_frame_t {
137         u1                       frame_type;
138         verification_type_info_t stack[1];
139 };
140
141
142 /* same_locals_1_stack_item_frame_extended_t **********************************/
143
144 struct same_locals_1_stack_item_frame_extended_t {
145         u1                       frame_type;
146         u2                       offset_delta;
147         verification_type_info_t stack[1];
148 };
149
150
151 /* chop_frame_t ***************************************************************/
152
153 struct chop_frame_t {
154         u1 frame_type;
155         u2 offset_delta;
156 };
157
158
159 /* same_frame_extended_t ******************************************************/
160
161 struct same_frame_extended_t {
162         u1 frame_type;
163         u2 offset_delta;
164 };
165
166
167 /* append_frame_t *************************************************************/
168
169 struct append_frame_t {
170         u1                        frame_type;
171         u2                        offset_delta;
172         verification_type_info_t *locals;
173 };
174
175
176 /* full_frame_t ***************************************************************/
177
178 struct full_frame_t {
179         u1                        frame_type;
180         u2                        offset_delta;
181         u2                        number_of_locals;
182         verification_type_info_t *locals;
183         u2                        number_of_stack_items;
184         verification_type_info_t *stack;
185 };
186
187
188 /* stack_map_frame_t **********************************************************/
189
190 #define FRAME_TYPE_SAME                                 63   /* 0-63          */
191 #define FRAME_TYPE_SAME_LOCALS_1_STACK_ITEM             127  /* 0-127         */
192 #define FRAME_TYPE_RESERVED                             246  /* 128-246       */
193 #define FRAME_TYPE_SAME_LOCALS_1_STACK_ITEM_EXTENDED    247  /* 247           */
194 #define FRAME_TYPE_CHOP                                 250  /* 248-250       */
195 #define FRAME_TYPE_SAME_FRAME_EXTENDED                  251  /* 251           */
196 #define FRAME_TYPE_APPEND                               254  /* 252-254       */
197 #define FRAME_TYPE_FULL_FRAME                           255  /* 255           */
198
199 union stack_map_frame_t {
200         u1                                        frame_type;
201         same_locals_1_stack_item_frame_t          same_locals_1_stack_item_frame;
202         same_locals_1_stack_item_frame_extended_t same_locals_1_stack_item_frame_extended;
203         chop_frame_t                              chop_frame;
204         same_frame_extended_t                     same_frame_extended;
205         append_frame_t                            append_frame;
206         full_frame_t                              full_frame;
207 };
208
209 #if defined(__cplusplus)
210 extern "C" {
211 #endif
212
213 /* function prototypes ********************************************************/
214
215 bool stackmap_load_attribute_stackmaptable(classbuffer *cb, methodinfo *m);
216
217 #if defined(__cplusplus)
218 }
219 #endif
220
221 #endif /* _STACKMAP_H */
222
223
224 /*
225  * These are local overrides for various environment variables in Emacs.
226  * Please do not remove this and leave it at the end of the file, where
227  * Emacs will automagically detect them.
228  * ---------------------------------------------------------------------
229  * Local variables:
230  * mode: c
231  * indent-tabs-mode: t
232  * c-basic-offset: 4
233  * tab-width: 4
234  * End:
235  * vim:noexpandtab:sw=4:ts=4:
236  */