/* src/vm/jit/verify/typecheck-stackbased.c - stack-based verifier
- Copyright (C) 1996-2005, 2006 R. Grafl, A. Krall, C. Kruegel,
+ Copyright (C) 1996-2005, 2006, 2007 R. Grafl, A. Krall, C. Kruegel,
C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring,
E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich,
J. Wenninger, Institut f. Computersprachen - TU Wien
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
- Contact: cacao@cacaojvm.org
+*/
- Authors: Edwin Steiner
- Changes:
+#include "config.h"
- $Id$
+#include <assert.h>
-*/
+#include "vm/types.h"
+#include "vm/builtin.h"
+#include "mm/memory.h"
-#include "config.h"
-#include "vm/types.h"
+#include "vm/array.h"
#include "vm/global.h"
+#include "vm/primitive.h"
-#include <assert.h>
+#include "vm/jit/parse.h"
+#include "vm/jit/show.h"
+#include "vm/jit/stack.h"
+#include "vm/jit/verify/typecheck-common.h"
-#include <vm/jit/stack.h>
-#include <vm/jit/show.h>
-#include <typecheck-common.h>
/* this #if runs over the whole file: */
#if defined(ENABLE_VERIFIER)
#define VERIFY_ERROR(msg) \
do { \
LOG1("VerifyError: %s", msg); \
- exceptions_throw_verifyerror(state.m, msg); \
+ exceptions_throw_verifyerror(STATE->m, msg); \
return false; \
} while (0)
#define REACH(target) \
do { \
- tbptr = BLOCK_OF((target).insindex); \
- REACH_BLOCK(tbptr); \
+ REACH_BLOCK((target).block); \
} while (0)
#undef TYPECHECK_INT
jd = state->jd;
- tbptr = BLOCK_OF(state->iptr->sx.s23.s3.jsrtarget.insindex);
+ tbptr = state->iptr->sx.s23.s3.jsrtarget.block;
jsr = state->jsrinfos[tbptr->nr];
if (jsr && tbptr->flags == BBFINISHED) {
jsr->next = state->topjsr;
state->topjsr = jsr;
- /* XXX ugly */
- assert(BLOCK_OF(state->iptr->sx.s23.s3.jsrtarget.insindex)->flags == BBTYPECHECK_REACHED);
+ assert(state->iptr->sx.s23.s3.jsrtarget.block->flags == BBTYPECHECK_REACHED);
+
tbptr->flags = BBFINISHED;
+
for (tbptr = state->basicblocks; tbptr != NULL; tbptr = tbptr->next) {
jsr->blockflags[tbptr->nr] = tbptr->flags;
+
if (tbptr->flags == BBTYPECHECK_REACHED)
tbptr->flags = BBFINISHED;
}
- BLOCK_OF(state->iptr->sx.s23.s3.jsrtarget.insindex)->flags = BBTYPECHECK_REACHED;
+
+ state->iptr->sx.s23.s3.jsrtarget.block->flags = BBTYPECHECK_REACHED;
}
/* register this block as a caller, if not already done */
verifier_slot_t *dst;
verifier_state state;
basicblock *tbptr;
- exceptiontable *ex;
+ exception_entry *ex;
typedescriptor exstack;
s4 skip = 0;
state.topjsr = NULL;
# define STATE (&state)
+ /* check that the basicblock numbers are valid */
+
+#if !defined(NDEBUG)
+ jit_check_basicblock_numbers(jd);
+#endif
+
/* check if this method is an instance initializer method */
state.initmethod = (state.m->name == utf_init);
/* allocate the buffer of active exception handlers */
- state.handlers = DMNEW(exceptiontable*, state.cd->exceptiontablelength + 1);
+ state.handlers = DMNEW(exception_entry*, state.jd->exceptiontablelength + 1);
/* initialize instack of exception handlers */
/* something? */
/* XXX reuse code from variables based verifer? */
len = 0;
- for (ex = STATE->cd->exceptiontable; ex ; ex = ex->down) {
+ for (ex = STATE->jd->exceptiontable; ex ; ex = ex->down) {
if ((ex->start->nr <= STATE->bptr->nr) && (ex->end->nr > STATE->bptr->nr)) {
LOG1("\tactive handler L%03d", ex->handler->nr);
STATE->handlers[len++] = ex;