blob: 5b70fb761059c19ef61d37ef7ebf724dde20d43b [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 Rogers4f0d07c2011-10-06 23:38:47 -070012 /*
13 * Macro that sets up the callee save frame to conform with
14 * Runtime::CreateCalleeSaveMethod(kSaveAll)
15 */
Ian Rogers15fdb8c2011-09-25 15:45:07 -070016.macro SETUP_CALLEE_SAVE_FRAME
Ian Rogers4f0d07c2011-10-06 23:38:47 -070017 push {r4-r11, lr} @ 9 words of callee saves
Ian Rogers15fdb8c2011-09-25 15:45:07 -070018 vpush {s0-s31}
Ian Rogers4f0d07c2011-10-06 23:38:47 -070019 sub sp, #12 @ 3 words of space, bottom word will hold Method*
20.endm
21
22 /*
23 * Macro that sets up the callee save frame to conform with
24 * Runtime::CreateCalleeSaveMethod(kRefsOnly)
25 */
26.macro SETUP_REF_ONLY_CALLEE_SAVE_FRAME
27 push {r5-r8, r10-r11, lr} @ 7 words of callee saves
28 sub sp, #4 @ bottom word will hold Method*
29.endm
30
31.macro RESTORE_REF_ONLY_CALLEE_SAVE_FRAME
32 add sp, #4
33 pop {r5-r8, r10-r11, lr} @ 7 words of callee saves
34.endm
35
36.macro RESTORE_REF_ONLY_CALLEE_SAVE_FRAME_AND_RETURN
37 add sp, #4
38 pop {r5-r8, r10-r11, pc} @ 7 words of callee saves
39.endm
40
41 /*
42 * Macro that sets up the callee save frame to conform with
43 * Runtime::CreateCalleeSaveMethod(kRefsAndArgs)
44 */
45.macro SETUP_REF_AND_ARGS_CALLEE_SAVE_FRAME
46 push {r1-r3, r5-r8, r10-r11, lr} @ 10 words of callee saves
47 sub sp, #8 @ 2 words of space, bottom word will hold Method*
48.endm
49
50.macro RESTORE_REF_AND_ARGS_CALLEE_SAVE_FRAME
51 add sp, #8
52 pop {r1-r3, r5-r8, r10-r11, lr} @ 10 words of callee saves
Ian Rogers15fdb8c2011-09-25 15:45:07 -070053.endm
54
Ian Rogersff1ed472011-09-20 13:46:24 -070055 .global art_deliver_exception_from_code
Ian Rogersbdb03912011-09-14 00:55:44 -070056 /*
Ian Rogersff1ed472011-09-20 13:46:24 -070057 * Called by managed code, saves mosts registers (forms basis of long jump context) and passes
58 * the bottom of the stack. artDeliverExceptionFromCode will place the callee save Method* at
59 * the bottom of the thread. On entry r0 holds Throwable*
Ian Rogersbdb03912011-09-14 00:55:44 -070060 */
Ian Rogersff1ed472011-09-20 13:46:24 -070061art_deliver_exception_from_code:
Ian Rogers15fdb8c2011-09-25 15:45:07 -070062 SETUP_CALLEE_SAVE_FRAME
Ian Rogersff1ed472011-09-20 13:46:24 -070063 mov r1, r9 @ pass Thread::Current
64 mov r2, sp @ pass SP
65 b artDeliverExceptionFromCode @ artDeliverExceptionFromCode(Throwable*, Thread*, SP)
Ian Rogers9651f422011-09-19 20:26:07 -070066
67 .global art_throw_null_pointer_exception_from_code
Ian Rogersff1ed472011-09-20 13:46:24 -070068 .extern artThrowNullPointerExceptionFromCode
Ian Rogers9651f422011-09-19 20:26:07 -070069 /*
Ian Rogersff1ed472011-09-20 13:46:24 -070070 * Called by managed code to create and deliver a NullPointerException
Ian Rogers9651f422011-09-19 20:26:07 -070071 */
72art_throw_null_pointer_exception_from_code:
Ian Rogers15fdb8c2011-09-25 15:45:07 -070073 SETUP_CALLEE_SAVE_FRAME
Ian Rogersff1ed472011-09-20 13:46:24 -070074 mov r0, r9 @ pass Thread::Current
75 mov r1, sp @ pass SP
76 b artThrowNullPointerExceptionFromCode @ artThrowNullPointerExceptionFromCode(Thread*, SP)
Ian Rogers9651f422011-09-19 20:26:07 -070077
78 .global art_throw_div_zero_from_code
Ian Rogersff1ed472011-09-20 13:46:24 -070079 .extern artThrowDivZeroFromCode
Ian Rogers9651f422011-09-19 20:26:07 -070080 /*
Ian Rogersff1ed472011-09-20 13:46:24 -070081 * Called by managed code to create and deliver an ArithmeticException
Ian Rogers9651f422011-09-19 20:26:07 -070082 */
83art_throw_div_zero_from_code:
Ian Rogers15fdb8c2011-09-25 15:45:07 -070084 SETUP_CALLEE_SAVE_FRAME
Ian Rogersff1ed472011-09-20 13:46:24 -070085 mov r0, r9 @ pass Thread::Current
86 mov r1, sp @ pass SP
87 b artThrowDivZeroFromCode @ artThrowDivZeroFromCode(Thread*, SP)
Ian Rogers9651f422011-09-19 20:26:07 -070088
89 .global art_throw_array_bounds_from_code
Ian Rogersff1ed472011-09-20 13:46:24 -070090 .extern artThrowArrayBoundsFromCode
Ian Rogers9651f422011-09-19 20:26:07 -070091 /*
Ian Rogersff1ed472011-09-20 13:46:24 -070092 * Called by managed code to create and deliver an ArrayIndexOutOfBoundsException
Ian Rogers9651f422011-09-19 20:26:07 -070093 */
94art_throw_array_bounds_from_code:
Ian Rogers15fdb8c2011-09-25 15:45:07 -070095 SETUP_CALLEE_SAVE_FRAME
Ian Rogersff1ed472011-09-20 13:46:24 -070096 mov r2, r9 @ pass Thread::Current
97 mov r3, sp @ pass SP
98 b artThrowArrayBoundsFromCode @ artThrowArrayBoundsFromCode(index, limit, Thread*, SP)
Ian Rogersbdb03912011-09-14 00:55:44 -070099
Ian Rogers932746a2011-09-22 18:57:50 -0700100 .global art_throw_stack_overflow_from_code
101 .extern artThrowStackOverflowFromCode
102art_throw_stack_overflow_from_code:
Ian Rogers15fdb8c2011-09-25 15:45:07 -0700103 SETUP_CALLEE_SAVE_FRAME
Ian Rogers932746a2011-09-22 18:57:50 -0700104 mov r1, r9 @ pass Thread::Current
105 mov r2, sp @ pass SP
106 b artThrowStackOverflowFromCode @ artThrowStackOverflowFromCode(method, Thread*, SP)
107
Ian Rogersc0c8dc82011-09-24 18:15:59 -0700108 .global art_throw_neg_array_size_from_code
109 .extern artThrowNegArraySizeFromCode
110art_throw_neg_array_size_from_code:
Ian Rogers15fdb8c2011-09-25 15:45:07 -0700111 SETUP_CALLEE_SAVE_FRAME
Ian Rogersc0c8dc82011-09-24 18:15:59 -0700112 mov r1, r9 @ pass Thread::Current
113 mov r2, sp @ pass SP
114 b artThrowNegArraySizeFromCode @ artThrowNegArraySizeFromCode(size, Thread*, SP)
115
Ian Rogersc0c8dc82011-09-24 18:15:59 -0700116 .global art_throw_no_such_method_from_code
117 .extern artThrowNoSuchMethodFromCode
118art_throw_no_such_method_from_code:
Ian Rogers15fdb8c2011-09-25 15:45:07 -0700119 SETUP_CALLEE_SAVE_FRAME
Ian Rogersc0c8dc82011-09-24 18:15:59 -0700120 mov r1, r9 @ pass Thread::Current
121 mov r2, sp @ pass SP
122 b artThrowNoSuchMethodFromCode @ artThrowNoSuchMethodFromCode(method_idx, Thread*, SP)
123
Ian Rogersc0c8dc82011-09-24 18:15:59 -0700124 .global art_throw_verification_error_from_code
125 .extern artThrowVerificationErrorFromCode
126art_throw_verification_error_from_code:
Ian Rogers15fdb8c2011-09-25 15:45:07 -0700127 SETUP_CALLEE_SAVE_FRAME
Ian Rogersc0c8dc82011-09-24 18:15:59 -0700128 mov r2, r9 @ pass Thread::Current
129 mov r3, sp @ pass SP
Elliott Hughes6c8867d2011-10-03 16:34:05 -0700130 b artThrowVerificationErrorFromCode @ artThrowVerificationErrorFromCode(kind, ref, Thread*, SP)
Ian Rogersc0c8dc82011-09-24 18:15:59 -0700131
buzbee4a3164f2011-09-03 11:25:10 -0700132 .global art_invoke_interface_trampoline
Ian Rogersff1ed472011-09-20 13:46:24 -0700133 .extern artFindInterfaceMethodInCacheFromCode
buzbee4a3164f2011-09-03 11:25:10 -0700134 /*
Ian Rogersff1ed472011-09-20 13:46:24 -0700135 * All generated callsites for interface invokes will load arguments as usual - except instead
136 * of loading arg0/r0 with the target Method*, arg0/r0 will contain the method_idx. This
137 * wrapper will save arg1-arg3, load the caller's Method*, align the stack and call the helper
138 * artFindInterfaceMethodInCacheFromCode(idx, this, method);
139 * NOTE: "this" is first visable argument of the target, and so can be found in arg1/r1.
buzbee4a3164f2011-09-03 11:25:10 -0700140 *
Ian Rogersff1ed472011-09-20 13:46:24 -0700141 * artFindInterfaceMethodInCacheFromCode will attempt to locate the target and return a 64-bit
142 * result in r0/r1 consisting of the target Method* in r0 and method->code_ in r1.
buzbee4a3164f2011-09-03 11:25:10 -0700143 *
Ian Rogersff1ed472011-09-20 13:46:24 -0700144 * If unsuccessful, artFindInterfaceMethodInCacheFromCode will return NULL/NULL. There will be
145 * a pending exception in the thread and we branch to another stub to deliver it.
buzbee4a3164f2011-09-03 11:25:10 -0700146 *
Ian Rogersff1ed472011-09-20 13:46:24 -0700147 * On success this wrapper will restore arguments and *jump* to the target, leaving the lr
148 * pointing back to the original caller.
buzbee4a3164f2011-09-03 11:25:10 -0700149 */
Ian Rogersff1ed472011-09-20 13:46:24 -0700150art_invoke_interface_trampoline:
Ian Rogers4f0d07c2011-10-06 23:38:47 -0700151 SETUP_REF_AND_ARGS_CALLEE_SAVE_FRAME @ save callee saves in case allocation triggers GC
152 mov r2, r9 @ pass Thread::Current
153 mov r3, sp @ pass SP
154 bl artFindInterfaceMethodInCacheFromCode @ (method_idx, this, Thread*, SP)
155 mov r12, r1 @ save r0->code_
156 RESTORE_REF_AND_ARGS_CALLEE_SAVE_FRAME
157 cmp r0, #0 @ did we find the target?
158 bxne r12 @ tail call to target if so
159 SETUP_CALLEE_SAVE_FRAME @ set up for throwing exception
160 mov r0, r9 @ pass Thread::Current
161 mov r1, sp @ pass SP
162 b artDeliverPendingExceptionFromCode @ artDeliverPendingExceptionFromCode(Thread*, SP)
Ian Rogersff1ed472011-09-20 13:46:24 -0700163
164 .global art_handle_fill_data_from_code
165 .extern artHandleFillArrayDataFromCode
166 /*
167 * Entry from managed code that calls artHandleFillArrayDataFromCode and delivers exception on
168 * failure.
169 */
170art_handle_fill_data_from_code:
Ian Rogers4f0d07c2011-10-06 23:38:47 -0700171 SETUP_REF_ONLY_CALLEE_SAVE_FRAME @ save callee saves in case exception allocation triggers GC
172 mov r2, r9 @ pass Thread::Current
173 mov r3, sp @ pass SP
174 bl artHandleFillArrayDataFromCode @ (Array* array, const uint16_t* table, Thread*, SP)
175 RESTORE_REF_ONLY_CALLEE_SAVE_FRAME
176 cmp r0, #0 @ success?
177 moveq pc, lr @ return on success
178 SETUP_CALLEE_SAVE_FRAME @ set up for throwing exception
179 mov r0, r9 @ pass Thread::Current
180 mov r1, sp @ pass SP
181 b artDeliverPendingExceptionFromCode @ artDeliverPendingExceptionFromCode(Thread*, SP)
182
183 .global art_lock_object_from_code
184 .extern artLockObjectFromCode
185 /*
186 * Entry from managed code that calls artLockObjectFromCode, may block for GC
187 */
188art_lock_object_from_code:
189 SETUP_REF_ONLY_CALLEE_SAVE_FRAME @ save callee saves in case we block
190 mov r1, r9 @ pass Thread::Current
191 mov r2, sp @ pass SP
192 bl artLockObjectFromCode @ (Object* obj, Thread*, SP)
193 RESTORE_REF_ONLY_CALLEE_SAVE_FRAME_AND_RETURN
Ian Rogersff1ed472011-09-20 13:46:24 -0700194
195 .global art_unlock_object_from_code
196 .extern artUnlockObjectFromCode
197 /*
198 * Entry from managed code that calls artUnlockObjectFromCode and delivers exception on failure.
199 */
200art_unlock_object_from_code:
Ian Rogers4f0d07c2011-10-06 23:38:47 -0700201 SETUP_REF_ONLY_CALLEE_SAVE_FRAME @ save callee saves in case exception allocation triggers GC
202 mov r1, r9 @ pass Thread::Current
203 mov r2, sp @ pass SP
204 bl artUnlockObjectFromCode @ (Object* obj, Thread*, SP)
205 RESTORE_REF_ONLY_CALLEE_SAVE_FRAME
206 cmp r0, #0 @ success?
207 moveq pc, lr @ return on success
208 SETUP_CALLEE_SAVE_FRAME @ set up for throwing exception
209 mov r0, r9 @ pass Thread::Current
210 mov r1, sp @ pass SP
Ian Rogersff1ed472011-09-20 13:46:24 -0700211 b artDeliverPendingExceptionFromCode @ artDeliverPendingExceptionFromCode(Thread*, SP)
212
213 .global art_check_cast_from_code
214 .extern artCheckCastFromCode
215 /*
216 * Entry from managed code that calls artCheckCastFromCode and delivers exception on failure.
217 */
218art_check_cast_from_code:
Ian Rogers4f0d07c2011-10-06 23:38:47 -0700219 SETUP_REF_ONLY_CALLEE_SAVE_FRAME @ save callee saves in case exception allocation triggers GC
220 mov r2, r9 @ pass Thread::Current
221 mov r3, sp @ pass SP
222 bl artCheckCastFromCode @ (Class* a, Class* b, Thread*, SP)
223 RESTORE_REF_ONLY_CALLEE_SAVE_FRAME
224 cmp r0, #0 @ success?
225 moveq pc, lr @ return on success
226 SETUP_CALLEE_SAVE_FRAME @ set up for throwing exception
227 mov r0, r9 @ pass Thread::Current
228 mov r1, sp @ pass SP
229 b artDeliverPendingExceptionFromCode @ artDeliverPendingExceptionFromCode(Thread*, SP)
buzbee4a3164f2011-09-03 11:25:10 -0700230
Ian Rogerse51a5112011-09-23 14:16:35 -0700231 .global art_can_put_array_element_from_code
232 .extern artCanPutArrayElementFromCode
233 /*
234 * Entry from managed code that calls artCanPutArrayElementFromCode and delivers exception on
235 * failure.
236 */
237art_can_put_array_element_from_code:
Ian Rogers4f0d07c2011-10-06 23:38:47 -0700238 cmp r0, #0 @ return if element == NULL
Ian Rogerse51a5112011-09-23 14:16:35 -0700239 moveq pc, lr
Ian Rogers4f0d07c2011-10-06 23:38:47 -0700240 SETUP_REF_ONLY_CALLEE_SAVE_FRAME @ save callee saves in case exception allocation triggers GC
241 mov r2, r9 @ pass Thread::Current
242 mov r3, sp @ pass SP
243 bl artCanPutArrayElementFromCode @ (Object* element, Class* array_class, Thread*, SP)
244 RESTORE_REF_ONLY_CALLEE_SAVE_FRAME
245 cmp r0, #0 @ success?
246 moveq pc, lr @ return on success
247 SETUP_CALLEE_SAVE_FRAME @ set up for throwing exception
248 mov r0, r9 @ pass Thread::Current
249 mov r1, sp @ pass SP
Ian Rogerse51a5112011-09-23 14:16:35 -0700250 b artDeliverPendingExceptionFromCode @ artDeliverPendingExceptionFromCode(Thread*, SP)
251
Ian Rogerscbba6ac2011-09-22 16:28:37 -0700252 .global art_initialize_static_storage_from_code
Ian Rogers4f0d07c2011-10-06 23:38:47 -0700253 .extern artInitializeStaticStorageFromCode
Ian Rogerscbba6ac2011-09-22 16:28:37 -0700254 /*
255 * Entry from managed code when uninitialized static storage, this stub will run the class
256 * initializer and deliver the exception on error. On success the static storage base is
257 * returned.
258 */
259art_initialize_static_storage_from_code:
Ian Rogers4f0d07c2011-10-06 23:38:47 -0700260 SETUP_REF_ONLY_CALLEE_SAVE_FRAME @ save callee saves in case of GC
261 mov r2, r9 @ pass Thread::Current
262 mov r3, sp @ pass SP
263 @ ClassLinker::InitializeStaticStorageFromCode(uint32_t type_idx, Method* referrer, Thread*, SP)
264 bl artInitializeStaticStorageFromCode
265 RESTORE_REF_ONLY_CALLEE_SAVE_FRAME
266 cmp r0, #0 @ success if result is non-null
267 movne pc, lr @ return on success
268 SETUP_CALLEE_SAVE_FRAME @ set up for throwing exception
269 mov r0, r9 @ pass Thread::Current
270 mov r1, sp @ pass SP
271 b artDeliverPendingExceptionFromCode @ artDeliverPendingExceptionFromCode(Thread*, SP)
Ian Rogerscbba6ac2011-09-22 16:28:37 -0700272
Ian Rogers21d9e832011-09-23 17:05:09 -0700273 .global art_alloc_object_from_code
274 .extern artAllocObjectFromCode
275 /*
276 * Called by managed code to allocate an object
277 */
278art_alloc_object_from_code:
Ian Rogers4f0d07c2011-10-06 23:38:47 -0700279 SETUP_REF_ONLY_CALLEE_SAVE_FRAME @ save callee saves in case of GC
280 mov r2, r9 @ pass Thread::Current
281 mov r3, sp @ pass SP
282 bl artAllocObjectFromCode @ (uint32_t type_idx, Method* method, Thread*, SP)
283 RESTORE_REF_ONLY_CALLEE_SAVE_FRAME
284 cmp r0, #0 @ success if result is non-null
285 movne pc, lr @ return on success
286 SETUP_CALLEE_SAVE_FRAME @ set up for throwing exception
287 mov r0, r9 @ pass Thread::Current
288 mov r1, sp @ pass SP
Ian Rogers21d9e832011-09-23 17:05:09 -0700289 b artDeliverPendingExceptionFromCode @ artDeliverPendingExceptionFromCode(Thread*, SP)
290
Elliott Hughesb408de72011-10-04 14:35:05 -0700291 .global art_alloc_array_from_code
292 .extern artAllocArrayFromCode
Ian Rogersb886da82011-09-23 16:27:54 -0700293 /*
294 * Called by managed code to allocate an array
295 */
Elliott Hughesb408de72011-10-04 14:35:05 -0700296art_alloc_array_from_code:
Ian Rogers4f0d07c2011-10-06 23:38:47 -0700297 SETUP_REF_ONLY_CALLEE_SAVE_FRAME @ save callee saves in case of GC
298 mov r3, r9 @ pass Thread::Current
299 str sp, [sp, #0] @ pass SP
300 @ artAllocArrayFromCode(uint32_t type_idx, Method* method, int32_t component_count, Thread*, SP)
301 bl artAllocArrayFromCode
302 RESTORE_REF_ONLY_CALLEE_SAVE_FRAME
303 cmp r0, #0 @ success if result is non-null
304 movne pc, lr @ return on success
305 SETUP_CALLEE_SAVE_FRAME @ set up for throwing exception
306 mov r0, r9 @ pass Thread::Current
307 mov r1, sp @ pass SP
Ian Rogersb886da82011-09-23 16:27:54 -0700308 b artDeliverPendingExceptionFromCode @ artDeliverPendingExceptionFromCode(Thread*, SP)
309
Elliott Hughesb408de72011-10-04 14:35:05 -0700310 .global art_check_and_alloc_array_from_code
311 .extern artCheckAndAllocArrayFromCode
Ian Rogersb886da82011-09-23 16:27:54 -0700312 /*
313 * Called by managed code to allocate an array
314 */
Elliott Hughesb408de72011-10-04 14:35:05 -0700315art_check_and_alloc_array_from_code:
Ian Rogers4f0d07c2011-10-06 23:38:47 -0700316 SETUP_REF_ONLY_CALLEE_SAVE_FRAME @ save callee saves in case of GC
317 mov r3, r9 @ pass Thread::Current
318 str sp, [sp, #0] @ pass SP
319 @ artCheckAndAllocArrayFromCode(uint32_t type_idx, Method* method, int32_t count, Thread* , SP)
320 bl artCheckAndAllocArrayFromCode
321 RESTORE_REF_ONLY_CALLEE_SAVE_FRAME
Ian Rogersb886da82011-09-23 16:27:54 -0700322 cmp r0, #0 @ success if result is non-null
323 movne pc, lr @ return on success
Ian Rogers4f0d07c2011-10-06 23:38:47 -0700324 SETUP_CALLEE_SAVE_FRAME @ set up for throwing exception
Ian Rogersb886da82011-09-23 16:27:54 -0700325 mov r0, r9 @ pass Thread::Current
326 mov r1, sp @ pass SP
327 b artDeliverPendingExceptionFromCode @ artDeliverPendingExceptionFromCode(Thread*, SP)
328
Ian Rogers4f0d07c2011-10-06 23:38:47 -0700329 .global art_test_suspend
330 .extern artCheckSuspendFromCode
331art_test_suspend:
332 ldr r0, [rSELF, #THREAD_SUSPEND_COUNT_OFFSET]
333 mov rSUSPEND, #SUSPEND_CHECK_INTERVAL @ reset rSUSPEND to SUSPEND_CHECK_INTERVAL
334 cmp r0, #0 @ check Thread::Current()->suspend_count_ == 0
335 bxeq rLR @ return if suspend_count_ == 0
336 mov r0, rSELF
337 mov r1, sp
338 SETUP_REF_ONLY_CALLEE_SAVE_FRAME @ save callee saves for stack crawl
339 bl artCheckSuspendFromCode @ (Thread*, SP)
340 RESTORE_REF_ONLY_CALLEE_SAVE_FRAME_AND_RETURN
341
buzbee54330722011-08-23 16:46:55 -0700342 .global art_shl_long
343art_shl_long:
344 /*
345 * Long integer shift. This is different from the generic 32/64-bit
346 * binary operations because vAA/vBB are 64-bit but vCC (the shift
347 * distance) is 32-bit. Also, Dalvik requires us to ignore all but the low
348 * 6 bits.
349 * On entry:
350 * r0: low word
351 * r1: high word
352 * r2: shift count
353 */
354 /* shl-long vAA, vBB, vCC */
355 and r2, r2, #63 @ r2<- r2 & 0x3f
356 mov r1, r1, asl r2 @ r1<- r1 << r2
357 rsb r3, r2, #32 @ r3<- 32 - r2
358 orr r1, r1, r0, lsr r3 @ r1<- r1 | (r0 << (32-r2))
359 subs ip, r2, #32 @ ip<- r2 - 32
360 movpl r1, r0, asl ip @ if r2 >= 32, r1<- r0 << (r2-32)
361 mov r0, r0, asl r2 @ r0<- r0 << r2
362 bx lr
363
364 .balign 4
365 .global art_shr_long
366art_shr_long:
367 /*
368 * Long integer shift. This is different from the generic 32/64-bit
369 * binary operations because vAA/vBB are 64-bit but vCC (the shift
370 * distance) is 32-bit. Also, Dalvik requires us to ignore all but the low
371 * 6 bits.
372 * On entry:
373 * r0: low word
374 * r1: high word
375 * r2: shift count
376 */
377 /* shr-long vAA, vBB, vCC */
378 and r2, r2, #63 @ r0<- r0 & 0x3f
379 mov r0, r0, lsr r2 @ r0<- r2 >> r2
380 rsb r3, r2, #32 @ r3<- 32 - r2
381 orr r0, r0, r1, asl r3 @ r0<- r0 | (r1 << (32-r2))
382 subs ip, r2, #32 @ ip<- r2 - 32
383 movpl r0, r1, asr ip @ if r2 >= 32, r0<-r1 >> (r2-32)
384 mov r1, r1, asr r2 @ r1<- r1 >> r2
385 bx lr
386
387 .balign 4
388 .global art_ushr_long
389art_ushr_long:
390 /*
391 * Long integer shift. This is different from the generic 32/64-bit
392 * binary operations because vAA/vBB are 64-bit but vCC (the shift
393 * distance) is 32-bit. Also, Dalvik requires us to ignore all but the low
394 * 6 bits.
395 * On entry:
396 * r0: low word
397 * r1: high word
398 * r2: shift count
399 */
400 /* ushr-long vAA, vBB, vCC */
401 and r2, r2, #63 @ r0<- r0 & 0x3f
402 mov r0, r0, lsr r2 @ r0<- r2 >> r2
403 rsb r3, r2, #32 @ r3<- 32 - r2
404 orr r0, r0, r1, asl r3 @ r0<- r0 | (r1 << (32-r2))
405 subs ip, r2, #32 @ ip<- r2 - 32
406 movpl r0, r1, lsr ip @ if r2 >= 32, r0<-r1 >>> (r2-32)
407 mov r1, r1, lsr r2 @ r1<- r1 >>> r2
408 bx lr
409
410#endif
Ian Rogers67375ac2011-09-14 00:55:44 -0700411
412#if defined(__i386__)
413
Ian Rogersff1ed472011-09-20 13:46:24 -0700414 .global art_deliver_exception_from_code
415 .extern artDeliverExceptionFromCode
Ian Rogers67375ac2011-09-14 00:55:44 -0700416 /*
Ian Rogersff1ed472011-09-20 13:46:24 -0700417 * Called by managed code, saves callee saves and then calls artThrowException
Ian Rogers67375ac2011-09-14 00:55:44 -0700418 * that will place a mock Method* at the bottom of the stack.
419 * EAX holds the exception.
420 */
Ian Rogersff1ed472011-09-20 13:46:24 -0700421art_deliver_exception_from_code:
Ian Rogers67375ac2011-09-14 00:55:44 -0700422 // Create frame
423 pushl %edi // Save callee saves
424 pushl %esi
425 pushl %ebp
426 pushl %ebx
427 pushl $0
428 pushl $0
429 pushl $0 // Will be clobbered to be Method*
430 mov %esp, %ecx
431 // Outgoing argument set up
Ian Rogersff1ed472011-09-20 13:46:24 -0700432 pushl $0 // Alignment padding
433 pushl %ecx // pass SP
434 pushl %fs:THREAD_SELF_OFFSET // pass fs:offsetof(Thread,self_)
435 pushl %eax // pass Throwable*
436 call artDeliverExceptionFromCode // artDeliverExceptionFromCode(Throwable*, Thread*, SP)
Ian Rogers67375ac2011-09-14 00:55:44 -0700437 int3
438
439#endif