1 /* src/vm/jit/intrp/intrp.h - definitions for Interpreter
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 Authors: Christian Thalinger
32 $Id: intrp.h 3972 2005-12-21 10:26:52Z twisti $
40 /* #define VM_PROFILING */
50 #include "vm/global.h"
51 #include "vm/method.h"
52 #include "vm/references.h"
53 #include "vm/resolve.h"
63 #if SIZEOF_VOID_P == 8
70 #define MAYBE_UNUSED __attribute__((unused))
75 #if SIZEOF_VOID_P == 4
86 #define FETCH_DCELL_T(d_,lo,hi,t_) ({ \
88 _d.cells.low = (lo); \
89 _d.cells.high = (hi); \
93 #define STORE_DCELL_T(d_,lo,hi,t_) ({ \
96 (lo) = _d.cells.low; \
97 (hi) = _d.cells.high; \
100 #else /* SIZEOF_VOID_P == 4 */
109 #define FETCH_DCELL_T(d_,lo,hi,t_) ({ (d_) = ((Double_Store)(lo)).t_; })
110 #define STORE_DCELL_T(d_,lo,hi,t_) ({ (lo) = ((Double_Store)(d_)).low; })
112 #endif /* SIZEOF_VOID_P == 4 */
115 #if defined(USE_THREADS) && defined(NATIVE_THREADS)
117 #define global_sp (*(Cell **)&(THREADINFO->_global_sp))
119 #else /* defined(USE_THREADS) && defined(NATIVE_THREADS) */
121 #define MAX_STACK_SIZE 128*1024
122 static char stack[MAX_STACK_SIZE];
124 static Cell *_global_sp = (Cell *)(stack+MAX_STACK_SIZE);
125 #define global_sp _global_sp
127 #endif /* defined(USE_THREADS) && defined(NATIVE_THREADS) */
129 #define CLEAR_global_sp (global_sp=NULL)
132 #define vm_twoCell2l(hi,lo,d_) FETCH_DCELL_T(d_,lo,hi,l);
133 #define vm_twoCell2d(hi,lo,d_) FETCH_DCELL_T(d_,lo,hi,d);
135 #define vm_l2twoCell(d_,hi,lo) STORE_DCELL_T(d_,lo,hi,l);
136 #define vm_d2twoCell(d_,hi,lo) STORE_DCELL_T(d_,lo,hi,d);
138 #define vm_Cell2v(cell, v) ((v)=(Cell)(cell))
139 #define vm_Cell2b(cell, b) ((b)=(u1)(Cell)(cell))
140 #define vm_Cell2i(cell, i) ((i)=(s4)(Cell)(cell))
142 #define vm_Cell2aRef(x1,x2) ((x2) = (java_objectheader *)(x1))
143 #define vm_Cell2aArray(x1,x2) ((x2) = (java_arrayheader * )(x1))
144 #define vm_Cell2aaTarget(x1,x2) ((x2) = (Inst ** )(x1))
145 #define vm_Cell2aClass(x1,x2) ((x2) = (classinfo * )(x1))
146 #define vm_Cell2acr(x1,x2) ((x2) = (constant_classref *)(x1))
147 #define vm_Cell2addr(x1,x2) ((x2) = (u1 * )(x1))
148 #define vm_Cell2af(x1,x2) ((x2) = (functionptr )(x1))
149 #define vm_Cell2am(x1,x2) ((x2) = (methodinfo * )(x1))
150 #define vm_Cell2acell(x1,x2) ((x2) = (Cell * )(x1))
151 #define vm_Cell2ainst(x1,x2) ((x2) = (Inst * )(x1))
152 #define vm_Cell2auf(x1,x2) ((x2) = (unresolved_field * )(x1))
153 #define vm_Cell2aum(x1,x2) ((x2) = (unresolved_method *)(x1))
154 #define vm_Cell2avftbl(x1,x2) ((x2) = (vftbl_t * )(x1))
156 #define vm_ui2Cell(x1,x2) ((x2) = (Cell)(x1))
157 #define vm_v2Cell(x1,x2) ((x2) = (Cell)(x1))
158 #define vm_b2Cell(x1,x2) ((x2) = (Cell)(x1))
159 #define vm_s2Cell(x1,x2) ((x2) = (Cell)(x1))
160 #define vm_i2Cell(x1,x2) ((x2) = (Cell)(x1))
161 #define vm_aRef2Cell(x1,x2) ((x2) = (Cell)(x1))
162 #define vm_aArray2Cell(x1,x2) ((x2) = (Cell)(x1))
163 #define vm_aaTarget2Cell(x1,x2) ((x2) = (Cell)(x1))
164 #define vm_aClass2Cell(x1,x2) ((x2) = (Cell)(x1))
165 #define vm_acr2Cell(x1,x2) ((x2) = (Cell)(x1))
166 #define vm_addr2Cell(x1,x2) ((x2) = (Cell)(x1))
167 #define vm_af2Cell(x1,x2) ((x2) = (Cell)(x1))
168 #define vm_am2Cell(x1,x2) ((x2) = (Cell)(x1))
169 #define vm_acell2Cell(x1,x2) ((x2) = (Cell)(x1))
170 #define vm_ainst2Cell(x1,x2) ((x2) = (Cell)(x1))
171 #define vm_auf2Cell(x1,x2) ((x2) = (Cell)(x1))
172 #define vm_aum2Cell(x1,x2) ((x2) = (Cell)(x1))
173 #define vm_avftbl2Cell(x1,x2) ((x2) = (Cell)(x1))
175 #define vm_Cell2Cell(x1,x2) ((x2)=(Cell)(x1))
177 #define IMM_ARG(access,value) (access)
179 /* for disassembler and tracer */
180 #define VM_IS_INST(inst, n) ((inst) == vm_prim[n])
183 #define gen_BBSTART (cd->lastmcodeptr = NULL, append_dispatch(cd))
192 #define access_local_int(_offset) \
193 ( *(Cell*)(((u1 *)fp) + (_offset)) )
195 #define access_local_ref(_offset) \
196 ( *(void **)(((u1 *)fp) + (_offset)) )
198 #define access_local_cell(_offset) \
199 ( *(Cell *)(((u1 *)fp) + (_offset)) )
202 typedef struct block_count block_count;
204 #define vm_f2Cell(x1,x2) ((x2) =(((union Cell_float)(x1)).cell))
205 #define vm_Cell2f(x1,x2) ((x2) =(((union Cell_float)(x1)).f))
207 extern Inst *vm_prim;
208 extern Cell peeptable;
209 extern Inst *last_compiled;
212 void init_peeptable(void);
213 Inst peephole_opt(Inst inst1, Inst inst2, Cell peeptable);
214 void gen_inst(codegendata *cd, u4 instr);
216 void vm_disassemble(Inst *ip, Inst *endp, Inst vm_prim[]);
217 Inst *vm_disassemble_inst(Inst *ip, Inst vm_prim[]);
219 java_objectheader *engine(Inst *ip0, Cell * sp, Cell * fp);
221 #if defined(WITH_FFI)
222 ffi_type *cacaotype2ffitype(s4 cacaotype);
226 /* print types for disassembler and tracer */
227 void printarg_ui (u4 ui );
228 void printarg_v (Cell v );
229 void printarg_b (s4 b );
230 void printarg_s (s4 s );
231 void printarg_i (s4 i );
232 void printarg_l (s8 l );
233 void printarg_f (float f );
234 void printarg_d (double d );
235 void printarg_aRef (java_objectheader *aRef );
236 void printarg_aArray (java_arrayheader * aArray );
237 void printarg_aaTarget(Inst ** aaTarget);
238 void printarg_aClass (classinfo * aClass );
239 void printarg_acr (constant_classref *acr );
240 void printarg_addr (u1 * addr );
241 void printarg_af (functionptr af );
242 void printarg_am (methodinfo * am );
243 void printarg_acell (Cell * acell );
244 void printarg_ainst (Inst * ainst );
245 void printarg_auf (unresolved_field * auf );
246 void printarg_aum (unresolved_method *aum );
247 void printarg_avftbl (vftbl_t * avftbl );
248 void printarg_Cell (Cell x );
250 void vm_uncount_block(Inst *ip);
251 block_count *vm_block_insert(Inst *ip);
253 Cell *nativecall(functionptr f, methodinfo *m, Cell *sp, Inst *ra, Cell *fp, u1 *addrcif);
254 u1 *createcalljavafunction(methodinfo *m);
256 Inst *intrp_asm_handle_exception(Inst *ip, java_objectheader *o, Cell *fp, Cell **new_spp, Cell **new_fpp);
258 #endif /* _INTRP_H */
262 * These are local overrides for various environment variables in Emacs.
263 * Please do not remove this and leave it at the end of the file, where
264 * Emacs will automagically detect them.
265 * ---------------------------------------------------------------------
268 * indent-tabs-mode: t