50 #define CLASSINFO_IS_ARRAY(clsinfo) ((clsinfo)->vftbl->arraydesc != NULL)
53 #define CLASSINFO_IMPLEMENTS_INTERFACE(cls,index) \
54 ( ((index) < (cls)->vftbl->interfacetablelength) \
55 && ( (cls)->vftbl->interfacetable[-(index)] != NULL ) )
62 #define TYPEINFO_ASSERT(cond) assert(cond)
64 #define TYPEINFO_ASSERT(cond)
71 #if defined(ENABLE_VERIFIER)
251 for (i=0; i<
size; ++
i) {
253 && set[i].typeinfo.is_newobject()
256 if (!set[i].typeinfo.init_class(initclass))
287 bool changed =
false;
450 mlist = merged->
list;
561 mlist = merged->
list;
626 if (dest.
cls->
name == classname)
674 if (this->dimension < dimension)
677 if (this->dimension > dimension) {
698 if (this->elementclass.any) {
765 #define TYPEINFO_ALLOCMERGED(mergedlist,count) \
766 do {(mergedlist) = (typeinfo_mergedlist_t *) DumpMemory::allocate(sizeof(typeinfo_mergedlist_t) \
767 + ((count)-1)*sizeof(classinfo*));} while(0)
769 #define TYPEINFO_FREEMERGED(mergedlist)
771 #define TYPEINFO_FREEMERGED_IF_ANY(mergedlist)
850 if (*utf_ptr ==
'[') {
852 while (*utf_ptr ==
'[') {
857 if (*utf_ptr ==
'L') {
890 #ifdef TYPEINFO_VERBOSE
891 fprintf(stderr,
"typeinfo_init_from_typedesc(");
893 fprintf(stderr,
")\n");
1010 int buflen,
int startindex,
1020 for (i=0; i<startindex; ++
i) {
1029 varindex = map[5*slot + type];
1038 if (varindex >= buflen) {
1090 int buflen,
bool twoword,
int startindex,
1098 if (++args > buflen) {
1108 if (++args > buflen) {
1203 *dstlist++ = *srclist++;
1218 #ifdef TYPEINFO_VERBOSE
1219 fprintf(stderr,
"Error in typeinfo_merge: %s\n",str);
1220 fprintf(stderr,
"Typeinfo x:\n");
1222 fprintf(stderr,
"Typeinfo y:\n");
1243 if (clsx.
any < clsy.
any) {
1269 if ((mlist++)->any == cls.
any) {
1282 *newlist++ = *mlist++;
1291 newmerged->
count = count+1;
1292 newlist = newmerged->
list;
1295 if (mlist->
any > cls.
any)
1297 *newlist++ = *mlist++;
1302 *newlist++ = *mlist++;
1307 dest->
merged = newmerged;
1329 while (countx && county) {
1330 if (clsx->
any == clsy->
any) {
1336 else if (clsx->
any < clsy->
any) {
1346 count += countx + county;
1350 if ((x->
count != count) && (y->
count == count)) {
1351 temp = x; x = y; y = temp;
1354 if (x->
count == count) {
1368 *newlist++ = *clsx++;
1377 result->
count = count;
1378 newlist = result->
list;
1385 while (countx && county) {
1386 if (clsx->
any == clsy->
any) {
1387 *newlist++ = *clsx++;
1392 else if (clsx->
any < clsy->
any) {
1393 *newlist++ = *clsx++;
1397 *newlist++ = *clsy++;
1402 *newlist++ = *clsx++;
1404 *newlist++ = *clsy++;
1463 if ( (x.
any == y.
any) && (!mergedx || !mergedy) ) {
1466 changed = (dest->
merged != NULL);
1483 goto return_simple_x;
1490 #ifdef TYPEINFO_VERBOSE
1493 fprintf(stderr,
"merge_nonarrays:\n");
1502 fprintf(stderr,
" with:\n");
1525 goto return_simple_x;
1529 goto merge_with_simple_x;
1557 goto return_simple_x;
1578 goto return_simple_x;
1587 goto return_simple_x;
1594 goto merge_with_simple_x;
1626 while (common != tcls) {
1627 common = common->
super;
1636 if (x.
cls == common && !mergedx) {
1637 goto return_simple_x;
1641 result->
cls = common;
1648 merge_with_simple_x:
1649 result->
cls = common;
1726 changed = (
merged != NULL);
1765 #ifdef TYPEINFO_VERBOSE
1766 fprintf(stderr,
"merge:\n");
1802 if (--dimension == 0) {
1805 elementclass.
any = NULL;
1867 elementclass.
any = NULL;
1876 if (this->dimension != dimension) {
1884 if (this->elementclass.
any != elementclass.
any) {
1885 this->elementclass.
any = elementclass.
any;
1898 #ifdef TYPEINFO_DEBUG
1904 if (a->
any == b->
any)
return 0;
1905 if (a->
any < b->
any)
return -1;
1919 num = typeinfo_count_method_args(desc,
false);
1924 typeinfo_init_from_method_args(desc,typebuf,infobuf,num,
false,
1930 for (i=0; i<num; ++
i) {
1932 log_text(
"non-reference type in mergedlist");
1939 (
int(*)(
const void *,
const void *))&typeinfo_test_compare);
1942 typeinfo_init_from_method_args(desc,NULL,NULL,0,
false,
1948 #define TYPEINFO_TEST_BUFLEN 4000
1995 bool changed = (r) ? 1 : 0;
1998 printf(
" %s\n",(changed) ?
"changed" :
"=");
2004 if (changed != changed_should_be) {
2005 printf(
"WRONG RETURN VALUE!\n");
2032 #define TYPEINFO_TEST_MAXDIM 10
2044 FILE *file = fopen(filename,
"rt");
2048 log_text(
"could not open typeinfo test file");
2053 if (buf[0] ==
'#' || !strlen(buf))
2056 res = sscanf(buf,
"%s\t%s\t%s\n",bufa,bufb,bufc);
2057 if (res != 3 || !strlen(bufa) || !strlen(bufb) || !strlen(bufc)) {
2058 log_text(
"Invalid line in typeinfo test file (none of empty, comment or test)");
2063 typeinfo_test_parse(&a,bufa);
2064 typeinfo_test_parse(&b,bufb);
2065 typeinfo_test_parse(&c,bufc);
2083 typeinfo_inc_dimension(&a);
2084 typeinfo_inc_dimension(&b);
2085 typeinfo_inc_dimension(&c);
2094 fprintf(stderr,
"Failed typeinfo_merge tests: %d\n",failed);
2103 log_text(
"Running typeinfo test file...");
2105 log_text(
"Finished typeinfo test file.");
2110 typeinfo_init_from_fielddescriptor(
typeinfo_t *info,
char *desc)
2112 typeinfo_init_from_descriptor(info,desc,desc+strlen(desc));
2116 #define TYPEINFO_MAXINDENT 80
2124 fprintf(file,
"<null>");
2128 fprintf(file,
"<ref>");
2145 for (
int i = 0; i <
indent; ++
i)
2151 fprintf(file,
"%sreturnAddress (L%03d)\n",ind,bptr->nr);
2153 fprintf(file,
"%sprimitive\n",ind);
2158 fprintf(file,
"%snull\n",ind);
2164 fprintf(file,
"%sNEW(%p):",ind,(
void*)ins);
2169 fprintf(file,
"%sNEW(this)",ind);
2174 fprintf(file,
"%sClass: ",ind);
2179 fprintf(file,
"%sDimension: %d",ind,(
int)info->
dimension);
2180 fprintf(file,
"\n%sElements: ",ind);
2197 fprintf(file,
"INVALID ARRAYTYPE!\n");
2202 fprintf(file,
"%sMerged: ",ind);
2204 if (i) fprintf(file,
", ");
2221 fprintf(file,
"(typeinfo*)NULL");
2228 fprintf(file,
"ret(L%03d)",bptr->
nr);
2230 fprintf(file,
"primitive");
2235 fprintf(file,
"null");
2243 fprintf(file,
"NEW(%p):",(
void*)ins);
2247 fprintf(file,
"NEW(this)");
2256 if (i) fprintf(file,
",");
2267 case TYPE_VOID: fprintf(file,
"V");
break;
2268 case TYPE_INT: fprintf(file,
"I");
break;
2269 case TYPE_FLT: fprintf(file,
"F");
break;
2270 case TYPE_DBL: fprintf(file,
"D");
break;
2271 case TYPE_LNG: fprintf(file,
"J");
break;
2293 for (i=0; i<
size; ++
i) {
2294 fprintf(file,
" %d=",i);
void exceptions_throw_verifyerror(methodinfo *m, const char *message,...)
#define TYPEINFO_TEST_BUFLEN
jlong jlong jlong jlong jint jmethodID jint slot
static bool typeinfo_init_varinfo_from_typedesc(varinfo *var, typedesc *desc)
bool typeinfo_init_varinfos_from_methoddesc(varinfo *vars, methoddesc *desc, int buflen, int startindex, s4 *map, typedescriptor_t *returntype)
void init_class(classinfo *c)
Initialize object type.
constant_classref * class_get_classref_component_of(constant_classref *ref)
static bool typeinfo_merge_mergedlists(typeinfo_t *dest, typeinfo_mergedlist_t *x, typeinfo_mergedlist_t *y)
classref_or_classinfo list[1]
#define TYPEINFO_ASSERT(cond)
int typedescriptors_init_from_methoddesc(typedescriptor_t *td, methoddesc *desc, int buflen, bool twoword, int startindex, typedescriptor_t *returntype)
classinfo * class_array_of(classinfo *component, bool link)
bool init_component(const typeinfo_t &srcarray)
classref_or_classinfo elementclass
bool is_newobject() const
bool typevector_checkretaddr(varinfo *vec, int index)
static bool typedescriptor_init_from_typedesc(typedescriptor_t *td, typedesc *desc)
#define DNEW_TYPEVECTOR(size)
static typecheck_result merged_implements_interface(classinfo *typeclass, typeinfo_mergedlist_t *merged, classinfo *interf)
classinfo * pseudo_class_Arraystub
classinfo * class_java_lang_Object
JNIEnv jthread jobject jclass jlong size
static bool typeinfo_merge_add(typeinfo_t *dest, typeinfo_mergedlist_t *m, classref_or_classinfo cls)
classinfo * class_multiarray_of(s4 dim, classinfo *element, bool link)
classinfo * pseudo_class_Null
static bool interface_extends_interface(classinfo *cls, classinfo *interf)
void typevector_print(FILE *file, const varinfo *vec, int size)
typecheck_result typevector_merge(methodinfo *m, varinfo *dst, varinfo *y, int size)
bool typevector_init_object(varinfo *set, void *ins, classref_or_classinfo initclass, int size)
#define IS_2_WORD_TYPE(a)
typecheck_result merge(methodinfo *m, const typeinfo_t *t)
functions for merging types
#define TYPEINFO_FREEMERGED_IF_ANY(mergedlist)
static bool typeinfo_merge_two(typeinfo_t *dest, classref_or_classinfo clsx, classref_or_classinfo clsy)
void init_returnaddress(void *adr)
Instruction::InstID tmp[]
#define TYPEVECTOR_SIZE(size)
static typecheck_result typeinfo_merge_nonarrays(typeinfo_t *dest, classref_or_classinfo *result, classref_or_classinfo x, classref_or_classinfo y, typeinfo_mergedlist_t *mergedx, typeinfo_mergedlist_t *mergedy)
void typeinfo_print_type(FILE *file, int type, const typeinfo_t *info)
Type
Types used internally by JITTED code.
void exceptions_throw_internalerror(const char *message,...)
static void clone_merged(const typeinfo_t &src, typeinfo_t &dst)
void typevector_copy_inplace(varinfo *src, varinfo *dst, int size)
typeinfo_mergedlist_t * merged
typecheck_result is_assignable_to(typeinfo_t *dest) const
static Utf8String from_utf8(const char *, size_t)
bool typevector_checkreference(varinfo *vec, int index)
void * returnaddress() const
constant_classref * class_get_classref(classinfo *cls, Utf8String name)
typecheck_result is_assignable_to_class(classref_or_classinfo dest) const
bool is_primitive() const
#define TYPEINFO_MAXINDENT
void typeinfo_print(FILE *file, const typeinfo_t *info, int indent)
#define CLASSREF_OR_CLASSINFO_NAME(value)
#define TYPEINFO_ALLOCMERGED(mergedlist, count)
static bool typeinfo_equal(typeinfo_t *x, typeinfo_t *y)
instruction * newobject_instruction() const
bool class_issubclass(classinfo *sub, classinfo *super)
arraydescriptor * arraydesc
void utf_fprint_printable_ascii(FILE *file, Utf8String u)
bool init_from_typedesc(const typedesc *desc, u1 *type)
classref_or_classinfo typeclass
#define CLASSINFO_IS_ARRAY(clsinfo)
void typeinfo_print_short(FILE *file, const typeinfo_t *info)
byte_iterator begin() const
void typevector_store(varinfo *vec, int index, Type type, typeinfo_t *info)
classinfo * pseudo_class_New
void typevector_store_retaddr(varinfo *vec, int index, typeinfo_t *info)
jmethodID jint const void jint const jvmtiAddrLocationMap * map
#define TYPEINFO_TEST_MAXDIM
classinfo * link_class(classinfo *c)
bool is_reference() const
void typeinfo_print_class(FILE *file, classref_or_classinfo c)
static void * allocate(size_t size)
#define CLASSINFO_IMPLEMENTS_INTERFACE(cls, index)
static typecheck_result merged_is_subclass(classinfo *typeclass, typeinfo_mergedlist_t *merged, classinfo *cls)
bool resolve_classref_or_classinfo(methodinfo *refmethod, classref_or_classinfo cls, resolve_mode_t mode, bool checkaccess, bool link, classinfo **result)
void typedescriptor_print(FILE *file, const typedescriptor_t *td)
static void typeinfo_merge_error(methodinfo *m, const char *str, const typeinfo_t *x, const typeinfo_t *y)
void descriptor_debug_print_typedesc(FILE *file, typedesc *d)
static void typeinfo_testrun(const char *filename)
bool is_returnaddress() const
static typecheck_result mergedlist_implements_interface(typeinfo_mergedlist_t *merged, classinfo *interf)
static typecheck_result classinfo_implements_interface(classinfo *cls, classinfo *interf)
bool typevector_checktype(varinfo *vec, int index, int type)
constant_classref * classref
constant_classref * class_get_classref_multiarray_of(s4 dim, constant_classref *ref)
static void clone(const typeinfo_t &src, typeinfo_t &dst)
static void typeinfo_testmerge(typeinfo_t *a, typeinfo_t *b, typeinfo_t *result, int *failed)
bool is_classinfo() const
varinfo * typevector_copy(varinfo *src, int size)