* src/vm/jit/s390/asmpart.S
authorPeter Molnar <pm@complang.tuwien.ac.at>
Wed, 12 Sep 2007 21:17:38 +0000 (21:17 +0000)
committerPeter Molnar <pm@complang.tuwien.ac.at>
Wed, 12 Sep 2007 21:17:38 +0000 (21:17 +0000)
src/vm/jit/s390/codegen.c,
src/vm/jit/s390/codegen.h,
src/vm/jit/s390/emit.c,
src/vm/jit/s390/emit.h,
src/vm/jit/s390/md-abi.c,
src/vm/jit/s390/md-abi.h,
src/vm/jit/s390/md-asm.h,
src/vm/jit/s390/md.c: Changed JIT ABI on s390: R0 is now REG_ITMP3, R12 is a saved register, REG_ITMPs are reordered, REG_ITMP1_XPTR is now REG_ITMP3_XPTR, REG_ITMP2_XPC is now REG_ITMP1_XPC.

src/vm/jit/s390/asmpart.S
src/vm/jit/s390/codegen.c
src/vm/jit/s390/codegen.h
src/vm/jit/s390/emit.c
src/vm/jit/s390/emit.h
src/vm/jit/s390/md-abi.c
src/vm/jit/s390/md-abi.h
src/vm/jit/s390/md-asm.h
src/vm/jit/s390/md.c

index a19454c55a33fdd138e9186d489e6633f066f749..ac8b9046a066cfe03f96abffc6df4455af49f56b 100644 (file)
@@ -86,7 +86,7 @@ asm_builtin_d2l:
  *
  * The offset table used is located at the bottom of this file.
  *
- * Note: destroys r12/itmp2. r12 MUST contain GOT for PIC calls!
+ * Note: destroys r12. r12 MUST contain GOT for PIC calls!
  */
 #define CALL_PIC(func, tag)                                                         \
        bras   %r14, L_bras_##tag;                           /* get PC */               \
@@ -139,7 +139,7 @@ asm_vm_call_method_double:
        st    s0, 0*4(sp)           /* store used calle saved registers */
        st    s1, 1*4(sp)
        st    a0, 2*4(sp)
-       st    mptr, 3*4(sp)         /* mptr/itmp2 is callee saved in terms of C abi */
+       st    %r12, 3*4(sp)         /* %r12 is callee saved, we'll need it as GOT */
        st    pv, 4*4(sp)
        st    a4, 5*4(sp)           /* a4 is callee saved in terms of C abi */
        std   ftmp1, 6*4(sp)        /* ftmp1 and ftmp2 are callees saved in terms of C abi */
@@ -186,7 +186,7 @@ L_asm_vm_call_method_return:
 
        l     s0, 0*4(sp)           /* restore used callee saved registers */
        l     s1, 1*4(sp)
-       l     mptr, 3*4(sp)
+       l     %r12, 3*4(sp)
        l     pv, 4*4(sp)
        l     a4, 5*4(sp)
        ld    ftmp1, 6*4(sp)
@@ -213,8 +213,8 @@ asm_vm_call_method_end:
 *                                                                              *
 *   invokes the compiler for untranslated JavaVM methods.                      *
 *                                                                              *
-*   itmp1: methodinfo pointer                                                  *
-*   itmp2: method pointer                                                      *
+*   itmp3: methodinfo pointer                                                  *
+*   itmp1: method pointer                                                      *
 *                                                                              *
 *******************************************************************************/
 
@@ -239,19 +239,20 @@ argument registers: arguments (like in JIT)
 asm_call_jit_compiler:
 L_asm_call_jit_compiler:
 
-#      define ACJC_STACKFRAME (4 + (4 * 4) + (2 * 8) + 96 + 4)
+#      define ACJC_STACKFRAME ((2 * 4) + (4 * 4) + (2 * 8) + 96)
 
        ahi     sp,-ACJC_STACKFRAME        /* allocate stack space */
 
        stm         %r2,%r5,96(sp)             /* store volatile int arg regs */
        std     %f0,96+16(sp)              /* store volatile float arg regs */
        std     %f2,96+24(sp)              
-       st      %r14,96+32(sp)             /* store return address */
+       st      %r12,96+32(sp)             /* store %r12, used as GOT pointer */
+       st      %r14,96+36(sp)             /* store return address */
 
        /* load arguments */
 
-       lr      a0,itmp1                   /* pass methodinfo pointer            */
-       lr      a1,itmp2                   /* pass method pointer                */
+       lr      a0,itmp3                   /* pass methodinfo pointer            */
+       lr      a1,mptr                    /* pass method pointer                */
        la      a2,ACJC_STACKFRAME(sp)     /* pass java sp                       */
        la      a3,0(%r14)                 /* pass return address, make sure bit 32 is 0 */
 
@@ -266,7 +267,8 @@ L_asm_call_jit_compiler:
        ltr     pv,pv
        je      L_asm_call_jit_compiler_exception
 
-       l       %r14,96+32(sp)             /* restore return address */
+       l       %r12,96+32(sp)             /* restore %r12 */
+       l       %r14,96+36(sp)             /* restore return address */
        ahi     sp, ACJC_STACKFRAME        /* remove stack frame */
 
 jit_code_entry:                        /* label to set breakpoint on */
@@ -278,7 +280,8 @@ L_asm_call_jit_compiler_exception:
        CALL_PIC(exceptions_get_and_clear_exception, acjce)
 
        lr      xptr, %r2
-       l       xpc,96+32(sp)              /* restore return address */
+       l       xpc,96+36(sp)              /* restore return address */
+       l       %r12,96+32(sp)             /* restore %r12 */
        ahi     sp, ACJC_STACKFRAME        /* remove stack frame */
        j       L_asm_handle_nat_exception
 
@@ -310,8 +313,8 @@ L_asm_handle_exception:
 
        /* store special registers to array */
 
-       st    xptr, REGS+(1*4)(sp)
-       st    xpc, REGS+(12*4)(sp)
+       st    xptr, REGS+(0*4)(sp)
+       st    xpc, REGS+(1*4)(sp)
        st    pv, REGS+(13*4)(sp)
        la    itmp3, STACKFRAMESIZE(sp)
        st    itmp3, REGS+(15*4)(sp)
@@ -334,6 +337,10 @@ L_asm_handle_exception:
        std   %f14, FREGS+(14*8)(sp)
        std   %f15, FREGS+(15*8)(sp)
 
+       /* store %r12 used as GOT */
+       
+       st    %r12, REGS+(12*4)(sp)
+
        /* call md_handle_exception */
 
        la    a0, REGS(sp)
@@ -342,6 +349,10 @@ L_asm_handle_exception:
 
        CALL_PIC(md_handle_exception, ahe)
 
+       /* restore %r12 */
+
+       l     %r12, REGS+(12*4)(sp)
+
        l     itmp3, OUT+(2*4)(sp)  /* out[2] contains maybe leaf flag */
        ltr   itmp3, itmp3           
        je    L_restore_saved
@@ -378,6 +389,10 @@ L_restore_saved:
 
        l     itmp3, OUT+(0*4)(sp)  /* out[0] contains IntSav */
 
+       ahi   itmp3, -1
+       jl    L_int_done
+       l     s5, REGS+(12*4)(sp)
+
        ahi   itmp3, -1
        jl    L_int_done
        l     s4, REGS+(11*4)(sp)
@@ -402,15 +417,7 @@ L_int_done:
 
        /* restore callee saved float registers */
 
-       l     itmp3, OUT+(1*4)(sp)   /* out[1] contains FltSav */
-
-       ahi   itmp3, -1
-       jl    L_flt_done
-       ld    %f6, FREGS+(6*8)(sp)
-
-       ahi   itmp3, -1
-       jl    L_flt_done
-       ld    %f4, FREGS+(4*8)(sp)
+       /* there are currently none */
 
 L_flt_done:
 
@@ -418,8 +425,8 @@ L_restore_done:
 
        /* write new values for special registers */
 
-       l     xptr, REGS+(1*4)(sp)
-       l     xpc, REGS+(12*4)(sp)
+       l     xptr, REGS+(0*4)(sp)
+       l     xpc, REGS+(1*4)(sp)
        l     pv, REGS+(13*4)(sp)  
        l     sp, REGS+(15*4)(sp)   
 
