* src/vm/jit/trace.c (trace_java_call_enter): Removed unused variable.
[cacao.git] / src / vm / jit / verify / typecheck-common.h
index 45d7490240b26e93b31e6ff3dcdce9a30307739a..ac91170dc7e9e4fa25d7d70e4ec44ce5c3d93899 100644 (file)
@@ -1,3 +1,36 @@
+/* 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
 
@@ -84,7 +117,7 @@ void typecheck_print_vararray(FILE *file, jitdata *jd, s4 *vars, int len);
 /* STATISTICS                                                               */
 /****************************************************************************/
 
-#ifdef TYPECHECK_DEBUG
+#if defined(TYPECHECK_DEBUG) && !defined(TYPECHECK_NO_STATISTICS)
 /*#define TYPECHECK_STATISTICS*/
 #endif
 
@@ -135,13 +168,16 @@ extern int stat_savedstack;
                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) */
 
 
 /****************************************************************************/
@@ -158,6 +194,40 @@ extern int stat_savedstack;
 #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                                                    */
 /****************************************************************************/
@@ -187,7 +257,7 @@ typedef struct verifier_state {
 
        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 */
@@ -195,11 +265,41 @@ typedef struct verifier_state {
 #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 */
 
 /*