- for (bref = cd->xcastrefs; bref != NULL; bref = bref->next) {
- gen_resolvebranch((u1 *) cd->mcodebase + bref->branchpos,
- bref->branchpos,
- (u1 *) mcodeptr - cd->mcodebase);
-
- MCODECHECK(100);
-
- M_LDA(REG_ITMP2_XPC, REG_PV, bref->branchpos - 4);
-
- if (xcodeptr != NULL) {
- disp = xcodeptr - mcodeptr - 1;
- M_BR(disp);
-
- } else {
- xcodeptr = mcodeptr;
-
- if (m->isleafmethod) {
- M_MFLR(REG_ZERO);
- M_AST(REG_ZERO, REG_SP, parentargs_base * 4 + LA_LR_OFFSET);
- }
-
- M_MOV(REG_PV, rd->argintregs[0]);
- M_MOV(REG_SP, rd->argintregs[1]);
-
- if (m->isleafmethod)
- M_MOV(REG_ZERO, rd->argintregs[2]);
- else
- M_ALD(rd->argintregs[2],
- REG_SP, parentargs_base * 4 + LA_LR_OFFSET);
-
- M_MOV(REG_ITMP2_XPC, rd->argintregs[3]);
-
- M_STWU(REG_SP, REG_SP, -(LA_SIZE + 5 * 4));
- M_AST(REG_ITMP2_XPC, REG_SP, LA_SIZE + 4 * 4);
-
- disp = dseg_addaddress(cd, stacktrace_inline_classcastexception);
- M_ALD(REG_ITMP1, REG_PV, disp);
- M_MTCTR(REG_ITMP1);
- M_JSR;
- M_MOV(REG_RESULT, REG_ITMP1_XPTR);
-
- M_ALD(REG_ITMP2_XPC, REG_SP, LA_SIZE + 4 * 4);
- M_IADD_IMM(REG_SP, LA_SIZE + 5 * 4, REG_SP);
-
- if (m->isleafmethod) {
- M_ALD(REG_ZERO, REG_SP, parentargs_base * 4 + LA_LR_OFFSET);
- M_MTLR(REG_ZERO);
- }
-
- disp = dseg_addaddress(cd, asm_handle_exception);
- M_ALD(REG_ITMP3, REG_PV, disp);
- M_MTCTR(REG_ITMP3);
- M_RTS;
- }
- }
-
- /* generate NullPointerException stubs */
-
- xcodeptr = NULL;
-
- for (bref = cd->xnullrefs; bref != NULL; bref = bref->next) {
- gen_resolvebranch((u1 *) cd->mcodebase + bref->branchpos,
- bref->branchpos,
- (u1 *) mcodeptr - cd->mcodebase);
-
- MCODECHECK(100);
-
- M_LDA(REG_ITMP2_XPC, REG_PV, bref->branchpos - 4);
-
- if (xcodeptr != NULL) {
- disp = xcodeptr - mcodeptr - 1;
- M_BR(disp);
-
- } else {
- xcodeptr = mcodeptr;
-
- if (m->isleafmethod) {
- M_MFLR(REG_ZERO);
- M_AST(REG_ZERO, REG_SP, parentargs_base * 4 + LA_LR_OFFSET);
- }
-
- M_MOV(REG_PV, rd->argintregs[0]);
- M_MOV(REG_SP, rd->argintregs[1]);
-
- if (m->isleafmethod)
- M_MOV(REG_ZERO, rd->argintregs[2]);
- else
- M_ALD(rd->argintregs[2],
- REG_SP, parentargs_base * 4 + LA_LR_OFFSET);
-
- M_MOV(REG_ITMP2_XPC, rd->argintregs[3]);
-
- M_STWU(REG_SP, REG_SP, -(LA_SIZE + 5 * 4));
- M_AST(REG_ITMP2_XPC, REG_SP, LA_SIZE + 4 * 4);
-
- disp = dseg_addaddress(cd, stacktrace_inline_nullpointerexception);
- M_ALD(REG_ITMP1, REG_PV, disp);
- M_MTCTR(REG_ITMP1);
- M_JSR;
- M_MOV(REG_RESULT, REG_ITMP1_XPTR);
-
- M_ALD(REG_ITMP2_XPC, REG_SP, LA_SIZE + 4 * 4);
- M_IADD_IMM(REG_SP, LA_SIZE + 5 * 4, REG_SP);
-
- if (m->isleafmethod) {
- M_ALD(REG_ZERO, REG_SP, parentargs_base * 4 + LA_LR_OFFSET);
- M_MTLR(REG_ZERO);
- }
-
- disp = dseg_addaddress(cd, asm_handle_exception);
- M_ALD(REG_ITMP3, REG_PV, disp);
- M_MTCTR(REG_ITMP3);
- M_RTS;
- }
- }
-
- /* generate exception check stubs */
-
- xcodeptr = NULL;
-
- for (bref = cd->xexceptionrefs; bref != NULL; bref = bref->next) {
- gen_resolvebranch((u1 *) cd->mcodebase + bref->branchpos,
- bref->branchpos,
- (u1 *) mcodeptr - cd->mcodebase);
-
- MCODECHECK(100);
-
- M_LDA(REG_ITMP2_XPC, REG_PV, bref->branchpos - 4);
-
- if (xcodeptr != NULL) {
- disp = xcodeptr - mcodeptr - 1;
- M_BR(disp);
-
- } 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 * 4 + LA_LR_OFFSET);
- M_MOV(REG_ITMP2_XPC, rd->argintregs[3]);
-
- M_STWU(REG_SP, REG_SP, -(LA_SIZE + 5 * 4));
- M_AST(REG_ITMP2_XPC, REG_SP, LA_SIZE + 4 * 4);
-
- disp = dseg_addaddress(cd, stacktrace_inline_fillInStackTrace);
- M_ALD(REG_ITMP1, REG_PV, disp);
- M_MTCTR(REG_ITMP1);
- M_JSR;
- M_MOV(REG_RESULT, REG_ITMP1_XPTR);
-
- M_ALD(REG_ITMP2_XPC, REG_SP, LA_SIZE + 4 * 4);
- M_IADD_IMM(REG_SP, LA_SIZE + 5 * 4, REG_SP);
-
- disp = dseg_addaddress(cd, asm_handle_exception);
- M_ALD(REG_ITMP3, REG_PV, disp);
- M_MTCTR(REG_ITMP3);
- M_RTS;
- }
- }
-
- /* generate patcher stub call code */
-
- {
- patchref *pref;
- u4 mcode;
- s4 *tmpmcodeptr;
-
- for (pref = cd->patchrefs; pref != NULL; pref = pref->next) {
- /* check code segment size */
-
- MCODECHECK(16);
-
- /* Get machine code which is patched back in later. The call is */
- /* 1 instruction word long. */
-
- xcodeptr = (s4 *) (cd->mcodebase + pref->branchpos);
- mcode = *xcodeptr;
-
- /* patch in the call to call the following code (done at compile */
- /* time) */
-
- tmpmcodeptr = mcodeptr; /* save current mcodeptr */
- mcodeptr = xcodeptr; /* set mcodeptr to patch position */
-
- M_BR(tmpmcodeptr - (xcodeptr + 1));
-
- mcodeptr = tmpmcodeptr; /* restore the current mcodeptr */
-
- /* create stack frame - keep stack 16-byte aligned */
-
- M_AADD_IMM(REG_SP, -8 * 4, REG_SP);
-
- /* calculate return address and move it onto the stack */
-
- M_LDA(REG_ITMP3, REG_PV, pref->branchpos);
- M_AST_INTERN(REG_ITMP3, REG_SP, 5 * 4);
-
- /* move pointer to java_objectheader onto stack */
-
-#if defined(USE_THREADS) && defined(NATIVE_THREADS)
- /* order reversed because of data segment layout */
-
- (void) dseg_addaddress(cd, get_dummyLR()); /* monitorPtr */
- disp = dseg_addaddress(cd, NULL); /* vftbl */
-
- M_LDA(REG_ITMP3, REG_PV, disp);
- M_AST_INTERN(REG_ITMP3, REG_SP, 4 * 4);
-#else
- /* do nothing */
-#endif
-
- /* move machine code onto stack */
-
- disp = dseg_adds4(cd, mcode);
- M_ILD(REG_ITMP3, REG_PV, disp);
- M_IST_INTERN(REG_ITMP3, REG_SP, 3 * 4);
-
- /* move class/method/field reference onto stack */
-
- disp = dseg_addaddress(cd, pref->ref);
- M_ALD(REG_ITMP3, REG_PV, disp);
- M_AST_INTERN(REG_ITMP3, REG_SP, 2 * 4);
-
- /* move data segment displacement onto stack */
-
- disp = dseg_addaddress(cd, pref->disp);
- M_ILD(REG_ITMP3, REG_PV, disp);
- M_IST_INTERN(REG_ITMP3, REG_SP, 1 * 4);