1/* 2 * =========================================================================== 3 * Common subroutines and data 4 * =========================================================================== 5 */ 6 7 .section .data.rel.ro 8 .align 4 9.LinvokeNative: 10 # Prep for the native call 11 # a1 = newFP, a0 = methodToCall 12 lw t9, offThread_jniLocal_topCookie(rSELF) # t9<- thread->localRef->... 13 sw zero, offThread_inJitCodeCache(rSELF) # not in jit code cache 14 sw a1, offThread_curFrame(rSELF) # self->curFrame = newFp 15 sw t9, (offStackSaveArea_localRefCookie - sizeofStackSaveArea)(a1) 16 # newFp->localRefCookie=top 17 lhu ra, offThread_subMode(rSELF) 18 SAVEAREA_FROM_FP(rBIX, a1) # rBIX<- new stack save area 19 20 move a2, a0 # a2<- methodToCall 21 move a0, a1 # a0<- newFp 22 add a1, rSELF, offThread_retval # a1<- &retval 23 move a3, rSELF # a3<- self 24 andi ra, kSubModeMethodTrace 25 beqz ra, 121f 26 # a2: methodToCall 27 # preserve a0-a3 28 SCRATCH_STORE(a0, 0) 29 SCRATCH_STORE(a1, 4) 30 SCRATCH_STORE(a2, 8) 31 SCRATCH_STORE(a3, 12) 32 33 move a0, a2 34 move a1, rSELF 35 la t9, dvmFastMethodTraceEnter 36 JALR(t9) 37 lw gp, STACK_OFFSET_GP(sp) 38 39 # restore a0-a3 40 SCRATCH_LOAD(a3, 12) 41 SCRATCH_LOAD(a2, 8) 42 SCRATCH_LOAD(a1, 4) 43 SCRATCH_LOAD(a0, 0) 44 45 lw t9, offMethod_nativeFunc(a2) 46 JALR(t9) # call methodToCall->nativeFunc 47 lw gp, STACK_OFFSET_GP(sp) 48 49 # restore a2 again 50 SCRATCH_LOAD(a2, 8) 51 52 move a0, a2 53 move a1, rSELF 54 la t9, dvmFastNativeMethodTraceExit 55 JALR(t9) 56 lw gp, STACK_OFFSET_GP(sp) 57 b 212f 58 59121: 60 lw t9, offMethod_nativeFunc(a2) 61 JALR(t9) # call methodToCall->nativeFunc 62 lw gp, STACK_OFFSET_GP(sp) 63 64212: 65 # native return; rBIX=newSaveArea 66 # equivalent to dvmPopJniLocals 67 lw a2, offStackSaveArea_returnAddr(rBIX) # a2 = chaining cell ret addr 68 lw a0, offStackSaveArea_localRefCookie(rBIX) # a0<- saved->top 69 lw a1, offThread_exception(rSELF) # check for exception 70 sw rFP, offThread_curFrame(rSELF) # self->curFrame = fp 71 sw a0, offThread_jniLocal_topCookie(rSELF) # new top <- old top 72 lw a0, offStackSaveArea_savedPc(rBIX) # reload rPC 73 74 # a0 = dalvikCallsitePC 75 bnez a1, .LhandleException # handle exception if any 76 77 sw a2, offThread_inJitCodeCache(rSELF) # set the mode properly 78 beqz a2, 3f 79 jr a2 # go if return chaining cell still exist 80 813: 82 # continue executing the next instruction through the interpreter 83 la a1, .LdvmJitToInterpTraceSelectNoChain # defined in footer.S 84 lw a1, (a1) 85 add rPC, a0, 3*2 # reconstruct new rPC 86 87#if defined(WITH_JIT_TUNING) 88 li a0, kCallsiteInterpreted 89#endif 90 jr a1 91 92 93/* 94 * On entry: 95 * a0 Faulting Dalvik PC 96 */ 97.LhandleException: 98#if defined(WITH_SELF_VERIFICATION) 99 la t0, .LdeadFood 100 lw t0, (t0) # should not see this under self-verification mode 101 jr t0 102.LdeadFood: 103 .word 0xdeadf00d 104#endif 105 sw zero, offThread_inJitCodeCache(rSELF) # in interpreter land 106 la a1, .LdvmMterpCommonExceptionThrown # PIC way of getting &func 107 lw a1, (a1) 108 la rIBASE, .LdvmAsmInstructionStart # PIC way of getting &func 109 lw rIBASE, (rIBASE) 110 move rPC, a0 # reload the faulting Dalvid address 111 jr a1 # branch to dvmMterpCommonExeceptionThrown 112 113 .align 4 114.LdvmAsmInstructionStart: 115 .word dvmAsmInstructionStart 116.LdvmJitToInterpNoChainNoProfile: 117 .word dvmJitToInterpNoChainNoProfile 118.LdvmJitToInterpTraceSelectNoChain: 119 .word dvmJitToInterpTraceSelectNoChain 120.LdvmJitToInterpNoChain: 121 .word dvmJitToInterpNoChain 122.LdvmMterpStdBail: 123 .word dvmMterpStdBail 124.LdvmMterpCommonExceptionThrown: 125 .word dvmMterpCommonExceptionThrown 126.LdvmLockObject: 127 .word dvmLockObject 128#if defined(WITH_JIT_TUNING) 129.LdvmICHitCount: 130 .word gDvmICHitCount 131#endif 132#if defined(WITH_SELF_VERIFICATION) 133.LdvmSelfVerificationMemOpDecode: 134 .word dvmSelfVerificationMemOpDecode 135#endif 136 137 .global dvmCompilerTemplateEnd 138dvmCompilerTemplateEnd: 139 140#endif /* WITH_JIT */ 141