X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=src%2Fvm%2Fjit%2Falpha%2Fcodegen.c;h=ebd3e527627e76ccb6d1ce5f753d9baebb321922;hb=7cd8277a5e97e742eb461185416b39afd8653149;hp=977e1e847b0c7bf47de2ae94d436233b01c688a6;hpb=4f7b43c90465f1f8140b2bba541a09c0f6ef1574;p=cacao.git diff --git a/src/vm/jit/alpha/codegen.c b/src/vm/jit/alpha/codegen.c index 977e1e847..ebd3e5276 100644 --- a/src/vm/jit/alpha/codegen.c +++ b/src/vm/jit/alpha/codegen.c @@ -31,7 +31,7 @@ Christian Thalinger Christian Ullrich - $Id: codegen.c 3109 2005-07-24 23:07:02Z twisti $ + $Id: codegen.c 3345 2005-10-04 22:14:53Z twisti $ */ @@ -39,6 +39,7 @@ #include #include "config.h" +#include "vm/types.h" #include "md.h" #include "md-abi.h" @@ -46,8 +47,6 @@ #include "vm/jit/alpha/arch.h" #include "vm/jit/alpha/codegen.h" -#include "vm/jit/alpha/types.h" -#include "vm/jit/alpha/asmoffsets.h" #include "cacao/cacao.h" #include "native/native.h" @@ -3095,7 +3094,7 @@ nowperformreturn: } gen_method: - s3 = iptr->op1; + s3 = md->paramcount; MCODECHECK((s3 << 1) + 64); @@ -3144,6 +3143,16 @@ gen_method: d = md->returntype.type; M_ALD(REG_PV, REG_PV, disp); /* Pointer to built-in-function */ + M_JSR(REG_RA, REG_PV); + disp = (s4) ((u1 *) mcodeptr - cd->mcodebase); + M_LDA(REG_PV, REG_RA, -disp); + + /* if op1 == true, we need to check for an exception */ + + if (iptr->op1 == true) { + M_BEQZ(REG_RESULT, 0); + codegen_addxexceptionrefs(cd, mcodeptr); + } break; case ICMD_INVOKESPECIAL: @@ -3171,6 +3180,9 @@ gen_method: } M_ALD(REG_PV, REG_PV, disp); /* method pointer in r27 */ + M_JSR(REG_RA, REG_PV); + disp = (s4) ((u1 *) mcodeptr - cd->mcodebase); + M_LDA(REG_PV, REG_RA, -disp); break; case ICMD_INVOKEVIRTUAL: @@ -3197,6 +3209,9 @@ gen_method: M_ALD(REG_METHODPTR, rd->argintregs[0], OFFSET(java_objectheader, vftbl)); M_ALD(REG_PV, REG_METHODPTR, s1); + M_JSR(REG_RA, REG_PV); + disp = (s4) ((u1 *) mcodeptr - cd->mcodebase); + M_LDA(REG_PV, REG_RA, -disp); break; case ICMD_INVOKEINTERFACE: @@ -3228,13 +3243,12 @@ gen_method: OFFSET(java_objectheader, vftbl)); M_ALD(REG_METHODPTR, REG_METHODPTR, s1); M_ALD(REG_PV, REG_METHODPTR, s2); + M_JSR(REG_RA, REG_PV); + disp = (s4) ((u1 *) mcodeptr - cd->mcodebase); + M_LDA(REG_PV, REG_RA, -disp); break; } - M_JSR(REG_RA, REG_PV); - disp = (s4) ((u1 *) mcodeptr - cd->mcodebase); - M_LDA(REG_PV, REG_RA, -disp); - /* d contains return type */ if (d != TYPE_VOID) { @@ -3593,20 +3607,6 @@ gen_method: } break; - - case ICMD_CHECKASIZE: /* ..., size ==> ..., size */ - - var_to_reg_int(s1, src, REG_ITMP1); - M_BLTZ(s1, 0); - codegen_addxcheckarefs(cd, mcodeptr); - break; - - case ICMD_CHECKEXCEPTION: /* ... ==> ... */ - - M_BEQZ(REG_RESULT, 0); - codegen_addxexceptionrefs(cd, mcodeptr); - break; - case ICMD_MULTIANEWARRAY:/* ..., cnt1, [cnt2, ...] ==> ..., arrayref */ /* op1 = dimension, val.a = array descriptor */ @@ -3615,13 +3615,10 @@ gen_method: MCODECHECK((iptr->op1 << 1) + 64); for (s1 = iptr->op1; --s1 >= 0; src = src->prev) { - var_to_reg_int(s2, src, REG_ITMP1); - M_BLTZ(s2, 0); - codegen_addxcheckarefs(cd, mcodeptr); - /* copy SAVEDVAR sizes to stack */ if (src->varkind != ARGVAR) { + var_to_reg_int(s2, src, REG_ITMP1); M_LST(s2, REG_SP, s1 * 8); } } @@ -3660,6 +3657,11 @@ gen_method: disp = (s4) ((u1 *) mcodeptr - cd->mcodebase); M_LDA(REG_PV, REG_RA, -disp); + /* check for exception before result assignment */ + + M_BEQZ(REG_RESULT, 0); + codegen_addxexceptionrefs(cd, mcodeptr); + d = reg_of_var(rd, iptr->dst, REG_RESULT); M_INTMOVE(REG_RESULT, d); store_reg_to_var_int(iptr->dst, d); @@ -3734,7 +3736,8 @@ gen_method: M_LDA(REG_ITMP2_XPC, REG_PV, bref->branchpos - 4); if (xcodeptr != NULL) { - M_BR(xcodeptr - mcodeptr - 1); + disp = xcodeptr - mcodeptr - 1; + M_BR(disp); } else { xcodeptr = mcodeptr; @@ -3782,7 +3785,8 @@ gen_method: M_LDA(REG_ITMP2_XPC, REG_PV, bref->branchpos - 4); if (xcodeptr != NULL) { - M_BR(xcodeptr - mcodeptr - 1); + disp = xcodeptr - mcodeptr - 1; + M_BR(disp); } else { xcodeptr = mcodeptr; @@ -3846,7 +3850,8 @@ gen_method: M_LDA(REG_ITMP2_XPC, REG_PV, bref->branchpos - 4); if (xcodeptr != NULL) { - M_BR(xcodeptr - mcodeptr - 1); + disp = xcodeptr - mcodeptr - 1; + M_BR(disp); } else { xcodeptr = mcodeptr; @@ -3898,7 +3903,8 @@ gen_method: M_LDA(REG_ITMP2_XPC, REG_PV, bref->branchpos - 4); if (xcodeptr != NULL) { - M_BR(xcodeptr - mcodeptr - 1); + disp = xcodeptr - mcodeptr - 1; + M_BR(disp); } else { xcodeptr = mcodeptr; @@ -3940,58 +3946,6 @@ gen_method: } } - /* generate NegativeArraySizeException stubs */ - - xcodeptr = NULL; - - for (bref = cd->xcheckarefs; bref != NULL; bref = bref->next) { - if ((cd->exceptiontablelength == 0) && (xcodeptr != NULL)) { - gen_resolvebranch((u1 *) cd->mcodebase + bref->branchpos, - bref->branchpos, - (u1 *) xcodeptr - (u1 *) cd->mcodebase - 4); - continue; - } - - gen_resolvebranch((u1 *) cd->mcodebase + bref->branchpos, - bref->branchpos, - (u1 *) mcodeptr - cd->mcodebase); - - MCODECHECK(16); - - M_LDA(REG_ITMP2_XPC, REG_PV, bref->branchpos - 4); - - if (xcodeptr != NULL) { - M_BR(xcodeptr - mcodeptr - 1); - - } else { - xcodeptr = mcodeptr; - - M_MOV(REG_PV, rd->argintregs[0]); - M_MOV(REG_SP, rd->argintregs[1]); - M_ALD(rd->argintregs[2], - REG_SP, parentargs_base * 8 - SIZEOF_VOID_P); - M_MOV(REG_ITMP2_XPC, rd->argintregs[3]); - - M_LDA(REG_SP, REG_SP, -2 * 8); - M_AST(REG_ITMP2_XPC, REG_SP, 0 * 8); - - disp = dseg_addaddress(cd, stacktrace_inline_negativearraysizeexception); - M_ALD(REG_PV, REG_PV, disp); - M_JSR(REG_RA, REG_PV); - disp = (s4) ((u1 *) mcodeptr - cd->mcodebase); - M_LDA(REG_PV, REG_RA, -disp); - - M_MOV(REG_RESULT, REG_ITMP1_XPTR); - - M_ALD(REG_ITMP2_XPC, REG_SP, 0 * 8); - M_LDA(REG_SP, REG_SP, 2 * 8); - - disp = dseg_addaddress(cd, asm_handle_exception); - M_ALD(REG_ITMP3, REG_PV, disp); - M_JMP(REG_ZERO, REG_ITMP3); - } - } - /* generate NullPointerException stubs */ xcodeptr = NULL; @@ -4013,7 +3967,8 @@ gen_method: M_LDA(REG_ITMP2_XPC, REG_PV, bref->branchpos - 4); if (xcodeptr != NULL) { - M_BR(xcodeptr - mcodeptr - 1); + disp = xcodeptr - mcodeptr - 1; + M_BR(disp); } else { xcodeptr = mcodeptr; @@ -4055,7 +4010,7 @@ gen_method: } } - /* generate ICMD_CHECKEXCEPTION stubs */ + /* generate exception check stubs */ xcodeptr = NULL; @@ -4076,7 +4031,8 @@ gen_method: M_LDA(REG_ITMP2_XPC, REG_PV, bref->branchpos - 4); if (xcodeptr != NULL) { - M_BR(xcodeptr - mcodeptr - 1); + disp = xcodeptr - mcodeptr - 1; + M_BR(disp); } else { xcodeptr = mcodeptr; @@ -4370,7 +4326,8 @@ functionptr createnativestub(functionptr f, methodinfo *m, codegendata *cd, /* create native stackframe info */ - M_AADD_IMM(REG_SP, stackframesize * 8 - sizeof(stackframeinfo), + M_AADD_IMM(REG_SP, + stackframesize * 8 - SIZEOF_VOID_P - sizeof(stackframeinfo), rd->argintregs[0]); M_MOV(REG_PV, rd->argintregs[1]); M_AADD_IMM(REG_SP, stackframesize * 8, rd->argintregs[2]); @@ -4470,15 +4427,17 @@ functionptr createnativestub(functionptr f, methodinfo *m, codegendata *cd, disp = (s4) ((u1 *) mcodeptr - cd->mcodebase); M_LDA(REG_PV, REG_RA, -disp); /* recompute pv from ra */ - - /* remove native stackframe info */ + /* save return value */ if (IS_INT_LNG_TYPE(md->returntype.type)) M_LST(REG_RESULT, REG_SP, 0 * 8); else M_DST(REG_FRESULT, REG_SP, 0 * 8); - M_AADD_IMM(REG_SP, stackframesize * 8 - sizeof(stackframeinfo), + /* remove native stackframe info */ + + M_AADD_IMM(REG_SP, + stackframesize * 8 - SIZEOF_VOID_P - sizeof(stackframeinfo), rd->argintregs[0]); disp = dseg_addaddress(cd, stacktrace_remove_stackframeinfo); M_ALD(REG_PV, REG_PV, disp); @@ -4486,18 +4445,9 @@ functionptr createnativestub(functionptr f, methodinfo *m, codegendata *cd, disp = (s4) ((u1 *) mcodeptr - cd->mcodebase); M_LDA(REG_PV, REG_RA, -disp); - if (IS_INT_LNG_TYPE(md->returntype.type)) - M_LLD(REG_RESULT, REG_SP, 0 * 8); - else - M_DLD(REG_FRESULT, REG_SP, 0 * 8); - - /* call finished trace */ if (runverbose) { - M_LST(REG_RESULT, REG_SP, 0 * 8); - M_DST(REG_FRESULT, REG_SP, 1 * 8); - disp = dseg_addaddress(cd, m); M_ALD(rd->argintregs[0], REG_PV, disp); @@ -4510,43 +4460,34 @@ functionptr createnativestub(functionptr f, methodinfo *m, codegendata *cd, M_JSR(REG_RA, REG_PV); disp = (s4) ((u1 *) mcodeptr - cd->mcodebase); M_LDA(REG_PV, REG_RA, -disp); - - M_LLD(REG_RESULT, REG_SP, 0 * 8); - M_DLD(REG_FRESULT, REG_SP, 1 * 8); } - /* check for exception */ #if defined(USE_THREADS) && defined(NATIVE_THREADS) - if (IS_FLT_DBL_TYPE(md->returntype.type)) - M_DST(REG_FRESULT, REG_SP, 0 * 8); - else - M_AST(REG_RESULT, REG_SP, 0 * 8); - disp = dseg_addaddress(cd, builtin_get_exceptionptrptr); M_ALD(REG_PV, REG_PV, disp); M_JSR(REG_RA, REG_PV); disp = (s4) ((u1 *) mcodeptr - cd->mcodebase); M_LDA(REG_PV, REG_RA, -disp); M_MOV(REG_RESULT, REG_ITMP3); - - if (IS_FLT_DBL_TYPE(md->returntype.type)) - M_DLD(REG_FRESULT, REG_SP, 0 * 8); - else - M_ALD(REG_RESULT, REG_SP, 0 * 8); #else disp = dseg_addaddress(cd, &_exceptionptr); - M_ALD(REG_ITMP3, REG_PV, disp); /* get address of exceptionptr */ + M_ALD(REG_RESULT, REG_PV, disp); /* get address of exceptionptr */ #endif - M_ALD(REG_ITMP1, REG_ITMP3, 0); /* load exception into reg. itmp1 */ + + /* restore return value */ + + if (IS_INT_LNG_TYPE(md->returntype.type)) + M_LLD(REG_RESULT, REG_SP, 0 * 8); + else + M_DLD(REG_FRESULT, REG_SP, 0 * 8); + M_BNEZ(REG_ITMP1, 3); /* if no exception then return */ M_ALD(REG_RA, REG_SP, (stackframesize - 1) * 8); /* load return address */ - M_LDA(REG_SP, REG_SP, stackframesize * 8); - M_RET(REG_ZERO, REG_RA); /* return to caller */ /* handle exception */