TEMPLATE_RETURN.S revision 5cc61d70ec727aa22f58463bf7940cc717cf3eb1
1    /*
2     * Unwind a frame from the Dalvik stack for compiled OP_RETURN_XXX.
3     * If the stored value in returnAddr
4     * is non-zero, the caller is compiled by the JIT thus return to the
5     * address in the code cache following the invoke instruction. Otherwise
6     * return to the special dvmJitToInterpNoChain entry point.
7     */
8#if defined(WITH_INLINE_PROFILING)
9    stmfd   sp!, {r0-r2,lr}             @ preserve live registers
10    mov     r0, r6
11    @ r0=rGlue
12    LDR_PC_LR ".LdvmFastJavaMethodTraceExit"
13    ldmfd   sp!, {r0-r2,lr}             @ restore live registers
14#endif
15    SAVEAREA_FROM_FP(r0, rFP)           @ r0<- saveArea (old)
16    ldr     r10, [r0, #offStackSaveArea_prevFrame] @ r10<- saveArea->prevFrame
17    ldr     r8, [rGLUE, #offGlue_pSelfSuspendCount] @ r8<- &suspendCount
18    ldr     rPC, [r0, #offStackSaveArea_savedPc] @ rPC<- saveArea->savedPc
19#if !defined(WITH_SELF_VERIFICATION)
20    ldr     r9,  [r0, #offStackSaveArea_returnAddr] @ r9<- chaining cell ret
21#else
22    mov     r9, #0                      @ disable chaining
23#endif
24    ldr     r2, [r10, #(offStackSaveArea_method - sizeofStackSaveArea)]
25                                        @ r2<- method we're returning to
26    ldr     r3, [rGLUE, #offGlue_self]  @ r3<- glue->self
27    cmp     r2, #0                      @ break frame?
28#if !defined(WITH_SELF_VERIFICATION)
29    beq     1f                          @ bail to interpreter
30#else
31    blxeq   lr                          @ punt to interpreter and compare state
32#endif
33    ldr     r1, .LdvmJitToInterpNoChainNoProfile @ defined in footer.S
34    mov     rFP, r10                    @ publish new FP
35    ldrne   r10, [r2, #offMethod_clazz] @ r10<- method->clazz
36    ldr     r8, [r8]                    @ r8<- suspendCount
37
38    str     r2, [rGLUE, #offGlue_method]@ glue->method = newSave->method
39    ldr     r0, [r10, #offClassObject_pDvmDex] @ r0<- method->clazz->pDvmDex
40    str     rFP, [r3, #offThread_curFrame] @ self->curFrame = fp
41    add     rPC, rPC, #6                @ publish new rPC (advance 6 bytes)
42    str     r0, [rGLUE, #offGlue_methodClassDex]
43    cmp     r8, #0                      @ check the suspendCount
44    movne   r9, #0                      @ clear the chaining cell address
45    str     r9, [r3, #offThread_inJitCodeCache] @ in code cache or not
46    cmp     r9, #0                      @ chaining cell exists?
47    blxne   r9                          @ jump to the chaining cell
48#if defined(WITH_JIT_TUNING)
49    mov     r0, #kCallsiteInterpreted
50#endif
51    mov     pc, r1                      @ callsite is interpreted
521:
53    stmia   rGLUE, {rPC, rFP}           @ SAVE_PC_FP_TO_GLUE()
54    ldr     r2, .LdvmMterpStdBail       @ defined in footer.S
55    mov     r1, #0                      @ changeInterp = false
56    mov     r0, rGLUE                   @ Expecting rGLUE in r0
57    blx     r2                          @ exit the interpreter
58