blob: eb12854981406092598a19f86ea5667f4212f74f [file] [log] [blame]
Ian Rogers9651f422011-09-19 20:26:07 -07001#include "asm_support.h"
2
buzbee54330722011-08-23 16:46:55 -07003#if defined(__arm__)
4
5 .balign 4
buzbee4a3164f2011-09-03 11:25:10 -07006
Ian Rogersff1ed472011-09-20 13:46:24 -07007 /* Deliver the given exception */
8 .extern artDeliverExceptionFromCode
9 /* Deliver an exception pending on a thread */
10 .extern artDeliverPendingException
11
Ian Rogers15fdb8c2011-09-25 15:45:07 -070012 /* Macro that sets up the callee save frame to conform with Runtime::CreateCalleeSaveMethod */
13.macro SETUP_CALLEE_SAVE_FRAME
14 push {r1-r11, lr}
15 vpush {s0-s31}
16 sub sp, #16 @ 4 words of space, bottom word will hold Method*
17.endm
18
Ian Rogersff1ed472011-09-20 13:46:24 -070019 .global art_deliver_exception_from_code
Ian Rogersbdb03912011-09-14 00:55:44 -070020 /*
Ian Rogersff1ed472011-09-20 13:46:24 -070021 * Called by managed code, saves mosts registers (forms basis of long jump context) and passes
22 * the bottom of the stack. artDeliverExceptionFromCode will place the callee save Method* at
23 * the bottom of the thread. On entry r0 holds Throwable*
Ian Rogersbdb03912011-09-14 00:55:44 -070024 */
Ian Rogersff1ed472011-09-20 13:46:24 -070025art_deliver_exception_from_code:
Ian Rogers15fdb8c2011-09-25 15:45:07 -070026 SETUP_CALLEE_SAVE_FRAME
Ian Rogersff1ed472011-09-20 13:46:24 -070027 mov r1, r9 @ pass Thread::Current
28 mov r2, sp @ pass SP
29 b artDeliverExceptionFromCode @ artDeliverExceptionFromCode(Throwable*, Thread*, SP)
Ian Rogers9651f422011-09-19 20:26:07 -070030
31 .global art_throw_null_pointer_exception_from_code
Ian Rogersff1ed472011-09-20 13:46:24 -070032 .extern artThrowNullPointerExceptionFromCode
Ian Rogers9651f422011-09-19 20:26:07 -070033 /*
Ian Rogersff1ed472011-09-20 13:46:24 -070034 * Called by managed code to create and deliver a NullPointerException
Ian Rogers9651f422011-09-19 20:26:07 -070035 */
36art_throw_null_pointer_exception_from_code:
Ian Rogers15fdb8c2011-09-25 15:45:07 -070037 SETUP_CALLEE_SAVE_FRAME
Ian Rogersff1ed472011-09-20 13:46:24 -070038 mov r0, r9 @ pass Thread::Current
39 mov r1, sp @ pass SP
40 b artThrowNullPointerExceptionFromCode @ artThrowNullPointerExceptionFromCode(Thread*, SP)
Ian Rogers9651f422011-09-19 20:26:07 -070041
42 .global art_throw_div_zero_from_code
Ian Rogersff1ed472011-09-20 13:46:24 -070043 .extern artThrowDivZeroFromCode
Ian Rogers9651f422011-09-19 20:26:07 -070044 /*
Ian Rogersff1ed472011-09-20 13:46:24 -070045 * Called by managed code to create and deliver an ArithmeticException
Ian Rogers9651f422011-09-19 20:26:07 -070046 */
47art_throw_div_zero_from_code:
Ian Rogers15fdb8c2011-09-25 15:45:07 -070048 SETUP_CALLEE_SAVE_FRAME
Ian Rogersff1ed472011-09-20 13:46:24 -070049 mov r0, r9 @ pass Thread::Current
50 mov r1, sp @ pass SP
51 b artThrowDivZeroFromCode @ artThrowDivZeroFromCode(Thread*, SP)
Ian Rogers9651f422011-09-19 20:26:07 -070052
53 .global art_throw_array_bounds_from_code
Ian Rogersff1ed472011-09-20 13:46:24 -070054 .extern artThrowArrayBoundsFromCode
Ian Rogers9651f422011-09-19 20:26:07 -070055 /*
Ian Rogersff1ed472011-09-20 13:46:24 -070056 * Called by managed code to create and deliver an ArrayIndexOutOfBoundsException
Ian Rogers9651f422011-09-19 20:26:07 -070057 */
58art_throw_array_bounds_from_code:
Ian Rogers15fdb8c2011-09-25 15:45:07 -070059 SETUP_CALLEE_SAVE_FRAME
Ian Rogersff1ed472011-09-20 13:46:24 -070060 mov r2, r9 @ pass Thread::Current
61 mov r3, sp @ pass SP
62 b artThrowArrayBoundsFromCode @ artThrowArrayBoundsFromCode(index, limit, Thread*, SP)
Ian Rogersbdb03912011-09-14 00:55:44 -070063
Ian Rogers932746a2011-09-22 18:57:50 -070064 .global art_throw_stack_overflow_from_code
65 .extern artThrowStackOverflowFromCode
66art_throw_stack_overflow_from_code:
Ian Rogers15fdb8c2011-09-25 15:45:07 -070067 SETUP_CALLEE_SAVE_FRAME
Ian Rogers932746a2011-09-22 18:57:50 -070068 mov r1, r9 @ pass Thread::Current
69 mov r2, sp @ pass SP
70 b artThrowStackOverflowFromCode @ artThrowStackOverflowFromCode(method, Thread*, SP)
71
Ian Rogersc0c8dc82011-09-24 18:15:59 -070072 .global art_throw_neg_array_size_from_code
73 .extern artThrowNegArraySizeFromCode
74art_throw_neg_array_size_from_code:
Ian Rogers15fdb8c2011-09-25 15:45:07 -070075 SETUP_CALLEE_SAVE_FRAME
Ian Rogersc0c8dc82011-09-24 18:15:59 -070076 mov r1, r9 @ pass Thread::Current
77 mov r2, sp @ pass SP
78 b artThrowNegArraySizeFromCode @ artThrowNegArraySizeFromCode(size, Thread*, SP)
79
80 .global art_throw_internal_error_from_code
81 .extern artThrowInternalErrorFromCode
82art_throw_internal_error_from_code:
Ian Rogers15fdb8c2011-09-25 15:45:07 -070083 SETUP_CALLEE_SAVE_FRAME
Ian Rogersc0c8dc82011-09-24 18:15:59 -070084 mov r1, r9 @ pass Thread::Current
85 mov r2, sp @ pass SP
86 b artThrowInternalErrorFromCode @ artThrowInternalErrorFromCode(errnum, Thread*, SP)
87
88 .global art_throw_no_such_method_from_code
89 .extern artThrowNoSuchMethodFromCode
90art_throw_no_such_method_from_code:
Ian Rogers15fdb8c2011-09-25 15:45:07 -070091 SETUP_CALLEE_SAVE_FRAME
Ian Rogersc0c8dc82011-09-24 18:15:59 -070092 mov r1, r9 @ pass Thread::Current
93 mov r2, sp @ pass SP
94 b artThrowNoSuchMethodFromCode @ artThrowNoSuchMethodFromCode(method_idx, Thread*, SP)
95
96 .global art_throw_runtime_exception_from_code
97 .extern artThrowRuntimeExceptionFromCode
98art_throw_runtime_exception_from_code:
Ian Rogers15fdb8c2011-09-25 15:45:07 -070099 SETUP_CALLEE_SAVE_FRAME
Ian Rogersc0c8dc82011-09-24 18:15:59 -0700100 mov r1, r9 @ pass Thread::Current
101 mov r2, sp @ pass SP
102 b artThrowRuntimeExceptionFromCode @ artThrowRuntimeExceptionFromCode(errnum, Thread*, SP)
103
104 .global art_throw_verification_error_from_code
105 .extern artThrowVerificationErrorFromCode
106art_throw_verification_error_from_code:
Ian Rogers15fdb8c2011-09-25 15:45:07 -0700107 SETUP_CALLEE_SAVE_FRAME
Ian Rogersc0c8dc82011-09-24 18:15:59 -0700108 mov r2, r9 @ pass Thread::Current
109 mov r3, sp @ pass SP
Elliott Hughes6c8867d2011-10-03 16:34:05 -0700110 b artThrowVerificationErrorFromCode @ artThrowVerificationErrorFromCode(kind, ref, Thread*, SP)
Ian Rogersc0c8dc82011-09-24 18:15:59 -0700111
buzbee4a3164f2011-09-03 11:25:10 -0700112 .global art_invoke_interface_trampoline
Ian Rogersff1ed472011-09-20 13:46:24 -0700113 .extern artFindInterfaceMethodInCacheFromCode
buzbee4a3164f2011-09-03 11:25:10 -0700114 /*
Ian Rogersff1ed472011-09-20 13:46:24 -0700115 * All generated callsites for interface invokes will load arguments as usual - except instead
116 * of loading arg0/r0 with the target Method*, arg0/r0 will contain the method_idx. This
117 * wrapper will save arg1-arg3, load the caller's Method*, align the stack and call the helper
118 * artFindInterfaceMethodInCacheFromCode(idx, this, method);
119 * NOTE: "this" is first visable argument of the target, and so can be found in arg1/r1.
buzbee4a3164f2011-09-03 11:25:10 -0700120 *
Ian Rogersff1ed472011-09-20 13:46:24 -0700121 * artFindInterfaceMethodInCacheFromCode will attempt to locate the target and return a 64-bit
122 * result in r0/r1 consisting of the target Method* in r0 and method->code_ in r1.
buzbee4a3164f2011-09-03 11:25:10 -0700123 *
Ian Rogersff1ed472011-09-20 13:46:24 -0700124 * If unsuccessful, artFindInterfaceMethodInCacheFromCode will return NULL/NULL. There will be
125 * a pending exception in the thread and we branch to another stub to deliver it.
buzbee4a3164f2011-09-03 11:25:10 -0700126 *
Ian Rogersff1ed472011-09-20 13:46:24 -0700127 * On success this wrapper will restore arguments and *jump* to the target, leaving the lr
128 * pointing back to the original caller.
buzbee4a3164f2011-09-03 11:25:10 -0700129 */
Ian Rogersff1ed472011-09-20 13:46:24 -0700130art_invoke_interface_trampoline:
131 str sp, [R9, #THREAD_TOP_OF_MANAGED_STACK_OFFSET] @ record top of stack and pc in case of
132 str lr, [R9, #THREAD_TOP_OF_MANAGED_STACK_PC_OFFSET] @ walking stack
buzbee4a3164f2011-09-03 11:25:10 -0700133 stmdb sp!, {r1, r2, r3, lr}
Ian Rogersff1ed472011-09-20 13:46:24 -0700134 ldr r2, [sp, #16] @ load caller's Method*
135 bl artFindInterfaceMethodInCacheFromCode @ (method_idx, this, callerMethod)
136 mov r12, r1 @ save r0->code_
137 ldmia sp!, {r1, r2, r3, lr} @ restore arguments
138 cmp r0, #0 @ did we find the target?
139 bxne r12 @ tail call to target if so
140 @ set up for throwing exception
Ian Rogers15fdb8c2011-09-25 15:45:07 -0700141 SETUP_CALLEE_SAVE_FRAME
Ian Rogersff1ed472011-09-20 13:46:24 -0700142 mov r0, r9 @ pass Thread::Current
143 mov r1, sp @ pass SP
144 b artDeliverPendingExceptionFromCode @ artDeliverPendingExceptionFromCode(Thread*, SP)
145
146 .global art_handle_fill_data_from_code
147 .extern artHandleFillArrayDataFromCode
148 /*
149 * Entry from managed code that calls artHandleFillArrayDataFromCode and delivers exception on
150 * failure.
151 */
152art_handle_fill_data_from_code:
153 str sp, [R9, #THREAD_TOP_OF_MANAGED_STACK_OFFSET] @ record top of stack and pc in case of
154 str lr, [R9, #THREAD_TOP_OF_MANAGED_STACK_PC_OFFSET] @ walking stack
155 stmdb sp!, {lr} @ Save LR
156 sub sp, #12 @ Align stack
157 bl artHandleFillArrayDataFromCode @ (Array* array, const uint16_t* table)
158 add sp, #12
159 ldmia sp!, {lr} @ restore LR
160 cmp r0, #0 @ success?
161 moveq pc, lr @ return on success
162 @ set up for throwing exception
Ian Rogers15fdb8c2011-09-25 15:45:07 -0700163 SETUP_CALLEE_SAVE_FRAME
Ian Rogersff1ed472011-09-20 13:46:24 -0700164 mov r0, r9 @ pass Thread::Current
165 mov r1, sp @ pass SP
166 b artDeliverPendingExceptionFromCode @ artDeliverPendingExceptionFromCode(Thread*, SP)
167
168 .global art_unlock_object_from_code
169 .extern artUnlockObjectFromCode
170 /*
171 * Entry from managed code that calls artUnlockObjectFromCode and delivers exception on failure.
172 */
173art_unlock_object_from_code:
174 str sp, [R9, #THREAD_TOP_OF_MANAGED_STACK_OFFSET] @ record top of stack and pc in case of
175 str lr, [R9, #THREAD_TOP_OF_MANAGED_STACK_PC_OFFSET] @ walking stack
176 stmdb sp!, {lr} @ Save LR
177 sub sp, #12 @ Align stack
178 bl artUnlockObjectFromCode @ (Thread* thread, Object* obj)
179 add sp, #12
180 ldmia sp!, {lr} @ restore LR
181 cmp r0, #0 @ success?
182 moveq pc, lr @ return on success
183 @ set up for throwing exception
Ian Rogers15fdb8c2011-09-25 15:45:07 -0700184 SETUP_CALLEE_SAVE_FRAME
Ian Rogersff1ed472011-09-20 13:46:24 -0700185 mov r0, r9 @ pass Thread::Current
186 mov r1, sp @ pass SP
187 b artDeliverPendingExceptionFromCode @ artDeliverPendingExceptionFromCode(Thread*, SP)
188
189 .global art_check_cast_from_code
190 .extern artCheckCastFromCode
191 /*
192 * Entry from managed code that calls artCheckCastFromCode and delivers exception on failure.
193 */
194art_check_cast_from_code:
195 str sp, [R9, #THREAD_TOP_OF_MANAGED_STACK_OFFSET] @ record top of stack and pc in case of
196 str lr, [R9, #THREAD_TOP_OF_MANAGED_STACK_PC_OFFSET] @ walking stack
197 stmdb sp!, {lr} @ Save LR
198 sub sp, #12 @ Align stack
199 bl artCheckCastFromCode @ (Class* a, Class* b)
200 add sp, #12
201 ldmia sp!, {lr} @ restore LR
202 cmp r0, #0 @ success?
203 moveq pc, lr @ return on success
204 @ set up for throwing exception
Ian Rogers15fdb8c2011-09-25 15:45:07 -0700205 SETUP_CALLEE_SAVE_FRAME
Ian Rogersff1ed472011-09-20 13:46:24 -0700206 mov r0, r9 @ pass Thread::Current
207 mov r1, sp @ pass SP
208 b artDeliverPendingExceptionFromCode @ artDeliverPendingExceptionFromCode(Thread*, SP)
buzbee4a3164f2011-09-03 11:25:10 -0700209
Ian Rogerse51a5112011-09-23 14:16:35 -0700210 .global art_can_put_array_element_from_code
211 .extern artCanPutArrayElementFromCode
212 /*
213 * Entry from managed code that calls artCanPutArrayElementFromCode and delivers exception on
214 * failure.
215 */
216art_can_put_array_element_from_code:
217 cmp r0, #0 @ return if element == NULL
218 moveq pc, lr
219 str sp, [R9, #THREAD_TOP_OF_MANAGED_STACK_OFFSET] @ record top of stack and pc in case of
220 str lr, [R9, #THREAD_TOP_OF_MANAGED_STACK_PC_OFFSET] @ walking stack
221 stmdb sp!, {lr} @ Save LR
222 sub sp, #12 @ Align stack
223 bl artCanPutArrayElementFromCode @ (Object* element, Class* array_class)
224 add sp, #12
225 ldmia sp!, {lr} @ restore LR
226 cmp r0, #0 @ success?
227 moveq pc, lr @ return on success
228 @ set up for throwing exception
Ian Rogers15fdb8c2011-09-25 15:45:07 -0700229 SETUP_CALLEE_SAVE_FRAME
Ian Rogerse51a5112011-09-23 14:16:35 -0700230 mov r0, r9 @ pass Thread::Current
231 mov r1, sp @ pass SP
232 b artDeliverPendingExceptionFromCode @ artDeliverPendingExceptionFromCode(Thread*, SP)
233
Ian Rogerscbba6ac2011-09-22 16:28:37 -0700234 .global art_initialize_static_storage_from_code
235 .extern _ZN3art11ClassLinker31InitializeStaticStorageFromCodeEjPKNS_6MethodE
236 /*
237 * Entry from managed code when uninitialized static storage, this stub will run the class
238 * initializer and deliver the exception on error. On success the static storage base is
239 * returned.
240 */
241art_initialize_static_storage_from_code:
242 str sp, [R9, #THREAD_TOP_OF_MANAGED_STACK_OFFSET] @ record top of stack and pc in case of
243 str lr, [R9, #THREAD_TOP_OF_MANAGED_STACK_PC_OFFSET] @ walking stack
244 stmdb sp!, {lr} @ Save LR
245 sub sp, #12 @ Align stack
246 @ ClassLinker::InitializeStaticStorageFromCode(uint32_t type_idx, Method* referrer)
247 bl _ZN3art11ClassLinker31InitializeStaticStorageFromCodeEjPKNS_6MethodE
248 add sp, #12
249 ldmia sp!, {lr} @ restore LR
250 cmp r0, #0 @ success if result is non-null
251 movne pc, lr @ return on success
252 @ set up for throwing exception
Ian Rogers15fdb8c2011-09-25 15:45:07 -0700253 SETUP_CALLEE_SAVE_FRAME
Ian Rogerscbba6ac2011-09-22 16:28:37 -0700254 mov r0, r9 @ pass Thread::Current
255 mov r1, sp @ pass SP
256 b artDeliverPendingExceptionFromCode @ artDeliverPendingExceptionFromCode(Thread*, SP)
257
Ian Rogers21d9e832011-09-23 17:05:09 -0700258 .global art_alloc_object_from_code
259 .extern artAllocObjectFromCode
260 /*
261 * Called by managed code to allocate an object
262 */
263art_alloc_object_from_code:
264 str sp, [R9, #THREAD_TOP_OF_MANAGED_STACK_OFFSET] @ record top of stack and pc in case of
265 str lr, [R9, #THREAD_TOP_OF_MANAGED_STACK_PC_OFFSET] @ walking stack
266 stmdb sp!, {lr} @ Save LR
267 sub sp, #12 @ Align stack
268 bl artAllocObjectFromCode @ (uint32_t type_idx, Method* method)
269 add sp, #12
270 ldmia sp!, {lr} @ restore LR
271 cmp r0, #0 @ success if result is non-null
272 movne pc, lr @ return on success
273 @ set up for throwing exception
Ian Rogers15fdb8c2011-09-25 15:45:07 -0700274 SETUP_CALLEE_SAVE_FRAME
Ian Rogers21d9e832011-09-23 17:05:09 -0700275 mov r0, r9 @ pass Thread::Current
276 mov r1, sp @ pass SP
277 b artDeliverPendingExceptionFromCode @ artDeliverPendingExceptionFromCode(Thread*, SP)
278
Elliott Hughesb408de72011-10-04 14:35:05 -0700279 .global art_alloc_array_from_code
280 .extern artAllocArrayFromCode
Ian Rogersb886da82011-09-23 16:27:54 -0700281 /*
282 * Called by managed code to allocate an array
283 */
Elliott Hughesb408de72011-10-04 14:35:05 -0700284art_alloc_array_from_code:
Ian Rogersb886da82011-09-23 16:27:54 -0700285 str sp, [R9, #THREAD_TOP_OF_MANAGED_STACK_OFFSET] @ record top of stack and pc in case of
286 str lr, [R9, #THREAD_TOP_OF_MANAGED_STACK_PC_OFFSET] @ walking stack
287 stmdb sp!, {lr} @ Save LR
288 sub sp, #12 @ Align stack
Elliott Hughesb408de72011-10-04 14:35:05 -0700289 bl artAllocArrayFromCode @ (uint32_t type_idx, Method* method, int32_t component_count)
Ian Rogersb886da82011-09-23 16:27:54 -0700290 add sp, #12
291 ldmia sp!, {lr} @ restore LR
292 cmp r0, #0 @ success if result is non-null
293 movne pc, lr @ return on success
294 @ set up for throwing exception
Ian Rogers15fdb8c2011-09-25 15:45:07 -0700295 SETUP_CALLEE_SAVE_FRAME
Ian Rogersb886da82011-09-23 16:27:54 -0700296 mov r0, r9 @ pass Thread::Current
297 mov r1, sp @ pass SP
298 b artDeliverPendingExceptionFromCode @ artDeliverPendingExceptionFromCode(Thread*, SP)
299
Elliott Hughesb408de72011-10-04 14:35:05 -0700300 .global art_check_and_alloc_array_from_code
301 .extern artCheckAndAllocArrayFromCode
Ian Rogersb886da82011-09-23 16:27:54 -0700302 /*
303 * Called by managed code to allocate an array
304 */
Elliott Hughesb408de72011-10-04 14:35:05 -0700305art_check_and_alloc_array_from_code:
Ian Rogersb886da82011-09-23 16:27:54 -0700306 str sp, [R9, #THREAD_TOP_OF_MANAGED_STACK_OFFSET] @ record top of stack and pc in case of
307 str lr, [R9, #THREAD_TOP_OF_MANAGED_STACK_PC_OFFSET] @ walking stack
308 stmdb sp!, {lr} @ Save LR
309 sub sp, #12 @ Align stack
Elliott Hughesb408de72011-10-04 14:35:05 -0700310 bl artCheckAndAllocArrayFromCode @ (uint32_t type_idx, Method* method, int32_t count)
Ian Rogersb886da82011-09-23 16:27:54 -0700311 add sp, #12
312 ldmia sp!, {lr} @ restore LR
313 cmp r0, #0 @ success if result is non-null
314 movne pc, lr @ return on success
315 @ set up for throwing exception
316 stmdb sp!, {r1, r2, r3, r4, r5, r6, r7, r8, r9, r10, r11, lr}
317 sub sp, #16 @ 4 words of space, bottom word will hold Method*
318 mov r0, r9 @ pass Thread::Current
319 mov r1, sp @ pass SP
320 b artDeliverPendingExceptionFromCode @ artDeliverPendingExceptionFromCode(Thread*, SP)
321
buzbee54330722011-08-23 16:46:55 -0700322 .global art_shl_long
323art_shl_long:
324 /*
325 * Long integer shift. This is different from the generic 32/64-bit
326 * binary operations because vAA/vBB are 64-bit but vCC (the shift
327 * distance) is 32-bit. Also, Dalvik requires us to ignore all but the low
328 * 6 bits.
329 * On entry:
330 * r0: low word
331 * r1: high word
332 * r2: shift count
333 */
334 /* shl-long vAA, vBB, vCC */
335 and r2, r2, #63 @ r2<- r2 & 0x3f
336 mov r1, r1, asl r2 @ r1<- r1 << r2
337 rsb r3, r2, #32 @ r3<- 32 - r2
338 orr r1, r1, r0, lsr r3 @ r1<- r1 | (r0 << (32-r2))
339 subs ip, r2, #32 @ ip<- r2 - 32
340 movpl r1, r0, asl ip @ if r2 >= 32, r1<- r0 << (r2-32)
341 mov r0, r0, asl r2 @ r0<- r0 << r2
342 bx lr
343
344 .balign 4
345 .global art_shr_long
346art_shr_long:
347 /*
348 * Long integer shift. This is different from the generic 32/64-bit
349 * binary operations because vAA/vBB are 64-bit but vCC (the shift
350 * distance) is 32-bit. Also, Dalvik requires us to ignore all but the low
351 * 6 bits.
352 * On entry:
353 * r0: low word
354 * r1: high word
355 * r2: shift count
356 */
357 /* shr-long vAA, vBB, vCC */
358 and r2, r2, #63 @ r0<- r0 & 0x3f
359 mov r0, r0, lsr r2 @ r0<- r2 >> r2
360 rsb r3, r2, #32 @ r3<- 32 - r2
361 orr r0, r0, r1, asl r3 @ r0<- r0 | (r1 << (32-r2))
362 subs ip, r2, #32 @ ip<- r2 - 32
363 movpl r0, r1, asr ip @ if r2 >= 32, r0<-r1 >> (r2-32)
364 mov r1, r1, asr r2 @ r1<- r1 >> r2
365 bx lr
366
367 .balign 4
368 .global art_ushr_long
369art_ushr_long:
370 /*
371 * Long integer shift. This is different from the generic 32/64-bit
372 * binary operations because vAA/vBB are 64-bit but vCC (the shift
373 * distance) is 32-bit. Also, Dalvik requires us to ignore all but the low
374 * 6 bits.
375 * On entry:
376 * r0: low word
377 * r1: high word
378 * r2: shift count
379 */
380 /* ushr-long vAA, vBB, vCC */
381 and r2, r2, #63 @ r0<- r0 & 0x3f
382 mov r0, r0, lsr r2 @ r0<- r2 >> r2
383 rsb r3, r2, #32 @ r3<- 32 - r2
384 orr r0, r0, r1, asl r3 @ r0<- r0 | (r1 << (32-r2))
385 subs ip, r2, #32 @ ip<- r2 - 32
386 movpl r0, r1, lsr ip @ if r2 >= 32, r0<-r1 >>> (r2-32)
387 mov r1, r1, lsr r2 @ r1<- r1 >>> r2
388 bx lr
389
buzbeec1f45042011-09-21 16:03:19 -0700390 .balign 4
391 .global art_test_suspend
392 .extern artCheckSuspendFromCode
393art_test_suspend:
394 /*
395 * Check to see if there's a pending suspend request on our thread.
396 * reset rSUSPEND to SUSPEND_CHECK_INTERVAL.
397 * On entry, rSUSPEND holds the suspend request value
398 * [TUNING: move load of suspend check value into this stub.
399 */
400 cmp rSUSPEND, #0
401 mov rSUSPEND, #SUSPEND_CHECK_INTERVAL
402 bxeq rLR
403 mov r0, rSELF
404 b artCheckSuspendFromCode
405
406
buzbee54330722011-08-23 16:46:55 -0700407#endif
Ian Rogers67375ac2011-09-14 00:55:44 -0700408
409#if defined(__i386__)
410
Ian Rogersff1ed472011-09-20 13:46:24 -0700411 .global art_deliver_exception_from_code
412 .extern artDeliverExceptionFromCode
Ian Rogers67375ac2011-09-14 00:55:44 -0700413 /*
Ian Rogersff1ed472011-09-20 13:46:24 -0700414 * Called by managed code, saves callee saves and then calls artThrowException
Ian Rogers67375ac2011-09-14 00:55:44 -0700415 * that will place a mock Method* at the bottom of the stack.
416 * EAX holds the exception.
417 */
Ian Rogersff1ed472011-09-20 13:46:24 -0700418art_deliver_exception_from_code:
Ian Rogers67375ac2011-09-14 00:55:44 -0700419 // Create frame
420 pushl %edi // Save callee saves
421 pushl %esi
422 pushl %ebp
423 pushl %ebx
424 pushl $0
425 pushl $0
426 pushl $0 // Will be clobbered to be Method*
427 mov %esp, %ecx
428 // Outgoing argument set up
Ian Rogersff1ed472011-09-20 13:46:24 -0700429 pushl $0 // Alignment padding
430 pushl %ecx // pass SP
431 pushl %fs:THREAD_SELF_OFFSET // pass fs:offsetof(Thread,self_)
432 pushl %eax // pass Throwable*
433 call artDeliverExceptionFromCode // artDeliverExceptionFromCode(Throwable*, Thread*, SP)
Ian Rogers67375ac2011-09-14 00:55:44 -0700434 int3
435
436#endif