TEMPLATE_RETURN.S revision 18fba346582c08d81aa96d9508c0e935bad5f36f
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(TEMPLATE_INLINE_PROFILING)
9    stmfd   sp!, {r0-r2,lr}             @ preserve live registers
10    mov     r0, r6
11    @ r0=rGlue
12    mov     lr, pc
13    ldr     pc, .LdvmFastJavaMethodTraceExit
14    ldmfd   sp!, {r0-r2,lr}             @ restore live registers
15#endif
16    SAVEAREA_FROM_FP(r0, rFP)           @ r0<- saveArea (old)
17    ldr     r10, [r0, #offStackSaveArea_prevFrame] @ r10<- saveArea->prevFrame
18    ldr     r8, [rGLUE, #offGlue_pSelfSuspendCount] @ r8<- &suspendCount
19    ldr     rPC, [r0, #offStackSaveArea_savedPc] @ rPC<- saveArea->savedPc
20#if !defined(WITH_SELF_VERIFICATION)
21    ldr     r9,  [r0, #offStackSaveArea_returnAddr] @ r9<- chaining cell ret
22#else
23    mov     r9, #0                      @ disable chaining
24#endif
25    ldr     r2, [r10, #(offStackSaveArea_method - sizeofStackSaveArea)]
26                                        @ r2<- method we're returning to
27    ldr     r3, [rGLUE, #offGlue_self]  @ r3<- glue->self
28    cmp     r2, #0                      @ break frame?
29#if !defined(WITH_SELF_VERIFICATION)
30    beq     1f                          @ bail to interpreter
31#else
32    blxeq   lr                          @ punt to interpreter and compare state
33#endif
34    ldr     r1, .LdvmJitToInterpNoChainNoProfile @ defined in footer.S
35    mov     rFP, r10                    @ publish new FP
36    ldr     r10, [r2, #offMethod_clazz] @ r10<- method->clazz
37    ldr     r8, [r8]                    @ r8<- suspendCount
38
39    str     r2, [rGLUE, #offGlue_method]@ glue->method = newSave->method
40    ldr     r0, [r10, #offClassObject_pDvmDex] @ r0<- method->clazz->pDvmDex
41    str     rFP, [r3, #offThread_curFrame] @ self->curFrame = fp
42    add     rPC, rPC, #6                @ publish new rPC (advance 6 bytes)
43    str     r0, [rGLUE, #offGlue_methodClassDex]
44    cmp     r8, #0                      @ check the suspendCount
45    movne   r9, #0                      @ clear the chaining cell address
46    str     r9, [r3, #offThread_inJitCodeCache] @ in code cache or not
47    cmp     r9, #0                      @ chaining cell exists?
48    blxne   r9                          @ jump to the chaining cell
49#if defined(WITH_JIT_TUNING)
50    mov     r0, #kCallsiteInterpreted
51#endif
52    mov     pc, r1                      @ callsite is interpreted
531:
54    stmia   rGLUE, {rPC, rFP}           @ SAVE_PC_FP_TO_GLUE()
55    ldr     r2, .LdvmMterpStdBail       @ defined in footer.S
56    mov     r1, #0                      @ changeInterp = false
57    mov     r0, rGLUE                   @ Expecting rGLUE in r0
58    blx     r2                          @ exit the interpreter
59