* src/vm/jit/mips/md.c (sys/cachectl.h): Added.
authortwisti <none@none>
Thu, 16 Mar 2006 17:24:18 +0000 (17:24 +0000)
committertwisti <none@none>
Thu, 16 Mar 2006 17:24:18 +0000 (17:24 +0000)
(md_cacheflush, md_icacheflush, md_dcacheflush): New method.

* src/vm/jit/mips/codegen.c: Use new exception stubs.
* src/vm/jit/mips/codegen.h (gen_nullptr_check, gen_bound_check)
(gen_div_check): Use new add reference functions.

* src/vm/jit/mips/patcher.c: Replaced cacheflush with md_icacheflush
or md_dcacheflush.

* src/vm/jit/mips/asmpart.S: (asm_calljavafunction): Removed.
(asm_calljavafunction2): Renamed to asm_vm_call_method. Pointer to
vm_arg block is now in a2. Use new defines.

src/vm/jit/mips/asmpart.S
src/vm/jit/mips/codegen.c
src/vm/jit/mips/codegen.h
src/vm/jit/mips/md.c
src/vm/jit/mips/patcher.c

index 9a34c5acbf68defefc2e947de723aa3104fab9d2..3382ceade70a98ceb89d0cec768429eba998d02a 100644 (file)
@@ -28,7 +28,7 @@
 
    Changes: Christian Thalinger
 
-   $Id: asmpart.S 4440 2006-02-05 12:03:43Z twisti $
+   $Id: asmpart.S 4640 2006-03-16 17:24:18Z twisti $
 
 */
 
        .set    noat
 
 
-/* exported functions and variables *******************************************/
+/* export functions ***********************************************************/
 
-       .globl asm_calljavafunction
-       .globl asm_calljavafunction_int
-
-       .globl asm_calljavafunction2
-       .globl asm_calljavafunction2int
-       .globl asm_calljavafunction2long
-       .globl asm_calljavafunction2float
-       .globl asm_calljavafunction2double
+       .globl asm_vm_call_method
+       .globl asm_vm_call_method_int
+       .globl asm_vm_call_method_long
+       .globl asm_vm_call_method_float
+       .globl asm_vm_call_method_double
 
        .globl asm_call_jit_compiler
        .globl asm_handle_exception
 *                                                                              *
 *******************************************************************************/
 
-       .ent    asm_calljavafunction
-
-       .align  3
-
-       .dword  0                           /* catch type all                     */
-       .dword  calljava_xhandler           /* handler pc                         */
-       .dword  calljava_xhandler           /* end pc                             */
-       .dword  asm_calljavafunction        /* start pc                           */
-       .word   1                           /* extable size                       */
-       .word   0                           /* 4-byte ALIGNMENT PADDING           */
-       .dword  0                           /* line number table start            */
-       .dword  0                           /* line number table size             */
-       .word   0                           /* 4-byte ALIGNMENT PADDING           */
-       .word   0                           /* fltsave                            */
-       .word   0                           /* intsave                            */
-       .word   0                           /* isleaf                             */
-       .word   0                           /* IsSync                             */
-       .word   0                           /* frame size                         */
-       .dword  0                           /* method pointer (pointer to name)   */
-
-asm_calljavafunction:
-asm_calljavafunction_int:
-       .set    noreorder                 /* XXX we need to recompute pv          */
-
-       aaddiu  sp,sp,-10*8               /* allocate stack space                 */
-       ast     ra,0(sp)                  /* save return address                  */
-
-       bal     call_java_pc
-       ast     pv,3*8(sp)                /* procedure vector (delay slot)        */
-call_java_pc:
-       aaddiu  pv,ra,-4*4
-
-       sdc1    fss0,4*8(sp)              /* save non JavaABI saved flt registers */
-       sdc1    fss1,5*8(sp)
-       sdc1    fss2,6*8(sp)
-       sdc1    fss3,7*8(sp)
-       sdc1    fss4,8*8(sp)
-       sdc1    fss5,9*8(sp)
-
-       move    itmp1,a0                  /* pass method pointer via tmp1         */
-
-       move    a0,a1                     /* pass the remaining parameters        */
-       move    a1,a2
-       move    a2,a3
-       move    a3,a4
-
-       ala     mptr,asm_call_jit_compiler/* fake virtual function call (2 instr) */
-       ast     mptr,1*8(sp)              /* store function address               */
-       move    mptr,sp                   /* set method pointer                   */
-
-       ald     pv,1*8(mptr)              /* method call as in Java               */
-       jalr    pv                        /* call JIT compiler                    */
-       nop
-L_asm_calljavafunction_recompute:
-/*     aaddiu  pv,ra,(asm_calljavafunction - L_asm_calljavafunction_recompute)*/
-       aaddiu  pv,ra,-22*4
-
-       .set    reorder                   /* XXX we need to recompute pv          */
-
-calljava_return:
-       ald     ra,0(sp)                  /* restore return address               */
-       ald     pv,3*8(sp)                /* restore procedure vector             */
-
-       ldc1    fss0,4*8(sp)              /* restore non JavaABI saved flt regs   */
-       ldc1    fss1,5*8(sp)
-       ldc1    fss2,6*8(sp)
-       ldc1    fss3,7*8(sp)
-       ldc1    fss4,8*8(sp)
-       ldc1    fss5,9*8(sp)
-
-       aaddiu  sp,sp,10*8                /* free stack space                     */
-       j       ra                        /* return                               */
-
-calljava_xhandler:
-       move    a0,itmp1                  
-       jal     builtin_throw_exception
-       move    v0,zero                   /* clear return value for exception     */
-       b       calljava_return
-
-       .end    asm_calljavafunction
-
-
-       .ent    asm_calljavafunction2
+       .ent    asm_vm_call_method
 
        .align  3
 
        .dword  0                           /* catch type all                     */
        .dword  calljava_xhandler2          /* handler pc                         */
        .dword  calljava_xhandler2          /* end pc                             */
-       .dword  asm_calljavafunction2       /* start pc                           */
+       .dword  asm_vm_call_method          /* start pc                           */
        .word   1                           /* extable size                       */
        .word   0                           /* 4-byte ALIGNMENT PADDING           */
        .dword  0                           /* line number table start            */
@@ -194,19 +109,19 @@ calljava_xhandler:
        .word   0                           /* frame size                         */
        .dword  0                           /* method pointer (pointer to name)   */
 
-asm_calljavafunction2:
-asm_calljavafunction2int:
-asm_calljavafunction2long:
-asm_calljavafunction2float:
-asm_calljavafunction2double:
+asm_vm_call_method:
+asm_vm_call_method_int:
+asm_vm_call_method_long:
+asm_vm_call_method_float:
+asm_vm_call_method_double:
        .set    noreorder                 /* XXX we need to recompute pv          */
 
        aaddiu  sp,sp,-12*8               /* allocate stack space (only 11 needed)*/
        ast     ra,0(sp)                  /* save return address                  */
 
-       bal     call_java_pc2
+       bal     L_asm_vm_call_method_compute_pv
        ast     pv,1*8(sp)                /* procedure vector                     */
-call_java_pc2:
+L_asm_vm_call_method_compute_pv:
        aaddiu  pv,ra,-4*4
        ast     s7,3*8(sp)
 
@@ -219,55 +134,55 @@ call_java_pc2:
 
        ast     a0,4*8(sp)                /* save method pointer for compiler     */
 
-       move    t0,a3
+       move    t0,a2
        move    s7,a1
        blez    s7,calljava_argsloaded
        nop
 
-       ald     a0,offjniitem(t0)
-       ldc1    fa0,offjniitem(t0)
+       ald     a0,offvmargdata(t0)
+       ldc1    fa0,offvmargdata(t0)
        daddi   s7,s7,-1
        blez    s7,calljava_argsloaded
        nop
 
-       ald     a1,offjniitem+sizejniblock*1(t0)
-       ldc1    fa1,offjniitem+sizejniblock*1(t0)
+       ald     a1,offvmargdata+sizevmarg*1(t0)
+       ldc1    fa1,offvmargdata+sizevmarg*1(t0)
        daddi   s7,s7,-1
        blez    s7,calljava_argsloaded
        nop
 
-       ald     a2,offjniitem+sizejniblock*2(t0)
-       ldc1    fa2,offjniitem+sizejniblock*2(t0)
+       ald     a2,offvmargdata+sizevmarg*2(t0)
+       ldc1    fa2,offvmargdata+sizevmarg*2(t0)
        daddi   s7,s7,-1
        blez    s7,calljava_argsloaded
        nop
 
-       ald     a3,offjniitem+sizejniblock*3(t0)
-       ldc1    fa3,offjniitem+sizejniblock*3(t0)
+       ald     a3,offvmargdata+sizevmarg*3(t0)
+       ldc1    fa3,offvmargdata+sizevmarg*3(t0)
        daddi   s7,s7,-1
        blez    s7,calljava_argsloaded
        nop
 
-       ald     a4,offjniitem+sizejniblock*4(t0)
-       ldc1    fa4,offjniitem+sizejniblock*4(t0)
+       ald     a4,offvmargdata+sizevmarg*4(t0)
+       ldc1    fa4,offvmargdata+sizevmarg*4(t0)
        daddi   s7,s7,-1
        blez    s7,calljava_argsloaded
        nop
 
-       ald     a5,offjniitem+sizejniblock*5(t0)
-       ldc1    fa5,offjniitem+sizejniblock*5(t0)
+       ald     a5,offvmargdata+sizevmarg*5(t0)
+       ldc1    fa5,offvmargdata+sizevmarg*5(t0)
        daddi   s7,s7,-1
        blez    s7,calljava_argsloaded
        nop
 
-       ald     a6,offjniitem+sizejniblock*6(t0)
-       ldc1    fa6,offjniitem+sizejniblock*6(t0)
+       ald     a6,offvmargdata+sizevmarg*6(t0)
+       ldc1    fa6,offvmargdata+sizevmarg*6(t0)
        daddi   s7,s7,-1
        blez    s7,calljava_argsloaded
        nop
 
-       ald     a7,offjniitem+sizejniblock*7(t0)
-       ldc1    fa7,offjniitem+sizejniblock*7(t0)
+       ald     a7,offvmargdata+sizevmarg*7(t0)
+       ldc1    fa7,offvmargdata+sizevmarg*7(t0)
        daddi   s7,s7,-1
                
 calljava_argsloaded:
@@ -280,10 +195,10 @@ calljava_argsloaded:
        aaddu   t2,t2,t8
 
 calljava_copyloop:
-    ald     t3,offjniitem+sizejniblock*8(t0)
+    ald     t3,offvmargdata+sizevmarg*8(t0)
        ast     t3,0(t2)
        ala     t1,1(t1)
-       ala     t0,sizejniblock(t0)
+       ala     t0,sizevmarg(t0)
        ala     t2,8(t2)
        bnez    t1,calljava_copyloop
        nop
@@ -298,8 +213,8 @@ calljava_nocopy:
        ald     pv,1*8(mptr)              /* method call as in Java               */
        jalr    pv                        /* call JIT compiler                    */
        nop
-L_asm_calljavafunction2_recompute:
-/*     aaddiu  pv,ra,(asm_calljavafunction2 - L_asm_calljavafunction2_recompute)*/
+L_asm_vm_call_method_recompute_pv:
+/*     aaddiu  pv,ra,(asm_vm_call_method - L_asm_vm_call_method_recompute_pv)*/
        aaddiu  pv,ra,-76*4               /* recompute procedure vector           */
 
        .set    reorder                   /* XXX we need to recompute pv          */
@@ -326,7 +241,7 @@ calljava_xhandler2:
        jal     builtin_throw_exception
        b       calljava_return2
 
-       .end    asm_calljavafunction2
+       .end    asm_vm_call_method
 
 
 /****************** function asm_call_jit_compiler *****************************
index be57817616688905894d0923b75334eb79a4072c..7972ae4f1fa41d2c7587796feac44216ecbfbea7 100644 (file)
@@ -35,7 +35,7 @@
    This module generates MIPS machine code for a sequence of
    intermediate code commands (ICMDs).
 
-   $Id: codegen.c 4598 2006-03-14 22:16:47Z edwin $
+   $Id: codegen.c 4640 2006-03-16 17:24:18Z twisti $
 
 */
 
@@ -260,7 +260,7 @@ bool codegen(methodinfo *m, codegendata *cd, registerdata *rd)
 
                } else {
                        M_BEQZ(rd->argintregs[0], 0);
-                       codegen_addxnullrefs(cd, mcodeptr);
+                       codegen_add_nullpointerexception_ref(cd, mcodeptr);
                        p = dseg_addaddress(cd, BUILTIN_monitorenter);
                        M_ALD(REG_ITMP3, REG_PV, p);
                        M_JSR(REG_RA, REG_ITMP3);
@@ -472,7 +472,7 @@ bool codegen(methodinfo *m, codegendata *cd, registerdata *rd)
 
                        var_to_reg_int(s1, src, REG_ITMP1);
                        M_BEQZ(s1, 0);
-                       codegen_addxnullrefs(cd, mcodeptr);
+                       codegen_add_nullpointerexception_ref(cd, mcodeptr);
                        M_NOP;
                        break;
 
@@ -1745,7 +1745,7 @@ bool codegen(methodinfo *m, codegendata *cd, registerdata *rd)
                        M_NOP;
 
                        M_BEQZ(REG_RESULT, 0);
-                       codegen_addxstorerefs(cd, mcodeptr);
+                       codegen_add_arraystoreexception_ref(cd, mcodeptr);
                        M_NOP;
 
                        var_to_reg_int(s1, src->prev->prev, REG_ITMP1);
@@ -3008,14 +3008,14 @@ gen_method:
 
                                if (iptr->op1 == true) {
                                        M_BEQZ(REG_RESULT, 0);
-                                       codegen_addxexceptionrefs(cd, mcodeptr);
+                                       codegen_add_fillinstacktrace_ref(cd, mcodeptr);
                                        M_NOP;
                                }
                                break;
 
                        case ICMD_INVOKESPECIAL:
                                M_BEQZ(rd->argintregs[0], 0);
-                               codegen_addxnullrefs(cd, mcodeptr);
+                               codegen_add_nullpointerexception_ref(cd, mcodeptr);
                                M_NOP;
                                /* fall through */
 
@@ -3227,13 +3227,13 @@ gen_method:
                                        M_ILD(REG_ITMP3, REG_ITMP2, OFFSET(vftbl_t, interfacetablelength));
                                        M_IADD_IMM(REG_ITMP3, -superindex, REG_ITMP3);
                                        M_BLEZ(REG_ITMP3, 0);
-                                       codegen_addxcastrefs(cd, mcodeptr);
+                                       codegen_add_classcastexception_ref(cd, mcodeptr);
                                        M_NOP;
                                        M_ALD(REG_ITMP3, REG_ITMP2,
                                                  OFFSET(vftbl_t, interfacetable[0]) -
                                                  superindex * sizeof(methodptr*));
                                        M_BEQZ(REG_ITMP3, 0);
-                                       codegen_addxcastrefs(cd, mcodeptr);
+                                       codegen_add_classcastexception_ref(cd, mcodeptr);
                                        M_NOP;
 
                                        if (!super) {
@@ -3286,7 +3286,7 @@ gen_method:
                                        /*                              } */
                                        M_CMPULT(REG_ITMP3, REG_ITMP2, REG_ITMP3);
                                        M_BNEZ(REG_ITMP3, 0);
-                                       codegen_addxcastrefs(cd, mcodeptr);
+                                       codegen_add_classcastexception_ref(cd, mcodeptr);
                                        M_NOP;
                                }
                                d = reg_of_var(rd, iptr->dst, s1);
@@ -3315,7 +3315,7 @@ gen_method:
                                M_NOP;
 
                                M_BEQZ(REG_RESULT, 0);
-                               codegen_addxcastrefs(cd, mcodeptr);
+                               codegen_add_classcastexception_ref(cd, mcodeptr);
                                M_NOP;
 
                                var_to_reg_int(s1, src, REG_ITMP1);
@@ -3532,7 +3532,7 @@ gen_method:
                        /* check for exception before result assignment */
 
                        M_BEQZ(REG_RESULT, 0);
-                       codegen_addxexceptionrefs(cd, mcodeptr);
+                       codegen_add_fillinstacktrace_ref(cd, mcodeptr);
                        M_NOP;
 
                        d = reg_of_var(rd, iptr->dst, REG_RESULT);
@@ -3597,6 +3597,7 @@ gen_method:
 
        dseg_createlinenumbertable(cd);
 
+#if 0
        {
        s4        *xcodeptr;
        branchref *bref;
@@ -3918,36 +3919,112 @@ gen_method:
                        M_NOP;
                }
        }
+#endif
+
 
-       /* generate patcher stub call code */
+       /* generate exception and patcher stubs */
 
        {
-               patchref *pref;
-               u8        mcode;
-               s4       *tmpmcodeptr;
+               exceptionref *eref;
+               patchref     *pref;
+               u8            mcode;
+               s4           *savedmcodeptr;
+               s4           *tmpmcodeptr;
+
+               savedmcodeptr = NULL;
+
+               /* generate exception stubs */
+
+               for (eref = cd->exceptionrefs; eref != NULL; eref = eref->next) {
+                       gen_resolvebranch((u1 *) cd->mcodebase + eref->branchpos, 
+                                                         eref->branchpos,
+                                                         (u1 *) mcodeptr - cd->mcodebase);
+
+                       MCODECHECK(100);
+
+                       /* Check if the exception is an
+                          ArrayIndexOutOfBoundsException.  If so, move index register
+                          into REG_ITMP1. */
+
+                       if (eref->reg != -1)
+                               M_MOV(eref->reg, REG_ITMP1);
+
+                       /* calcuate exception address */
+
+                       M_LDA(REG_ITMP2_XPC, REG_PV, eref->branchpos - 4);
+
+                       /* move function to call into REG_ITMP3 */
+
+                       disp = dseg_addaddress(cd, eref->function);
+                       M_ALD(REG_ITMP3, REG_PV, disp);
+
+                       if (savedmcodeptr != NULL) {
+                               M_BR(savedmcodeptr - mcodeptr);
+                               M_NOP;
+
+                       } else {
+                               savedmcodeptr = mcodeptr;
+
+                               M_MOV(REG_PV, rd->argintregs[0]);
+                               M_MOV(REG_SP, rd->argintregs[1]);
+
+                               if (m->isleafmethod)
+                                       M_MOV(REG_RA, rd->argintregs[2]);
+                               else
+                                       M_ALD(rd->argintregs[2],
+                                                 REG_SP, parentargs_base * 8 - SIZEOF_VOID_P);
+
+                               M_MOV(REG_ITMP2_XPC, rd->argintregs[3]);
+                               M_MOV(REG_ITMP1, rd->argintregs[4]);
+
+                               M_ASUB_IMM(REG_SP, 2 * 8, REG_SP);
+                               M_AST(REG_ITMP2_XPC, REG_SP, 0 * 8);
+
+                               if (m->isleafmethod)
+                                       M_AST(REG_RA, REG_SP, 1 * 8);
+
+                               M_JSR(REG_RA, REG_ITMP3);
+                               M_NOP;
+                               M_MOV(REG_RESULT, REG_ITMP1_XPTR);
+
+                               if (m->isleafmethod)
+                                       M_ALD(REG_RA, REG_SP, 1 * 8);
+
+                               M_ALD(REG_ITMP2_XPC, REG_SP, 0 * 8);
+                               M_AADD_IMM(REG_SP, 2 * 8, REG_SP);
+
+                               a = dseg_addaddress(cd, asm_handle_exception);
+                               M_ALD(REG_ITMP3, REG_PV, a);
+                               M_JMP(REG_ITMP3);
+                               M_NOP;
+                       }
+               }
+
+
+               /* generate code patching stub call code */
 
                for (pref = cd->patchrefs; pref != NULL; pref = pref->next) {
                        /* check code segment size */
 
                        MCODECHECK(100);
 
-                       /* Get machine code which is patched back in later. The call is   */
-                       /* 2 instruction words long.                                      */
+                       /* Get machine code which is patched back in later. The
+                          call is 2 instruction words long. */
 
-                       xcodeptr = (s4 *) (cd->mcodebase + pref->branchpos);
+                       tmpmcodeptr = (s4 *) (cd->mcodebase + pref->branchpos);
 
-                       /* We need to split this, because an unaligned 8 byte read causes */
-                       /* a SIGSEGV.                                                     */
+                       /* We need to split this, because an unaligned 8 byte read
+                          causes a SIGSEGV. */
 
-                       mcode = ((u8) xcodeptr[1] << 32) + (u4) xcodeptr[0];
+                       mcode = ((u8) tmpmcodeptr[1] << 32) + (u4) tmpmcodeptr[0];
 
-                       /* patch in the call to call the following code (done at compile  */
-                       /* time)                                                          */
+                       /* Patch in the call to call the following code (done at
+                          compile time). */
 
-                       tmpmcodeptr = mcodeptr;         /* save current mcodeptr          */
-                       mcodeptr = xcodeptr;            /* set mcodeptr to patch position */
+                       savedmcodeptr = mcodeptr;       /* save current mcodeptr          */
+                       mcodeptr      = tmpmcodeptr;    /* set mcodeptr to patch position */
 
-                       disp = (s4) (tmpmcodeptr - (xcodeptr + 1));
+                       disp = (s4) (savedmcodeptr - (tmpmcodeptr + 1));
 
                        if ((disp < (s4) 0xffff8000) || (disp > (s4) 0x00007fff)) {
                                *exceptionptr =
@@ -3959,7 +4036,7 @@ gen_method:
                        M_BR(disp);
                        M_NOP;
 
-                       mcodeptr = tmpmcodeptr;         /* restore the current mcodeptr   */
+                       mcodeptr = savedmcodeptr;       /* restore the current mcodeptr   */
 
                        /* create stack frame */
 
@@ -4014,7 +4091,6 @@ gen_method:
                        M_NOP;
                }
        }
-       }
 
        codegen_finish(m, cd, (s4) ((u1 *) mcodeptr - cd->mcodebase));
 
