TEMPLATE_INVOKE_METHOD_NATIVE.S revision d88756df5b4dbc6fd450afd0019a5f64ebe4432d
1    @ r0 = methodToCall, r1 = returnCell, rPC = dalvikCallsite
2    @ r7 = methodToCall->registersSize
3    ldr     r9, [rGLUE, #offGlue_interpStackEnd]    @ r9<- interpStackEnd
4    ldr     r8, [rGLUE, #offGlue_pSelfSuspendCount] @ r8<- &suspendCount
5    add     r3, r1, #1  @ Thumb addr is odd
6    SAVEAREA_FROM_FP(r1, rFP)           @ r1<- stack save area
7    sub     r1, r1, r7, lsl #2          @ r1<- newFp (old savearea - regsSize)
8    SAVEAREA_FROM_FP(r10, r1)           @ r10<- stack save area
9    ldr     r8, [r8]                    @ r3<- suspendCount (int)
10    cmp     r10, r9                     @ bottom < interpStackEnd?
11    bxlo    lr                          @ return to raise stack overflow excep.
12    @ r1 = newFP, r0 = methodToCall, r3 = returnCell, rPC = dalvikCallsite
13    str     rPC, [rFP, #(offStackSaveArea_currentPc - sizeofStackSaveArea)]
14    str     rPC, [r1, #(offStackSaveArea_savedPc - sizeofStackSaveArea)]
15
16    @ set up newSaveArea
17    str     rFP, [r1, #(offStackSaveArea_prevFrame - sizeofStackSaveArea)]
18    str     r3, [r1, #(offStackSaveArea_returnAddr - sizeofStackSaveArea)]
19    ldr     r3, [rGLUE, #offGlue_self]      @ r3<- glue->self
20    str     r0, [r1, #(offStackSaveArea_method - sizeofStackSaveArea)]
21    cmp     r8, #0                      @ suspendCount != 0
22    ldr     r8, [r0, #offMethod_nativeFunc] @ r8<- method->nativeFunc
23#if !defined(WITH_SELF_VERIFICATION)
24    bxne    lr                          @ bail to the interpreter
25#else
26    bx      lr                          @ bail to interpreter unconditionally
27#endif
28
29    @ go ahead and transfer control to the native code
30    ldr     r9, [r3, #offThread_jniLocal_topCookie] @ r9<- thread->localRef->...
31    mov     r2, #0
32    str     r1, [r3, #offThread_curFrame]   @ self->curFrame = newFp
33    str     r2, [r3, #offThread_inJitCodeCache] @ not in the jit code cache
34    str     r9, [r1, #(offStackSaveArea_localRefCookie - sizeofStackSaveArea)]
35                                        @ newFp->localRefCookie=top
36    mov     r9, r3                      @ r9<- glue->self (preserve)
37    SAVEAREA_FROM_FP(r10, r1)           @ r10<- new stack save area
38
39    mov     r2, r0                      @ r2<- methodToCall
40    mov     r0, r1                      @ r0<- newFP
41    add     r1, rGLUE, #offGlue_retval  @ r1<- &retval
42#if defined(WITH_INLINE_PROFILING)
43    @ r2=methodToCall, r6=rGLUE
44    stmfd   sp!, {r2,r6}                @ to be consumed after JNI return
45    stmfd   sp!, {r0-r3}                @ preserve r0-r3
46    mov     r0, r2
47    mov     r1, r6
48    @ r0=JNIMethod, r1=rGlue
49    mov     lr, pc
50    ldr     pc, .LdvmFastMethodTraceEnter
51    ldmfd   sp!, {r0-r3}                @ restore r0-r3
52#endif
53
54    blx     r8                          @ off to the native code
55
56#if defined(WITH_INLINE_PROFILING)
57    ldmfd   sp!, {r0-r1}                @ restore r2 and r6
58    @ r0=JNIMethod, r1=rGlue
59    mov     lr, pc
60    ldr     pc, .LdvmFastNativeMethodTraceExit
61#endif
62    @ native return; r9=self, r10=newSaveArea
63    @ equivalent to dvmPopJniLocals
64    ldr     r2, [r10, #offStackSaveArea_returnAddr] @ r2 = chaining cell ret
65    ldr     r0, [r10, #offStackSaveArea_localRefCookie] @ r0<- saved->top
66    ldr     r1, [r9, #offThread_exception] @ check for exception
67    str     rFP, [r9, #offThread_curFrame]  @ self->curFrame = fp
68    cmp     r1, #0                      @ null?
69    str     r0, [r9, #offThread_jniLocal_topCookie] @ new top <- old top
70    ldr     r0, [rFP, #(offStackSaveArea_currentPc - sizeofStackSaveArea)]
71
72    @ r0 = dalvikCallsitePC
73    bne     .LhandleException           @ no, handle exception
74
75    str     r2, [r9, #offThread_inJitCodeCache] @ set the mode properly
76    cmp     r2, #0                      @ return chaining cell still exists?
77    bxne    r2                          @ yes - go ahead
78
79    @ continue executing the next instruction through the interpreter
80    ldr     r1, .LdvmJitToInterpTraceSelectNoChain @ defined in footer.S
81    add     rPC, r0, #6                 @ reconstruct new rPC (advance 6 bytes)
82#if defined(WITH_JIT_TUNING)
83    mov     r0, #kCallsiteInterpreted
84#endif
85    mov     pc, r1
86