* Removed all Id tags.
[cacao.git] / src / vm / jit / verify / typeinfo.h
index 4f3361f6e4fc5fef968dc23430bb87570cb1b95c..10125f12cd620f368e1fa803f98910c21427d49c 100644 (file)
@@ -1,9 +1,9 @@
-/* typeinfo.h - type system used by the type checker
+/* src/vm/jit/verify/typeinfo.h - type system used by the type checker
 
-   Copyright (C) 1996-2005 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
+   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
 
    This file is part of CACAO.
 
 
    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., 59 Temple Place - Suite 330, Boston, MA
-   02111-1307, USA.
-
-   Contact: cacao@complang.tuwien.ac.at
-
-   Authors: Edwin Steiner
-
-   $Id: typeinfo.h 3642 2005-11-08 19:01:17Z edwin $
+   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+   02110-1301, USA.
 
 */
 
 #ifndef _TYPEINFO_H
 #define _TYPEINFO_H
 
+/* resolve typedef cycles *****************************************************/
+
+typedef struct typeinfo typeinfo;
+typedef struct typeinfo_mergedlist typeinfo_mergedlist;
+typedef struct typedescriptor typedescriptor;
+
+#include "config.h"
+#include "vm/types.h"
+
 #include "vm/global.h"
-#include "vm/references.h"
+
+#include "vmcore/references.h"
+
 
 /* configuration **************************************************************/
 
@@ -47,7 +52,7 @@
  * TYPECHECK_VERBOSE activates all debug messages
  * TYPEINFO_VERBOSE activates debug prints in typeinfo.c
  */
-#ifdef CACAO_TYPECHECK
+#ifdef ENABLE_VERIFIER
 #ifndef NDEBUG
 /*#define TYPECHECK_STATISTICS*/
 #define TYPEINFO_DEBUG
 #endif
 
 #ifdef TYPECHECK_VERBOSE_OPT
-extern bool typecheckverbose;
+extern bool opt_typecheckverbose;
 #endif
 
-/* resolve typedef cycles *****************************************************/
-
-typedef struct typeinfo typeinfo;
-typedef struct typeinfo_mergedlist typeinfo_mergedlist;
-typedef struct typedescriptor typedescriptor;
-typedef struct typevector typevector;
-typedef struct typeinfo_retaddr_set typeinfo_retaddr_set;
-
 /* types **********************************************************************/
 
 /* typecheck_result - return type for boolean and tristate  functions     */
@@ -131,17 +128,7 @@ typedef enum {
  *
  * A) typeclass == NULL
  *
- *        This is a returnAddress type. The interpretation of the
- *        elementclass field depends on wether this typeinfo describes
- *        a stack slot or a local variable:
- *
- *        stack slot: elementclass is a pointer to a
- *            typeinfo_retaddr_set which contains a return target for
- *            every vector in the current set of local variable vectors.
- *            See typeinfo_retaddr_set and typevector below.
- *
- *        local variable: elementclass is the return target (when cast
- *            to basicblock *)
+ *        This is a returnAddress type.
  *
  *        Use TYPEINFO_IS_PRIMITIVE to check for this.
  *        Use TYPEINFO_RETURNADDRESS to access the pointer in elementclass.
@@ -257,48 +244,15 @@ struct typeinfo_mergedlist {
        classref_or_classinfo list[1];       /* variable length!                        */
 };
 
-/*-----------------------------------------------------------------------*/
-/* a typeinfo_retaddr_set stores the set of possible returnAddresses     */
-/* that may be in a particular stack slot at a particular point in the   */
-/* program.                                                              */
-/*                                                                       */
-/* There may be one or more alternative returnAddresses if the           */
-/* instruction can be reached via one or more JSR jumps (among other     */
-/* control-flow paths                                                    */
-/*-----------------------------------------------------------------------*/
-
-struct typeinfo_retaddr_set {
-       typeinfo_retaddr_set *alt;  /* next alternative in set               */
-       void                 *addr; /* return address                        */
-};
-
 /* a type descriptor stores a basic type and the typeinfo                */
 /* this is used for storing the type of a local variable, and for        */
 /* storing types in the signature of a method                            */
 
 struct typedescriptor {
-       typeinfo        info;     /* valid if type == TYPE_ADR               */
+       typeinfo        typeinfo; /* valid if type == TYPE_ADR               */
        u1              type;     /* basic type (TYPE_INT, ...)              */
 };
 
