-/* 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, 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
+ Copyright (C) 1996-2005, 2006, 2007, 2008
+ CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
This file is part of CACAO.
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
- Contact: cacao@cacaojvm.org
-
- Authors: Edwin Steiner
-
- $Id: typeinfo.h 4863 2006-04-30 16:17:44Z edwin $
-
*/
#ifndef _TYPEINFO_H
#define _TYPEINFO_H
+/* resolve typedef cycles *****************************************************/
+
+typedef struct typeinfo typeinfo_t;
+typedef struct typeinfo_mergedlist typeinfo_mergedlist_t;
+typedef struct typedescriptor typedescriptor_t;
+
#include "config.h"
#include "vm/types.h"
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 */
*
* 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.
struct typeinfo {
classref_or_classinfo typeclass;
classref_or_classinfo elementclass; /* valid if dimension>0 */ /* various uses! */
- typeinfo_mergedlist *merged;
+ typeinfo_mergedlist_t *merged;
u1 dimension;
u1 elementtype; /* valid if dimension>0 */
};
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_t 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 */
/****************************************************************************/
/* 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 *) DMNEW(uint8_t, TYPEVECTOR_SIZE(size)))
#define DMNEW_TYPEVECTOR(num,size) \
- ((void*)dump_alloc((num) * TYPEVECTOR_SIZE(size)))
+ ((void *) DMNEW(uint8_t, (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 ***************************************************/
/* internal, don't use this explicitly! */
-#define TYPEINFO_ALLOCMERGED(mergedlist,count) \
- do {(mergedlist) = (typeinfo_mergedlist*)dump_alloc( \
- sizeof(typeinfo_mergedlist) \
+#define TYPEINFO_ALLOCMERGED(mergedlist,count) \
+ do {(mergedlist) = (typeinfo_mergedlist_t *) DMNEW(uint8_t, \
+ sizeof(typeinfo_mergedlist_t) \
+ ((count)-1)*sizeof(classinfo*));} while(0)
/* internal, don't use this explicitly! */
&& 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 ********************************************/
/* FUNCTIONS */
/****************************************************************************/
+#ifdef __cplusplus
+extern "C" {
+#endif
+
/* 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_t *info);
+void typevector_store_retaddr(varinfo *set,int index,typeinfo_t *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) ********************************************/
-bool typeinfo_is_array(typeinfo *info);
-bool typeinfo_is_primitive_array(typeinfo *info,int arraytype);
-bool typeinfo_is_array_of_refs(typeinfo *info);
+bool typeinfo_is_array(typeinfo_t *info);
+bool typeinfo_is_primitive_array(typeinfo_t *info,int arraytype);
+bool typeinfo_is_array_of_refs(typeinfo_t *info);
-typecheck_result typeinfo_is_assignable(typeinfo *value,typeinfo *dest);
-typecheck_result typeinfo_is_assignable_to_class(typeinfo *value,classref_or_classinfo dest);
+typecheck_result typeinfo_is_assignable(typeinfo_t *value,typeinfo_t *dest);
+typecheck_result typeinfo_is_assignable_to_class(typeinfo_t *value,classref_or_classinfo dest);
/* initialization functions *************************************************/
* >= 0.............ok,
* -1...............an exception has been thrown.
*/
-void typeinfo_init_classinfo(typeinfo *info,classinfo *c);
-bool typeinfo_init_class(typeinfo *info,classref_or_classinfo c);
-bool typeinfo_init_component(typeinfo *srcarray,typeinfo *dst);
+void typeinfo_init_classinfo(typeinfo_t *info,classinfo *c);
+bool typeinfo_init_class(typeinfo_t *info,classref_or_classinfo c);
+bool typeinfo_init_component(typeinfo_t *srcarray,typeinfo_t *dst);
-bool typeinfo_init_from_typedesc(typedesc *desc,u1 *type,typeinfo *info);
+bool typeinfo_init_from_typedesc(typedesc *desc,u1 *type,typeinfo_t *info);
bool typeinfos_init_from_methoddesc(methoddesc *desc,u1 *typebuf,
- typeinfo *infobuf,
+ typeinfo_t *infobuf,
int buflen,bool twoword,
- u1 *returntype,typeinfo *returntypeinfo);
-bool typedescriptor_init_from_typedesc(typedescriptor *td,
+ u1 *returntype,typeinfo_t *returntypeinfo);
+bool typedescriptor_init_from_typedesc(typedescriptor_t *td,
+ typedesc *desc);
+bool typeinfo_init_varinfo_from_typedesc(varinfo *var,
typedesc *desc);
-int typedescriptors_init_from_methoddesc(typedescriptor *td,
+int typedescriptors_init_from_methoddesc(typedescriptor_t *td,
methoddesc *desc,
int buflen,bool twoword,int startindex,
- typedescriptor *returntype);
+ typedescriptor_t *returntype);
+bool typeinfo_init_varinfos_from_methoddesc(varinfo *vars,
+ methoddesc *desc,
+ int buflen, int startindex,
+ s4 *map,
+ typedescriptor_t *returntype);
-void typeinfo_clone(typeinfo *src,typeinfo *dest);
+void typeinfo_clone(typeinfo_t *src,typeinfo_t *dest);
/* freeing memory ***********************************************************/
-void typeinfo_free(typeinfo *info);
+void typeinfo_free(typeinfo_t *info);
/* functions for merging types **********************************************/
-typecheck_result typeinfo_merge(methodinfo *m,typeinfo *dest,typeinfo* y);
+typecheck_result typeinfo_merge(methodinfo *m,typeinfo_t *dest,typeinfo_t* y);
/* debugging helpers ********************************************************/
void typeinfo_test();
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 typeinfo_print(FILE *file,typeinfo_t *info,int indent);
+void typeinfo_print_short(FILE *file,typeinfo_t *info);
+void typeinfo_print_type(FILE *file,int type,typeinfo_t *info);
+void typedescriptor_print(FILE *file,typedescriptor_t *td);
+void typevector_print(FILE *file,varinfo *vec,int size);
#endif /* TYPEINFO_DEBUG */
+#ifdef __cplusplus
+}
+#endif
+
#endif /* _TYPEINFO_H */