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 4699 2006-03-28 14:52:32Z twisti $
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; \
57 #define LOADCONST_L(v) \
58 iptr->opc = ICMD_LCONST; \
60 iptr->line = currentline; \
64 #define LOADCONST_F(v) \
65 iptr->opc = ICMD_FCONST; \
67 iptr->line = currentline; \
71 #define LOADCONST_D(v) \
72 iptr->opc = ICMD_DCONST; \
74 iptr->line = currentline; \
78 #define LOADCONST_A(v) \
79 iptr->opc = ICMD_ACONST; \
81 iptr->line = currentline; \
85 #define LOADCONST_A_CLASS(v,t) \
86 iptr->opc = ICMD_ACONST; \
89 iptr->line = currentline; \
93 /* ACONST instructions generated as arguments for builtin functions
94 * have op1 set to non-zero. This is used for stack overflow checking
96 #define LOADCONST_A_BUILTIN(v,t) \
97 iptr->opc = ICMD_ACONST; \
100 iptr->target = (t); \
101 iptr->line = currentline; \
107 iptr->line = currentline; \
114 iptr->line = currentline; \
118 #define OP2I(o,o1,v) \
122 iptr->line = currentline; \
126 #define OP2A_NOINC(o,o1,v,l) \
133 #define OP2A(o,o1,v,l) \
134 OP2A_NOINC(o,o1,v,l); \
137 #define OP2AT(o,o1,v,t,l) \
138 OP2A_NOINC(o,o1,v,l); \
139 iptr->target = (t); \
142 #define BUILTIN(v,o1,t,l) \
143 m->isleafmethod = false; \
144 iptr->opc = ICMD_BUILTIN; \
147 iptr->target = (t); \
153 /* We have to check local variables indices here because they are
154 * used in stack.c to index the locals array. */
156 #define INDEX_ONEWORD(num) \
158 if (((num) < 0) || ((num) >= m->maxlocals)) \
159 goto throw_illegal_local_variable_number; \
162 #define INDEX_TWOWORD(num) \
164 if (((num) < 0) || (((num) + 1) >= m->maxlocals)) \
165 goto throw_illegal_local_variable_number; \
168 #define OP1LOAD(o,o1) \
170 if (((o) == ICMD_LLOAD) || ((o) == ICMD_DLOAD)) \
177 #define OP1STORE(o,o1) \
179 if (((o) == ICMD_LSTORE) || ((o) == ICMD_DSTORE)) \
186 /* block generating and checking macros */
188 #define block_insert(i) \
190 if (!(m->basicblockindex[(i)] & 1)) { \
192 m->basicblockindex[(i)] |= 1; \
197 #if defined(ENABLE_VERIFIER)
199 #define CHECK_BYTECODE_INDEX(i) \
201 if (((i) < 0) || ((i) >= m->jcodelength)) \
202 goto throw_invalid_bytecode_index; \
205 /* CHECK_BYTECODE_INDEX_EXCLUSIVE is used for the exclusive ends */
206 /* of exception handler ranges */
207 #define CHECK_BYTECODE_INDEX_EXCLUSIVE(i) \
209 if ((i) < 0 || (i) > m->jcodelength) \
210 goto throw_invalid_bytecode_index; \
213 #else /* !ENABLE_VERIFIER */
215 #define CHECK_BYTECODE_INDEX(i)
216 #define CHECK_BYTECODE_INDEX_EXCLUSIVE(i)
220 /* macros for byte code fetching ***********************************************
222 fetch a byte code of given size from position p in code array jcode
224 *******************************************************************************/
226 #define code_get_u1(p,m) m->jcode[p]
227 #define code_get_s1(p,m) ((s1)m->jcode[p])
228 #define code_get_u2(p,m) ((((u2)m->jcode[p]) << 8) + m->jcode[p + 1])
229 #define code_get_s2(p,m) ((s2)((((u2)m->jcode[p]) << 8) + m->jcode[p + 1]))
230 #define code_get_u4(p,m) ((((u4)m->jcode[p]) << 24) + (((u4)m->jcode[p + 1]) << 16) \
231 +(((u4)m->jcode[p + 2]) << 8) + m->jcode[p + 3])
232 #define code_get_s4(p,m) ((s4)((((u4)m->jcode[p]) << 24) + (((u4)m->jcode[p + 1]) << 16) \
233 +(((u4)m->jcode[p + 2]) << 8) + m->jcode[p + 3]))
236 /* function prototypes ********************************************************/
238 bool parse(jitdata *jd);
240 #endif /* _PARSE_H */
244 * These are local overrides for various environment variables in Emacs.
245 * Please do not remove this and leave it at the end of the file, where
246 * Emacs will automagically detect them.
247 * ---------------------------------------------------------------------
250 * indent-tabs-mode: t
254 * vim:noexpandtab:sw=4:ts=4: