From d86bbab248e7c905cf9e9cb200aa7bbdcfeb0c4b Mon Sep 17 00:00:00 2001 From: ajordan Date: Wed, 27 Dec 2006 21:13:42 +0000 Subject: [PATCH] * src/vm/jit/sparc64/asmpart.S: Some fixes for exception handling. * src/vm/jit/sparc64/codegen.c: Likewise. --- src/vm/jit/sparc64/asmpart.S | 22 ++++++++++++++++------ src/vm/jit/sparc64/codegen.c | 29 ++++++++++++++++------------- 2 files changed, 32 insertions(+), 19 deletions(-) diff --git a/src/vm/jit/sparc64/asmpart.S b/src/vm/jit/sparc64/asmpart.S index 3d008a5ac..b72ee1302 100644 --- a/src/vm/jit/sparc64/asmpart.S +++ b/src/vm/jit/sparc64/asmpart.S @@ -144,7 +144,10 @@ calljava_copyloop: bnz %xcc, calljava_copyloop calljava_nocopy: - + /* set pv, like a java method does */ + /* add ra_caller,(asm_vm_call_method - calljava_nocopy + 8),pv_callee */ + setx asm_vm_call_method,%l0,pv_callee + mov %i0,itmp1 /* pass method info pointer via itmp1 */ setx asm_call_jit_compiler,%l0,mptr_itmp2 /* fake virtual function call (2 instr) */ @@ -156,7 +159,7 @@ calljava_nocopy: nop calljava_jit2: /* pretend to restore pv */ - add ra_caller,(asm_vm_call_method - calljava_jit2 + 8),pv_callee + add ra_caller,(asm_vm_call_method - calljava_jit2 + 8),zero calljava_return: mov %o0, %i0 /* pass on the return value */ @@ -166,7 +169,11 @@ calljava_return: asm_vm_call_method_exception_handler: - mov itmp1,%o0 + /* so far this function did not call any c functions */ + /* but now we need ABI compliant argslots on the stack */ + sub %sp,6*8,%sp + + mov xptr_itmp2,%o0 call builtin_throw_exception nop return %i7 + 8 /* implicit window restore */ @@ -326,7 +333,7 @@ L_asm_handle_exception_not_caught: restore /* unwind stack and window */ ba L_asm_handle_exception_stack_loop - mov xpc_itmp3,ra_caller /* the new xpc is ra (delay) */ + mov ra_caller,xpc_itmp3 /* the new xpc is ra (delay) */ @@ -396,6 +403,7 @@ asm_patcher_wrapper: mov %l1,itmp2 /* restore itmp2 */ brnz %o0,L_asm_patcher_wrapper_exception + nop /* load RA (patch position from patcher data on the stack */ ldx [%fp+USESTACK+5*8],itmp3 @@ -404,9 +412,10 @@ asm_patcher_wrapper: restore %fp,6*8,%sp /* (source regs refer to old window, rd to new window) */ jmpl itmp3,zero /* jump to newly patched code */ + nop L_asm_patcher_wrapper_exception: - mov itmp3,xptr_itmp2 /* get exception */ + mov %o0,xptr_itmp2 /* get exception */ ldx [%fp+USESTACK+5*8],xpc_itmp3 /* xpc is RA */ restore %fp,6*8,%sp /* remove stack frame */ ba asm_handle_exception @@ -424,7 +433,8 @@ _crit_end: stw itmp1,[offcast_super_baseval+%o2] stw itmp2,[offcast_super_diffval+%o2] stw itmp3,[offcast_sub_baseval+%o2] - jmpl ra_caller,zero /* caller's ra, b/c no window save */ + jmpl ra_caller+8,zero /* caller's ra, b/c no window save */ + nop .end asm_getclassvalues_atomic diff --git a/src/vm/jit/sparc64/codegen.c b/src/vm/jit/sparc64/codegen.c index 1b5069813..13ffba146 100644 --- a/src/vm/jit/sparc64/codegen.c +++ b/src/vm/jit/sparc64/codegen.c @@ -337,17 +337,17 @@ bool codegen(jitdata *jd) } else { #endif while (len) { - len--; + len--; var = VAR(bptr->invars[len]); if ((len == bptr->indepth-1) && (bptr->type == BBTYPE_EXH)) { d = codegen_reg_of_var(0, var, REG_ITMP1); - M_INTMOVE(REG_ITMP1, d); + M_INTMOVE(REG_ITMP1, d); emit_store(jd, NULL, var, d); - } + } else { assert((var->flags & INOUT)); - } - } + } + } #if defined(ENABLE_LSRA) } #endif @@ -1777,18 +1777,15 @@ bool codegen(jitdata *jd) #ifdef ENABLE_VERIFIER if (INSTRUCTION_IS_UNRESOLVED(iptr)) { - codegen_addpatchref(cd, PATCHER_athrow_areturn, - iptr->sx.s23.s2.uc, 0); + uc = iptr->sx.s23.s2.uc; - if (opt_showdisassemble) { - M_NOP; M_NOP; - } + codegen_add_patch_ref(cd, PATCHER_athrow_areturn, uc, 0); } #endif /* ENABLE_VERIFIER */ disp = dseg_add_functionptr(cd, asm_handle_exception); - M_ALD(REG_ITMP2, REG_PV, disp); - M_JMP(REG_ITMP3_XPC, REG_ITMP2, REG_ZERO); + M_ALD(REG_ITMP1, REG_PV, disp); + M_JMP(REG_ITMP3_XPC, REG_ITMP1, REG_ZERO); M_NOP; M_NOP; /* nop ensures that XPC is less than the end */ /* of basic block */ @@ -3083,17 +3080,23 @@ u1 *createnativestub(functionptr f, jitdata *jd, methoddesc *nmd) /* check for exception */ M_BNEZ(REG_ITMP2_XPTR, 4); /* if no exception then return */ + M_NOP; + + M_RETURN(REG_RA_CALLEE, 8); /* implicit window restore */ + M_NOP; +#if 0 M_RESTORE(REG_ZERO, 0, REG_ZERO); /* restore callers window (DELAY) */ M_RET(REG_RA_CALLER, 8); /* return to caller */ M_NOP; /* DELAY SLOT */ +#endif /* handle exception */ disp = dseg_add_functionptr(cd, asm_handle_nat_exception); M_ALD(REG_ITMP3, REG_PV, disp); /* load asm exception handler address */ M_JMP(REG_ZERO, REG_ITMP3, REG_ZERO);/* jump to asm exception handler */ - M_MOV(REG_RA_CALLER, REG_ITMP3_XPC); /* get exception address (DELAY) */ + M_MOV(REG_RA_CALLEE, REG_ITMP3_XPC); /* get exception address (DELAY) */ /* generate patcher stubs */ -- 2.25.1