* Removed all Id tags.
[cacao.git] / src / vm / jit / mips / asmpart.S
index a2768dfe41524ee68d22e13654d1ac03c21281aa..ab19557308eb7f5c740a9f49834119cc40f74547 100644 (file)
@@ -22,8 +22,6 @@
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   $Id: asmpart.S 7678 2007-04-09 17:23:55Z twisti $
-
 */
 
 
@@ -31,7 +29,6 @@
 
 #include "vm/jit/mips/md-abi.h"
 #include "vm/jit/mips/md-asm.h"
-#include "vm/jit/mips/offsets.h"
 
 #include "vm/jit/abi-asm.h"
 #include "vm/jit/methodheader.h"
 
        .globl asm_abstractmethoderror
 
-       .globl asm_patcher_wrapper
-
 #if defined(ENABLE_REPLACEMENT)
        .globl asm_replacement_out
        .globl asm_replacement_in
 #endif
 
-       .globl asm_getclassvalues_atomic
-       .globl asm_criticalsections
-
        .globl compare_and_swap
 
 
@@ -145,7 +137,8 @@ asm_vm_call_method_double:
 L_asm_vm_call_method_compute_pv:
        aaddiu  pv,ra,-4*4
 
-       ast     s7,3*8(sp)
+       ast     s0,3*8(sp)                /* save callee saved register           */
+       ast     a0,4*8(sp)                /* save method PV                       */
 
 #if SIZEOF_VOID_P == 8
        sdc1    fss0,5*8(sp)              /* save non JavaABI saved flt registers */
@@ -156,146 +149,84 @@ L_asm_vm_call_method_compute_pv:
        sdc1    fss5,10*8(sp)
 #endif
 
-       ast     a0,4*8(sp)                /* save method pointer for compiler     */
-
-       move    t0,a2                     /* address of first block               */
-       move    s7,a1                     /* argument count                       */
-       blez    s7,calljava_argsloaded
-       nop
+       move    t0,a1                     /* address of data structure            */
+       move    t1,a2                     /* stack argument count                 */
+       move    s0,sp                     /* save stack pointer                   */
 
 #if SIZEOF_VOID_P == 8
 
-       ald     a0,offvmargdata(t0)
-       ldc1    fa0,offvmargdata(t0)
-       aaddi   s7,s7,-1
-       blez    s7,calljava_argsloaded
-       nop
-
-       ald     a1,offvmargdata+sizevmarg*1(t0)
-       ldc1    fa1,offvmargdata+sizevmarg*1(t0)
-       aaddi   s7,s7,-1
-       blez    s7,calljava_argsloaded
-       nop
-
-       ald     a2,offvmargdata+sizevmarg*2(t0)
-       ldc1    fa2,offvmargdata+sizevmarg*2(t0)
-       aaddi   s7,s7,-1
-       blez    s7,calljava_argsloaded
-       nop
-
-       ald     a3,offvmargdata+sizevmarg*3(t0)
-       ldc1    fa3,offvmargdata+sizevmarg*3(t0)
-       aaddi   s7,s7,-1
-       blez    s7,calljava_argsloaded
-       nop
-
-       ald     a4,offvmargdata+sizevmarg*4(t0)
-       ldc1    fa4,offvmargdata+sizevmarg*4(t0)
-       aaddi   s7,s7,-1
-       blez    s7,calljava_argsloaded
-       nop
-
-       ald     a5,offvmargdata+sizevmarg*5(t0)
-       ldc1    fa5,offvmargdata+sizevmarg*5(t0)
-       aaddi   s7,s7,-1
-       blez    s7,calljava_argsloaded
-       nop
-
-       ald     a6,offvmargdata+sizevmarg*6(t0)
-       ldc1    fa6,offvmargdata+sizevmarg*6(t0)
-       aaddi   s7,s7,-1
-       blez    s7,calljava_argsloaded
-       nop
-
-       ald     a7,offvmargdata+sizevmarg*7(t0)
-       ldc1    fa7,offvmargdata+sizevmarg*7(t0)
-       aaddi   s7,s7,-1
+       ld      a0,0*8(t0)
+       ld      a1,1*8(t0)
+       ld      a2,2*8(t0)
+       ld      a3,3*8(t0)
+       ld      a4,4*8(t0)
+       ld      a5,5*8(t0)
+       ld      a6,6*8(t0)
+       ld      a7,7*8(t0)
+
+       ldc1    fa0,8*8(t0)
+       ldc1    fa1,9*8(t0)
+       ldc1    fa2,10*8(t0)
+       ldc1    fa3,11*8(t0)
+       ldc1    fa4,12*8(t0)
+       ldc1    fa5,13*8(t0)
+       ldc1    fa6,14*8(t0)
+       ldc1    fa7,15*8(t0)
 
 #else /* SIZEOF_VOID_P == 8 */
 