index fb101a1d346b04bfe745105c6e4ec50c915f9e14..222bec0ada5005e605613b38d412329b4d61a9f3 100644 (file)
@@ -177,7 +177,7 @@ bool codegen_emit(jitdata *jd)
        cd->stackframesize = rd->memuse + savedregs_num + 1  /* space to save RA */;
 
        /* CAUTION:
-        * As REG_ITMP3 == REG_RA, do not touch REG_ITMP3, until it has been saved.
+        * As REG_ITMP2 == REG_RA, do not touch REG_ITMP2, until it has been saved.
         */
 
 #if defined(ENABLE_THREADS)
@@ -240,6 +240,16 @@ bool codegen_emit(jitdata *jd)
 
        M_AADD_IMM(N_PV_OFFSET, REG_PV);
 
+       /* create stack frame (if necessary) */
+
+       if (cd->stackframesize) {
+               M_ASUB_IMM(cd->stackframesize * 8, REG_SP);
+       }
+
+       /* store return address */
+
+       M_AST(REG_RA, REG_SP, (cd->stackframesize - 1) * 8);
+
        /* generate method profiling code */
 
 #if defined(ENABLE_PROFILING)
@@ -254,15 +264,9 @@ bool codegen_emit(jitdata *jd)
        }
 #endif
 
-       /* create stack frame (if necessary) */
-
-       if (cd->stackframesize)
-               M_ASUB_IMM(cd->stackframesize * 8, REG_SP);
-
        /* save used callee saved registers and return address */
 
-       p = cd->stackframesize;
-       p--; M_AST(REG_RA, REG_SP, p * 8);
+       p = cd->stackframesize - 1;
 
        for (i = INT_SAV_CNT - 1; i >= rd->savintreguse; i--) {
                p--; M_IST(rd->savintregs[i], REG_SP, p * 8);
@@ -391,12 +395,12 @@ bool codegen_emit(jitdata *jd)
                }
 
                disp = dseg_add_functionptr(cd, LOCK_monitor_enter);
-               M_ALD_DSEG(REG_ITMP3, disp);
+               M_ALD_DSEG(REG_ITMP2, disp);
 
                M_AST(REG_A0, REG_SP, s1 * 8);
 
                M_ASUB_IMM(96, REG_SP); 
-               M_CALL(REG_ITMP3);
+               M_CALL(REG_ITMP2);
                M_AADD_IMM(96, REG_SP); 
 
 #if !defined(NDEBUG)
@@ -475,10 +479,10 @@ bool codegen_emit(jitdata *jd)
                                        if (bptr->type == BBTYPE_EXH) {
 /*                                     d = reg_of_var(rd, src, REG_ITMP1); */
                                                if (!IS_INMEMORY(src->flags))
-                                                       d= src->vv.regoff;
+                                                       d = src->vv.regoff;
                                                else
-                                                       d=REG_ITMP1;
-                                               M_INTMOVE(REG_ITMP1, d);
+                                                       d = REG_ITMP3_XPTR;
+                                               M_INTMOVE(REG_ITMP3_XPTR, d);
                                                emit_store(jd, NULL, src, d);
                                        }
                                }
@@ -492,8 +496,8 @@ bool codegen_emit(jitdata *jd)
                        var = VAR(bptr->invars[len]);
                        if ((len ==  bptr->indepth-1) && (bptr->type != BBTYPE_STD)) {
                                if (bptr->type == BBTYPE_EXH) {
-                                       d = codegen_reg_of_var(0, var, REG_ITMP1);
-                                       M_INTMOVE(REG_ITMP1, d);
+                                       d = codegen_reg_of_var(0, var, REG_ITMP3_XPTR);
+                                       M_INTMOVE(REG_ITMP3_XPTR, d);
                                        emit_store(jd, NULL, var, d);
                                }
                        } 
@@ -658,17 +662,19 @@ bool codegen_emit(jitdata *jd)
 
                case ICMD_I2L:        /* ..., value  ==> ..., value                   */
 
-                       d = emit_alloc_dst_even_odd(jd, iptr, R0, REG_ITMP1, REG_ITMP2);
-                       s1 = emit_load_s1(jd, iptr, GET_HIGH_REG(d)); 
+                       d = codegen_reg_of_dst(jd, iptr, REG_ITMP31_PACKED); /* even-odd */
+                       if (! N_IS_EVEN_ODD(d)) {
+                               d = REG_ITMP31_PACKED;
+                       }
+                       assert(N_IS_EVEN_ODD(d));
+
+                       s1 = emit_load_s1(jd, iptr, REG_ITMP2);
 
                        M_INTMOVE(s1, GET_HIGH_REG(d));
-                       ICONST(GET_LOW_REG(d), 0);
                        M_SRDA_IMM(32, GET_HIGH_REG(d));
 
                        emit_copy_dst(jd, iptr, d);
                        emit_store_dst(jd, iptr, d);
-                       emit_restore_dst_even_odd(jd, iptr, R0, REG_ITMP1, REG_ITMP2);
-
                        break;
 
                case ICMD_L2I:        /* ..., value  ==> ..., value                   */
@@ -680,7 +686,7 @@ bool codegen_emit(jitdata *jd)
 
                case ICMD_INT2BYTE:   /* ..., value  ==> ..., value                   */
                        s1 = emit_load_s1(jd, iptr, REG_ITMP1);
-                       d = codegen_reg_of_dst(jd, iptr, REG_ITMP3);
+                       d = codegen_reg_of_dst(jd, iptr, REG_ITMP2);
                        M_INTMOVE(s1, d);
                        M_SLL_IMM(24, d);
                        M_SRA_IMM(24, d);
@@ -689,7 +695,7 @@ bool codegen_emit(jitdata *jd)
 
                case ICMD_INT2CHAR:   /* ..., value  ==> ..., value                   */
                        s1 = emit_load_s1(jd, iptr, REG_ITMP1);
-                       d = codegen_reg_of_dst(jd, iptr, REG_ITMP3);
+                       d = codegen_reg_of_dst(jd, iptr, REG_ITMP2);
                        M_INTMOVE(s1, d);
                        M_SLL_IMM(16, d);
                        M_SRL_IMM(16, d);
@@ -699,7 +705,7 @@ bool codegen_emit(jitdata *jd)
                case ICMD_INT2SHORT:  /* ..., value  ==> ..., value                   */
 
                        s1 = emit_load_s1(jd, iptr, REG_ITMP1);
-                       d = codegen_reg_of_dst(jd, iptr, REG_ITMP3);
+                       d = codegen_reg_of_dst(jd, iptr, REG_ITMP2);
                        M_INTMOVE(s1, d);
                        M_SLL_IMM(16, d);
                        M_SRA_IMM(16, d);
@@ -938,47 +944,37 @@ bool codegen_emit(jitdata *jd)
                case ICMD_IDIV:       /* ..., val1, val2  ==> ..., val1 / val2        */
                case ICMD_IREM:       /* ..., val1, val2  ==> ..., val1 % val2        */
 
-                       s2 = emit_load_s2_notzero(jd, iptr, REG_ITMP2);
-                       emit_arithmetic_check(cd, iptr, s2);
+                       /* load s1 into r0 */
 
-                       /* For this operation we need a register pair.
-                        * We will use r0 and itmp1 and will backup r0.
-                        */
+                       s1 = emit_load_s1(jd, iptr, GET_HIGH_REG(REG_ITMP31_PACKED));
+                       M_INTMOVE(s1, GET_HIGH_REG(REG_ITMP31_PACKED));
+                       s1 = GET_HIGH_REG(REG_ITMP31_PACKED);
 
-                       M_INTMOVE(R0, REG_ITMP3);
+                       s2 = emit_load_s2(jd, iptr, REG_ITMP2);
 
-                       /* We won't check for division by 0, we catch a SIGFPE instead
-                        * Special case 0x80000000 / 0xffffffff handled by signal handler too.
-                        */
+                       /* extend s1 to long */
 
-                       s1 = emit_load_s1(jd, iptr, R0);
-                       M_INTMOVE(s1, R0);
-                       M_CLR(REG_ITMP1);
-                       M_SRDA_IMM(32, R0);
+                       M_SRDA_IMM(32, GET_HIGH_REG(REG_ITMP31_PACKED));
 
