1/*
2 * ===========================================================================
3 *  Common subroutines and data
4 * ===========================================================================
5 */
6
7    .section .data.rel.ro
8    .align  2
9.LinvokeNative:
10    @ Prep for the native call
11    @ r1 = newFP, r0 = methodToCall
12    mov     r2, #0
13    ldr     r9, [rSELF, #offThread_jniLocal_topCookie]@r9<-thread->localRef->...
14    str     r2, [rSELF, #offThread_inJitCodeCache] @ not in jit code cache
15    str     r1, [rSELF, #offThread_curFrame]   @ curFrame = newFp
16    str     r9, [r1, #(offStackSaveArea_localRefCookie - sizeofStackSaveArea)]
17                                        @ newFp->localRefCookie=top
18    ldrh    lr, [rSELF, #offThread_subMode]
19    SAVEAREA_FROM_FP(r10, r1)           @ r10<- new stack save area
20
21    mov     r2, r0                      @ r2<- methodToCall
22    mov     r0, r1                      @ r0<- newFP
23    add     r1, rSELF, #offThread_retval  @ r1<- &retval
24    mov     r3, rSELF                   @ arg3<- self
25    ands    lr, #kSubModeMethodTrace
26    beq     121f                        @ hop if not profiling
27    @ r2: methodToCall, r6: rSELF
28    stmfd   sp!, {r2,r6}
29    stmfd   sp!, {r0-r3}
30    mov     r0, r2
31    mov     r1, r6
32    ldr     ip, .LdvmFastMethodTraceEnter
33    blx     ip
34    ldmfd   sp!, {r0-r3}
35
36    ldr     ip, [r2, #offMethod_nativeFunc]
37    blx     ip
38
39    ldmfd   sp!, {r0-r1}
40    ldr     ip, .LdvmFastNativeMethodTraceExit
41    blx     ip
42    b       212f
43121:
44    ldr     ip, [r2, #offMethod_nativeFunc]
45    blx     ip
46212:
47
48    @ native return; r10=newSaveArea
49    @ equivalent to dvmPopJniLocals
50    ldr     r2, [r10, #offStackSaveArea_returnAddr] @ r2 = chaining cell ret
51    ldr     r0, [r10, #offStackSaveArea_localRefCookie] @ r0<- saved->top
52    ldr     r1, [rSELF, #offThread_exception] @ check for exception
53    str     rFP, [rSELF, #offThread_curFrame]  @ curFrame = fp
54    cmp     r1, #0                      @ null?
55    str     r0, [rSELF, #offThread_jniLocal_topCookie] @ new top <- old top
56    ldr     r0, [r10, #offStackSaveArea_savedPc] @ reload rPC
57
58    @ r0 = dalvikCallsitePC
59    bne     .LhandleException           @ no, handle exception
60
61    str     r2, [rSELF, #offThread_inJitCodeCache] @ set the new mode
62    cmp     r2, #0                      @ return chaining cell still exists?
63    bxne    r2                          @ yes - go ahead
64
65    @ continue executing the next instruction through the interpreter
66    ldr     r1, .LdvmJitToInterpTraceSelectNoChain @ defined in footer.S
67    add     rPC, r0, #6                 @ reconstruct new rPC (advance 6 bytes)
68#if defined(WITH_JIT_TUNING)
69    mov     r0, #kCallsiteInterpreted
70#endif
71    bx      r1
72
73/*
74 * On entry:
75 * r0  Faulting Dalvik PC
76 */
77.LhandleException:
78#if defined(WITH_SELF_VERIFICATION)
79    ldr     pc, .LdeadFood @ should not see this under self-verification mode
80.LdeadFood:
81    .word   0xdeadf00d
82#endif
83    mov     r2, #0
84    str     r2, [rSELF, #offThread_inJitCodeCache] @ in interpreter land
85    ldr     r1, .LdvmMterpCommonExceptionThrown @ PIC way of getting &func
86    ldr     rIBASE, .LdvmAsmInstructionStart    @ same as above
87    mov     rPC, r0                 @ reload the faulting Dalvik address
88    bx      r1                  @ branch to dvmMterpCommonExceptionThrown
89
90    .align  2
91.LdvmAsmInstructionStart:
92    .word   dvmAsmInstructionStart
93.LdvmJitToInterpNoChainNoProfile:
94    .word   dvmJitToInterpNoChainNoProfile
95.LdvmJitToInterpTraceSelectNoChain:
96    .word   dvmJitToInterpTraceSelectNoChain
97.LdvmJitToInterpNoChain:
98    .word   dvmJitToInterpNoChain
99.LdvmMterpStdBail:
100    .word   dvmMterpStdBail
101.LdvmMterpCommonExceptionThrown:
102    .word   dvmMterpCommonExceptionThrown
103.LdvmLockObject:
104    .word   dvmLockObject
105.LdvmJitTraceProfilingOff:
106    .word   dvmJitTraceProfilingOff
107#if defined(WITH_JIT_TUNING)
108.LdvmICHitCount:
109    .word   gDvmICHitCount
110#endif
111#if defined(WITH_SELF_VERIFICATION)
112.LdvmSelfVerificationMemOpDecode:
113    .word   dvmSelfVerificationMemOpDecode
114#endif
115.LdvmFastMethodTraceEnter:
116    .word   dvmFastMethodTraceEnter
117.LdvmFastNativeMethodTraceExit:
118    .word   dvmFastNativeMethodTraceExit
119.LdvmFastMethodTraceExit:
120    .word   dvmFastMethodTraceExit
121.L__aeabi_cdcmple:
122    .word   __aeabi_cdcmple
123.L__aeabi_cfcmple:
124    .word   __aeabi_cfcmple
125
126    .global dvmCompilerTemplateEnd
127dvmCompilerTemplateEnd:
128
129#endif /* WITH_JIT */
130