From 13c38f9df801b5129997a4005243f6e488161214 Mon Sep 17 00:00:00 2001 From: twisti Date: Mon, 11 Jul 2005 18:56:09 +0000 Subject: [PATCH] * Implemented new (and new improved) stacktrace system --- src/vm/jit/alpha/asmpart.S | 537 ++------------------------------ src/vm/jit/alpha/codegen.c | 618 +++++++++++++++++++++++++++---------- src/vm/jit/alpha/codegen.h | 4 +- src/vm/jit/alpha/md.c | 76 ++++- src/vm/jit/alpha/patcher.c | 44 +-- 5 files changed, 577 insertions(+), 702 deletions(-) diff --git a/src/vm/jit/alpha/asmpart.S b/src/vm/jit/alpha/asmpart.S index b043b2319..32f870e7e 100644 --- a/src/vm/jit/alpha/asmpart.S +++ b/src/vm/jit/alpha/asmpart.S @@ -30,7 +30,7 @@ Changes: Joseph Wenninger Christian Thalinger - $Id: asmpart.S 2931 2005-07-08 11:49:50Z twisti $ + $Id: asmpart.S 2986 2005-07-11 18:56:09Z twisti $ */ @@ -61,31 +61,16 @@ .globl asm_calljavafunction2double .globl asm_call_jit_compiler - .globl asm_throw_and_handle_exception - .globl asm_throw_and_handle_nat_exception - .globl asm_throw_and_handle_arithmetic_exception - .globl asm_throw_and_handle_arrayindexoutofbounds_exception .globl asm_handle_exception .globl asm_handle_nat_exception .globl asm_wrapper_patcher - .globl asm_builtin_arraycheckcast - .globl asm_builtin_aastore - - .globl asm_builtin_idiv - .globl asm_builtin_irem - .globl asm_builtin_ldiv - .globl asm_builtin_lrem - .globl asm_perform_threadswitch .globl asm_initialize_thread_stack .globl asm_switchstackandcall .globl asm_criticalsections .globl asm_getclassvalues_atomic - .globl asm_prepare_native_stackinfo - .globl asm_remove_native_stackinfo - .globl asm_refillin_and_handle_exception /* asm_sync_instruction_cache ************************************************** @@ -374,7 +359,7 @@ noregchange: ldq ra,13*8(sp) /* load return address */ lda sp,14*8(sp) /* deallocate stack area */ - beq v0,asm_call_jit_compiler_exception + beq v0,L_asm_call_jit_compiler_exception ldl t8,-8(ra) /* load instruction LDQ PV,xxx($yy) */ sll t8,48,t8 @@ -389,18 +374,19 @@ noregchange: jmp zero,(pv) /* and call method. The method returns */ /* directly to the caller (ra). */ -asm_call_jit_compiler_exception: -#if defined(USE_THREADS) && defined(NATIVE_THREADS) +L_asm_call_jit_compiler_exception: subq sp,1*8,sp stq ra,0*8(sp) - jsr ra,builtin_asm_get_exceptionptrptr + + mov zero,a0 /* fill in the correct stacktrace */ + lda a1,1*8(sp) /* pass sp of parent Java function */ + mov ra,a2 /* pass ra to parent Java function */ + mov ra,a3 /* xpc is the same as ra */ + jsr ra,stacktrace_fillInStackTrace + mov v0,xptr + ldq ra,0*8(sp) addq sp,1*8,sp -#else - lda v0,_exceptionptr -#endif - ldq xptr,0(v0) /* get the exception pointer */ - stq zero,0(v0) /* clear the exception pointer */ subq ra,4,xpc br asm_handle_nat_exception @@ -408,242 +394,6 @@ asm_call_jit_compiler_exception: .end asm_call_jit_compiler -/**************** function asm_refillin_and_handle_exception ******************* -* * -* This function handles an exception. It does not use the usual calling * -* conventions. The exception is passed in REG_ITMP1 and the * -* pc from the exception raising position is passed in REG_ITMP2. * -* a0 contains the PV of the function causing the problem * -* * -* void asm_handle_arithmetic_exception (exceptionclass, exceptionpc); * -* * -*******************************************************************************/ - .ent asm_refillin_and_handle_exception -asm_refillin_and_handle_exception: - ldgp gp,0(pv) - ldl t0,0(ra) /* load instruction LDA PV,xxx(RA) */ - sll t0,48,t0 - sra t0,48,t0 /* isolate offset */ - addq t0,ra,pv /* compute update address */ - ldl t0,4(ra) /* load instruction LDAH PV,xxx(PV) */ - srl t0,16,t0 /* isolate instruction code */ - lda t0,-0x177b(t0) /* test for LDAH */ - bne t0, asm_refillin_and_handle_exception_cont - ldl t0,4(ra) /* load instruction LDAH PV,xxx(PV) */ - sll t0,16,t0 /* compute high offset */ - addl t0,0,t0 /* sign extend high offset */ - addq t0,pv,pv /* compute update address */ - -asm_refillin_and_handle_exception_cont: - - mov sp,t0 - lda sp,-6*8(sp) /* prepare stackframe*/ - stq pv,5*8(sp) /* store pv of caller */ - stq xptr,4*8(sp) /*exception ptr*/ - stq xpc,3*8(sp) /*address of failure*/ - stq t0,2*8(sp) /*begin of java stack frame*/ - stq pv,1*8(sp) /* store pv of caller */ - stq zero,0*8(sp) /*builtin (invisible) function */ - jsr ra,asm_prepare_native_stackinfo /* puts 2 additional quadwords on stack */ - ldgp gp,0(ra) - - ldq a2,utf_void__java_lang_Throwable - ldq a1,utf_fillInStackTrace - ldq t0,6*8(sp) - ldq t1,offobjvftbl(t0) - ldq a0,offclass(t1) - jsr ra,class_resolvemethod - ldgp gp,0(ra) - /* now we have the method */ - - /*refillin */ - mov v0,a0 - ldq a1,6*8(sp) - jsr ra,asm_calljavafunction - ldgp gp,0(ra) - - /*remove frame*/ - jsr ra,asm_remove_native_stackinfo - ldgp gp,0(ra) - - - /*finish*/ - ldq xpc,0(sp) - ldq xptr,1*8(sp) - ldq pv,2*8(sp) - lda sp,3*8(sp) - br asm_handle_exception - - .end asm_refillin_and_handle_exception - -/****** function asm_throw_and_handle_arrayindexoutofbounds_exception ********** -* * -* This function handles an exception. It does not use the usual calling * -* conventions. The integer parameter is passed in REG_ITMP1 and the * -* pc from the exception raising position is passed in REG_ITMP2. * -* * -* void asm_handle_arithmetic_exception (exceptionclass, exceptionpc); * -* * -*******************************************************************************/ - - .ent asm_throw_and_handle_arrayindexoutofbounds_exception - -asm_throw_and_handle_arrayindexoutofbounds_exception: - ldgp gp,0(pv) - - ldl t0,0(ra) /* load instruction LDA PV,xxx(RA) */ - sll t0,48,t0 - sra t0,48,t0 /* isolate offset */ - addq t0,ra,pv /* compute update address */ - ldl t0,4(ra) /* load instruction LDAH PV,xxx(PV) */ - srl t0,16,t0 /* isolate instruction code */ - lda t0,-0x177b(t0) /* test for LDAH */ - bne t0,asm_throw_and_handle_arrayindexoutofbounds_exception_cont - ldl t0,4(ra) /* load instruction LDAH PV,xxx(PV) */ - sll t0,16,t0 /* compute high offset */ - addl t0,0,t0 /* sign extend high offset */ - addq t0,pv,pv /* compute update address */ - -asm_throw_and_handle_arrayindexoutofbounds_exception_cont: - mov sp,t0 - lda sp,-6*8(sp) /*prepare stackframe*/ - stq pv,5*8(sp) /*pv of failure*/ - stq itmp1,4*8(sp) /*int parameter of the exception*/ - stq xpc,3*8(sp) /*address of failure */ - stq t0,2*8(sp) /*store begin of java stack frame*/ - stq pv,1*8(sp) /*store pv of caller in structure*/ - stq zero,0*8(sp) /*builtin (invisible function)*/ - - jsr ra,asm_prepare_native_stackinfo /* puts 2 additional quadwords on stack */ - ldgp gp,0(ra) - - ldq a0,6*8(sp) /*int of exception*/ - jsr ra,new_arrayindexoutofboundsexception - ldgp gp,0(ra) - - mov v0,itmp1 /*itmp1 is not touched in asm_remove_native_stackinfo*/ - - jsr ra,asm_remove_native_stackinfo - ldgp gp,0(ra) - - ldq itmp2,0(sp) - ldq pv,2*8(sp) - lda sp,3*8(sp) - br asm_handle_exception - - .end asm_throw_and_handle_arrayindexoutofbounds_exception - - -/* asm_throw_and_handle_arithmetic_exception *********************************** - - DOCUMENT ME! - -*******************************************************************************/ - - .ent asm_throw_and_handle_arithmetic_exception - -asm_throw_and_handle_arithmetic_exception: - ldl t0,0(ra) /* load instruction LDA PV,xxx(RA) */ - sll t0,48,t0 - sra t0,48,t0 /* isolate offset */ - addq t0,ra,pv /* compute update address */ - ldl t0,4(ra) /* load instruction LDAH PV,xxx(PV) */ - srl t0,16,t0 /* isolate instruction code */ - lda t0,-0x177b(t0) /* test for LDAH */ - bne t0,asm_throw_and_handle_arithmetic_exception_cont - ldl t0,4(ra) /* load instruction LDAH PV,xxx(PV) */ - sll t0,16,t0 /* compute high offset */ - addl t0,0,t0 /* sign extend high offset */ - addq t0,pv,pv /* compute update address */ - -asm_throw_and_handle_arithmetic_exception_cont: - mov sp,t0 - lda sp,-6*8(sp) /*prepare stackframe*/ - stq pv,5*8(sp) /*pv of failure*/ - stq itmp1,4*8(sp) /*exception string of the exception*/ - stq xpc,3*8(sp) /*address of failure */ - stq t0,2*8(sp) /*store begin of java stack frame*/ - stq pv,1*8(sp) /*store pv of caller in structure*/ - stq zero,0*8(sp) /*builtin (invisible function)*/ - jsr ra,asm_prepare_native_stackinfo /* puts 2 additional quadwords on stack */ - ldgp gp,0(ra) - - jsr ra,new_arithmeticexception - ldgp gp,0(ra) - mov v0,itmp1 /*itmp1 is not touched in asm_remove_native_stackinfo*/ - - jsr ra,asm_remove_native_stackinfo - ldgp gp,0(ra) - - ldq itmp2,0(sp) - ldq pv,2*8(sp) - lda sp,3*8(sp) - br asm_handle_exception - - .end asm_throw_and_handle_arithmetic_exception - - -/* asm_throw_and_handle_exception ********************************************** - - DOCUMENT ME!!! - -*******************************************************************************/ - - .ent asm_throw_and_handle_nat_exception - -asm_throw_and_handle_nat_exception: - ldgp gp,0(pv) - ldl t0,0(ra) /* load instruction LDA PV,xxx(RA) */ - sll t0,48,t0 - sra t0,48,t0 /* isolate offset */ - addq t0,ra,pv /* compute update address */ - ldl t0,4(ra) /* load instruction LDAH PV,xxx(PV) */ - srl t0,16,t0 /* isolate instruction code */ - lda t0,-0x177b(t0) /* test for LDAH */ - bne t0,asm_throw_and_handle_exception - ldl t0,4(ra) /* load instruction LDAH PV,xxx(PV) */ - sll t0,16,t0 /* compute high offset */ - addl t0,0,t0 /* sign extend high offset */ - addq t0,pv,pv /* compute update address */ - - .aent asm_throw_and_handle_exception - -asm_throw_and_handle_exception: - mov sp,t0 - lda sp,-6*8(sp) /* prepare stackframe */ - stq pv,5*8(sp) /* pv of failure */ - stq xptr,4*8(sp) /* classname of the exception */ - stq xpc,3*8(sp) /* address of failure */ - stq t0,2*8(sp) /* store begin of java stack frame */ - stq pv,1*8(sp) /* store pv of caller in structure */ - stq zero,0*8(sp) /* builtin (invisible function) */ - /* puts 2 additional quadwords on stack */ - - br ra,L_asm_throw_and_handle_exception_load_gp -L_asm_throw_and_handle_exception_load_gp: - ldgp gp,0(ra) /* load gp (it's not set correctly in jit) */ - - jsr ra,asm_prepare_native_stackinfo - ldgp gp,0(ra) - - ldq a0,6*8(sp) /* classname of exception */ - jsr ra,new_exception - ldgp gp,0(ra) - - mov v0,xptr /* xptr (itmp1) is not touched in */ - /* asm_remove_native_stackinfo */ - - jsr ra,asm_remove_native_stackinfo - ldgp gp,0(ra) - - ldq itmp2,0(sp) - ldq pv,2*8(sp) - lda sp,3*8(sp) - br asm_handle_exception - - .end asm_throw_and_handle_nat_exception - - /********************* function asm_handle_exception *************************** * * * This function handles an exception. It does not use the usual calling * @@ -958,7 +708,7 @@ ex_flt2: .ent asm_wrapper_patcher asm_wrapper_patcher: - lda sp,-(12+27+4)*8(sp) /* create stack frame */ + lda sp,-((12+27+4)*8+sizestackframeinfo)(sp) /* create stack frame */ SAVE_ARGUMENT_REGISTERS(0) /* save 6 int/6 float argument registers */ SAVE_TEMPORARY_REGISTERS(12) /* save 11 int/16 float temporary registers */ @@ -968,13 +718,29 @@ asm_wrapper_patcher: stq ra,(12+27+2)*8(sp) /* save method return address (for leafs) */ stq pv,(12+27+3)*8(sp) /* save pv of calling java function */ - lda a0,(0+12+27+4)*8(sp) /* pass sp */ - ldq pv,(0+12+27+4)*8(sp) /* get function pointer */ + br ra,L_asm_wrapper_patcher_load_gp +L_asm_wrapper_patcher_load_gp: + ldgp gp,0(ra) /* load gp (it's not set correctly in jit) */ + + lda a0,(12+27+4)*8(sp) /* create stackframe info */ + mov pv,a1 /* pass java pv */ + lda a2,((5+12+27+4)*8+sizestackframeinfo)(sp) /* pass java sp */ + ldq a3,(12+27+2)*8(sp) /* this is correct for leafs */ + ldq a4,((4+12+27+4)*8+sizestackframeinfo)(sp) /* pass xpc */ + jsr ra,stacktrace_create_inline_stackframeinfo + ldgp gp,0(ra) + + lda a0,((0+12+27+4)*8+sizestackframeinfo)(sp) /* pass sp */ + ldq pv,((0+12+27+4)*8+sizestackframeinfo)(sp) /* get function pointer */ ldq itmp1,(12+27+3)*8(sp) /* save pv to the position of fp */ - stq itmp1,(0+12+27+4)*8(sp) + stq itmp1,((0+12+27+4)*8+sizestackframeinfo)(sp) jmp ra,(pv) /* call the patcher function */ ldgp gp,0(ra) - + + lda a0,(12+27+4)*8(sp) /* remove stackframe info */ + jsr ra,stacktrace_remove_stackframeinfo + ldgp gp,0(ra) + RESTORE_ARGUMENT_REGISTERS(0) /* restore 6 int/6 float argument registers */ RESTORE_TEMPORARY_REGISTERS(12)/* restore 11 integer temporary registers */ @@ -983,8 +749,8 @@ asm_wrapper_patcher: ldq ra,(12+27+2)*8(sp) /* restore method return address (for leafs)*/ ldq pv,(12+27+3)*8(sp) /* restore pv of calling java function */ - ldq itmp3,(4+12+27+4)*8(sp)/* get return address (into JIT code) */ - lda sp,(5+12+27+4)*8(sp) /* remove stack frame */ + ldq itmp3,((4+12+27+4)*8+sizestackframeinfo)(sp)/* get RA to jit code */ + lda sp,((5+12+27+4)*8+sizestackframeinfo)(sp) /* remove stack frame */ beq v0,L_asm_wrapper_patcher_exception @@ -1017,218 +783,6 @@ L_asm_wrapper_patcher_exception_load_gp: .end asm_wrapper_patcher -/************************ function asm_builtin_idiv **************************** -* * -* Does null check and calls idiv or throws an exception * -* * -*******************************************************************************/ - - .ent asm_builtin_idiv - -asm_builtin_idiv: - ldgp gp,0(pv) - lda pv,builtin_idiv - beq a1,nb_idiv /* if (null) throw exception */ - jmp zero,(pv) /* else call builtin_idiv */ - -nb_idiv: - ldq xptr,string_java_lang_ArithmeticException_message - lda xpc,-4(ra) /* faulting address is return adress - 4*/ - br asm_throw_and_handle_arithmetic_exception - - .end asm_builtin_idiv - - -/************************ function asm_builtin_ldiv **************************** -* * -* Does null check and calls ldiv or throws an exception * -* * -*******************************************************************************/ - - .ent asm_builtin_ldiv - -asm_builtin_ldiv: - ldgp gp,0(pv) - lda pv,builtin_ldiv - beq a1,nb_ldiv /* if (null) throw exception */ - jmp zero,(pv) /* else call builtin_ldiv */ - -nb_ldiv: - ldq xptr,string_java_lang_ArithmeticException_message - lda xpc,-4(ra) /* faulting address is return adress - 4*/ - br asm_throw_and_handle_arithmetic_exception - - .end asm_builtin_ldiv - - -/************************ function asm_builtin_irem **************************** -* * -* Does null check and calls irem or throws an exception * -* * -*******************************************************************************/ - - .ent asm_builtin_irem - -asm_builtin_irem: - ldgp gp,0(pv) - lda pv,builtin_irem - beq a1,nb_irem /* if (null) throw exception */ - jmp zero,(pv) /* else call builtin_irem */ - -nb_irem: - ldq xptr,string_java_lang_ArithmeticException_message - lda xpc,-4(ra) /* faulting address is return adress - 4*/ - br asm_throw_and_handle_arithmetic_exception - - .end asm_builtin_irem - - -/************************ function asm_builtin_lrem **************************** -* * -* Does null check and calls lrem or throws an exception * -* * -*******************************************************************************/ - - .ent asm_builtin_lrem - -asm_builtin_lrem: - ldgp gp,0(pv) - lda pv,builtin_lrem - beq a1,nb_lrem /* if (null) throw exception */ - jmp zero,(pv) /* else call builtin_lrem */ - -nb_lrem: - ldq xptr,string_java_lang_ArithmeticException_message - lda xpc,-4(ra) /* faulting address is return adress - 4*/ - br asm_throw_and_handle_arithmetic_exception - - .end asm_builtin_lrem - - -/* asm_builtin_arraycheckcast ************************************************** - - Does the cast check and eventually throws an exception. - -*******************************************************************************/ - - .ent asm_builtin_arraycheckcast - -asm_builtin_arraycheckcast: - ldgp gp,0(pv) - lda sp,-16(sp) /* allocate stack space */ - stq ra,0(sp) /* save return address */ - stq a0,8(sp) /* save object pointer */ - jsr ra,builtin_arraycheckcast - ldgp gp,0(ra) - beq v0,nb_carray_throw /* if (false) throw exception */ - ldq ra,0(sp) /* restore return address */ - ldq v0,8(sp) /* return object pointer */ - lda sp,16(sp) /* free stack space */ - jmp zero,(ra) - -nb_carray_throw: - ldq ra,0(sp) - lda sp,16(sp) - lda xpc,-4(ra) - ldq xptr,string_java_lang_ClassCastException - jmp zero,asm_throw_and_handle_nat_exception -#if 0 - ldq a0,string_java_lang_ClassCastException - jsr ra,new_exception - ldgp gp,0(ra) - mov v0,xptr - - ldq ra,0(sp) /* restore return address */ - lda sp,16(sp) /* free stack space */ - lda xpc,-4(ra) /* faulting address is return adress - 4*/ - br asm_handle_nat_exception -#endif - - .end asm_builtin_arraycheckcast - - -/******************* function asm_builtin_aastore ****************************** -* * -* Does the cast check and eventually throws an exception * -* * -*******************************************************************************/ - - .ent asm_builtin_aastore - -asm_builtin_aastore: - ldgp gp,0(pv) - beq a0,nb_aastore_null /* if null pointer throw exception */ - ldl t0,offarraysize(a0) /* load size */ - lda sp,-24(sp) /* allocate stack space */ - stq ra,0(sp) /* save return address */ - s8addq a1,a0,t1 /* add index*8 to arrayref */ - cmpult a1,t0,t0 /* do bound check */ - beq t0,nb_aastore_bound /* if out of bounds throw exception */ - mov a2,a1 /* object is second argument */ - stq t1,8(sp) /* save store position */ - stq a1,16(sp) /* save object */ - jsr ra,builtin_canstore /* builtin_canstore(arrayref,object) */ - ldgp gp,0(ra) - ldq ra,0(sp) /* restore return address */ - ldq a0,8(sp) /* restore store position */ - ldq a1,16(sp) /* restore object */ - lda sp,24(sp) /* free stack space */ - beq v0,nb_aastore_throw /* if (false) throw exception */ - stq a1,offobjarrdata(a0) /* store objectptr in array */ - jmp zero,(ra) - -nb_aastore_null: - ldq xptr,string_java_lang_NullPointerException - mov ra,xpc - jmp zero,asm_throw_and_handle_nat_exception -#if 0 - subq sp,8,sp /* allocate stack space */ - stq ra,0(sp) /* save return address */ - jsr ra,new_nullpointerexception - ldgp gp,0(ra) - mov v0,xptr - ldq ra,0(sp) - addq sp,8,sp - - mov ra,xpc /* faulting address is return adress */ - br asm_handle_nat_exception -#endif -nb_aastore_bound: - ldq ra,0(sp) - lda sp,24(sp) - mov ra,xpc - mov a1,xptr - jmp zero,asm_throw_and_handle_arrayindexoutofbounds_exception -#if 0 - ldq a0,string_java_lang_ArrayIndexOutOfBoundsException - jsr ra,new_exception_int /* a1 already contains the index */ - ldgp gp,0(ra) - mov v0,xptr - - ldq ra,0(sp) /* restore return address */ - lda sp,24(sp) /* free stack space */ - mov ra,xpc /* faulting address is return adress */ - br asm_handle_nat_exception -#endif -nb_aastore_throw: - mov ra,xpc - ldq xptr,string_java_lang_ArrayStoreException - jmp zero,asm_throw_and_handle_nat_exception -#if 0 - subq sp,8,sp /* allocate stack space */ - stq ra,0(sp) /* save return address */ - jsr ra,new_arraystoreexception - ldgp gp,0(ra) - mov v0,xptr - ldq ra,0(sp) - addq sp,8,sp - - mov ra,xpc /* faulting address is return adress */ - br asm_handle_nat_exception -#endif - .end asm_builtin_aastore - - /******************* function asm_initialize_thread_stack ********************** * * * initialized a thread stack * @@ -1379,29 +933,6 @@ asm_criticalsections: .quad 0 - .ent asm_prepare_native_stackinfo -asm_prepare_native_stackinfo: - lda sp,-24(sp) - stq ra,0(sp) - jsr ra,builtin_asm_get_stackframeinfo - stq v0,16(sp) - ldq t0,0(v0) - stq t0,8(sp) - ldq ra,0(sp) - lda sp,8(sp) - stq sp,0(v0) - ret - .end asm_prepare_native_stackinfo - - .ent asm_remove_native_stackinfo -asm_remove_native_stackinfo: - ldq t0,0(sp) - ldq t1,8(sp) - stq t0,0(t1) - lda sp,40(sp) - ret - .end asm_remove_native_stackinfo - /* * These are local overrides for various environment variables in Emacs. * Please do not remove this and leave it at the end of the file, where diff --git a/src/vm/jit/alpha/codegen.c b/src/vm/jit/alpha/codegen.c index ec15cc415..e4cb62a6c 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 2910 2005-07-05 08:48:07Z twisti $ + $Id: codegen.c 2986 2005-07-11 18:56:09Z twisti $ */ @@ -79,7 +79,7 @@ void codegen(methodinfo *m, codegendata *cd, registerdata *rd) { - s4 len, s1, s2, s3, d; + s4 len, s1, s2, s3, d, disp; ptrint a; s4 parentargs_base; s4 *mcodeptr; @@ -442,7 +442,7 @@ void codegen(methodinfo *m, codegendata *cd, registerdata *rd) for (iptr = bptr->iinstr; len > 0; src = iptr->dst, len--, iptr++) { if (iptr->line != currentline) { - dseg_addlinenumber(cd, iptr->line, mcodeptr); + dseg_addlinenumber(cd, iptr->line, (u1 *) mcodeptr); currentline = iptr->line; } @@ -857,6 +857,38 @@ void codegen(methodinfo *m, codegendata *cd, registerdata *rd) store_reg_to_var_int(iptr->dst, d); break; + case ICMD_IDIV: /* ..., val1, val2 ==> ..., val1 / val2 */ + case ICMD_IREM: /* ..., val1, val2 ==> ..., val1 % val2 */ + case ICMD_LDIV: /* ..., val1, val2 ==> ..., val1 / val2 */ + case ICMD_LREM: /* ..., val1, val2 ==> ..., val1 % val2 */ + + var_to_reg_int(s1, src->prev, REG_ITMP1); + var_to_reg_int(s2, src, REG_ITMP2); + d = reg_of_var(rd, iptr->dst, REG_RESULT); + M_BEQZ(s2, 0); + codegen_addxdivrefs(cd, mcodeptr); + + M_MOV(s1, rd->argintregs[0]); + M_MOV(s2, rd->argintregs[1]); + bte = iptr->val.a; + disp = dseg_addaddress(cd, bte->fp); + M_ALD(REG_PV, REG_PV, disp); + M_JSR(REG_RA, REG_PV); + + disp = (s4) ((u1 *) mcodeptr - cd->mcodebase); + if (disp <= 32768) + M_LDA(REG_PV, REG_RA, -disp); + else { + s4 ml = -disp, mh = 0; + while (ml < -32768) { ml += 65536; mh--; } + M_LDA(REG_PV, REG_RA, ml); + M_LDAH(REG_PV, REG_PV, mh); + } + + M_INTMOVE(REG_RESULT, d); + store_reg_to_var_int(iptr->dst, d); + break; + case ICMD_IDIVPOW2: /* ..., value ==> ..., value << constant */ case ICMD_LDIVPOW2: /* val.i = constant */ @@ -1750,19 +1782,6 @@ void codegen(methodinfo *m, codegendata *cd, registerdata *rd) break; - case ICMD_AASTORE: /* ..., arrayref, index, value ==> ... */ - - var_to_reg_int(s1, src->prev->prev, REG_ITMP1); - var_to_reg_int(s2, src->prev, REG_ITMP2); - if (iptr->op1 == 0) { - gen_nullptr_check(s1); - gen_bound_check; - } - var_to_reg_int(s3, src, REG_ITMP3); - M_SAADDQ(s2, s1, REG_ITMP1); - M_AST (s3, REG_ITMP1, OFFSET(java_objectarray, data[0])); - break; - case ICMD_LASTORE: /* ..., arrayref, index, value ==> ... */ var_to_reg_int(s1, src->prev->prev, REG_ITMP1); @@ -1770,10 +1789,10 @@ void codegen(methodinfo *m, codegendata *cd, registerdata *rd) if (iptr->op1 == 0) { gen_nullptr_check(s1); gen_bound_check; - } + } var_to_reg_int(s3, src, REG_ITMP3); M_S8ADDQ(s2, s1, REG_ITMP1); - M_LST (s3, REG_ITMP1, OFFSET(java_longarray, data[0])); + M_LST(s3, REG_ITMP1, OFFSET(java_longarray, data[0])); break; case ICMD_IASTORE: /* ..., arrayref, index, value ==> ... */ @@ -1783,11 +1802,10 @@ void codegen(methodinfo *m, codegendata *cd, registerdata *rd) if (iptr->op1 == 0) { gen_nullptr_check(s1); gen_bound_check; - } - + } var_to_reg_int(s3, src, REG_ITMP3); M_S4ADDQ(s2, s1, REG_ITMP1); - M_IST (s3, REG_ITMP1, OFFSET(java_intarray, data[0])); + M_IST(s3, REG_ITMP1, OFFSET(java_intarray, data[0])); break; case ICMD_FASTORE: /* ..., arrayref, index, value ==> ... */ @@ -1797,10 +1815,10 @@ void codegen(methodinfo *m, codegendata *cd, registerdata *rd) if (iptr->op1 == 0) { gen_nullptr_check(s1); gen_bound_check; - } + } var_to_reg_flt(s3, src, REG_FTMP3); M_S4ADDQ(s2, s1, REG_ITMP1); - M_FST (s3, REG_ITMP1, OFFSET(java_floatarray, data[0])); + M_FST(s3, REG_ITMP1, OFFSET(java_floatarray, data[0])); break; case ICMD_DASTORE: /* ..., arrayref, index, value ==> ... */ @@ -1810,10 +1828,10 @@ void codegen(methodinfo *m, codegendata *cd, registerdata *rd) if (iptr->op1 == 0) { gen_nullptr_check(s1); gen_bound_check; - } + } var_to_reg_flt(s3, src, REG_FTMP3); M_S8ADDQ(s2, s1, REG_ITMP1); - M_DST (s3, REG_ITMP1, OFFSET(java_doublearray, data[0])); + M_DST(s3, REG_ITMP1, OFFSET(java_doublearray, data[0])); break; case ICMD_CASTORE: /* ..., arrayref, index, value ==> ... */ @@ -1823,23 +1841,22 @@ void codegen(methodinfo *m, codegendata *cd, registerdata *rd) if (iptr->op1 == 0) { gen_nullptr_check(s1); gen_bound_check; - } + } var_to_reg_int(s3, src, REG_ITMP3); if (has_ext_instr_set) { M_LADD(s2, s1, REG_ITMP1); M_LADD(s2, REG_ITMP1, REG_ITMP1); - M_SST (s3, REG_ITMP1, OFFSET(java_chararray, data[0])); - } - else { - M_LADD (s2, s1, REG_ITMP1); - M_LADD (s2, REG_ITMP1, REG_ITMP1); + M_SST(s3, REG_ITMP1, OFFSET(java_chararray, data[0])); + } else { + M_LADD(s2, s1, REG_ITMP1); + M_LADD(s2, REG_ITMP1, REG_ITMP1); M_LLD_U(REG_ITMP2, REG_ITMP1, OFFSET(java_chararray, data[0])); - M_LDA (REG_ITMP1, REG_ITMP1, OFFSET(java_chararray, data[0])); + M_LDA(REG_ITMP1, REG_ITMP1, OFFSET(java_chararray, data[0])); M_INSWL(s3, REG_ITMP1, REG_ITMP3); M_MSKWL(REG_ITMP2, REG_ITMP1, REG_ITMP2); - M_OR (REG_ITMP2, REG_ITMP3, REG_ITMP2); + M_OR(REG_ITMP2, REG_ITMP3, REG_ITMP2); M_LST_U(REG_ITMP2, REG_ITMP1, 0); - } + } break; case ICMD_SASTORE: /* ..., arrayref, index, value ==> ... */ @@ -1849,23 +1866,22 @@ void codegen(methodinfo *m, codegendata *cd, registerdata *rd) if (iptr->op1 == 0) { gen_nullptr_check(s1); gen_bound_check; - } + } var_to_reg_int(s3, src, REG_ITMP3); if (has_ext_instr_set) { M_LADD(s2, s1, REG_ITMP1); M_LADD(s2, REG_ITMP1, REG_ITMP1); - M_SST (s3, REG_ITMP1, OFFSET(java_shortarray, data[0])); - } - else { - M_LADD (s2, s1, REG_ITMP1); - M_LADD (s2, REG_ITMP1, REG_ITMP1); + M_SST(s3, REG_ITMP1, OFFSET(java_shortarray, data[0])); + } else { + M_LADD(s2, s1, REG_ITMP1); + M_LADD(s2, REG_ITMP1, REG_ITMP1); M_LLD_U(REG_ITMP2, REG_ITMP1, OFFSET(java_shortarray, data[0])); - M_LDA (REG_ITMP1, REG_ITMP1, OFFSET(java_shortarray, data[0])); + M_LDA(REG_ITMP1, REG_ITMP1, OFFSET(java_shortarray, data[0])); M_INSWL(s3, REG_ITMP1, REG_ITMP3); M_MSKWL(REG_ITMP2, REG_ITMP1, REG_ITMP2); - M_OR (REG_ITMP2, REG_ITMP3, REG_ITMP2); + M_OR(REG_ITMP2, REG_ITMP3, REG_ITMP2); M_LST_U(REG_ITMP2, REG_ITMP1, 0); - } + } break; case ICMD_BASTORE: /* ..., arrayref, index, value ==> ... */ @@ -1875,21 +1891,57 @@ void codegen(methodinfo *m, codegendata *cd, registerdata *rd) if (iptr->op1 == 0) { gen_nullptr_check(s1); gen_bound_check; - } + } var_to_reg_int(s3, src, REG_ITMP3); if (has_ext_instr_set) { M_LADD(s2, s1, REG_ITMP1); - M_BST (s3, REG_ITMP1, OFFSET(java_bytearray, data[0])); - } - else { - M_LADD (s2, s1, REG_ITMP1); + M_BST(s3, REG_ITMP1, OFFSET(java_bytearray, data[0])); + } else { + M_LADD(s2, s1, REG_ITMP1); M_LLD_U(REG_ITMP2, REG_ITMP1, OFFSET(java_bytearray, data[0])); - M_LDA (REG_ITMP1, REG_ITMP1, OFFSET(java_bytearray, data[0])); + M_LDA(REG_ITMP1, REG_ITMP1, OFFSET(java_bytearray, data[0])); M_INSBL(s3, REG_ITMP1, REG_ITMP3); M_MSKBL(REG_ITMP2, REG_ITMP1, REG_ITMP2); - M_OR (REG_ITMP2, REG_ITMP3, REG_ITMP2); + M_OR(REG_ITMP2, REG_ITMP3, REG_ITMP2); M_LST_U(REG_ITMP2, REG_ITMP1, 0); - } + } + break; + + case ICMD_AASTORE: /* ..., arrayref, index, value ==> ... */ + + var_to_reg_int(s1, src->prev->prev, REG_ITMP1); + var_to_reg_int(s2, src->prev, REG_ITMP2); +/* if (iptr->op1 == 0) { */ + gen_nullptr_check(s1); + gen_bound_check; +/* } */ + var_to_reg_int(s3, src, REG_ITMP3); + + M_MOV(s1, rd->argintregs[0]); + M_MOV(s3, rd->argintregs[1]); + bte = iptr->val.a; + disp = dseg_addaddress(cd, bte->fp); + M_ALD(REG_PV, REG_PV, disp); + M_JSR(REG_RA, REG_PV); + + disp = (s4) ((u1 *) mcodeptr - cd->mcodebase); + if (disp <= 32768) + M_LDA(REG_PV, REG_RA, -disp); + else { + s4 ml = -disp, mh = 0; + while (ml < -32768) { ml += 65536; mh--; } + M_LDA(REG_PV, REG_RA, ml); + M_LDAH(REG_PV, REG_PV, mh); + } + + M_BEQZ(REG_RESULT, 0); + codegen_addxstorerefs(cd, mcodeptr); + + var_to_reg_int(s1, src->prev->prev, REG_ITMP1); + var_to_reg_int(s2, src->prev, REG_ITMP2); + var_to_reg_int(s3, src, REG_ITMP3); + M_SAADDQ(s2, s1, REG_ITMP1); + M_AST(s3, REG_ITMP1, OFFSET(java_objectarray, data[0])); break; @@ -2011,7 +2063,7 @@ void codegen(methodinfo *m, codegendata *cd, registerdata *rd) PATCHER_get_putstatic, (unresolved_field *) iptr->target); - if (showdisassemble) + if (opt_showdisassemble) M_NOP; a = 0; @@ -2023,7 +2075,7 @@ void codegen(methodinfo *m, codegendata *cd, registerdata *rd) codegen_addpatchref(cd, mcodeptr, PATCHER_clinit, fi->class); - if (showdisassemble) + if (opt_showdisassemble) M_NOP; } @@ -2069,7 +2121,7 @@ void codegen(methodinfo *m, codegendata *cd, registerdata *rd) PATCHER_get_putstatic, (unresolved_field *) iptr->target); - if (showdisassemble) + if (opt_showdisassemble) M_NOP; a = 0; @@ -2081,7 +2133,7 @@ void codegen(methodinfo *m, codegendata *cd, registerdata *rd) codegen_addpatchref(cd, mcodeptr, PATCHER_clinit, fi->class); - if (showdisassemble) + if (opt_showdisassemble) M_NOP; } @@ -2124,7 +2176,7 @@ void codegen(methodinfo *m, codegendata *cd, registerdata *rd) PATCHER_get_putstatic, (unresolved_field *) iptr[1].target); - if (showdisassemble) + if (opt_showdisassemble) M_NOP; a = 0; @@ -2136,7 +2188,7 @@ void codegen(methodinfo *m, codegendata *cd, registerdata *rd) codegen_addpatchref(cd, mcodeptr, PATCHER_clinit, fi->class); - if (showdisassemble) + if (opt_showdisassemble) M_NOP; } @@ -2176,7 +2228,7 @@ void codegen(methodinfo *m, codegendata *cd, registerdata *rd) PATCHER_get_putfield, (unresolved_field *) iptr->target); - if (showdisassemble) + if (opt_showdisassemble) M_NOP; a = 0; @@ -2231,7 +2283,7 @@ void codegen(methodinfo *m, codegendata *cd, registerdata *rd) PATCHER_get_putfield, (unresolved_field *) iptr->target); - if (showdisassemble) + if (opt_showdisassemble) M_NOP; a = 0; @@ -2272,7 +2324,7 @@ void codegen(methodinfo *m, codegendata *cd, registerdata *rd) PATCHER_get_putfield, (unresolved_field *) iptr[1].target); - if (showdisassemble) + if (opt_showdisassemble) M_NOP; a = 0; @@ -3150,7 +3202,7 @@ gen_method: if (iptr->target) { codegen_addpatchref(cd, mcodeptr, bte->fp, iptr->target); - if (showdisassemble) + if (opt_showdisassemble) M_NOP; a = 0; @@ -3177,7 +3229,7 @@ gen_method: codegen_addpatchref(cd, mcodeptr, PATCHER_invokestatic_special, um); - if (showdisassemble) + if (opt_showdisassemble) M_NOP; a = 0; @@ -3201,7 +3253,7 @@ gen_method: codegen_addpatchref(cd, mcodeptr, PATCHER_invokevirtual, um); - if (showdisassemble) + if (opt_showdisassemble) M_NOP; s1 = 0; @@ -3227,7 +3279,7 @@ gen_method: codegen_addpatchref(cd, mcodeptr, PATCHER_invokeinterface, um); - if (showdisassemble) + if (opt_showdisassemble) M_NOP; s1 = 0; @@ -3322,24 +3374,24 @@ gen_method: s2 = 6; if (!super) - s2 += showdisassemble ? 1 : 0; + s2 += opt_showdisassemble ? 1 : 0; /* calculate class checkcast code size */ s3 = 9 /* 8 + (s1 == REG_ITMP1) */; if (!super) - s3 += showdisassemble ? 1 : 0; + s3 += opt_showdisassemble ? 1 : 0; /* if class is not resolved, check which code to call */ if (!super) { - M_BEQZ(s1, 4 + (showdisassemble ? 1 : 0) + s2 + 1 + s3); + M_BEQZ(s1, 4 + (opt_showdisassemble ? 1 : 0) + s2 + 1 + s3); codegen_addpatchref(cd, mcodeptr, PATCHER_checkcast_instanceof_flags, (constant_classref *) iptr->target); - if (showdisassemble) + if (opt_showdisassemble) M_NOP; a = dseg_adds4(cd, 0); /* super->flags */ @@ -3361,7 +3413,7 @@ gen_method: PATCHER_checkcast_instanceof_interface, (constant_classref *) iptr->target); - if (showdisassemble) + if (opt_showdisassemble) M_NOP; } @@ -3391,7 +3443,7 @@ gen_method: PATCHER_checkcast_instanceof_class, (constant_classref *) iptr->target); - if (showdisassemble) + if (opt_showdisassemble) M_NOP; } @@ -3429,6 +3481,51 @@ gen_method: } break; + case ICMD_ARRAYCHECKCAST: /* ..., objectref ==> ..., objectref */ + /* op1: 1... resolved, 0... not resolved */ + + var_to_reg_int(s1, src, rd->argintregs[0]); + M_INTMOVE(s1, rd->argintregs[0]); + + bte = iptr->val.a; + + if (!iptr->op1) { + codegen_addpatchref(cd, mcodeptr, bte->fp, iptr->target); + + if (opt_showdisassemble) + M_NOP; + + a = 0; + + } else { + a = (ptrint) bte->fp; + } + + disp = dseg_addaddress(cd, iptr->target); + M_ALD(rd->argintregs[1], REG_PV, disp); + disp = dseg_addaddress(cd, a); + M_ALD(REG_PV, REG_PV, disp); + M_JSR(REG_RA, REG_PV); + + disp = (s4) ((u1 *) mcodeptr - cd->mcodebase); + if (disp <= 32768) + M_LDA(REG_PV, REG_RA, -disp); + else { + s4 ml = -disp, mh = 0; + while (ml < -32768) { ml += 65536; mh--; } + M_LDA(REG_PV, REG_RA, ml); + M_LDAH(REG_PV, REG_PV, mh); + } + + M_BEQZ(REG_RESULT, 0); + codegen_addxcastrefs(cd, mcodeptr); + + var_to_reg_int(s1, src, REG_ITMP1); + d = reg_of_var(rd, iptr->dst, s1); + M_INTMOVE(s1, d); + store_reg_to_var_int(iptr->dst, d); + break; + case ICMD_INSTANCEOF: /* ..., objectref ==> ..., intresult */ /* op1: 0 == array, 1 == class */ @@ -3477,25 +3574,25 @@ gen_method: s2 = 6; if (!super) - s2 += (d == REG_ITMP2 ? 1 : 0) + (showdisassemble ? 1 : 0); + s2 += (d == REG_ITMP2 ? 1 : 0) + (opt_showdisassemble ? 1 : 0); /* calculate class instanceof code size */ s3 = 7; if (!super) - s3 += (showdisassemble ? 1 : 0); + s3 += (opt_showdisassemble ? 1 : 0); /* if class is not resolved, check which code to call */ if (!super) { M_CLR(d); - M_BEQZ(s1, 4 + (showdisassemble ? 1 : 0) + s2 + 1 + s3); + M_BEQZ(s1, 4 + (opt_showdisassemble ? 1 : 0) + s2 + 1 + s3); codegen_addpatchref(cd, mcodeptr, PATCHER_checkcast_instanceof_flags, (constant_classref *) iptr->target); - if (showdisassemble) + if (opt_showdisassemble) M_NOP; a = dseg_adds4(cd, 0); /* super->flags */ @@ -3523,7 +3620,7 @@ gen_method: PATCHER_checkcast_instanceof_interface, (constant_classref *) iptr->target); - if (showdisassemble) + if (opt_showdisassemble) M_NOP; } @@ -3552,7 +3649,7 @@ gen_method: PATCHER_checkcast_instanceof_class, (constant_classref *) iptr->target); - if (showdisassemble) + if (opt_showdisassemble) M_NOP; } @@ -3614,7 +3711,7 @@ gen_method: codegen_addpatchref(cd, mcodeptr, (functionptr) iptr->target, iptr->val.a); - if (showdisassemble) + if (opt_showdisassemble) M_NOP; a = 0; @@ -3699,19 +3796,80 @@ gen_method: codegen_createlinenumbertable(cd); { - /* generate bound check stubs */ s4 *xcodeptr = NULL; branchref *bref; + /* generate ArithmeticException stubs */ + + for (bref = cd->xdivrefs; 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_MOV(REG_RA, rd->argintregs[2]); + M_MOV(REG_ITMP2_XPC, rd->argintregs[3]); + + M_LDA(REG_SP, REG_SP, -1 * 8); + M_AST(REG_ITMP2_XPC, REG_SP, 0 * 8); + + disp = dseg_addaddress(cd, stacktrace_new_arithmeticexception); + M_ALD(REG_PV, REG_PV, disp); + M_JSR(REG_RA, REG_PV); + + /* recompute pv */ + disp = (s4) ((u1 *) mcodeptr - cd->mcodebase); + if (disp <= 32768) M_LDA(REG_PV, REG_RA, -disp); + else { + s4 ml = -disp, mh = 0; + while (ml < -32768) { ml += 65536; mh--; } + M_LDA(REG_PV, REG_RA, ml); + M_LDAH(REG_PV, REG_PV, mh); + } + + M_MOV(REG_RESULT, REG_ITMP1_XPTR); + + M_ALD(REG_ITMP2_XPC, REG_SP, 0 * 8); + M_LDA(REG_SP, REG_SP, 1 * 8); + + disp = dseg_addaddress(cd, asm_handle_exception); + M_ALD(REG_ITMP3, REG_PV, disp); + M_JMP(REG_ZERO, REG_ITMP3); + } + } + + /* generate ArrayIndexOutOfBoundsException stubs */ + + xcodeptr = NULL; + for (bref = cd->xboundrefs; bref != NULL; bref = bref->next) { gen_resolvebranch((u1*) cd->mcodebase + bref->branchpos, bref->branchpos, (u1*) mcodeptr - cd->mcodebase); - MCODECHECK(8); + MCODECHECK(18); /* move index register into REG_ITMP1 */ + M_MOV(bref->reg, REG_ITMP1); M_LDA(REG_ITMP2_XPC, REG_PV, bref->branchpos - 4); @@ -3721,28 +3879,51 @@ gen_method: } else { xcodeptr = mcodeptr; - a = dseg_addaddress(cd, asm_throw_and_handle_arrayindexoutofbounds_exception); - M_ALD(REG_PV, REG_PV, a); + M_MOV(REG_PV, rd->argintregs[0]); + M_MOV(REG_SP, rd->argintregs[1]); + M_MOV(REG_RA, rd->argintregs[2]); + M_MOV(REG_ITMP2_XPC, rd->argintregs[3]); + M_MOV(REG_ITMP1, rd->argintregs[4]); + + M_LDA(REG_SP, REG_SP, -2 * 8); + M_AST(REG_ITMP2_XPC, REG_SP, 0 * 8); + + if (m->isleafmethod) + M_AST(REG_RA, REG_SP, 1 * 8); + disp = dseg_addaddress(cd, stacktrace_new_arrayindexoutofboundsexception); + M_ALD(REG_PV, REG_PV, disp); M_JSR(REG_RA, REG_PV); /* recompute pv */ - s1 = (s4) ((u1 *) mcodeptr - cd->mcodebase); - if (s1 <= 32768) M_LDA(REG_PV, REG_RA, -s1); + disp = (s4) ((u1 *) mcodeptr - cd->mcodebase); + if (disp <= 32768) M_LDA(REG_PV, REG_RA, -disp); else { - s4 ml = -s1, mh = 0; + s4 ml = -disp, mh = 0; while (ml < -32768) { ml += 65536; mh--; } M_LDA(REG_PV, REG_RA, ml); M_LDAH(REG_PV, REG_PV, mh); } + + M_MOV(REG_RESULT, REG_ITMP1_XPTR); + + if (m->isleafmethod) + M_ALD(REG_RA, REG_SP, 1 * 8); + + 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 negative array size check stubs */ + /* generate ArrayStoreException stubs */ xcodeptr = NULL; - for (bref = cd->xcheckarefs; bref != NULL; bref = bref->next) { + for (bref = cd->xstorerefs; bref != NULL; bref = bref->next) { if ((cd->exceptiontablelength == 0) && (xcodeptr != NULL)) { gen_resolvebranch((u1 *) cd->mcodebase + bref->branchpos, bref->branchpos, @@ -3754,7 +3935,7 @@ gen_method: bref->branchpos, (u1 *) mcodeptr - cd->mcodebase); - MCODECHECK(8); + MCODECHECK(16); M_LDA(REG_ITMP2_XPC, REG_PV, bref->branchpos - 4); @@ -3764,27 +3945,40 @@ gen_method: } else { xcodeptr = mcodeptr; - a = dseg_addaddress(cd, string_java_lang_NegativeArraySizeException); - M_ALD(REG_ITMP1_XPTR,REG_PV,a); + M_MOV(REG_PV, rd->argintregs[0]); + M_MOV(REG_SP, rd->argintregs[1]); + M_MOV(REG_RA, rd->argintregs[2]); + M_MOV(REG_ITMP2_XPC, rd->argintregs[3]); - a = dseg_addaddress(cd, asm_throw_and_handle_nat_exception); - M_ALD(REG_PV, REG_PV, a); + M_LDA(REG_SP, REG_SP, -1 * 8); + M_AST(REG_ITMP2_XPC, REG_SP, 0 * 8); + disp = dseg_addaddress(cd, stacktrace_new_arraystoreexception); + M_ALD(REG_PV, REG_PV, disp); M_JSR(REG_RA, REG_PV); - + /* recompute pv */ - s1 = (s4) ((u1 *) mcodeptr - cd->mcodebase); - if (s1 <= 32768) M_LDA(REG_PV, REG_RA, -s1); + disp = (s4) ((u1 *) mcodeptr - cd->mcodebase); + if (disp <= 32768) M_LDA(REG_PV, REG_RA, -disp); else { - s4 ml = -s1, mh = 0; + s4 ml = -disp, mh = 0; while (ml < -32768) { ml += 65536; mh--; } M_LDA(REG_PV, REG_RA, ml); M_LDAH(REG_PV, REG_PV, mh); } + + M_MOV(REG_RESULT, REG_ITMP1_XPTR); + + M_ALD(REG_ITMP2_XPC, REG_SP, 0 * 8); + M_LDA(REG_SP, REG_SP, 1 * 8); + + disp = dseg_addaddress(cd, asm_handle_exception); + M_ALD(REG_ITMP3, REG_PV, disp); + M_JMP(REG_ZERO, REG_ITMP3); } } - /* generate cast check stubs */ + /* generate ClassCastException stubs */ xcodeptr = NULL; @@ -3800,7 +3994,7 @@ gen_method: bref->branchpos, (u1 *) mcodeptr - cd->mcodebase); - MCODECHECK(8); + MCODECHECK(18); M_LDA(REG_ITMP2_XPC, REG_PV, bref->branchpos - 4); @@ -3810,33 +4004,52 @@ gen_method: } else { xcodeptr = mcodeptr; - a = dseg_addaddress(cd, string_java_lang_ClassCastException); - M_ALD(REG_ITMP1_XPTR,REG_PV,a); + M_MOV(REG_PV, rd->argintregs[0]); + M_MOV(REG_SP, rd->argintregs[1]); + M_MOV(REG_RA, rd->argintregs[2]); + M_MOV(REG_ITMP2_XPC, rd->argintregs[3]); - a = dseg_addaddress(cd, asm_throw_and_handle_nat_exception); - M_ALD(REG_PV, REG_PV, a); + M_LDA(REG_SP, REG_SP, -2 * 8); + M_AST(REG_ITMP2_XPC, REG_SP, 0 * 8); + if (m->isleafmethod) + M_AST(REG_RA, REG_SP, 1 * 8); + + disp = dseg_addaddress(cd, stacktrace_new_classcastexception); + M_ALD(REG_PV, REG_PV, disp); M_JSR(REG_RA, REG_PV); /* recompute pv */ - s1 = (s4) ((u1 *) mcodeptr - cd->mcodebase); - if (s1 <= 32768) M_LDA(REG_PV, REG_RA, -s1); + disp = (s4) ((u1 *) mcodeptr - cd->mcodebase); + if (disp <= 32768) M_LDA(REG_PV, REG_RA, -disp); else { - s4 ml = -s1, mh = 0; + s4 ml = -disp, mh = 0; while (ml < -32768) { ml += 65536; mh--; } M_LDA(REG_PV, REG_RA, ml); M_LDAH(REG_PV, REG_PV, mh); } + + M_MOV(REG_RESULT, REG_ITMP1_XPTR); + + if (m->isleafmethod) + M_ALD(REG_RA, REG_SP, 1 * 8); + + 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 exception check stubs */ + /* generate NegativeArraySizeException stubs */ xcodeptr = NULL; - - for (bref = cd->xexceptionrefs; bref != NULL; bref = bref->next) { + + for (bref = cd->xcheckarefs; bref != NULL; bref = bref->next) { if ((cd->exceptiontablelength == 0) && (xcodeptr != NULL)) { - gen_resolvebranch((u1 *) cd->mcodebase + bref->branchpos, + gen_resolvebranch((u1 *) cd->mcodebase + bref->branchpos, bref->branchpos, (u1 *) xcodeptr - (u1 *) cd->mcodebase - 4); continue; @@ -3846,7 +4059,7 @@ gen_method: bref->branchpos, (u1 *) mcodeptr - cd->mcodebase); - MCODECHECK(8); + MCODECHECK(16); M_LDA(REG_ITMP2_XPC, REG_PV, bref->branchpos - 4); @@ -3856,61 +4069,111 @@ gen_method: } else { xcodeptr = mcodeptr; -#if defined(USE_THREADS) && defined(NATIVE_THREADS) - M_LSUB_IMM(REG_SP, 1 * 8, REG_SP); - M_LST(REG_ITMP2_XPC, REG_SP, 0 * 8); + M_MOV(REG_PV, rd->argintregs[0]); + M_MOV(REG_SP, rd->argintregs[1]); + M_MOV(REG_RA, rd->argintregs[2]); + M_MOV(REG_ITMP2_XPC, rd->argintregs[3]); - a = dseg_addaddress(cd, &builtin_get_exceptionptrptr); - M_ALD(REG_PV, REG_PV, a); + M_LDA(REG_SP, REG_SP, -2 * 8); + M_AST(REG_ITMP2_XPC, REG_SP, 0 * 8); + + disp = dseg_addaddress(cd, stacktrace_new_negativearraysizeexception); + M_ALD(REG_PV, REG_PV, disp); M_JSR(REG_RA, REG_PV); /* recompute pv */ - s1 = (s4) ((u1 *) mcodeptr - cd->mcodebase); - if (s1 <= 32768) M_LDA(REG_PV, REG_RA, -s1); + disp = (s4) ((u1 *) mcodeptr - cd->mcodebase); + if (disp <= 32768) M_LDA(REG_PV, REG_RA, -disp); else { - s4 ml = -s1, mh = 0; + s4 ml = -disp, mh = 0; while (ml < -32768) { ml += 65536; mh--; } M_LDA(REG_PV, REG_RA, ml); M_LDAH(REG_PV, REG_PV, mh); } - M_ALD(REG_ITMP1_XPTR, REG_RESULT, 0); - M_AST(REG_ZERO, REG_RESULT, 0); + M_MOV(REG_RESULT, REG_ITMP1_XPTR); - M_LLD(REG_ITMP2_XPC, REG_SP, 0 * 8); - M_LADD_IMM(REG_SP, 1 * 8, REG_SP); -#else - a = dseg_addaddress(cd, &_exceptionptr); - M_ALD(REG_ITMP3, REG_PV, a); - M_ALD(REG_ITMP1_XPTR, REG_ITMP3, 0); - M_AST(REG_ZERO, REG_ITMP3, 0); -#endif + M_ALD(REG_ITMP2_XPC, REG_SP, 0 * 8); + M_LDA(REG_SP, REG_SP, 2 * 8); - a = dseg_addaddress(cd, asm_refillin_and_handle_exception); - M_ALD(REG_PV, REG_PV, a); + 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; + + for (bref = cd->xnullrefs; 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(18); + + 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_MOV(REG_RA, rd->argintregs[2]); + 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); + + if (m->isleafmethod) + M_AST(REG_RA, REG_SP, 1 * 8); + + disp = dseg_addaddress(cd, stacktrace_new_nullpointerexception); + M_ALD(REG_PV, REG_PV, disp); + M_JSR(REG_RA, REG_PV); - M_JMP(REG_RA, REG_PV); - /* recompute pv */ - s1 = (s4) ((u1 *) mcodeptr - cd->mcodebase); - if (s1 <= 32768) M_LDA(REG_PV, REG_RA, -s1); + disp = (s4) ((u1 *) mcodeptr - cd->mcodebase); + if (disp <= 32768) M_LDA(REG_PV, REG_RA, -disp); else { - s4 ml = -s1, mh = 0; + s4 ml = -disp, mh = 0; while (ml < -32768) { ml += 65536; mh--; } M_LDA(REG_PV, REG_RA, ml); M_LDAH(REG_PV, REG_PV, mh); } + M_MOV(REG_RESULT, REG_ITMP1_XPTR); + + if (m->isleafmethod) + M_ALD(REG_RA, REG_SP, 1 * 8); + + 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 null pointer check stubs */ + /* generate ICMD_CHECKEXCEPTION stubs */ xcodeptr = NULL; - for (bref = cd->xnullrefs; bref != NULL; bref = bref->next) { + for (bref = cd->xexceptionrefs; bref != NULL; bref = bref->next) { if ((cd->exceptiontablelength == 0) && (xcodeptr != NULL)) { - gen_resolvebranch((u1 *) cd->mcodebase + bref->branchpos, + gen_resolvebranch((u1 *) cd->mcodebase + bref->branchpos, bref->branchpos, (u1 *) xcodeptr - (u1 *) cd->mcodebase - 4); continue; @@ -3920,7 +4183,7 @@ gen_method: bref->branchpos, (u1 *) mcodeptr - cd->mcodebase); - MCODECHECK(8); + MCODECHECK(16); M_LDA(REG_ITMP2_XPC, REG_PV, bref->branchpos - 4); @@ -3930,27 +4193,40 @@ gen_method: } else { xcodeptr = mcodeptr; - a = dseg_addaddress(cd, string_java_lang_NullPointerException); - M_ALD(REG_ITMP1_XPTR,REG_PV,a); + M_MOV(REG_PV, rd->argintregs[0]); + M_MOV(REG_SP, rd->argintregs[1]); + M_MOV(REG_RA, rd->argintregs[2]); /* this is correct for leafs */ + M_MOV(REG_ITMP2_XPC, rd->argintregs[3]); - a = dseg_addaddress(cd, asm_throw_and_handle_nat_exception); - M_ALD(REG_PV, REG_PV, a); + M_LDA(REG_SP, REG_SP, -1 * 8); + M_AST(REG_ITMP2_XPC, REG_SP, 0 * 8); + disp = dseg_addaddress(cd, stacktrace_fillInStackTrace); + M_ALD(REG_PV, REG_PV, disp); M_JSR(REG_RA, REG_PV); /* recompute pv */ - s1 = (s4) ((u1 *) mcodeptr - cd->mcodebase); - if (s1 <= 32768) M_LDA(REG_PV, REG_RA, -s1); + disp = (s4) ((u1 *) mcodeptr - cd->mcodebase); + if (disp <= 32768) M_LDA(REG_PV, REG_RA, -disp); else { - s4 ml = -s1, mh = 0; + s4 ml = -disp, mh = 0; while (ml < -32768) { ml += 65536; mh--; } M_LDA(REG_PV, REG_RA, ml); M_LDAH(REG_PV, REG_PV, mh); } + + M_MOV(REG_RESULT, REG_ITMP1_XPTR); + + M_ALD(REG_ITMP2_XPC, REG_SP, 0 * 8); + M_LDA(REG_SP, REG_SP, 1 * 8); + + disp = dseg_addaddress(cd, asm_handle_exception); + M_ALD(REG_ITMP3, REG_PV, disp); + M_JMP(REG_ZERO, REG_ITMP3); } } - /* generate put/getstatic stub call code */ + /* generate patcher stub call code */ { patchref *pref; @@ -4111,7 +4387,7 @@ functionptr createnativestub(functionptr f, methodinfo *m, codegendata *cd, stackframesize = 1 + /* return address */ - 6 + /* dynamic stack info */ + sizeof(stackframeinfo) / SIZEOF_VOID_P + 1 + /* methodinfo for call trace */ (md->paramcount > INT_ARG_CNT ? INT_ARG_CNT : md->paramcount) + nmd->memuse; @@ -4138,7 +4414,7 @@ functionptr createnativestub(functionptr f, methodinfo *m, codegendata *cd, /* generate stub code */ M_LDA(REG_SP, REG_SP, -stackframesize * 8); - M_AST(REG_RA, REG_SP, (stackframesize - 1) * 8); + M_AST(REG_RA, REG_SP, stackframesize * 8 - SIZEOF_VOID_P); /* if function is static, check for initialized */ @@ -4146,7 +4422,7 @@ functionptr createnativestub(functionptr f, methodinfo *m, codegendata *cd, if ((m->flags & ACC_STATIC) && !m->class->initialized) { codegen_addpatchref(cd, mcodeptr, PATCHER_clinit, m->class); - if (showdisassemble) + if (opt_showdisassemble) M_NOP; } @@ -4214,25 +4490,19 @@ functionptr createnativestub(functionptr f, methodinfo *m, codegendata *cd, if (IS_FLT_DBL_TYPE(md->paramtypes[i].type)) M_DST(rd->argfltregs[i], REG_SP, j++ * 8); - /* create native stack info */ + /* create native stackframe info */ - off = dseg_addaddress(cd, builtin_asm_get_stackframeinfo); + M_AADD_IMM(REG_SP, stackframesize * 8 - sizeof(stackframeinfo), + rd->argintregs[0]); + M_MOV(REG_PV, rd->argintregs[1]); + M_AADD_IMM(REG_SP, stackframesize * 8, rd->argintregs[2]); + M_ALD(rd->argintregs[3], REG_SP, stackframesize * 8 - SIZEOF_VOID_P); + off = dseg_addaddress(cd, stacktrace_create_native_stackframeinfo); M_ALD(REG_PV, REG_PV, off); M_JSR(REG_RA, REG_PV); disp = (s4) ((u1 *) mcodeptr - cd->mcodebase); M_LDA(REG_PV, REG_RA, -disp); - M_LST(REG_RESULT, REG_SP, (stackframesize - 5) * 8); /* save adress of pointer */ - M_LLD(REG_ITMP2, REG_RESULT, 0); /* get pointer */ - M_LST(REG_ITMP2, REG_SP, (stackframesize - 6) * 8); /* save old value */ - M_LDA(REG_ITMP3, REG_SP, (stackframesize - 6) * 8); /* calculate new value */ - M_LST(REG_ITMP3, REG_RESULT, 0); /* store new value */ - off = dseg_addaddress(cd, m); - M_LLD(REG_ITMP2, REG_PV, off); - M_LST(REG_ITMP2, REG_SP, (stackframesize - 4) * 8); - M_LST(REG_ZERO, REG_SP, (stackframesize - 3) * 8); - M_LST(REG_ZERO, REG_SP, (stackframesize - 2) * 8); - /* restore integer and float argument registers */ for (i = 0, j = 0; i < md->paramcount && i < INT_ARG_CNT; i++) @@ -4315,7 +4585,7 @@ functionptr createnativestub(functionptr f, methodinfo *m, codegendata *cd, if (f == NULL) { codegen_addpatchref(cd, mcodeptr, PATCHER_resolve_native, m); - if (showdisassemble) + if (opt_showdisassemble) M_NOP; } #endif @@ -4327,11 +4597,25 @@ functionptr createnativestub(functionptr f, methodinfo *m, codegendata *cd, M_LDA(REG_PV, REG_RA, -disp); /* recompute pv from ra */ - /* remove native stack info */ + /* remove native stackframe info */ + + 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_LLD(REG_ITMP3, REG_SP, (stackframesize - 5) * 8); /* get address of stacktrace helper pointer */ - M_LLD(REG_ITMP1, REG_SP, (stackframesize - 6) * 8); /* get old value */ - M_LST(REG_ITMP1, REG_ITMP3, 0); /* set old value */ + M_AADD_IMM(REG_SP, stackframesize * 8 - sizeof(stackframeinfo), + rd->argintregs[0]); + off = dseg_addaddress(cd, stacktrace_remove_stackframeinfo); + M_ALD(REG_PV, REG_PV, off); + M_JSR(REG_RA, REG_PV); + 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 */ diff --git a/src/vm/jit/alpha/codegen.h b/src/vm/jit/alpha/codegen.h index 954ec6364..ac9a91a83 100644 --- a/src/vm/jit/alpha/codegen.h +++ b/src/vm/jit/alpha/codegen.h @@ -29,7 +29,7 @@ Changes: Christian Thalinger - $Id: codegen.h 2613 2005-06-08 20:53:09Z twisti $ + $Id: codegen.h 2986 2005-07-11 18:56:09Z twisti $ */ @@ -285,6 +285,8 @@ #define M_IMUL_IMM(a,b,c) M_OP3 (0x13,0x00, a,b,c,1) /* 32 mul */ #define M_LMUL_IMM(a,b,c) M_OP3 (0x13,0x20, a,b,c,1) /* 64 mul */ +#define M_AADD_IMM(a,b,c) M_LADD_IMM(a,b,c) + #define M_CMPEQ(a,b,c) M_OP3 (0x10,0x2d, a,b,c,0) /* c = a == b */ #define M_CMPLT(a,b,c) M_OP3 (0x10,0x4d, a,b,c,0) /* c = a < b */ #define M_CMPLE(a,b,c) M_OP3 (0x10,0x6d, a,b,c,0) /* c = a <= b */ diff --git a/src/vm/jit/alpha/md.c b/src/vm/jit/alpha/md.c index 9062b085b..e2dcd1077 100644 --- a/src/vm/jit/alpha/md.c +++ b/src/vm/jit/alpha/md.c @@ -30,14 +30,17 @@ Changes: Joseph Wenninger Christian Thalinger - $Id: md.c 2930 2005-07-08 11:45:43Z twisti $ + $Id: md.c 2986 2005-07-11 18:56:09Z twisti $ */ +#include #include #include "config.h" + +#include "vm/jit/alpha/asmoffsets.h" #include "vm/jit/alpha/md-abi.h" #include "vm/jit/alpha/types.h" @@ -90,10 +93,15 @@ extern void ieee_set_fp_control(unsigned long fp_control); void signal_handler_sigsegv(int sig, siginfo_t *siginfo, void *_p) { - ucontext_t *_uc; - mcontext_t *_mc; - u4 instr; - ptrint addr; + ucontext_t *_uc; + mcontext_t *_mc; + u4 instr; + ptrint addr; + u1 *pv; + u1 *sp; + functionptr ra; + functionptr xpc; + bool isleafmethod; _uc = (ucontext_t *) _p; _mc = &_uc->uc_mcontext; @@ -102,17 +110,23 @@ void signal_handler_sigsegv(int sig, siginfo_t *siginfo, void *_p) addr = _mc->sc_regs[(instr >> 16) & 0x1f]; if (addr == 0) { + pv = (u1 *) _mc->sc_regs[REG_PV]; + sp = (u1 *) _mc->sc_regs[REG_SP]; + ra = (u1 *) _mc->sc_regs[REG_RA]; /* this is correct for leafs */ + xpc = (functionptr) _mc->sc_pc; + _mc->sc_regs[REG_ITMP1_XPTR] = - (ptrint) string_java_lang_NullPointerException; + (ptrint) stacktrace_new_nullpointerexception(pv, sp, ra, xpc); - _mc->sc_regs[REG_ITMP2_XPC] = _mc->sc_pc; - _mc->sc_pc = (ptrint) asm_throw_and_handle_exception; + _mc->sc_regs[REG_ITMP2_XPC] = (ptrint) xpc; + _mc->sc_pc = (ptrint) asm_handle_exception; } else { addr += (long) ((instr << 16) >> 16); throw_cacao_exception_exit(string_java_lang_InternalError, - "faulting address: 0x%016lx\n", addr); + "Segmentation fault: 0x%016lx at 0x%016lx\n", + addr, _mc->sc_pc); } } @@ -149,6 +163,50 @@ functionptr md_stacktrace_get_returnaddress(u1 *sp, u4 framesize) } +/* codegen_findmethod ********************************************************** + + Machine code: + + 6b5b4000 jsr (pv) + 237affe8 lda pv,-24(ra) + +*******************************************************************************/ + +functionptr codegen_findmethod(functionptr pc) +{ + u1 *ra; + u1 *pv; + u4 mcode; + s2 offset; + + ra = (u1 *) pc; + pv = ra; + + /* get offset of first instruction (lda) */ + + mcode = *((u4 *) ra); + + if ((mcode >> 16) != 0x237a) { + log_text("No `lda pv,x(ra)' instruction found on return address!"); + assert(0); + } + + offset = (s2) (mcode & 0x0000ffff); + pv += offset; + + /* check for second instruction (ldah) */ + + mcode = *((u4 *) (ra + 1 * 4)); + + if ((mcode >> 16) == 0x177b) { + offset = (s2) (mcode << 16); + pv += offset; + } + + return (functionptr) pv; +} + + /* * These are local overrides for various environment variables in Emacs. * Please do not remove this and leave it at the end of the file, where diff --git a/src/vm/jit/alpha/patcher.c b/src/vm/jit/alpha/patcher.c index 705472803..cca843a1d 100644 --- a/src/vm/jit/alpha/patcher.c +++ b/src/vm/jit/alpha/patcher.c @@ -28,7 +28,7 @@ Changes: - $Id: patcher.c 2931 2005-07-08 11:49:50Z twisti $ + $Id: patcher.c 2986 2005-07-11 18:56:09Z twisti $ */ @@ -106,7 +106,7 @@ bool patcher_get_putstatic(u1 *sp) /* if we show disassembly, we have to skip the nop */ - if (showdisassemble) + if (opt_showdisassemble) ra = ra + 4; /* get the offset from machine instruction */ @@ -172,7 +172,7 @@ bool patcher_get_putfield(u1 *sp) /* if we show disassembly, we have to skip the nop */ - if (showdisassemble) + if (opt_showdisassemble) ra = ra + 4; /* patch the field's offset */ @@ -247,7 +247,7 @@ bool patcher_builtin_new(u1 *sp) /* if we show disassembly, we have to skip the nop */ - if (showdisassemble) + if (opt_showdisassemble) ra = ra + 4; /* get the offset from machine instruction */ @@ -326,7 +326,7 @@ bool patcher_builtin_newarray(u1 *sp) /* if we show disassembly, we have to skip the nop */ - if (showdisassemble) + if (opt_showdisassemble) ra = ra + 4; /* get the offset from machine instruction */ @@ -399,7 +399,7 @@ bool patcher_builtin_multianewarray(u1 *sp) /* if we show disassembly, we have to skip the nop */ - if (showdisassemble) + if (opt_showdisassemble) ra = ra + 4; /* get the offset from machine instruction */ @@ -424,8 +424,8 @@ bool patcher_builtin_multianewarray(u1 *sp) Machine code: - a63bfe60 ldq a1,-416(pv) + a63bfe60 ldq a1,-416(pv) a77bfe58 ldq pv,-424(pv) 6b5b4000 jsr (pv) @@ -451,7 +451,7 @@ bool patcher_builtin_arraycheckcast(u1 *sp) /* calculate and set the new return address */ - ra = ra - 2 * 4; + ra = ra - 1 * 4; *((ptrint *) (sp + 4 * 8)) = (ptrint) ra; PATCHER_MONITORENTER; @@ -466,7 +466,12 @@ bool patcher_builtin_arraycheckcast(u1 *sp) /* patch back original code */ - *((u4 *) (ra + 4)) = mcode; + *((u4 *) ra) = mcode; + + /* if we show disassembly, we have to skip the nop */ + + if (opt_showdisassemble) + ra = ra + 4; /* get the offset from machine instruction */ @@ -476,11 +481,6 @@ bool patcher_builtin_arraycheckcast(u1 *sp) *((ptrint *) (pv + offset)) = (ptrint) c->vftbl; - /* if we show disassembly, we have to skip the nop */ - - if (showdisassemble) - ra = ra + 4; - /* get the offset from machine instruction */ offset = (s2) (*((u4 *) (ra + 4)) & 0x0000ffff); @@ -557,7 +557,7 @@ bool patcher_builtin_arrayinstanceof(u1 *sp) /* if we show disassembly, we have to skip the nop */ - if (showdisassemble) + if (opt_showdisassemble) ra = ra + 4; /* get the offset from machine instruction */ @@ -627,7 +627,7 @@ bool patcher_invokestatic_special(u1 *sp) /* if we show disassembly, we have to skip the nop */ - if (showdisassemble) + if (opt_showdisassemble) ra = ra + 4; /* get the offset from machine instruction */ @@ -695,7 +695,7 @@ bool patcher_invokevirtual(u1 *sp) /* if we show disassembly, we have to skip the nop */ - if (showdisassemble) + if (opt_showdisassemble) ra = ra + 4; /* patch vftbl index */ @@ -761,7 +761,7 @@ bool patcher_invokeinterface(u1 *sp) /* if we show disassembly, we have to skip the nop */ - if (showdisassemble) + if (opt_showdisassemble) ra = ra + 4; /* patch interfacetable index */ @@ -831,7 +831,7 @@ bool patcher_checkcast_instanceof_flags(u1 *sp) /* if we show disassembly, we have to skip the nop */ - if (showdisassemble) + if (opt_showdisassemble) ra = ra + 4; /* get the offset from machine instruction */ @@ -901,7 +901,7 @@ bool patcher_checkcast_instanceof_interface(u1 *sp) /* if we show disassembly, we have to skip the nop */ - if (showdisassemble) + if (opt_showdisassemble) ra = ra + 4; /* patch super class index */ @@ -970,7 +970,7 @@ bool patcher_checkcast_instanceof_class(u1 *sp) /* if we show disassembly, we have to skip the nop */ - if (showdisassemble) + if (opt_showdisassemble) ra = ra + 4; /* get the offset from machine instruction */ @@ -1088,7 +1088,7 @@ bool patcher_resolve_native(u1 *sp) /* if we show disassembly, we have to skip the nop */ - if (showdisassemble) + if (opt_showdisassemble) ra = ra + 4; /* get the offset from machine instruction */ -- 2.25.1