-                       N_DR(R0, s2);
+                       /* divide */
+
+                       N_DR(GET_HIGH_REG(REG_ITMP31_PACKED), s2);
+
+                       /* take result */
 
                        switch (iptr->opc) {
                                case ICMD_IREM:
-                                       d = codegen_reg_of_dst(jd, iptr, R0);
-                                       M_INTMOVE(R0, d);
+                                       d = codegen_reg_of_dst(jd, iptr, GET_HIGH_REG(REG_ITMP31_PACKED));
+                                       M_INTMOVE(GET_HIGH_REG(REG_ITMP31_PACKED), d);
                                        break;
                                case ICMD_IDIV:
-                                       d = codegen_reg_of_dst(jd, iptr, REG_ITMP1);
-                                       M_INTMOVE(REG_ITMP1, d);
+                                       d = codegen_reg_of_dst(jd, iptr, GET_LOW_REG(REG_ITMP31_PACKED));
+                                       M_INTMOVE(GET_LOW_REG(REG_ITMP31_PACKED), d);
                                        break;
                        }
 
                        emit_store_dst(jd, iptr, d);
 
-                       /* If destionation of operation was not register R0,
-                        * restore R0.
-                        */
-
-                       if (! ((d == R0) && !IS_INMEMORY(VAROP(iptr->dst)->flags))) {
-                               M_INTMOVE(REG_ITMP3, R0);
-                       }
-
                        break;
 
                case ICMD_LDIV:       /* ..., val1, val2  ==> ..., val1 / val2        */
@@ -1008,8 +1004,8 @@ bool codegen_emit(jitdata *jd)
                        /* call builtin */
 
                        M_ASUB_IMM(96, REG_SP);
-                       M_ALD_DSEG(REG_ITMP3, disp);
-                       M_JSR(REG_RA, REG_ITMP3);
+                       M_ALD_DSEG(REG_ITMP2, disp);
+                       M_JSR(REG_RA, REG_ITMP2);
                        M_AADD_IMM(96, REG_SP);
 
                        /* store result */
@@ -1150,23 +1146,25 @@ bool codegen_emit(jitdata *jd)
 
                case ICMD_LUSHR:      /* ..., val1, val2  ==> ..., val1 >>> val2      */
 
-                       s2 = emit_load_s2(jd, iptr, REG_ITMP3); /* d wont contain REG_ITMP3 */
+                       s2 = emit_load_s2(jd, iptr, REG_ITMP2);
 
                        /* Use only 6 bits of second operand */
 
-                       M_INTMOVE(s2, REG_ITMP3);
-                       s2 = REG_ITMP3;
-                       ICONST(REG_ITMP2, 0x3F);
-                       M_IAND(REG_ITMP2, s2);
+                       M_INTMOVE(s2, REG_ITMP2);
+                       s2 = REG_ITMP2;
+                       ICONST(REG_ITMP1, 0x3F);
+                       M_IAND(REG_ITMP1, s2);
 
-                       d = emit_alloc_dst_even_odd(jd, iptr, R0, REG_ITMP1, REG_ITMP2);
+                       s1 = emit_load_s1(jd, iptr, REG_ITMP31_PACKED); /* even-odd pair */
+                       d = codegen_reg_of_dst(jd, iptr, REG_ITMP31_PACKED);
 
-                       if ((s2 == GET_LOW_REG(d)) || (s2 == GET_HIGH_REG(d))) {
-                               M_INTMOVE(s2, REG_ITMP3);
-                               s2 = REG_ITMP3;
+                       /* Destination must be even-odd pair */
+
+                       if (! N_IS_EVEN_ODD(d)) {
+                               d = REG_ITMP31_PACKED;
                        }
 
-                       s1 = emit_load_s1(jd, iptr, d);
+                       assert(N_IS_EVEN_ODD(d));
 
                        M_LNGMOVE(s1, d);
 
@@ -1186,7 +1184,6 @@ bool codegen_emit(jitdata *jd)
 
                        emit_copy_dst(jd, iptr, d);
                        emit_store_dst(jd, iptr, d);
-                       emit_restore_dst_even_odd(jd, iptr, R0, REG_ITMP1, REG_ITMP2);
 
                        break;
 
@@ -1198,7 +1195,12 @@ bool codegen_emit(jitdata *jd)
                                      /* sx.val.l = constant                             */
                case ICMD_LMULPOW2:
                
-                       d = emit_alloc_dst_even_odd(jd, iptr, R0, REG_ITMP1, REG_ITMP2); /* won't contain itmp3 */
+                       d = codegen_reg_of_dst(jd, iptr, REG_ITMP31_PACKED); /* even-odd */
+                       if (! N_IS_EVEN_ODD(d)) {
+                               d = REG_ITMP31_PACKED;
+                       }
+                       assert(N_IS_EVEN_ODD(d));
+
                        s1 = emit_load_s1(jd, iptr, d);
                
                        M_LNGMOVE(s1, d);
@@ -1224,8 +1226,6 @@ bool codegen_emit(jitdata *jd)
 
                        emit_copy_dst(jd, iptr, d);
                        emit_store_dst(jd, iptr, d);
-                       emit_restore_dst_even_odd(jd, iptr, R0, REG_ITMP1, REG_ITMP2);
-
                        break;
 
                case ICMD_IAND:       /* ..., val1, val2  ==> ..., val1 & val2        */
@@ -1717,7 +1717,7 @@ bool codegen_emit(jitdata *jd)
 
                case ICMD_ARRAYLENGTH: /* ..., arrayref  ==> ..., (int) length        */
 
-                       s1 = emit_load_s1_notzero(jd, iptr, REG_ITMP1);
+                       s1 = emit_load_s1(jd, iptr, REG_ITMP1);
                        d = codegen_reg_of_dst(jd, iptr, REG_ITMP3);
                        /* TODO softnull */
                        /* implicit null-pointer check */
@@ -1727,8 +1727,8 @@ bool codegen_emit(jitdata *jd)
                        break;
 
                case ICMD_BALOAD:     /* ..., arrayref, index  ==> ..., value         */
-                       s1 = emit_load_s1_notzero(jd, iptr, REG_ITMP1);
-                       s2 = emit_load_s2_notzero(jd, iptr, REG_ITMP2);
+                       s1 = emit_load_s1(jd, iptr, REG_ITMP1);
+                       s2 = emit_load_s2(jd, iptr, REG_ITMP2);
                        d = codegen_reg_of_dst(jd, iptr, REG_ITMP2);
 
                        /* implicit null-pointer check */
@@ -1744,7 +1744,7 @@ bool codegen_emit(jitdata *jd)
 
                case ICMD_CALOAD:     /* ..., arrayref, index  ==> ..., value         */
 
-                       s1 = emit_load_s1_notzero(jd, iptr, REG_ITMP1);
+                       s1 = emit_load_s1(jd, iptr, REG_ITMP1);
                        s2 = emit_load_s2(jd, iptr, REG_ITMP2);
                        d = codegen_reg_of_dst(jd, iptr, REG_ITMP2);
 
@@ -1765,7 +1765,7 @@ bool codegen_emit(jitdata *jd)
                        break;                  
 
                case ICMD_SALOAD:     /* ..., arrayref, index  ==> ..., value         */
-                       s1 = emit_load_s1_notzero(jd, iptr, REG_ITMP1);
+                       s1 = emit_load_s1(jd, iptr, REG_ITMP1);
                        s2 = emit_load_s2(jd, iptr, REG_ITMP2);
                        d = codegen_reg_of_dst(jd, iptr, REG_ITMP2);
 
@@ -1780,7 +1780,7 @@ bool codegen_emit(jitdata *jd)
                        break;
 
                case ICMD_IALOAD:     /* ..., arrayref, index  ==> ..., value         */
-                       s1 = emit_load_s1_notzero(jd, iptr, REG_ITMP1);
+                       s1 = emit_load_s1(jd, iptr, REG_ITMP1);
                        s2 = emit_load_s2(jd, iptr, REG_ITMP2);
                        d = codegen_reg_of_dst(jd, iptr, REG_ITMP2);
 
@@ -1795,10 +1795,10 @@ bool codegen_emit(jitdata *jd)
 
                case ICMD_LALOAD:     /* ..., arrayref, index  ==> ..., value         */
 
-                       s1 = emit_load_s1_notzero(jd, iptr, REG_ITMP3);
+                       s1 = emit_load_s1(jd, iptr, REG_ITMP1);
                        s2 = emit_load_s2(jd, iptr, REG_ITMP2);
 
-                       d = codegen_reg_of_dst(jd, iptr, REG_ITMP12_PACKED);
+                       d = codegen_reg_of_dst(jd, iptr, REG_ITMP13_PACKED);
 
                        /* implicit null-pointer check */
                        emit_arrayindexoutofbounds_check(cd, iptr, s1, s2);
@@ -1806,22 +1806,25 @@ bool codegen_emit(jitdata *jd)
                        M_INTMOVE(s2, REG_ITMP2);
                        M_SLL_IMM(3, REG_ITMP2); /* scale index by 8 */
 
-                       /* We need to preserve the array address after the first load */
+                       N_L(
+                               GET_LOW_REG(d) /* maybe itmp3 */, 
+                               OFFSET(java_intarray_t, data[0]) + 4, 
+                               REG_ITMP2, s1 /* maybe itmp1 */
+                       );
 
-                       if (GET_HIGH_REG(d) == s1) {
-                               M_INTMOVE(s1, REG_ITMP3);
-                               s1 = REG_ITMP3;
-                       }
+                       N_L(
+                               GET_HIGH_REG(d) /* maybe itmp1 */, 
+                               OFFSET(java_intarray_t, data[0]), 
+                               REG_ITMP2, s1 /* maybe itmp1 */
+                       );
 
-                       N_L(GET_HIGH_REG(d) /* evntl. itmp1 */, OFFSET(java_intarray_t, data[0]), REG_ITMP2, s1);
-                       N_L(GET_LOW_REG(d) /* evntl. itmp2 */, OFFSET(java_intarray_t, data[0]) + 4, REG_ITMP2, s1);
                        emit_store_dst(jd, iptr, d);
 
                        break;
 
                case ICMD_FALOAD:     /* ..., arrayref, index  ==> ..., value         */
 
-                       s1 = emit_load_s1_notzero(jd, iptr, REG_ITMP1);
+                       s1 = emit_load_s1(jd, iptr, REG_ITMP1);
                        s2 = emit_load_s2(jd, iptr, REG_ITMP2);
                        d = codegen_reg_of_dst(jd, iptr, REG_FTMP1);
 
@@ -1837,7 +1840,7 @@ bool codegen_emit(jitdata *jd)
                        break;
 
                case ICMD_DALOAD:     /* ..., arrayref, index  ==> ..., value         */
-                       s1 = emit_load_s1_notzero(jd, iptr, REG_ITMP1);
+                       s1 = emit_load_s1(jd, iptr, REG_ITMP1);
                        s2 = emit_load_s2(jd, iptr, REG_ITMP2);
                        d = codegen_reg_of_dst(jd, iptr, REG_FTMP1);
 
@@ -1853,7 +1856,7 @@ bool codegen_emit(jitdata *jd)
                        break;
 
                case ICMD_AALOAD:     /* ..., arrayref, index  ==> ..., value         */
-                       s1 = emit_load_s1_notzero(jd, iptr, REG_ITMP1);
+                       s1 = emit_load_s1(jd, iptr, REG_ITMP1);
                        s2 = emit_load_s2(jd, iptr, REG_ITMP2);
                        d = codegen_reg_of_dst(jd, iptr, REG_ITMP2);
 
@@ -1867,8 +1870,8 @@ bool codegen_emit(jitdata *jd)
                        break;
 
                case ICMD_BASTORE:    /* ..., arrayref, index, value  ==> ...         */
-                       s1 = emit_load_s1_notzero(jd, iptr, REG_ITMP1);
-                       s2 = emit_load_s2_notzero(jd, iptr, REG_ITMP2);
+                       s1 = emit_load_s1(jd, iptr, REG_ITMP1);
+                       s2 = emit_load_s2(jd, iptr, REG_ITMP2);
                        /* implicit null-pointer check */
                        emit_arrayindexoutofbounds_check(cd, iptr, s1, s2);
                        s3 = emit_load_s3(jd, iptr, REG_ITMP3);
@@ -1878,7 +1881,7 @@ bool codegen_emit(jitdata *jd)
 
                case ICMD_CASTORE:    /* ..., arrayref, index, value  ==> ...         */
 
-                       s1 = emit_load_s1_notzero(jd, iptr, REG_ITMP1);
+                       s1 = emit_load_s1(jd, iptr, REG_ITMP1);
                        s2 = emit_load_s2(jd, iptr, REG_ITMP2);
                        /* implicit null-pointer check */
                        emit_arrayindexoutofbounds_check(cd, iptr, s1, s2);
@@ -1892,7 +1895,7 @@ bool codegen_emit(jitdata *jd)
                        break;
 
                case ICMD_SASTORE:    /* ..., arrayref, index, value  ==> ...         */
-                       s1 = emit_load_s1_notzero(jd, iptr, REG_ITMP1);
+                       s1 = emit_load_s1(jd, iptr, REG_ITMP1);
                        s2 = emit_load_s2(jd, iptr, REG_ITMP2);
                        /* implicit null-pointer check */
                        emit_arrayindexoutofbounds_check(cd, iptr, s1, s2);
@@ -1906,7 +1909,7 @@ bool codegen_emit(jitdata *jd)
 
                case ICMD_IASTORE:    /* ..., arrayref, index, value  ==> ...         */
 
-                       s1 = emit_load_s1_notzero(jd, iptr, REG_ITMP1);
+                       s1 = emit_load_s1(jd, iptr, REG_ITMP1);
                        s2 = emit_load_s2(jd, iptr, REG_ITMP2);
                        /* implicit null-pointer check */
                        emit_arrayindexoutofbounds_check(cd, iptr, s1, s2);
@@ -1921,7 +1924,7 @@ bool codegen_emit(jitdata *jd)
 
                case ICMD_LASTORE:    /* ..., arrayref, index, value  ==> ...         */
 
-                       s1 = emit_load_s1_notzero(jd, iptr, REG_ITMP1);
+                       s1 = emit_load_s1(jd, iptr, REG_ITMP1);
                        s2 = emit_load_s2(jd, iptr, REG_ITMP2);
                        /* implicit null-pointer check */
                        emit_arrayindexoutofbounds_check(cd, iptr, s1, s2);
@@ -1936,7 +1939,7 @@ bool codegen_emit(jitdata *jd)
                        break;
 
                case ICMD_FASTORE:    /* ..., arrayref, index, value  ==> ...         */
-                       s1 = emit_load_s1_notzero(jd, iptr, REG_ITMP1);
+                       s1 = emit_load_s1(jd, iptr, REG_ITMP1);
                        s2 = emit_load_s2(jd, iptr, REG_ITMP2);
                        /* implicit null-pointer check */
                        emit_arrayindexoutofbounds_check(cd, iptr, s1, s2);
@@ -1949,7 +1952,7 @@ bool codegen_emit(jitdata *jd)
                        break;
 
                case ICMD_DASTORE:    /* ..., arrayref, index, value  ==> ...         */
-                       s1 = emit_load_s1_notzero(jd, iptr, REG_ITMP1);
+                       s1 = emit_load_s1(jd, iptr, REG_ITMP1);
                        s2 = emit_load_s2(jd, iptr, REG_ITMP2);
                        /* implicit null-pointer check */
                        emit_arrayindexoutofbounds_check(cd, iptr, s1, s2);
@@ -1963,7 +1966,7 @@ bool codegen_emit(jitdata *jd)
 
                case ICMD_AASTORE:    /* ..., arrayref, index, value  ==> ...         */
 
-                       s1 = emit_load_s1_notzero(jd, iptr, REG_A0);
+                       s1 = emit_load_s1(jd, iptr, REG_A0);
                        s2 = emit_load_s2(jd, iptr, REG_ITMP2);
                        /* implicit null-pointer check */
                        emit_arrayindexoutofbounds_check(cd, iptr, s1, s2);
@@ -1973,9 +1976,9 @@ bool codegen_emit(jitdata *jd)
                        M_INTMOVE(s3, REG_A1);
 
                        disp = dseg_add_functionptr(cd, BUILTIN_FAST_canstore);
-                       M_ALD_DSEG(REG_ITMP3, disp);
+                       M_ALD_DSEG(REG_ITMP2, disp);
                        M_ASUB_IMM(96, REG_SP);
-                       M_JSR(REG_RA, REG_ITMP3);
+                       M_JSR(REG_RA, REG_ITMP2);
                        M_AADD_IMM(96, REG_SP);
 
                        emit_arraystore_check(cd, iptr);
@@ -2099,7 +2102,7 @@ bool codegen_emit(jitdata *jd)
 
                case ICMD_GETFIELD:   /* ...  ==> ..., value                          */
 
-                       s1 = emit_load_s1_notzero(jd, iptr, REG_ITMP1);
+                       s1 = emit_load_s1(jd, iptr, REG_ITMP1);
                        emit_nullpointer_check(cd, iptr, s1);
 
                        if (INSTRUCTION_IS_UNRESOLVED(iptr)) {
@@ -2151,7 +2154,7 @@ bool codegen_emit(jitdata *jd)
                        {
                        u1 *ref;
 
-                       s1 = emit_load_s1_notzero(jd, iptr, REG_ITMP1);
+                       s1 = emit_load_s1(jd, iptr, REG_ITMP1);
                        emit_nullpointer_check(cd, iptr, s1);
 
                        if (INSTRUCTION_IS_UNRESOLVED(iptr)) {
@@ -2221,8 +2224,8 @@ bool codegen_emit(jitdata *jd)
 
                        /* PROFILE_CYCLE_STOP; */
                
-                       s1 = emit_load_s1(jd, iptr, REG_ITMP1);
-                       M_INTMOVE(s1, REG_ITMP1_XPTR);
+                       s1 = emit_load_s1(jd, iptr, REG_ITMP3);
+                       M_INTMOVE(s1, REG_ITMP3_XPTR);
 
 #ifdef ENABLE_VERIFIER
                        if (INSTRUCTION_IS_UNRESOLVED(iptr)) {
@@ -2233,8 +2236,8 @@ bool codegen_emit(jitdata *jd)
 #endif /* ENABLE_VERIFIER */
 
                        disp = dseg_add_functionptr(cd, asm_handle_exception);
-                       M_ALD_DSEG(REG_ITMP2, disp);
-                       M_JMP(REG_ITMP2_XPC, REG_ITMP2);
+                       M_ALD_DSEG(REG_ITMP1, disp);
+                       M_JMP(REG_ITMP1_XPC, REG_ITMP1);
                        M_NOP;
 
                        break;
@@ -2406,10 +2409,10 @@ bool codegen_emit(jitdata *jd)
 
                        /* Compare addresses as 31 bit unsigned integers */
 
-                       s1 = emit_load_s1_notzero(jd, iptr, REG_ITMP1);
+                       s1 = emit_load_s1(jd, iptr, REG_ITMP1);
                        M_LDA(REG_ITMP1, s1, 0);
 
-                       s2 = emit_load_s2_notzero(jd, iptr, REG_ITMP2);
+                       s2 = emit_load_s2(jd, iptr, REG_ITMP2);
                        M_LDA(REG_ITMP2, s2, 0);
 
                        M_CMP(REG_ITMP1, REG_ITMP2);
@@ -2618,10 +2621,10 @@ nowperformreturn:
                                M_ALD(REG_A0, REG_SP, rd->memuse * 8);
 
                                disp = dseg_add_functionptr(cd, LOCK_monitor_exit);
-                               M_ALD_DSEG(REG_ITMP3, disp);
+                               M_ALD_DSEG(REG_ITMP2, disp);
 
                                M_ASUB_IMM(96, REG_SP);
-                               M_CALL(REG_ITMP3);
+                               M_CALL(REG_ITMP2);
                                M_AADD_IMM(96, REG_SP);
 
                                /* and now restore the proper return value */
@@ -2914,8 +2917,8 @@ gen_method:
 
                                /* Implicit null-pointer check */
                                M_ALD(REG_METHODPTR, REG_A0, OFFSET(java_object_t, vftbl));
-                               N_LHI(REG_ITMP1, s1);
-                               N_L(REG_METHODPTR, 0, REG_ITMP1, REG_METHODPTR);
+                               N_LHI(REG_ITMP2, s1);
+                               N_L(REG_METHODPTR, 0, REG_ITMP2, REG_METHODPTR);
                                M_ALD(REG_PV, REG_METHODPTR, s2);
                                break;
                        }
@@ -3011,7 +3014,7 @@ gen_method:
                                if ((super == NULL) || !(super->flags & ACC_INTERFACE))
                                        CODEGEN_CRITICAL_SECTION_NEW;
 
-                               s1 = emit_load_s1_notzero(jd, iptr, REG_ITMP1);
+                               s1 = emit_load_s1(jd, iptr, REG_ITMP1);
 
                                /* if class is not resolved, check which code to call */
 
@@ -3025,12 +3028,13 @@ gen_method:
                                                                                  iptr->sx.s23.s3.c.ref,
                                                                                  disp);
 
-                                       ICONST(REG_ITMP2, ACC_INTERFACE);
+                                       ICONST(REG_ITMP3, ACC_INTERFACE);
+
                                        if (N_VALID_DSEG_DISP(disp)) {
-                                               N_N(REG_ITMP2, N_DSEG_DISP(disp), RN, REG_PV);
+                                               N_N(REG_ITMP3, N_DSEG_DISP(disp), RN, REG_PV);
                                        } else {
-                                               ICONST(REG_ITMP3, disp);
-                                               N_N(REG_ITMP2, -N_PV_OFFSET, REG_ITMP3, REG_PV);
+                                               ICONST(REG_ITMP2, disp);
+                                               N_N(REG_ITMP3, -N_PV_OFFSET, REG_ITMP2, REG_PV);
                                        }
                                        emit_label_beq(cd, LABEL_CLASS);
                                }
@@ -3086,6 +3090,32 @@ gen_method:
                                                emit_label_beq(cd, LABEL_EXIT_CLASS_NULL);
                                        }
 
+#if 1
+                                       CODEGEN_CRITICAL_SECTION_START;
+
+                                       /* REG_ITMP3 := baseval(s1) */
+                                       M_ALD(REG_ITMP2, s1, OFFSET(java_object_t, vftbl));
+                                       M_ILD(REG_ITMP3, REG_ITMP2, OFFSET(vftbl_t, baseval));
+
+                                       /* REG_ITMP2 := baseval(class) */
+                                       M_ALD_DSEG(REG_ITMP2, disp);
+                                       M_ILD(REG_ITMP2, REG_ITMP2, OFFSET(vftbl_t, baseval));
+
+                                       /* REG_ITMP3 := REG_ITMP3 - REG_ITMP2 */
+                                       M_ISUB(REG_ITMP2, REG_ITMP3);
+
+                                       /* REG_ITMP2 := diffval(class) */
+                                       M_ALD_DSEG(REG_ITMP2, disp);
+                                       M_ILD(REG_ITMP2, REG_ITMP2, OFFSET(vftbl_t, diffval));
+
+                                       CODEGEN_CRITICAL_SECTION_END;
+
+                                       M_CMPU(REG_ITMP3, REG_ITMP2); /* Unsigned compare */
+
+                                       /* M_CMPULE(REG_ITMP2, REG_ITMP3, REG_ITMP3); itmp3 = (itmp2 <= itmp3) */
+                                       /* M_BEQZ(REG_ITMP3, 0); branch if (! itmp) -> branch if > */
+                                       /* Branch if greater then */
+#else
                                        M_ALD(REG_ITMP2, s1, OFFSET(java_object_t, vftbl));
                                        M_ALD_DSEG(REG_ITMP3, disp);
 
@@ -3103,6 +3133,7 @@ gen_method:
                                        /* M_CMPULE(REG_ITMP2, REG_ITMP3, REG_ITMP3); itmp3 = (itmp2 <= itmp3) */
                                        /* M_BEQZ(REG_ITMP3, 0); branch if (! itmp) -> branch if > */
                                        /* Branch if greater then */
+#endif
                                        emit_classcast_check(cd, iptr, BRANCH_GT, RN, s1);
                                }
 
@@ -3203,7 +3234,7 @@ gen_method:
                        if ((super == NULL) || !(super->flags & ACC_INTERFACE))
                                CODEGEN_CRITICAL_SECTION_NEW;
 
-                       s1 = emit_load_s1_notzero(jd, iptr, REG_ITMP1);
+                       s1 = emit_load_s1(jd, iptr, REG_ITMP1);
                        d = codegen_reg_of_dst(jd, iptr, REG_ITMP2);
                        if (s1 == d) {
                                M_MOV(s1, REG_ITMP1);
@@ -3223,13 +3254,13 @@ gen_method:
                                patcher_add_patch_ref(jd, PATCHER_resolve_classref_to_flags,
                                                                          iptr->sx.s23.s3.c.ref, disp);
 
-                               ICONST(REG_ITMP2, ACC_INTERFACE);
+                               ICONST(REG_ITMP3, ACC_INTERFACE);
 
                                if (N_VALID_DSEG_DISP(disp)) {
-                                       N_N(REG_ITMP2, N_DSEG_DISP(disp), RN, REG_PV);
+                                       N_N(REG_ITMP3, N_DSEG_DISP(disp), RN, REG_PV);
                                } else {
-                                       ICONST(REG_ITMP3, disp);
-                                       N_N(REG_ITMP2, -N_PV_OFFSET, REG_ITMP3, REG_PV);
+                                       ICONST(REG_ITMP2, disp);
+                                       N_N(REG_ITMP3, -N_PV_OFFSET, REG_ITMP2, REG_PV);
                                }
 
                                emit_label_beq(cd, LABEL_CLASS);
@@ -3456,12 +3487,12 @@ void codegen_emit_stub_compiler(jitdata *jd)
 
        /* code for the stub */
 
-       /* don't touch ITMP3 as it cointains the return address */
+       /* don't touch ITMP2 as it cointains the return address */
 
        M_AADD_IMM(N_PV_OFFSET, REG_PV); /* suppress negative displacements */
 
-       M_ILD_DSEG(REG_ITMP1, -2 * SIZEOF_VOID_P); /* methodinfo  */
-       /* TODO where is methodpointer loaded into itmp2? is it already inside? */
+       /* REG_METHODPTR (REG_ITMP1) already used */
+       M_ILD_DSEG(REG_ITMP3, -2 * SIZEOF_VOID_P); /* methodinfo  */
        M_ILD_DSEG(REG_PV, -3 * SIZEOF_VOID_P); /* compiler pointer */
        N_BR(REG_PV);
 }