-/*-----------------------------------------------------------------------*/
-/* typevectors are used to store the types of all local variables        */
-/* at a given point in the program.                                      */
-/*                                                                       */
-/* There may be more than one possible typevector for the local          */
-/* variables at a given instruction if the instruction can be reached    */
-/* via one or more JSR jumps (among other control-flow paths).           */
-/*                                                                       */
-/* This is called the set of alternative type vectors at that            */
-/* particular point in the program.                                      */
-/*-----------------------------------------------------------------------*/
-
-struct typevector {
-       typevector      *alt;     /* next alternative in typevector set      */
-       int              k;       /* for lining up with the stack set        */
-       typedescriptor   td[1];   /* types of locals, variable length!       */
-};
-
 /****************************************************************************/
 /* MACROS                                                                   */
 /****************************************************************************/
@@ -310,17 +264,16 @@ struct typevector {
 /* typevectors **************************************************************/
 
 #define TYPEVECTOR_SIZE(size)                                          \
-    ((sizeof(typevector) - sizeof(typedescriptor))     \
-     + (size)*sizeof(typedescriptor))
+    ((size) * sizeof(varinfo)) 
 
 #define DNEW_TYPEVECTOR(size)                                          \
-    ((typevector*)dump_alloc(TYPEVECTOR_SIZE(size)))
+    ((varinfo*)dump_alloc(TYPEVECTOR_SIZE(size)))
 
 #define DMNEW_TYPEVECTOR(num,size)                                             \
     ((void*)dump_alloc((num) * TYPEVECTOR_SIZE(size)))
 
 #define MGET_TYPEVECTOR(array,index,size) \
-    ((typevector*) (((u1*)(array)) + TYPEVECTOR_SIZE(size) * (index)))
+    ((varinfo*) (((u1*)(array)) + TYPEVECTOR_SIZE(size) * (index)))
 
 /* internally used macros ***************************************************/
 
@@ -395,18 +348,18 @@ struct typevector {
               && TYPEINFO_IS_ARRAY_OF_REFS_NOCHECK(info) )
 
 #define TYPE_IS_RETURNADDRESS(type,info)                        \
-            ( ((type)==TYPE_ADDRESS)                            \
+            ( ((type)==TYPE_RET)                                \
               && TYPEINFO_IS_PRIMITIVE(info) )
 
 #define TYPE_IS_REFERENCE(type,info)                            \
-            ( ((type)==TYPE_ADDRESS)                            \
+            ( ((type)==TYPE_ADR)                                \
               && !TYPEINFO_IS_PRIMITIVE(info) )
 
 #define TYPEDESC_IS_RETURNADDRESS(td)                           \
-            TYPE_IS_RETURNADDRESS((td).type,(td).info)
+            TYPE_IS_RETURNADDRESS((td).type,(td).typeinfo)
 
 #define TYPEDESC_IS_REFERENCE(td)                               \
-            TYPE_IS_REFERENCE((td).type,(td).info)
+            TYPE_IS_REFERENCE((td).type,(td).typeinfo)
 
 /* queries allowing the null type ********************************************/
 
@@ -442,9 +395,9 @@ struct typevector {
              (info).dimension = 0;                      \
              (info).elementtype = 0;} while(0)
 
-#define TYPEINFO_INIT_JAVA_LANG_CLASS(info,cr)                  \
+#define TYPEINFO_INIT_JAVA_LANG_CLASS(info,c                  \
          do {(info).typeclass.any = class_java_lang_Class;      \
-             (info).elementclass.ref = (cr);                    \
+             (info).elementclass = (c);                         \
              (info).merged = NULL;                              \
              (info).dimension = 0;                              \
              (info).elementtype = 0;} while(0)
@@ -482,29 +435,19 @@ struct typevector {
 /* typevector functions *****************************************************/
 
 /* element read-only access */
-bool typevectorset_checktype(typevector *set,int index,int type);
-bool typevectorset_checkreference(typevector *set,int index);
-bool typevectorset_checkretaddr(typevector *set,int index);
-int typevectorset_copymergedtype(methodinfo *m,typevector *set,int index,typeinfo *dst);
-int typevectorset_mergedtype(methodinfo *m,typevector *set,int index,typeinfo *temp,typeinfo **result);
+bool typevector_checktype(varinfo *set,int index,int type);
+bool typevector_checkreference(varinfo *set,int index);
+bool typevector_checkretaddr(varinfo *set,int index);
 
 /* element write access */
-void typevectorset_store(typevector *set,int index,int type,typeinfo *info);
-void typevectorset_store_retaddr(typevector *set,int index,typeinfo *info);
-void typevectorset_store_twoword(typevector *set,int index,int type);
-bool typevectorset_init_object(typevector *set,void *ins,classref_or_classinfo initclass,int size);
+void typevector_store(varinfo *set,int index,int type,typeinfo *info);
+void typevector_store_retaddr(varinfo *set,int index,typeinfo *info);
+bool typevector_init_object(varinfo *set,void *ins,classref_or_classinfo initclass,int size);
 
 /* vector functions */
-bool typevector_separable_from(typevector *a,typevector *b,int size);
-typecheck_result typevector_merge(methodinfo *m,typevector *dst,typevector *y,int size);
-
-/* vector set functions */
-typevector *typevectorset_copy(typevector *src,int k,int size);
-void typevectorset_copy_inplace(typevector *src,typevector *dst,int size);
-bool typevectorset_separable_with(typevector *set,typevector *add,int size);
-typecheck_result typevectorset_collapse(methodinfo *m,typevector *dst,int size);
-void typevectorset_add(typevector *dst,typevector *v,int size);
-typevector *typevectorset_select(typevector **set,int retindex,void *retaddr);
+varinfo *typevector_copy(varinfo *src,int size);
+void typevector_copy_inplace(varinfo *src,varinfo *dst,int size);
+typecheck_result typevector_merge(methodinfo *m,varinfo *dst,varinfo *y,int size);
 
 /* inquiry functions (read-only) ********************************************/
 
@@ -536,10 +479,17 @@ bool typeinfos_init_from_methoddesc(methoddesc *desc,u1 *typebuf,
                                    u1 *returntype,typeinfo *returntypeinfo);
 bool  typedescriptor_init_from_typedesc(typedescriptor *td,
                                                                            typedesc *desc);
+bool  typeinfo_init_varinfo_from_typedesc(varinfo *var,
+                                                                           typedesc *desc);
 int  typedescriptors_init_from_methoddesc(typedescriptor *td,
                                                                                  methoddesc *desc,
                                                                                  int buflen,bool twoword,int startindex,
                                                                                  typedescriptor *returntype);
+bool typeinfo_init_varinfos_from_methoddesc(varinfo *vars,
+                                                                                 methoddesc *desc,
+                                                                                 int buflen, int startindex,
+                                                                                 s4 *map,
+                                                                                 typedescriptor *returntype);
 
 void typeinfo_clone(typeinfo *src,typeinfo *dest);
 
@@ -562,10 +512,8 @@ void typeinfo_print_class(FILE *file,classref_or_classinfo c);
 void typeinfo_print(FILE *file,typeinfo *info,int indent);
 void typeinfo_print_short(FILE *file,typeinfo *info);
 void typeinfo_print_type(FILE *file,int type,typeinfo *info);
-void typeinfo_print_stacktype(FILE *file,int type,typeinfo *info);
 void typedescriptor_print(FILE *file,typedescriptor *td);
-void typevector_print(FILE *file,typevector *vec,int size);
-void typevectorset_print(FILE *file,typevector *set,int size);
+void typevector_print(FILE *file,varinfo *vec,int size);
 
 #endif /* TYPEINFO_DEBUG */