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
31 $Id: parse.h 4742 2006-04-05 20:31:38Z edwin $
42 #include "vm/global.h"
43 #include "vm/jit/codegen-common.h"
46 /* intermediate code generating macros ****************************************/
48 #define PINC iptr++;ipc++
50 #define LOADCONST_I(v) \
51 iptr->opc = ICMD_ICONST; \
53 iptr->line = currentline; \
56 #define LOADCONST_L(v) \
57 iptr->opc = ICMD_LCONST; \
59 iptr->line = currentline; \
62 #define LOADCONST_F(v) \
63 iptr->opc = ICMD_FCONST; \
65 iptr->line = currentline; \
68 #define LOADCONST_D(v) \
69 iptr->opc = ICMD_DCONST; \
71 iptr->line = currentline; \
74 #define LOADCONST_A(v) \
75 iptr->opc = ICMD_ACONST; \
77 iptr->line = currentline; \
80 #define LOADCONST_A_CLASS(v,t) \
81 iptr->opc = ICMD_ACONST; \
84 iptr->line = currentline; \
87 /* ACONST instructions generated as arguments for builtin functions
88 * have op1 set to non-zero. This is used for stack overflow checking
90 #define LOADCONST_A_BUILTIN(v,t) \
91 iptr->opc = ICMD_ACONST; \
95 iptr->line = currentline; \
100 iptr->line = currentline; \
106 iptr->line = currentline; \
109 #define OP2I(o,o1,v) \
113 iptr->line = currentline; \
116 #define OP2A_NOINC(o,o1,v,l) \
122 #define OP2A(o,o1,v,l) \
123 OP2A_NOINC(o,o1,v,l); \
126 #define OP2AT(o,o1,v,t,l) \
127 OP2A_NOINC(o,o1,v,l); \
128 iptr->target = (t); \
131 #define BUILTIN(v,o1,t,l) \
132 m->isleafmethod = false; \
133 iptr->opc = ICMD_BUILTIN; \
136 iptr->target = (t); \
141 /* We have to check local variables indices here because they are
142 * used in stack.c to index the locals array. */
144 #if defined(ENABLE_VERIFIER)
146 #define INDEX_ONEWORD(num) \
148 if (((num) < 0) || ((num) >= m->maxlocals)) \
149 goto throw_illegal_local_variable_number; \
152 #define INDEX_TWOWORD(num) \
154 if (((num) < 0) || (((num) + 1) >= m->maxlocals)) \
155 goto throw_illegal_local_variable_number; \
158 #else /* !define(ENABLE_VERIFIER) */
160 #define INDEX_ONEWORD(num)
161 #define INDEX_TWOWORD(num)
163 #endif /* define(ENABLE_VERIFIER) */
165 #define OP1LOAD_ONEWORD(o,o1) \
171 #define OP1LOAD_TWOWORD(o,o1) \
177 #define OP1STORE_ONEWORD(o,o1) \
183 #define OP1STORE_TWOWORD(o,o1) \
189 /* block generating and checking macros */
191 #define block_insert(i) \
193 if (!(m->basicblockindex[(i)] & 1)) { \
195 m->basicblockindex[(i)] |= 1; \
200 #if defined(ENABLE_VERIFIER)
202 #define CHECK_BYTECODE_INDEX(i) \
204 if (((i) < 0) || ((i) >= m->jcodelength)) \
205 goto throw_invalid_bytecode_index; \
208 /* CHECK_BYTECODE_INDEX_EXCLUSIVE is used for the exclusive ends */
209 /* of exception handler ranges */
210 #define CHECK_BYTECODE_INDEX_EXCLUSIVE(i) \
212 if ((i) < 0 || (i) > m->jcodelength) \
213 goto throw_invalid_bytecode_index; \
216 #else /* !ENABLE_VERIFIER */
218 #define CHECK_BYTECODE_INDEX(i)
219 #define CHECK_BYTECODE_INDEX_EXCLUSIVE(i)
223 /* macros for byte code fetching ***********************************************
225 fetch a byte code of given size from position p in code array jcode
227 *******************************************************************************/
229 #define code_get_u1(p,m) m->jcode[p]
230 #define code_get_s1(p,m) ((s1)m->jcode[p])
231 #define code_get_u2(p,m) ((((u2)m->jcode[p]) << 8) + m->jcode[p + 1])
232 #define code_get_s2(p,m) ((s2)((((u2)m->jcode[p]) << 8) + m->jcode[p + 1]))
233 #define code_get_u4(p,m) ((((u4)m->jcode[p]) << 24) + (((u4)m->jcode[p + 1]) << 16) \
234 +(((u4)m->jcode[p + 2]) << 8) + m->jcode[p + 3])
235 #define code_get_s4(p,m) ((s4)((((u4)m->jcode[p]) << 24) + (((u4)m->jcode[p + 1]) << 16) \
236 +(((u4)m->jcode[p + 2]) << 8) + m->jcode[p + 3]))
239 /* function prototypes ********************************************************/
241 bool parse(jitdata *jd);
243 #endif /* _PARSE_H */
247 * These are local overrides for various environment variables in Emacs.
248 * Please do not remove this and leave it at the end of the file, where
249 * Emacs will automagically detect them.
250 * ---------------------------------------------------------------------
253 * indent-tabs-mode: t
257 * vim:noexpandtab:sw=4:ts=4: