/* src/vm/jit/mips/asmpart.S - Java-C interface functions for MIPS
- Copyright (C) 1996-2005, 2006 R. Grafl, A. Krall, C. Kruegel,
+ Copyright (C) 1996-2005, 2006, 2007 R. Grafl, A. Krall, C. Kruegel,
C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring,
E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich,
J. Wenninger, Institut f. Computersprachen - TU Wien
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
- Contact: cacao@cacaojvm.org
-
- Authors: Andreas Krall
-
- Changes: Christian Thalinger
- Edwin Steiner
-
- $Id: asmpart.S 7206 2007-01-11 22:39:52Z twisti $
-
*/
#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_vm_call_method_float
.globl asm_vm_call_method_double
.globl asm_vm_call_method_exception_handler
+ .globl asm_vm_call_method_end
.globl asm_call_jit_compiler
.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
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 */
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
.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 */
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
#if SIZEOF_VOID_P == 4
aaddiu sp,sp,4*4
#endif
+asm_vm_call_method_end:
b calljava_return2
.end asm_vm_call_method
.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,-((5+4+4+8+7)*4) /* create stack frame */
- /* +7 keeps the SP 16-bytes aligned */
-
- SAVE_RETURN_REGISTERS(5) /* save 2 int / 2 float return registers */
- SAVE_ARGUMENT_REGISTERS(9) /* save 4 int argument registers */
- SAVE_TEMPORARY_REGISTERS(13) /* save 8 int temporary registers */
-
- ast itmp1,(5+4+4+8+0)*4(sp) /* save itmp1 */
- ast itmp2,(5+4+4+8+1)*4(sp) /* save itmp2 */
- ast ra,(5+4+4+8+2)*4(sp) /* save method return address (for leafs) */
- ast pv,(5+4+4+8+3)*4(sp) /* save pv of calling java function */
-
- aaddiu a0,sp,(5+4+4+8+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(5) /* restore 2 int / 2 float return registers */
- RESTORE_ARGUMENT_REGISTERS(9) /* restore 4 int argument registers */
- RESTORE_TEMPORARY_REGISTERS(13) /* restore 9 int temporary registers */
-
- ald itmp1,(5+4+4+8+0)*4(sp) /* restore itmp1 */
- ald itmp2,(5+4+4+8+1)*4(sp) /* restore itmp2 */
- ald ra,(5+4+4+8+2)*4(sp) /* restore method return address (for leafs)*/
- ald pv,(5+4+4+8+3)*4(sp) /* restore pv of calling java function */
-
- bnez itmp3,L_asm_wrapper_patcher_exception
-
- ald itmp3,7*8+(5+4+4+8+7)*4(sp) /* load RA */
- aaddiu sp,sp,8*8+(5+4+4+8+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+(5+4+4+8+7)*4(sp) /* xpc is RA */
- aaddiu sp,sp,8*8+(5+4+4+8+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 *********************************************************
#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:
.end compare_and_swap
-/* Disable exec-stacks, required for Gentoo ***********************************/
+/* disable exec-stacks ********************************************************/
-#if defined(__GCC__) && defined(__ELF__)
- .section .note.GNU-stack,"",@progbits
+#if defined(__linux__) && defined(__ELF__)
+ .section .note.GNU-stack,"",%progbits
#endif