@@ -3545,6 +3576,10 @@ void codegen_emit_stub_native(jitdata *jd, methoddesc *nmd, functionptr f)
        N_AHI(REG_SP, -(cd->stackframesize * 8));
        N_AHI(REG_PV, N_PV_OFFSET);
 
+       /* save return address */
+
+       N_ST(REG_RA, (cd->stackframesize - 1) * 8, RN, REG_SP);
+
        /* generate native method profiling code */
 
 #if defined(ENABLE_PROFILING)
@@ -3557,10 +3592,6 @@ void codegen_emit_stub_native(jitdata *jd, methoddesc *nmd, functionptr f)
        }
 #endif
 
-       /* save return address */
-
-       N_ST(R14, (cd->stackframesize - 1) * 8, RN, REG_SP);
-
 #if !defined(NDEBUG)
        if (JITDATA_HAS_FLAG_VERBOSECALL(jd))
                emit_verbosecall_enter(jd);
@@ -3573,7 +3604,7 @@ void codegen_emit_stub_native(jitdata *jd, methoddesc *nmd, functionptr f)
        if (f == NULL)
                patcher_add_patch_ref(jd, PATCHER_resolve_native_function, m, disp);
 
-       M_ILD_DSEG(REG_ITMP1, disp);
+       M_ALD_DSEG(REG_ITMP1, disp);
 
        j = 96 + (nmd->memuse * 8);
 
@@ -3614,7 +3645,7 @@ void codegen_emit_stub_native(jitdata *jd, methoddesc *nmd, functionptr f)
        N_LA(REG_A1, -N_PV_OFFSET, RN, REG_PV); /* pv */
 
        disp = dseg_add_functionptr(cd, codegen_start_native_call);
-       M_ILD_DSEG(REG_ITMP1, disp);
+       M_ALD_DSEG(REG_ITMP1, disp);
 
        M_CALL(REG_ITMP1); /* call */
 
@@ -3811,8 +3842,8 @@ void codegen_emit_stub_native(jitdata *jd, methoddesc *nmd, functionptr f)
 
        /* handle exception */
 
-       M_MOV(REG_ITMP3, REG_ITMP1_XPTR);
-       M_MOV(REG_ITMP2, REG_ITMP2_XPC); /* get return address from stack */
+       M_MOV(REG_ITMP3, REG_ITMP3_XPTR);
+       M_MOV(REG_ITMP2, REG_ITMP1_XPC); /* get return address from stack */
 
 #if 0
        /* TODO */
@@ -3820,25 +3851,14 @@ void codegen_emit_stub_native(jitdata *jd, methoddesc *nmd, functionptr f)
 #endif
 
        disp = dseg_add_functionptr(cd, asm_handle_nat_exception);
-       M_ALD_DSEG(REG_ITMP3, disp);
-       M_JMP(RN, REG_ITMP3);
+       M_ALD_DSEG(REG_ITMP2, disp);
+       M_JMP(RN, REG_ITMP2);
 
        /* generate patcher stubs */
 
        emit_patcher_traps(jd);
 }
 
-s4 codegen_reg_of_dst_notzero(jitdata *jd, instruction *iptr, s4 tempregnum) {
-       codegendata *cd = jd->cd;
-       s4 reg = codegen_reg_of_dst(jd, iptr, tempregnum);
-       if (reg == 0) {
-               M_MOV(reg, tempregnum);
-               return tempregnum;
-       } else {
-               return reg;
-       }
-}
-
 /*
  * 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
index 7ef8c41eab21529fcc69bc0b18f2a466a67a88c2..ff3769e449d1b3211dc86d782d3381bac9565b92 100644 (file)
 #define N_VALID_BRANCH(x) ((N_BRANCH_MIN <= (x)) && ((x) <= N_BRANCH_MAX))
 #define ASSERT_VALID_BRANCH(x) assert(N_VALID_BRANCH(x))
 
+#define N_IS_EVEN_ODD(x) \
+       (((GET_HIGH_REG(x) % 2) == 0) && (GET_LOW_REG(x) == (GET_HIGH_REG(x) + 1)))
+
 /* Condition codes */
 
 #define DD_O 1
 
 #define PROFILE_CYCLE_STOP 
 
-s4 codegen_reg_of_dst_notzero(jitdata *jd, instruction *iptr, s4 tempregnum);
-
 #endif /* _CODEGEN_H */
 
 /*
index 715b0be5a8a67a4eea7fbfa65a95f1398b816fe3..ac50f8e3ceeec60083ff8aa07b9bf6b2e376e84f 100644 (file)
@@ -302,8 +302,8 @@ void emit_verbosecall_enter(jitdata *jd)
        /* call trace_java_call_enter */
 
        disp = dseg_add_functionptr(cd, trace_java_call_enter);
-       M_ALD_DSEG(REG_ITMP3, disp);
-       M_CALL(REG_ITMP3);
+       M_ALD_DSEG(REG_ITMP2, disp);
+       M_CALL(REG_ITMP2);
 
        /* restore argument registers */
 
@@ -561,8 +561,8 @@ void emit_verbosecall_exit(jitdata *jd)
        M_ALD_DSEG(REG_A0, disp);
        M_LDA(REG_A1, REG_SP, 96);
        disp = dseg_add_functionptr(cd, trace_java_call_exit);
-       M_ALD_DSEG(REG_ITMP3, disp);
-       M_CALL(REG_ITMP3);
+       M_ALD_DSEG(REG_ITMP2, disp);
+       M_CALL(REG_ITMP2);
 
        /* restore return values */
 
@@ -698,32 +698,6 @@ s4 emit_load_low(jitdata *jd, instruction *iptr, varinfo *src, s4 tempreg)
        return reg;
 }
 
