* patcher_athrow_areturn changes.
authortwisti <none@none>
Thu, 3 Nov 2005 21:39:25 +0000 (21:39 +0000)
committertwisti <none@none>
Thu, 3 Nov 2005 21:39:25 +0000 (21:39 +0000)
src/vm/jit/powerpc/asmpart.S
src/vm/jit/powerpc/codegen.c
src/vm/jit/powerpc/patcher.c

index 6daf55be002768ed19574a6ca10bf7f6bf80ca32..616ff8ac5b16b83e7326007dd3fc0f8a31a4697b 100644 (file)
@@ -30,7 +30,7 @@
 
    Changes: Christian Thalinger
 
-   $Id: asmpart.S 3234 2005-09-21 12:11:58Z twisti $
+   $Id: asmpart.S 3556 2005-11-03 21:39:25Z twisti $
 
 */
 
@@ -258,27 +258,44 @@ asm_calljavafunction2double:
        ble     calljava_argsloaded
 
        addi    itmp2,itmp2,-1
-       lwz     r3,offjniitem+4(itmp1)
+       lwz     a0,offjniitem+4(itmp1)
        mr.     itmp2,itmp2
        ble     calljava_argsloaded
 
        addi    itmp2,itmp2,-1
-       lwz     r4,offjniitem+sizejniblock*1+4(itmp1)
+       lwz     a1,offjniitem+sizejniblock*1+4(itmp1)
        mr.     itmp2,itmp2
        ble     calljava_argsloaded
+
        addi    itmp2,itmp2,-1
+       lwz     a2,offjniitem+sizejniblock*2+4(itmp1)
+       mr.     itmp2,itmp2
+       ble     calljava_argsloaded
 
        addi    itmp2,itmp2,-1
-       lwz     r5,offjniitem+sizejniblock*2+4(itmp1)
+       lwz     a3,offjniitem+sizejniblock*3+4(itmp1)
        mr.     itmp2,itmp2
        ble     calljava_argsloaded
+
        addi    itmp2,itmp2,-1
+       lwz     a4,offjniitem+sizejniblock*4+4(itmp1)
+       mr.     itmp2,itmp2
+       ble     calljava_argsloaded
 
        addi    itmp2,itmp2,-1
-       lwz     r6,offjniitem+sizejniblock*3+4(itmp1)
+       lwz     a5,offjniitem+sizejniblock*5+4(itmp1)
        mr.     itmp2,itmp2
        ble     calljava_argsloaded
+
        addi    itmp2,itmp2,-1
+       lwz     a6,offjniitem+sizejniblock*6+4(itmp1)
+       mr.     itmp2,itmp2
+       ble     calljava_argsloaded
+
+       addi    itmp2,itmp2,-1
+       lwz     a7,offjniitem+sizejniblock*7+4(itmp1)
+       mr.     itmp2,itmp2
+       ble     calljava_argsloaded
 
 calljava_argsloaded:
        addi    itmp1,r1,36
@@ -810,7 +827,7 @@ asm_wrapper_patcher:
        mflr    r0
        stw     r0,8*4+LA_LR_OFFSET(r1) /* skip stack frame of patcher stub       */
                                      /* keep stack 16-bytes aligned: 6+1+37 = 44 */
-       stwu    r1,-(LA_SIZE+(5+38)*4+sizestackframeinfo)(r1)
+       stwu    sp,-(LA_SIZE+(5+38)*4+sizestackframeinfo)(sp)
 
 #if 1
        stw     a0,LA_SIZE+(5+0)*4(r1)      /* save argument registers            */
@@ -859,7 +876,7 @@ asm_wrapper_patcher:
        mr      a1,pv
        addi    a2,sp,(8+LA_WORD_SIZE+5+38)*4+sizestackframeinfo
        mr      a3,r0                       /* this is correct for leafs          */
-       mr      a4,a3                       /* pass xpc                           */
+       lwz     a4,((5+LA_WORD_SIZE+5+38)*4+sizestackframeinfo)(sp) /* pass xpc   */
        bl      stacktrace_create_extern_stackframeinfo
 
        addi    a0,sp,(0+LA_WORD_SIZE+5+38)*4+sizestackframeinfo  /* pass sp      */
@@ -873,8 +890,6 @@ asm_wrapper_patcher:
        addi    a0,sp,LA_SIZE+(5+38)*4
        bl      stacktrace_remove_stackframeinfo /* remove stackframe info        */
 
-       lwz     itmp3,LA_SIZE+(5+37)*4(sp)  /* restore return value into temp reg.*/
-
 #if 1
        lwz     a0,LA_SIZE+(5+0)*4(r1)
        lwz     a1,LA_SIZE+(5+1)*4(r1)
@@ -916,19 +931,21 @@ asm_wrapper_patcher:
 
                                      /* get return address (into JIT code)       */
        lwz     itmp1,(5+LA_WORD_SIZE+5+38)*4+sizestackframeinfo(sp)
-       mtlr    itmp1
+       mtctr   itmp1
 
        lwz     itmp1,LA_SIZE+(5+34)*4(sp)
        lwz     itmp2,LA_SIZE+(5+35)*4(sp)
        lwz     pv,LA_SIZE+(5+36)*4(sp)
 
-                                     /* remove stack frame + patcher stub stack  */
-       addi    r1,r1,(8+LA_WORD_SIZE+5+38)*4+sizestackframeinfo
+       lwz     itmp3,LA_SIZE+(5+37)*4(sp)  /* restore return value into temp reg.*/
 
        mr.     itmp3,itmp3           /* check for an exception                   */
        beq     L_asm_wrapper_patcher_exception
 
-       blr                           /* jump to new patched code                 */
+                                     /* remove stack frame + patcher stub stack  */
+       addi    sp,sp,(8+LA_WORD_SIZE+5+38)*4+sizestackframeinfo
+
+       bctr                          /* jump to new patched code                 */
 
 L_asm_wrapper_patcher_exception:
 #if defined(USE_THREADS) && defined(NATIVE_THREADS)
@@ -952,7 +969,7 @@ L_asm_wrapper_patcher_exception:
        li      itmp3,0
        stw     itmp3,0(v0)           /* clear the exception pointer              */
 
-       mflr    xpc
+       mfctr   xpc
        b       asm_handle_exception
 
 
index 4cc7df959beff9690463747bcf4f71c4763bc1e7..7b559f235869fde61ca968303b44f77b8203499d 100644 (file)
@@ -30,7 +30,7 @@
    Changes: Christian Thalinger
             Christian Ullrich
 
-   $Id: codegen.c 3485 2005-10-21 13:44:43Z twisti $
+   $Id: codegen.c 3556 2005-11-03 21:39:25Z twisti $
 
 */
 
 #include "vm/jit/reg.inc"
 
 
-/* #include <architecture/ppc/cframe.h> */
-
-#if defined(USE_THREADS) && defined(NATIVE_THREADS)
-void thread_restartcriticalsection(void *u)
-{
-       /* XXX set pc to restart address */
-}
-#endif
-
 s4 *codegen_trace_args( methodinfo *m, codegendata *cd, registerdata *rd,
                                                s4 *mcodeptr, s4 parentargs_base, bool nativestub);
 
@@ -3651,7 +3642,7 @@ gen_method:
                        tmpmcodeptr = mcodeptr;         /* save current mcodeptr          */
                        mcodeptr = xcodeptr;            /* set mcodeptr to patch position */
 
-                       M_BL(tmpmcodeptr - (xcodeptr + 1));
+                       M_BR(tmpmcodeptr - (xcodeptr + 1));
 
                        mcodeptr = tmpmcodeptr;         /* restore the current mcodeptr   */
 
@@ -3659,10 +3650,10 @@ gen_method:
 
                        M_AADD_IMM(REG_SP, -8 * 4, REG_SP);
 
-                       /* move return address onto stack */
+                       /* calculate return address and move it onto the stack */
 
-                       M_MFLR(REG_ZERO);
-                       M_AST_INTERN(REG_ZERO, REG_SP, 5 * 4);
+                       M_LDA(REG_ITMP3, REG_PV, pref->branchpos);
+                       M_AST_INTERN(REG_ITMP3, REG_SP, 5 * 4);
 
                        /* move pointer to java_objectheader onto stack */
 
@@ -3675,8 +3666,7 @@ gen_method:
                        M_LDA(REG_ITMP3, REG_PV, disp);
                        M_AST_INTERN(REG_ITMP3, REG_SP, 4 * 4);
 #else
-                       M_CLR(REG_ITMP3);
-                       M_AST_INTERN(REG_ITMP3, REG_SP, 4 * 4);
+                       /* do nothing */
 #endif
 
                        /* move machine code onto stack */
