blob: 8f79b37681c7d6d9e31d0349b80fb138dd53e157 [file] [log] [blame]
Serguei Katkov99229c72015-12-31 13:05:31 +06001/*
2 * ===========================================================================
3 * Common subroutines and data
4 * ===========================================================================
5 */
6
7 .text
8 .align 2
9
10/*
11 * We've detected a condition that will result in an exception, but the exception
12 * has not yet been thrown. Just bail out to the reference interpreter to deal with it.
13 * TUNING: for consistency, we may want to just go ahead and handle these here.
14 */
15#define MTERP_LOGGING 0
16common_errDivideByZero:
17 EXPORT_PC
18#if MTERP_LOGGING
19 movl rSELF, %eax
20 movl %eax, OUT_ARG0(%esp)
21 lea OFF_FP_SHADOWFRAME(rFP), %ecx
22 movl %ecx, OUT_ARG1(%esp)
23 call MterpLogDivideByZeroException
24#endif
25 jmp MterpCommonFallback
26
27common_errArrayIndex:
28 EXPORT_PC
29#if MTERP_LOGGING
30 movl rSELF, %eax
31 movl %eax, OUT_ARG0(%esp)
32 lea OFF_FP_SHADOWFRAME(rFP), %ecx
33 movl %ecx, OUT_ARG1(%esp)
34 call MterpLogArrayIndexException
35#endif
36 jmp MterpCommonFallback
37
38common_errNegativeArraySize:
39 EXPORT_PC
40#if MTERP_LOGGING
41 movl rSELF, %eax
42 movl %eax, OUT_ARG0(%esp)
43 lea OFF_FP_SHADOWFRAME(rFP), %ecx
44 movl %ecx, OUT_ARG1(%esp)
45 call MterpLogNegativeArraySizeException
46#endif
47 jmp MterpCommonFallback
48
49common_errNoSuchMethod:
50 EXPORT_PC
51#if MTERP_LOGGING
52 movl rSELF, %eax
53 movl %eax, OUT_ARG0(%esp)
54 lea OFF_FP_SHADOWFRAME(rFP), %ecx
55 movl %ecx, OUT_ARG1(%esp)
56 call MterpLogNoSuchMethodException
57#endif
58 jmp MterpCommonFallback
59
60common_errNullObject:
61 EXPORT_PC
62#if MTERP_LOGGING
63 movl rSELF, %eax
64 movl %eax, OUT_ARG0(%esp)
65 lea OFF_FP_SHADOWFRAME(rFP), %ecx
66 movl %ecx, OUT_ARG1(%esp)
67 call MterpLogNullObjectException
68#endif
69 jmp MterpCommonFallback
70
71common_exceptionThrown:
72 EXPORT_PC
73#if MTERP_LOGGING
74 movl rSELF, %eax
75 movl %eax, OUT_ARG0(%esp)
76 lea OFF_FP_SHADOWFRAME(rFP), %ecx
77 movl %ecx, OUT_ARG0(%esp)
78 call MterpLogExceptionThrownException
79#endif
80 jmp MterpCommonFallback
81
82MterpSuspendFallback:
83 EXPORT_PC
84#if MTERP_LOGGING
85 movl rSELF, %eax
86 movl %eax, OUT_ARG0(%esp)
87 lea OFF_FP_SHADOWFRAME(rFP), %ecx
88 movl %ecx, OUT_ARG0(%esp)
89 movl THREAD_FLAGS_OFFSET(%eax), %eax
90 movl %eax, OUT_ARG2(%esp)
91 call MterpLogSuspendFallback
92#endif
93 jmp MterpCommonFallback
94
95/*
96 * If we're here, something is out of the ordinary. If there is a pending
97 * exception, handle it. Otherwise, roll back and retry with the reference
98 * interpreter.
99 */
100MterpPossibleException:
101 movl rSELF, %eax
102 testl $$-1, THREAD_EXCEPTION_OFFSET(%eax)
103 jz MterpFallback
104 /* intentional fallthrough - handle pending exception. */
105
106/*
107 * On return from a runtime helper routine, we've found a pending exception.
108 * Can we handle it here - or need to bail out to caller?
109 *
110 */
111MterpException:
112 movl rSELF, %eax
113 movl %eax, OUT_ARG0(%esp)
114 lea OFF_FP_SHADOWFRAME(rFP), %ecx
115 movl %ecx, OUT_ARG1(%esp)
116 call MterpHandleException
117 testl %eax, %eax
118 jz MterpExceptionReturn
119 REFRESH_IBASE
120 movl OFF_FP_CODE_ITEM(rFP), %eax
121 movl OFF_FP_DEX_PC(rFP), %ecx
122 lea CODEITEM_INSNS_OFFSET(%eax), rPC
123 lea (rPC, %ecx, 2), rPC
124 movl rPC, OFF_FP_DEX_PC_PTR(rFP)
125 /* resume execution at catch block */
126 FETCH_INST
127 GOTO_NEXT
128 /* NOTE: no fallthrough */
129
130/*
131 * Check for suspend check request. Assumes rINST already loaded, rPC advanced and
132 * still needs to get the opcode and branch to it, and flags are in lr.
133 */
134MterpCheckSuspendAndContinue:
135 movl rSELF, %eax
136 EXPORT_PC
137 testl $$(THREAD_SUSPEND_REQUEST | THREAD_CHECKPOINT_REQUEST), THREAD_FLAGS_OFFSET(%eax)
138 jz 1f
139 movl %eax, OUT_ARG0(%esp)
140 call MterpSuspendCheck
141 REFRESH_IBASE
1421:
143 GOTO_NEXT
144
145/*
146 * Bail out to reference interpreter.
147 */
148MterpFallback:
149 EXPORT_PC
150#if MTERP_LOGGING
151 movl rSELF, %eax
152 movl %eax, OUT_ARG0(%esp)
153 lea OFF_FP_SHADOWFRAME(rFP), %ecx
154 movl %ecx, OUT_ARG1(%esp)
155 call MterpLogFallback
156#endif
157MterpCommonFallback:
158 xor %eax, %eax
159 jmp MterpDone
160
161/*
162 * On entry:
163 * uint32_t* rFP (should still be live, pointer to base of vregs)
164 */
165MterpExceptionReturn:
166 movl $$1, %eax
167 jmp MterpDone
168MterpReturn:
169 movl OFF_FP_RESULT_REGISTER(rFP), %edx
170 movl %eax, (%edx)
171 movl %ecx, 4(%edx)
172 movl rSELF, %eax
173 testl $$(THREAD_SUSPEND_REQUEST | THREAD_CHECKPOINT_REQUEST), THREAD_FLAGS_OFFSET(%eax)
174 jz 1f
175 movl %eax, OUT_ARG0(%esp)
176 call MterpSuspendCheck
1771:
178 mov $$1, %eax
179MterpDone:
180 /* Restore callee save register */
181 movl EBP_SPILL(%esp), %ebp
182 movl EDI_SPILL(%esp), %edi
183 movl ESI_SPILL(%esp), %esi
184 movl EBX_SPILL(%esp), %ebx
185
186 /* pop up frame */
187 addl $$FRAME_SIZE, %esp
188 .cfi_adjust_cfa_offset -FRAME_SIZE
189 ret
190
191 .cfi_endproc
192 .size ExecuteMterpImpl, .-ExecuteMterpImpl