.globl asm_vm_call_method_exception_handler
.globl asm_vm_call_method_end
- .globl asm_call_jit_compiler
-
.globl asm_handle_nat_exception
.globl asm_handle_exception
.globl asm_abstractmethoderror
- .globl asm_patcher_wrapper
-
-#if defined(ENABLE_REPLACEMENT)
- .globl asm_replacement_out
- .globl .asm_replacement_in
-#endif
-
.globl asm_cacheflush
.align 3
- .quad 0 /* catch type all */
- .quad 0 /* handler pc */
- .quad 0 /* end pc */
- .quad 0 /* start pc */
- .long 1 /* extable size */
- .long 0 /* ALIGNMENT PADDING */
- .quad 0 /* line number table start */
- .quad 0 /* line number table size */
- .long 0 /* ALIGNMENT PADDING */
.long 0 /* fltsave */
.long 0 /* intsave */
.long 0 /* isleaf */
- .long 0 /* IsSync */
.long 0 /* frame size */
.quad 0 /* codeinfo pointer */
SAVE_TEMPORARY_REGISTERS(15)
- mr s0, r1 /* save stack pointer */
+ mr s0, sp /* save stack pointer */
/* a1 contains a pointer to a unit64_t structure filled with all INT_ARG_REG,
followed by ADR_ARG_CNT and FLT_ARG_CNT, afterwards what else needs to be copied onto
RESTORE_TEMPORARY_REGISTERS(15)
- ld r0,40*8+LA_LR_OFFSET(r1)
+ ld r0,40*8+LA_LR_OFFSET(sp)
mtlr r0
- addi r1,r1,40*8
+ addi sp,sp,40*8
blr
asm_vm_call_method_exception_handler:
asm_vm_call_method_end:
nop
-/* asm_call_jit_compiler *******************************************************
-
- Invokes the compiler for untranslated JavaVM methods.
-
-*******************************************************************************/
-
-asm_call_jit_compiler:
-L_asm_call_jit_compiler: /* required for PIC code */
- mflr r0
- std r0,LA_LR_OFFSET(sp) /* save return address */
- stdu r1,-(LA_SIZE+PA_SIZE+ARG_CNT*8)(sp)
-
- SAVE_ARGUMENT_REGISTERS(LA_SIZE_IN_POINTERS+PA_SIZE_IN_POINTERS)
-
- mr a0,itmp1
- mr a1,mptr
- addi a2,sp,(LA_SIZE + PA_SIZE+ ARG_CNT*8)
- ld a3,(LA_SIZE + PA_SIZE + ARG_CNT*8)+LA_LR_OFFSET(sp)
- bl jit_asm_compile
- ori r0,r0,0 /* nop needed after jump to function desc. */
- mr pv,v0 /* move address to pv register */
-
- RESTORE_ARGUMENT_REGISTERS(LA_SIZE_IN_POINTERS+PA_SIZE_IN_POINTERS)
-
- ld itmp1,(LA_SIZE + PA_SIZE + ARG_CNT*8)+LA_LR_OFFSET(sp)
- mtlr itmp1
-
- addi sp,sp,(LA_SIZE + PA_SIZE + ARG_CNT*8)
-
- mr. pv,pv /* test for exception */
- beq L_asm_call_jit_compiler_exception
-
- mtctr pv /* move method address to control reg */
- bctr /* and call the Java method */
-
-L_asm_call_jit_compiler_exception:
- mflr r0
- std r0,LA_LR_OFFSET(sp)
- stdu sp,-LA_SIZE_ALIGNED(sp) /* preserve linkage area */
- bl exceptions_get_and_clear_exception
- ld xpc,LA_SIZE_ALIGNED+LA_LR_OFFSET(sp)
- mtlr xpc
- addi sp,sp,LA_SIZE_ALIGNED
-
- mr xptr,v0 /* get exception */
- addi xpc,xpc,-4 /* exception address is ra - 4 */
- b L_asm_handle_nat_exception
-
/********************* function asm_handle_exception ***************************
* *
std itmp3,LA_SIZE+PA_SIZE+(4+4)*8(sp) /* save maybe-leaf flag (cleared) */
mr a0,r0 /* pass return address */
- bl md_codegen_get_pv_from_pc /* get PV from RA */
+ bl md_asm_codegen_get_pv_from_pc /* get PV from RA */
std v0,LA_SIZE+PA_SIZE+(4+2)*8(sp) /* save data segment pointer */
ld a0,LA_SIZE+PA_SIZE+(4+0)*8(sp) /* pass xptr */
b L_asm_handle_nat_exception
-/* asm_patcher_wrapper *********************************************************
-
- XXX
-
- Stack layout:
- 40 return address into JIT code (patch position)
- 32 pointer to virtual java_objectheader
- 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 (pv is saved here afterwards)
-
-*******************************************************************************/
-
-asm_patcher_wrapper:
- mflr r0 /* get Java return address (leaf) */
- std r0,6*8(sp) /* store it in the stub stackframe */
- /* keep stack 16-bytes aligned: 6+1+37 = 44 */
- stdu sp,-(LA_SIZE+PA_SIZE+ARG_CNT*8+TMP_CNT*8+4*8)(sp)
-
- SAVE_ARGUMENT_REGISTERS(LA_SIZE_IN_POINTERS+PA_SIZE_IN_POINTERS) /* save 8 int/8 float arguments */
- SAVE_TEMPORARY_REGISTERS(LA_SIZE_IN_POINTERS+PA_SIZE_IN_POINTERS+ARG_CNT)
-
- std itmp1,LA_SIZE+PA_SIZE+(ARG_CNT+TMP_CNT)*8+1*8(sp)
- std itmp2,LA_SIZE+PA_SIZE+(ARG_CNT+TMP_CNT)*8+2*8(sp)
- std pv,LA_SIZE+PA_SIZE+(ARG_CNT+TMP_CNT)*8+3*8(sp)
-
- addi a0,sp,LA_SIZE+PA_SIZE+ARG_CNT*8+TMP_CNT*8+4*8 /* pass SP of patcher stub */
- mr a1,pv /* pass PV */
- mr a2,r0 /* pass RA (correct for leafs) */
- bl patcher_wrapper
- std v0,LA_SIZE+PA_SIZE+(ARG_CNT+TMP_CNT)*8+4*8(sp) /* save return value */
-
-
- RESTORE_ARGUMENT_REGISTERS(LA_SIZE_IN_POINTERS+PA_SIZE_IN_POINTERS) /* restore 8 int/8 float args */
- RESTORE_TEMPORARY_REGISTERS(LA_SIZE_IN_POINTERS+PA_SIZE_IN_POINTERS+ARG_CNT)
-
- ld itmp1,LA_SIZE+PA_SIZE+(ARG_CNT+TMP_CNT)*8+1*8(sp)
- ld itmp2,LA_SIZE+PA_SIZE+(ARG_CNT+TMP_CNT)*8+2*8(sp)
- ld pv,LA_SIZE+PA_SIZE+(ARG_CNT+TMP_CNT)*8+3*8(sp)
- ld itmp3,LA_SIZE+PA_SIZE+(ARG_CNT+TMP_CNT)*8+4*8(sp)
-
- ld r0,LA_SIZE+PA_SIZE+ARG_CNT*8+TMP_CNT*8+4*8+6*8(sp) /* restore RA */
- mtlr r0
-
- mr. itmp3,itmp3 /* check for an exception */
- bne L_asm_patcher_wrapper_exception
-
- /* get return address (into JIT code) */
- ld itmp3,LA_SIZE+PA_SIZE+ARG_CNT*8+TMP_CNT*8+4*8+5*8(sp)
-
- /* remove stack frame + patcher stub stack */
- addi sp,sp,LA_SIZE+PA_SIZE+ARG_CNT*8+TMP_CNT*8+4*8+8*8
-
- mtctr itmp3
- bctr /* jump to new patched code */
-
-L_asm_patcher_wrapper_exception:
- mr xptr,itmp3 /* get exception */
- ld xpc,LA_SIZE+PA_SIZE+ARG_CNT*8+TMP_CNT*8+4*8+5*8(sp)
- addi sp,sp,LA_SIZE+PA_SIZE+ARG_CNT*8+TMP_CNT*8+4*8+8*8
- b L_asm_handle_exception
-
-#if defined(ENABLE_REPLACEMENT)
-
-/* asm_replacement_out *********************************************************
-
- This code is jumped to from the replacement-out stubs that are executed
- when a thread reaches an activated replacement point.
-
- The purpose of asm_replacement_out is to read out the parts of the
- execution state that cannot be accessed from C code, store this state,
- and then call the C function replace_me.
-
- Stack layout:
- 16 start of stack inside method to replace
- 0 rplpoint * info on the replacement point that was reached
-
- NOTE: itmp3 has been clobbered by the replacement-out stub!
-
-*******************************************************************************/
-
-/* some room to accomodate changes of the stack frame size during replacement */
- /* XXX we should find a cleaner solution here */
-#define REPLACEMENT_ROOM 512
-
-asm_replacement_out:
- /* create stack frame */
- addi sp,sp,-(sizeexecutionstate + REPLACEMENT_ROOM) /* XXX align */
-
- /* save link register */
- mflr r16
-
- /* save registers in execution state */
- std r0 ,( 0*8+offes_intregs)(sp)
- std r1 ,( 1*8+offes_intregs)(sp)
- std r2 ,( 2*8+offes_intregs)(sp)
- std r3 ,( 3*8+offes_intregs)(sp)
- std r4 ,( 4*8+offes_intregs)(sp)
- std r5 ,( 5*8+offes_intregs)(sp)
- std r6 ,( 6*8+offes_intregs)(sp)
- std r7 ,( 7*8+offes_intregs)(sp)
- std r8 ,( 8*8+offes_intregs)(sp)
- std r9 ,( 9*8+offes_intregs)(sp)
- std r10,(10*8+offes_intregs)(sp)
- std r11,(11*8+offes_intregs)(sp)
- std r12,(12*8+offes_intregs)(sp)
- std r13,(13*8+offes_intregs)(sp)
- std r14,(14*8+offes_intregs)(sp)
- std r15,(15*8+offes_intregs)(sp)
- std r16,(16*8+offes_intregs)(sp) /* link register */
- std r17,(17*8+offes_intregs)(sp)
- std r18,(18*8+offes_intregs)(sp)
- std r19,(19*8+offes_intregs)(sp)
- std r20,(20*8+offes_intregs)(sp)
- std r21,(21*8+offes_intregs)(sp)
- std r22,(22*8+offes_intregs)(sp)
- std r23,(23*8+offes_intregs)(sp)
- std r24,(24*8+offes_intregs)(sp)
- std r25,(25*8+offes_intregs)(sp)
- std r26,(26*8+offes_intregs)(sp)
- std r27,(27*8+offes_intregs)(sp)
- std r28,(28*8+offes_intregs)(sp)
- std r29,(29*8+offes_intregs)(sp)
- std r30,(30*8+offes_intregs)(sp)
- std r31,(31*8+offes_intregs)(sp)
-
- stfd fr0 ,( 0*8+offes_fltregs)(sp)
- stfd fr1 ,( 1*8+offes_fltregs)(sp)
- stfd fr2 ,( 2*8+offes_fltregs)(sp)
- stfd fr3 ,( 3*8+offes_fltregs)(sp)
- stfd fr4 ,( 4*8+offes_fltregs)(sp)
- stfd fr5 ,( 5*8+offes_fltregs)(sp)
- stfd fr6 ,( 6*8+offes_fltregs)(sp)
- stfd fr7 ,( 7*8+offes_fltregs)(sp)
- stfd fr8 ,( 8*8+offes_fltregs)(sp)
- stfd fr9 ,( 9*8+offes_fltregs)(sp)
- stfd fr10,(10*8+offes_fltregs)(sp)
- stfd fr11,(11*8+offes_fltregs)(sp)
- stfd fr12,(12*8+offes_fltregs)(sp)
- stfd fr13,(13*8+offes_fltregs)(sp)
- stfd fr14,(14*8+offes_fltregs)(sp)
- stfd fr15,(15*8+offes_fltregs)(sp)
- stfd fr16,(16*8+offes_fltregs)(sp)
- stfd fr17,(17*8+offes_fltregs)(sp)
- stfd fr18,(18*8+offes_fltregs)(sp)
- stfd fr19,(19*8+offes_fltregs)(sp)
- stfd fr20,(20*8+offes_fltregs)(sp)
- stfd fr21,(21*8+offes_fltregs)(sp)
- stfd fr22,(22*8+offes_fltregs)(sp)
- stfd fr23,(23*8+offes_fltregs)(sp)
- stfd fr24,(24*8+offes_fltregs)(sp)
- stfd fr25,(25*8+offes_fltregs)(sp)
- stfd fr26,(26*8+offes_fltregs)(sp)
- stfd fr27,(27*8+offes_fltregs)(sp)
- stfd fr28,(28*8+offes_fltregs)(sp)
- stfd fr29,(29*8+offes_fltregs)(sp)
- stfd fr30,(30*8+offes_fltregs)(sp)
- stfd fr31,(31*8+offes_fltregs)(sp)
-
- /* calculate sp of method */
- addi itmp1,sp,(sizeexecutionstate + REPLACEMENT_ROOM + 4*4)
- stw itmp1,(offes_sp)(sp)
-
- /* store pv */
- stw pv,(offes_pv)(sp)
-
- /* call replace_me */
- lwz a0,-(4*4)(itmp1) /* arg0: rplpoint * */
- mr a1,sp /* arg1: execution state */
- addi sp,sp,-(LA_SIZE_ALIGNED)
- b replace_me /* call C function replace_me */
-
-/* asm_replacement_in **********************************************************
-
- This code writes the given execution state and jumps to the replacement
- code.
-
- This function never returns!
-
- NOTE: itmp3 is not restored!
-
- C prototype:
- void asm_replacement_in(executionstate *es);
-
-*******************************************************************************/
-
-.asm_replacement_in:
- /* a0 == executionstate *es */
-
- /* set new sp and pv */
- ld sp,(offes_sp)(a0)
- ld pv,(offes_pv)(a0)
-
- /* copy registers from execution state */
- ld r0 ,( 0*8+offes_intregs)(a0)
- /* r1 is sp */
- /* r2 is reserved */
- /* a0 is loaded below */
- ld r4 ,( 4*8+offes_intregs)(a0)
- ld r5 ,( 5*8+offes_intregs)(a0)
- ld r6 ,( 6*8+offes_intregs)(a0)
- ld r7 ,( 7*8+offes_intregs)(a0)
- ld r8 ,( 8*8+offes_intregs)(a0)
- ld r9 ,( 9*8+offes_intregs)(a0)
- ld r10,(10*8+offes_intregs)(a0)
- ld r11,(11*8+offes_intregs)(a0)
- ld r12,(12*8+offes_intregs)(a0)
- /* r13 is pv */
- ld r14,(14*8+offes_intregs)(a0)
- ld r15,(15*8+offes_intregs)(a0)
- ld r16,(16*8+offes_intregs)(a0) /* link register */
- ld r17,(17*8+offes_intregs)(a0)
- ld r18,(18*8+offes_intregs)(a0)
- ld r19,(19*8+offes_intregs)(a0)
- ld r20,(20*8+offes_intregs)(a0)
- ld r21,(21*8+offes_intregs)(a0)
- ld r22,(22*8+offes_intregs)(a0)
- ld r23,(23*8+offes_intregs)(a0)
- ld r24,(24*8+offes_intregs)(a0)
- ld r25,(25*8+offes_intregs)(a0)
- ld r26,(26*8+offes_intregs)(a0)
- ld r27,(27*8+offes_intregs)(a0)
- ld r28,(28*8+offes_intregs)(a0)
- ld r29,(29*8+offes_intregs)(a0)
- ld r30,(30*8+offes_intregs)(a0)
- ld r31,(31*8+offes_intregs)(a0)
-
- lfd fr0 ,( 0*8+offes_fltregs)(a0)
- lfd fr1 ,( 1*8+offes_fltregs)(a0)
- lfd fr2 ,( 2*8+offes_fltregs)(a0)
- lfd fr3 ,( 3*8+offes_fltregs)(a0)
- lfd fr4 ,( 4*8+offes_fltregs)(a0)
- lfd fr5 ,( 5*8+offes_fltregs)(a0)
- lfd fr6 ,( 6*8+offes_fltregs)(a0)
- lfd fr7 ,( 7*8+offes_fltregs)(a0)
- lfd fr8 ,( 8*8+offes_fltregs)(a0)
- lfd fr9 ,( 9*8+offes_fltregs)(a0)
- lfd fr10,(10*8+offes_fltregs)(a0)
- lfd fr11,(11*8+offes_fltregs)(a0)
- lfd fr12,(12*8+offes_fltregs)(a0)
- lfd fr13,(13*8+offes_fltregs)(a0)
- lfd fr14,(14*8+offes_fltregs)(a0)
- lfd fr15,(15*8+offes_fltregs)(a0)
- lfd fr16,(16*8+offes_fltregs)(a0)
- lfd fr17,(17*8+offes_fltregs)(a0)
- lfd fr18,(18*8+offes_fltregs)(a0)
- lfd fr19,(19*8+offes_fltregs)(a0)
- lfd fr20,(20*8+offes_fltregs)(a0)
- lfd fr21,(21*8+offes_fltregs)(a0)
- lfd fr22,(22*8+offes_fltregs)(a0)
- lfd fr23,(23*8+offes_fltregs)(a0)
- lfd fr24,(24*8+offes_fltregs)(a0)
- lfd fr25,(25*8+offes_fltregs)(a0)
- lfd fr26,(26*8+offes_fltregs)(a0)
- lfd fr27,(27*8+offes_fltregs)(a0)
- lfd fr28,(28*8+offes_fltregs)(a0)
- lfd fr29,(29*8+offes_fltregs)(a0)
- lfd fr30,(30*8+offes_fltregs)(a0)
- lfd fr31,(31*8+offes_fltregs)(a0)
-
- /* restore link register */
-
- mtlr r16
-
- /* load new pc */
-
- ld itmp3,offes_pc(a0)
-
- /* load a0 */
-
- ld a0,(3*8+offes_intregs)(a0)
-
- /* jump to new code */
-
- mtctr itmp3
- bctr
-
-#endif /* defined(ENABLE_REPLACEMENT) */
-
/* asm_cacheflush **************************************************************
- copied from linux/arch/ppc64/kernel/vdso64/cacheflush.S
assumes 128 byte cache line size.
All registers used may be trashed for fun and profit.
*******************************************************************************/