@@ -4153,8 +4143,7 @@ functionptr createnativestub(functionptr f, methodinfo *m, codegendata *cd,
                        M_LDA(REG_ITMP3, REG_PV, disp);
                        M_AST(REG_ITMP3, REG_SP, 4 * 4);
 #else
-                       M_CLR(REG_ITMP3);
-                       M_AST(REG_ITMP3, REG_SP, 4 * 4);
+                       /* do nothing */
 #endif
 
                        /* move machine code onto stack */
index 60a7f1926688227f505581e459fa27410d3638ed..4a53dfeb6da6f6385c60511bee4dcb435ea25b19 100644 (file)
@@ -28,7 +28,7 @@
 
    Changes:
 
-   $Id: patcher.c 3484 2005-10-21 13:43:51Z twisti $
+   $Id: patcher.c 3556 2005-11-03 21:39:25Z twisti $
 
 */
 
@@ -77,11 +77,6 @@ bool patcher_get_putstatic(u1 *sp)
        disp  =                       *((s4 *)     (sp + 1 * 4));
        pv    = (u1 *)                *((ptrint *) (sp + 0 * 4));
 
-       /* calculate and set the new return address */
-
-       ra = ra - 4;
-       *((ptrint *) (sp + 5 * 4)) = (ptrint) ra;
-
        PATCHER_MONITORENTER;
 
        /* get the fieldinfo */
@@ -144,11 +139,6 @@ bool patcher_get_putfield(u1 *sp)
        uf    = (unresolved_field *)  *((ptrint *) (sp + 2 * 4));
        pv    = (u1 *)                *((ptrint *) (sp + 1 * 4));
 
-       /* calculate and set the new return address */
-
-       ra = ra - 4;
-       *((ptrint *) (sp + 5 * 4)) = (ptrint) ra;
-
        PATCHER_MONITORENTER;
 
        /* get the fieldinfo */
@@ -227,7 +217,7 @@ bool patcher_builtin_new(u1 *sp)
 
        /* calculate and set the new return address */
 
-       ra = ra - (2 * 4);
+       ra = ra - 1 * 4;
        *((ptrint *) (sp + 5 * 4)) = (ptrint) ra;
 
        PATCHER_MONITORENTER;
@@ -299,7 +289,7 @@ bool patcher_builtin_newarray(u1 *sp)
 
        /* calculate and set the new return address */
 
-       ra = ra - 2 * 4;
+       ra = ra - 1 * 4;
        *((ptrint *) (sp + 5 * 4)) = (ptrint) ra;
 
        PATCHER_MONITORENTER;
@@ -366,11 +356,6 @@ bool patcher_builtin_multianewarray(u1 *sp)
        disp  =                       *((s4 *)     (sp + 1 * 4));
        pv    = (u1 *)                *((ptrint *) (sp + 0 * 4));
 
-       /* calculate and set the new return address */
-
-       ra = ra - 4;
-       *((ptrint *) (sp + 5 * 4)) = (ptrint) ra;
-
        PATCHER_MONITORENTER;
 
        /* get the classinfo */
@@ -434,11 +419,6 @@ bool patcher_builtin_arraycheckcast(u1 *sp)
        disp  =                       *((s4 *)     (sp + 1 * 4));
        pv    = (u1 *)                *((ptrint *) (sp + 0 * 4));
 
-       /* calculate and set the new return address */
-
-       ra = ra - 1 * 4;
-       *((ptrint *) (sp + 5 * 4)) = (ptrint) ra;
-
        PATCHER_MONITORENTER;
 
        /* get the classinfo */
@@ -509,7 +489,7 @@ bool patcher_builtin_arrayinstanceof(u1 *sp)
 
        /* calculate and set the new return address */
 
-       ra = ra - 2 * 4;
+       ra = ra - 1 * 4;
        *((ptrint *) (sp + 5 * 4)) = (ptrint) ra;
 
        PATCHER_MONITORENTER;
@@ -574,11 +554,6 @@ bool patcher_invokestatic_special(u1 *sp)
        disp  =                       *((s4 *)     (sp + 1 * 4));
        pv    = (u1 *)                *((ptrint *) (sp + 0 * 4));
 
-       /* calculate and set the new return address */
-
-       ra = ra - 4;
-       *((ptrint *) (sp + 5 * 4)) = (ptrint) ra;
-
        PATCHER_MONITORENTER;
 
        /* get the fieldinfo */
@@ -634,11 +609,6 @@ bool patcher_invokevirtual(u1 *sp)
        mcode =                       *((u4 *)     (sp + 3 * 4));
        um    = (unresolved_method *) *((ptrint *) (sp + 2 * 4));
 
-       /* calculate and set the new return address */
-
-       ra = ra - 4;
-       *((ptrint *) (sp + 5 * 4)) = (ptrint) ra;
-
        PATCHER_MONITORENTER;
 
        /* get the fieldinfo */
@@ -701,11 +671,6 @@ bool patcher_invokeinterface(u1 *sp)
        mcode =                       *((u4 *)     (sp + 3 * 4));
        um    = (unresolved_method *) *((ptrint *) (sp + 2 * 4));
 
-       /* calculate and set the new return address */
-
-       ra = ra - 4;
-       *((ptrint *) (sp + 5 * 4)) = (ptrint) ra;
-
        PATCHER_MONITORENTER;
 
        /* get the fieldinfo */
@@ -773,11 +738,6 @@ bool patcher_checkcast_instanceof_flags(u1 *sp)
        disp  =                       *((s4 *)     (sp + 1 * 4));
        pv    = (u1 *)                *((ptrint *) (sp + 0 * 4));
 
-       /* calculate and set the new return address */
-
-       ra = ra - 4;
-       *((ptrint *) (sp + 5 * 4)) = (ptrint) ra;
-
        PATCHER_MONITORENTER;
 
        /* get the fieldinfo */
@@ -834,11 +794,6 @@ bool patcher_checkcast_instanceof_interface(u1 *sp)
        mcode =                       *((u4 *)     (sp + 3 * 4));
        cr    = (constant_classref *) *((ptrint *) (sp + 2 * 4));
 
-       /* calculate and set the new return address */
-
-       ra = ra - 4;
-       *((ptrint *) (sp + 5 * 4)) = (ptrint) ra;
-
        PATCHER_MONITORENTER;
 
        /* get the fieldinfo */
@@ -905,11 +860,6 @@ bool patcher_checkcast_class(u1 *sp)
        disp  =                       *((s4 *)     (sp + 1 * 4));
        pv    = (u1 *)                *((ptrint *) (sp + 0 * 4));
 
-       /* calculate and set the new return address */
-
-       ra = ra - 4;
-       *((ptrint *) (sp + 5 * 4)) = (ptrint) ra;
-
        PATCHER_MONITORENTER;
 
        /* get the fieldinfo */
@@ -967,11 +917,6 @@ bool patcher_instanceof_class(u1 *sp)
        disp  =                       *((s4 *)     (sp + 1 * 4));
        pv    = (u1 *)                *((ptrint *) (sp + 0 * 4));
 
-       /* calculate and set the new return address */
-
-       ra = ra - 4;
-       *((ptrint *) (sp + 5 * 4)) = (ptrint) ra;
-
        PATCHER_MONITORENTER;
 
        /* get the fieldinfo */
@@ -1020,11 +965,6 @@ bool patcher_clinit(u1 *sp)
        mcode =                       *((u4 *)     (sp + 3 * 4));
        c     = (classinfo *)         *((ptrint *) (sp + 2 * 4));
 
-       /* calculate and set the new return address */
-
-       ra = ra - 4;
-       *((ptrint *) (sp + 5 * 4)) = (ptrint) ra;
-
        PATCHER_MONITORENTER;
 
        /* check if the class is initialized */
@@ -1074,11 +1014,6 @@ bool patcher_athrow_areturn(u1 *sp)
        mcode =                       *((u4 *)     (sp + 3 * 4));
        uc    = (unresolved_class *)  *((ptrint *) (sp + 2 * 4));
 
-       /* calculate and set the new return address */
-
-       ra = ra - 4;
-       *((ptrint *) (sp + 5 * 4)) = (ptrint) ra;
-
        PATCHER_MONITORENTER;
 
        /* resolve the class */
@@ -1131,7 +1066,7 @@ bool patcher_resolve_native(u1 *sp)
 
        /* calculate and set the new return address */
 
-       ra = ra - 4;
+       ra = ra - 1 * 4;
        *((ptrint *) (sp + 5 * 4)) = (ptrint) ra;
 
        PATCHER_MONITORENTER;