TEMPLATE_RETURN.S revision 9f601a917c8878204482c37aec7005054b6776fa
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=rSELF
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, [rSELF, #offThread_suspendCount] @ 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    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    ldr     r10, [r2, #offMethod_clazz] @ r10<- method->clazz
36
37    str     r2, [rSELF, #offThread_method]@ self->method = newSave->method
38    ldr     r0, [r10, #offClassObject_pDvmDex] @ r0<- method->clazz->pDvmDex
39    str     rFP, [rSELF, #offThread_curFrame] @ self->curFrame = fp
40    add     rPC, rPC, #6                @ publish new rPC (advance 6 bytes)
41    str     r0, [rSELF, #offThread_methodClassDex]
42    cmp     r8, #0                      @ check the suspendCount
43    movne   r9, #0                      @ clear the chaining cell address
44    str     r9, [rSELF, #offThread_inJitCodeCache] @ in code cache or not
45    cmp     r9, #0                      @ chaining cell exists?
46    blxne   r9                          @ jump to the chaining cell
47#if defined(WITH_JIT_TUNING)
48    mov     r0, #kCallsiteInterpreted
49#endif
50    mov     pc, r1                      @ callsite is interpreted
511:
52    stmia   rSELF, {rPC, rFP}           @ SAVE_PC_FP_TO_SELF()
53    ldr     r2, .LdvmMterpStdBail       @ defined in footer.S
54    mov     r1, #0                      @ changeInterp = false
55    mov     r0, rSELF                   @ Expecting rSELF in r0
56    blx     r2                          @ exit the interpreter
57