-s4 emit_load_s1_notzero(jitdata *jd, instruction *iptr, s4 tempreg) {
-       codegendata *cd = jd->cd;
-       s4 reg = emit_load_s1(jd, iptr, tempreg);
-       if (reg == 0) {
-               M_MOV(reg, tempreg);
-               return tempreg;
-       } else {
-               return reg;
-       }
-}
-
-s4 emit_load_s2_notzero(jitdata *jd, instruction *iptr, s4 tempreg) {
-       codegendata *cd = jd->cd;
-       s4 reg = emit_load_s2(jd, iptr, tempreg);
-       if (reg == 0) {
-               if (IS_FLT_DBL_TYPE(VAROP(iptr->sx.s23.s2)->type)) {
-                       M_FMOV(reg, tempreg);
-               } else {
-                       M_MOV(reg, tempreg);
-               }
-               return tempreg;
-       } else {
-               return reg;
-       }
-}
-
 s4 emit_load_s1_but(jitdata *jd, instruction *iptr, s4 tempreg, s4 notreg) {
        codegendata *cd = jd->cd;
        s4 reg = emit_load_s1(jd, iptr, tempreg);
@@ -754,96 +728,6 @@ s4 emit_load_s2_but(jitdata *jd, instruction *iptr, s4 tempreg, s4 notreg) {
        }
 }
 