@@ -4398,31 +4474,31 @@ u1 *createnativestub(functionptr f, methodinfo *m, codegendata *cd,
 
        {
                patchref *pref;
-               s4       *xcodeptr;
-               s8        mcode;
+               u8        mcode;
+               s4       *savedmcodeptr;
                s4       *tmpmcodeptr;
 
                for (pref = cd->patchrefs; pref != NULL; pref = pref->next) {
-                       /* Get machine code which is patched back in later. The call is   */
-                       /* 2 instruction words long.                                      */
+                       /* Get machine code which is patched back in later. The
+                          call is 2 instruction words long. */
 
-                       xcodeptr = (s4 *) (cd->mcodebase + pref->branchpos);
+                       tmpmcodeptr = (s4 *) (cd->mcodebase + pref->branchpos);
 
-                       /* We need to split this, because an unaligned 8 byte read causes */
-                       /* a SIGSEGV.                                                     */
+                       /* We need to split this, because an unaligned 8 byte read
+                          causes a SIGSEGV. */
 
-                       mcode = ((u8) xcodeptr[1] << 32) + (u4) xcodeptr[0];
+                       mcode = ((u8) tmpmcodeptr[1] << 32) + (u4) tmpmcodeptr[0];
 
-                       /* patch in the call to call the following code (done at compile  */
-                       /* time)                                                          */
+                       /* Patch in the call to call the following code (done at
+                          compile time). */
 
-                       tmpmcodeptr = mcodeptr;         /* save current mcodeptr          */
-                       mcodeptr = xcodeptr;            /* set mcodeptr to patch position */
+                       savedmcodeptr = mcodeptr;       /* save current mcodeptr          */
+                       mcodeptr      = tmpmcodeptr;    /* set mcodeptr to patch position */
 
-                       M_BRS(tmpmcodeptr - (xcodeptr + 1));
+                       M_BRS(savedmcodeptr - (tmpmcodeptr + 1));
                        M_NOP;                          /* branch delay slot              */
 
-                       mcodeptr = tmpmcodeptr;         /* restore the current mcodeptr   */
+                       mcodeptr = savedmcodeptr;       /* restore the current mcodeptr   */
 
                        /* create stack frame                                             */
 
index 8532b252622ccec16afd4efc8ff5e537fe66ade5..bc5db736d37c113511ce1bf6a8abd2de1f649e8e 100644 (file)
@@ -26,7 +26,7 @@
 
    Authors: Andreas Krall
 
-   $Id: codegen.h 4357 2006-01-22 23:33:38Z twisti $
+   $Id: codegen.h 4640 2006-03-16 17:24:18Z twisti $
 
 */
 
 
 /* additional functions and macros to generate code ***************************/
 
-/* gen_nullptr_check(objreg) */
-
 #define gen_nullptr_check(objreg) \
     if (checknull) { \
-        M_BEQZ((objreg), 0); \
-        codegen_addxnullrefs(cd, mcodeptr); \
+        M_BEQZ(objreg, 0); \
+        codegen_add_nullpointerexception_ref(cd, mcodeptr); \
         M_NOP; \
     }
 
         M_ILD(REG_ITMP3, s1, OFFSET(java_arrayheader, size)); \
         M_CMPULT(s2, REG_ITMP3, REG_ITMP3); \
         M_BEQZ(REG_ITMP3, 0); \
-        codegen_addxboundrefs(cd, mcodeptr, s2); \
+        codegen_add_arrayindexoutofboundsexception_ref(cd, mcodeptr, s2); \
         M_NOP; \
     }
 
 #define gen_div_check(r) \
-    M_BEQZ((r), 0); \
-    codegen_addxdivrefs(cd, mcodeptr); \
-    M_NOP;
+    do { \
+        M_BEQZ((r), 0); \
+        codegen_add_arithmeticexception_ref(cd, mcodeptr); \
+        M_NOP; \
+    } while (0)
 
 
 /* MCODECHECK(icnt) */
index ccfb4b11fee7586d4a01a025a78e83d42e655c09..7836913ca2e1cbafb6c38938fc2f658c65242fdc 100644 (file)
@@ -28,7 +28,7 @@
 
    Changes: 
 
-   $Id: md.c 4498 2006-02-12 23:43:09Z twisti $
+   $Id: md.c 4640 2006-03-16 17:24:18Z twisti $
 
 */
 
@@ -36,8 +36,9 @@
 #include "config.h"
 
 #include <assert.h>
-#include <sys/mman.h>
 #include <unistd.h>
+#include <sys/cachectl.h>
+#include <sys/mman.h>
 
 #include "vm/types.h"
 
@@ -220,6 +221,43 @@ u1 *md_codegen_findmethod(u1 *ra)
 }
 
 
+/* md_cacheflush ***************************************************************
+
+   Calls the system's function to flush the instruction and data
+   cache.
+
+*******************************************************************************/
+
+void md_cacheflush(u1 *addr, s4 nbytes)
+{
+       cacheflush(addr, nbytes, BCACHE);
+}
+
+
+/* md_icacheflush **************************************************************
+
+   Calls the system's function to flush the instruction cache.
+
+*******************************************************************************/
+
+void md_icacheflush(u1 *addr, s4 nbytes)
+{
+       cacheflush(addr, nbytes, ICACHE);
+}
+
+
+/* md_dcacheflush **************************************************************
+
+   Calls the system's function to flush the data cache.
+
+*******************************************************************************/
+
+void md_dcacheflush(u1 *addr, s4 nbytes)
+{
+       cacheflush(addr, nbytes, DCACHE);
+}
+
+
 /*
  * 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 65871670e5aa94a720248ac34307cbc42b2b0274..fa3b2d7871f77bebfa0b201b164d8e14b5f77452 100644 (file)
 
    Changes:
 
-   $Id: patcher.c 4530 2006-02-21 09:11:53Z twisti $
+   $Id: patcher.c 4640 2006-03-16 17:24:18Z twisti $
 
 */
 
 
 #include "config.h"
-
-#include <sys/cachectl.h>
-
 #include "vm/types.h"
 
 #include "mm/memory.h"
@@ -122,7 +119,7 @@ bool patcher_get_putstatic(u1 *sp)
 
        /* synchronize instruction cache */
 
-       cacheflush(ra, 2 * 4, ICACHE);
+       md_icacheflush(ra, 2 * 4);
 
        /* patch the field value's address */
 
@@ -130,7 +127,7 @@ bool patcher_get_putstatic(u1 *sp)
 
        /* synchronize data cache */
 
-       cacheflush(pv + disp, SIZEOF_VOID_P, DCACHE);
+       md_dcacheflush(pv + disp, SIZEOF_VOID_P);
 
        PATCHER_MARK_PATCHED_MONITOREXIT;
 
@@ -216,12 +213,12 @@ bool patcher_get_putfield(u1 *sp)
        if (opt_showdisassemble) {
 #if SIZEOF_VOID_P == 4
                if (fi->type == TYPE_LNG) {
-                       cacheflush(ra - 2 * 4, 4 * 4, ICACHE);
+                       md_icacheflush(ra - 2 * 4, 4 * 4);
                } else
 #endif
-                       cacheflush(ra - 2 * 4, 3 * 4, ICACHE);
+                       md_icacheflush(ra - 2 * 4, 3 * 4);
        } else {
-               cacheflush(ra, 2 * 4, ICACHE);
+               md_icacheflush(ra, 2 * 4);
        }
 
        PATCHER_MARK_PATCHED_MONITOREXIT;
@@ -289,7 +286,7 @@ bool patcher_aconst(u1 *sp)
 
        /* synchronize instruction cache */
 
-       cacheflush(ra, 2 * 4, ICACHE);
+       md_icacheflush(ra, 2 * 4);
 
        /* patch the classinfo pointer */
 
@@ -297,7 +294,7 @@ bool patcher_aconst(u1 *sp)
 
        /* synchronize data cache */
 
-       cacheflush(pv + disp, SIZEOF_VOID_P * 1, DCACHE);
+       md_dcacheflush(pv + disp, SIZEOF_VOID_P);
 
        PATCHER_MARK_PATCHED_MONITOREXIT;
 
@@ -368,7 +365,7 @@ bool patcher_builtin_multianewarray(u1 *sp)
 
        /* synchronize instruction cache */
 
-       cacheflush(ra, 2 * 4, ICACHE);
+       md_icacheflush(ra, 2 * 4);
 
        /* patch the classinfo pointer */
 
@@ -376,7 +373,7 @@ bool patcher_builtin_multianewarray(u1 *sp)
 
        /* synchronize data cache */
 
-       cacheflush(pv + disp, SIZEOF_VOID_P, DCACHE);
+       md_dcacheflush(pv + disp, SIZEOF_VOID_P);
 
        PATCHER_MARK_PATCHED_MONITOREXIT;
 
@@ -446,7 +443,7 @@ bool patcher_builtin_arraycheckcast(u1 *sp)
 
        /* synchronize instruction cache */
 
-       cacheflush(ra, 2 * 4, ICACHE);
+       md_icacheflush(ra, 2 * 4);
 
        /* patch the classinfo pointer */
 
@@ -454,7 +451,7 @@ bool patcher_builtin_arraycheckcast(u1 *sp)
 
        /* synchronize data cache */
 
-       cacheflush(pv + disp, SIZEOF_VOID_P * 1, DCACHE);
+       md_dcacheflush(pv + disp, SIZEOF_VOID_P);
 
        PATCHER_MARK_PATCHED_MONITOREXIT;
 
@@ -523,7 +520,7 @@ bool patcher_invokestatic_special(u1 *sp)
 
        /* synchronize instruction cache */
 
-       cacheflush(ra, 2 * 4, ICACHE);
+       md_icacheflush(ra, 2 * 4);
 
        /* patch stubroutine */
 
@@ -531,7 +528,7 @@ bool patcher_invokestatic_special(u1 *sp)
 
        /* synchronize data cache */
 
-       cacheflush(pv + disp, SIZEOF_VOID_P, DCACHE);
+       md_dcacheflush(pv + disp, SIZEOF_VOID_P);
 
        PATCHER_MARK_PATCHED_MONITOREXIT;
 
@@ -608,9 +605,9 @@ bool patcher_invokevirtual(u1 *sp)
        /* synchronize instruction cache */
 
        if (opt_showdisassemble)
-               cacheflush(ra - 2 * 4, 4 * 4, ICACHE);
+               md_icacheflush(ra - 2 * 4, 4 * 4);
        else
-               cacheflush(ra, 2 * 4, ICACHE);
+               md_icacheflush(ra, 2 * 4);
 
        PATCHER_MARK_PATCHED_MONITOREXIT;
 
@@ -693,9 +690,9 @@ bool patcher_invokeinterface(u1 *sp)
        /* synchronize instruction cache */
 
        if (opt_showdisassemble)
-               cacheflush(ra - 2 * 4, 5 * 4, ICACHE);
+               md_icacheflush(ra - 2 * 4, 5 * 4);
        else
-               cacheflush(ra, 3 * 4, ICACHE);
+               md_icacheflush(ra, 3 * 4);
 
        PATCHER_MARK_PATCHED_MONITOREXIT;
 
@@ -765,7 +762,7 @@ bool patcher_checkcast_instanceof_flags(u1 *sp)
 
        /* synchronize instruction cache */
 
-       cacheflush(ra, 2 * 4, ICACHE);
+       md_icacheflush(ra, 2 * 4);
 
        /* patch class flags */
 
@@ -773,7 +770,7 @@ bool patcher_checkcast_instanceof_flags(u1 *sp)
 
        /* synchronize data cache */
 
-       cacheflush(pv + disp, sizeof(s4), DCACHE);
+       md_dcacheflush(pv + disp, sizeof(s4));
 
        PATCHER_MARK_PATCHED_MONITOREXIT;
 
@@ -854,9 +851,9 @@ bool patcher_checkcast_instanceof_interface(u1 *sp)
        /* synchronize instruction cache */
 
        if (opt_showdisassemble)
-               cacheflush(ra - 2 * 4, 8 * 4, ICACHE);
+               md_icacheflush(ra - 2 * 4, 8 * 4);
        else
-               cacheflush(ra, 6 * 4, ICACHE);
+               md_icacheflush(ra, 6 * 4);
 
        PATCHER_MARK_PATCHED_MONITOREXIT;
 
@@ -924,7 +921,7 @@ bool patcher_checkcast_instanceof_class(u1 *sp)
 
        /* synchronize instruction cache */
 
-       cacheflush(ra, 2 * 4, ICACHE);
+       md_icacheflush(ra, 2 * 4);
 
        /* patch super class' vftbl */
 
@@ -932,7 +929,7 @@ bool patcher_checkcast_instanceof_class(u1 *sp)
 
        /* synchronize data cache */
 
-       cacheflush(pv + disp, SIZEOF_VOID_P, DCACHE);
+       md_dcacheflush(pv + disp, SIZEOF_VOID_P);
 
        PATCHER_MARK_PATCHED_MONITOREXIT;
 
@@ -993,7 +990,7 @@ bool patcher_clinit(u1 *sp)
 
        /* synchronize instruction cache */
 
-       cacheflush(ra, 2 * 4, ICACHE);
+       md_icacheflush(ra, 2 * 4);
 
        PATCHER_MARK_PATCHED_MONITOREXIT;
 
@@ -1056,7 +1053,7 @@ bool patcher_athrow_areturn(u1 *sp)
 
        /* synchronize instruction cache */
 
-       cacheflush(ra, 2 * 4, ICACHE);
+       md_icacheflush(ra, 2 * 4);
 
        PATCHER_MARK_PATCHED_MONITOREXIT;
 
@@ -1127,7 +1124,7 @@ bool patcher_resolve_native(u1 *sp)
 
        /* synchronize instruction cache */
 
-       cacheflush(ra, 2 * 4, ICACHE);
+       md_icacheflush(ra, 2 * 4);
 
        /* patch native function pointer */
 
@@ -1135,7 +1132,7 @@ bool patcher_resolve_native(u1 *sp)
 
        /* synchronize data cache */
 
-       cacheflush(pv + disp, SIZEOF_VOID_P, DCACHE);
+       md_dcacheflush(pv + disp, SIZEOF_VOID_P);
 
        PATCHER_MARK_PATCHED_MONITOREXIT;