}
-/* emit_exception_stubs ********************************************************
-
- Generates the code for the exception stubs.
-
-*******************************************************************************/
-
-#if 0
-void emit_exception_stubs(jitdata *jd)
-{
- codegendata *cd;
- registerdata *rd;
- exceptionref *er;
- s4 branchmpc;
- s4 targetmpc;
- s4 targetdisp;
- s4 disp;
-
- /* get required compiler data */
-
- cd = jd->cd;
- rd = jd->rd;
-
- /* generate exception stubs */
-
- targetdisp = 0;
-
- for (er = cd->exceptionrefs; er != NULL; er = er->next) {
- /* back-patch the branch to this exception code */
-
- branchmpc = er->branchmpc;
- targetmpc = cd->mcodeptr - cd->mcodebase;
-
- md_codegen_patch_branch(cd, branchmpc, targetmpc);
-
- MCODECHECK(100);
-
- /* Check if the exception is an
- ArrayIndexOutOfBoundsException. If so, move index register
- into REG_ITMP1. */
-
- if (er->reg != -1)
- M_MOV(REG_ITMP1, er->reg);
-
- /* calcuate exception address */
-
- assert((er->branchmpc - 4) % 4 == 0);
- M_ADD_IMM_EXT_MUL4(REG_ITMP2_XPC, REG_PV, (er->branchmpc - 4) / 4);
-
- /* move function to call into REG_ITMP3 */
-
- disp = dseg_add_functionptr(cd, er->function);
- M_DSEG_LOAD(REG_ITMP3, disp);
-
- if (targetdisp == 0) {
- targetdisp = ((u4 *) cd->mcodeptr) - ((u4 *) cd->mcodebase);
-
- M_MOV(rd->argintregs[0], REG_PV);
- M_MOV(rd->argintregs[1], REG_SP);
-
- if (jd->isleafmethod)
- M_MOV(rd->argintregs[2], REG_LR);
- else
- M_LDR(rd->argintregs[2], REG_SP,
- cd->stackframesize * 4 - SIZEOF_VOID_P);
-
- M_MOV(rd->argintregs[3], REG_ITMP2_XPC);
-
- /* save registers */
- /* TODO: we only need to save LR in leaf methods */
-
- M_STMFD(BITMASK_ARGS | 1<<REG_PV | 1<<REG_LR, REG_SP);
-
- /* move a3 to stack */
-
- M_STR_UPDATE(REG_ITMP1, REG_SP, -4);
-
- /* do the exception call */
-
- M_MOV(REG_LR, REG_PC);
- M_MOV(REG_PC, REG_ITMP3);
-
- M_ADD_IMM(REG_SP, REG_SP, 4);
-
- /* result of stacktrace is our XPTR */
-
- M_MOV(REG_ITMP1_XPTR, REG_RESULT);
-
- /* restore registers */
-
- M_LDMFD(BITMASK_ARGS | 1<<REG_PV | 1<<REG_LR, REG_SP);
-
- disp = dseg_add_functionptr(cd, asm_handle_exception);
- M_DSEG_LOAD(REG_ITMP3, disp);
- M_MOV(REG_PC, REG_ITMP3);
- }
- else {
- disp = (((u4 *) cd->mcodebase) + targetdisp) -
- (((u4 *) cd->mcodeptr) + 2);
-
- M_B(disp);
- }
- }
-}
-#endif
-
-
/* emit_patcher_stubs **********************************************************
Generates the code for the patcher stubs.
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
- $Id: md.c 7596 2007-03-28 21:05:53Z twisti $
+ $Id: md.c 7653 2007-04-03 14:34:23Z twisti $
*/
}
-/* md_codegen_patch_branch *****************************************************
-
- Back-patches a branch instruction.
-
-*******************************************************************************/
-
-void md_codegen_patch_branch(codegendata *cd, s4 branchmpc, s4 targetmpc)
-{
- s4 *mcodeptr;
- s4 disp; /* branch displacement */
-
- /* calculate the patch position */
-
- mcodeptr = (s4 *) (cd->mcodebase + branchmpc);
-
- /* Calculate the branch displacement. */
-
- disp = (targetmpc - branchmpc - 4) >> 2;
-
- if ((disp < (s4) 0xff000000) || (disp > (s4) 0x00ffffff))
- vm_abort("md_codegen_patch_branch: branch displacement out of range: %d > +/-%d", disp, 0x00ffffff);
-
- /* sanity check: are we really patching a branch instruction */
-
- assert((mcodeptr[-1] & 0x0e000000) == 0x0a000000);
-
- /* patch the branch instruction before the mcodeptr */
-
- mcodeptr[-1] |= (disp & 0x00ffffff);
-}
-
-
/* md_stacktrace_get_returnaddress *********************************************
Returns the return address of the current stackframe, specified by
{
u1 *ra;
- /*printf("md_stacktrace_get_returnaddress(): called (sp=%x, framesize=%d)\n", sp, framesize);*/
+ /* On ARM the return address is located on the top of the
+ stackframe. */
+ /* ATTENTION: This is only true for non-leaf methods!!! */
- /* on ARM the return address is located on the top of the stackframe */
- /* ATTENTION: this is only true for non-leaf methods !!! */
ra = *((u1 **) (sp + framesize - SIZEOF_VOID_P));
- /*printf("md_stacktrace_get_returnaddress(): result (ra=%x)\n", ra);*/
-
return ra;
}