X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=src%2Fvm%2Fjit%2Fparse.c;h=7a02bb8a45004fd7ea8e7ed38c35ddd81812c4c9;hb=f355d55d7cda7577f1696e9fc573c2f73494e317;hp=ba7babcb4129c8914d5c10eed2a7cc86634533df;hpb=f7f39916196f2819ec4e8101d10bfa59f71c536d;p=cacao.git diff --git a/src/vm/jit/parse.c b/src/vm/jit/parse.c index ba7babcb4..7a02bb8a4 100644 --- a/src/vm/jit/parse.c +++ b/src/vm/jit/parse.c @@ -31,11 +31,12 @@ Joseph Wenninger Christian Thalinger - $Id: parse.c 2358 2005-04-22 22:01:51Z jowenn $ + $Id: parse.c 2541 2005-05-31 16:02:14Z twisti $ */ +#include #include #include "config.h" @@ -56,6 +57,7 @@ #include "vm/jit/asmpart.h" #include "vm/jit/jit.h" #include "vm/jit/parse.h" +#include "vm/jit/patcher.h" #include "vm/jit/inline/parseRT.h" #include "vm/jit/inline/parseXTA.h" #include "vm/jit/inline/inline.h" @@ -98,7 +100,7 @@ static exceptiontable* fillextable(methodinfo *m, /*if (m->exceptiontablelength > 0) { METHINFOx(m); printf("m->exceptiontablelength=%i\n",m->exceptiontablelength); - panic("exceptiontablelength > 0"); + assert(0); }*/ b_count = *block_count; @@ -114,12 +116,16 @@ static exceptiontable* fillextable(methodinfo *m, /*** if (DEBUG==true){printf("---------------------block_inserted:b_count=%i m->basicblockindex[(p=%i)]=%i=%p\n",b_count,p,m->basicblockindex[(p)],m->basicblockindex[(p)]); fflush(stdout); } ***/ p = raw_extable[src].endpc; /* see JVM Spec 4.7.3 */ - if (p <= raw_extable[src].startpc) - panic("Invalid exception handler range"); + if (p <= raw_extable[src].startpc) { + log_text("Invalid exception handler range"); + assert(0); + } if (p >inline_env->method->jcodelength) { - panic("Invalid exception handler end is after code end"); + log_text("Invalid exception handler end is after code end"); + assert(0); } + if (pmethod->jcodelength) insertBlock=1; else insertBlock=0; /*if (label_index !=NULL) printf("%s:translating endpc:%ld to %ld, label_index:%p\n",m->name->text,p,label_index[p],label_index); else printf("%s:fillextab: endpc:%ld\n",m->name->text,p);*/ @@ -177,6 +183,7 @@ methodinfo *parse(methodinfo *m, codegendata *cd, t_inlining_globals *inline_env u2 skipBasicBlockChange; +#if defined(USE_INLINING) METHINFOt(m,"\nPARSING: ",DEBUG4); if ((opt_rt) || (opt_xta)) { FILE *Missed; @@ -203,16 +210,20 @@ if ((opt_rt) || (opt_xta)) { } } } - /* INLINING */ +#endif +#if defined(USE_INLINING) if (useinlining) { label_index = inlinfo->label_index; m->maxstack = inline_env->cummaxstack; /*JOWENN m->exceptiontablelength = inline_env->cumextablelength;*/ - tmpinlinf = (inlining_methodinfo*) - list_first(inlinfo->inlinedmethods); - if (tmpinlinf != NULL) nextgp = tmpinlinf->startgp; + + tmpinlinf = (inlining_methodinfo *) list_first(inlinfo->inlinedmethods); + + if (tmpinlinf != NULL) + nextgp = tmpinlinf->startgp; } +#endif /**** static analysis has to be called before inlining which has to be called before reg_set @@ -306,7 +317,7 @@ if (m->exceptiontablelength > 0) } } - /*INLINING*/ +#if defined(USE_INLINING) if ((useinlining) && (gp == nextgp)) { u1 *tptr; bool *readonly = NULL; @@ -319,8 +330,11 @@ if (m->exceptiontablelength > 0) opcode = code_get_u1(p,inline_env->method); nextp = p += jcommandsize[opcode]; - if (nextp > inline_env->method->jcodelength) - panic("Unexpected end of bytecode"); + if (nextp > inline_env->method->jcodelength) { + log_text("Unexpected end of bytecode"); + assert(0); + } + tmpinlinf = list_first(inlinfo->inlinedmethods); firstlocal = tmpinlinf->firstlocal; label_index = tmpinlinf->label_index; @@ -382,7 +396,8 @@ METHINFO(inline_env->method,DEBUG); label_index, &b_count, inline_env); continue; } - +#endif /* defined(USE_INLINING) */ + opcode = code_get_u1(p,inline_env->method); /* fetch op code */ if (DEBUG==true) { @@ -412,8 +427,12 @@ fflush(stdout); } nextp = p + jcommandsize[opcode]; /* compute next instruction start */ - if (nextp > inline_env->method->jcodelength) - panic("Unexpected end of bytecode"); + + if (nextp > inline_env->method->jcodelength) { + log_text("Unexpected end of bytecode"); + assert(0); + } + s_count += stackreq[opcode]; /* compute stack element count */ SHOWOPCODE(DEBUG4) switch (opcode) { @@ -440,8 +459,10 @@ SHOWOPCODE(DEBUG4) pushconstantitem: - if (i >= inline_env->method->class->cpcount) - error("Attempt to access constant outside range: %d >= %d", i, inline_env->method->class->cpcount); + if (i >= inline_env->method->class->cpcount) { + dolog("Attempt to access constant outside range: %d >= %d", i, inline_env->method->class->cpcount); + assert(0); + } switch (inline_env->method->class->cptags[i]) { case CONSTANT_Integer: @@ -459,7 +480,9 @@ SHOWOPCODE(DEBUG4) case CONSTANT_String: LOADCONST_A(literalstring_new((utf *) (inline_env->method->class->cpinfos[i]))); break; - default: panic("Invalid constant type to push"); + default: + log_text("Invalid constant type to push"); + assert(0); } break; @@ -627,46 +650,46 @@ SHOWOPCODE(DEBUG4) case JAVA_NEWARRAY: OP(ICMD_CHECKASIZE); - switch (code_get_s1(p + 1,inline_env->method)) { + switch (code_get_s1(p + 1, inline_env->method)) { case 4: - BUILTIN1(BUILTIN_newarray_boolean, TYPE_ADR,currentline); + BUILTIN1(BUILTIN_newarray_boolean, TYPE_ADR, currentline); break; case 5: - BUILTIN1(BUILTIN_newarray_char, TYPE_ADR,currentline); + BUILTIN1(BUILTIN_newarray_char, TYPE_ADR, currentline); break; case 6: - BUILTIN1(BUILTIN_newarray_float, TYPE_ADR,currentline); + BUILTIN1(BUILTIN_newarray_float, TYPE_ADR, currentline); break; case 7: - BUILTIN1(BUILTIN_newarray_double, TYPE_ADR,currentline); + BUILTIN1(BUILTIN_newarray_double, TYPE_ADR, currentline); break; case 8: - BUILTIN1(BUILTIN_newarray_byte, TYPE_ADR,currentline); + BUILTIN1(BUILTIN_newarray_byte, TYPE_ADR, currentline); break; case 9: - BUILTIN1(BUILTIN_newarray_short, TYPE_ADR,currentline); + BUILTIN1(BUILTIN_newarray_short, TYPE_ADR, currentline); break; case 10: - BUILTIN1(BUILTIN_newarray_int, TYPE_ADR,currentline); + BUILTIN1(BUILTIN_newarray_int, TYPE_ADR, currentline); break; case 11: - BUILTIN1(BUILTIN_newarray_long, TYPE_ADR,currentline); + BUILTIN1(BUILTIN_newarray_long, TYPE_ADR, currentline); break; - default: panic("Invalid array-type to create"); + default: + log_text("Invalid array-type to create"); + assert(0); } OP(ICMD_CHECKEXCEPTION); break; case JAVA_ANEWARRAY: OP(ICMD_CHECKASIZE); - i = code_get_u2(p + 1,inline_env->method); + i = code_get_u2(p + 1, inline_env->method); { - classinfo *component; constant_classref *compr; constant_classref *cr; classinfo *c; -#if defined(__X86_64__) || defined(__I386__) compr = (constant_classref *) class_getconstant(inline_env->method->class, i, CONSTANT_Class); if (!(cr = class_get_classref_multiarray_of(1, compr))) @@ -677,27 +700,13 @@ SHOWOPCODE(DEBUG4) if (c) { LOADCONST_A_BUILTIN(c->vftbl); - BUILTIN2(BUILTIN_newarray, TYPE_ADR, currentline); + BUILTIN2T(BUILTIN_newarray, TYPE_ADR, NULL, currentline); } else { LOADCONST_A_BUILTIN(cr); - BUILTIN2(asm_wrapper_patcher_BUILTIN_newarray, TYPE_ADR, currentline); + BUILTIN2T(PATCHER_builtin_newarray, TYPE_ADR, cr, currentline); } s_count++; -#else - cr = (constant_classref *) class_getconstant(inline_env->method->class, i, CONSTANT_Class); - - if (!resolve_classref(inline_env->method, - cr,resolveEager,true,&component)) - return NULL; - - c = class_array_of(component,true); - if (!c) - return NULL; - LOADCONST_A_BUILTIN(c->vftbl); - s_count++; - BUILTIN2(BUILTIN_anewarray, TYPE_ADR, currentline); -#endif } OP(ICMD_CHECKEXCEPTION); break; @@ -706,43 +715,23 @@ SHOWOPCODE(DEBUG4) inline_env->method->isleafmethod = false; i = code_get_u2(p + 1, inline_env->method); { - classinfo *component; + constant_classref *cr; classinfo *c; - constant_classref *cr; - vftbl_t *arrayvftbl; s4 v = code_get_u1(p + 3, inline_env->method); -#if defined(__X86_64__) || defined(__I386__) cr = (constant_classref *) class_getconstant(inline_env->method->class, i, CONSTANT_Class); if (!resolve_classref(inline_env->method, cr, resolveLazy, true, &c)) return NULL; if (c) { - OP2AT(opcode, v, c->vftbl, BUILTIN_multianewarray, currentline); + OP2AT(opcode, v, c->vftbl, NULL, currentline); } else { - OP2AT(opcode, v, cr, asm_wrapper_patcher_BUILTIN_multianewarray, currentline); + OP2AT(opcode, v, cr, + (voidptr) (ptrint) PATCHER_builtin_multianewarray, + currentline); } -#else -/* vftbl *arrayvftbl = */ -/* ((classinfo *) class_getconstant(class, i, CONSTANT_Class))->vftbl; */ -/* OP2A(opcode, v, arrayvftbl,currentline); */ - - - cr = (constant_classref *) class_getconstant(inline_env->method->class, i, CONSTANT_Class); - - if (!resolve_classref_or_classinfo(inline_env->method, - CLASSREF_OR_CLASSINFO(cr),resolveEager,true,&component)) - return NULL; - - arrayvftbl = component->vftbl; - OP2A(opcode, v, arrayvftbl, currentline); - -/* classinfo *arrayclass = */ -/* (classinfo *) class_getconstant(class, i, CONSTANT_Class); */ -/* OP2A(opcode, v, arrayclass, currentline); */ -#endif } break; @@ -769,6 +758,7 @@ SHOWOPCODE(DEBUG4) debug_writebranch; i = label_index[i]; } + /*printf("GOTO: %d\n",i);*/ bound_check(i); block_insert(i); blockend = true; @@ -851,21 +841,25 @@ SHOWOPCODE(DEBUG4) blockend = true; nextp = ALIGN((p + 1), 4); - if (nextp + 8 > inline_env->method->jcodelength) - panic("Unexpected end of bytecode"); + + if (nextp + 8 > inline_env->method->jcodelength) { + log_text("Unexpected end of bytecode"); + assert(0); + } + if (!useinlining) { tablep = (s4 *) (inline_env->method->jcode + nextp); } else { - num = code_get_u4(nextp + 4,inline_env->method); + num = code_get_u4(nextp + 4, inline_env->method); tablep = DMNEW(s4, num * 2 + 2); } - OP2A(opcode, 0, tablep,currentline); + OP2A(opcode, 0, tablep, currentline); /* default target */ - j = p + code_get_s4(nextp,inline_env->method); + j = p + code_get_s4(nextp, inline_env->method); if (useinlining) j = label_index[j]; *tablep = j; /* restore for little endian */ @@ -876,18 +870,21 @@ SHOWOPCODE(DEBUG4) /* number of pairs */ - num = code_get_u4(nextp,inline_env->method); + num = code_get_u4(nextp, inline_env->method); *tablep = num; tablep++; nextp += 4; - if (nextp + 8*(num) > inline_env->method->jcodelength) - panic("Unexpected end of bytecode"); + if (nextp + 8 * num > inline_env->method->jcodelength) { + /* XXX TODO VerifyError */ + log_text("Unexpected end of bytecode"); + assert(0); + } for (i = 0; i < num; i++) { /* value */ - j = code_get_s4(nextp,inline_env->method); + j = code_get_s4(nextp, inline_env->method); *tablep = j; /* restore for little endian */ tablep++; nextp += 4; @@ -923,8 +920,12 @@ SHOWOPCODE(DEBUG4) blockend = true; nextp = ALIGN((p + 1), 4); - if (nextp + 12 > inline_env->method->jcodelength) - panic("Unexpected end of bytecode"); + if (nextp + 12 > inline_env->method->jcodelength) { + /* XXX TODO VerifyError */ + log_text("Unexpected end of bytecode"); + assert(0); + } + if (!useinlining) { tablep = (s4 *) (inline_env->method->jcode + nextp); @@ -933,11 +934,11 @@ SHOWOPCODE(DEBUG4) tablep = DMNEW(s4, num + 1 + 3); } - OP2A(opcode, 0, tablep,currentline); + OP2A(opcode, 0, tablep, currentline); /* default target */ - j = p + code_get_s4(nextp,inline_env->method); + j = p + code_get_s4(nextp, inline_env->method); if (useinlining) j = label_index[j]; *tablep = j; /* restore for little endian */ @@ -948,24 +949,31 @@ SHOWOPCODE(DEBUG4) /* lower bound */ - j = code_get_s4(nextp,inline_env->method); + j = code_get_s4(nextp, inline_env->method); *tablep = j; /* restore for little endian */ tablep++; nextp += 4; /* upper bound */ - num = code_get_s4(nextp,inline_env->method); + num = code_get_s4(nextp, inline_env->method); *tablep = num; /* restore for little endian */ tablep++; nextp += 4; num -= j; /* difference of upper - lower */ - if (num < 0) - panic("invalid TABLESWITCH: upper bound < lower bound"); - if (nextp + 4*(num+1) > inline_env->method->jcodelength) - panic("Unexpected end of bytecode"); + if (num < 0) { + /* XXX TODO VerifyError */ + log_text("invalid TABLESWITCH: upper bound < lower bound"); + assert(0); + } + + if (nextp + 4 * (num + 1) > inline_env->method->jcodelength) { + /* XXX TODO VerifyError */ + log_text("Unexpected end of bytecode"); + assert(0); + } for (i = 0; i <= num; i++) { j = p + code_get_s4(nextp,inline_env->method); @@ -993,19 +1001,15 @@ SHOWOPCODE(DEBUG4) case JAVA_GETSTATIC: case JAVA_PUTSTATIC: -#if defined(__X86_64__) || defined(__I386__) case JAVA_GETFIELD: case JAVA_PUTFIELD: -#endif i = code_get_u2(p + 1, inline_env->method); { constant_FMIref *fr; unresolved_field *uf; fieldinfo *fi; - classinfo *c; fr = class_getconstant(inline_env->method->class, i, CONSTANT_Fieldref); -#if defined(__X86_64__) || defined(__I386__) OP2A_NOINC(opcode, fr->parseddesc.fd->type, fr, currentline); if (!(uf = create_unresolved_field(inline_env->method->class, @@ -1027,72 +1031,26 @@ SHOWOPCODE(DEBUG4) iptr->val.a = fi; } PINC; -#else - { - classinfo *frclass; - if (!resolve_classref(inline_env->method,fr->classref,resolveEager,true,&frclass)) - return NULL; - - fi = class_resolvefield(frclass, - fr->name, - fr->descriptor, - inline_env->method->class, - true); - - if (!fi) - return NULL; - - OP2A(opcode, fi->type, fi, currentline); - if (!fi->class->initialized) { +#if defined(__MIPS__) || defined(__POWERPC__) + if (!fi || !fi->class->initialized) inline_env->method->isleafmethod = false; - } - } #endif } break; -#if !defined(__X86_64__) && !defined(__I386__) - case JAVA_PUTFIELD: - case JAVA_GETFIELD: - i = code_get_u2(p + 1,inline_env->method); - { - constant_FMIref *fr; - fieldinfo *fi; - classinfo *frclass; - - fr = class_getconstant(inline_env->method->class, i, CONSTANT_Fieldref); - if (!resolve_classref(inline_env->method,fr->classref,resolveEager,true,&frclass)) - return NULL; - - fi = class_resolvefield(frclass, - fr->name, - fr->descriptor, - inline_env->method->class, - true); - - if (!fi) - return NULL; - - OP2A(opcode, fi->type, fi, currentline); - } - break; -#endif - /* method invocation *****/ case JAVA_INVOKESTATIC: i = code_get_u2(p + 1, inline_env->method); { - constant_FMIref *mr; - methodinfo *mi; + constant_FMIref *mr; unresolved_method *um; - classinfo *mrclass; + methodinfo *mi; inline_env->method->isleafmethod = false; mr = class_getconstant(inline_env->method->class, i, CONSTANT_Methodref); -#if defined(__X86_64__) || defined(__I386__) OP2A_NOINC(opcode, mr->parseddesc.md->paramcount, mr, currentline); um = create_unresolved_method(inline_env->method->class, @@ -1116,33 +1074,6 @@ SHOWOPCODE(DEBUG4) iptr->val.a = mi; } PINC; -#else - if (!resolve_classref(inline_env->method,mr->classref,resolveEager,true,&mrclass)) - return NULL; - - mi = class_resolveclassmethod(mrclass, - mr->name, - mr->descriptor, - inline_env->method->class, - true); - - if (!mi) - return NULL; - -if (DEBUG4==true) { - method_display_w_class(mi); - printf("\tINVOKE STAT\n"); - fflush(stdout);} - - if (!(mi->flags & ACC_STATIC)) { - *exceptionptr = - new_exception(string_java_lang_IncompatibleClassChangeError); - return NULL; - } - - method_descriptor2types(mi); - OP2A(opcode, mi->paramcount, mi, currentline); -#endif } break; @@ -1150,15 +1081,13 @@ if (DEBUG4==true) { case JAVA_INVOKEVIRTUAL: i = code_get_u2(p + 1, inline_env->method); { - constant_FMIref *mr; - methodinfo *mi; + constant_FMIref *mr; unresolved_method *um; - classinfo *mrclass; + methodinfo *mi; inline_env->method->isleafmethod = false; mr = class_getconstant(inline_env->method->class, i, CONSTANT_Methodref); -#if defined(__X86_64__) || defined(__I386__) OP2A_NOINC(opcode, mr->parseddesc.md->paramcount + 1, mr, currentline); um = create_unresolved_method(inline_env->method->class, @@ -1182,48 +1111,19 @@ if (DEBUG4==true) { iptr->val.a = mi; } PINC; -#else - if (!resolve_classref(inline_env->method,mr->classref,resolveEager,true,&mrclass)) - return NULL; - - mi = class_resolveclassmethod(mrclass, - mr->name, - mr->descriptor, - inline_env->method->class, - true); - - if (!mi) - return NULL; - -if (DEBUG4==true) { - method_display_w_class(mi); - printf("\tINVOKE SPEC/VIRT\n"); - fflush(stdout);} - - if (mi->flags & ACC_STATIC) { - *exceptionptr = - new_exception(string_java_lang_IncompatibleClassChangeError); - return NULL; - } - - method_descriptor2types(mi); - OP2A(opcode, mi->paramcount, mi, currentline); -#endif } break; case JAVA_INVOKEINTERFACE: i = code_get_u2(p + 1,inline_env->method); { - constant_FMIref *mr; - methodinfo *mi; - classinfo *mrclass; + constant_FMIref *mr; unresolved_method *um; + methodinfo *mi; inline_env->method->isleafmethod = false; mr = class_getconstant(inline_env->method->class, i, CONSTANT_InterfaceMethodref); -#if defined(__X86_64__) || defined(__I386__) OP2A_NOINC(opcode, mr->parseddesc.md->paramcount + 1, mr, currentline); um = create_unresolved_method(inline_env->method->class, @@ -1247,32 +1147,6 @@ if (DEBUG4==true) { iptr->val.a = mi; } PINC; -#else - if (!resolve_classref(inline_env->method,mr->classref,resolveEager,true,&mrclass)) - return NULL; - - mi = class_resolveinterfacemethod(mrclass, - mr->name, - mr->descriptor, - inline_env->method->class, - true); - if (!mi) - return NULL; - - if (mi->flags & ACC_STATIC) { - *exceptionptr = - new_exception(string_java_lang_IncompatibleClassChangeError); - return NULL; - } - -if (DEBUG4==true) { - method_display_w_class(mi); - printf("\tINVOKE INTERFACE\n"); - fflush(stdout);} - - method_descriptor2types(mi); - OP2A(opcode, mi->paramcount, mi, currentline); -#endif } break; @@ -1281,38 +1155,27 @@ if (DEBUG4==true) { case JAVA_NEW: { constant_classref *cr; - classinfo *cls; + classinfo *c; -#if defined(__X86_64__) || defined(__I386__) i = code_get_u2(p + 1, inline_env->method); cr = (constant_classref *) class_getconstant(inline_env->method->class, i, CONSTANT_Class); - if (!resolve_classref(inline_env->method, cr, resolveLazy, true, &cls)) + if (!resolve_classref(inline_env->method, cr, resolveLazy, true, &c)) return NULL; /* can throw an exception over native code */ - if (cls && cls->initialized) { - LOADCONST_A_BUILTIN(cls); - BUILTIN1(BUILTIN_new, TYPE_ADR, currentline); + if (c && c->initialized) { + LOADCONST_A_BUILTIN(c); + BUILTIN1T(BUILTIN_new, TYPE_ADR, NULL, currentline); } else { LOADCONST_A_BUILTIN(cr); - BUILTIN1(asm_wrapper_patcher_BUILTIN_new, TYPE_ADR, currentline); + BUILTIN1T(PATCHER_builtin_new, TYPE_ADR, cr, currentline); } s_count++; OP(ICMD_CHECKEXCEPTION); -#else - i = code_get_u2(p + 1,inline_env->method); - cr = (constant_classref *) class_getconstant(inline_env->method->class, i, CONSTANT_Class); - if (!resolve_classref(inline_env->method,cr,resolveEager,true,&cls)) - return NULL; - LOADCONST_A_BUILTIN(cls); - s_count++; - BUILTIN1(BUILTIN_new, TYPE_ADR, currentline); - OP(ICMD_CHECKEXCEPTION); -#endif } break; @@ -1320,49 +1183,32 @@ if (DEBUG4==true) { i = code_get_u2(p + 1, inline_env->method); { constant_classref *cr; - classinfo *cls; + classinfo *c; cr = (constant_classref *) class_getconstant(inline_env->method->class, i, CONSTANT_Class); -#if defined(__X86_64__) || defined(__I386__) - if (!resolve_classref(inline_env->method, cr, resolveLazy, true, &cls)) + if (!resolve_classref(inline_env->method, cr, resolveLazy, true, &c)) return NULL; if (cr->name->text[0] == '[') { /* array type cast-check */ - if (cls) { - LOADCONST_A_BUILTIN(cls->vftbl); - BUILTIN2(BUILTIN_checkarraycast, TYPE_ADR, currentline); + if (c) { + LOADCONST_A_BUILTIN(c->vftbl); + BUILTIN2T(BUILTIN_arraycheckcast, TYPE_ADR, NULL, currentline); } else { LOADCONST_A_BUILTIN(cr); - BUILTIN2(asm_wrapper_patcher_BUILTIN_checkarraycast, TYPE_ADR, currentline); + BUILTIN2T(PATCHER_builtin_arraycheckcast, TYPE_ADR, cr, currentline); } s_count++; } else { /* object type cast-check */ - OP2AT(opcode, 1, cls, cr, currentline); - } -#else - if (!resolve_classref(inline_env->method, - cr,resolveEager,true,&cls)) - return NULL; - - if (cls->vftbl->arraydesc) { - /* array type cast-check */ - LOADCONST_A_BUILTIN(cls->vftbl); - s_count++; - BUILTIN2(BUILTIN_checkarraycast, TYPE_ADR,currentline); - - } else { /* object type cast-check */ - /* - + LOADCONST_A_BUILTIN(class_getconstant(class, i, CONSTANT_Class)); - + s_count++; - + BUILTIN2(BUILTIN_checkcast, TYPE_ADR,currentline); - + */ - OP2A(opcode, 1, cls, currentline); + OP2AT(opcode, 1, c, cr, currentline); } +#if defined(__MIPS__) || defined(__POWERPC__) + if (!c) + inline_env->method->isleafmethod = false; #endif } break; @@ -1371,49 +1217,32 @@ if (DEBUG4==true) { i = code_get_u2(p + 1,inline_env->method); { constant_classref *cr; - classinfo *cls; + classinfo *c; cr = (constant_classref *) class_getconstant(inline_env->method->class, i, CONSTANT_Class); -#if defined(__X86_64__) || defined(__I386__) - if (!resolve_classref(inline_env->method, cr, resolveLazy, true, &cls)) + if (!resolve_classref(inline_env->method, cr, resolveLazy, true, &c)) return NULL; if (cr->name->text[0] == '[') { /* array type cast-check */ - if (cls) { - LOADCONST_A_BUILTIN(cls->vftbl); - BUILTIN2(BUILTIN_arrayinstanceof, TYPE_INT, currentline); + if (c) { + LOADCONST_A_BUILTIN(c->vftbl); + BUILTIN2T(BUILTIN_arrayinstanceof, TYPE_INT, NULL, currentline); } else { LOADCONST_A_BUILTIN(cr); - BUILTIN2(asm_wrapper_patcher_BUILTIN_arrayinstanceof, TYPE_INT, currentline); + BUILTIN2T(PATCHER_builtin_arrayinstanceof, TYPE_INT, cr, currentline); } s_count++; } else { /* object type cast-check */ - OP2AT(opcode, 1, cls, cr, currentline); - } -#else - if (!resolve_classref(inline_env->method, - cr,resolveEager,true,&cls)) - return NULL; - - if (cls->vftbl->arraydesc) { - /* array type cast-check */ - LOADCONST_A_BUILTIN(cls->vftbl); - s_count++; - BUILTIN2(BUILTIN_arrayinstanceof, TYPE_INT, currentline); - } - else { /* object type cast-check */ - /* - LOADCONST_A_BUILTIN(class_getconstant(class, i, CONSTANT_Class)); - s_count++; - BUILTIN2(BUILTIN_instanceof, TYPE_INT,currentline); - + */ - OP2A(opcode, 1, cls, currentline); + OP2AT(opcode, 1, c, cr, currentline); } +#if defined(__MIPS__) || defined(__POWERPC__) + if (!c) + inline_env->method->isleafmethod = false; #endif } break; @@ -1421,19 +1250,20 @@ if (DEBUG4==true) { case JAVA_MONITORENTER: #if defined(USE_THREADS) if (checksync) { - BUILTIN1(BUILTIN_monitorenter, TYPE_VOID,currentline); + OP(ICMD_CHECKNULL); + BUILTIN1(BUILTIN_monitorenter, TYPE_VOID, currentline); } else #endif { - OP(ICMD_NULLCHECKPOP); + OP(ICMD_CHECKNULL); + OP(ICMD_POP); } break; case JAVA_MONITOREXIT: #if defined(USE_THREADS) if (checksync) { - BUILTIN1(BUILTIN_monitorexit, TYPE_VOID,currentline); - OP(ICMD_CHECKEXCEPTION); + BUILTIN1(BUILTIN_monitorexit, TYPE_VOID, currentline); } else #endif { @@ -1448,6 +1278,7 @@ if (DEBUG4==true) { break; case JAVA_IREM: + /*log_text("parse.c: adding IREM to bytecode list");*/ OP(opcode); break; @@ -1576,8 +1407,10 @@ if (DEBUG4==true) { case 253: case 254: case 255: - printf("Illegal opcode %d at instr %d\n", opcode, ipc); - panic("Illegal opcode encountered"); + *exceptionptr = + new_internalerror("Illegal opcode %d at instr %d\n", + opcode, ipc); + return NULL; break; default: @@ -1587,11 +1420,12 @@ if (DEBUG4==true) { } /* end switch */ /* If WIDE was used correctly, iswide should have been reset by now. */ - if (iswide && opcode != JAVA_WIDE) - panic("Illegal instruction: WIDE before incompatible opcode"); - - /* INLINING */ - + if (iswide && opcode != JAVA_WIDE) { + log_text("Illegal instruction: WIDE before incompatible opcode"); + assert(0); + } + +#if defined(USE_INLINING) /* if (inline_env->isinlinedmethod && p == inline_env->method->jcodelength - 1) { */ /* end of an inlined method */ if (inline_env->isinlinedmethod && (nextp >= inline_env->method->jcodelength) ) { /* end of an inlined method */ /* printf("setting gp from %d to %d\n",gp, inlinfo->stopgp); */ @@ -1612,14 +1446,17 @@ METHINFOt(inline_env->method,"AFTER RESTORE : ",DEBUG); label_index=inlinfo->label_index; firstlocal = inlinfo->firstlocal; } +#endif /* defined(USE_INLINING) */ } /* end for */ if (p != m->jcodelength) { printf("p (%d) != m->jcodelength (%d)\n",p,m->jcodelength); - panic("Command-sequence crosses code-boundary"); + log_text("Command-sequence crosses code-boundary"); + assert(0); } + if (!blockend) { *exceptionptr = new_verifyerror(m, "Falling off the end of the code"); return NULL; @@ -1668,11 +1505,15 @@ METHINFOt(inline_env->method,"AFTER RESTORE : ",DEBUG); for (p = 0; p < inline_env->cumjcodelength; p++) { /* for (p = 0; p < m->jcodelength; p++) { */ if (m->basicblockindex[p] & 1) { - /* check if this block starts at the beginning of an instruction */ + /* Check if this block starts at the beginning of an */ + /* instruction. */ + if (!instructionstart[p]) { - printf("Basic Block beginn: %d\n",p); - panic("Branch into middle of instruction"); + /* XXX TODO throw exception? which one? */ + dolog("Branch into middle of instruction: Basic Block beginn: %d\n", p); + assert(0); } + /* allocate the block */ bptr->iinstr = m->instructions + (m->basicblockindex[p] >> 1); bptr->debug_nr = m->c_debug_nr++; @@ -1723,8 +1564,11 @@ METHINFOt(inline_env->method,"AFTER RESTORE : ",DEBUG); cd->exceptiontable[i].handler = m->basicblocks + m->basicblockindex[p]; } } - - if (useinlining) inlining_cleanup(inline_env); + +#if defined(USE_INLINING) + if (useinlining) + inlining_cleanup(inline_env); +#endif /* just return methodinfo* to signal everything was ok */