+/* src/vm/jit/verify/typecheck-common.h - internal header for the type checker
+
+ Copyright (C) 1996-2005, 2006 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
+
+ This file is part of CACAO.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2, or (at
+ your option) any later version.
+
+ This program is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301, USA.
+
+ Contact: cacao@cacaojvm.org
+
+ Authors: Edwin Steiner
+
+ Changes:
+
+*/
+
+
#ifndef _TYPECHECK_COMMON_H
#define _TYPECHECK_COMMON_H
/* STATISTICS */
/****************************************************************************/
-#ifdef TYPECHECK_DEBUG
+#if defined(TYPECHECK_DEBUG) && !defined(TYPECHECK_NO_STATISTICS)
/*#define TYPECHECK_STATISTICS*/
#endif
else (array)[limit]++; \
} while (0)
-#else
+void typecheck_print_statistics(FILE *file);
+
+#else /* !defined(TYPECHECK_STATISTICS) */
#define TYPECHECK_COUNT(cnt)
#define TYPECHECK_MARK(var)
#define TYPECHECK_COUNTIF(cond,cnt)
#define TYPECHECK_COUNT_FREQ(array,val,limit)
-#endif
+
+#endif /* defined(TYPECHECK_STATISTICS) */
/****************************************************************************/
#define TYPECHECK_VERIFYERROR_bool(msg) TYPECHECK_VERIFYERROR_ret(state->m,(msg),false)
+/****************************************************************************/
+/* MISC MACROS */
+/****************************************************************************/
+
+#define COPYTYPE(source,dest) \
+ {if (VAROP(source)->type == TYPE_ADR) \
+ TYPEINFO_COPY(VAROP(source)->typeinfo,VAROP(dest)->typeinfo);}
+
+
+/****************************************************************************/
+/* JSR VERIFICATION (stack-based verifier) */
+/****************************************************************************/
+
+typedef struct typecheck_jsr_t typecheck_jsr_t;
+typedef struct typecheck_jsr_caller_t typecheck_jsr_caller_t;
+
+struct typecheck_jsr_caller_t {
+ typecheck_jsr_caller_t *next; /* next in linked list */
+ basicblock *callblock; /* block containing the calling JSR */
+};
+
+struct typecheck_jsr_t {
+ typecheck_jsr_t *next; /* next (lower) in the call chain */
+ basicblock *start; /* for debugging */
+ typecheck_jsr_caller_t *callers; /* list of callers (blocks with JSR) */
+ basicblock *retblock; /* block with the RET for this sub */
+ bool active; /* true if this sub is currently active */
+ char *blockflags; /* saved block flags when JSR was traversed */
+ char *usedlocals; /* != 0 for each local used in this sub */
+ typedescriptor *retlocals; /* locals on the RET edge */
+ typedescriptor *retstack; /* stack on the RET edge */
+ s4 retdepth; /* stack depth on the RET edge */
+};
+
/****************************************************************************/
/* VERIFIER STATE STRUCT */
/****************************************************************************/
s4 exinvars;
- exceptiontable **handlers; /* active exception handlers */
+ exception_entry **handlers; /* active exception handlers */
bool repeat; /* if true, blocks are iterated over again */
bool initmethod; /* true if this is an "<init>" method */
#ifdef TYPECHECK_STATISTICS
bool stat_maythrow; /* at least one instruction may throw */
#endif
+
+ /* the following fields are used by the stackbased verifier only: */
+
+ typedescriptor *locals; /* current local variables */
+ typedescriptor *startlocals; /* locals at the start of each block */
+ typedescriptor *startstack; /* stack at the start of each block */
+ s4 *indepth; /* stack depth at --''-- */
+ typedescriptor *stackceiling; /* upper edge of verifier stack */
+
+ typecheck_jsr_t *topjsr; /* most recently called subroutine */
+ typecheck_jsr_t **jsrinfos; /* subroutine info for each block */
} verifier_state;
void typecheck_init_flags(verifier_state *state, s4 minflags);
void typecheck_reset_flags(verifier_state *state);
+bool typecheck_copy_types(verifier_state *state,
+ s4 *srcvars, s4 *dstvars, s4 n);
+
+typecheck_result typecheck_merge_types(verifier_state *state,
+ s4 *srcvars,
+ s4 *dstvars,
+ s4 n);
+
+typecheck_result typestate_merge(verifier_state *state,
+ s4 *srcvars, varinfo *srclocals,
+ s4 *dstvars, varinfo *dstlocals,
+ s4 n);
+
+bool typestate_reach(verifier_state *state,
+ basicblock *destblock,
+ s4 *srcvars, varinfo *srclocals, s4 n);
+
+bool typecheck_init_locals(verifier_state *state, bool newthis);
+
#endif /* _TYPECHECK_COMMON_H */
/*