-s4 emit_alloc_dst_even_odd(jitdata *jd, instruction *iptr, s4 htmpreg, s4 ltmpreg, s4 breg) {
-       codegendata *cd;
-       s4           hr, lr;
-       varinfo     *dst;
-
-       /* (r0, r1)    
-        * (r2, r3)
-        * (r4, r5)
-        * (r6, r7)
-        * (r8, r9)
-        * (r10, r11)
-        * (r12, r13) Illegal, because r13 is PV
-        * (r14, r15) Illegal, because r15 is SP
-        */
-
-       cd = jd->cd;
-       dst = VAROP(iptr->dst);
-
-       if (IS_INMEMORY(dst->flags)) {
-               if (! IS_REG_ITMP(ltmpreg)) {
-                       M_INTMOVE(ltmpreg, breg);
-               }
-               if (! IS_REG_ITMP(htmpreg)) {
-                       M_INTMOVE(htmpreg, breg);
-               }
-               return PACK_REGS(ltmpreg, htmpreg);
-       } else {
-               hr = GET_HIGH_REG(dst->vv.regoff);
-               lr = GET_LOW_REG(dst->vv.regoff);
-               if (((hr % 2) == 0) && lr == (hr + 1)) {
-                       /* the result is already in a even-odd pair */
-                       return dst->vv.regoff;                  
-               } else if (((hr % 2) == 0) && (hr < R12)) {
-                       /* the high register is at a even position */
-                       M_INTMOVE(hr + 1, breg);
-                       return PACK_REGS(hr + 1, hr);
-               } else if (((lr % 2) == 1) && (lr < R12)) {
-                       /* the low register is at a odd position */
-                       M_INTMOVE(lr - 1, breg);
-                       return PACK_REGS(lr, lr - 1);
-               } else {
-                       /* no way to create an even-odd pair by 1 copy operation,
-                        * Use the temporary register pair.
-                        */
-                       if (! IS_REG_ITMP(ltmpreg)) {
-                               M_INTMOVE(ltmpreg, breg);
-                       }
-                       if (! IS_REG_ITMP(htmpreg)) {
-                               M_INTMOVE(htmpreg, breg);
-                       }
-                       return PACK_REGS(ltmpreg, htmpreg);
-               }
-       }
-}
-
-void emit_restore_dst_even_odd(jitdata *jd, instruction *iptr, s4 htmpreg, s4 ltmpreg, s4 breg) {
-       codegendata *cd;
-       s4           hr, lr;
-       varinfo     *dst;
-
-       cd = jd->cd;
-       dst = VAROP(iptr->dst);
-
-       if (IS_INMEMORY(dst->flags)) {
-               if (! IS_REG_ITMP(ltmpreg)) {
-                       M_INTMOVE(breg, ltmpreg);
-               }
-               if (! IS_REG_ITMP(htmpreg)) {
-                       M_INTMOVE(breg, htmpreg);
-               }
-       } else {
-               hr = GET_HIGH_REG(dst->vv.regoff);
-               lr = GET_LOW_REG(dst->vv.regoff);
-               if (((hr % 2) == 0) && lr == (hr + 1)) {
-                       return;
-               } else if (((hr % 2) == 0) && (hr < R12)) {
-                       M_INTMOVE(breg, hr + 1);
-               } else if (((lr % 2) == 1) && (lr < R12)) {
-                       M_INTMOVE(breg, lr - 1);
-               } else {
-                       if (! IS_REG_ITMP(ltmpreg)) {
-                               M_INTMOVE(breg, ltmpreg);
-                       }
-                       if (! IS_REG_ITMP(htmpreg)) {
-                               M_INTMOVE(breg, htmpreg);
-                       }
-               }
-       }
-}
-
 void emit_copy_dst(jitdata *jd, instruction *iptr, s4 dtmpreg) {
        codegendata *cd;
        varinfo *dst;
@@ -949,9 +833,9 @@ void emit_branch(codegendata *cd, s4 disp, s4 condition, s4 reg, u4 opt) {
                /* The actual long branch */
 
                disp = dseg_add_s4(cd, branchmpc + disp - N_PV_OFFSET);
-               M_ILD_DSEG(REG_ITMP3, disp);
-               M_AADD(REG_PV, REG_ITMP3);
-               M_JMP(RN, REG_ITMP3);
+               M_ILD_DSEG(REG_ITMP2, disp);
+               M_AADD(REG_PV, REG_ITMP2);
+               M_JMP(RN, REG_ITMP2);
 
                /* Patch back the displacement */
 
index 2724ec6d4f9cb92009d1a21ee4d316434a946e54..be5865e33c526b14a8bf3213d702d6e36c86a8ed 100644 (file)
 
 /* macros to create code ******************************************************/
 
-s4 emit_load_s1_notzero(jitdata *jd, instruction *iptr, s4 tempreg);
-s4 emit_load_s2_notzero(jitdata *jd, instruction *iptr, s4 tempreg);
-
 s4 emit_load_s1_but(jitdata *jd, instruction *iptr, s4 tempreg, s4 notreg);
 s4 emit_load_s2_but(jitdata *jd, instruction *iptr, s4 tempreg, s4 notreg);
 
-/* Allocate an even-odd register pair for the destination of an instruction.
- *
- */
-
-s4 emit_alloc_dst_even_odd(jitdata *jd, instruction *iptr, s4 htmpreg, s4 ltmpreg, s4 breg);
-
-void emit_restore_dst_even_odd(jitdata *jd, instruction *iptr, s4 htmpreg, s4 ltmpreg, s4 breg);
-
 /* If the destination operand is in a register, different than
  * dtmpreg, a register copy is emitted.
  */
index 0b3ff13ce44180efaa456f58e638c364f6da1789..1ec40d83601eaad84d319c7bae0339ebd98695da 100644 (file)
 /* register descripton array **************************************************/
 
 s4 nregdescint[] = {
-       /*   r0,   itmp1,      a0,      a1,      a2,      a3,      a4,      s0, */
-       REG_TMP, REG_RES, REG_ARG, REG_ARG, REG_ARG, REG_ARG, REG_ARG, REG_SAV,
-       /*   s1,      s2,      s3,      s4,   itmp2,    pv,  ra/itmp3,      sp */
-       REG_SAV, REG_SAV, REG_SAV, REG_SAV, REG_RES, REG_RES, REG_RES, REG_RES,
+       /*itmp3,   itmp1,      a0,      a1,      a2,      a3,      a4,      s0, */
+       REG_RES, REG_RES, REG_ARG, REG_ARG, REG_ARG, REG_ARG, REG_ARG, REG_SAV,
+       /*   s1,      s2,      s3,      s4,      s5,    pv,  ra/itmp2,      sp */
+       REG_SAV, REG_SAV, REG_SAV, REG_SAV, REG_SAV, REG_RES, REG_RES, REG_RES,
     REG_END
 };
 
@@ -71,11 +71,12 @@ const s4 abi_registers_integer_saved[] = {
        8,  /* r8/s1 */
        9,  /* r9/s2 */
        10, /* r10/s3 */
-       11  /* r11/s4 */
+       11, /* r11/s4 */
+       12  /* r12/s5 */
 };
 
 const s4 abi_registers_integer_temporary[] = {
-       0, /* r0 */
+       -1 /* none */
 };
 
 s4 nregdescfloat[] = {
index 83736f598f8d4873d280c4cecce3a88d7139950f..b37947fe484e14af57f6258fe430d0e6c5211339 100644 (file)
 #define REG_RESULT2     R3
 
 #define REG_ITMP1       R1      /* temporary register                        */
-#define REG_ITMP2       R12     /* temporary register and method pointer     */
-#define REG_ITMP3       R14     /* temporary register                        */
+#define REG_ITMP2       R14     /* temporary register and method pointer     */
+#define REG_ITMP3       R     /* temporary register                        */
 
 #define IS_REG_ITMP(x) (((x) == REG_ITMP1) || ((x) == REG_ITMP2) || ((x) == REG_ITMP3))
 
 #define REG_ITMP12_PACKED    PACK_REGS(REG_ITMP2, REG_ITMP1)
 #define REG_ITMP23_PACKED    PACK_REGS(REG_ITMP3, REG_ITMP2)
+#define REG_ITMP13_PACKED    PACK_REGS(REG_ITMP3, REG_ITMP1)
+/* even odd */
+#define REG_ITMP31_PACKED    PACK_REGS(REG_ITMP1, REG_ITMP3)
 #define REG_RESULT_PACKED    PACK_REGS(REG_RESULT2, REG_RESULT)
 
-#define REG_METHODPTR   REG_ITMP2/* pointer to the place from where the       */
+#define REG_METHODPTR   REG_ITMP1/* pointer to the place from where the       */
                                  /* procedure vector has been fetched         */
 
 #define REG_NULL        -1       /* used for reg_of_var where d is not needed */
 
-#define REG_ITMP1_XPTR  REG_ITMP1/* exception pointer = temporary register 1  */
-#define REG_ITMP2_XPC   REG_ITMP2/* exception pc = temporary register 2       */
+#define REG_ITMP3_XPTR  REG_ITMP3/* exception pointer = temporary register 3  */
+#define REG_ITMP1_XPC   REG_ITMP1/* exception pc = temporary register 1       */
 
 #define REG_SP          R15      /* stack pointer                             */
 #define REG_RA          R14      /* same as itmp3 */
 /* No ftmp3 */
 
 #define INT_REG_CNT     16       /* number of integer registers               */
-#define INT_SAV_CNT     5        /* number of integer callee saved registers  */
+#define INT_SAV_CNT     6        /* number of integer callee saved registers  */
 #define INT_ARG_CNT     5        /* number of integer argument registers      */
-#define INT_TMP_CNT     1        /* number of integer temporary registers     */
+#define INT_TMP_CNT     0        /* number of integer temporary registers     */
 #define INT_RES_CNT     5        /* number of integer reserved registers      */
 
 #define FLT_REG_CNT     16       /* number of float registers                 */
index d41cc74c746142acd545ea4f2ddc640771030c49..c8965845e38885322666391510bc6b88eca00328 100644 (file)
 
 #define sp       %r15
 #define itmp1    %r1
-#define itmp2    %r12
-#define itmp3    %r14
+#define itmp2    %r14
+#define itmp3    %r0
 #define v0       %r2
 #define pv       %r13
 #define ra       %r14
 
-#define mptr     itmp2
-#define xptr     itmp1
-#define xpc      itmp2
+#define mptr     itmp1
+#define xptr     itmp3
+#define xpc      itmp1
 
 #define s0 %r7
 #define s1 %r8
 #define s2 %r9
 #define s3 %r10
 #define s4 %r11
+#define s5 %r12
 
 #define fa0 %f0
 #define fa1 %f2
index 936fa329ac997daaa88eeedf783871c5a1f503da..dbd691e151bd81835e2954752d770cf61955df28 100644 (file)
@@ -204,8 +204,8 @@ void md_signal_handler_sigsegv(int sig, siginfo_t *siginfo, void *_p)
        stacktrace_remove_stackframeinfo(&sfi);
 
        if (p != NULL) {
-               _mc->gregs[REG_ITMP1_XPTR] = (intptr_t) p;
-               _mc->gregs[REG_ITMP2_XPC]  = (intptr_t) xpc;
+               _mc->gregs[REG_ITMP3_XPTR] = (intptr_t) p;
+               _mc->gregs[REG_ITMP1_XPC]  = (intptr_t) xpc;
                _mc->psw.addr              = (intptr_t) asm_handle_exception;
        }
        else {
@@ -258,8 +258,8 @@ void md_signal_handler_sigill(int sig, siginfo_t *siginfo, void *_p)
                stacktrace_remove_stackframeinfo(&sfi);
 
                if (p != NULL) {
-                       _mc->gregs[REG_ITMP1_XPTR] = (intptr_t) p;
-                       _mc->gregs[REG_ITMP2_XPC]  = (intptr_t) xpc;
+                       _mc->gregs[REG_ITMP3_XPTR] = (intptr_t) p;
+                       _mc->gregs[REG_ITMP1_XPC]  = (intptr_t) xpc;
                        _mc->psw.addr              = (intptr_t) asm_handle_exception;
                }
                else {
@@ -347,8 +347,8 @@ void md_signal_handler_sigfpe(int sig, siginfo_t *siginfo, void *_p)
 
                        stacktrace_remove_stackframeinfo(&sfi);
 
-                       _mc->gregs[REG_ITMP1_XPTR] = (intptr_t) p;
-                       _mc->gregs[REG_ITMP2_XPC]  = (intptr_t) xpc;
+                       _mc->gregs[REG_ITMP3_XPTR] = (intptr_t) p;
+                       _mc->gregs[REG_ITMP1_XPC]  = (intptr_t) xpc;
                        _mc->psw.addr              = (intptr_t) asm_handle_exception;
 
                        return;
@@ -512,16 +512,16 @@ u1 *md_get_method_patch_address(u1 *ra, stackframeinfo *sfi, u1 *mptr)
        /* check for the different calls */
 
        switch (base) {
-               case 0xd:
+               case REG_PV:
                        /* INVOKESTATIC/SPECIAL */
 
                
                        switch (index) {
-                               case 0x0:
+                               case R0:
                                        /* the offset is in the load instruction */
                                        offset = ((*(u2 *)(ra + 2)) & 0xFFF) + N_PV_OFFSET;
                                        break;
-                               case 0x1:
+                               case REG_ITMP1:
                                        /* the offset is in the immediate load before the load */
                                        offset = *((s2 *) (ra - 2));
                                        break;
@@ -535,7 +535,7 @@ u1 *md_get_method_patch_address(u1 *ra, stackframeinfo *sfi, u1 *mptr)
 
                        break;
 
-               case 0xc:
+               case REG_METHODPTR:
                        /* mptr relative */
                        /* INVOKEVIRTUAL/INTERFACE */
 
@@ -647,8 +647,8 @@ void md_handle_exception(int32_t *regs, int64_t *fregs, int32_t *out) {
 
        /* get registers */
 
-       xptr = *(uint8_t **)(regs + REG_ITMP1_XPTR);
-       xpc = *(uint8_t **)(regs + REG_ITMP2_XPC);
+       xptr = *(uint8_t **)(regs + REG_ITMP3_XPTR);
+       xpc = *(uint8_t **)(regs + REG_ITMP1_XPC);
        sp = *(uint8_t **)(regs + REG_SP);
 
 
@@ -723,8 +723,8 @@ void md_handle_exception(int32_t *regs, int64_t *fregs, int32_t *out) {
 
        /* write new values for registers */
 
-       *(uint8_t **)(regs + REG_ITMP1_XPTR) = xptr;
-       *(uint8_t **)(regs + REG_ITMP2_XPC) = xpc;
+       *(uint8_t **)(regs + REG_ITMP3_XPTR) = xptr;
+       *(uint8_t **)(regs + REG_ITMP1_XPC) = xpc;
        *(uint8_t **)(regs + REG_SP) = sp;
        *(uint8_t **)(regs + REG_PV) = pv - 0XFFC;