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
,
25 Frame
*last
= ee
->last_frame
;
26 Frame
*dummy
= (Frame
*)(last
->ostack
+ last
->mb
->max_stack
);
28 uintptr_t *new_ostack
;
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
) {
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");
44 ee
->stack_end
+= STACK_RED_ZONE_SIZE
;
45 signalException("java/lang/StackOverflowError", NULL
);
55 new_frame
->lvars
= *sp
;
58 new_frame
->lvars_jem
= (uintptr_t *)new_frame
;
59 ret
= new_frame
->lvars_jem
- 1;
61 new_frame
->ostack
= new_ostack
;
63 new_frame
->prev
= dummy
;
64 ee
->last_frame
= new_frame
;
69 #define POP_TOP_FRAME(ee) \
70 ee->last_frame = ee->last_frame->prev->prev;