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