blob: 3965ecde62a7462c1e3fa9dd3ac8495676e8e52f [file] [log] [blame]
Bill Buzbee7c58bd42016-01-20 20:46:01 +00001/*
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 */
Bill Buzbee7c58bd42016-01-20 20:46:01 +000015common_errDivideByZero:
16 EXPORT_PC
17#if MTERP_LOGGING
18 movl rSELF, %eax
19 movl %eax, OUT_ARG0(%esp)
20 lea OFF_FP_SHADOWFRAME(rFP), %ecx
21 movl %ecx, OUT_ARG1(%esp)
Serguei Katkov05dfaaa2016-01-28 08:21:26 +060022 call SYMBOL(MterpLogDivideByZeroException)
Bill Buzbee7c58bd42016-01-20 20:46:01 +000023#endif
24 jmp MterpCommonFallback
25
26common_errArrayIndex:
27 EXPORT_PC
28#if MTERP_LOGGING
29 movl rSELF, %eax
30 movl %eax, OUT_ARG0(%esp)
31 lea OFF_FP_SHADOWFRAME(rFP), %ecx
32 movl %ecx, OUT_ARG1(%esp)
Serguei Katkov05dfaaa2016-01-28 08:21:26 +060033 call SYMBOL(MterpLogArrayIndexException)
Bill Buzbee7c58bd42016-01-20 20:46:01 +000034#endif
35 jmp MterpCommonFallback
36
37common_errNegativeArraySize:
38 EXPORT_PC
39#if MTERP_LOGGING
40 movl rSELF, %eax
41 movl %eax, OUT_ARG0(%esp)
42 lea OFF_FP_SHADOWFRAME(rFP), %ecx
43 movl %ecx, OUT_ARG1(%esp)
Serguei Katkov05dfaaa2016-01-28 08:21:26 +060044 call SYMBOL(MterpLogNegativeArraySizeException)
Bill Buzbee7c58bd42016-01-20 20:46:01 +000045#endif
46 jmp MterpCommonFallback
47
48common_errNoSuchMethod:
49 EXPORT_PC
50#if MTERP_LOGGING
51 movl rSELF, %eax
52 movl %eax, OUT_ARG0(%esp)
53 lea OFF_FP_SHADOWFRAME(rFP), %ecx
54 movl %ecx, OUT_ARG1(%esp)
Serguei Katkov05dfaaa2016-01-28 08:21:26 +060055 call SYMBOL(MterpLogNoSuchMethodException)
Bill Buzbee7c58bd42016-01-20 20:46:01 +000056#endif
57 jmp MterpCommonFallback
58
59common_errNullObject:
60 EXPORT_PC
61#if MTERP_LOGGING
62 movl rSELF, %eax
63 movl %eax, OUT_ARG0(%esp)
64 lea OFF_FP_SHADOWFRAME(rFP), %ecx
65 movl %ecx, OUT_ARG1(%esp)
Serguei Katkov05dfaaa2016-01-28 08:21:26 +060066 call SYMBOL(MterpLogNullObjectException)
Bill Buzbee7c58bd42016-01-20 20:46:01 +000067#endif
68 jmp MterpCommonFallback
69
70common_exceptionThrown:
71 EXPORT_PC
72#if MTERP_LOGGING
73 movl rSELF, %eax
74 movl %eax, OUT_ARG0(%esp)
75 lea OFF_FP_SHADOWFRAME(rFP), %ecx
76 movl %ecx, OUT_ARG0(%esp)
Serguei Katkov05dfaaa2016-01-28 08:21:26 +060077 call SYMBOL(MterpLogExceptionThrownException)
Bill Buzbee7c58bd42016-01-20 20:46:01 +000078#endif
79 jmp MterpCommonFallback
80
81MterpSuspendFallback:
82 EXPORT_PC
83#if MTERP_LOGGING
84 movl rSELF, %eax
85 movl %eax, OUT_ARG0(%esp)
86 lea OFF_FP_SHADOWFRAME(rFP), %ecx
87 movl %ecx, OUT_ARG0(%esp)
88 movl THREAD_FLAGS_OFFSET(%eax), %eax
89 movl %eax, OUT_ARG2(%esp)
Serguei Katkov05dfaaa2016-01-28 08:21:26 +060090 call SYMBOL(MterpLogSuspendFallback)
Bill Buzbee7c58bd42016-01-20 20:46:01 +000091#endif
92 jmp MterpCommonFallback
93
94/*
95 * If we're here, something is out of the ordinary. If there is a pending
96 * exception, handle it. Otherwise, roll back and retry with the reference
97 * interpreter.
98 */
99MterpPossibleException:
100 movl rSELF, %eax
101 testl $$-1, THREAD_EXCEPTION_OFFSET(%eax)
102 jz MterpFallback
103 /* intentional fallthrough - handle pending exception. */
104
105/*
106 * On return from a runtime helper routine, we've found a pending exception.
107 * Can we handle it here - or need to bail out to caller?
108 *
109 */
110MterpException:
111 movl rSELF, %eax
112 movl %eax, OUT_ARG0(%esp)
113 lea OFF_FP_SHADOWFRAME(rFP), %ecx
114 movl %ecx, OUT_ARG1(%esp)
Serguei Katkov05dfaaa2016-01-28 08:21:26 +0600115 call SYMBOL(MterpHandleException)
Serguei Katkovff8579e2016-02-17 11:30:23 +0600116 testb %al, %al
Bill Buzbee7c58bd42016-01-20 20:46:01 +0000117 jz MterpExceptionReturn
Bill Buzbee7c58bd42016-01-20 20:46:01 +0000118 movl OFF_FP_CODE_ITEM(rFP), %eax
119 movl OFF_FP_DEX_PC(rFP), %ecx
120 lea CODEITEM_INSNS_OFFSET(%eax), rPC
121 lea (rPC, %ecx, 2), rPC
122 movl rPC, OFF_FP_DEX_PC_PTR(rFP)
Bill Buzbee481352d2016-02-25 17:37:46 +0000123 /* Do we need to switch interpreters? */
124 call SYMBOL(MterpShouldSwitchInterpreters)
125 testb %al, %al
126 jnz MterpFallback
Bill Buzbee7c58bd42016-01-20 20:46:01 +0000127 /* resume execution at catch block */
Bill Buzbee481352d2016-02-25 17:37:46 +0000128 REFRESH_IBASE
Bill Buzbee7c58bd42016-01-20 20:46:01 +0000129 FETCH_INST
130 GOTO_NEXT
131 /* NOTE: no fallthrough */
132
133/*
134 * Check for suspend check request. Assumes rINST already loaded, rPC advanced and
135 * still needs to get the opcode and branch to it, and flags are in lr.
136 */
137MterpCheckSuspendAndContinue:
138 movl rSELF, %eax
139 EXPORT_PC
140 testl $$(THREAD_SUSPEND_REQUEST | THREAD_CHECKPOINT_REQUEST), THREAD_FLAGS_OFFSET(%eax)
141 jz 1f
142 movl %eax, OUT_ARG0(%esp)
Serguei Katkov05dfaaa2016-01-28 08:21:26 +0600143 call SYMBOL(MterpSuspendCheck)
Bill Buzbee7c58bd42016-01-20 20:46:01 +0000144 REFRESH_IBASE
1451:
146 GOTO_NEXT
147
148/*
buzbee2de973d2016-02-23 13:25:00 -0800149 * On-stack replacement has happened, and now we've returned from the compiled method.
150 */
151MterpOnStackReplacement:
152#if MTERP_LOGGING
153 movl rSELF, %eax
154 movl %eax, OUT_ARG0(%esp)
155 lea OFF_FP_SHADOWFRAME(rFP), %ecx
156 movl %ecx, OUT_ARG1(%esp)
157 movl rINST, OUT_ARG2(%esp)
158 call SYMBOL(MterpLogOSR)
159#endif
160 movl $$1, %eax
161 jmp MterpDone
162
163/*
Bill Buzbee7c58bd42016-01-20 20:46:01 +0000164 * Bail out to reference interpreter.
165 */
166MterpFallback:
167 EXPORT_PC
168#if MTERP_LOGGING
169 movl rSELF, %eax
170 movl %eax, OUT_ARG0(%esp)
171 lea OFF_FP_SHADOWFRAME(rFP), %ecx
172 movl %ecx, OUT_ARG1(%esp)
Serguei Katkov05dfaaa2016-01-28 08:21:26 +0600173 call SYMBOL(MterpLogFallback)
Bill Buzbee7c58bd42016-01-20 20:46:01 +0000174#endif
175MterpCommonFallback:
176 xor %eax, %eax
177 jmp MterpDone
178
179/*
180 * On entry:
181 * uint32_t* rFP (should still be live, pointer to base of vregs)
182 */
183MterpExceptionReturn:
184 movl $$1, %eax
185 jmp MterpDone
186MterpReturn:
187 movl OFF_FP_RESULT_REGISTER(rFP), %edx
188 movl %eax, (%edx)
189 movl %ecx, 4(%edx)
Bill Buzbee7c58bd42016-01-20 20:46:01 +0000190 mov $$1, %eax
191MterpDone:
Bill Buzbee7c58bd42016-01-20 20:46:01 +0000192 /* pop up frame */
193 addl $$FRAME_SIZE, %esp
194 .cfi_adjust_cfa_offset -FRAME_SIZE
Bill Buzbee7c58bd42016-01-20 20:46:01 +0000195
Serguei Katkov897338d2016-03-01 15:53:22 +0600196 /* Restore callee save register */
197 POP %ebx
198 POP %esi
199 POP %edi
200 POP %ebp
201 ret
Bill Buzbee7c58bd42016-01-20 20:46:01 +0000202 .cfi_endproc
Serguei Katkov05dfaaa2016-01-28 08:21:26 +0600203 SIZE(ExecuteMterpImpl,ExecuteMterpImpl)