1 /* src/vm/jit/parse.h - parser header
3 Copyright (C) 1996-2005, 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
8 This file is part of CACAO.
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.
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.
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
25 Contact: cacao@cacaojvm.org
27 Author: Christian Thalinger
29 Changes: Edwin Steiner
31 $Id: parse.h 5370 2006-09-06 13:46:37Z christian $
42 #include "vm/global.h"
43 #include "vm/jit/codegen-common.h"
46 /* macros for verifier checks during parsing **********************************/
48 #if defined(ENABLE_VERIFIER)
50 /* We have to check local variables indices here because they are */
51 /* used in stack.c to index the locals array. */
53 #define INDEX_ONEWORD(num) \
55 if (((num) < 0) || ((num) >= m->maxlocals)) \
56 goto throw_illegal_local_variable_number; \
59 #define INDEX_TWOWORD(num) \
61 if (((num) < 0) || (((num) + 1) >= m->maxlocals)) \
62 goto throw_illegal_local_variable_number; \
65 /* CHECK_BYTECODE_INDEX(i) checks whether i is a valid bytecode index. */
66 /* The end of the bytecode (i == m->jcodelength) is considered valid. */
68 #define CHECK_BYTECODE_INDEX(i) \
70 if (((i) < 0) || ((i) >= m->jcodelength)) \
71 goto throw_invalid_bytecode_index; \
74 /* CHECK_BYTECODE_INDEX_EXCLUSIVE is used for the exclusive ends */
75 /* of exception handler ranges. */
76 #define CHECK_BYTECODE_INDEX_EXCLUSIVE(i) \
78 if ((i) < 0 || (i) > m->jcodelength) \
79 goto throw_invalid_bytecode_index; \
82 #else /* !define(ENABLE_VERIFIER) */
84 #define INDEX_ONEWORD(num)
85 #define INDEX_TWOWORD(num)
86 #define CHECK_BYTECODE_INDEX(i)
87 #define CHECK_BYTECODE_INDEX_EXCLUSIVE(i)
89 #endif /* define(ENABLE_VERIFIER) */
92 /* basic block generating macro ***********************************************/
94 #define MARK_BASICBLOCK(i) \
96 if (!(jd->new_basicblockindex[(i)] & 1)) { \
98 jd->new_basicblockindex[(i)] |= 1; \
103 /* intermediate code generating macros ****************************************/
105 /* These macros ALWAYS set the following fields of *iptr to valid values: */
110 /* These macros do NOT touch the following fields of *iptr, unless a value is */
111 /* given for them: */
116 /* The _PREPARE macros omit the PINC, so you can set additional fields */
118 /* CAUTION: Some of the _PREPARE macros don't set iptr->flags! */
123 /* CAUTION: You must set iptr->flags yourself when using this! */
124 #define OP_PREPARE(o) \
126 iptr->line = currentline;
128 #define OP_PREPARE_ZEROFLAGS(o) \
130 iptr->line = currentline; \
131 iptr->flags.bits = 0;
134 OP_PREPARE_ZEROFLAGS(o); \
137 #define OP_LOADCONST_I(v) \
138 OP_PREPARE_ZEROFLAGS(ICMD_ICONST); \
139 iptr->sx.val.i = (v); \
142 #define OP_LOADCONST_L(v) \
143 OP_PREPARE_ZEROFLAGS(ICMD_LCONST); \
144 iptr->sx.val.l = (v); \
147 #define OP_LOADCONST_F(v) \
148 OP_PREPARE_ZEROFLAGS(ICMD_FCONST); \
149 iptr->sx.val.f = (v); \
152 #define OP_LOADCONST_D(v) \
153 OP_PREPARE_ZEROFLAGS(ICMD_DCONST); \
154 iptr->sx.val.d = (v); \
157 #define OP_LOADCONST_NULL() \
158 OP_PREPARE_ZEROFLAGS(ICMD_ACONST); \
159 iptr->sx.val.anyptr = NULL; \
162 #define OP_LOADCONST_STRING(v) \
163 OP_PREPARE_ZEROFLAGS(ICMD_ACONST); \
164 iptr->sx.val.stringconst = (v); \
167 #define OP_LOADCONST_CLASSINFO_OR_CLASSREF(c, cr, extraflags) \
168 OP_PREPARE(ICMD_ACONST); \
170 iptr->sx.val.c.cls = (c); \
171 iptr->flags.bits = INS_FLAG_CLASS | (extraflags); \
174 iptr->sx.val.c.ref = (cr); \
175 iptr->flags.bits = INS_FLAG_CLASS | INS_FLAG_UNRESOLVED \
180 #define OP_S3_CLASSINFO_OR_CLASSREF(o, c, cr, extraflags) \
183 iptr->sx.s23.s3.c.cls= (c); \
184 iptr->flags.bits = (extraflags); \
187 iptr->sx.s23.s3.c.ref= (cr); \
188 iptr->flags.bits = INS_FLAG_UNRESOLVED | (extraflags); \
192 #define OP_INSINDEX(o, iindex) \
193 OP_PREPARE_ZEROFLAGS(o); \
194 iptr->dst.insindex = (iindex); \
198 # define OP_LOCALINDEX(o,index) \
199 OP_PREPARE_ZEROFLAGS(o); \
200 iptr->s1.varindex = (index); \
203 # define OP_LOCALINDEX_I(o,index,v) \
204 OP_PREPARE_ZEROFLAGS(o); \
205 iptr->s1.varindex = (index); \
206 iptr->sx.val.i = (v); \
209 # define LOCALTYPE_USED(index,type) \
211 local_map[index * 5 +type] = 1; \
214 # define OP_LOCALINDEX(o,index) \
215 OP_PREPARE_ZEROFLAGS(o); \
216 iptr->s1.localindex = (index); \
219 # define OP_LOCALINDEX_I(o,index,v) \
220 OP_PREPARE_ZEROFLAGS(o); \
221 iptr->s1.localindex = (index); \
222 iptr->sx.val.i = (v); \
225 # define LOCALTYPE_USED(index,type)
226 #endif /* defined(NEW_VAR) */
228 #define OP_LOAD_ONEWORD(o,index,type) \
230 INDEX_ONEWORD(index); \
231 OP_LOCALINDEX(o,index); \
232 LOCALTYPE_USED(index,type); \
235 #define OP_LOAD_TWOWORD(o,index,type) \
237 INDEX_TWOWORD(index); \
238 OP_LOCALINDEX(o,index); \
239 LOCALTYPE_USED(index,type); \
243 # define OP_STORE_ONEWORD(o,index,type) \
245 INDEX_ONEWORD(index); \
246 OP_PREPARE_ZEROFLAGS(o); \
247 iptr->dst.varindex = (index); \
248 LOCALTYPE_USED(index,type); \
252 # define OP_STORE_TWOWORD(o,index,type) \
254 INDEX_TWOWORD(index); \
255 OP_PREPARE_ZEROFLAGS(o); \
256 iptr->dst.varindex = (index); \
257 LOCALTYPE_USED(index,type); \
261 # define OP_STORE_ONEWORD(o,index,type) \
263 INDEX_ONEWORD(index); \
264 OP_PREPARE_ZEROFLAGS(o); \
265 iptr->dst.localindex = (index); \
266 LOCALTYPE_USED(index,type); \
270 # define OP_STORE_TWOWORD(o,index,type) \
272 INDEX_TWOWORD(index); \
273 OP_PREPARE_ZEROFLAGS(o); \
274 iptr->dst.localindex = (index); \
275 LOCALTYPE_USED(index,type); \
278 #endif /* defined(NEW_VAR) */
280 #define OP_BUILTIN_CHECK_EXCEPTION(bte) \
281 jd->isleafmethod = false; \
282 OP_PREPARE_ZEROFLAGS(ICMD_BUILTIN); \
283 iptr->sx.s23.s3.bte = (bte); \
286 #define OP_BUILTIN_NO_EXCEPTION(bte) \
287 jd->isleafmethod = false; \
288 OP_PREPARE(ICMD_BUILTIN); \
289 iptr->sx.s23.s3.bte = (bte); \
290 iptr->flags.bits = INS_FLAG_NOCHECK; \
293 #define OP_BUILTIN_ARITHMETIC(opcode, bte) \
294 jd->isleafmethod = false; \
295 OP_PREPARE_ZEROFLAGS(opcode); \
296 iptr->sx.s23.s3.bte = (bte); \
299 /* CAUTION: You must set iptr->flags yourself when using this! */
300 #define OP_FMIREF_PREPARE(o, fmiref) \
302 iptr->sx.s23.s3.fmiref = (fmiref);
305 /* function prototypes ********************************************************/
307 bool new_parse(jitdata *jd);
309 #endif /* _PARSE_H */
313 * These are local overrides for various environment variables in Emacs.
314 * Please do not remove this and leave it at the end of the file, where
315 * Emacs will automagically detect them.
316 * ---------------------------------------------------------------------
319 * indent-tabs-mode: t
323 * vim:noexpandtab:sw=4:ts=4: