1 /* src/vm/jit/parse.h - parser header
3 Copyright (C) 1996-2005 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
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., 59 Temple Place - Suite 330, Boston, MA
25 Contact: cacao@complang.tuwien.ac.at
27 Author: Christian Thalinger
31 $Id: parse.h 3499 2005-10-26 16:49:18Z twisti $
42 #include "vm/global.h"
43 #include "vm/jit/codegen.inc.h"
44 #include "vm/jit/inline/inline.h"
47 /* intermediate code generating macros ****************************************/
49 #define PINC iptr++;ipc++
51 #define LOADCONST_I(v) \
52 iptr->opc = ICMD_ICONST; \
55 iptr->line = currentline; \
56 iptr->method = inline_env->method; \
59 #define LOADCONST_L(v) \
60 iptr->opc = ICMD_LCONST; \
63 iptr->line = currentline; \
64 iptr->method = inline_env->method; \
67 #define LOADCONST_F(v) \
68 iptr->opc = ICMD_FCONST; \
71 iptr->line = currentline; \
72 iptr->method = inline_env->method; \
75 #define LOADCONST_D(v) \
76 iptr->opc = ICMD_DCONST; \
79 iptr->line = currentline; \
80 iptr->method = inline_env->method; \
83 #define LOADCONST_A(v) \
84 iptr->opc = ICMD_ACONST; \
87 iptr->line = currentline; \
88 iptr->method = inline_env->method; \
91 /* ACONST instructions generated as arguments for builtin functions
92 * have op1 set to non-zero. This is used for stack overflow checking
94 #define LOADCONST_A_BUILTIN(v) \
95 iptr->opc = ICMD_ACONST; \
98 iptr->line = currentline; \
99 iptr->method = inline_env->method; \
106 iptr->line = currentline; \
107 iptr->method = inline_env->method; \
113 /*iptr->val.l=(0)*/; \
114 iptr->line = currentline; \
115 iptr->method = inline_env->method; \
118 #define OP2I(o,o1,v) \
122 iptr->line = currentline; \
123 iptr->method = inline_env->method; \
126 #define OP2A_NOINC(o,o1,v,l) \
131 iptr->method = inline_env->method
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 inline_env->method->isleafmethod = false; \
144 iptr->opc = ICMD_BUILTIN; \
147 iptr->target = (t); \
149 iptr->method = inline_env->method; \
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) >= inline_env->cumlocals) { \
160 new_verifyerror(inline_env->method, "Illegal local variable number"); \
165 #define INDEX_TWOWORD(num) \
167 if ((num) < 0 || ((num) + 1) >= inline_env->cumlocals) { \
169 new_verifyerror(inline_env->method, "Illegal local variable number"); \
174 #define OP1LOAD(o,o1) \
175 do {if (o == ICMD_LLOAD || o == ICMD_DLOAD) \
181 #define OP1STORE(o,o1) \
182 do {if (o == ICMD_LSTORE || o == ICMD_DSTORE) \
188 /* block generating and checking macros */
190 #define block_insert(i) \
192 if (!(m->basicblockindex[(i)] & 1)) { \
194 m->basicblockindex[(i)] |= 1; \
199 /* FIXME really use cumjcodelength for the bound_checkers ? */
201 #define bound_check(i) \
203 if (i < 0 || i >= inline_env->cumjcodelength) { \
204 /* if (i < 0 || i >= m->jcodelength) { */ \
206 new_verifyerror(inline_env->method, "Illegal target of jump or branch"); \
211 /* bound_check1 is used for the inclusive ends of exception handler ranges */
212 #define bound_check1(i) \
214 if (i < 0 || i > inline_env->cumjcodelength) { \
215 /* if (i < 0 || i > m->jcodelength) { */ \
217 new_verifyerror(inline_env->method, "Illegal target of jump or branch"); \
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 void compiler_addinitclass(classinfo *c);
242 methodinfo *parse(methodinfo *m, codegendata *cd, t_inlining_globals *inline_env);
244 #endif /* _PARSE_H */
248 * These are local overrides for various environment variables in Emacs.
249 * Please do not remove this and leave it at the end of the file, where
250 * Emacs will automagically detect them.
251 * ---------------------------------------------------------------------
254 * indent-tabs-mode: t