-#if WORDS_BIGENDIAN == 1
-       ald     a0,offvmargdata+4(t0)
-#else
-       ald     a0,offvmargdata(t0)
-#endif
-#if !defined(ENABLE_SOFT_FLOAT)
-       ldc1    fa0,offvmargdata(t0)
-#endif
-       aaddi   s7,s7,-1
-       blez    s7,calljava_argsloaded
-
-#if WORDS_BIGENDIAN == 1
-       ald     a1,offvmargdata+4+sizevmarg*1(t0)
-#else
-       ald     a1,offvmargdata+sizevmarg*1(t0)
-#endif
-#if !defined(ENABLE_SOFT_FLOAT)
-       ldc1    fa1,offvmargdata+sizevmarg*1(t0)
-#endif
-       aaddi   s7,s7,-1
-       blez    s7,calljava_argsloaded
-
-#if WORDS_BIGENDIAN == 1
-       ald     a2,offvmargdata+4+sizevmarg*2(t0)
-#else
-       ald     a2,offvmargdata+sizevmarg*2(t0)
-#endif
-       aaddi   s7,s7,-1
-       blez    s7,calljava_argsloaded
+# if WORDS_BIGENDIAN == 1
+       lw      a0,0*8+4(t0)
+       lw      a1,1*8+4(t0)
+       lw      a2,2*8+4(t0)
+       lw      a3,3*8+4(t0)
+# else
+       lw      a0,0*8(t0)
+       lw      a1,1*8(t0)
+       lw      a2,2*8(t0)
+       lw      a3,3*8(t0)
+# endif
 
-#if WORDS_BIGENDIAN == 1
-       ald     a3,offvmargdata+4+sizevmarg*3(t0)
-#else
-       ald     a3,offvmargdata+sizevmarg*3(t0)
-#endif
-       aaddi   s7,s7,-1
-       blez    s7,calljava_argsloaded
+# if !defined(ENABLE_SOFT_FLOAT)
+       ldc1    fa0,4*8(t0)
+       ldc1    fa1,5*8(t0)
+# endif
 
 #endif /* SIZEOF_VOID_P == 8 */
 
-calljava_argsloaded:
-       move    t4,sp                     /* save stack pointer                   */
-       blez    s7,calljava_nocopy
+       beqz    t1,L_asm_vm_call_method_stack_copy_done
        nop
 
-#if SIZEOF_VOID_P == 4
-       aaddiu  s7,s7,4                   /* add stack space for 4 arguments      */
-#endif
-       subu    t1,zero,s7                /* remaining argument count (negative)  */
-       sll     t2,t1,3                   /* calculate stackframe size            */
-       aaddu   sp,sp,t2                  /* create stackframe                    */
-       aaddu   t2,t2,t4                  /* also set temp sp                     */
-#if SIZEOF_VOID_P == 4
-       aaddiu  t2,t2,4*8                 /* skip stack space for 4 arguments     */
-       addiu   t1,t1,4
-#endif
+       sll     t2,t1,3                   /* calculate stackframe size (* 8)      */
+       asubu   sp,sp,t2                  /* create stackframe                    */
+       move    t2,sp                     /* temporary stack pointer              */
 
-calljava_copyloop:
+L_asm_vm_call_method_stack_copy_loop:
 #if SIZEOF_VOID_P == 8
-       ald     t3,offvmargdata+sizevmarg*8(t0)
+       ld      t3,16*8(t0)               /* load argument                        */
+       sd      t3,0(t2)                  /* store argument on stack              */
 #else
-# if WORDS_BIGENDIAN == 1
-       ald     t3,offvmargdata+4+sizevmarg*4(t0)
+# if !defined(ENABLE_SOFT_FLOAT)
+       lw      t3,6*8+0(t0)              /* load argument                        */
+       lw      t4,6*8+4(t0)
+       sw      t3,0(t2)                  /* store argument on stack              */
+       sw      t4,4(t2)
 # else
-       ald     t3,offvmargdata+sizevmarg*4(t0)
+#  error implement me
 # endif
 #endif
-       ast     t3,0(t2)                  /* store argument on stack              */
-       addi    t1,t1,1                   /* count 1 argument                     */
-       aaddi   t0,t0,sizevmarg           /* load address of next block           */
-       aaddi   t2,t2,8                   /* increase stack position              */
-       bnez    t1,calljava_copyloop      /* all arguments copied?                */
-       nop
 
-calljava_nocopy:
-       ald     itmp1,4*8(t4)             /* pass method pointer via itmp1        */
+       aaddi   t1,t1,-1                  /* subtract 1 argument                  */
+       aaddi   t0,t0,8                   /* load address of next argument        */
+       aaddi   t2,t2,8                   /* increase stack pointer               */
 
-       ala     mptr,asm_call_jit_compiler/* fake virtual function call (2 instr) */
-       ast     mptr,2*8(t4)              /* store function address               */
-       ala     mptr,1*8(t4)              /* set method pointer                   */
+       bgtz    t1,L_asm_vm_call_method_stack_copy_loop
+       nop
 
-       ald     pv,1*8(mptr)              /* method call as in Java               */
-       jalr    pv                        /* call JIT compiler                    */
+L_asm_vm_call_method_stack_copy_done:
+       ala     mptr,4*8(s0)              /* get address of PV                    */
+       ald     pv,0*8(mptr)              /* load PV                              */
+       jalr    pv
        nop
 L_asm_vm_call_method_recompute_pv:
 #if SIZEOF_VOID_P == 8
@@ -306,13 +237,12 @@ L_asm_vm_call_method_recompute_pv:
 
        .set    reorder                   /* XXX we need to recompute pv          */
 
-       sll     t1,s7,3                   /* remove argument stackframe           */
-       aaddu   sp,sp,t1
+       move    sp,s0                     /* restore stack pointer                */
 
 calljava_return2:
        ald     ra,0*8(sp)                /* restore return address               */
        ald     pv,1*8(sp)                /* restore procedure vector             */
-       ald     s7,3*8(sp)
+       ald     s0,3*8(sp)
 
 #if SIZEOF_VOID_P == 8
        ldc1    fss0,5*8(sp)              /* restore non JavaABI saved flt regs   */
@@ -327,8 +257,7 @@ calljava_return2:
        j       ra                        /* return                               */
 
 asm_vm_call_method_exception_handler:
-       sll     t1,s7,3                   /* remove stackframe                    */
-       aaddu   sp,sp,t1
+       move    sp,s0                     /* restore stack pointer                */
 #if SIZEOF_VOID_P == 4
        aaddiu  sp,sp,-4*4                /* reserve space for 1 argument         */
 #endif
@@ -653,112 +582,6 @@ asm_abstractmethoderror:
        .end    asm_abstractmethoderror
 
 
-/* asm_patcher_wrapper *********************************************************
-
-   XXX
-
-   Stack layout:
-     56   return address into JIT code (patch position)
-     48   pointer to virtual java_objectheader
-     40   machine code (which is patched back later)
-     32   machine code (which is patched back later)
-     24   machine code (which is patched back later)
-     16   unresolved class/method/field reference
-      8   data segment displacement from load instructions
-      0   patcher function pointer to call
-
-*******************************************************************************/
-               
-    .ent    asm_patcher_wrapper
-
-asm_patcher_wrapper:
-#if SIZEOF_VOID_P == 8
-
-       aaddiu  sp,sp,-((2+16+22+4)*8)/* create stack frame                       */
-
-       SAVE_RETURN_REGISTERS(0)      /* save 1 int/1 float return registers      */
-       SAVE_ARGUMENT_REGISTERS(2)    /* save 8 int/8 float argument registers    */
-       SAVE_TEMPORARY_REGISTERS(18)  /* save 5 int/16 float temporary registers  */
-
-       ast     itmp1,(2+16+22+0)*8(sp) /* save itmp1                             */
-       ast     itmp2,(2+16+22+1)*8(sp) /* save itmp2                             */
-       ast     ra,(2+16+22+2)*8(sp)  /* save method return address (for leafs)   */
-       ast     pv,(2+16+22+3)*8(sp)  /* save pv of calling java function         */
-
-       aaddiu  a0,sp,(2+16+22+4)*8   /* pass SP of patcher stub                  */
-       move    a1,pv                 /* pass PV                                  */
-       move    a2,ra                 /* pass RA (correct for leafs)              */
-       jal     patcher_wrapper
-       move    itmp3,v0
-
-       RESTORE_RETURN_REGISTERS(0)   /* restore 1 int/1 float return registers   */
-       RESTORE_ARGUMENT_REGISTERS(2) /* restore 8 int/8 float argument registers */
-       RESTORE_TEMPORARY_REGISTERS(18) /* restore 5 int/16 float temporary reg.  */
-
-       ald     itmp1,(2+16+22+0)*8(sp) /* restore itmp1                          */
-       ald     itmp2,(2+16+22+1)*8(sp) /* restore itmp2                          */
-       ald     ra,(2+16+22+2)*8(sp)  /* restore method return address (for leafs)*/
-       ald     pv,(2+16+22+3)*8(sp)  /* restore pv of calling java function      */
-
-       bnez    itmp3,L_asm_patcher_wrapper_exception
-
-       ald     itmp3,(7+2+16+22+4)*8(sp) /* load RA                              */
-       aaddiu  sp,sp,(8+2+16+22+4)*8 /* remove stack frame                       */
-
-       jr      itmp3                 /* jump to new patched code                 */
-
-L_asm_patcher_wrapper_exception:
-       move    xptr,itmp3            /* get exception                            */
-       ald     xpc,(7+2+16+22+4)*8(sp) /* xpc is RA                              */
-       aaddiu  sp,sp,(8+2+16+22+4)*8 /* remove stack frame                       */
-
-#else /* SIZEOF_VOID_P == 8 */
-
-       aaddiu  sp,sp,-((6+4+8+16+7)*4) /* create stack frame                     */
-                                     /* +7 keeps the SP 16-bytes aligned         */
-
-       SAVE_RETURN_REGISTERS(6)      /* save 2 int / 1 float return registers    */
-       SAVE_ARGUMENT_REGISTERS(10)   /* save 4 int / 2 float argument registers  */
-       SAVE_TEMPORARY_REGISTERS(18)  /* save 8 int / 4 float temporary registers */
-
-       ast     itmp1,(6+4+8+16+0)*4(sp) /* save itmp1                            */
-       ast     itmp2,(6+4+8+16+1)*4(sp) /* save itmp2                            */
-       ast     ra,(6+4+8+16+2)*4(sp) /* save method return address (for leafs)   */
-       ast     pv,(6+4+8+16+3)*4(sp) /* save pv of calling java function         */
-
-       aaddiu  a0,sp,(6+4+8+16+7)*4  /* pass SP of patcher stub                  */
-       move    a1,pv                 /* pass PV                                  */
-       move    a2,ra                 /* pass RA (correct for leafs)              */
-       jal     patcher_wrapper
-       move    itmp3,v0
-
-       RESTORE_RETURN_REGISTERS(6)   /* restore 2 int / 2 float return registers */
-       RESTORE_ARGUMENT_REGISTERS(10) /* restore 4 int / 2 float argument regs   */
-       RESTORE_TEMPORARY_REGISTERS(18) /* restore 8 int / 4 float temporary regs */
-
-       ald     itmp1,(6+4+8+16+0)*4(sp) /* restore itmp1                         */
-       ald     itmp2,(6+4+8+16+1)*4(sp) /* restore itmp2                         */
-       ald     ra,(6+4+8+16+2)*4(sp) /* restore method return address (for leafs)*/
-       ald     pv,(6+4+8+16+3)*4(sp) /* restore pv of calling java function      */
-
-       bnez    itmp3,L_asm_wrapper_patcher_exception
-
-       ald     itmp3,7*8+(6+4+8+16+7)*4(sp) /* load RA                           */
-       aaddiu  sp,sp,8*8+(6+4+8+16+7)*4 /* remove stack frame                    */
-
-       jr      itmp3                 /* jump to new patched code                 */
-
-L_asm_wrapper_patcher_exception:
-       move    xptr,itmp3            /* get exception                            */
-       ald     xpc,7*8+(6+4+8+16+7)*4(sp) /* xpc is RA                           */
-       aaddiu  sp,sp,8*8+(6+4+8+16+7)*4 /* remove stack frame                    */
-
-#endif /* SIZEOF_VOID_P == 8 */
-
-       b       asm_handle_exception
-
-       .end    asm_patcher_wrapper
-
 #if defined(ENABLE_REPLACEMENT)
                
 /* asm_replacement_out *********************************************************
@@ -1025,35 +848,6 @@ asm_replacement_in:
 #endif /* defined(ENABLE_REPLACEMENT) */
 
 
-       .ent    asm_getclassvalues_atomic
-
-asm_getclassvalues_atomic:
-_crit_restart:
-_crit_begin:
-       lw      t0,offbaseval(a0)
-       lw      t1,offdiffval(a0)
-       lw      t2,offbaseval(a1)
-_crit_end:
-       sw      t0,offcast_super_baseval(a2)
-       sw      t1,offcast_super_diffval(a2)
-       sw      t2,offcast_sub_baseval(a2)
-       j       ra
-
-       .end    asm_getclassvalues_atomic
-
-    .data
-
-asm_criticalsections:
-#if defined(ENABLE_THREADS)
-    .dword  _crit_begin
-    .dword  _crit_end
-    .dword  _crit_restart
-#endif
-    .dword  0
-
-
-       .text
-
        .ent    compare_and_swap
 
 compare_and_swap: