* src/vm/jit/i386/codegen.c (GETFIELD, PUTFIELD, PUTFIELDCONST): Use
authortwisti <none@none>
Wed, 15 Mar 2006 11:18:30 +0000 (11:18 +0000)
committertwisti <none@none>
Wed, 15 Mar 2006 11:18:30 +0000 (11:18 +0000)
M_ILD32 and M_LLD32 macros.
(patcher): Save REG_ITMP3. Don't allocate a codegendata structure,
just do it as on Alpha.
* src/vm/jit/i386/codegen.h (var_to_reg_lng): Added.
(store_reg_to_var_lng): Likewise.
(M_ILD32, M_LLD, M_LLD32, M_IST32, M_IST32_IMM, M_LST, M_LST32)
(M_LST_IMM, M_LST32_IMM): Likewise.

* src/vm/jit/i386/patcher.c: Changed position of return address due to
saving of REG_ITMP3.
* src/vm/jit/i386/asmpart.S (asm_wrapper_patcher): Changed due to
saving of REG_ITMP3.

src/vm/jit/i386/asmpart.S
src/vm/jit/i386/codegen.c
src/vm/jit/i386/codegen.h
src/vm/jit/i386/patcher.c

index 01b8fd8465fd5926472a7721b6b363f10636cb1b..7e961126841c07e9f2d2a88d3f2ff91c896c6ec1 100644 (file)
@@ -31,7 +31,7 @@
    Changes: Joseph Wenninger
             Edwin Steiner
 
-   $Id: asmpart.S 4606 2006-03-15 04:43:25Z edwin $
+   $Id: asmpart.S 4611 2006-03-15 11:18:30Z twisti $
 
 */
 
@@ -471,7 +471,8 @@ noflt:
    XXX
 
    Stack layout:
-     20   return address
+     24   return address
+     20   REG_ITMP3
      16   pointer to virtual java_objectheader
      12   last byte of machine code (xmcode)
       8   machine code (which is patched back later)
@@ -491,9 +492,9 @@ asm_wrapper_patcher:
        mov     itmp1,0*4(sp)               /* stackframeinfo pointer             */
        movl    $0,1*4(sp)                  /* if pv is NULL, use findmethod      */
        mov     sp,itmp2
-       add     $((6+2+4)*4+sizestackframeinfo),itmp2
+       add     $((7+2+4)*4+sizestackframeinfo),itmp2
        mov     itmp2,2*4(sp)               /* pass Java sp                       */
-       mov     ((5+2+4)*4+sizestackframeinfo)(sp),itmp3
+       mov     ((6+2+4)*4+sizestackframeinfo)(sp),itmp3
        mov     itmp3,3*4(sp)               /* pass ra to java function           */
        call    stacktrace_create_inline_stackframeinfo
 
@@ -509,16 +510,20 @@ asm_wrapper_patcher:
        mov     itmp1,0*4(sp)               /* stackframeinfo pointer             */
        call    stacktrace_remove_stackframeinfo
 
-       mov     (0+4)*4(sp),itmp1           /* restore itmp1 and itmp2            */
-       mov     (1+4)*4(sp),itmp2           /* may be used by some instructions   */
        mov     1*4(sp),itmp3               /* restore return value               */
-
-       add     $((5+2+4)*4+sizestackframeinfo),sp /* remove stack frame, keep ra */
        test    itmp3,itmp3                 /* exception thrown?                  */
        jz      L_asm_wrapper_patcher_exception
+
+       mov     (0+4)*4(sp),itmp1           /* restore itmp1 and itmp2            */
+       mov     (1+4)*4(sp),itmp2           /* may be used by some instructions   */
+       mov     ((5+2+4)*4+sizestackframeinfo)(sp),itmp3
+       add     $((6+2+4)*4+sizestackframeinfo),sp /* remove stack frame, keep ra */
+
        ret                                 /* call new patched code              */
 
 L_asm_wrapper_patcher_exception:
+       add     $((6+2+4)*4+sizestackframeinfo),sp /* remove stack frame, keep ra */
+
 #if defined(USE_THREADS) && defined(NATIVE_THREADS)
        call    builtin_asm_get_exceptionptrptr
        mov     v0,itmp2
index 5b6fced3d540012d3618f759c88d4b8428b6faac..4039e6f7232e10b9f7d785df2345c1ffc70126ea 100644 (file)
@@ -31,7 +31,7 @@
             Christian Ullrich
                        Edwin Steiner
 
-   $Id: codegen.c 4606 2006-03-15 04:43:25Z edwin $
+   $Id: codegen.c 4611 2006-03-15 11:18:30Z twisti $
 
 */
 
@@ -3354,15 +3354,13 @@ bool codegen(methodinfo *m, codegendata *cd, registerdata *rd)
                        case TYPE_INT:
                        case TYPE_ADR:
                                d = reg_of_var(rd, iptr->dst, REG_ITMP2);
-                               i386_mov_membase32_reg(cd, s1, disp, d);
+                               M_ILD32(d, s1, disp);
                                store_reg_to_var_int(iptr->dst, d);
                                break;
                        case TYPE_LNG:
-                               d = reg_of_var(rd, iptr->dst, REG_NULL);
-                               i386_mov_membase32_reg(cd, s1, disp, REG_ITMP2);
-                               i386_mov_membase32_reg(cd, s1, disp + 4, REG_ITMP3);
-                               i386_mov_reg_membase(cd, REG_ITMP2, REG_SP, iptr->dst->regoff * 4);
-                               i386_mov_reg_membase(cd, REG_ITMP3, REG_SP, iptr->dst->regoff * 4 + 4);
+                               d = reg_of_var(rd, iptr->dst, PACK_REGS(REG_ITMP2, REG_ITMP3));
+                               M_LLD32(d, s1, disp);
+                               store_reg_to_var_lng(iptr->dst, d);
                                break;
                        case TYPE_FLT:
                                d = reg_of_var(rd, iptr->dst, REG_FTMP1);
@@ -3387,11 +3385,15 @@ bool codegen(methodinfo *m, codegendata *cd, registerdata *rd)
                        var_to_reg_int(s1, src->prev, REG_ITMP1);
                        gen_nullptr_check(s1);
 
