1 /* src/vm/jit/intrp/asmpart.c - Java-C interface functions for Interpreter
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 Authors: Christian Thalinger
32 $Id: asmpart.c 4921 2006-05-15 14:24:36Z twisti $
45 #include "vm/builtin.h"
47 #include "vm/exceptions.h"
48 #include "vm/loader.h"
49 #include "vm/options.h"
50 #include "vm/jit/asmpart.h"
51 #include "vm/jit/methodheader.h"
52 #include "vm/jit/intrp/intrp.h"
55 static bool intrp_asm_vm_call_method_intern(methodinfo *m, s4 vmargscount,
58 java_objectheader *retval;
68 for (i = 0; i < vmargscount; i++) {
69 switch (vmargs[i].type) {
73 *(--sp) = (Cell) vmargs[i].data.l;
78 *((u8 *) sp) = vmargs[i].data.l;
83 entrypoint = createcalljavafunction(m);
85 retval = engine((Inst *) entrypoint, sp, NULL);
87 /* XXX remove the method from the method table */
90 (void)builtin_throw_exception(retval);
98 java_objectheader *intrp_asm_vm_call_method(methodinfo *m, s4 vmargscount,
101 java_objectheader *retval = NULL;
103 if (intrp_asm_vm_call_method_intern(m, vmargscount, vmargs)) {
104 if (m->parseddesc->returntype.type == TYPE_ADR)
105 retval = (java_objectheader *)*global_sp++;
107 assert(m->parseddesc->returntype.type == TYPE_VOID);
114 s4 intrp_asm_vm_call_method_int(methodinfo *m, s4 vmargscount, vm_arg *vmargs)
118 if (intrp_asm_vm_call_method_intern(m, vmargscount, vmargs)) {
119 if (m->parseddesc->returntype.type == TYPE_INT)
120 retval = *global_sp++;
122 assert(m->parseddesc->returntype.type == TYPE_VOID);
129 s8 intrp_asm_vm_call_method_long(methodinfo *m, s4 vmargscount, vm_arg *vmargs)
133 assert(m->parseddesc->returntype.type == TYPE_LNG);
135 if (intrp_asm_vm_call_method_intern(m, vmargscount, vmargs)) {
136 retval = *(s8 *)global_sp;
144 float intrp_asm_vm_call_method_float(methodinfo *m, s4 vmargscount,
149 assert(m->parseddesc->returntype.type == TYPE_FLT);
151 if (intrp_asm_vm_call_method_intern(m, vmargscount, vmargs)) {
152 retval = *(float *)global_sp;
160 double intrp_asm_vm_call_method_double(methodinfo *m, s4 vmargscount,
165 assert(m->parseddesc->returntype.type == TYPE_DBL);
167 if (intrp_asm_vm_call_method_intern(m, vmargscount, vmargs)) {
168 retval = *(double *)global_sp;
176 Inst *intrp_asm_handle_exception(Inst *ip, java_objectheader *o, Cell *fp, Cell **new_spp, Cell **new_fpp)
181 s4 exceptiontablelength;
184 /* for a description of the stack see IRETURN in java.vmg */
186 for (; fp != NULL; ) {
187 u1 *f = codegen_findmethod((u1 *) (ip - 1));
189 /* get methodinfo pointer from method header */
191 methodinfo *m = *(methodinfo **) (((u1 *) f) + MethodPointer);
193 framesize = (*((s4 *) (((u1 *) f) + FrameSize)));
194 ex = (exceptionentry *) (((u1 *) f) + ExTableStart);
195 exceptiontablelength = *((s4 *) (((u1 *) f) + ExTableSize));
198 if (opt_verbose || opt_verbosecall || opt_verboseexception)
199 builtin_trace_exception(o, m, ip, 1);
202 for (i = 0; i < exceptiontablelength; i++) {
204 c = ex->catchtype.cls;
207 if (!(c->state & CLASS_LOADED))
209 if (!load_class_bootstrap(c->name))
212 if (!(c->state & CLASS_LINKED))
217 if (ip-1 >= (Inst *) ex->startpc && ip-1 < (Inst *) ex->endpc &&
218 (c == NULL || builtin_instanceof(o, c))) {
219 *new_spp = (Cell *)(((u1 *)fp) - framesize - SIZEOF_VOID_P);
221 return (Inst *) (ex->handlerpc);
225 ip = (Inst *)access_local_cell(-framesize - SIZEOF_VOID_P);
226 fp = (Cell *)access_local_cell(-framesize);
233 void intrp_asm_getclassvalues_atomic(vftbl_t *super, vftbl_t *sub, castinfo *out)
237 #if defined(ENABLE_THREADS)
241 sbv = super->baseval;
242 sdv = super->diffval;
245 #if defined(ENABLE_THREADS)
249 out->super_baseval = sbv;
250 out->super_diffval = sdv;
251 out->sub_baseval = sv;
256 * These are local overrides for various environment variables in Emacs.
257 * Please do not remove this and leave it at the end of the file, where
258 * Emacs will automagically detect them.
259 * ---------------------------------------------------------------------
262 * indent-tabs-mode: t