Fix LDC, LDC_W, and INSTANCEOF opcodes, more debugging
[jamvm-avr32-jem.git] / src / frame.h
blob7122751794e103a09efcbc4772b76e958042f88f
1 /*
2 * Copyright (C) 2003, 2004, 2005, 2006, 2007
3 * Robert Lougher <rob@lougher.org.uk>.
5 * This file is part of JamVM.
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2,
10 * or (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
22 static inline void *CREATE_TOP_FRAME(ExecEnv *ee, Class *class, MethodBlock *mb,
23 uintptr_t **sp)
25 Frame *last = ee->last_frame;
26 Frame *dummy = (Frame *)(last->ostack + last->mb->max_stack);
27 Frame *new_frame;
28 uintptr_t *new_ostack;
29 void *ret;
31 *sp = (uintptr_t*)(dummy + 1);
32 new_frame = (Frame *)(*sp + mb->max_locals);
33 new_ostack = (uintptr_t *)(new_frame + 1);
35 if((char*)(new_ostack + mb->max_stack) > ee->stack_end) {
36 if(ee->overflow++) {
37 /* Overflow when we're already throwing stack
38 overflow. Stack extension should be enough
39 to throw exception, so something's seriously
40 gone wrong - abort the VM! */
41 printf("Fatal stack overflow! Aborting VM.\n");
42 exitVM(1);
44 ee->stack_end += STACK_RED_ZONE_SIZE;
45 signalException("java/lang/StackOverflowError", NULL);
46 return NULL;
49 dummy->mb = NULL;
50 dummy->ostack = *sp;
51 dummy->prev = last;
53 new_frame->mb = mb;
54 #ifndef JEM
55 new_frame->lvars = *sp;
56 ret = *sp;
57 #else
58 new_frame->lvars_jem = (uintptr_t *)new_frame;
59 ret = new_frame->lvars_jem - 1;
60 #endif
61 new_frame->ostack = new_ostack;
63 new_frame->prev = dummy;
64 ee->last_frame = new_frame;
66 return ret;
69 #define POP_TOP_FRAME(ee) \
70 ee->last_frame = ee->last_frame->prev->prev;