-                       if ((iptr->op1 == TYPE_INT) || IS_ADR_TYPE(iptr->op1)) {
-                               var_to_reg_int(s2, src, REG_ITMP2);
-                       } else if (IS_FLT_DBL_TYPE(iptr->op1)) {
+                       /* must be done here because of code patching */
+
+                       if (!IS_FLT_DBL_TYPE(iptr->op1)) {
+                               if (IS_2_WORD_TYPE(iptr->op1))
+                                       var_to_reg_lng(s2, src, PACK_REGS(REG_ITMP2, REG_ITMP3));
+                               else
+                                       var_to_reg_int(s2, src, REG_ITMP2);
+                       } else
                                var_to_reg_flt(s2, src, REG_FTMP2);
-                       }
 
                        if (iptr->val.a == NULL) {
                                codegen_addpatchref(cd, cd->mcodeptr,
@@ -3411,18 +3413,10 @@ bool codegen(methodinfo *m, codegendata *cd, registerdata *rd)
                        switch (iptr->op1) {
                        case TYPE_INT:
                        case TYPE_ADR:
-                               i386_mov_reg_membase32(cd, s2, s1, disp);
+                               M_IST32(s2, s1, disp);
                                break;
                        case TYPE_LNG:
-                               if (src->flags & INMEMORY) {
-                                       i386_mov_membase32_reg(cd, REG_SP, src->regoff * 4, REG_ITMP2);
-                                       i386_mov_membase32_reg(cd, REG_SP, src->regoff * 4 + 4, REG_ITMP3);
-                                       i386_mov_reg_membase32(cd, REG_ITMP2, s1, disp);
-                                       i386_mov_reg_membase32(cd, REG_ITMP3, s1, disp + 4);
-                               } else {
-                                       log_text("PUTFIELD: longs have to be in memory");
-                                       assert(0);
-                               }
+                               M_LST32(s2, s1, disp);
                                break;
                        case TYPE_FLT:
                                i386_fstps_membase32(cd, s1, disp);
@@ -3464,12 +3458,11 @@ bool codegen(methodinfo *m, codegendata *cd, registerdata *rd)
                        case TYPE_INT:
                        case TYPE_FLT:
                        case TYPE_ADR:
-                               i386_mov_imm_membase32(cd, iptr->val.i, s1, disp);
+                               M_IST32_IMM(iptr->val.i, s1, disp);
                                break;
                        case TYPE_LNG:
                        case TYPE_DBL:
-                               i386_mov_imm_membase32(cd, iptr->val.l, s1, disp);
-                               i386_mov_imm_membase32(cd, iptr->val.l >> 32, s1, disp + 4);
+                               M_LST32_IMM(iptr->val.l, s1, disp);
                                break;
                        }
                        break;
@@ -3520,7 +3513,7 @@ bool codegen(methodinfo *m, codegendata *cd, registerdata *rd)
                        /* REG_RES Register usage: see icmd_uses_reg_res.inc */
                        /* EAX: YES ECX: YES EDX: YES OUTPUT: REG_NULL*/ 
 
-                       i386_call_imm(cd, 0);
+                       M_CALL_IMM(0);
                        codegen_addreference(cd, (basicblock *) iptr->target, cd->mcodeptr);
                        break;
                        
@@ -5427,27 +5420,33 @@ gen_method:
        /* generate code patching stub call code */
 
        {
-               patchref    *pref;
-               codegendata *tmpcd;
-               u8           mcode;
-
-               tmpcd = DNEW(codegendata);
+               patchref *pref;
+               u8        mcode;
+               u1       *tmpmcodeptr;
 
                for (pref = cd->patchrefs; pref != NULL; pref = pref->next) {
                        /* check code segment size */
 
                        MCODECHECK(512);
 
-                       /* Get machine code which is patched back in later. A             */
-                       /* `call rel32' is 5 bytes long.                                  */
+                       /* Get machine code which is patched back in later. A
+                          `call rel32' is 5 bytes long. */
 
                        xcodeptr = cd->mcodebase + pref->branchpos;
                        mcode = *((u8 *) xcodeptr);
 
-                       /* patch in `call rel32' to call the following code               */
+                       /* patch in `call rel32' to call the following code */
+
+                       tmpmcodeptr  = cd->mcodeptr;    /* save current mcodeptr          */
+                       cd->mcodeptr = xcodeptr;        /* set mcodeptr to patch position */
 
-                       tmpcd->mcodeptr = xcodeptr;     /* set dummy mcode pointer        */
-                       i386_call_imm(tmpcd, cd->mcodeptr - (xcodeptr + 5));
+                       M_CALL_IMM(tmpmcodeptr - (xcodeptr + PATCHER_CALL_SIZE));
+
+                       cd->mcodeptr = tmpmcodeptr;     /* restore the current mcodeptr   */
+
+                       /* save REG_ITMP3 */
+
+                       M_PUSH(REG_ITMP3);
 
                        /* move pointer to java_objectheader onto stack */
 
@@ -5884,24 +5883,30 @@ u1 *createnativestub(functionptr f, methodinfo *m, codegendata *cd,
        /* process patcher calls **************************************************/
 
        {
-               u1          *xcodeptr;
-               patchref    *pref;
-               codegendata *tmpcd;
-               u8           mcode;
-
-               tmpcd = DNEW(codegendata);
+               u1       *xcodeptr;
+               patchref *pref;
+               u8        mcode;
+               u1       *tmpmcodeptr;
 
                for (pref = cd->patchrefs; pref != NULL; pref = pref->next) {
-                       /* Get machine code which is patched back in later. A             */
-                       /* `call rel32' is 5 bytes long.                                  */
+                       /* Get machine code which is patched back in later. A
+                          `call rel32' is 5 bytes long. */
 
                        xcodeptr = cd->mcodebase + pref->branchpos;
                        mcode =  *((u8 *) xcodeptr);
 
-                       /* patch in `call rel32' to call the following code               */
+                       /* patch in `call rel32' to call the following code */
 
-                       tmpcd->mcodeptr = xcodeptr;     /* set dummy mcode pointer        */
-                       i386_call_imm(tmpcd, cd->mcodeptr - (xcodeptr + 5));
+                       tmpmcodeptr  = cd->mcodeptr;    /* save current mcodeptr          */
+                       cd->mcodeptr = xcodeptr;        /* set mcodeptr to patch position */
+
+                       M_CALL_IMM(tmpmcodeptr - (xcodeptr + PATCHER_CALL_SIZE));
+
+                       cd->mcodeptr = tmpmcodeptr;     /* restore the current mcodeptr   */
+
+                       /* save REG_ITMP3 */
+
+                       M_PUSH(REG_ITMP3);
 
                        /* move pointer to java_objectheader onto stack */
 
index 7e558cdd1ba242e82df78e44be9dee86881c4ec1..c7f9ca7cad9d8cd8e90ae5681defdc7f9817974a 100644 (file)
@@ -29,7 +29,7 @@
 
    Changes:
 
-   $Id: codegen.h 4389 2006-01-30 16:25:20Z twisti $
+   $Id: codegen.h 4611 2006-03-15 11:18:30Z twisti $
 
 */
 
 */
 
 #define var_to_reg_int(regnr,v,tempnr) \
-    if ((v)->flags & INMEMORY) { \
-        COUNT_SPILLS; \
-        i386_mov_membase_reg(cd, REG_SP, (v)->regoff * 4, tempnr); \
-        regnr = tempnr; \
-    } else { \
-        regnr = (v)->regoff; \
-    }
-
+    do { \
+        if ((v)->flags & INMEMORY) { \
+            COUNT_SPILLS; \
+            M_ILD(tempnr, REG_SP, (v)->regoff * 4); \
+            regnr = tempnr; \
+        } else { \
+            regnr = (v)->regoff; \
+        } \
+    } while (0)
 
+#define var_to_reg_lng(regnr,v,tempnr) \
+    do { \
+        if ((v)->flags & INMEMORY) { \
+            COUNT_SPILLS; \
+            M_LLD(tempnr, REG_SP, (v)->regoff * 4); \
+            regnr = tempnr; \
+        } else { \
+            regnr = (v)->regoff; \
+        } \
+    } while (0)
 
 #define var_to_reg_flt(regnr,v,tempnr) \
     if ((v)->type == TYPE_FLT) { \
 #define store_reg_to_var_int(sptr, tempregnum) \
     if ((sptr)->flags & INMEMORY) { \
         COUNT_SPILLS; \
-        i386_mov_reg_membase(cd, tempregnum, REG_SP, (sptr)->regoff * 4); \
+        M_IST(tempregnum, REG_SP, (sptr)->regoff * 4); \
+    }
+
+
+#define store_reg_to_var_lng(sptr, tempregnum) \
+    if ((sptr)->flags & INMEMORY) { \
+        COUNT_SPILLS; \
+        M_LST(tempregnum, REG_SP, (sptr)->regoff * 4); \
     }
 
 
@@ -459,11 +477,52 @@ typedef enum {
 #define M_ILD(a,b,disp)         i386_mov_membase_reg(cd, (b), (disp), (a))
 #define M_ALD(a,b,disp)         M_ILD(a,b,disp)
 
+#define M_ILD32(a,b,disp)       i386_mov_membase32_reg(cd, (b), (disp), (a))
+
+#define M_LLD(a,b,disp) \
+    do { \
+        M_ILD(GET_LOW_REG(a),b,disp); \
+        M_ILD(GET_HIGH_REG(a),b,disp + 4); \
+    } while (0)
+
+#define M_LLD32(a,b,disp) \
+    do { \
+        M_ILD32(GET_LOW_REG(a),b,disp); \
+        M_ILD32(GET_HIGH_REG(a),b,disp + 4); \
+    } while (0)
+
 #define M_IST(a,b,disp)         i386_mov_reg_membase(cd, (a), (b), (disp))
 #define M_IST_IMM(a,b,disp)     i386_mov_imm_membase(cd, (a), (b), (disp))
 #define M_AST(a,b,disp)         M_IST(a,b,disp)
 #define M_AST_IMM(a,b,disp)     M_IST_IMM(a,b,disp)
 
+#define M_IST32(a,b,disp)       i386_mov_reg_membase32(cd, (a), (b), (disp))
+#define M_IST32_IMM(a,b,disp)   i386_mov_imm_membase32(cd, (a), (b), (disp))
+
+#define M_LST(a,b,disp) \
+    do { \
+        M_IST(GET_LOW_REG(a),b,disp); \
+        M_IST(GET_HIGH_REG(a),b,disp + 4); \
+    } while (0)
+
+#define M_LST32(a,b,disp) \
+    do { \
+        M_IST32(GET_LOW_REG(a),b,disp); \
+        M_IST32(GET_HIGH_REG(a),b,disp + 4); \
+    } while (0)
+
+#define M_LST_IMM(a,b,disp) \
+    do { \
+        M_IST_IMM(a,b,disp); \
+        M_IST_IMM(a >> 32,b,disp + 4); \
+    } while (0)
+
+#define M_LST32_IMM(a,b,disp) \
+    do { \
+        M_IST32_IMM(a,b,disp); \
+        M_IST32_IMM(a >> 32,b,disp + 4); \
+    } while (0)
+
 #define M_IADD_IMM(a,b)         i386_alu_imm_reg(cd, ALU_ADD, (a), (b))
 #define M_IADD_IMM32(a,b)       i386_alu_imm32_reg(cd, ALU_ADD, (a), (b))
 #define M_ISUB_IMM(a,b)         i386_alu_imm_reg(cd, ALU_SUB, (a), (b))
index 386501ae77c9479548ea5937cc3493a7d1f9d888..252fe28b8e4160c47ffc8253f3842bb5eca8ac9e 100644 (file)
@@ -28,7 +28,7 @@
 
    Changes:
 
-   $Id: patcher.c 4530 2006-02-21 09:11:53Z twisti $
+   $Id: patcher.c 4611 2006-03-15 11:18:30Z twisti $
 
 */
 
@@ -46,6 +46,7 @@
 #include "vm/resolve.h"
 #include "vm/references.h"
 #include "vm/jit/patcher.h"
+#include "vm/jit/i386/codegen.h"
 
 
 /* patcher_get_putstatic *******************************************************
@@ -67,15 +68,15 @@ bool patcher_get_putstatic(u1 *sp)
 
        /* get stuff from the stack */
 
-       ra    = (u1 *)                *((ptrint *) (sp + 4 * 4));
+       ra    = (u1 *)                *((ptrint *) (sp + 5 * 4));
        o     = (java_objectheader *) *((ptrint *) (sp + 3 * 4));
        mcode =                       *((u8 *)     (sp + 1 * 4));
        uf    = (unresolved_field *)  *((ptrint *) (sp + 0 * 4));
 
        /* calculate and set the new return address */
 
-       ra = ra - 5;
-       *((ptrint *) (sp + 4 * 4)) = (ptrint) ra;
+       ra = ra - PATCHER_CALL_SIZE;
+       *((ptrint *) (sp + 5 * 4)) = (ptrint) ra;
 
        PATCHER_MONITORENTER;
 
@@ -136,15 +137,15 @@ bool patcher_getfield(u1 *sp)
 
        /* get stuff from the stack */
 
-       ra    = (u1 *)                *((ptrint *) (sp + 4 * 4));
+       ra    = (u1 *)                *((ptrint *) (sp + 5 * 4));
        o     = (java_objectheader *) *((ptrint *) (sp + 3 * 4));
        mcode =                       *((u8 *)     (sp + 1 * 4));
        uf    = (unresolved_field *)  *((ptrint *) (sp + 0 * 4));
 
        /* calculate and set the new return address */
 
-       ra = ra - 5;
-       *((ptrint *) (sp + 4 * 4)) = (ptrint) ra;
+       ra = ra - PATCHER_CALL_SIZE;
+       *((ptrint *) (sp + 5 * 4)) = (ptrint) ra;
 
        PATCHER_MONITORENTER;
 
@@ -200,15 +201,15 @@ bool patcher_putfield(u1 *sp)
 
        /* get stuff from the stack */
 
-       ra    = (u1 *)                *((ptrint *) (sp + 4 * 4));
+       ra    = (u1 *)                *((ptrint *) (sp + 5 * 4));
        o     = (java_objectheader *) *((ptrint *) (sp + 3 * 4));
        mcode =                       *((u8 *)     (sp + 1 * 4));
        uf    = (unresolved_field *)  *((ptrint *) (sp + 0 * 4));
 
        /* calculate and set the new return address */
 
-       ra = ra - 5;
-       *((ptrint *) (sp + 4 * 4)) = (ptrint) ra;
+       ra = ra - PATCHER_CALL_SIZE;
+       *((ptrint *) (sp + 5 * 4)) = (ptrint) ra;
 
        PATCHER_MONITORENTER;
 
@@ -236,16 +237,14 @@ bool patcher_putfield(u1 *sp)
                *((u4 *) (ra + 2)) = (u4) (fi->offset);
 
        } else {
-               /* long code is very special:
+               /* The long code is special:
                 *
-                * 8b 8c 24 00 00 00 00       mov    0x00000000(%esp),%ecx
-                * 8b 94 24 00 00 00 00       mov    0x00000000(%esp),%edx
                 * 89 8d 00 00 00 00          mov    %ecx,0x00000000(%ebp)
                 * 89 95 00 00 00 00          mov    %edx,0x00000000(%ebp)
                 */
 
-               *((u4 *) (ra + 7 + 7 + 2)) = (u4) (fi->offset);
-               *((u4 *) (ra + 7 + 7 + 6 + 2)) = (u4) (fi->offset + 4);
+               *((u4 *) (ra + 2))     = (u4) (fi->offset);
+               *((u4 *) (ra + 6 + 2)) = (u4) (fi->offset + 4);
        }
 
        PATCHER_MARK_PATCHED_MONITOREXIT;
@@ -273,15 +272,15 @@ bool patcher_putfieldconst(u1 *sp)
 
        /* get stuff from the stack */
 
-       ra    = (u1 *)                *((ptrint *) (sp + 4 * 4));
+       ra    = (u1 *)                *((ptrint *) (sp + 5 * 4));
        o     = (java_objectheader *) *((ptrint *) (sp + 3 * 4));
        mcode =                       *((u8 *)     (sp + 1 * 4));
        uf    = (unresolved_field *)  *((ptrint *) (sp + 0 * 4));
 
        /* calculate and set the new return address */
 
-       ra = ra - 5;
-       *((ptrint *) (sp + 4 * 4)) = (ptrint) ra;
+       ra = ra - PATCHER_CALL_SIZE;
+       *((ptrint *) (sp + 5 * 4)) = (ptrint) ra;
 
        PATCHER_MONITORENTER;
 
@@ -345,15 +344,15 @@ bool patcher_aconst(u1 *sp)
 
        /* get stuff from the stack */
 
-       ra    = (u1 *)                *((ptrint *) (sp + 4 * 4));
+       ra    = (u1 *)                *((ptrint *) (sp + 5 * 4));
        o     = (java_objectheader *) *((ptrint *) (sp + 3 * 4));
        mcode =                       *((u8 *)     (sp + 1 * 4));
        cr    = (constant_classref *) *((ptrint *) (sp + 0 * 4));
 
        /* calculate and set the new return address */
 
-       ra = ra - 5;
-       *((ptrint *) (sp + 4 * 4)) = (ptrint) ra;
+       ra = ra - PATCHER_CALL_SIZE;
+       *((ptrint *) (sp + 5 * 4)) = (ptrint) ra;
 
        PATCHER_MONITORENTER;
 
@@ -410,15 +409,15 @@ bool patcher_builtin_multianewarray(u1 *sp)
 
        /* get stuff from the stack */
 
-       ra    = (u1 *)                *((ptrint *) (sp + 4 * 4));
+       ra    = (u1 *)                *((ptrint *) (sp + 5 * 4));
        o     = (java_objectheader *) *((ptrint *) (sp + 3 * 4));
        mcode =                       *((u8 *)     (sp + 1 * 4));
        cr    = (constant_classref *) *((ptrint *) (sp + 0 * 4));
 
        /* calculate and set the new return address */
 
-       ra = ra - 5;
-       *((ptrint *) (sp + 4 * 4)) = (ptrint) ra;
+       ra = ra - PATCHER_CALL_SIZE;
+       *((ptrint *) (sp + 5 * 4)) = (ptrint) ra;
 
        PATCHER_MONITORENTER;
 
@@ -475,15 +474,15 @@ bool patcher_builtin_arraycheckcast(u1 *sp)
 
        /* get stuff from the stack */
 
-       ra    = (u1 *)                *((ptrint *) (sp + 4 * 4));
+       ra    = (u1 *)                *((ptrint *) (sp + 5 * 4));
        o     = (java_objectheader *) *((ptrint *) (sp + 3 * 4));
        mcode =                       *((u8 *)     (sp + 1 * 4));
        cr    = (constant_classref *) *((ptrint *) (sp + 0 * 4));
 
        /* calculate and set the new return address */
 
-       ra = ra - 5;
-       *((ptrint *) (sp + 4 * 4)) = (ptrint) ra;
+       ra = ra - PATCHER_CALL_SIZE;
+       *((ptrint *) (sp + 5 * 4)) = (ptrint) ra;
 
        PATCHER_MONITORENTER;
 
@@ -539,15 +538,15 @@ bool patcher_invokestatic_special(u1 *sp)
 
        /* get stuff from the stack */
 
-       ra    = (u1 *)                *((ptrint *) (sp + 4 * 4));
+       ra    = (u1 *)                *((ptrint *) (sp + 5 * 4));
        o     = (java_objectheader *) *((ptrint *) (sp + 3 * 4));
        mcode =                       *((u8 *)     (sp + 1 * 4));
        um    = (unresolved_method *) *((ptrint *) (sp + 0 * 4));
 
        /* calculate and set the new return address */
 
-       ra = ra - 5;
-       *((ptrint *) (sp + 4 * 4)) = (ptrint) ra;
+       ra = ra - PATCHER_CALL_SIZE;
+       *((ptrint *) (sp + 5 * 4)) = (ptrint) ra;
 
        PATCHER_MONITORENTER;
 
@@ -600,15 +599,15 @@ bool patcher_invokevirtual(u1 *sp)
 
        /* get stuff from the stack */
 
-       ra    = (u1 *)                *((ptrint *) (sp + 4 * 4));
+       ra    = (u1 *)                *((ptrint *) (sp + 5 * 4));
        o     = (java_objectheader *) *((ptrint *) (sp + 3 * 4));
        mcode =                       *((u8 *)     (sp + 1 * 4));
        um    = (unresolved_method *) *((ptrint *) (sp + 0 * 4));
 
        /* calculate and set the new return address */
 
-       ra = ra - 5;
-       *((ptrint *) (sp + 4 * 4)) = (ptrint) ra;
+       ra = ra - PATCHER_CALL_SIZE;
+       *((ptrint *) (sp + 5 * 4)) = (ptrint) ra;
 
        PATCHER_MONITORENTER;
 
@@ -663,15 +662,15 @@ bool patcher_invokeinterface(u1 *sp)
 
        /* get stuff from the stack */
 
-       ra    = (u1 *)                *((ptrint *) (sp + 4 * 4));
+       ra    = (u1 *)                *((ptrint *) (sp + 5 * 4));
        o     = (java_objectheader *) *((ptrint *) (sp + 3 * 4));
        mcode =                       *((u8 *)     (sp + 1 * 4));
        um    = (unresolved_method *) *((ptrint *) (sp + 0 * 4));
 
        /* calculate and set the new return address */
 
-       ra = ra - 5;
-       *((ptrint *) (sp + 4 * 4)) = (ptrint) ra;
+       ra = ra - PATCHER_CALL_SIZE;
+       *((ptrint *) (sp + 5 * 4)) = (ptrint) ra;
 
        PATCHER_MONITORENTER;
 
@@ -728,15 +727,15 @@ bool patcher_checkcast_instanceof_flags(u1 *sp)
 
        /* get stuff from the stack */
 
-       ra    = (u1 *)                *((ptrint *) (sp + 4 * 4));
+       ra    = (u1 *)                *((ptrint *) (sp + 5 * 4));
        o     = (java_objectheader *) *((ptrint *) (sp + 3 * 4));
        mcode =                       *((u8 *)     (sp + 1 * 4));
        cr    = (constant_classref *) *((ptrint *) (sp + 0 * 4));
 
        /* calculate and set the new return address */
 
-       ra = ra - 5;
-       *((ptrint *) (sp + 4 * 4)) = (ptrint) ra;
+       ra = ra - PATCHER_CALL_SIZE;
+       *((ptrint *) (sp + 5 * 4)) = (ptrint) ra;
 
        PATCHER_MONITORENTER;
 
@@ -791,15 +790,15 @@ bool patcher_checkcast_instanceof_interface(u1 *sp)
 
        /* get stuff from the stack */
 
-       ra    = (u1 *)                *((ptrint *) (sp + 4 * 4));
+       ra    = (u1 *)                *((ptrint *) (sp + 5 * 4));
        o     = (java_objectheader *) *((ptrint *) (sp + 3 * 4));
        mcode =                       *((u8 *)     (sp + 1 * 4));
        cr    = (constant_classref *) *((ptrint *) (sp + 0 * 4));
 
        /* calculate and set the new return address */
 
-       ra = ra - 5;
-       *((ptrint *) (sp + 4 * 4)) = (ptrint) ra;
+       ra = ra - PATCHER_CALL_SIZE;
+       *((ptrint *) (sp + 5 * 4)) = (ptrint) ra;
 
        PATCHER_MONITORENTER;
 
@@ -858,15 +857,15 @@ bool patcher_checkcast_class(u1 *sp)
 
        /* get stuff from the stack */
 
-       ra    = (u1 *)                *((ptrint *) (sp + 4 * 4));
+       ra    = (u1 *)                *((ptrint *) (sp + 5 * 4));
        o     = (java_objectheader *) *((ptrint *) (sp + 3 * 4));
        mcode =                       *((u8 *)     (sp + 1 * 4));
        cr    = (constant_classref *) *((ptrint *) (sp + 0 * 4));
 
        /* calculate and set the new return address */
 
-       ra = ra - 5;
-       *((ptrint *) (sp + 4 * 4)) = (ptrint) ra;
+       ra = ra - PATCHER_CALL_SIZE;
+       *((ptrint *) (sp + 5 * 4)) = (ptrint) ra;
 
        PATCHER_MONITORENTER;
 
@@ -921,15 +920,15 @@ bool patcher_instanceof_class(u1 *sp)
 
        /* get stuff from the stack */
 
-       ra    = (u1 *)                *((ptrint *) (sp + 4 * 4));
+       ra    = (u1 *)                *((ptrint *) (sp + 5 * 4));
        o     = (java_objectheader *) *((ptrint *) (sp + 3 * 4));
        mcode =                       *((u8 *)     (sp + 1 * 4));
        cr    = (constant_classref *) *((ptrint *) (sp + 0 * 4));
 
        /* calculate and set the new return address */
 
-       ra = ra - 5;
-       *((ptrint *) (sp + 4 * 4)) = (ptrint) ra;
+       ra = ra - PATCHER_CALL_SIZE;
+       *((ptrint *) (sp + 5 * 4)) = (ptrint) ra;
 
        PATCHER_MONITORENTER;
 
@@ -980,15 +979,15 @@ bool patcher_clinit(u1 *sp)
 
        /* get stuff from the stack */
 
-       ra    = (u1 *)                *((ptrint *) (sp + 4 * 4));
+       ra    = (u1 *)                *((ptrint *) (sp + 5 * 4));
        o     = (java_objectheader *) *((ptrint *) (sp + 3 * 4));
        mcode =                       *((u8 *)     (sp + 1 * 4));
        c     = (classinfo *)         *((ptrint *) (sp + 0 * 4));
 
        /* calculate and set the new return address */
 
-       ra = ra - 5;
-       *((ptrint *) (sp + 4 * 4)) = (ptrint) ra;
+       ra = ra - PATCHER_CALL_SIZE;
+       *((ptrint *) (sp + 5 * 4)) = (ptrint) ra;
 
        PATCHER_MONITORENTER;
 
@@ -1032,15 +1031,15 @@ bool patcher_athrow_areturn(u1 *sp)
 
        /* get stuff from the stack */
 
-       ra    = (u1 *)                *((ptrint *) (sp + 4 * 4));
+       ra    = (u1 *)                *((ptrint *) (sp + 5 * 4));
        o     = (java_objectheader *) *((ptrint *) (sp + 3 * 4));
        mcode =                       *((u8 *)     (sp + 1 * 4));
        uc    = (unresolved_class *)  *((ptrint *) (sp + 0 * 4));
 
        /* calculate and set the new return address */
 
-       ra = ra - 5;
-       *((ptrint *) (sp + 4 * 4)) = (ptrint) ra;
+       ra = ra - PATCHER_CALL_SIZE;
+       *((ptrint *) (sp + 5 * 4)) = (ptrint) ra;
 
        PATCHER_MONITORENTER;
 
@@ -1086,15 +1085,15 @@ bool patcher_resolve_native(u1 *sp)
 
        /* get stuff from the stack */
 
-       ra    = (u1 *)                *((ptrint *) (sp + 4 * 4));
+       ra    = (u1 *)                *((ptrint *) (sp + 5 * 4));
        o     = (java_objectheader *) *((ptrint *) (sp + 3 * 4));
        mcode =                       *((u8 *)     (sp + 1 * 4));
        m     = (methodinfo *)        *((ptrint *) (sp + 0 * 4));
 
        /* calculate and set the new return address */
 
-       ra = ra - 5;
-       *((ptrint *) (sp + 4 * 4)) = (ptrint) ra;
+       ra = ra - PATCHER_CALL_SIZE;
+       *((ptrint *) (sp + 5 * 4)) = (ptrint) ra;
 
        PATCHER_MONITORENTER;